@theia/application-package 1.45.0 → 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.
Files changed (38) hide show
  1. package/README.md +25 -25
  2. package/lib/api.d.ts +5 -5
  3. package/lib/api.js +23 -23
  4. package/lib/application-package.d.ts +88 -82
  5. package/lib/application-package.d.ts.map +1 -1
  6. package/lib/application-package.js +262 -232
  7. package/lib/application-package.js.map +1 -1
  8. package/lib/application-package.spec.d.ts +1 -1
  9. package/lib/application-package.spec.js +57 -57
  10. package/lib/application-props.d.ts +172 -171
  11. package/lib/application-props.d.ts.map +1 -1
  12. package/lib/application-props.js +102 -101
  13. package/lib/application-props.js.map +1 -1
  14. package/lib/environment.d.ts +39 -39
  15. package/lib/environment.js +73 -73
  16. package/lib/extension-package-collector.d.ts +15 -15
  17. package/lib/extension-package-collector.js +76 -76
  18. package/lib/extension-package.d.ts +65 -63
  19. package/lib/extension-package.d.ts.map +1 -1
  20. package/lib/extension-package.js +176 -176
  21. package/lib/extension-package.js.map +1 -1
  22. package/lib/index.d.ts +6 -6
  23. package/lib/index.js +33 -33
  24. package/lib/json-file.d.ts +3 -3
  25. package/lib/json-file.js +26 -26
  26. package/lib/npm-registry.d.ts +73 -73
  27. package/lib/npm-registry.js +101 -101
  28. package/package.json +5 -5
  29. package/src/api.ts +21 -21
  30. package/src/application-package.spec.ts +62 -62
  31. package/src/application-package.ts +334 -297
  32. package/src/application-props.ts +264 -263
  33. package/src/environment.ts +76 -76
  34. package/src/extension-package-collector.ts +83 -83
  35. package/src/extension-package.ts +223 -221
  36. package/src/index.ts +22 -22
  37. package/src/json-file.ts +25 -25
  38. package/src/npm-registry.ts +161 -161
