Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@evoke-platform/plugin-scripts

Package Overview
Dependencies
Maintainers
2
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evoke-platform/plugin-scripts - npm Package Compare versions

Comparing version
1.0.0-dev.7
to
1.0.0-dev.8
+2
-8
package.json
{
"name": "@evoke-platform/plugin-scripts",
"version": "1.0.0-dev.7",
"version": "1.0.0-dev.8",
"description": "Scripts for managing an Evoke platform plugin project",

@@ -15,3 +15,2 @@ "homepage": "https://github.com/Evoke-Platform/evoke-sdk/blob/main/packages/plugin-scripts/README.md",

"bin": {
"genmanifest": "./bin/generate-manifest.js",
"pkgplugin": "./bin/package-plugin.js"

@@ -26,3 +25,2 @@ },

"scripts": {
"build": "tsc",
"release": "commit-and-tag-version -t plugin-scripts@ --releaseCommitMessageFormat \"chore(release): plugin-scripts@{{currentTag}} [skip ci]\"",

@@ -35,8 +33,4 @@ "predeploy": "cp ../../LICENSE .",

"dependencies": {
"@evoke-platform/plugin-runtime": "^1.0.0-dev.0",
"glob": "^9.3.2",
"jszip": "^3.10.0",
"mkdirp": "^2.1.6",
"tmp-promise": "^3.0.3",
"typescript": "^5.0.2"
"mkdirp": "^2.1.6"
},

@@ -43,0 +37,0 @@ "devDependencies": {

#!/usr/bin/env node
// Copyright (c) 2023 System Automation Corporation.
// This file is licensed under the MIT License.
'use strict';
const fs = require('fs');
const path = require('path');
const debug = require('debug')('plugin-scripts:generate-manifest');
const glob = require('glob').glob;
const { mkdirp } = require('mkdirp');
const Plugin = require('@evoke-platform/plugin-runtime');
const ts = require('typescript');
const tmp = require('tmp-promise');
const { compile, readCompilerOptions } = require('../dist');
async function main() {
const packageJson = require(`${process.cwd()}/package.json`);
const tmpdir = 'tmp';
await mkdirp(tmpdir);
Plugin.startWidgetDeclarations(packageJson.version);
await tmp.withDir(
async (outDir) => {
const config = readCompilerOptions();
const rootDir = config.rootDir || 'src';
config.rootDir = rootDir;
await compileProject(config, outDir.path);
await scan(outDir.path, rootDir);
},
{ unsafeCleanup: true, tmpdir },
);
const widgets = Plugin.getWidgets();
if (widgets.length === 0) {
console.log('No widgets detected, aborting');
process.exit(2);
}
printWidgets(widgets);
validateWidgets(widgets);
const manifest = createManifest(packageJson, widgets);
const manifestPath = 'dist/manifest.json';
await mkdirp('dist');
saveManifest(manifest, manifestPath);
console.log(`Manifest generated at ${manifestPath}`);
}
async function compileProject(config, outDir) {
config.outDir = outDir;
config.module = ts.ModuleKind.CommonJS;
config.skipLibCheck = true;
await compile(config);
}
async function scan(dir, rootDir) {
debug(`Scanning ${dir} for widgets...`);
const files = await glob(`${dir}/**/*.js`, { withFileTypes: true });
if (!files.length) {
debug('no source files matching *.js found');
}
for (const file of files) {
const relativePath = path.relative(dir, file.fullpath());
let importModule;
debug('scanning file %s', relativePath);
Plugin.context.modulePath = `${rootDir}/${stripExtension(relativePath)}`;
const widgetCount = Plugin.getWidgets().length;
try {
importModule = require(file.fullpath());
} catch (err) {
console.error(`Error parsing ${file}: ${err}`);
debug(err);
}
const newWidgets = Plugin.getWidgets().length - widgetCount;
debug('found %d widgets', newWidgets);
if (newWidgets > 1) {
throw new Error(`Multiple widgets declared in ${relativePath}, make sure each widget has its own module`);
} else if (newWidgets === 1) {
debug('default export is %s', typeof importModule.default);
if (typeof importModule.default !== 'function') {
throw new Error(
`No widget exported in ${relativePath}, make sure widgets are exported as the default export`,
);
}
}
}
}
function stripExtension(filePath) {
const parsedPath = path.parse(filePath);
const extLength = parsedPath.ext?.length ?? 0;
return filePath.substring(0, filePath.length - extLength);
}
function printWidgets(widgets) {
for (const widget of widgets) {
console.log(`Detected widget ${widget.id} (${widget.name})`);
}
}
function validateWidgets(widgets) {
const widgetIds = new Set();
for (const widget of widgets) {
if (widgetIds.has(widget.id)) {
console.error(`Duplicate widget id ${widget.id}, each widget must have a unique id!`);
process.exit(3);
}
}
}
function createManifest(packageJson, widgets) {
return {
name: packageJson.name,
description: packageJson.description,
widgets,
};
}
async function saveManifest(manifest, path) {
await fs.promises.writeFile(path, JSON.stringify(manifest, undefined, 2), 'utf-8');
}
main().catch((err) => {
console.error(err);
});
import { CompilerOptions } from 'typescript';
export declare function compile(options: CompilerOptions): Promise<void>;
"use strict";
// Copyright (c) 2023 System Automation Corporation.
// This file is licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.compile = void 0;
const glob_1 = require("glob");
const typescript_1 = require("typescript");
const logger_1 = require("./logger");
async function compile(options) {
const rootDir = options.rootDir || 'src';
(0, logger_1.debug)('using root dir %s', rootDir);
const files = await (0, glob_1.glob)(`${rootDir}/**/*.{ts,tsx}`);
(0, logger_1.debug)('discovered %O', files);
const program = (0, typescript_1.createProgram)({
rootNames: files,
options,
});
const result = program.emit();
const diagnostics = (0, typescript_1.getPreEmitDiagnostics)(program).concat(result.diagnostics);
for (const diagnostic of diagnostics) {
let output;
if (diagnostic.file && diagnostic.start) {
const { line, character } = (0, typescript_1.getLineAndCharacterOfPosition)(diagnostic.file, diagnostic.start);
const msg = (0, typescript_1.flattenDiagnosticMessageText)(diagnostic.messageText, '\n');
output = `${diagnostic.file.fileName} (${line + 1}:${character + 1}): ${msg}`;
}
else {
output = (0, typescript_1.flattenDiagnosticMessageText)(diagnostic.messageText, '\n');
}
console.log(output);
}
if (result.emitSkipped) {
throw new Error('Compilation errors');
}
}
exports.compile = compile;
//# sourceMappingURL=compiler.js.map
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/compiler/compiler.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,+CAA+C;;;AAE/C,+BAA4B;AAC5B,2CAMoB;AACpB,qCAAiC;AAE1B,KAAK,UAAU,OAAO,CAAC,OAAwB;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IAEzC,IAAA,cAAK,EAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IAEpC,MAAM,KAAK,GAAG,MAAM,IAAA,WAAI,EAAC,GAAG,OAAO,gBAAgB,CAAC,CAAC;IAErD,IAAA,cAAK,EAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,IAAA,0BAAa,EAAC;QAC1B,SAAS,EAAE,KAAK;QAChB,OAAO;KACV,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC9B,MAAM,WAAW,GAAG,IAAA,kCAAqB,EAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE9E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,IAAI,MAAc,CAAC;QAEnB,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE;YACrC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAA,0CAA6B,EAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAC7F,MAAM,GAAG,GAAG,IAAA,yCAA4B,EAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YAEvE,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;SACjF;aAAM;YACH,MAAM,GAAG,IAAA,yCAA4B,EAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACvB;IAED,IAAI,MAAM,CAAC,WAAW,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACzC;AACL,CAAC;AAnCD,0BAmCC"}
export declare function readCompilerOptions(): import("typescript").CompilerOptions;
"use strict";
// Copyright (c) 2023 System Automation Corporation.
// This file is licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.readCompilerOptions = void 0;
const typescript_1 = require("typescript");
const logger_1 = require("./logger");
function readCompilerOptions() {
const configFilePath = (0, typescript_1.findConfigFile)('./', typescript_1.sys.fileExists, 'tsconfig.json');
if (!configFilePath) {
throw new Error('Unable to find tsconfig.json');
}
(0, logger_1.debug)('using config from %s', configFilePath);
const configFile = (0, typescript_1.readConfigFile)(configFilePath, typescript_1.sys.readFile);
if (configFile.error) {
const msg = typeof configFile.error.messageText === 'string'
? configFile.error.messageText
: configFile.error.messageText.messageText;
throw new Error(`Error in tsconfig.json: ${msg}`);
}
const config = (0, typescript_1.parseJsonConfigFileContent)(configFile.config, typescript_1.sys, './');
return config.options;
}
exports.readCompilerOptions = readCompilerOptions;
//# sourceMappingURL=config.js.map
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/compiler/config.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,+CAA+C;;;AAE/C,2CAA6F;AAC7F,qCAAiC;AAEjC,SAAgB,mBAAmB;IAC/B,MAAM,cAAc,GAAG,IAAA,2BAAc,EAAC,IAAI,EAAE,gBAAG,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAE7E,IAAI,CAAC,cAAc,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACnD;IAED,IAAA,cAAK,EAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;IAE9C,MAAM,UAAU,GAAG,IAAA,2BAAc,EAAC,cAAc,EAAE,gBAAG,CAAC,QAAQ,CAAC,CAAC;IAEhE,IAAI,UAAU,CAAC,KAAK,EAAE;QAClB,MAAM,GAAG,GACL,OAAO,UAAU,CAAC,KAAK,CAAC,WAAW,KAAK,QAAQ;YAC5C,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW;YAC9B,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC;QAEnD,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;KACrD;IAED,MAAM,MAAM,GAAG,IAAA,uCAA0B,EAAC,UAAU,CAAC,MAAM,EAAE,gBAAG,EAAE,IAAI,CAAC,CAAC;IAExE,OAAO,MAAM,CAAC,OAAO,CAAC;AAC1B,CAAC;AAvBD,kDAuBC"}
export * from './compiler';
export * from './config';
"use strict";
// Copyright (c) 2023 System Automation Corporation.
// This file is licensed under the MIT License.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./compiler"), exports);
__exportStar(require("./config"), exports);
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compiler/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,+CAA+C;;;;;;;;;;;;;;;;AAE/C,6CAA2B;AAC3B,2CAAyB"}
import _debug from 'debug';
export declare const debug: _debug.Debugger;
"use strict";
// Copyright (c) 2023 System Automation Corporation.
// This file is licensed under the MIT License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.debug = void 0;
const debug_1 = __importDefault(require("debug"));
exports.debug = (0, debug_1.default)('plugin-scripts:compiler');
//# sourceMappingURL=logger.js.map
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/compiler/logger.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,+CAA+C;;;;;;AAE/C,kDAA2B;AAEd,QAAA,KAAK,GAAG,IAAA,eAAM,EAAC,yBAAyB,CAAC,CAAC"}
export * from './compiler';
"use strict";
// Copyright (c) 2023 System Automation Corporation.
// This file is licensed under the MIT License.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./compiler"), exports);
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,+CAA+C;;;;;;;;;;;;;;;;AAE/C,6CAA2B"}