@theia/application-manager 1.48.1 → 1.48.2
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 +25 -25
- package/lib/application-package-manager.d.ts +45 -45
- package/lib/application-package-manager.js +225 -225
- package/lib/application-process.d.ts +19 -19
- package/lib/application-process.js +72 -72
- package/lib/expose-loader.d.ts +8 -8
- package/lib/expose-loader.js +69 -69
- package/lib/generator/abstract-generator.d.ts +17 -17
- package/lib/generator/abstract-generator.js +57 -57
- package/lib/generator/backend-generator.d.ts +7 -7
- package/lib/generator/backend-generator.js +196 -196
- package/lib/generator/frontend-generator.d.ts +13 -13
- package/lib/generator/frontend-generator.js +212 -212
- package/lib/generator/index.d.ts +3 -3
- package/lib/generator/index.js +21 -21
- package/lib/generator/webpack-generator.d.ts +12 -12
- package/lib/generator/webpack-generator.js +493 -493
- package/lib/index.d.ts +3 -3
- package/lib/index.js +21 -21
- package/lib/package.spec.js +25 -25
- package/lib/rebuild.d.ts +24 -24
- package/lib/rebuild.js +309 -309
- package/package.json +6 -6
- package/src/application-package-manager.ts +263 -263
- package/src/application-process.ts +80 -80
- package/src/expose-loader.ts +80 -80
- package/src/generator/abstract-generator.ts +69 -69
- package/src/generator/backend-generator.ts +198 -198
- package/src/generator/frontend-generator.ts +222 -222
- package/src/generator/index.ts +19 -19
- package/src/generator/webpack-generator.ts +501 -501
- package/src/index.ts +19 -19
- package/src/package.spec.ts +28 -28
- package/src/rebuild.ts +345 -345
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2017 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ApplicationProcess = void 0;
|
|
19
|
-
const path = require("path");
|
|
20
|
-
const fs = require("fs-extra");
|
|
21
|
-
const cp = require("child_process");
|
|
22
|
-
class ApplicationProcess {
|
|
23
|
-
constructor(pck, binProjectPath) {
|
|
24
|
-
this.pck = pck;
|
|
25
|
-
this.binProjectPath = binProjectPath;
|
|
26
|
-
this.defaultOptions = {
|
|
27
|
-
cwd: this.pck.projectPath,
|
|
28
|
-
env: process.env
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
spawn(command, args, options) {
|
|
32
|
-
return cp.spawn(command, args || [], Object.assign({}, this.defaultOptions, options));
|
|
33
|
-
}
|
|
34
|
-
fork(modulePath, args, options) {
|
|
35
|
-
return cp.fork(modulePath, args, Object.assign({}, this.defaultOptions, options));
|
|
36
|
-
}
|
|
37
|
-
canRun(command) {
|
|
38
|
-
return fs.existsSync(this.resolveBin(command));
|
|
39
|
-
}
|
|
40
|
-
run(command, args, options) {
|
|
41
|
-
const commandProcess = this.spawnBin(command, args, options);
|
|
42
|
-
return this.promisify(command, commandProcess);
|
|
43
|
-
}
|
|
44
|
-
spawnBin(command, args, options) {
|
|
45
|
-
const binPath = this.resolveBin(command);
|
|
46
|
-
return this.spawn(binPath, args, options);
|
|
47
|
-
}
|
|
48
|
-
resolveBin(command) {
|
|
49
|
-
const commandPath = path.resolve(this.binProjectPath, 'node_modules', '.bin', command);
|
|
50
|
-
return process.platform === 'win32' ? commandPath + '.cmd' : commandPath;
|
|
51
|
-
}
|
|
52
|
-
promisify(command, p) {
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
p.stdout.on('data', data => this.pck.log(data.toString()));
|
|
55
|
-
p.stderr.on('data', data => this.pck.error(data.toString()));
|
|
56
|
-
p.on('error', reject);
|
|
57
|
-
p.on('close', (code, signal) => {
|
|
58
|
-
if (signal) {
|
|
59
|
-
reject(new Error(`${command} exited with an unexpected signal: ${signal}.`));
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (code === 0) {
|
|
63
|
-
resolve();
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
reject(new Error(`${command} exited with an unexpected code: ${code}.`));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.ApplicationProcess = ApplicationProcess;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ApplicationProcess = void 0;
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const fs = require("fs-extra");
|
|
21
|
+
const cp = require("child_process");
|
|
22
|
+
class ApplicationProcess {
|
|
23
|
+
constructor(pck, binProjectPath) {
|
|
24
|
+
this.pck = pck;
|
|
25
|
+
this.binProjectPath = binProjectPath;
|
|
26
|
+
this.defaultOptions = {
|
|
27
|
+
cwd: this.pck.projectPath,
|
|
28
|
+
env: process.env
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
spawn(command, args, options) {
|
|
32
|
+
return cp.spawn(command, args || [], Object.assign({}, this.defaultOptions, options));
|
|
33
|
+
}
|
|
34
|
+
fork(modulePath, args, options) {
|
|
35
|
+
return cp.fork(modulePath, args, Object.assign({}, this.defaultOptions, options));
|
|
36
|
+
}
|
|
37
|
+
canRun(command) {
|
|
38
|
+
return fs.existsSync(this.resolveBin(command));
|
|
39
|
+
}
|
|
40
|
+
run(command, args, options) {
|
|
41
|
+
const commandProcess = this.spawnBin(command, args, options);
|
|
42
|
+
return this.promisify(command, commandProcess);
|
|
43
|
+
}
|
|
44
|
+
spawnBin(command, args, options) {
|
|
45
|
+
const binPath = this.resolveBin(command);
|
|
46
|
+
return this.spawn(binPath, args, options);
|
|
47
|
+
}
|
|
48
|
+
resolveBin(command) {
|
|
49
|
+
const commandPath = path.resolve(this.binProjectPath, 'node_modules', '.bin', command);
|
|
50
|
+
return process.platform === 'win32' ? commandPath + '.cmd' : commandPath;
|
|
51
|
+
}
|
|
52
|
+
promisify(command, p) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
p.stdout.on('data', data => this.pck.log(data.toString()));
|
|
55
|
+
p.stderr.on('data', data => this.pck.error(data.toString()));
|
|
56
|
+
p.on('error', reject);
|
|
57
|
+
p.on('close', (code, signal) => {
|
|
58
|
+
if (signal) {
|
|
59
|
+
reject(new Error(`${command} exited with an unexpected signal: ${signal}.`));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (code === 0) {
|
|
63
|
+
resolve();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
reject(new Error(`${command} exited with an unexpected code: ${code}.`));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.ApplicationProcess = ApplicationProcess;
|
|
73
73
|
//# sourceMappingURL=application-process.js.map
|
package/lib/expose-loader.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { RawSourceMap } from 'source-map';
|
|
2
|
-
declare const _default: (this: any, source: string, sourceMap?: RawSourceMap | undefined) => string | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* Expose bundled modules on window.theia.moduleName namespace, e.g.
|
|
5
|
-
* window['theia']['@theia/core/lib/common/uri'].
|
|
6
|
-
* Such syntax can be used by external code, for instance, for testing.
|
|
7
|
-
*/
|
|
8
|
-
export = _default;
|
|
1
|
+
import type { RawSourceMap } from 'source-map';
|
|
2
|
+
declare const _default: (this: any, source: string, sourceMap?: RawSourceMap | undefined) => string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Expose bundled modules on window.theia.moduleName namespace, e.g.
|
|
5
|
+
* window['theia']['@theia/core/lib/common/uri'].
|
|
6
|
+
* Such syntax can be used by external code, for instance, for testing.
|
|
7
|
+
*/
|
|
8
|
+
export = _default;
|
|
9
9
|
//# sourceMappingURL=expose-loader.d.ts.map
|
package/lib/expose-loader.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
const fs = require("fs-extra");
|
|
18
|
-
const path = require("path");
|
|
19
|
-
const application_package_1 = require("@theia/application-package/lib/application-package");
|
|
20
|
-
const modulePackages = [];
|
|
21
|
-
for (const extensionPackage of new application_package_1.ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
|
|
22
|
-
modulePackages.push({
|
|
23
|
-
name: extensionPackage.name,
|
|
24
|
-
dir: path.dirname(extensionPackage.raw.installed.packagePath)
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function exposeModule(modulePackage, resourcePath, source) {
|
|
28
|
-
if (!modulePackage.name) {
|
|
29
|
-
return source;
|
|
30
|
-
}
|
|
31
|
-
const { dir, name } = path.parse(resourcePath);
|
|
32
|
-
let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
|
|
33
|
-
if (name !== 'index') {
|
|
34
|
-
moduleName = path.join(moduleName, name);
|
|
35
|
-
}
|
|
36
|
-
if (path.sep !== '/') {
|
|
37
|
-
moduleName = moduleName.split(path.sep).join('/');
|
|
38
|
-
}
|
|
39
|
-
return source + `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = this;\n`;
|
|
40
|
-
}
|
|
41
|
-
module.exports = function (source, sourceMap) {
|
|
42
|
-
if (this.cacheable) {
|
|
43
|
-
this.cacheable();
|
|
44
|
-
}
|
|
45
|
-
let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + path.sep));
|
|
46
|
-
if (modulePackage) {
|
|
47
|
-
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const searchString = path.sep + 'node_modules';
|
|
51
|
-
const index = this.resourcePath.lastIndexOf(searchString);
|
|
52
|
-
if (index !== -1) {
|
|
53
|
-
const nodeModulesPath = this.resourcePath.substring(0, index + searchString.length);
|
|
54
|
-
let dir = this.resourcePath;
|
|
55
|
-
while ((dir = path.dirname(dir)) !== nodeModulesPath) {
|
|
56
|
-
try {
|
|
57
|
-
const { name } = fs.readJSONSync(path.join(dir, 'package.json'));
|
|
58
|
-
modulePackage = { name, dir };
|
|
59
|
-
modulePackages.push(modulePackage);
|
|
60
|
-
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
/** no-op */
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
this.callback(undefined, source, sourceMap);
|
|
69
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
const fs = require("fs-extra");
|
|
18
|
+
const path = require("path");
|
|
19
|
+
const application_package_1 = require("@theia/application-package/lib/application-package");
|
|
20
|
+
const modulePackages = [];
|
|
21
|
+
for (const extensionPackage of new application_package_1.ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
|
|
22
|
+
modulePackages.push({
|
|
23
|
+
name: extensionPackage.name,
|
|
24
|
+
dir: path.dirname(extensionPackage.raw.installed.packagePath)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function exposeModule(modulePackage, resourcePath, source) {
|
|
28
|
+
if (!modulePackage.name) {
|
|
29
|
+
return source;
|
|
30
|
+
}
|
|
31
|
+
const { dir, name } = path.parse(resourcePath);
|
|
32
|
+
let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
|
|
33
|
+
if (name !== 'index') {
|
|
34
|
+
moduleName = path.join(moduleName, name);
|
|
35
|
+
}
|
|
36
|
+
if (path.sep !== '/') {
|
|
37
|
+
moduleName = moduleName.split(path.sep).join('/');
|
|
38
|
+
}
|
|
39
|
+
return source + `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = this;\n`;
|
|
40
|
+
}
|
|
41
|
+
module.exports = function (source, sourceMap) {
|
|
42
|
+
if (this.cacheable) {
|
|
43
|
+
this.cacheable();
|
|
44
|
+
}
|
|
45
|
+
let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir + path.sep));
|
|
46
|
+
if (modulePackage) {
|
|
47
|
+
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const searchString = path.sep + 'node_modules';
|
|
51
|
+
const index = this.resourcePath.lastIndexOf(searchString);
|
|
52
|
+
if (index !== -1) {
|
|
53
|
+
const nodeModulesPath = this.resourcePath.substring(0, index + searchString.length);
|
|
54
|
+
let dir = this.resourcePath;
|
|
55
|
+
while ((dir = path.dirname(dir)) !== nodeModulesPath) {
|
|
56
|
+
try {
|
|
57
|
+
const { name } = fs.readJSONSync(path.join(dir, 'package.json'));
|
|
58
|
+
modulePackage = { name, dir };
|
|
59
|
+
modulePackages.push(modulePackage);
|
|
60
|
+
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
/** no-op */
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.callback(undefined, source, sourceMap);
|
|
69
|
+
};
|
|
70
70
|
//# sourceMappingURL=expose-loader.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ApplicationPackage } from '@theia/application-package';
|
|
2
|
-
export interface GeneratorOptions {
|
|
3
|
-
mode?: 'development' | 'production';
|
|
4
|
-
splitFrontend?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class AbstractGenerator {
|
|
7
|
-
protected readonly pck: ApplicationPackage;
|
|
8
|
-
protected options: GeneratorOptions;
|
|
9
|
-
constructor(pck: ApplicationPackage, options?: GeneratorOptions);
|
|
10
|
-
protected ifBrowser(value: string, defaultValue?: string): string;
|
|
11
|
-
protected ifElectron(value: string, defaultValue?: string): string;
|
|
12
|
-
protected ifBrowserOnly(value: string, defaultValue?: string): string;
|
|
13
|
-
protected write(path: string, content: string): Promise<void>;
|
|
14
|
-
protected ifMonaco(value: () => string, defaultValue?: () => string): string;
|
|
15
|
-
protected ifPackage(packageName: string | string[], value: string | (() => string), defaultValue?: string | (() => string)): string;
|
|
16
|
-
protected prettyStringify(object: object): string;
|
|
17
|
-
}
|
|
1
|
+
import { ApplicationPackage } from '@theia/application-package';
|
|
2
|
+
export interface GeneratorOptions {
|
|
3
|
+
mode?: 'development' | 'production';
|
|
4
|
+
splitFrontend?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class AbstractGenerator {
|
|
7
|
+
protected readonly pck: ApplicationPackage;
|
|
8
|
+
protected options: GeneratorOptions;
|
|
9
|
+
constructor(pck: ApplicationPackage, options?: GeneratorOptions);
|
|
10
|
+
protected ifBrowser(value: string, defaultValue?: string): string;
|
|
11
|
+
protected ifElectron(value: string, defaultValue?: string): string;
|
|
12
|
+
protected ifBrowserOnly(value: string, defaultValue?: string): string;
|
|
13
|
+
protected write(path: string, content: string): Promise<void>;
|
|
14
|
+
protected ifMonaco(value: () => string, defaultValue?: () => string): string;
|
|
15
|
+
protected ifPackage(packageName: string | string[], value: string | (() => string), defaultValue?: string | (() => string)): string;
|
|
16
|
+
protected prettyStringify(object: object): string;
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=abstract-generator.d.ts.map
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2017 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AbstractGenerator = void 0;
|
|
19
|
-
const fs = require("fs-extra");
|
|
20
|
-
class AbstractGenerator {
|
|
21
|
-
constructor(pck, options = {}) {
|
|
22
|
-
this.pck = pck;
|
|
23
|
-
this.options = options;
|
|
24
|
-
}
|
|
25
|
-
ifBrowser(value, defaultValue = '') {
|
|
26
|
-
return this.pck.ifBrowser(value, defaultValue);
|
|
27
|
-
}
|
|
28
|
-
ifElectron(value, defaultValue = '') {
|
|
29
|
-
return this.pck.ifElectron(value, defaultValue);
|
|
30
|
-
}
|
|
31
|
-
ifBrowserOnly(value, defaultValue = '') {
|
|
32
|
-
return this.pck.ifBrowserOnly(value, defaultValue);
|
|
33
|
-
}
|
|
34
|
-
async write(path, content) {
|
|
35
|
-
await fs.ensureFile(path);
|
|
36
|
-
await fs.writeFile(path, content);
|
|
37
|
-
}
|
|
38
|
-
ifMonaco(value, defaultValue = () => '') {
|
|
39
|
-
return this.ifPackage([
|
|
40
|
-
'@theia/monaco',
|
|
41
|
-
'@theia/monaco-editor-core'
|
|
42
|
-
], value, defaultValue);
|
|
43
|
-
}
|
|
44
|
-
ifPackage(packageName, value, defaultValue = '') {
|
|
45
|
-
const packages = Array.isArray(packageName) ? packageName : [packageName];
|
|
46
|
-
if (this.pck.extensionPackages.some(e => packages.includes(e.name))) {
|
|
47
|
-
return typeof value === 'string' ? value : value();
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return typeof defaultValue === 'string' ? defaultValue : defaultValue();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
prettyStringify(object) {
|
|
54
|
-
return JSON.stringify(object, undefined, 4);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.AbstractGenerator = AbstractGenerator;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AbstractGenerator = void 0;
|
|
19
|
+
const fs = require("fs-extra");
|
|
20
|
+
class AbstractGenerator {
|
|
21
|
+
constructor(pck, options = {}) {
|
|
22
|
+
this.pck = pck;
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
ifBrowser(value, defaultValue = '') {
|
|
26
|
+
return this.pck.ifBrowser(value, defaultValue);
|
|
27
|
+
}
|
|
28
|
+
ifElectron(value, defaultValue = '') {
|
|
29
|
+
return this.pck.ifElectron(value, defaultValue);
|
|
30
|
+
}
|
|
31
|
+
ifBrowserOnly(value, defaultValue = '') {
|
|
32
|
+
return this.pck.ifBrowserOnly(value, defaultValue);
|
|
33
|
+
}
|
|
34
|
+
async write(path, content) {
|
|
35
|
+
await fs.ensureFile(path);
|
|
36
|
+
await fs.writeFile(path, content);
|
|
37
|
+
}
|
|
38
|
+
ifMonaco(value, defaultValue = () => '') {
|
|
39
|
+
return this.ifPackage([
|
|
40
|
+
'@theia/monaco',
|
|
41
|
+
'@theia/monaco-editor-core'
|
|
42
|
+
], value, defaultValue);
|
|
43
|
+
}
|
|
44
|
+
ifPackage(packageName, value, defaultValue = '') {
|
|
45
|
+
const packages = Array.isArray(packageName) ? packageName : [packageName];
|
|
46
|
+
if (this.pck.extensionPackages.some(e => packages.includes(e.name))) {
|
|
47
|
+
return typeof value === 'string' ? value : value();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return typeof defaultValue === 'string' ? defaultValue : defaultValue();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
prettyStringify(object) {
|
|
54
|
+
return JSON.stringify(object, undefined, 4);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.AbstractGenerator = AbstractGenerator;
|
|
58
58
|
//# sourceMappingURL=abstract-generator.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AbstractGenerator } from './abstract-generator';
|
|
2
|
-
export declare class BackendGenerator extends AbstractGenerator {
|
|
3
|
-
generate(): Promise<void>;
|
|
4
|
-
protected compileElectronMain(electronMainModules?: Map<string, string>): string;
|
|
5
|
-
protected compileServer(backendModules: Map<string, string>): string;
|
|
6
|
-
protected compileMain(backendModules: Map<string, string>): string;
|
|
7
|
-
}
|
|
1
|
+
import { AbstractGenerator } from './abstract-generator';
|
|
2
|
+
export declare class BackendGenerator extends AbstractGenerator {
|
|
3
|
+
generate(): Promise<void>;
|
|
4
|
+
protected compileElectronMain(electronMainModules?: Map<string, string>): string;
|
|
5
|
+
protected compileServer(backendModules: Map<string, string>): string;
|
|
6
|
+
protected compileMain(backendModules: Map<string, string>): string;
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=backend-generator.d.ts.map
|