@@ -1,221 +1,223 @@
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 * as fs from 'fs-extra';
18
- import * as paths from 'path';
19
- import * as semver from 'semver';
20
- import { NpmRegistry, PublishedNodePackage, NodePackage } from './npm-registry';
21
-
22
- export interface Extension {
23
- frontendPreload?: string;
24
- frontend?: string;
25
- frontendElectron?: string;
26
- secondaryWindow?: string;
27
- backend?: string;
28
- backendElectron?: string;
29
- electronMain?: string;
30
- preload?: string;
31
- }
32
-
33
- export interface ExtensionPackageOptions {
34
- /**
35
- * Alias to use in place of the original package's name.
36
- */
37
- alias?: string
38
- }
39
-
40
- export class ExtensionPackage {
41
-
42
- protected _name: string;
43
-
44
- constructor(
45
- readonly raw: PublishedNodePackage & Partial<RawExtensionPackage>,
46
- protected readonly registry: NpmRegistry,
47
- options: ExtensionPackageOptions = {}
48
- ) {
49
- this._name = options.alias ?? raw.name;
50
- }
51
-
52
- /**
53
- * The name of the extension's package as defined in "dependencies" (might be aliased)
54
- */
55
- get name(): string {
56
- return this._name;
57
- }
58
-
59
- get version(): string {
60
- if (this.raw.installed) {
61
- return this.raw.installed.version;
62
- }
63
- if (this.raw.view) {
64
- const latestVersion = this.raw.view.latestVersion;
65
- if (latestVersion) {
66
- return latestVersion;
67
- }
68
- }
69
- return this.raw.version;
70
- }
71
-
72
- get description(): string {
73
- return this.raw.description || '';
74
- }
75
-
76
- get theiaExtensions(): Extension[] {
77
- return this.raw.theiaExtensions || [];
78
- }
79
-
80
- get installed(): boolean {
81
- return !!this.raw.installed;
82
- }
83
-
84
- get dependent(): string | undefined {
85
- if (!this.transitive) {
86
- return undefined;
87
- }
88
- let current = this.parent!;
89
- let parent = current.parent;
90
- while (parent !== undefined) {
91
- current = parent;
92
- parent = current.parent;
93
- }
94
- return current.name;
95
- }
96
-
97
- get transitive(): boolean {
98
- return !!this.raw.installed && this.raw.installed.transitive;
99
- }
100
-
101
- get parent(): ExtensionPackage | undefined {
102
- if (this.raw.installed) {
103
- return this.raw.installed.parent;
104
- }
105
- return undefined;
106
- }
107
-
108
- protected async view(): Promise<RawExtensionPackage.ViewState> {
109
- if (this.raw.view === undefined) {
110
- const raw = await RawExtensionPackage.view(this.registry, this.name, this.version);
111
- this.raw.view = raw ? raw.view : new RawExtensionPackage.ViewState(this.registry);
112
- }
113
- return this.raw.view!;
114
- }
115
-
116
- protected readme?: string;
117
- async getReadme(): Promise<string> {
118
- if (this.readme === undefined) {
119
- this.readme = await this.resolveReadme();
120
- }
121
- return this.readme;
122
- }
123
- protected async resolveReadme(): Promise<string> {
124
- const raw = await this.view();
125
- if (raw && raw.readme) {
126
- return raw.readme;
127
- }
128
- if (this.raw.installed) {
129
- const readmePath = paths.resolve(this.raw.installed.packagePath, '..', 'README.md');
130
- if (await fs.pathExists(readmePath)) {
131
- return fs.readFile(readmePath, { encoding: 'utf8' });
132
- }
133
- return '';
134
- }
135
- return '';
136
- }
137
-
138
- getAuthor(): string {
139
- if (this.raw.publisher) {
140
- return this.raw.publisher.username;
141
- }
142
- if (typeof this.raw.author === 'string') {
143
- return this.raw.author;
144
- }
145
- if (this.raw.author && this.raw.author.name) {
146
- return this.raw.author.name;
147
- }
148
- if (!!this.raw.maintainers && this.raw.maintainers.length > 0) {
149
- return this.raw.maintainers[0].username;
150
- }
151
- return '';
152
- }
153
-
154
- }
155
-
156
- export interface RawExtensionPackage extends PublishedNodePackage {
157
- installed?: RawExtensionPackage.InstalledState
158
- view?: RawExtensionPackage.ViewState
159
- theiaExtensions: Extension[];
160
- }
161
- export namespace RawExtensionPackage {
162
- export interface InstalledState {
163
- version: string;
164
- packagePath: string;
165
- transitive: boolean;
166
- parent?: ExtensionPackage;
167
- }
168
- export class ViewState {
169
- readme?: string;
170
- tags?: {
171
- [tag: string]: string
172
- };
173
- constructor(
174
- protected readonly registry: NpmRegistry
175
- ) { }
176
- get latestVersion(): string | undefined {
177
- if (this.tags) {
178
- if (this.registry.props.next) {
179
- const next = this.tags['next'];
180
- if (next !== undefined) {
181
- return next;
182
- }
183
- }
184
- const latest = this.tags['latest'];
185
- if (this.registry.props.next || !semver.prerelease(latest)) {
186
- return latest;
187
- }
188
- return undefined;
189
- }
190
- return undefined;
191
- }
192
- }
193
- export function is(pck: NodePackage | undefined): pck is RawExtensionPackage {
194
- return PublishedNodePackage.is(pck) && !!pck.theiaExtensions;
195
- }
196
- export async function view(registry: NpmRegistry, name: string, version?: string): Promise<RawExtensionPackage | undefined> {
197
- const result = await registry.view(name).catch(() => undefined);
198
- if (!result) {
199
- return undefined;
200
- }
201
- const tags = result['dist-tags'];
202
- const versions = [tags['latest']];
203
- if (registry.props.next) {
204
- versions.push(tags['next']);
205
- }
206
- if (version) {
207
- versions.push(tags[version], version);
208
- }
209
- for (const current of versions.reverse()) {
210
- const raw = result.versions[current];
211
- if (is(raw)) {
212
- const viewState = new ViewState(registry);
213
- viewState.readme = result.readme;
214
- viewState.tags = tags;
215
- raw.view = viewState;
216
- return raw;
217
- }
218
- }
219
- return undefined;
220
- }
221
- }
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 * as fs from 'fs-extra';
18
+ import * as paths from 'path';
19
+ import * as semver from 'semver';
20
+ import { NpmRegistry, PublishedNodePackage, NodePackage } from './npm-registry';
21
+
22
+ export interface Extension {
23
+ frontendPreload?: string;
24
+ frontendOnlyPreload?: string;
25
+ frontend?: string;
26
+ frontendOnly?: string;
27
+ frontendElectron?: string;
28
+ secondaryWindow?: string;
29
+ backend?: string;
30
+ backendElectron?: string;
31
+ electronMain?: string;
32
+ preload?: string;
33
+ }
34
+
35
+ export interface ExtensionPackageOptions {
36
+ /**
37
+ * Alias to use in place of the original package's name.
38
+ */
39
+ alias?: string
40
+ }
41
+
42
+ export class ExtensionPackage {
43
+
44
+ protected _name: string;
45
+
46
+ constructor(
47
+ readonly raw: PublishedNodePackage & Partial<RawExtensionPackage>,
48
+ protected readonly registry: NpmRegistry,
49
+ options: ExtensionPackageOptions = {}
50
+ ) {
51
+ this._name = options.alias ?? raw.name;
52
+ }
53
+
54
+ /**
55
+ * The name of the extension's package as defined in "dependencies" (might be aliased)
56
+ */
57
+ get name(): string {
58
+ return this._name;
59
+ }
60
+
61
+ get version(): string {
62
+ if (this.raw.installed) {
63
+ return this.raw.installed.version;
64
+ }
65
+ if (this.raw.view) {
66
+ const latestVersion = this.raw.view.latestVersion;
67
+ if (latestVersion) {
68
+ return latestVersion;
69
+ }
70
+ }
71
+ return this.raw.version;
72
+ }
73
+
74
+ get description(): string {
75
+ return this.raw.description || '';
76
+ }
77
+
78
+ get theiaExtensions(): Extension[] {
79
+ return this.raw.theiaExtensions || [];
80
+ }
81
+
82
+ get installed(): boolean {
83
+ return !!this.raw.installed;
84
+ }
85
+
86
+ get dependent(): string | undefined {
87
+ if (!this.transitive) {
88
+ return undefined;
89
+ }
90
+ let current = this.parent!;
91
+ let parent = current.parent;
92
+ while (parent !== undefined) {
93
+ current = parent;
94
+ parent = current.parent;
95
+ }
96
+ return current.name;
97
+ }
98
+
99
+ get transitive(): boolean {
100
+ return !!this.raw.installed && this.raw.installed.transitive;
101
+ }
102
+
103
+ get parent(): ExtensionPackage | undefined {
104
+ if (this.raw.installed) {
105
+ return this.raw.installed.parent;
106
+ }
107
+ return undefined;
108
+ }
109
+
110
+ protected async view(): Promise<RawExtensionPackage.ViewState> {
111
+ if (this.raw.view === undefined) {
112
+ const raw = await RawExtensionPackage.view(this.registry, this.name, this.version);
113
+ this.raw.view = raw ? raw.view : new RawExtensionPackage.ViewState(this.registry);
114
+ }
115
+ return this.raw.view!;
116
+ }
117
+
118
+ protected readme?: string;
119
+ async getReadme(): Promise<string> {
120
+ if (this.readme === undefined) {
121
+ this.readme = await this.resolveReadme();
122
+ }
123
+ return this.readme;
124
+ }
125
+ protected async resolveReadme(): Promise<string> {
126
+ const raw = await this.view();
127
+ if (raw && raw.readme) {
128
+ return raw.readme;
129
+ }
130
+ if (this.raw.installed) {
131
+ const readmePath = paths.resolve(this.raw.installed.packagePath, '..', 'README.md');
132
+ if (await fs.pathExists(readmePath)) {
133
+ return fs.readFile(readmePath, { encoding: 'utf8' });
134
+ }
135
+ return '';
136
+ }
137
+ return '';
138
+ }
139
+
140
+ getAuthor(): string {
141
+ if (this.raw.publisher) {
142
+ return this.raw.publisher.username;
143
+ }
144
+ if (typeof this.raw.author === 'string') {
145
+ return this.raw.author;
146
+ }
147
+ if (this.raw.author && this.raw.author.name) {
148
+ return this.raw.author.name;
149
+ }
150
+ if (!!this.raw.maintainers && this.raw.maintainers.length > 0) {
151
+ return this.raw.maintainers[0].username;
152
+ }
153
+ return '';
154
+ }
155
+
156
+ }
157
+
158
+ export interface RawExtensionPackage extends PublishedNodePackage {
159
+ installed?: RawExtensionPackage.InstalledState
160
+ view?: RawExtensionPackage.ViewState
161
+ theiaExtensions: Extension[];
162
+ }
163
+ export namespace RawExtensionPackage {
164
+ export interface InstalledState {
165
+ version: string;
166
+ packagePath: string;
167
+ transitive: boolean;
168
+ parent?: ExtensionPackage;
169
+ }
170
+ export class ViewState {
171
+ readme?: string;
172
+ tags?: {
173
+ [tag: string]: string
174
+ };
175
+ constructor(
176
+ protected readonly registry: NpmRegistry
177
+ ) { }
178
+ get latestVersion(): string | undefined {
179
+ if (this.tags) {
180
+ if (this.registry.props.next) {
181
+ const next = this.tags['next'];
182
+ if (next !== undefined) {
183
+ return next;
184
+ }
185
+ }
186
+ const latest = this.tags['latest'];
187
+ if (this.registry.props.next || !semver.prerelease(latest)) {
188
+ return latest;
189
+ }
190
+ return undefined;
191
+ }
192
+ return undefined;
193
+ }
194
+ }
195
+ export function is(pck: NodePackage | undefined): pck is RawExtensionPackage {
196
+ return PublishedNodePackage.is(pck) && !!pck.theiaExtensions;
197
+ }
198
+ export async function view(registry: NpmRegistry, name: string, version?: string): Promise<RawExtensionPackage | undefined> {
199
+ const result = await registry.view(name).catch(() => undefined);
200
+ if (!result) {
201
+ return undefined;
202
+ }
203
+ const tags = result['dist-tags'];
204
+ const versions = [tags['latest']];
205
+ if (registry.props.next) {
206
+ versions.push(tags['next']);
207
+ }
208
+ if (version) {
209
+ versions.push(tags[version], version);
210
+ }
211
+ for (const current of versions.reverse()) {
212
+ const raw = result.versions[current];
213
+ if (is(raw)) {
214
+ const viewState = new ViewState(registry);
215
+ viewState.readme = result.readme;
216
+ viewState.tags = tags;
217
+ raw.view = viewState;
218
+ return raw;
219
+ }
220
+ }
221
+ return undefined;
222
+ }
223
+ }
package/src/index.ts CHANGED
@@ -1,22 +1,22 @@
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
- export * from './npm-registry';
18
- export * from './extension-package';
19
- export * from './application-package';
20
- export * from './application-props';
21
- export * from './environment';
22
- export * from './api';
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
+ export * from './npm-registry';
18
+ export * from './extension-package';
19
+ export * from './application-package';
20
+ export * from './application-props';
21
+ export * from './environment';
22
+ export * from './api';
package/src/json-file.ts CHANGED
@@ -1,25 +1,25 @@
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 * as fs from 'fs';
18
- import writeJsonFile = require('write-json-file');
19
-
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- function readJsonFile(path: string): any {
22
- return JSON.parse(fs.readFileSync(path, { encoding: 'utf-8' }));
23
- }
24
-
25
- export { writeJsonFile, readJsonFile };
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 * as fs from 'fs';
18
+ import writeJsonFile = require('write-json-file');
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ function readJsonFile(path: string): any {
22
+ return JSON.parse(fs.readFileSync(path, { encoding: 'utf-8' }));
23
+ }
24
+
25
+ export { writeJsonFile, readJsonFile };