lucid-package 0.0.29 → 0.0.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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(child_process.execSync(`npm install --silent --save ${relativePath}`).toString());
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(child_process.execSync('npm install --silent').toString());
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(child_process.execSync('npm install --save lucid-extension-sdk').toString());
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(child_process.execSync('npm install lucid-extension-sdk@latest').toString());
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)(true);
117
+ const manifest = await (0, packagemanifest_1.readManifest)('local');
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)(true);
122
+ const manifest = await (0, packagemanifest_1.readManifest)('local');
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)(true);
138
+ const manifest = await (0, packagemanifest_1.readManifest)('local');
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)(true);
160
+ const manifest = await (0, packagemanifest_1.readManifest)('local');
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/index.js CHANGED
@@ -29,6 +29,9 @@ class LucidSuiteExtensionCLI {
29
29
  action: 'store_true',
30
30
  help: argparse_1.SUPPRESS,
31
31
  });
32
+ packageParser.add_argument('--env', {
33
+ help: 'Provide the environment to define which manifest.<env>.json is combined with manifest.json when bundling. If not provided, uses manifest.json only.',
34
+ });
32
35
  const updateSDKParser = subparsers.add_parser('update-sdk', {
33
36
  help: 'Update the editor extension SDK to the latest published version for all editor extensions in this package',
34
37
  });
@@ -95,7 +98,7 @@ class LucidSuiteExtensionCLI {
95
98
  break;
96
99
  case 'bundle':
97
100
  if ((0, package_1.currentlyInPackage)()) {
98
- await (0, package_1.writePackage)(parsed['quiet']);
101
+ await (0, package_1.writePackage)(parsed['quiet'], parsed['env']);
99
102
  }
100
103
  else {
101
104
  console.error('Not currently in a Lucid extension package folder');
package/src/package.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { PackageManifest } from './packagemanifest';
2
2
  export declare function createEmptyPackage(root: string): Promise<void>;
3
3
  export declare function currentlyInPackage(): boolean;
4
- export declare function modifyManifest(callback: (manifest: PackageManifest) => void | Promise<void>): Promise<void>;
4
+ export declare function modifyManifest(callback: (manifest: PackageManifest) => void | Promise<void>, manifestOverrideEnv?: string): Promise<void>;
5
5
  export declare function updateAllExtensionSDK(): Promise<void>;
6
- export declare function writePackage(quiet?: boolean): Promise<void>;
6
+ /**
7
+ *
8
+ * @param manifestOverrideEnv The environment definine what manifest to read from. `manifest.env.json`
9
+ */
10
+ export declare function writePackage(quiet?: boolean, manifestOverrideEnv?: string): Promise<void>;
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);
@@ -19,14 +19,14 @@ function currentlyInPackage() {
19
19
  }
20
20
  exports.currentlyInPackage = currentlyInPackage;
21
21
  const allScopes = new Set(['DOWNLOAD', 'NETWORK', 'READ', 'SHOW_MODAL', 'CUSTOM_UI', 'WRITE']);
22
- async function modifyManifest(callback) {
23
- const manifest = await (0, packagemanifest_1.readManifest)(false);
22
+ async function modifyManifest(callback, manifestOverrideEnv) {
23
+ const manifest = await (0, packagemanifest_1.readManifest)(manifestOverrideEnv);
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)(false);
29
+ const manifest = await (0, packagemanifest_1.readManifest)();
30
30
  for (const extension of manifest['extensions'] || []) {
31
31
  const parts = extension['codePath'].split('/');
32
32
  if (parts[0] === 'editorextensions') {
@@ -35,7 +35,11 @@ async function updateAllExtensionSDK() {
35
35
  }
36
36
  }
37
37
  exports.updateAllExtensionSDK = updateAllExtensionSDK;
38
- async function writePackage(quiet = false) {
38
+ /**
39
+ *
40
+ * @param manifestOverrideEnv The environment definine what manifest to read from. `manifest.env.json`
41
+ */
42
+ async function writePackage(quiet = false, manifestOverrideEnv) {
39
43
  const zip = new JSZip();
40
44
  //Increment the patch number automatically on each build
41
45
  await modifyManifest(async (manifest) => {
@@ -66,7 +70,7 @@ async function writePackage(quiet = false) {
66
70
  parts[1] +
67
71
  '"';
68
72
  console.log(cmd);
69
- console.log(child_process.execSync(cmd).toString());
73
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)(cmd).toString());
70
74
  }
71
75
  zip.file(extension['codePath'], await fs.readFile(extension['codePath']));
72
76
  }
@@ -84,7 +88,8 @@ async function writePackage(quiet = false) {
84
88
  //Write out the zip file
85
89
  const zipBytes = await zip.generateAsync({ type: 'uint8array' });
86
90
  console.log('Writing file package.zip');
87
- await fs.writeFile('package.zip', zipBytes);
88
- });
91
+ const fileName = `package${manifestOverrideEnv ? `-${manifestOverrideEnv}` : ''}.zip`;
92
+ await fs.writeFile(fileName, zipBytes);
93
+ }, manifestOverrideEnv);
89
94
  }
