lucid-package 0.0.99 → 0.0.100
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 +1 -1
- package/src/editorextension.d.ts +5 -3
- package/src/editorextension.js +31 -8
- package/src/index.js +11 -1
package/package.json
CHANGED
package/src/editorextension.d.ts
CHANGED
|
@@ -6,15 +6,17 @@ export declare function updateExtensionSDK(name: string): Promise<void>;
|
|
|
6
6
|
* Uses webpack to watch for changes in the editor extension
|
|
7
7
|
* @param name The editor extension name
|
|
8
8
|
* @param quiet If true, will only show errors in output
|
|
9
|
+
* @param ignoreNodeModules If true, while serving, will not autoreload on changes to node_modules files
|
|
9
10
|
*/
|
|
10
|
-
export declare function watchEditorExtension(name: string, isInternal: boolean, quiet?: boolean): Promise<{
|
|
11
|
+
export declare function watchEditorExtension(name: string, isInternal: boolean, quiet?: boolean, ignoreNodeModules?: boolean): Promise<{
|
|
11
12
|
name: string;
|
|
12
13
|
compiler: Compiler;
|
|
13
14
|
}>;
|
|
14
15
|
/**
|
|
15
|
-
* Runs the editor extensions and shape libraries in debug mode, including watching code for changes.
|
|
16
|
+
* Runs the editor extensions and shape libraries in debug mode, possibly including watching code for changes.
|
|
16
17
|
* @param extensionNames The names of the editor extensions
|
|
17
18
|
* @param quiet If true, will only show errors in output
|
|
19
|
+
* @param watchIgnoreNodeModules If true, while serving, will not autoreload on changes to node_modules files
|
|
18
20
|
*/
|
|
19
|
-
export declare function debugEditorExtension(extensionNames: string[], isInternal: boolean, quiet?: boolean, pickAnyPort?: boolean): Promise<void>;
|
|
21
|
+
export declare function debugEditorExtension(extensionNames: string[], isInternal: boolean, quiet?: boolean, pickAnyPort?: boolean, watchIgnoreNodeModules?: boolean): Promise<void>;
|
|
20
22
|
export declare function getAllExtensionNames(): Promise<string[]>;
|
package/src/editorextension.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllExtensionNames = exports.debugEditorExtension = exports.watchEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
4
5
|
const express = require("express");
|
|
5
6
|
const oldFs = require("fs");
|
|
6
7
|
const fs = require("fs/promises");
|
|
8
|
+
const checks_1 = require("lucid-extension-sdk/sdk/core/checks");
|
|
7
9
|
const path = require("path");
|
|
8
10
|
const cors_1 = require("./cors");
|
|
9
11
|
const filesystemutil_1 = require("./filesystemutil");
|
|
@@ -13,7 +15,6 @@ const packagemanifest_1 = require("./packagemanifest");
|
|
|
13
15
|
const shapelibrary_1 = require("./shapelibrary");
|
|
14
16
|
const shellutil_1 = require("./shellutil");
|
|
15
17
|
const supportedproduct_1 = require("./supportedproduct");
|
|
16
|
-
const child_process_1 = require("child_process");
|
|
17
18
|
const theme_1 = require("./theme");
|
|
18
19
|
const webpack = require('webpack');
|
|
19
20
|
const WebPackCLI = require('webpack-cli');
|
|
@@ -64,8 +65,9 @@ exports.updateExtensionSDK = updateExtensionSDK;
|
|
|
64
65
|
* Uses webpack to watch for changes in the editor extension
|
|
65
66
|
* @param name The editor extension name
|
|
66
67
|
* @param quiet If true, will only show errors in output
|
|
68
|
+
* @param ignoreNodeModules If true, while serving, will not autoreload on changes to node_modules files
|
|
67
69
|
*/
|
|
68
|
-
async function watchEditorExtension(name, isInternal, quiet = false) {
|
|
70
|
+
async function watchEditorExtension(name, isInternal, quiet = false, ignoreNodeModules = false) {
|
|
69
71
|
const originalDirectory = process.cwd();
|
|
70
72
|
const extensionCodePath = path.join('editorextensions', await getExtensionCodeDirectoryName(name));
|
|
71
73
|
process.chdir(extensionCodePath);
|
|
@@ -77,8 +79,26 @@ async function watchEditorExtension(name, isInternal, quiet = false) {
|
|
|
77
79
|
if (quiet) {
|
|
78
80
|
webpackConfig.stats = 'errors-only';
|
|
79
81
|
}
|
|
82
|
+
if (ignoreNodeModules) {
|
|
83
|
+
// It's possible that `ignored` isn't defined yet, or is a single object
|
|
84
|
+
// So if needed, we create and modify objects, so they can be added to
|
|
85
|
+
// (For more info: https://webpack.js.org/configuration/watch/#watchoptionsignored)
|
|
86
|
+
if (!(0, checks_1.isDef)(webpackConfig.watchOptions)) {
|
|
87
|
+
webpackConfig.watchOptions = {};
|
|
88
|
+
}
|
|
89
|
+
let directoriesToIgnore = webpackConfig.watchOptions.ignored;
|
|
90
|
+
if (!(0, checks_1.isDef)(directoriesToIgnore)) {
|
|
91
|
+
directoriesToIgnore = [];
|
|
92
|
+
}
|
|
93
|
+
if (!(0, checks_1.isArray)(directoriesToIgnore)) {
|
|
94
|
+
directoriesToIgnore = [directoriesToIgnore];
|
|
95
|
+
}
|
|
96
|
+
directoriesToIgnore = ['**/node_modules', ...directoriesToIgnore];
|
|
97
|
+
webpackConfig.watchOptions = { ...webpackConfig.watchOptions, ignored: directoriesToIgnore };
|
|
98
|
+
}
|
|
80
99
|
const compiler = webpack(webpackConfig);
|
|
81
|
-
|
|
100
|
+
const watchOptions = webpackConfig.watchOptions ?? {};
|
|
101
|
+
compiler.watch(watchOptions, (err, stats) => {
|
|
82
102
|
console.log(stats?.toString({ colors: true }));
|
|
83
103
|
});
|
|
84
104
|
process.chdir(originalDirectory);
|
|
@@ -86,13 +106,14 @@ async function watchEditorExtension(name, isInternal, quiet = false) {
|
|
|
86
106
|
}
|
|
87
107
|
exports.watchEditorExtension = watchEditorExtension;
|
|
88
108
|
/**
|
|
89
|
-
* Runs the editor extensions and shape libraries in debug mode, including watching code for changes.
|
|
109
|
+
* Runs the editor extensions and shape libraries in debug mode, possibly including watching code for changes.
|
|
90
110
|
* @param extensionNames The names of the editor extensions
|
|
91
111
|
* @param quiet If true, will only show errors in output
|
|
112
|
+
* @param watchIgnoreNodeModules If true, while serving, will not autoreload on changes to node_modules files
|
|
92
113
|
*/
|
|
93
|
-
async function debugEditorExtension(extensionNames, isInternal, quiet = false, pickAnyPort = false) {
|
|
114
|
+
async function debugEditorExtension(extensionNames, isInternal, quiet = false, pickAnyPort = false, watchIgnoreNodeModules = false) {
|
|
94
115
|
const port = 9900;
|
|
95
|
-
const watchers = await Promise.all(extensionNames.map(async (name) => watchEditorExtension(name, isInternal, quiet)));
|
|
116
|
+
const watchers = await Promise.all(extensionNames.map(async (name) => watchEditorExtension(name, isInternal, quiet, watchIgnoreNodeModules)));
|
|
96
117
|
startCustomUIServers(extensionNames);
|
|
97
118
|
const app = express();
|
|
98
119
|
const server = listen(app, port, pickAnyPort);
|
|
@@ -315,7 +336,7 @@ function getExtensionProducts(product, products) {
|
|
|
315
336
|
async function getAllExtensionNames() {
|
|
316
337
|
const manifest = await (0, packagemanifest_1.readManifest)('local');
|
|
317
338
|
if (manifest.extensions) {
|
|
318
|
-
return manifest.extensions.map(extn => extn.name);
|
|
339
|
+
return manifest.extensions.map((extn) => extn.name);
|
|
319
340
|
}
|
|
320
341
|
else {
|
|
321
342
|
return [];
|
|
@@ -325,7 +346,9 @@ exports.getAllExtensionNames = getAllExtensionNames;
|
|
|
325
346
|
async function startCustomUIServers(extensionNames) {
|
|
326
347
|
for (let extensionName of extensionNames) {
|
|
327
348
|
const extensionCodePath = path.resolve(path.join('editorextensions', await getExtensionCodeDirectoryName(extensionName)));
|
|
328
|
-
const potentialCustomUIServer = (await fs.readdir(extensionCodePath, { withFileTypes: true }))
|
|
349
|
+
const potentialCustomUIServer = (await fs.readdir(extensionCodePath, { withFileTypes: true }))
|
|
350
|
+
.filter((dirent) => dirent.isDirectory())
|
|
351
|
+
.map((dirent) => path.join(extensionCodePath, dirent.name));
|
|
329
352
|
for (let potentialPaths of potentialCustomUIServer) {
|
|
330
353
|
runNpmStartIfExists(potentialPaths);
|
|
331
354
|
}
|
package/src/index.js
CHANGED
|
@@ -79,6 +79,11 @@ class LucidSuiteExtensionCLI {
|
|
|
79
79
|
action: 'store_true',
|
|
80
80
|
help: argparse_1.SUPPRESS,
|
|
81
81
|
});
|
|
82
|
+
testExtensionParser.add_argument('--watch-ignore-node-modules', {
|
|
83
|
+
default: false,
|
|
84
|
+
action: 'store_true',
|
|
85
|
+
help: 'Do not recompile extension when files in node_modules are changed',
|
|
86
|
+
});
|
|
82
87
|
const watchExtensionParser = subparsers.add_parser('watch-editor-extension', {
|
|
83
88
|
help: 'Compile an editor extension in debug mode',
|
|
84
89
|
});
|
|
@@ -88,6 +93,11 @@ class LucidSuiteExtensionCLI {
|
|
|
88
93
|
action: 'store_true',
|
|
89
94
|
help: argparse_1.SUPPRESS,
|
|
90
95
|
});
|
|
96
|
+
watchExtensionParser.add_argument('--watch-ignore-node-modules', {
|
|
97
|
+
default: false,
|
|
98
|
+
action: 'store_true',
|
|
99
|
+
help: 'Do not recompile extension when files in node_modules are changed',
|
|
100
|
+
});
|
|
91
101
|
const testShapeLibraries = subparsers.add_parser('test-shape-libraries', {
|
|
92
102
|
help: 'Serve any shape libraries in this package at localhost:9901. Watch for changes to the code and live-update as needed',
|
|
93
103
|
});
|
|
@@ -228,7 +238,7 @@ class LucidSuiteExtensionCLI {
|
|
|
228
238
|
if (parsed['name'].length === 0) {
|
|
229
239
|
parsed['name'] = await (0, editorextension_1.getAllExtensionNames)();
|
|
230
240
|
}
|
|
231
|
-
await (0, editorextension_1.debugEditorExtension)(parsed['name'], isInternal, parsed['quiet'], parsed['anyport']);
|
|
241
|
+
await (0, editorextension_1.debugEditorExtension)(parsed['name'], isInternal, parsed['quiet'], parsed['anyport'], parsed['watch_ignore_node_modules']);
|
|
232
242
|
break;
|
|
233
243
|
case 'watch-editor-extension':
|
|
234
244
|
await (0, editorextension_1.watchEditorExtension)(parsed['name'], isInternal, parsed['quiet']);
|