lucid-package 0.0.1 → 0.0.5

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
@@ -2,7 +2,76 @@
2
2
 
3
3
  ## Description
4
4
 
5
- CLI for creating and managing extensibility packages for the products of Lucid Software.
5
+ CLI for creating and managing extension packages for the products of Lucid Software.
6
+
7
+ ## Getting started
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).
6
75
 
7
76
  ## License
8
77
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.1",
3
+ "version": "0.0.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,3 +1,4 @@
1
1
  export declare function createEditorExtension(name: string, isInternalTesting: boolean): Promise<void>;
2
2
  export declare function buildEditorExtension(name: string): Promise<void>;
3
+ export declare function updateExtensionSDK(name: string): Promise<void>;
3
4
  export declare function debugEditorExtension(name: string): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debugEditorExtension = exports.buildEditorExtension = exports.createEditorExtension = void 0;
3
+ exports.debugEditorExtension = exports.updateExtensionSDK = exports.buildEditorExtension = exports.createEditorExtension = void 0;
4
4
  const fs = require("fs/promises");
5
5
  const filesystemutil_1 = require("./filesystemutil");
6
6
  const package_1 = require("./package");
@@ -39,6 +39,12 @@ async function buildEditorExtension(name) {
39
39
  await cli.run(['node', 'webpack', '--mode', 'production']);
40
40
  }
41
41
  exports.buildEditorExtension = buildEditorExtension;
42
+ async function updateExtensionSDK(name) {
43
+ process.chdir('editorextensions/' + name);
44
+ console.log('Installing latest SDK in extension ' + name);
45
+ console.log(child_process.execSync('npm install lucid-extension-sdk@latest').toString());
46
+ }
47
+ exports.updateExtensionSDK = updateExtensionSDK;
42
48
  async function debugEditorExtension(name) {
43
49
  process.chdir('editorextensions/' + name);
44
50
  const cli = new WebPackCLI();
package/src/index.js CHANGED
@@ -13,7 +13,7 @@ class LucidSuiteExtensionCLI {
13
13
  //When running with bazel, specifies a project name inside the chdir. Otherwise, directly specifies a directory to chdir to.
14
14
  parser.add_argument('--project', '-p', {
15
15
  type: 'str',
16
- help: 'Specify a project directory to run this command inside',
16
+ help: argparse_1.SUPPRESS,
17
17
  });
18
18
  const subparsers = parser.add_subparsers({ dest: 'command' });
19
19
  const createParser = subparsers.add_parser('create', {
@@ -23,6 +23,9 @@ class LucidSuiteExtensionCLI {
23
23
  const packageParser = subparsers.add_parser('package', {
24
24
  help: 'Prepare the current package for upload to the developer dashboard',
25
25
  });
26
+ const updateSDKParser = subparsers.add_parser('update-sdk', {
27
+ help: 'Update the editor extension SDK to the latest published version for all editor extensions in this package',
28
+ });
26
29
  const createExtensionParser = subparsers.add_parser('create-editor-extension', {
27
30
  help: 'Create a new editor extension as part of the current package',
28
31
  });
@@ -61,6 +64,14 @@ class LucidSuiteExtensionCLI {
61
64
  console.error('Not currently in a Lucid extensibility package folder');
62
65
  }
63
66
  break;
67
+ case 'update-sdk':
68
+ if ((0, package_1.currentlyInPackage)()) {
69
+ (0, package_1.updateAllExtensionSDK)();
70
+ }
71
+ else {
72
+ console.error('Not currently in a Lucid extensibility package folder');
73
+ }
74
+ break;
64
75
  case 'create-editor-extension':
65
76
  if ((0, package_1.currentlyInPackage)()) {
66
77
  (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting);
package/src/package.d.ts CHANGED
@@ -9,6 +9,8 @@ declare type PackageManifest = {
9
9
  scopes: string[];
10
10
  }[];
11
11
  };
12
+ export declare function readManifest(): Promise<PackageManifest>;
12
13
  export declare function modifyManifest(callback: (manifest: PackageManifest) => void | Promise<void>): Promise<void>;
14
+ export declare function updateAllExtensionSDK(): Promise<void>;
13
15
  export declare function writePackage(): Promise<void>;
14
16
  export {};
package/src/package.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writePackage = exports.modifyManifest = exports.currentlyInPackage = exports.createEmptyPackage = void 0;
3
+ exports.writePackage = exports.updateAllExtensionSDK = exports.modifyManifest = exports.readManifest = exports.currentlyInPackage = exports.createEmptyPackage = void 0;
4
4
  const fs = require("fs/promises");
5
5
  const fsOld = require("fs");
6
6
  const filesystemutil_1 = require("./filesystemutil");
7
+ const editorextension_1 = require("./editorextension");
7
8
  const child_process = require("child_process");
8
9
  const JSZip = require("jszip");
9
10
  async function createEmptyPackage(root) {
@@ -16,12 +17,25 @@ function currentlyInPackage() {
16
17
  }
17
18
  exports.currentlyInPackage = currentlyInPackage;
18
19
  const allScopes = new Set(['DOWNLOAD', 'NETWORK', 'READ', 'SHOW_MODAL', 'WRITE']);
20
+ async function readManifest() {
21
+ return JSON.parse((await fs.readFile('manifest.json')).toString());
22
+ }
23
+ exports.readManifest = readManifest;
19
24
  async function modifyManifest(callback) {
20
- const manifest = JSON.parse((await fs.readFile('manifest.json')).toString());
25
+ const manifest = await readManifest();
21
26
  await callback(manifest);
22
27
  await fs.writeFile('manifest.json', JSON.stringify(manifest, undefined, 2));
23
28
  }
24
29
  exports.modifyManifest = modifyManifest;
30
+ async function updateAllExtensionSDK() {
31
+ for (const extension of (await readManifest()).extensions) {
32
+ const parts = extension.codePath.split('/');
33
+ if (parts[0] === 'editorextensions') {
34
+ await (0, editorextension_1.updateExtensionSDK)(parts[1]);
35
+ }
36
+ }
37
+ }
38
+ exports.updateAllExtensionSDK = updateAllExtensionSDK;
25
39
  async function writePackage() {
26
40
  const zip = new JSZip();
27
41
  //Increment the patch number automatically on each build
@@ -42,9 +56,9 @@ async function writePackage() {
42
56
  if (parts[0] === 'editorextensions') {
43
57
  //Can't just call the method, as the WebpackCLI class does process.exit(2) :facepalm:
44
58
  console.log(`Compiling editor extension ${parts[1]}`);
45
- console.log(child_process
46
- .execSync(process.argv[0] + ' ' + process.argv[1] + ' build-editor-extension ' + parts[1])
47
- .toString());
59
+ const cmd = process.argv[0] + ' ' + process.argv[1] + ' build-editor-extension ' + parts[1];
60
+ console.log(cmd);
61
+ console.log(child_process.execSync(cmd).toString());
48
62
  }
49
63
  zip.file(extension.codePath, await fs.readFile(extension.codePath));
50
64
  }