Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trinitymirrordigital/cue-templates-plugin

Package Overview
Dependencies
Maintainers
19
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trinitymirrordigital/cue-templates-plugin

Webpack plugin to create cue component yml

  • 1.3.1-alpha.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
19
Weekly downloads
 
Created
Source

@trinitymirrordigital/cue-templates-plugin

This sets up a Webpack plug that creates the cue configuration yaml from JS comments

Installation

  yarn add --dev @trinitymirrordigital/cue-templates-plugin

Config

Update your config.yml with the following:

default: &default
 ...

  # Templates plugin
  templates_path: template # folder with web component templates are
  yaml_output: /etc/escenic/cue-web # where the yaml files are outputted in docker image
  start_up_script: /usr/bin/startup.sh # startup script fired when dev-server starts

  ...

Then in webpack config add the following

/* eslint-env node */
const { TemplatePlugin, getFiles } = require('@trinitymirrordigital/cue-templates-plugin');
const { webpackConfig, config } = require('@trinitymirrordigital/webpack-config');
const { merge } = require('webpack-merge');
const { env } = require('process');

// See reach-et-templates-plugin
const files = getFiles(config); // Gets the template files
// Use config data
const {
  cueUrl,
  publicDevOutput,
  publicOutputPath,
  publicRootPath,
  startUpScript,
  yamlOutput,
} = config;

const publicPath = env.NODE_ENV === 'development' ? publicDevOutput : publicOutputPath; // Sets the path depending if using webpack-dev-server or not

// You can pass any webpack config you want that will append to the config please see https://webpack.js.org/
module.exports = merge(webpackConfig, {
  entry: { ...files },
  plugins: [
    // See  reach-et-templates-plugin
    new TemplatePlugin({
      js: publicRootPath, // Sets path to file
      publicPath, // Sets path for output JS
      output: yamlOutput, // sets path for output YAML
      shellScript: startUpScript, // Shell script for webpack dev server see below
    }),
  ],
  new HtmlWebpackPlugin({
      filename: htmlOutput,
      alwaysWriteToDisk: true,
      template: htmlTemplate,
      excludeChunks: Object.keys(files), // Stops Templates being added to index.html as it is added by CUE
    }),
  ]
});

Shell script

As CUE requires the YAML files before starting it is important that the YML file are created before CUE has started. In production this is fine, however as the webpack-dev-server is always building we need to ensure they created first so you should add something like this too the entry.sh:

if [ "${ENVIRONMENT_NAME}" == "dev" ]
then
  cd /var/www/html/cue-web && npm run webpack:server # see stratup.sh which runs after build step
else
  cd /var/www/html/cue-web && npm run webpack && \
  sed -i "s|CUE_URL|${CUE_URL}|" /etc/escenic/cue-web/config.yml
  # CUE set up
  dpkg-reconfigure cue-web-3.7
  /etc/init.d/content-duplication-service start
  nginx -g "daemon off;"
  rm -rf /var/www/html/cue-web/node_modules # kills node_modules
fi

then in the start.sh

#!/usr/bin/env bash
unlink /var/log/nginx/error.log && unlink /var/log/nginx/access.log
sed -i "s|CUE_URL|${CUE_URL}|" /etc/escenic/cue-web/config.yml
echo 'adding CUE_URL'
dpkg-reconfigure cue-web-3.7
/etc/init.d/content-duplication-service start
# nginx -g "daemon off;"
service nginx start

Creating YAML comments

Then in the webcomponet please add the following comment at the top of your file:

/* ** yml-create bookmark

*/

So yml-create let's the plugin know this is a for creating a yaml config, the name after is the name of the yaml file so this one will create bookmark.yml.

Then the config should be expressed in JSON, the exception is the file name:

FILE: [my - web - component - file];

This will allow webpack to replace with a the correct cache busted file.

Then add you config as a json string like so:

/* ** yml-create bookmark
  {
    "sidePanels":[{
      "id":"book-mark",
      "name":"Bookmark",
      "directive":"cue-custom-panel-loader",
      "isAngular":true,
      "webComponent":{
        "icon":"bookmark-icon",
        "modulePath": FILE:[bookmark]
      },
      "mimeTypes":["*\/*"],
      "homeScreen":true,
      "metadata":[],
      "active":false,
      "order":1250
    }]
  }
*/

Copyright (c) 2019 "Reach Shared Services Ltd"

FAQs

Package last updated on 14 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc