lucid-package 0.0.12 → 0.0.17

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/README.md CHANGED
@@ -6,72 +6,7 @@ CLI for creating and managing extension packages for the products of Lucid Softw
6
6
 
7
7
  ## Getting started
8
8
 
9
- ### Step 1: Install `lucid-package` and create a new package
10
-
11
- An extension package is a set of Lucid product extensions that is installable by a Lucid
12
- account admin for use by all of their users. In order to start building an extension, you
13
- need to create a package to contain it.
14
-
15
- In a directory that will contain your extension packages:
16
-
17
- ```
18
- npm install lucid-package
19
- npx lucid-package create my-new-package-name
20
- ```
21
-
22
- ### Step 2: Add an editor extension to your new package
23
-
24
- An editor extension is a piece of custom code that executes inside a Lucid product such
25
- as Lucidchart or Lucidspark. The `lucid-package` CLI provides a quick-start template to
26
- help you get up and running immediately.
27
-
28
- To add a new extension to your package:
29
-
30
- ```
31
- cd my-new-package-name
32
- npx lucid-package create-editor-extension my-extension-name
33
- ```
34
-
35
- ### Step 3: Serve your extension code in debug mode to test it
36
-
37
- You don't need to package, upload, and install your extension in order to run it and
38
- make sure it works. The following command will start `webpack` on your code in `--watch`
39
- mode, and start up a local HTTP server that Lucid products can connect to, to load your
40
- latest code.
41
-
42
- To start the debug server:
43
-
44
- ```
45
- npx lucid-package test-editor-extension my-extension-name
46
- ```
47
-
48
- You can then enable loading of your local plugin in the Developer menu in Lucidchart
49
- by clicking `Load local extension`. The page will refresh and your extension code will run.
50
-
51
- The main entry point to your new editor extension is in `editorextensions/my-extension-name/src/extension.ts`.
52
- Experiment by changing code in that file and refreshing your browser tab to reload it.
53
-
54
- For all published extensions, and by default for this debug server as well, your code
55
- runs in a sandboxed JavaScript VM for security. However, this makes debugging difficult.
56
- If you turn on the `Debug local extensions (no sandbox)` option in the Developer menu,
57
- your code will be run via a scoped `eval`, allowing you to use the standard browser
58
- debugging tools to examine and step through your code.
59
-
60
- We recommend that you do all final validation of your extension with the normal
61
- sandbox enabled, however, as you may have inadvertently used features not allowed in
62
- the sandbox that won't work once you release your extension.
63
-
64
- ### Step 4: Prepare your package for upload
65
-
66
- Once your editor extension works the way you want, you can package it for upload to the
67
- Lucid developer dashboard:
68
-
69
- ```
70
- npx lucid-package package
71
- ```
72
-
73
- This will create the file `package.zip` which is ready for upload to the [Lucid developer
74
- dashboard](https://lucid.app/developer).
9
+ Please see our [Extension API Developer Docs](https://developer.lucid.co/extension-api/#lucid-extension-api).
75
10
 
76
11
  ## License
77
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.12",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
1
  export declare function createEditorExtension(name: string, isInternalTesting: boolean): Promise<void>;
2
- export declare function buildEditorExtension(name: string): Promise<void>;
2
+ export declare function buildEditorExtension(name: string, quiet?: boolean): Promise<void>;
3
3
  export declare function updateExtensionSDK(name: string): Promise<void>;
4
- export declare function debugEditorExtension(name: string): Promise<void>;
4
+ export declare function debugEditorExtension(name: string, quiet?: boolean): Promise<void>;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.debugEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
4
4
  const fs = require("fs/promises");
5
+ const oldFs = require("fs");
5
6
  const filesystemutil_1 = require("./filesystemutil");
6
7
  const package_1 = require("./package");
7
8
  const express = require("express");
@@ -26,7 +27,7 @@ async function createEditorExtension(name, isInternalTesting) {
26
27
  });
27
28
  console.log(`Installing dependencies`);
28
29
  process.chdir('editorextensions/' + name);
29
- console.log(child_process.execSync('npm install').toString());
30
+ console.log(child_process.execSync('npm install --silent').toString());
30
31
  if (isInternalTesting) {
31
32
  console.log('Using symlink for dependency on SDK for internal testing');
32
33
  console.log(child_process
@@ -39,10 +40,10 @@ async function createEditorExtension(name, isInternalTesting) {
39
40
  }
40
41
  }
41
42
  exports.createEditorExtension = createEditorExtension;
42
- async function buildEditorExtension(name) {
43
+ async function buildEditorExtension(name, quiet = false) {
43
44
  process.chdir('editorextensions/' + name);
44
45
  const cli = new WebPackCLI();
45
- await cli.run(['node', 'webpack', '--mode', 'production']);
46
+ await cli.run(['node', 'webpack', '--mode', 'production', ...(quiet ? ['--stats', 'errors-only'] : [])]);
46
47
  }
47
48
  exports.buildEditorExtension = buildEditorExtension;
48
49
  async function updateExtensionSDK(name) {
@@ -51,10 +52,10 @@ async function updateExtensionSDK(name) {
51
52
  console.log(child_process.execSync('npm install lucid-extension-sdk@latest').toString());
52
53
  }
53
54
  exports.updateExtensionSDK = updateExtensionSDK;
54
- async function debugEditorExtension(name) {
55
+ async function debugEditorExtension(name, quiet = false) {
55
56
  process.chdir('editorextensions/' + name);
56
57
  const cli = new WebPackCLI();
57
- cli.run(['node', 'webpack', '--watch']);
58
+ cli.run(['node', 'webpack', '--watch', ...(quiet ? ['--stats', 'errors-only'] : [])]);
58
59
  const app = express();
59
60
  app.use((req, res, next) => {
60
61
  res.header('Access-Control-Allow-Origin', '*');
@@ -62,6 +63,11 @@ async function debugEditorExtension(name) {
62
63
  next();
63
64
  });
64
65
  app.get('/extension.js', async (req, res) => {
66
+ //Give it several seconds for the extension to finish generating before failing.
67
+ const before = Date.now();
68
+ while (!oldFs.existsSync('bin/extension.js') && Date.now() - before < 5000) {
69
+ await new Promise((resolve) => setTimeout(resolve, 50));
70
+ }
65
71
  res.send((await fs.readFile('bin/extension.js')).toString());
66
72
  });
67
73
  app.get('/scopes', async (req, res) => {
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const argparse_1 = require("argparse");
3
4
  const editorextension_1 = require("./editorextension");
4
5
  const package_1 = require("./package");
5
- const argparse_1 = require("argparse");
6
6
  const shapelibrary_1 = require("./shapelibrary");
7
7
  class LucidSuiteExtensionCLI {
8
- run(args) {
8
+ async run(args) {
9
9
  const parser = new argparse_1.ArgumentParser({
10
10
  description: 'Create and manage Lucid extension packages',
11
11
  });
@@ -24,6 +24,11 @@ class LucidSuiteExtensionCLI {
24
24
  const packageParser = subparsers.add_parser('bundle', {
25
25
  help: 'Prepare the current package for upload to the developer dashboard',
26
26
  });
27
+ packageParser.add_argument('--quiet', {
28
+ default: false,
29
+ action: 'store_true',
30
+ help: argparse_1.SUPPRESS,
31
+ });
27
32
  const updateSDKParser = subparsers.add_parser('update-sdk', {
28
33
  help: 'Update the editor extension SDK to the latest published version for all editor extensions in this package',
29
34
  });
@@ -35,10 +40,20 @@ class LucidSuiteExtensionCLI {
35
40
  help: 'Compile an editor extension in production mode; use this to check types and validate final compiled output',
36
41
  });
37
42
  buildExtensionParser.add_argument('name');
43
+ buildExtensionParser.add_argument('--quiet', {
44
+ default: false,
45
+ action: 'store_true',
46
+ help: argparse_1.SUPPRESS,
47
+ });
38
48
  const testExtensionParser = subparsers.add_parser('test-editor-extension', {
39
49
  help: 'Compile an editor extension in debug mode, and serve it at localhost:9900, along with any shape libraries in this package at localhost:9901. Watch for changes to the code and recompile as needed',
40
50
  });
41
51
  testExtensionParser.add_argument('name');
52
+ testExtensionParser.add_argument('--quiet', {
53
+ default: false,
54
+ action: 'store_true',
55
+ help: argparse_1.SUPPRESS,
56
+ });
42
57
  const testShapeLibraries = subparsers.add_parser('test-shape-libraries', {
43
58
  help: 'Serve any shape libraries in this package at localhost:9901. Watch for changes to the code and live-update as needed',
44
59
  });
@@ -66,7 +81,7 @@ class LucidSuiteExtensionCLI {
66
81
  break;
67
82
  case 'bundle':
68
83
  if ((0, package_1.currentlyInPackage)()) {
69
- (0, package_1.writePackage)();
84
+ await (0, package_1.writePackage)(parsed['quiet']);
70
85
  }
71
86
  else {
72
87
  console.error('Not currently in a Lucid extension package folder');
@@ -74,7 +89,7 @@ class LucidSuiteExtensionCLI {
74
89
  break;
75
90
  case 'update-sdk':
76
91
  if ((0, package_1.currentlyInPackage)()) {
77
- (0, package_1.updateAllExtensionSDK)();
92
+ await (0, package_1.updateAllExtensionSDK)();
78
93
  }
79
94
  else {
80
95
  console.error('Not currently in a Lucid extension package folder');
@@ -82,7 +97,7 @@ class LucidSuiteExtensionCLI {
82
97
  break;
83
98
  case 'create-editor-extension':
84
99
  if ((0, package_1.currentlyInPackage)()) {
85
- (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting);
100
+ await (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting);
86
101
  }
87
102
  else {
88
103
  console.error('Not currently in a Lucid extension package folder');
@@ -90,7 +105,7 @@ class LucidSuiteExtensionCLI {
90
105
  break;
91
106
  case 'build-editor-extension':
92
107
  if ((0, package_1.currentlyInPackage)()) {
93
- (0, editorextension_1.buildEditorExtension)(parsed['name']);
108
+ await (0, editorextension_1.buildEditorExtension)(parsed['name'], parsed['quiet']);
94
109
  }
95
110
  else {
96
111
  console.error('Not currently in a Lucid extension package folder');
@@ -98,7 +113,7 @@ class LucidSuiteExtensionCLI {
98
113
  break;
99
114
  case 'create-shape-library':
100
115
  if ((0, package_1.currentlyInPackage)()) {
101
- (0, shapelibrary_1.createEmptyShapeLibrary)(parsed['name']);
116
+ await (0, shapelibrary_1.createEmptyShapeLibrary)(parsed['name']);
102
117
  }
103
118
  else {
104
119
  console.error('Not currently in a Lucid extension package folder');
@@ -106,7 +121,7 @@ class LucidSuiteExtensionCLI {
106
121
  break;
107
122
  case 'test-shape-libraries':
108
123
  if ((0, package_1.currentlyInPackage)()) {
109
- (0, shapelibrary_1.debugShapeLibraries)();
124
+ await (0, shapelibrary_1.debugShapeLibraries)();
110
125
  }
111
126
  else {
112
127
  console.error('Not currently in a Lucid extension package folder');
@@ -114,7 +129,7 @@ class LucidSuiteExtensionCLI {
114
129
  break;
115
130
  case 'test-editor-extension':
116
131
  if ((0, package_1.currentlyInPackage)()) {
117
- (0, editorextension_1.debugEditorExtension)(parsed['name']);
132
+ await (0, editorextension_1.debugEditorExtension)(parsed['name'], parsed['quiet']);
118
133
  }
119
134
  else {
120
135
  console.error('Not currently in a Lucid extension package folder');
@@ -125,4 +140,6 @@ class LucidSuiteExtensionCLI {
125
140
  }
126
141
  }
127
142
  }
128
- new LucidSuiteExtensionCLI().run(process.argv.slice(2));
143
+ new LucidSuiteExtensionCLI()
144
+ .run(process.argv.slice(2))
145
+ .catch((reason) => console.error('Error running Lucid Suite Extension CLI', reason));
package/src/package.d.ts CHANGED
@@ -3,4 +3,4 @@ export declare function createEmptyPackage(root: string): Promise<void>;
3
3
  export declare function currentlyInPackage(): boolean;
4
4
  export declare function modifyManifest(callback: (manifest: PackageManifest) => void | Promise<void>): Promise<void>;
5
5
  export declare function updateAllExtensionSDK(): Promise<void>;
6
- export declare function writePackage(): Promise<void>;
6
+ export declare function writePackage(quiet?: boolean): Promise<void>;
package/src/package.js CHANGED
@@ -35,7 +35,7 @@ async function updateAllExtensionSDK() {
35
35
  }
36
36
  }
37
37
  exports.updateAllExtensionSDK = updateAllExtensionSDK;
38
- async function writePackage() {
38
+ async function writePackage(quiet = false) {
39
39
  const zip = new JSZip();
40
40
  //Increment the patch number automatically on each build
41
41
  await modifyManifest(async (manifest) => {
@@ -55,7 +55,12 @@ async function writePackage() {
55
55
  if (parts[0] === 'editorextensions') {
56
56
  //Can't just call the method, as the WebpackCLI class does process.exit(2) :facepalm:
57
57
  console.log(`Compiling editor extension ${parts[1]}`);
58
- const cmd = process.argv[0] + ' ' + process.argv[1] + ' build-editor-extension ' + parts[1];
58
+ const cmd = process.argv[0] +
59
+ ' ' +
60
+ process.argv[1] +
61
+ ' build-editor-extension ' +
62
+ (quiet ? '--quiet ' : '') +
63
+ parts[1];
59
64
  console.log(cmd);
60
65
  console.log(child_process.execSync(cmd).toString());
61
66
  }
@@ -85,11 +85,11 @@ function validateManifestOrThrow(manifest) {
85
85
  if (!(0, checks_1.isString)(provider['oauthProviderName'])) {
86
86
  throw new Error('manifest.json: Data connector "oauthProviderName" must be a string');
87
87
  }
88
- if (!(0, checks_1.isString)(provider['callbackUrl'])) {
89
- throw new Error('manifest.json: Data connector "callbackUrl" must be a string');
88
+ if (!(0, checks_1.isString)(provider['callbackBaseUrl'])) {
89
+ throw new Error('manifest.json: Data connector "callbackBaseUrl" must be a string');
90
90
  }
91
- if (!(0, checks_1.isTypedArray)(checks_1.isString)(provider['callbackEvents'])) {
92
- throw new Error('manifest.json: Data connector "callbackEvents" must be a string array');
91
+ if (!(0, checks_1.isRecord)(checks_1.isString)(provider['callbackEvents'])) {
92
+ throw new Error('manifest.json: Data connector "callbackEvents" must be a record from strings to strings');
93
93
  }
94
94
  }
95
95
  }
@@ -38,10 +38,11 @@ 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
42
  const rawManifest = await fs.readFile(packagePath + `/shapelibraries/${name}/library.manifest`);
42
43
  const manifest = hjson.parse(rawManifest.toString());
43
44
  return JSON.stringify(await Promise.all(manifest['shapes'].map(async (shapeManifest, index) => {
44
- var _a;
45
+ var _a, _b;
45
46
  const rawShapeData = await fs.readFile(packagePath + `/shapelibraries/${name}/shapes/${shapeManifest['shape']}.shape`);
46
47
  const shapeData = hjson.parse(rawShapeData.toString());
47
48
  const properties = {
@@ -61,8 +62,8 @@ async function getShapeListJson(name, packagePath) {
61
62
  'name': shapeManifest['name'],
62
63
  'i18n': {},
63
64
  'sourcePackage': {
64
- 'packageId': '__local__',
65
- 'version': '0.0.0',
65
+ 'packageId': (_a = packageManifest['id']) !== null && _a !== void 0 ? _a : '__local__',
66
+ 'version': packageManifest['version'],
66
67
  'library': name,
67
68
  'shape': shapeManifest['shape'],
68
69
  },
@@ -98,7 +99,7 @@ async function getShapeListJson(name, packagePath) {
98
99
  }
99
100
  for (var key in shapeManifest['defaults']) {
100
101
  if (key !== 'width' && key !== 'height') {
101
- const outName = (_a = defaultNameMap.get(key)) !== null && _a !== void 0 ? _a : key;
102
+ const outName = (_b = defaultNameMap.get(key)) !== null && _b !== void 0 ? _b : key;
102
103
  properties[outName] = shapeManifest['defaults'][key];
103
104
  }
104
105
  }
@@ -1,8 +1,12 @@
1
+ /** @ignore */
1
2
  declare namespace lucid {
2
3
  export function executeCommand(name: string, params: any): any;
3
4
  export function listen(msg: any): void;
5
+ export function getPackageId(): string;
6
+ export function getVersion(): string;
4
7
  }
5
8
 
9
+ /** @ignore */
6
10
  declare namespace console {
7
11
  export function log(...args: any[]): void;
8
12
  }