@evoke-platform/plugin-scripts
Advanced tools
| #!/usr/bin/env node | ||
| // Copyright (c) 2023 System Automation Corporation. | ||
| // This file is licensed under the MIT License. | ||
| 'use strict'; | ||
| const path = require('path'); | ||
| const packageJson = require(path.resolve(process.cwd(), './package.json')); | ||
| (async () => { | ||
| const fs = require('fs'); | ||
| //1. Read from the "widgets" folder | ||
| const folderName = path.resolve(process.cwd(), 'src/widgets'); | ||
| const getWidgetProperties = async (widgetsList) => { | ||
| const temp = []; | ||
| console.log(''); | ||
| for await (const widget of widgetsList) { | ||
| try { | ||
| const widget_folder_path = path.join(folderName, widget); | ||
| const WidgetProperties = require(`${widget_folder_path}/WidgetProperties.json`); | ||
| WidgetProperties.src = 'src/widgets/' + widget; | ||
| temp.push(WidgetProperties); | ||
| console.info(WidgetProperties.name + ' widget -- READ'); | ||
| } catch (e) { | ||
| if (e.code === 'ERR_MODULE_NOT_FOUND') | ||
| console.error(widget + ' widget -- WidgetProperties not defined.'); | ||
| else console.error('ERROR while reading properties for ' + widget + ':: ', e); | ||
| continue; | ||
| } | ||
| } | ||
| return temp; | ||
| }; | ||
| try { | ||
| let widgetsList = []; | ||
| fs.accessSync(folderName, fs.constants.R_OK); | ||
| widgetsList = fs.readdirSync(folderName).map((widget) => widget); | ||
| let WidgetProperties = await getWidgetProperties(widgetsList); | ||
| console.log(''); | ||
| const outputJSON = { | ||
| name: packageJson.name, | ||
| description: '', | ||
| widgets: WidgetProperties, | ||
| }; | ||
| if (!fs.existsSync('./dist')) { | ||
| fs.mkdirSync('./dist'); | ||
| } | ||
| fs.writeFileSync('./dist/manifest.json', JSON.stringify(outputJSON, null, 2), 'utf-8', (err) => { | ||
| if (err) console.error('Manifest generation error::', err); | ||
| }); | ||
| console.info('manifest.json created'); | ||
| } catch (error) { | ||
| console.error('Error while generating manifest.json::', error); | ||
| } | ||
| })(); |
+3
-2
| { | ||
| "name": "@evoke-platform/plugin-scripts", | ||
| "version": "1.0.0-dev.12", | ||
| "version": "1.0.0-dev.13", | ||
| "description": "Scripts for managing an Evoke platform plugin project", | ||
@@ -15,3 +15,4 @@ "homepage": "https://github.com/Evoke-Platform/evoke-sdk/blob/main/packages/plugin-scripts/README.md", | ||
| "bin": { | ||
| "pkgplugin": "./bin/package-plugin.js" | ||
| "pkgplugin": "./bin/package-plugin.js", | ||
| "manifestgen": "./bin/generate-manifest.js" | ||
| }, | ||
@@ -18,0 +19,0 @@ "main": "dist/index.js", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6553
49.17%5
25%94
118.6%3
200%