lucid-package 0.0.38 → 0.0.40
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 +1 -1
- package/src/editorextension.js +20 -7
- package/src/index.js +6 -1
- package/src/packagemanifest.d.ts +3 -1
- package/src/packagemanifest.js +16 -4
- package/src/supportedproduct.d.ts +5 -0
- package/src/supportedproduct.js +9 -0
package/package.json
CHANGED
package/src/editorextension.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function createEditorExtension(name: string, isInternalTesting: boolean): Promise<void>;
|
|
1
|
+
export declare function createEditorExtension(name: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
|
|
2
2
|
export declare function buildEditorExtension(name: string, isInternalTesting: boolean, quiet?: boolean): Promise<void>;
|
|
3
3
|
export declare function updateExtensionSDK(name: string): Promise<void>;
|
|
4
4
|
/**
|
package/src/editorextension.js
CHANGED
|
@@ -11,6 +11,7 @@ const package_1 = require("./package");
|
|
|
11
11
|
const packagemanifest_1 = require("./packagemanifest");
|
|
12
12
|
const shapelibrary_1 = require("./shapelibrary");
|
|
13
13
|
const shellutil_1 = require("./shellutil");
|
|
14
|
+
const supportedproduct_1 = require("./supportedproduct");
|
|
14
15
|
const WebPackCLI = require('webpack-cli');
|
|
15
16
|
function linkInternalTestingSDK() {
|
|
16
17
|
if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
|
|
@@ -23,11 +24,11 @@ function linkInternalTestingSDK() {
|
|
|
23
24
|
console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install --silent --save ${relativePath}`).toString());
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
function installDependenciesIfNeeded(isInternalTesting) {
|
|
27
|
+
function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false) {
|
|
27
28
|
if (!oldFs.existsSync('node_modules')) {
|
|
28
29
|
console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
|
|
29
30
|
}
|
|
30
|
-
if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
|
|
31
|
+
if (!oldFs.existsSync('node_modules/lucid-extension-sdk') && !skipSDKDependency) {
|
|
31
32
|
if (isInternalTesting) {
|
|
32
33
|
linkInternalTestingSDK();
|
|
33
34
|
}
|
|
@@ -37,7 +38,7 @@ function installDependenciesIfNeeded(isInternalTesting) {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
async function createEditorExtension(name, isInternalTesting) {
|
|
41
|
+
async function createEditorExtension(name, isInternalTesting, skipSDKDependency) {
|
|
41
42
|
console.log('Creating empty editor extension in editorextensions/' + name);
|
|
42
43
|
(0, filesystemutil_1.copyFolderRecursiveSync)(__dirname + '/../templates/editorextension', 'editorextensions/' + name);
|
|
43
44
|
await (0, package_1.modifyManifest)((manifest) => {
|
|
@@ -47,14 +48,14 @@ async function createEditorExtension(name, isInternalTesting) {
|
|
|
47
48
|
manifest['extensions'].push({
|
|
48
49
|
'name': name,
|
|
49
50
|
'title': name,
|
|
50
|
-
'
|
|
51
|
+
'products': [supportedproduct_1.SupportedProduct.Chart],
|
|
51
52
|
'codePath': `editorextensions/${name}/bin/extension.js`,
|
|
52
53
|
'scopes': ['READ', 'WRITE', 'DOWNLOAD', 'SHOW_MODAL', 'CUSTOM_UI', 'NETWORK'],
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
console.log(`Installing dependencies`);
|
|
56
57
|
process.chdir('editorextensions/' + name);
|
|
57
|
-
installDependenciesIfNeeded(isInternalTesting);
|
|
58
|
+
installDependenciesIfNeeded(isInternalTesting, skipSDKDependency);
|
|
58
59
|
}
|
|
59
60
|
exports.createEditorExtension = createEditorExtension;
|
|
60
61
|
async function buildEditorExtension(name, isInternalTesting, quiet = false) {
|
|
@@ -186,10 +187,13 @@ async function getExtensionCodeDirectoryNameFromCodePath(codePath) {
|
|
|
186
187
|
return undefined;
|
|
187
188
|
}
|
|
188
189
|
async function getRawEditorExtension(name) {
|
|
189
|
-
var _a, _b, _c
|
|
190
|
+
var _a, _b, _c;
|
|
190
191
|
const { manifest, extensionManifest } = await getExtensionManifest(name);
|
|
191
192
|
const codePath = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['codePath'];
|
|
192
193
|
const directory = codePath ? (_a = (await getExtensionCodeDirectoryNameFromCodePath(codePath))) !== null && _a !== void 0 ? _a : name : name;
|
|
194
|
+
const products = extensionManifest
|
|
195
|
+
? getExtensionProducts(extensionManifest['product'], extensionManifest['products'])
|
|
196
|
+
: [supportedproduct_1.SupportedProduct.Chart];
|
|
193
197
|
return {
|
|
194
198
|
id: '__local__',
|
|
195
199
|
packageId: (_b = manifest['id']) !== null && _b !== void 0 ? _b : '__local__',
|
|
@@ -197,8 +201,17 @@ async function getRawEditorExtension(name) {
|
|
|
197
201
|
version: manifest['version'],
|
|
198
202
|
name: name,
|
|
199
203
|
title: (_c = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['title']) !== null && _c !== void 0 ? _c : 'Local dev extension',
|
|
200
|
-
|
|
204
|
+
products: products,
|
|
201
205
|
scopes: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['scopes'],
|
|
202
206
|
codeUrl: `http://localhost:9900/editorextension/${directory}/extension.js`,
|
|
203
207
|
};
|
|
204
208
|
}
|
|
209
|
+
function getExtensionProducts(product, products) {
|
|
210
|
+
if (products && products.length !== 0) {
|
|
211
|
+
return products;
|
|
212
|
+
}
|
|
213
|
+
if (product) {
|
|
214
|
+
return [product];
|
|
215
|
+
}
|
|
216
|
+
throw new Error('Either "product" or "products" must be spcified for the editor extension in the package manifest');
|
|
217
|
+
}
|
package/src/index.js
CHANGED
|
@@ -39,6 +39,11 @@ class LucidSuiteExtensionCLI {
|
|
|
39
39
|
help: 'Create a new editor extension as part of the current package',
|
|
40
40
|
});
|
|
41
41
|
createExtensionParser.add_argument('name');
|
|
42
|
+
createExtensionParser.add_argument('--skip-sdk', {
|
|
43
|
+
default: false,
|
|
44
|
+
action: 'store_true',
|
|
45
|
+
help: argparse_1.SUPPRESS,
|
|
46
|
+
});
|
|
42
47
|
const buildExtensionParser = subparsers.add_parser('build-editor-extension', {
|
|
43
48
|
help: 'Compile an editor extension in production mode; use this to check types and validate final compiled output',
|
|
44
49
|
});
|
|
@@ -114,7 +119,7 @@ class LucidSuiteExtensionCLI {
|
|
|
114
119
|
break;
|
|
115
120
|
case 'create-editor-extension':
|
|
116
121
|
if ((0, package_1.currentlyInPackage)()) {
|
|
117
|
-
await (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting);
|
|
122
|
+
await (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting, parsed['skip_sdk']);
|
|
118
123
|
}
|
|
119
124
|
else {
|
|
120
125
|
console.error('Not currently in a Lucid extension package folder');
|
package/src/packagemanifest.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SupportedProduct } from './supportedproduct';
|
|
1
2
|
export declare enum SettingType {
|
|
2
3
|
STRING = "string"
|
|
3
4
|
}
|
|
@@ -9,7 +10,8 @@ export declare type PackageManifest = {
|
|
|
9
10
|
'title': string;
|
|
10
11
|
'codePath': string;
|
|
11
12
|
'scopes': string[];
|
|
12
|
-
'product'
|
|
13
|
+
'product'?: SupportedProduct;
|
|
14
|
+
'products'?: SupportedProduct[];
|
|
13
15
|
}[];
|
|
14
16
|
'shapeLibraries'?: {
|
|
15
17
|
'name': string;
|
package/src/packagemanifest.js
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const fsPromises = require("fs/promises");
|
|
6
6
|
const checks_1 = require("lucid-extension-sdk/sdk/core/checks");
|
|
7
7
|
const validators_1 = require("lucid-extension-sdk/sdk/core/validators/validators");
|
|
8
|
+
const supportedproduct_1 = require("./supportedproduct");
|
|
8
9
|
var SettingType;
|
|
9
10
|
(function (SettingType) {
|
|
10
11
|
SettingType["STRING"] = "string";
|
|
@@ -60,10 +61,21 @@ function validateManifestOrThrow(manifest) {
|
|
|
60
61
|
if (!(0, checks_1.isTypedArray)(checks_1.isString)(extension['scopes'])) {
|
|
61
62
|
throw new Error('manifest.json: extension "scopes" must be a string array');
|
|
62
63
|
}
|
|
63
|
-
if (extension['product']
|
|
64
|
-
extension['product']
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
if ((extension['product'] && extension['products']) ||
|
|
65
|
+
(!(0, checks_1.isDef)(extension['product']) && !(0, checks_1.isDef)(extension['products']))) {
|
|
66
|
+
throw new Error('either the "product" or "products" field must be specified and not both');
|
|
67
|
+
}
|
|
68
|
+
const supportedProducts = Object.values(supportedproduct_1.SupportedProduct);
|
|
69
|
+
if (extension['product']) {
|
|
70
|
+
if (!(0, validators_1.enumValidator)(supportedproduct_1.SupportedProduct)(extension['product'])) {
|
|
71
|
+
throw new Error(`manifest.json: found ${extension['product']}. extension "product" must be one of ${supportedProducts}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (extension['products']) {
|
|
75
|
+
if (!(0, checks_1.isTypedArray)((0, validators_1.enumValidator)(supportedproduct_1.SupportedProduct))(extension['products']) ||
|
|
76
|
+
extension['products'].length === 0) {
|
|
77
|
+
throw new Error(`manifest.json: found ${extension['products']}. extension "products" must be an array containing values from ${supportedProducts}`);
|
|
78
|
+
}
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
81
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SupportedProduct = void 0;
|
|
4
|
+
var SupportedProduct;
|
|
5
|
+
(function (SupportedProduct) {
|
|
6
|
+
SupportedProduct["Chart"] = "chart";
|
|
7
|
+
SupportedProduct["Spark"] = "spark";
|
|
8
|
+
SupportedProduct["TeamSpaces"] = "teamspaces";
|
|
9
|
+
})(SupportedProduct = exports.SupportedProduct || (exports.SupportedProduct = {}));
|