lucid-package 0.0.28 → 0.0.30
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.js +9 -8
- package/src/package.js +4 -4
- package/src/packagemanifest.d.ts +1 -1
- package/src/packagemanifest.js +38 -1
- package/src/shapelibrary.js +2 -2
- package/src/shellutil.d.ts +2 -0
- package/src/shellutil.js +15 -0
package/package.json
CHANGED
package/src/editorextension.js
CHANGED
|
@@ -10,6 +10,7 @@ const child_process = require("child_process");
|
|
|
10
10
|
const shapelibrary_1 = require("./shapelibrary");
|
|
11
11
|
const packagemanifest_1 = require("./packagemanifest");
|
|
12
12
|
const path = require("path");
|
|
13
|
+
const shellutil_1 = require("./shellutil");
|
|
13
14
|
const WebPackCLI = require('webpack-cli');
|
|
14
15
|
function linkInternalTestingSDK() {
|
|
15
16
|
if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
|
|
@@ -19,12 +20,12 @@ function linkInternalTestingSDK() {
|
|
|
19
20
|
const sdkPath = cwd.substr(0, pos + rootSearch.length) + 'lucid-extension-sdk';
|
|
20
21
|
const relativePath = path.relative(cwd, sdkPath);
|
|
21
22
|
console.log('Using symlink for dependency on SDK for internal testing');
|
|
22
|
-
console.log(
|
|
23
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install --silent --save ${relativePath}`).toString());
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
function installDependenciesIfNeeded(isInternalTesting) {
|
|
26
27
|
if (!oldFs.existsSync('node_modules')) {
|
|
27
|
-
console.log(
|
|
28
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
|
|
28
29
|
}
|
|
29
30
|
if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
|
|
30
31
|
if (isInternalTesting) {
|
|
@@ -32,7 +33,7 @@ function installDependenciesIfNeeded(isInternalTesting) {
|
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
35
|
console.log('Adding dependency on SDK');
|
|
35
|
-
console.log(
|
|
36
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --save lucid-extension-sdk').toString());
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -66,7 +67,7 @@ exports.buildEditorExtension = buildEditorExtension;
|
|
|
66
67
|
async function updateExtensionSDK(name) {
|
|
67
68
|
process.chdir('editorextensions/' + name);
|
|
68
69
|
console.log('Installing latest SDK in extension ' + name);
|
|
69
|
-
console.log(
|
|
70
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install lucid-extension-sdk@latest').toString());
|
|
70
71
|
}
|
|
71
72
|
exports.updateExtensionSDK = updateExtensionSDK;
|
|
72
73
|
/**
|
|
@@ -113,12 +114,12 @@ async function debugEditorExtension(extensionNames, quiet = false) {
|
|
|
113
114
|
app.get(['/scopes', '/editorextension/:name/scopes'], async (req, res) => {
|
|
114
115
|
var _a, _b, _c;
|
|
115
116
|
const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
|
|
116
|
-
const manifest = await (0, packagemanifest_1.readManifest)();
|
|
117
|
+
const manifest = await (0, packagemanifest_1.readManifest)(true);
|
|
117
118
|
res.send(JSON.stringify((_c = (_b = manifest['extensions']) === null || _b === void 0 ? void 0 : _b.find((extension) => extension['name'] === name)) === null || _c === void 0 ? void 0 : _c.scopes));
|
|
118
119
|
});
|
|
119
120
|
app.get('/packageId', async (req, res) => {
|
|
120
121
|
var _a;
|
|
121
|
-
const manifest = await (0, packagemanifest_1.readManifest)();
|
|
122
|
+
const manifest = await (0, packagemanifest_1.readManifest)(true);
|
|
122
123
|
res.send((_a = manifest['id']) !== null && _a !== void 0 ? _a : '__local__');
|
|
123
124
|
});
|
|
124
125
|
app.get(['/editorextension', '/editorextension/:name'], async (req, res) => {
|
|
@@ -134,7 +135,7 @@ async function debugEditorExtension(extensionNames, quiet = false) {
|
|
|
134
135
|
var _a;
|
|
135
136
|
const name = req.params['name'];
|
|
136
137
|
if (name) {
|
|
137
|
-
const manifest = await (0, packagemanifest_1.readManifest)();
|
|
138
|
+
const manifest = await (0, packagemanifest_1.readManifest)(true);
|
|
138
139
|
const provider = (_a = manifest['oauthProviders']) === null || _a === void 0 ? void 0 : _a.find((one) => one.name === name);
|
|
139
140
|
if (provider && oldFs.existsSync(`${name}.credentials.local`)) {
|
|
140
141
|
const credentials = JSON.parse((await fs.readFile(`${name}.credentials.local`)).toString());
|
|
@@ -156,7 +157,7 @@ async function debugEditorExtension(extensionNames, quiet = false) {
|
|
|
156
157
|
exports.debugEditorExtension = debugEditorExtension;
|
|
157
158
|
async function getRawEditorExtension(name) {
|
|
158
159
|
var _a, _b, _c, _d;
|
|
159
|
-
const manifest = await (0, packagemanifest_1.readManifest)();
|
|
160
|
+
const manifest = await (0, packagemanifest_1.readManifest)(true);
|
|
160
161
|
const extensionManifest = (_a = manifest['extensions']) === null || _a === void 0 ? void 0 : _a.find((one) => one['name'] === name);
|
|
161
162
|
return {
|
|
162
163
|
id: '__local__',
|
package/src/package.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writePackage = exports.updateAllExtensionSDK = exports.modifyManifest = exports.currentlyInPackage = exports.createEmptyPackage = void 0;
|
|
4
|
-
const child_process = require("child_process");
|
|
5
4
|
const fsOld = require("fs");
|
|
6
5
|
const fs = require("fs/promises");
|
|
7
6
|
const JSZip = require("jszip");
|
|
@@ -9,6 +8,7 @@ const editorextension_1 = require("./editorextension");
|
|
|
9
8
|
const filesystemutil_1 = require("./filesystemutil");
|
|
10
9
|
const packagemanifest_1 = require("./packagemanifest");
|
|
11
10
|
const shapelibrary_1 = require("./shapelibrary");
|
|
11
|
+
const shellutil_1 = require("./shellutil");
|
|
12
12
|
async function createEmptyPackage(root) {
|
|
13
13
|
console.log('Creating empty Lucid Suite package in ' + root);
|
|
14
14
|
(0, filesystemutil_1.copyFolderRecursiveSync)(__dirname + '/../templates/package', root);
|
|
@@ -20,13 +20,13 @@ function currentlyInPackage() {
|
|
|
20
20
|
exports.currentlyInPackage = currentlyInPackage;
|
|
21
21
|
const allScopes = new Set(['DOWNLOAD', 'NETWORK', 'READ', 'SHOW_MODAL', 'CUSTOM_UI', 'WRITE']);
|
|
22
22
|
async function modifyManifest(callback) {
|
|
23
|
-
const manifest = await (0, packagemanifest_1.readManifest)();
|
|
23
|
+
const manifest = await (0, packagemanifest_1.readManifest)(false);
|
|
24
24
|
await callback(manifest);
|
|
25
25
|
await fs.writeFile('manifest.json', JSON.stringify(manifest, undefined, 2));
|
|
26
26
|
}
|
|
27
27
|
exports.modifyManifest = modifyManifest;
|
|
28
28
|
async function updateAllExtensionSDK() {
|
|
29
|
-
const manifest = await (0, packagemanifest_1.readManifest)();
|
|
29
|
+
const manifest = await (0, packagemanifest_1.readManifest)(false);
|
|
30
30
|
for (const extension of manifest['extensions'] || []) {
|
|
31
31
|
const parts = extension['codePath'].split('/');
|
|
32
32
|
if (parts[0] === 'editorextensions') {
|
|
@@ -66,7 +66,7 @@ async function writePackage(quiet = false) {
|
|
|
66
66
|
parts[1] +
|
|
67
67
|
'"';
|
|
68
68
|
console.log(cmd);
|
|
69
|
-
console.log(
|
|
69
|
+
console.log((0, shellutil_1.execSyncLoggingOutputOnError)(cmd).toString());
|
|
70
70
|
}
|
|
71
71
|
zip.file(extension['codePath'], await fs.readFile(extension['codePath']));
|
|
72
72
|
}
|
package/src/packagemanifest.d.ts
CHANGED
|
@@ -28,4 +28,4 @@ export declare type PackageManifest = {
|
|
|
28
28
|
'callbackEvents': string[];
|
|
29
29
|
}[];
|
|
30
30
|
};
|
|
31
|
-
export declare function readManifest(path?: string): Promise<PackageManifest>;
|
|
31
|
+
export declare function readManifest(includeLocalOverrides: boolean, path?: string): Promise<PackageManifest>;
|
package/src/packagemanifest.js
CHANGED
|
@@ -106,8 +106,45 @@ function validateManifestOrThrow(manifest) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
function deepMixin(target, mixin) {
|
|
110
|
+
if ((0, checks_1.isArray)(target) && (0, checks_1.isArray)(mixin)) {
|
|
111
|
+
for (let i = 0; i < mixin.length; i++) {
|
|
112
|
+
const value = mixin[i];
|
|
113
|
+
if (i >= target.length) {
|
|
114
|
+
target[i] = value;
|
|
115
|
+
}
|
|
116
|
+
else if ((0, checks_1.isObject)(value) || (0, checks_1.isArray)(value)) {
|
|
117
|
+
deepMixin(target[i], value);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
target[i] = value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if ((0, checks_1.isObject)(target) && (0, checks_1.isObject)(mixin)) {
|
|
125
|
+
for (var key in mixin) {
|
|
126
|
+
const value = mixin[key];
|
|
127
|
+
if ((0, checks_1.isObject)(value) || (0, checks_1.isArray)(value)) {
|
|
128
|
+
deepMixin(target[key], value);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
target[key] = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function readManifest(includeLocalOverrides, path = './') {
|
|
110
137
|
const raw = JSON.parse((await fs.readFile(path + 'manifest.json')).toString());
|
|
138
|
+
if (includeLocalOverrides) {
|
|
139
|
+
try {
|
|
140
|
+
const overrides = JSON.parse((await fs.readFile(path + 'manifest.local.json')).toString());
|
|
141
|
+
deepMixin(raw, overrides);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
//No need to do anything; local overrides are just invalid
|
|
145
|
+
console.warn('Local manifest overrides could not be applied', e);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
111
148
|
validateManifestOrThrow(raw);
|
|
112
149
|
return raw;
|
|
113
150
|
}
|
package/src/shapelibrary.js
CHANGED
|
@@ -38,7 +38,7 @@ const defaultNameMap = new Map([
|
|
|
38
38
|
//Produce JSON equivalent to the document service's
|
|
39
39
|
// /shapeLibraries/:name/shapes endpoint
|
|
40
40
|
async function getShapeListJson(name, packagePath) {
|
|
41
|
-
const packageManifest = await (0, packagemanifest_1.readManifest)(packagePath + '/');
|
|
41
|
+
const packageManifest = await (0, packagemanifest_1.readManifest)(true, packagePath + '/');
|
|
42
42
|
const rawManifest = await fs.readFile(packagePath + `/shapelibraries/${name}/library.manifest`);
|
|
43
43
|
const manifest = hjson.parse(rawManifest.toString());
|
|
44
44
|
const usedNames = new Set(manifest['shapes'].map((shape) => shape['key']).filter((key) => key !== undefined));
|
|
@@ -161,7 +161,7 @@ async function debugShapeLibraries(packagePath = '.') {
|
|
|
161
161
|
let shapeLibraryVersion = Date.now();
|
|
162
162
|
app.get('/shapeLibraries', async (req, res) => {
|
|
163
163
|
var _a;
|
|
164
|
-
const manifest = await (0, packagemanifest_1.readManifest)(packagePath + '/');
|
|
164
|
+
const manifest = await (0, packagemanifest_1.readManifest)(true, packagePath + '/');
|
|
165
165
|
const libraries = (_a = manifest['shapeLibraries']) !== null && _a !== void 0 ? _a : [];
|
|
166
166
|
const output = await Promise.all(libraries.map(async (libraryManifest) => {
|
|
167
167
|
const libraryDefinitionContent = await fs.readFile(packagePath + '/shapelibraries/' + libraryManifest['name'] + '/library.manifest');
|
package/src/shellutil.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execSyncLoggingOutputOnError = void 0;
|
|
4
|
+
const child_process = require("child_process");
|
|
5
|
+
function execSyncLoggingOutputOnError(cmd) {
|
|
6
|
+
try {
|
|
7
|
+
return child_process.execSync(cmd);
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
console.log(String(e.stdout));
|
|
11
|
+
console.error(String(e.stderr));
|
|
12
|
+
throw e;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.execSyncLoggingOutputOnError = execSyncLoggingOutputOnError;
|