@theia/application-package 1.45.1 → 1.46.0-next.72
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/api.d.ts +5 -5
- package/lib/api.js +23 -23
- package/lib/application-package.d.ts +88 -82
- package/lib/application-package.d.ts.map +1 -1
- package/lib/application-package.js +262 -232
- package/lib/application-package.js.map +1 -1
- package/lib/application-package.spec.d.ts +1 -1
- package/lib/application-package.spec.js +57 -57
- package/lib/application-props.d.ts +172 -171
- package/lib/application-props.d.ts.map +1 -1
- package/lib/application-props.js +102 -101
- package/lib/application-props.js.map +1 -1
- package/lib/environment.d.ts +39 -39
- package/lib/environment.js +73 -73
- package/lib/extension-package-collector.d.ts +15 -15
- package/lib/extension-package-collector.js +76 -76
- package/lib/extension-package.d.ts +65 -63
- package/lib/extension-package.d.ts.map +1 -1
- package/lib/extension-package.js +176 -176
- package/lib/extension-package.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +33 -33
- package/lib/json-file.d.ts +3 -3
- package/lib/json-file.js +26 -26
- package/lib/npm-registry.d.ts +73 -73
- package/lib/npm-registry.js +101 -101
- package/package.json +5 -5
- package/src/api.ts +21 -21
- package/src/application-package.spec.ts +62 -62
- package/src/application-package.ts +334 -297
- package/src/application-props.ts +264 -263
- package/src/environment.ts +76 -76
- package/src/extension-package-collector.ts +83 -83
- package/src/extension-package.ts +223 -221
- package/src/index.ts +22 -22
- package/src/json-file.ts +25 -25
- package/src/npm-registry.ts +161 -161
package/src/environment.ts
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
const isElectron: () => boolean = require('is-electron');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The electron specific environment.
|
|
21
|
-
*/
|
|
22
|
-
class ElectronEnv {
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Environment variable that can be accessed on the `process` to check if running in electron or not.
|
|
26
|
-
*/
|
|
27
|
-
readonly THEIA_ELECTRON_VERSION = 'THEIA_ELECTRON_VERSION';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* `true` if running in electron. Otherwise, `false`.
|
|
31
|
-
*
|
|
32
|
-
* Can be called from both the `main` and the render process. Also works for forked cluster workers.
|
|
33
|
-
*/
|
|
34
|
-
is(): boolean {
|
|
35
|
-
return isElectron();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* `true` if running in Electron in development mode. Otherwise, `false`.
|
|
40
|
-
*
|
|
41
|
-
* Cannot be used from the browser. From the browser, it is always `false`.
|
|
42
|
-
*/
|
|
43
|
-
isDevMode(): boolean {
|
|
44
|
-
return this.is()
|
|
45
|
-
&& typeof process !== 'undefined'
|
|
46
|
-
// `defaultApp` does not exist on the Node.js API, but on electron (`electron.d.ts`).
|
|
47
|
-
&& ((process as any).defaultApp || /node_modules[/\\]electron[/\\]/.test(process.execPath)); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Creates and return with a new environment object which always contains the `ELECTRON_RUN_AS_NODE: 1` property pair.
|
|
52
|
-
* This should be used to `spawn` and `fork` a new Node.js process from the Node.js shipped with Electron. Otherwise, a new Electron
|
|
53
|
-
* process will be spawned which [has side-effects](https://github.com/eclipse-theia/theia/issues/5385).
|
|
54
|
-
*
|
|
55
|
-
* If called from the backend and the `env` argument is not defined, it falls back to `process.env` such as Node.js behaves
|
|
56
|
-
* with the [`SpawnOptions`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
|
|
57
|
-
* If `env` is defined, it will be shallow-copied.
|
|
58
|
-
*
|
|
59
|
-
* Calling this function from the frontend does not make any sense, hence throw an error.
|
|
60
|
-
*/
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
runAsNodeEnv(env?: any): any & { ELECTRON_RUN_AS_NODE: 1 } {
|
|
63
|
-
if (typeof process === 'undefined') {
|
|
64
|
-
throw new Error("'process' cannot be undefined.");
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
...(env === undefined ? process.env : env),
|
|
68
|
-
ELECTRON_RUN_AS_NODE: 1
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const electron = new ElectronEnv();
|
|
75
|
-
const environment: Readonly<{ electron: ElectronEnv }> = { electron };
|
|
76
|
-
export { environment };
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
const isElectron: () => boolean = require('is-electron');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The electron specific environment.
|
|
21
|
+
*/
|
|
22
|
+
class ElectronEnv {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Environment variable that can be accessed on the `process` to check if running in electron or not.
|
|
26
|
+
*/
|
|
27
|
+
readonly THEIA_ELECTRON_VERSION = 'THEIA_ELECTRON_VERSION';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `true` if running in electron. Otherwise, `false`.
|
|
31
|
+
*
|
|
32
|
+
* Can be called from both the `main` and the render process. Also works for forked cluster workers.
|
|
33
|
+
*/
|
|
34
|
+
is(): boolean {
|
|
35
|
+
return isElectron();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `true` if running in Electron in development mode. Otherwise, `false`.
|
|
40
|
+
*
|
|
41
|
+
* Cannot be used from the browser. From the browser, it is always `false`.
|
|
42
|
+
*/
|
|
43
|
+
isDevMode(): boolean {
|
|
44
|
+
return this.is()
|
|
45
|
+
&& typeof process !== 'undefined'
|
|
46
|
+
// `defaultApp` does not exist on the Node.js API, but on electron (`electron.d.ts`).
|
|
47
|
+
&& ((process as any).defaultApp || /node_modules[/\\]electron[/\\]/.test(process.execPath)); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates and return with a new environment object which always contains the `ELECTRON_RUN_AS_NODE: 1` property pair.
|
|
52
|
+
* This should be used to `spawn` and `fork` a new Node.js process from the Node.js shipped with Electron. Otherwise, a new Electron
|
|
53
|
+
* process will be spawned which [has side-effects](https://github.com/eclipse-theia/theia/issues/5385).
|
|
54
|
+
*
|
|
55
|
+
* If called from the backend and the `env` argument is not defined, it falls back to `process.env` such as Node.js behaves
|
|
56
|
+
* with the [`SpawnOptions`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).
|
|
57
|
+
* If `env` is defined, it will be shallow-copied.
|
|
58
|
+
*
|
|
59
|
+
* Calling this function from the frontend does not make any sense, hence throw an error.
|
|
60
|
+
*/
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
runAsNodeEnv(env?: any): any & { ELECTRON_RUN_AS_NODE: 1 } {
|
|
63
|
+
if (typeof process === 'undefined') {
|
|
64
|
+
throw new Error("'process' cannot be undefined.");
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...(env === undefined ? process.env : env),
|
|
68
|
+
ELECTRON_RUN_AS_NODE: 1
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const electron = new ElectronEnv();
|
|
75
|
+
const environment: Readonly<{ electron: ElectronEnv }> = { electron };
|
|
76
|
+
export { environment };
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { readJsonFile } from './json-file';
|
|
18
|
-
import { NodePackage, PublishedNodePackage } from './npm-registry';
|
|
19
|
-
import { ExtensionPackage, ExtensionPackageOptions, RawExtensionPackage } from './extension-package';
|
|
20
|
-
|
|
21
|
-
export class ExtensionPackageCollector {
|
|
22
|
-
|
|
23
|
-
protected readonly sorted: ExtensionPackage[] = [];
|
|
24
|
-
protected readonly visited = new Map<string, boolean>();
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
protected readonly extensionPackageFactory: (raw: PublishedNodePackage, options?: ExtensionPackageOptions) => ExtensionPackage,
|
|
28
|
-
protected readonly resolveModule: (modulePath: string) => string
|
|
29
|
-
) { }
|
|
30
|
-
|
|
31
|
-
protected root: NodePackage;
|
|
32
|
-
collect(pck: NodePackage): ReadonlyArray<ExtensionPackage> {
|
|
33
|
-
this.root = pck;
|
|
34
|
-
this.collectPackages(pck);
|
|
35
|
-
return this.sorted;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected collectPackages(pck: NodePackage): void {
|
|
39
|
-
for (const [dependency, versionRange] of [
|
|
40
|
-
...Object.entries(pck.dependencies ?? {}),
|
|
41
|
-
...Object.entries(pck.peerDependencies ?? {})
|
|
42
|
-
]) {
|
|
43
|
-
this.collectPackage(dependency, versionRange!);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected parent: ExtensionPackage | undefined;
|
|
48
|
-
protected collectPackagesWithParent(pck: NodePackage, parent: ExtensionPackage): void {
|
|
49
|
-
const current = this.parent;
|
|
50
|
-
this.parent = parent;
|
|
51
|
-
this.collectPackages(pck);
|
|
52
|
-
this.parent = current;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
protected collectPackage(name: string, versionRange: string): void {
|
|
56
|
-
if (this.visited.has(name)) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.visited.set(name, true);
|
|
60
|
-
|
|
61
|
-
let packagePath: string | undefined;
|
|
62
|
-
try {
|
|
63
|
-
packagePath = this.resolveModule(name);
|
|
64
|
-
} catch {
|
|
65
|
-
console.debug(`Failed to resolve module: ${name}`);
|
|
66
|
-
}
|
|
67
|
-
if (!packagePath) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const pck: NodePackage = readJsonFile(packagePath);
|
|
71
|
-
if (RawExtensionPackage.is(pck)) {
|
|
72
|
-
const parent = this.parent;
|
|
73
|
-
const version = pck.version;
|
|
74
|
-
const transitive = !(name in this.root.dependencies!);
|
|
75
|
-
pck.installed = { packagePath, version, parent, transitive };
|
|
76
|
-
pck.version = versionRange;
|
|
77
|
-
const extensionPackage = this.extensionPackageFactory(pck, { alias: name });
|
|
78
|
-
this.collectPackagesWithParent(pck, extensionPackage);
|
|
79
|
-
this.sorted.push(extensionPackage);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { readJsonFile } from './json-file';
|
|
18
|
+
import { NodePackage, PublishedNodePackage } from './npm-registry';
|
|
19
|
+
import { ExtensionPackage, ExtensionPackageOptions, RawExtensionPackage } from './extension-package';
|
|
20
|
+
|
|
21
|
+
export class ExtensionPackageCollector {
|
|
22
|
+
|
|
23
|
+
protected readonly sorted: ExtensionPackage[] = [];
|
|
24
|
+
protected readonly visited = new Map<string, boolean>();
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
protected readonly extensionPackageFactory: (raw: PublishedNodePackage, options?: ExtensionPackageOptions) => ExtensionPackage,
|
|
28
|
+
protected readonly resolveModule: (modulePath: string) => string
|
|
29
|
+
) { }
|
|
30
|
+
|
|
31
|
+
protected root: NodePackage;
|
|
32
|
+
collect(pck: NodePackage): ReadonlyArray<ExtensionPackage> {
|
|
33
|
+
this.root = pck;
|
|
34
|
+
this.collectPackages(pck);
|
|
35
|
+
return this.sorted;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected collectPackages(pck: NodePackage): void {
|
|
39
|
+
for (const [dependency, versionRange] of [
|
|
40
|
+
...Object.entries(pck.dependencies ?? {}),
|
|
41
|
+
...Object.entries(pck.peerDependencies ?? {})
|
|
42
|
+
]) {
|
|
43
|
+
this.collectPackage(dependency, versionRange!);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected parent: ExtensionPackage | undefined;
|
|
48
|
+
protected collectPackagesWithParent(pck: NodePackage, parent: ExtensionPackage): void {
|
|
49
|
+
const current = this.parent;
|
|
50
|
+
this.parent = parent;
|
|
51
|
+
this.collectPackages(pck);
|
|
52
|
+
this.parent = current;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected collectPackage(name: string, versionRange: string): void {
|
|
56
|
+
if (this.visited.has(name)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.visited.set(name, true);
|
|
60
|
+
|
|
61
|
+
let packagePath: string | undefined;
|
|
62
|
+
try {
|
|
63
|
+
packagePath = this.resolveModule(name);
|
|
64
|
+
} catch {
|
|
65
|
+
console.debug(`Failed to resolve module: ${name}`);
|
|
66
|
+
}
|
|
67
|
+
if (!packagePath) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const pck: NodePackage = readJsonFile(packagePath);
|
|
71
|
+
if (RawExtensionPackage.is(pck)) {
|
|
72
|
+
const parent = this.parent;
|
|
73
|
+
const version = pck.version;
|
|
74
|
+
const transitive = !(name in this.root.dependencies!);
|
|
75
|
+
pck.installed = { packagePath, version, parent, transitive };
|
|
76
|
+
pck.version = versionRange;
|
|
77
|
+
const extensionPackage = this.extensionPackageFactory(pck, { alias: name });
|
|
78
|
+
this.collectPackagesWithParent(pck, extensionPackage);
|
|
79
|
+
this.sorted.push(extensionPackage);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|