90
95
  exports.writePackage = writePackage;
@@ -28,4 +28,8 @@ export declare type PackageManifest = {
28
28
  'callbackEvents': string[];
29
29
  }[];
30
30
  };
31
- export declare function readManifest(includeLocalOverrides: boolean, path?: string): Promise<PackageManifest>;
31
+ /**
32
+ * @param manifestOverrideEnv The environment to override the manifest with
33
+ * @param path The path to read the manifest from
34
+ */
35
+ export declare function readManifest(manifestOverrideEnv?: string, path?: string): Promise<PackageManifest>;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readManifest = void 0;
4
- const fs = require("fs/promises");
4
+ const fs = require("fs");
5
+ const fsPromises = require("fs/promises");
5
6
  const checks_1 = require("lucid-extension-sdk/sdk/core/checks");
6
7
  const versionRegex = /^\d+\.\d+\.\d+$/;
7
8
  function validateManifestOrThrow(manifest) {
@@ -133,16 +134,28 @@ function deepMixin(target, mixin) {
133
134
  }
134
135
  }
135
136
  }
136
- async function readManifest(includeLocalOverrides, path = './') {
137
- const raw = JSON.parse((await fs.readFile(path + 'manifest.json')).toString());
138
- if (includeLocalOverrides) {
137
+ /**
138
+ * @param manifestOverrideEnv The environment to override the manifest with
139
+ * @param path The path to read the manifest from
140
+ */
141
+ async function readManifest(manifestOverrideEnv, path = './') {
142
+ const raw = JSON.parse((await fsPromises.readFile(path + 'manifest.json')).toString());
143
+ if (manifestOverrideEnv) {
144
+ const manifestOverridePath = path + `manifest.${manifestOverrideEnv}.json`;
139
145
  try {
140
- const overrides = JSON.parse((await fs.readFile(path + 'manifest.local.json')).toString());
146
+ const overrides = JSON.parse((await fsPromises.readFile(manifestOverridePath)).toString());
141
147
  deepMixin(raw, overrides);
142
148
  }
143
149
  catch (e) {
144
- //No need to do anything; local overrides are just invalid
145
- console.warn('Local manifest overrides could not be applied', e);
150
+ if (manifestOverrideEnv == 'local') {
151
+ // Warn if the file exists (this means it's invalid), otherwise fail silently
152
+ if (fs.existsSync(manifestOverridePath)) {
153
+ console.warn('Local manifest overrides could not be applied', e);
154
+ }
155
+ }
156
+ else {
157
+ throw new Error(`Missing or malformated \"manifest.${manifestOverrideEnv}.json\". Please create and run the command again.`);
158
+ }
146
159
  }
147
160
  }
148
161
  validateManifestOrThrow(raw);
@@ -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)(true, packagePath + '/');
41
+ const packageManifest = await (0, packagemanifest_1.readManifest)('local', 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)(true, packagePath + '/');
164
+ const manifest = await (0, packagemanifest_1.readManifest)('local', 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');
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function execSyncLoggingOutputOnError(cmd: string): Buffer;
@@ -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;