lucid-package 0.0.91 → 0.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.91",
3
+ "version": "0.0.92",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  "@inquirer/input": "^1.2.14",
27
27
  "@inquirer/select": "^1.3.1",
28
28
  "argparse": "^2.0.1",
29
+ "chalk": "4.1.2",
29
30
  "chokidar": "^3.5.3",
30
31
  "express": "^4.17.1",
31
32
  "hjson": "^3.2.2",
@@ -6,13 +6,14 @@ const path = require("path");
6
6
  const editorextension_1 = require("./editorextension");
7
7
  const installationutil_1 = require("./installationutil");
8
8
  const package_1 = require("./package");
9
+ const theme_1 = require("./theme");
9
10
  async function createAngularEditorExtension(name, isInternalTesting, skipSDKDependency) {
10
11
  await (0, editorextension_1.createEditorExtension)(name, isInternalTesting, skipSDKDependency, path.join('angular', 'skeleton'), [
11
12
  'webpack-shell-plugin-next',
12
13
  ]);
13
14
  const angularProjectName = name;
14
15
  const angularEditorExtensionTargetFolder = path.join(process.cwd(), angularProjectName);
15
- console.log('Creating Angular project in ' + angularEditorExtensionTargetFolder);
16
+ console.log((0, theme_1.success)('Creating Angular project in ' + angularEditorExtensionTargetFolder));
16
17
  (0, installationutil_1.installAngularProject)(angularProjectName);
17
18
  const webpackConfig = (await fs.readFile('webpack.config.js', 'utf8')).replace('<<dynamicname>>', angularProjectName);
18
19
  const extensionTemplateCode = (await fs.readFile(path.join('src', 'extension.ts'), 'utf8')).replace('<<dynamicname>>', angularProjectName);
@@ -5,8 +5,9 @@ const path = require("path");
5
5
  const filesystemutil_1 = require("./filesystemutil");
6
6
  const installationutil_1 = require("./installationutil");
7
7
  const package_1 = require("./package");
8
+ const theme_1 = require("./theme");
8
9
  async function createDataConnector(name, isInternalTesting, skipSDKDependency) {
9
- console.log('Creating data connector in dataconnectors/' + name);
10
+ console.log((0, theme_1.success)('Creating data connector in dataconnectors/' + name));
10
11
  const source = path.join(__dirname, '..', 'templates', 'dataconnector');
11
12
  const targetFolder = path.join('dataconnectors', name);
12
13
  (0, filesystemutil_1.copyFolderRecursiveSync)(source, targetFolder);
@@ -17,3 +17,4 @@ export declare function watchEditorExtension(name: string, isInternalTesting: bo
17
17
  * @param quiet If true, will only show errors in output
18
18
  */
19
19
  export declare function debugEditorExtension(extensionNames: string[], isInternalTesting: boolean, quiet?: boolean, pickAnyPort?: boolean): Promise<void>;
20
+ export declare function getAllExtensionNames(): Promise<string[]>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debugEditorExtension = exports.watchEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
3
+ exports.getAllExtensionNames = exports.debugEditorExtension = exports.watchEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
4
4
  const express = require("express");
5
5
  const oldFs = require("fs");
6
6
  const fs = require("fs/promises");
@@ -13,6 +13,8 @@ const packagemanifest_1 = require("./packagemanifest");
13
13
  const shapelibrary_1 = require("./shapelibrary");
14
14
  const shellutil_1 = require("./shellutil");
15
15
  const supportedproduct_1 = require("./supportedproduct");
16
+ const child_process_1 = require("child_process");
17
+ const theme_1 = require("./theme");
16
18
  const webpack = require('webpack');
17
19
  const WebPackCLI = require('webpack-cli');
18
20
  const ws = require('ws');
@@ -23,7 +25,7 @@ async function createEditorExtension(name, isInternalTesting, skipSDKDependency,
23
25
  const publicSource = path.join(__dirname, '..', 'templates', 'public');
24
26
  const publicTargetFolder = 'public';
25
27
  const codePath = path.join('editorextensions', name, 'bin', 'extension.js');
26
- console.log('Creating empty editor extension in ' + editorExtensionTargetFolder);
28
+ console.log((0, theme_1.success)('Creating empty editor extension in ' + editorExtensionTargetFolder));
27
29
  (0, filesystemutil_1.copyFolderRecursiveSync)(editorExtensionSource, editorExtensionTargetFolder);
28
30
  (0, filesystemutil_1.copyFolderRecursiveSync)(publicSource, publicTargetFolder);
29
31
  await (0, package_1.modifyManifest)((manifest) => {
@@ -54,7 +56,7 @@ exports.buildEditorExtension = buildEditorExtension;
54
56
  async function updateExtensionSDK(name) {
55
57
  const extensionCodePath = path.join('editorextensions', await getExtensionCodeDirectoryName(name));
56
58
  process.chdir(extensionCodePath);
57
- console.log('Installing latest SDK in extension ' + name);
59
+ console.log((0, theme_1.success)('Installing latest SDK in extension ' + name));
58
60
  console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install lucid-extension-sdk@latest').toString());
59
61
  }
60
62
  exports.updateExtensionSDK = updateExtensionSDK;
@@ -91,6 +93,7 @@ exports.watchEditorExtension = watchEditorExtension;
91
93
  async function debugEditorExtension(extensionNames, isInternalTesting, quiet = false, pickAnyPort = false) {
92
94
  const port = 9900;
93
95
  const watchers = await Promise.all(extensionNames.map(async (name) => watchEditorExtension(name, isInternalTesting, quiet)));
96
+ startCustomUIServers(extensionNames);
94
97
  const app = express();
95
98
  const server = listen(app, port, pickAnyPort);
96
99
  setupWebSockets(server);
@@ -203,7 +206,7 @@ exports.debugEditorExtension = debugEditorExtension;
203
206
  function listen(app, port, pickAnyPort) {
204
207
  return app
205
208
  .listen(port, 'localhost', () => {
206
- console.log('Listening at http://localhost:' + port + '/extension.js');
209
+ console.log((0, theme_1.success)('Listening at http://localhost:' + port + '/extension.js'));
207
210
  (0, shapelibrary_1.debugShapeLibraries)(undefined, pickAnyPort);
208
211
  })
209
212
  .on('error', (err) => {
@@ -309,3 +312,53 @@ function getExtensionProducts(product, products) {
309
312
  }
310
313
  throw new Error('Either "product" or "products" must be spcified for the editor extension in the package manifest');
311
314
  }
315
+ async function getAllExtensionNames() {
316
+ const manifest = await (0, packagemanifest_1.readManifest)('local');
317
+ if (manifest.extensions) {
318
+ return manifest.extensions.map(extn => extn.name);
319
+ }
320
+ else {
321
+ return [];
322
+ }
323
+ }
324
+ exports.getAllExtensionNames = getAllExtensionNames;
325
+ async function startCustomUIServers(extensionNames) {
326
+ for (let extensionName of extensionNames) {
327
+ const extensionCodePath = path.resolve(path.join('editorextensions', await getExtensionCodeDirectoryName(extensionName)));
328
+ const potentialCustomUIServer = (await fs.readdir(extensionCodePath, { withFileTypes: true })).filter(dirent => dirent.isDirectory()).map(dirent => path.join(extensionCodePath, dirent.name));
329
+ for (let potentialPaths of potentialCustomUIServer) {
330
+ runNpmStartIfExists(potentialPaths);
331
+ }
332
+ }
333
+ }
334
+ async function runNpmStartIfExists(directoryPath) {
335
+ try {
336
+ // Read the package.json file
337
+ const packageJsonPath = path.join(directoryPath, 'package.json');
338
+ if (oldFs.existsSync(packageJsonPath)) {
339
+ const packageJson = await fs.readFile(packageJsonPath, 'utf-8');
340
+ const packageData = JSON.parse(packageJson);
341
+ // Check if package.json has "scripts" object and it contains "start"
342
+ if (packageData && packageData.scripts && packageData.scripts.start) {
343
+ console.log((0, theme_1.success)(`Found npm start script in ${directoryPath}.`));
344
+ // Execute npm start
345
+ const npmStart = (0, child_process_1.spawn)('npm', ['start'], { cwd: directoryPath, stdio: ['inherit', 'pipe', 'pipe'] });
346
+ npmStart.stdout.on('data', (data) => {
347
+ process.stdout.write(data);
348
+ });
349
+ npmStart.stderr.on('data', (data) => {
350
+ process.stderr.write(data);
351
+ });
352
+ npmStart.on('exit', (code) => {
353
+ console.log(`npm start process exited with code ${code}`);
354
+ });
355
+ }
356
+ else {
357
+ console.log(`No npm start script found in ${directoryPath}.`);
358
+ }
359
+ }
360
+ }
361
+ catch (error) {
362
+ console.error(error(`Error occurred: ${error.message}`));
363
+ }
364
+ }
package/src/index.js CHANGED
@@ -219,6 +219,9 @@ class LucidSuiteExtensionCLI {
219
219
  await (0, shapelibrary_1.debugShapeLibraries)();
220
220
  break;
221
221
  case 'test-editor-extension':
222
+ if (parsed['name'].length === 0) {
223
+ parsed['name'] = await (0, editorextension_1.getAllExtensionNames)();
224
+ }
222
225
  await (0, editorextension_1.debugEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet'], parsed['anyport']);
223
226
  break;
224
227
  case 'watch-editor-extension':
@@ -4,6 +4,7 @@ exports.installAngularProject = exports.installReactProject = exports.installDep
4
4
  const oldFs = require("fs");
5
5
  const path = require("path");
6
6
  const shellutil_1 = require("./shellutil");
7
+ const theme_1 = require("./theme");
7
8
  function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false, additionalDependencies = []) {
8
9
  if (!oldFs.existsSync('node_modules')) {
9
10
  console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
@@ -14,7 +15,7 @@ function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = fals
14
15
  oldFs.rmSync(sdkDir, { recursive: true, force: true });
15
16
  }
16
17
  else if (!oldFs.existsSync(sdkDir) && !skipSDKDependency) {
17
- console.log('Adding dependency on SDK');
18
+ console.log((0, theme_1.success)('Adding dependency on SDK'));
18
19
  console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --save lucid-extension-sdk').toString());
19
20
  }
20
21
  if (additionalDependencies.length) {
package/src/package.js CHANGED
@@ -11,8 +11,9 @@ const filesystemutil_1 = require("./filesystemutil");
11
11
  const packagemanifest_1 = require("./packagemanifest");
12
12
  const shapelibrary_1 = require("./shapelibrary");
13
13
  const shellutil_1 = require("./shellutil");
14
+ const theme_1 = require("./theme");
14
15
  async function createEmptyPackage(root) {
15
- console.log('Creating Lucid Suite package in ' + root);
16
+ console.log((0, theme_1.success)('Creating Lucid Suite package in ' + root));
16
17
  const source = path.join(__dirname, '..', 'templates', 'package');
17
18
  (0, filesystemutil_1.copyFolderRecursiveSync)(source, root);
18
19
  }
@@ -81,7 +82,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
81
82
  const parts = extension['codePath'].split(path.sep);
82
83
  if (parts[0] === 'editorextensions') {
83
84
  //Can't just call the method, as the WebpackCLI class does process.exit(2) :facepalm:
84
- console.log(`Compiling editor extension ${parts[1]}`);
85
+ console.log((0, theme_1.success)(`Compiling editor extension ${parts[1]}`));
85
86
  // Quotes are needed around every use of a path to deal with spaces
86
87
  const cmd = '"' +
87
88
  process.argv[0] +
@@ -101,7 +102,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
101
102
  for (const library of manifest['shapeLibraries'] || []) {
102
103
  const parts = library['lcszPath'].split(path.sep);
103
104
  if (parts[0] === 'shapelibraries') {
104
- console.log(`Building shape library ${parts[1]}`);
105
+ console.log((0, theme_1.success)(`Building shape library ${parts[1]}`));
105
106
  await (0, shapelibrary_1.buildShapeLibrary)(parts[1].replace('.lcsz', ''));
106
107
  }
107
108
  zip.file(library['lcszPath'], await fs.readFile(library['lcszPath']));
@@ -143,7 +144,7 @@ async function writePackage(quiet = false, manifestOverrideEnv) {
143
144
  compression: 'DEFLATE',
144
145
  compressionOptions: { level: 9 },
145
146
  });
146
- console.log('Writing file package.zip');
147
+ console.log((0, theme_1.success)('Writing file package.zip'));
147
148
  const fileName = `package${manifestOverrideEnv ? `-${manifestOverrideEnv}` : ''}.zip`;
148
149
  await fs.writeFile(fileName, zipBytes);
149
150
  }, manifestOverrideEnv);
@@ -6,6 +6,7 @@ const path = require("path");
6
6
  const editorextension_1 = require("./editorextension");
7
7
  const installationutil_1 = require("./installationutil");
8
8
  const package_1 = require("./package");
9
+ const theme_1 = require("./theme");
9
10
  async function createReactEditorExtension(name, flavor, isInternalTesting, skipSDKDependency) {
10
11
  await (0, editorextension_1.createEditorExtension)(name, isInternalTesting, skipSDKDependency, path.join('react', 'skeleton'), [
11
12
  'webpack-shell-plugin-next',
@@ -18,13 +19,13 @@ async function createReactEditorExtension(name, flavor, isInternalTesting, skipS
18
19
  typescript = true;
19
20
  }
20
21
  else {
21
- console.log('Unexpected flavor type');
22
+ console.log((0, theme_1.error)('Unexpected flavor type'));
22
23
  return;
23
24
  }
24
25
  const reactProjectName = name;
25
26
  const reactEditorExtensionTargetFolder = path.join(process.cwd(), reactProjectName);
26
27
  const publicTargetFolder = path.join(process.cwd(), '..', '..', 'public');
27
- console.log('Creating React project in ' + reactEditorExtensionTargetFolder);
28
+ console.log((0, theme_1.success)('Creating React project in ' + reactEditorExtensionTargetFolder));
28
29
  (0, installationutil_1.installReactProject)(reactProjectName, typescript);
29
30
  await fs.mkdir(path.join(publicTargetFolder, name));
30
31
  await copyFilesTo(path.join(reactEditorExtensionTargetFolder, 'public'), path.join(publicTargetFolder, name), [
@@ -10,6 +10,7 @@ const cors_1 = require("./cors");
10
10
  const filesystemutil_1 = require("./filesystemutil");
11
11
  const package_1 = require("./package");
12
12
  const packagemanifest_1 = require("./packagemanifest");
13
+ const theme_1 = require("./theme");
13
14
  const hjson = require('hjson');
14
15
  const ws = require('ws');
15
16
  const chokidar = require('chokidar');
@@ -17,7 +18,7 @@ const sizeOf = require('image-size');
17
18
  async function createEmptyShapeLibrary(name) {
18
19
  const source = path.join(__dirname, '..', 'templates', 'shapelibrary');
19
20
  const targetFolder = path.join('shapelibraries', name);
20
- console.log('Creating shape library in ' + targetFolder);
21
+ console.log((0, theme_1.success)('Creating shape library in ' + targetFolder));
21
22
  (0, filesystemutil_1.copyFolderRecursiveSync)(source, targetFolder);
22
23
  await (0, package_1.modifyManifest)((manifest) => {
23
24
  if (!manifest['shapeLibraries']) {
@@ -32,7 +33,7 @@ async function createEmptyShapeLibrary(name) {
32
33
  }
33
34
  exports.createEmptyShapeLibrary = createEmptyShapeLibrary;
34
35
  async function createImageShapeLibrary(name, imagePath, config) {
35
- console.log('Creating image shape library in ' + path.join('shapelibraries', name));
36
+ console.log((0, theme_1.success)('Creating image shape library in ' + path.join('shapelibraries', name)));
36
37
  if (!fsSync.lstatSync(imagePath).isDirectory()) {
37
38
  console.error('The provided path `' + imagePath + '` is not a folder');
38
39
  return;
@@ -58,7 +59,7 @@ async function createImageShapeLibrary(name, imagePath, config) {
58
59
  console.log('dimen of ' + file + ': ' + dimen + ' - ' + JSON.stringify(dimen));
59
60
  }
60
61
  catch (e) {
61
- console.log('No dimensions found for ' + file);
62
+ console.log((0, theme_1.error)('No dimensions found for ' + file));
62
63
  }
63
64
  }
64
65
  const lockedArray = [];
@@ -249,7 +250,7 @@ async function buildShapeLibrary(name) {
249
250
  };
250
251
  await addToZip(`shapelibraries/${name}`);
251
252
  const zipBytes = await zip.generateAsync({ type: 'uint8array' });
252
- console.log(`Writing file ${name}.lcsz`);
253
+ console.log((0, theme_1.success)(`Writing file ${name}.lcsz`));
253
254
  await fs.writeFile(`shapelibraries/${name}.lcsz`, zipBytes);
254
255
  }
255
256
  exports.buildShapeLibrary = buildShapeLibrary;
@@ -305,7 +306,7 @@ async function debugShapeLibraries(packagePath = '.', pickAnyPort = false) {
305
306
  });
306
307
  const listen = () => {
307
308
  const server = app.listen(port, 'localhost', () => {
308
- console.log('Listening at http://localhost:' + port + '/shapeLibraries');
309
+ console.log((0, theme_1.success)('Listening at http://localhost:' + port + '/shapeLibraries'));
309
310
  //Watch for any shape library changes, and inform watchers that they need to refresh them.
310
311
  const wss = new ws.Server({ server, path: '/shapeLibraries/changes' });
311
312
  const sockets = [];
package/src/shellutil.js CHANGED
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execSyncLoggingOutputOnError = void 0;
4
4
  const child_process = require("child_process");
5
+ const theme_1 = require("./theme");
5
6
  function execSyncLoggingOutputOnError(cmd) {
6
7
  try {
7
8
  return child_process.execSync(cmd);
8
9
  }
9
10
  catch (e) {
10
- console.log(String(e.stdout));
11
- console.error(String(e.stderr));
11
+ console.log((0, theme_1.error)(String(e.stdout)));
12
+ console.error((0, theme_1.error)(String(e.stderr)));
12
13
  throw e;
13
14
  }
14
15
  }
package/src/theme.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const error: any;
2
+ export declare const warning: any;
3
+ export declare const success: any;
package/src/theme.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.success = exports.warning = exports.error = void 0;
4
+ const chalk = require("chalk");
5
+ exports.error = chalk.bold.red;
6
+ exports.warning = chalk.hex('#FFA500');
7
+ exports.success = chalk.greenBright;
@@ -0,0 +1,16 @@
1
+ {
2
+ "scripts": {
3
+ "create-editor-extension":"npx lucid-package create-editor-extension",
4
+ "create-shape-library":"npx lucid-package create-shape-library",
5
+ "create-data-connector":"npx lucid-package create-data-connector",
6
+ "create-image-shape-library":"npx lucid-package create-image-shape-library",
7
+
8
+ "test-editor-extension":"npx lucid-package test-editor-extension",
9
+ "test-shape-libraries":"npx lucid-package test-shape-libraries",
10
+ "test": "npx lucid-package test-editor-extension",
11
+
12
+ "start": "npx lucid-package test-editor-extension",
13
+
14
+ "bundle":"npx lucid-package bundle"
15
+ }
16
+ }