lucid-package 0.0.28 → 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.28",
3
+ "version": "0.0.29",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -113,12 +113,12 @@ async function debugEditorExtension(extensionNames, quiet = false) {
113
113
  app.get(['/scopes', '/editorextension/:name/scopes'], async (req, res) => {
114
114
  var _a, _b, _c;
115
115
  const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
116
- const manifest = await (0, packagemanifest_1.readManifest)();
116
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
117
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));
118
118
  });
119
119
  app.get('/packageId', async (req, res) => {
120
120
  var _a;
121
- const manifest = await (0, packagemanifest_1.readManifest)();
121
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
122
122
  res.send((_a = manifest['id']) !== null && _a !== void 0 ? _a : '__local__');
123
123
  });
124
124
  app.get(['/editorextension', '/editorextension/:name'], async (req, res) => {
@@ -134,7 +134,7 @@ async function debugEditorExtension(extensionNames, quiet = false) {
134
134
  var _a;
135
135
  const name = req.params['name'];
136
136
  if (name) {
137
- const manifest = await (0, packagemanifest_1.readManifest)();
137
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
138
138
  const provider = (_a = manifest['oauthProviders']) === null || _a === void 0 ? void 0 : _a.find((one) => one.name === name);
139
139
  if (provider && oldFs.existsSync(`${name}.credentials.local`)) {
140
140
  const credentials = JSON.parse((await fs.readFile(`${name}.credentials.local`)).toString());
@@ -156,7 +156,7 @@ async function debugEditorExtension(extensionNames, quiet = false) {
156
156
  exports.debugEditorExtension = debugEditorExtension;
157
157
  async function getRawEditorExtension(name) {
158
158
  var _a, _b, _c, _d;
159
- const manifest = await (0, packagemanifest_1.readManifest)();
159
+ const manifest = await (0, packagemanifest_1.readManifest)(true);
160
160
  const extensionManifest = (_a = manifest['extensions']) === null || _a === void 0 ? void 0 : _a.find((one) => one['name'] === name);
161
161
  return {
162
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');