ovsx 0.2.0 → 0.4.0
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/CHANGELOG.md +57 -19
- package/README.md +48 -48
- package/lib/check-license.d.ts +12 -12
- package/lib/check-license.js +110 -110
- package/lib/check-license.js.map +1 -1
- package/lib/create-namespace.d.ts +20 -20
- package/lib/create-namespace.js +43 -43
- package/lib/get.d.ts +32 -32
- package/lib/get.js +115 -115
- package/lib/index.d.ts +15 -15
- package/lib/index.js +23 -23
- package/lib/main.d.ts +10 -10
- package/lib/main.js +87 -87
- package/lib/main.js.map +1 -1
- package/lib/ovsx +10 -8
- package/lib/publish.d.ts +35 -41
- package/lib/publish.d.ts.map +1 -1
- package/lib/publish.js +82 -63
- package/lib/publish.js.map +1 -1
- package/lib/registry.d.ts +128 -128
- package/lib/registry.d.ts.map +1 -1
- package/lib/registry.js +198 -201
- package/lib/registry.js.map +1 -1
- package/lib/util.d.ts +35 -35
- package/lib/util.js +183 -183
- package/package.json +67 -67
- package/src/check-license.ts +1 -1
- package/src/main.ts +4 -4
- package/src/ovsx +10 -8
- package/src/publish.ts +47 -19
- package/src/registry.ts +1 -4
package/src/publish.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
********************************************************************************/
|
|
10
|
-
|
|
11
10
|
import { createVSIX, ICreateVSIXOptions } from 'vsce';
|
|
12
11
|
import { createTempFile, addEnvOptions } from './util';
|
|
13
12
|
import { Registry, RegistryOptions } from './registry';
|
|
@@ -17,34 +16,46 @@ import { checkLicense } from './check-license';
|
|
|
17
16
|
* Publishes an extension.
|
|
18
17
|
*/
|
|
19
18
|
export async function publish(options: PublishOptions = {}): Promise<void> {
|
|
20
|
-
|
|
19
|
+
addEnvOptions(options);
|
|
20
|
+
if (options.packagePath) {
|
|
21
|
+
// call the publish command for every package path
|
|
22
|
+
await Promise.all(options.packagePath.map(path => doPublish({ ...options, packagePath: path })));
|
|
23
|
+
} else {
|
|
24
|
+
return doPublish({ ... options, packagePath: undefined });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function doPublish(options: InternalPublishOptions = {}): Promise<void> {
|
|
21
29
|
if (!options.pat) {
|
|
22
30
|
throw new Error("A personal access token must be given with the option '--pat'.");
|
|
23
31
|
}
|
|
24
32
|
|
|
33
|
+
// if the packagePath is a link to a vsix, don't need to package it
|
|
34
|
+
if (options.packagePath && options.packagePath.endsWith('.vsix')) {
|
|
35
|
+
options.extensionFile = options.packagePath;
|
|
36
|
+
delete options.packagePath;
|
|
37
|
+
}
|
|
25
38
|
const registry = new Registry(options);
|
|
26
39
|
if (!options.extensionFile) {
|
|
27
40
|
await packageExtension(options, registry);
|
|
28
41
|
console.log(); // new line
|
|
42
|
+
} else if (options.preRelease) {
|
|
43
|
+
console.warn("Ignoring option '--pre-release' for prepackaged extension.");
|
|
29
44
|
}
|
|
30
45
|
|
|
31
|
-
const extension = await registry.publish(options.extensionFile!, options.pat
|
|
46
|
+
const extension = await registry.publish(options.extensionFile!, options.pat);
|
|
32
47
|
if (extension.error) {
|
|
33
48
|
throw new Error(extension.error);
|
|
34
49
|
}
|
|
35
50
|
console.log(`\ud83d\ude80 Published ${extension.namespace}.${extension.name} v${extension.version}`);
|
|
36
51
|
}
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
interface PublishCommonOptions extends RegistryOptions {
|
|
39
54
|
/**
|
|
40
55
|
* Path to the vsix file to be published. Cannot be used together with `packagePath`.
|
|
41
56
|
*/
|
|
42
57
|
extensionFile?: string;
|
|
43
|
-
|
|
44
|
-
* Path to the extension to be packaged and published. Cannot be used together
|
|
45
|
-
* with `extensionFile`.
|
|
46
|
-
*/
|
|
47
|
-
packagePath?: string;
|
|
58
|
+
|
|
48
59
|
/**
|
|
49
60
|
* The base URL for links detected in Markdown files. Only valid with `packagePath`.
|
|
50
61
|
*/
|
|
@@ -58,28 +69,45 @@ export interface PublishOptions extends RegistryOptions {
|
|
|
58
69
|
*/
|
|
59
70
|
yarn?: boolean;
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
72
|
+
* Mark this package as a pre-release. Only valid with `packagePath`.
|
|
62
73
|
*/
|
|
63
|
-
|
|
74
|
+
preRelease?: boolean;
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
// Interface used by top level CLI
|
|
78
|
+
export interface PublishOptions extends PublishCommonOptions {
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Paths to the extension to be packaged and published. Cannot be used together
|
|
82
|
+
* with `extensionFile`.
|
|
83
|
+
*/
|
|
84
|
+
packagePath?: string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Interface used internally by the doPublish method
|
|
88
|
+
interface InternalPublishOptions extends PublishCommonOptions {
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Only one path for our internal command.
|
|
92
|
+
* Path to the extension to be packaged and published. Cannot be used together
|
|
93
|
+
* with `extensionFile`.
|
|
94
|
+
*/
|
|
95
|
+
packagePath?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function packageExtension(options: InternalPublishOptions, registry: Registry): Promise<void> {
|
|
67
99
|
if (registry.requiresLicense) {
|
|
68
100
|
await checkLicense(options.packagePath!);
|
|
69
101
|
}
|
|
70
102
|
|
|
71
103
|
options.extensionFile = await createTempFile({ postfix: '.vsix' });
|
|
72
|
-
const createVSIXOptions:
|
|
104
|
+
const createVSIXOptions: ICreateVSIXOptions = {
|
|
73
105
|
cwd: options.packagePath,
|
|
74
106
|
packagePath: options.extensionFile,
|
|
75
107
|
baseContentUrl: options.baseContentUrl,
|
|
76
108
|
baseImagesUrl: options.baseImagesUrl,
|
|
77
109
|
useYarn: options.yarn,
|
|
78
|
-
|
|
110
|
+
preRelease: options.preRelease
|
|
79
111
|
};
|
|
80
112
|
await createVSIX(createVSIXOptions);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
interface IPackageOptions extends ICreateVSIXOptions {
|
|
84
|
-
web?: boolean // experimental flag, not part of the public ICreateVSIXOptions api, yet
|
|
85
|
-
}
|
|
113
|
+
}
|
package/src/registry.ts
CHANGED
|
@@ -58,12 +58,9 @@ export class Registry {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
publish(file: string, pat: string
|
|
61
|
+
publish(file: string, pat: string): Promise<Extension> {
|
|
62
62
|
try {
|
|
63
63
|
const query: { [key: string]: string } = { token: pat };
|
|
64
|
-
if (web) {
|
|
65
|
-
query.web = 'true';
|
|
66
|
-
}
|
|
67
64
|
const url = this.getUrl('api/-/publish', query);
|
|
68
65
|
return this.postFile(file, url, {
|
|
69
66
|
'Content-Type': 'application/octet-stream'
|