ovsx 0.10.2 → 0.10.4
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 +26 -0
- package/lib/create-namespace-options.d.ts +17 -0
- package/lib/create-namespace-options.d.ts.map +1 -0
- package/lib/create-namespace-options.js +12 -0
- package/lib/create-namespace-options.js.map +1 -0
- package/lib/create-namespace.d.ts +1 -7
- package/lib/create-namespace.d.ts.map +1 -1
- package/lib/create-namespace.js +2 -1
- package/lib/create-namespace.js.map +1 -1
- package/lib/get-options.d.ts +33 -0
- package/lib/get-options.d.ts.map +1 -0
- package/lib/get-options.js +12 -0
- package/lib/get-options.js.map +1 -0
- package/lib/get.d.ts +1 -23
- package/lib/get.d.ts.map +1 -1
- package/lib/get.js +2 -2
- package/lib/get.js.map +1 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/login-options.d.ts +17 -0
- package/lib/login-options.d.ts.map +1 -0
- package/lib/login-options.js +3 -0
- package/lib/login-options.js.map +1 -0
- package/lib/login.d.ts +1 -7
- package/lib/login.d.ts.map +1 -1
- package/lib/login.js +2 -1
- package/lib/login.js.map +1 -1
- package/lib/logout.d.ts.map +1 -1
- package/lib/logout.js +9 -0
- package/lib/logout.js.map +1 -1
- package/lib/pat.d.ts +16 -0
- package/lib/pat.d.ts.map +1 -0
- package/lib/pat.js +39 -0
- package/lib/pat.js.map +1 -0
- package/lib/publish-options.d.ts +56 -0
- package/lib/publish-options.d.ts.map +1 -0
- package/lib/publish-options.js +3 -0
- package/lib/publish-options.js.map +1 -0
- package/lib/publish.d.ts +1 -47
- package/lib/publish.d.ts.map +1 -1
- package/lib/publish.js +2 -1
- package/lib/publish.js.map +1 -1
- package/lib/registry-options.d.ts +36 -0
- package/lib/registry-options.d.ts.map +1 -0
- package/lib/registry-options.js +12 -0
- package/lib/registry-options.js.map +1 -0
- package/lib/registry.d.ts +1 -26
- package/lib/registry.d.ts.map +1 -1
- package/lib/registry.js +9 -11
- package/lib/registry.js.map +1 -1
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +9 -0
- package/lib/store.js.map +1 -1
- package/lib/util.d.ts +2 -6
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +11 -38
- package/lib/util.js.map +1 -1
- package/lib/verify-pat-options.d.ts +17 -0
- package/lib/verify-pat-options.d.ts.map +1 -0
- package/lib/verify-pat-options.js +12 -0
- package/lib/verify-pat-options.js.map +1 -0
- package/lib/verify-pat.d.ts +1 -8
- package/lib/verify-pat.d.ts.map +1 -1
- package/lib/verify-pat.js +3 -14
- package/lib/verify-pat.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/zip.d.ts +0 -1
- package/lib/zip.d.ts.map +1 -1
- package/lib/zip.js +24 -24
- package/lib/zip.js.map +1 -1
- package/package.json +4 -4
- package/src/create-namespace-options.ts +18 -0
- package/src/create-namespace.ts +4 -9
- package/src/get-options.ts +34 -0
- package/src/get.ts +5 -27
- package/src/index.ts +8 -0
- package/src/login-options.ts +17 -0
- package/src/login.ts +3 -9
- package/src/logout.ts +9 -0
- package/src/pat.ts +52 -0
- package/src/publish-options.ts +61 -0
- package/src/publish.ts +21 -70
- package/src/registry-options.ts +36 -0
- package/src/registry.ts +16 -44
- package/src/store.ts +9 -0
- package/src/util.ts +14 -47
- package/src/verify-pat-options.ts +18 -0
- package/src/verify-pat.ts +3 -20
- package/src/version.ts +1 -1
- package/src/zip.ts +26 -31
package/lib/zip.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readZip = readZip;
|
|
4
3
|
exports.readVSIXPackage = readVSIXPackage;
|
|
5
|
-
|
|
4
|
+
/********************************************************************************
|
|
5
|
+
* Copyright (c) 2024 Precies. Software and others
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made available under the
|
|
8
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
*
|
|
11
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
12
|
+
********************************************************************************/
|
|
13
|
+
const yauzl = require("yauzl-promise");
|
|
6
14
|
async function bufferStream(stream) {
|
|
7
15
|
return await new Promise((resolve, reject) => {
|
|
8
16
|
const buffers = [];
|
|
@@ -12,30 +20,22 @@ async function bufferStream(stream) {
|
|
|
12
20
|
});
|
|
13
21
|
}
|
|
14
22
|
async function readZip(packagePath, filter) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
zipfile.on('entry', (entry) => {
|
|
21
|
-
const name = entry.fileName.toLowerCase();
|
|
23
|
+
const result = new Map();
|
|
24
|
+
const zipfile = await yauzl.open(packagePath);
|
|
25
|
+
try {
|
|
26
|
+
for await (const entry of zipfile) {
|
|
27
|
+
const name = entry.filename.toLowerCase();
|
|
22
28
|
if (filter(name)) {
|
|
23
|
-
zipfile.openReadStream(entry
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return reject(err);
|
|
27
|
-
}
|
|
28
|
-
bufferStream(stream).then(buffer => {
|
|
29
|
-
result.set(name, buffer);
|
|
30
|
-
zipfile.readEntry();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
zipfile.readEntry();
|
|
29
|
+
const stream = await zipfile.openReadStream(entry);
|
|
30
|
+
const buffer = await bufferStream(stream);
|
|
31
|
+
result.set(name, buffer);
|
|
36
32
|
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
await zipfile.close();
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
39
|
}
|
|
40
40
|
async function readVSIXPackage(packagePath) {
|
|
41
41
|
const map = await readZip(packagePath, name => /^extension\/package\.json$/i.test(name));
|
package/lib/zip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":";;AAyCA,0CAQC;AAjDD;;;;;;;;kFAQkF;AAClF,uCAAuC;AAIvC,KAAK,UAAU,YAAY,CAAC,MAAgB;IAC3C,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,WAAmB,EAAE,MAAiC;IAC5E,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC;QACJ,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC1C,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;gBACnD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;gBAC1C,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1B,CAAC;QACF,CAAC;IACF,CAAC;YAAS,CAAC;QACV,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,WAAmB;IACxD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzF,MAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACtD,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAa,CAAC;AAC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ovsx",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Command line interface for Eclipse Open VSX",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"leven": "^3.1.0",
|
|
42
42
|
"semver": "^7.6.0",
|
|
43
43
|
"tmp": "^0.2.3",
|
|
44
|
-
"yauzl": "^
|
|
44
|
+
"yauzl-promise": "^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@eslint/eslintrc": "^3.2.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/node": "^20.14.8",
|
|
53
53
|
"@types/semver": "^7.5.8",
|
|
54
54
|
"@types/tmp": "^0.2.2",
|
|
55
|
-
"@types/yauzl": "^
|
|
55
|
+
"@types/yauzl-promise": "^4",
|
|
56
56
|
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
|
57
57
|
"@typescript-eslint/parser": "^8.15.0",
|
|
58
58
|
"eslint": "^9.15.0",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publish:latest": "yarn npm publish --tag latest",
|
|
72
72
|
"load-extensions": "node scripts/load-test-extensions.js"
|
|
73
73
|
},
|
|
74
|
-
"packageManager": "yarn@4.
|
|
74
|
+
"packageManager": "yarn@4.9.1"
|
|
75
75
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2020 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
|
|
11
|
+
import { RegistryOptions } from './registry-options';
|
|
12
|
+
|
|
13
|
+
export interface CreateNamespaceOptions extends RegistryOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Name of the new namespace.
|
|
16
|
+
*/
|
|
17
|
+
name?: string
|
|
18
|
+
}
|
package/src/create-namespace.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { CreateNamespaceOptions } from './create-namespace-options';
|
|
12
|
+
import { getPAT } from './pat';
|
|
13
|
+
import { Registry } from './registry';
|
|
14
|
+
import { addEnvOptions } from './util';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Creates a namespace (corresponds to `publisher` in package.json).
|
|
@@ -29,10 +31,3 @@ export async function createNamespace(options: CreateNamespaceOptions = {}): Pro
|
|
|
29
31
|
}
|
|
30
32
|
console.log(`\ud83d\ude80 Created namespace ${options.name}`);
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
export interface CreateNamespaceOptions extends RegistryOptions {
|
|
34
|
-
/**
|
|
35
|
-
* Name of the new namespace.
|
|
36
|
-
*/
|
|
37
|
-
name?: string
|
|
38
|
-
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2019 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
|
|
11
|
+
import { RegistryOptions } from "./registry-options";
|
|
12
|
+
|
|
13
|
+
export interface GetOptions extends RegistryOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Identifier in the form `namespace.extension` or `namespace/extension`.
|
|
16
|
+
*/
|
|
17
|
+
extensionId: string;
|
|
18
|
+
/**
|
|
19
|
+
* Target platform.
|
|
20
|
+
*/
|
|
21
|
+
target?: string;
|
|
22
|
+
/**
|
|
23
|
+
* An exact version or version range.
|
|
24
|
+
*/
|
|
25
|
+
version?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Save the output in the specified file or directory.
|
|
28
|
+
*/
|
|
29
|
+
output?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Print the extension's metadata instead of downloading it.
|
|
32
|
+
*/
|
|
33
|
+
metadata?: boolean;
|
|
34
|
+
}
|
package/src/get.ts
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
import * as fs from 'fs';
|
|
12
12
|
import * as path from 'path';
|
|
13
13
|
import * as semver from 'semver';
|
|
14
|
-
import { Registry, Extension
|
|
15
|
-
import { promisify, matchExtensionId, optionalStat, makeDirs, addEnvOptions } from './util';
|
|
14
|
+
import { Registry, Extension } from "./registry";
|
|
15
|
+
import { promisify, matchExtensionId, optionalStat, makeDirs, addEnvOptions, rejectError } from './util';
|
|
16
|
+
import { GetOptions } from './get-options';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Downloads an extension or its metadata.
|
|
@@ -51,11 +52,11 @@ function findMatchingVersion(registry: Registry, extension: Extension, constrain
|
|
|
51
52
|
try {
|
|
52
53
|
return registry.getJson(new URL(extension.allVersions[version]));
|
|
53
54
|
} catch (err) {
|
|
54
|
-
return
|
|
55
|
+
return rejectError(err);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
return Promise.reject(`Extension ${extension.namespace}.${extension.name} has no published version matching '${constraint}'`);
|
|
59
|
+
return Promise.reject(new Error(`Extension ${extension.namespace}.${extension.name} has no published version matching '${constraint}'`));
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
function isAlias(extension: Extension, version: string): boolean {
|
|
@@ -103,26 +104,3 @@ async function download(registry: Registry, extension: Extension, output?: strin
|
|
|
103
104
|
console.log(`Downloading ${extension.namespace}.${extension.name}-${extension.version}${target} to ${filePath}`);
|
|
104
105
|
await registry.download(filePath, new URL(downloadUrl));
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
-
export interface GetOptions extends RegistryOptions {
|
|
108
|
-
/**
|
|
109
|
-
* Identifier in the form `namespace.extension` or `namespace/extension`.
|
|
110
|
-
*/
|
|
111
|
-
extensionId: string;
|
|
112
|
-
/**
|
|
113
|
-
* Target platform.
|
|
114
|
-
*/
|
|
115
|
-
target?: string;
|
|
116
|
-
/**
|
|
117
|
-
* An exact version or version range.
|
|
118
|
-
*/
|
|
119
|
-
version?: string;
|
|
120
|
-
/**
|
|
121
|
-
* Save the output in the specified file or directory.
|
|
122
|
-
*/
|
|
123
|
-
output?: string;
|
|
124
|
-
/**
|
|
125
|
-
* Print the extension's metadata instead of downloading it.
|
|
126
|
-
*/
|
|
127
|
-
metadata?: boolean;
|
|
128
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,17 @@
|
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
|
|
11
11
|
export * from './create-namespace';
|
|
12
|
+
export * from './create-namespace-options';
|
|
12
13
|
export * from './get';
|
|
14
|
+
export * from './get-options';
|
|
15
|
+
export * from './login';
|
|
16
|
+
export * from './login-options';
|
|
17
|
+
export * from './logout';
|
|
13
18
|
export * from './publish';
|
|
19
|
+
export * from './publish-options';
|
|
14
20
|
export * from './registry';
|
|
21
|
+
export * from './registry-options';
|
|
15
22
|
export * from './verify-pat';
|
|
23
|
+
export * from './verify-pat-options';
|
|
16
24
|
export { isLicenseOk } from './check-license';
|
|
17
25
|
export { validateManifest, readManifest } from './util';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Precies. Software 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
import { RegistryOptions } from './registry-options';
|
|
11
|
+
|
|
12
|
+
export interface LoginOptions extends RegistryOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Name of the namespace.
|
|
15
|
+
*/
|
|
16
|
+
namespace?: string
|
|
17
|
+
}
|
package/src/login.ts
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
import { } from '@vscode/vsce';
|
|
11
|
-
import { addEnvOptions, getUserInput
|
|
11
|
+
import { addEnvOptions, getUserInput } from './util';
|
|
12
12
|
import { openDefaultStore } from './store';
|
|
13
|
-
import {
|
|
13
|
+
import { LoginOptions } from './login-options';
|
|
14
|
+
import { requestPAT } from './pat';
|
|
14
15
|
|
|
15
16
|
export default async function login(options: LoginOptions) {
|
|
16
17
|
addEnvOptions(options);
|
|
@@ -31,11 +32,4 @@ export default async function login(options: LoginOptions) {
|
|
|
31
32
|
|
|
32
33
|
pat = await requestPAT(options.namespace, options);
|
|
33
34
|
await store.add(options.namespace, pat);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface LoginOptions extends RegistryOptions {
|
|
37
|
-
/**
|
|
38
|
-
* Name of the namespace.
|
|
39
|
-
*/
|
|
40
|
-
namespace?: string
|
|
41
35
|
}
|
package/src/logout.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Precies. Software 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
********************************************************************************/
|
|
1
10
|
import { openDefaultStore } from "./store";
|
|
2
11
|
|
|
3
12
|
export default async function logout(namespaceName: string) {
|
package/src/pat.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** ******************************************************************************
|
|
2
|
+
* Copyright (c) 2025 Precies. Software OU 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
* ****************************************************************************** */
|
|
10
|
+
import { CreateNamespaceOptions } from './create-namespace-options';
|
|
11
|
+
import { PublishOptions } from './publish-options';
|
|
12
|
+
import { VerifyPatOptions } from './verify-pat-options';
|
|
13
|
+
import { Registry } from './registry';
|
|
14
|
+
import { getUserInput } from './util';
|
|
15
|
+
import { openDefaultStore } from './store';
|
|
16
|
+
|
|
17
|
+
export async function doVerifyPat(options: VerifyPatOptions) {
|
|
18
|
+
const registry = new Registry(options);
|
|
19
|
+
const namespace = options.namespace as string;
|
|
20
|
+
const pat = options.pat as string;
|
|
21
|
+
const result = await registry.verifyPat(namespace, pat);
|
|
22
|
+
if (result.error) {
|
|
23
|
+
throw new Error(result.error);
|
|
24
|
+
}
|
|
25
|
+
console.log(`\ud83d\ude80 PAT valid to publish at ${namespace}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function requestPAT(namespace: string, options: CreateNamespaceOptions | PublishOptions | VerifyPatOptions, verify: boolean = true): Promise<string> {
|
|
29
|
+
const pat = await getUserInput(`Personal Access Token for namespace '${namespace}':`);
|
|
30
|
+
if (verify) {
|
|
31
|
+
await doVerifyPat({ ...options, namespace, pat });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return pat;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function getPAT(namespace: string, options: CreateNamespaceOptions | PublishOptions | VerifyPatOptions, verify: boolean = true): Promise<string> {
|
|
38
|
+
if (options?.pat) {
|
|
39
|
+
return options.pat;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const store = await openDefaultStore();
|
|
43
|
+
let pat = store.get(namespace);
|
|
44
|
+
if (pat) {
|
|
45
|
+
return pat;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pat = await requestPAT(namespace, options, verify);
|
|
49
|
+
await store.add(namespace, pat);
|
|
50
|
+
|
|
51
|
+
return pat;
|
|
52
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2019 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
import { RegistryOptions } from './registry-options';
|
|
11
|
+
|
|
12
|
+
export interface PublishCommonOptions extends RegistryOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Path to the vsix file to be published. Cannot be used together with `packagePath`.
|
|
15
|
+
*/
|
|
16
|
+
extensionFile?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The base URL for links detected in Markdown files. Only valid with `packagePath`.
|
|
19
|
+
*/
|
|
20
|
+
baseContentUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The base URL for images detected in Markdown files. Only valid with `packagePath`.
|
|
23
|
+
*/
|
|
24
|
+
baseImagesUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Should use `yarn` instead of `npm`. Only valid with `packagePath`.
|
|
27
|
+
*/
|
|
28
|
+
yarn?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Mark this package as a pre-release. Only valid with `packagePath`.
|
|
31
|
+
*/
|
|
32
|
+
preRelease?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to fail silently if version already exists on the marketplace
|
|
35
|
+
*/
|
|
36
|
+
skipDuplicate?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Extension version. Only valid with `packagePath`.
|
|
39
|
+
*/
|
|
40
|
+
packageVersion?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Interface used by top level CLI
|
|
44
|
+
export interface PublishOptions extends PublishCommonOptions {
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Target architectures.
|
|
48
|
+
*/
|
|
49
|
+
targets?: string[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Paths to the extension to be packaged and published. Cannot be used together
|
|
53
|
+
* with `extensionFile`.
|
|
54
|
+
*/
|
|
55
|
+
packagePath?: string[];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether to do dependency detection via npm or yarn
|
|
59
|
+
*/
|
|
60
|
+
dependencies?: boolean;
|
|
61
|
+
}
|
package/src/publish.ts
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
import { createVSIX, IPackageOptions } from '@vscode/vsce';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { getPAT } from './pat';
|
|
12
|
+
import { createTempFile, addEnvOptions } from './util';
|
|
13
|
+
import { Extension, Registry } from './registry';
|
|
13
14
|
import { checkLicense } from './check-license';
|
|
14
15
|
import { readVSIXPackage } from './zip';
|
|
16
|
+
import { PublishOptions, PublishCommonOptions } from './publish-options';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Publishes an extension.
|
|
@@ -77,55 +79,24 @@ async function doPublish(options: InternalPublishOptions = {}): Promise<void> {
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
extensionFile?: string;
|
|
85
|
-
/**
|
|
86
|
-
* The base URL for links detected in Markdown files. Only valid with `packagePath`.
|
|
87
|
-
*/
|
|
88
|
-
baseContentUrl?: string;
|
|
89
|
-
/**
|
|
90
|
-
* The base URL for images detected in Markdown files. Only valid with `packagePath`.
|
|
91
|
-
*/
|
|
92
|
-
baseImagesUrl?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Should use `yarn` instead of `npm`. Only valid with `packagePath`.
|
|
95
|
-
*/
|
|
96
|
-
yarn?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Mark this package as a pre-release. Only valid with `packagePath`.
|
|
99
|
-
*/
|
|
100
|
-
preRelease?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Whether to fail silently if version already exists on the marketplace
|
|
103
|
-
*/
|
|
104
|
-
skipDuplicate?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Extension version. Only valid with `packagePath`.
|
|
107
|
-
*/
|
|
108
|
-
packageVersion?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Interface used by top level CLI
|
|
112
|
-
export interface PublishOptions extends PublishCommonOptions {
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Target architectures.
|
|
116
|
-
*/
|
|
117
|
-
targets?: string[];
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Paths to the extension to be packaged and published. Cannot be used together
|
|
121
|
-
* with `extensionFile`.
|
|
122
|
-
*/
|
|
123
|
-
packagePath?: string[];
|
|
82
|
+
async function packageExtension(options: InternalPublishOptions, registry: Registry): Promise<void> {
|
|
83
|
+
if (registry.requiresLicense) {
|
|
84
|
+
await checkLicense(options.packagePath!);
|
|
85
|
+
}
|
|
124
86
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
87
|
+
options.extensionFile = await createTempFile({ postfix: '.vsix' });
|
|
88
|
+
const packageOptions: IPackageOptions = {
|
|
89
|
+
packagePath: options.extensionFile,
|
|
90
|
+
target: options.target,
|
|
91
|
+
cwd: options.packagePath,
|
|
92
|
+
baseContentUrl: options.baseContentUrl,
|
|
93
|
+
baseImagesUrl: options.baseImagesUrl,
|
|
94
|
+
useYarn: options.yarn,
|
|
95
|
+
dependencies: options.dependencies,
|
|
96
|
+
preRelease: options.preRelease,
|
|
97
|
+
version: options.packageVersion
|
|
98
|
+
};
|
|
99
|
+
await createVSIX(packageOptions);
|
|
129
100
|
}
|
|
130
101
|
|
|
131
102
|
// Interface used internally by the doPublish method
|
|
@@ -148,24 +119,4 @@ interface InternalPublishOptions extends PublishCommonOptions {
|
|
|
148
119
|
* Whether to do dependency detection via npm or yarn
|
|
149
120
|
*/
|
|
150
121
|
dependencies?: boolean;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async function packageExtension(options: InternalPublishOptions, registry: Registry): Promise<void> {
|
|
154
|
-
if (registry.requiresLicense) {
|
|
155
|
-
await checkLicense(options.packagePath!);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
options.extensionFile = await createTempFile({ postfix: '.vsix' });
|
|
159
|
-
const packageOptions: IPackageOptions = {
|
|
160
|
-
packagePath: options.extensionFile,
|
|
161
|
-
target: options.target,
|
|
162
|
-
cwd: options.packagePath,
|
|
163
|
-
baseContentUrl: options.baseContentUrl,
|
|
164
|
-
baseImagesUrl: options.baseImagesUrl,
|
|
165
|
-
useYarn: options.yarn,
|
|
166
|
-
dependencies: options.dependencies,
|
|
167
|
-
preRelease: options.preRelease,
|
|
168
|
-
version: options.packageVersion
|
|
169
|
-
};
|
|
170
|
-
await createVSIX(packageOptions);
|
|
171
122
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2019 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
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
|
|
11
|
+
export interface RegistryOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The base URL of the registry API.
|
|
14
|
+
*/
|
|
15
|
+
registryUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Personal access token.
|
|
18
|
+
*/
|
|
19
|
+
pat?: string;
|
|
20
|
+
/**
|
|
21
|
+
* User name for basic authentication.
|
|
22
|
+
*/
|
|
23
|
+
username?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Password for basic authentication.
|
|
26
|
+
*/
|
|
27
|
+
password?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Maximal request body size for creating namespaces.
|
|
30
|
+
*/
|
|
31
|
+
maxNamespaceSize?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Maximal request body size for publishing.
|
|
34
|
+
*/
|
|
35
|
+
maxPublishSize?: number;
|
|
36
|
+
}
|