lucid-package 0.0.27 → 0.0.29

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.27",
3
+ "version": "0.0.29",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,6 +9,7 @@ const express = require("express");
9
9
  const child_process = require("child_process");
10
10
  const shapelibrary_1 = require("./shapelibrary");
11
11
  const packagemanifest_1 = require("./packagemanifest");
12
+ const path = require("path");
12
13
  const WebPackCLI = require('webpack-cli');
13
14
  function linkInternalTestingSDK() {
14
15
  if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
@@ -16,8 +17,9 @@ function linkInternalTestingSDK() {
16
17
  const rootSearch = 'lucid/main/extensibility/';
17
18
  const pos = cwd.indexOf(rootSearch);
18
19
  const sdkPath = cwd.substr(0, pos + rootSearch.length) + 'lucid-extension-sdk';
20
+ const relativePath = path.relative(cwd, sdkPath);
19
21
  console.log('Using symlink for dependency on SDK for internal testing');
20
- console.log(child_process.execSync(`ln -s ${sdkPath} node_modules/lucid-extension-sdk`).toString());
22
+ console.log(child_process.execSync(`npm install --silent --save ${relativePath}`).toString());
21
23
  }
22
24
  }
23
25
  function installDependenciesIfNeeded(isInternalTesting) {
@@ -111,12 +113,12 @@ async function debugEditorExtension(extensionNames, quiet = false) {
111
113
  app.get(['/scopes', '/editorextension/:name/scopes'], async (req, res) => {
112
114
  var _a, _b, _c;
113
115
  const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
114
- const manifest = await (0, packagemanifest_1.readManifest)();
116
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
115
117
  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));
116
118
  });
117
119
  app.get('/packageId', async (req, res) => {
118
120
  var _a;
119
- const manifest = await (0, packagemanifest_1.readManifest)();
121
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
120
122
  res.send((_a = manifest['id']) !== null && _a !== void 0 ? _a : '__local__');
121
123
  });
122
124
  app.get(['/editorextension', '/editorextension/:name'], async (req, res) => {
@@ -132,7 +134,7 @@ async function debugEditorExtension(extensionNames, quiet = false) {
132
134
  var _a;
133
135
  const name = req.params['name'];
134
136
  if (name) {
135
- const manifest = await (0, packagemanifest_1.readManifest)();
137
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
136
138
  const provider = (_a = manifest['oauthProviders']) === null || _a === void 0 ? void 0 : _a.find((one) => one.name === name);
137
139
  if (provider && oldFs.existsSync(`${name}.credentials.local`)) {
138
140
  const credentials = JSON.parse((await fs.readFile(`${name}.credentials.local`)).toString());
@@ -154,7 +156,7 @@ async function debugEditorExtension(extensionNames, quiet = false) {
154
156
  exports.debugEditorExtension = debugEditorExtension;
155
157
  async function getRawEditorExtension(name) {
156
158
  var _a, _b, _c, _d;
157
- const manifest = await (0, packagemanifest_1.readManifest)();
159
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
158
160
  const extensionManifest = (_a = manifest['extensions']) === null || _a === void 0 ? void 0 : _a.find((one) => one['name'] === name);
159
161
  return {
160
162
  id: '__local__',
package/src/package.js CHANGED
@@ -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') {
@@ -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>;
@@ -106,8 +106,45 @@ function validateManifestOrThrow(manifest) {
106
106
  }
107
107
  }
108
108
  }
109
- async function readManifest(path = './') {
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
  }
@@ -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');