lucid-package 0.0.23 → 0.0.24

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.23",
3
+ "version": "0.0.24",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,12 +1,12 @@
1
1
  export declare function createEditorExtension(name: string, isInternalTesting: boolean): Promise<void>;
2
- export declare function buildEditorExtension(name: string, quiet?: boolean): Promise<void>;
2
+ export declare function buildEditorExtension(name: string, isInternalTesting: boolean, quiet?: boolean): Promise<void>;
3
3
  export declare function updateExtensionSDK(name: string): Promise<void>;
4
4
  /**
5
5
  * Uses webpack to watch for changes in the editor extension
6
6
  * @param name The editor extension name
7
7
  * @param quiet If true, will only show errors in output
8
8
  */
9
- export declare function watchEditorExtension(name: string, quiet?: boolean): Promise<void>;
9
+ export declare function watchEditorExtension(name: string, isInternalTesting: boolean, quiet?: boolean): Promise<void>;
10
10
  /**
11
11
  * Runs the editor extensions and shape libraries in debug mode, including watching code for changes.
12
12
  * @param extensionNames The names of the editor extensions
@@ -10,6 +10,30 @@ const child_process = require("child_process");
10
10
  const shapelibrary_1 = require("./shapelibrary");
11
11
  const packagemanifest_1 = require("./packagemanifest");
12
12
  const WebPackCLI = require('webpack-cli');
13
+ function linkInternalTestingSDK() {
14
+ if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
15
+ const cwd = process.cwd();
16
+ const rootSearch = 'lucid/main/extensibility/';
17
+ const pos = cwd.indexOf(rootSearch);
18
+ const sdkPath = cwd.substr(0, pos + rootSearch.length) + 'lucid-extension-sdk';
19
+ 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());
21
+ }
22
+ }
23
+ function installDependenciesIfNeeded(isInternalTesting) {
24
+ if (!oldFs.existsSync('node_modules')) {
25
+ console.log(child_process.execSync('npm install --silent').toString());
26
+ }
27
+ if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
28
+ if (isInternalTesting) {
29
+ linkInternalTestingSDK();
30
+ }
31
+ else {
32
+ console.log('Adding dependency on SDK');
33
+ console.log(child_process.execSync('npm install --save lucid-extension-sdk').toString());
34
+ }
35
+ }
36
+ }
13
37
  async function createEditorExtension(name, isInternalTesting) {
14
38
  console.log('Creating empty editor extension in editorextensions/' + name);
15
39
  (0, filesystemutil_1.copyFolderRecursiveSync)(__dirname + '/../templates/editorextension', 'editorextensions/' + name);
@@ -27,21 +51,12 @@ async function createEditorExtension(name, isInternalTesting) {
27
51
  });
28
52
  console.log(`Installing dependencies`);
29
53
  process.chdir('editorextensions/' + name);
30
- console.log(child_process.execSync('npm install --silent').toString());
31
- if (isInternalTesting) {
32
- console.log('Using symlink for dependency on SDK for internal testing');
33
- console.log(child_process
34
- .execSync('ln -s ../../../../lucid-extension-sdk node_modules/lucid-extension-sdk ')
35
- .toString());
36
- }
37
- else {
38
- console.log('Adding dependency on SDK');
39
- console.log(child_process.execSync('npm install --save lucid-extension-sdk').toString());
40
- }
54
+ installDependenciesIfNeeded(isInternalTesting);
41
55
  }
42
56
  exports.createEditorExtension = createEditorExtension;
43
- async function buildEditorExtension(name, quiet = false) {
57
+ async function buildEditorExtension(name, isInternalTesting, quiet = false) {
44
58
  process.chdir('editorextensions/' + name);
59
+ installDependenciesIfNeeded(isInternalTesting);
45
60
  const cli = new WebPackCLI();
46
61
  await cli.run(['node', 'webpack', '--mode', 'production', ...(quiet ? ['--stats', 'errors-only'] : [])]);
47
62
  }
@@ -57,8 +72,9 @@ exports.updateExtensionSDK = updateExtensionSDK;
57
72
  * @param name The editor extension name
58
73
  * @param quiet If true, will only show errors in output
59
74
  */
60
- async function watchEditorExtension(name, quiet = false) {
75
+ async function watchEditorExtension(name, isInternalTesting, quiet = false) {
61
76
  process.chdir(`editorextensions/${name}`);
77
+ installDependenciesIfNeeded(isInternalTesting);
62
78
  const cli = new WebPackCLI();
63
79
  cli.run(['node', 'webpack', '--watch', ...(quiet ? ['--stats', 'errors-only'] : [])]);
64
80
  }
@@ -112,6 +128,21 @@ async function debugEditorExtension(extensionNames, quiet = false) {
112
128
  app.get('/editorextensions', async (req, res) => {
113
129
  res.send(await Promise.all(extensionNames.map((name) => getRawEditorExtension(name))));
114
130
  });
131
+ app.get('/oauthCredentials/:name', async (req, res) => {
132
+ var _a;
133
+ const name = req.params['name'];
134
+ if (name) {
135
+ const manifest = await (0, packagemanifest_1.readManifest)();
136
+ const provider = (_a = manifest['oauthProviders']) === null || _a === void 0 ? void 0 : _a.find((one) => one.name === name);
137
+ if (provider && oldFs.existsSync(`${name}.credentials.local`)) {
138
+ const credentials = JSON.parse((await fs.readFile(`${name}.credentials.local`)).toString());
139
+ res.send(JSON.stringify(Object.assign(Object.assign({}, provider), credentials)));
140
+ }
141
+ }
142
+ else {
143
+ res.sendStatus(404);
144
+ }
145
+ });
115
146
  app.listen(9900, 'localhost', () => {
116
147
  console.log('Listening at http://localhost:9900/extension.js');
117
148
  });
@@ -18,7 +18,7 @@ function copyFolderRecursiveSync(source, targetFolder) {
18
18
  var files = [];
19
19
  // Check if folder needs to be created or integrated
20
20
  if (!fs.existsSync(targetFolder)) {
21
- fs.mkdirSync(targetFolder);
21
+ fs.mkdirSync(targetFolder, { recursive: true });
22
22
  }
23
23
  // Copy
24
24
  if (fs.lstatSync(source).isDirectory()) {
package/src/index.js CHANGED
@@ -114,7 +114,7 @@ class LucidSuiteExtensionCLI {
114
114
  break;
115
115
  case 'build-editor-extension':
116
116
  if ((0, package_1.currentlyInPackage)()) {
117
- await (0, editorextension_1.buildEditorExtension)(parsed['name'], parsed['quiet']);
117
+ await (0, editorextension_1.buildEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet']);
118
118
  }
119
119
  else {
120
120
  console.error('Not currently in a Lucid extension package folder');
@@ -146,7 +146,7 @@ class LucidSuiteExtensionCLI {
146
146
  break;
147
147
  case 'watch-editor-extension':
148
148
  if ((0, package_1.currentlyInPackage)()) {
149
- await (0, editorextension_1.watchEditorExtension)(parsed['name'], parsed['quiet']);
149
+ await (0, editorextension_1.watchEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet']);
150
150
  }
151
151
  else {
152
152
  console.error('Not currently in a Lucid extension package folder');