ovsx 0.2.1 → 0.5.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/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,60 @@ import { checkLicense } from './check-license';
17
16
  * Publishes an extension.
18
17
  */
19
18
  export async function publish(options: PublishOptions = {}): Promise<void> {
20
- addEnvOptions(options);
19
+ addEnvOptions(options);
20
+ const internalPublishOptions = [];
21
+ const packagePaths = options.packagePath || [undefined];
22
+ const targets = options.targets || [undefined];
23
+ for (const packagePath of packagePaths) {
24
+ for (const target of targets) {
25
+ internalPublishOptions.push({ ... options, packagePath: packagePath, target: target });
26
+ }
27
+ }
28
+ await Promise.all(internalPublishOptions.map(publishOptions => doPublish(publishOptions)));
29
+ }
30
+
31
+ async function doPublish(options: InternalPublishOptions = {}): Promise<void> {
21
32
  if (!options.pat) {
22
33
  throw new Error("A personal access token must be given with the option '--pat'.");
23
34
  }
24
35
 
36
+ // if the packagePath is a link to a vsix, don't need to package it
37
+ if (options.packagePath && options.packagePath.endsWith('.vsix')) {
38
+ options.extensionFile = options.packagePath;
39
+ delete options.packagePath;
40
+ delete options.target;
41
+ }
25
42
  const registry = new Registry(options);
26
43
  if (!options.extensionFile) {
27
44
  await packageExtension(options, registry);
28
45
  console.log(); // new line
46
+ } else if (options.preRelease) {
47
+ console.warn("Ignoring option '--pre-release' for prepackaged extension.");
29
48
  }
30
49
 
31
50
  const extension = await registry.publish(options.extensionFile!, options.pat);
32
51
  if (extension.error) {
33
52
  throw new Error(extension.error);
34
53
  }
35
- console.log(`\ud83d\ude80 Published ${extension.namespace}.${extension.name} v${extension.version}`);
54
+
55
+ const name = `${extension.namespace}.${extension.name}`;
56
+ let description = `${name} v${extension.version}`;
57
+ if (options.target) {
58
+ description += `@${options.target}`;
59
+ }
60
+
61
+ console.log(`\ud83d\ude80 Published ${description}`);
62
+ if (extension.warning) {
63
+ console.log(`\n!! ${extension.warning}`);
64
+ }
36
65
  }
37
66
 
38
- export interface PublishOptions extends RegistryOptions {
67
+ interface PublishCommonOptions extends RegistryOptions {
39
68
  /**
40
69
  * Path to the vsix file to be published. Cannot be used together with `packagePath`.
41
70
  */
42
71
  extensionFile?: string;
43
- /**
44
- * Path to the extension to be packaged and published. Cannot be used together
45
- * with `extensionFile`.
46
- */
47
- packagePath?: string;
72
+
48
73
  /**
49
74
  * The base URL for links detected in Markdown files. Only valid with `packagePath`.
50
75
  */
@@ -57,20 +82,58 @@ export interface PublishOptions extends RegistryOptions {
57
82
  * Should use `yarn` instead of `npm`. Only valid with `packagePath`.
58
83
  */
59
84
  yarn?: boolean;
85
+ /**
86
+ * Mark this package as a pre-release. Only valid with `packagePath`.
87
+ */
88
+ preRelease?: boolean;
89
+ }
90
+
91
+ // Interface used by top level CLI
92
+ export interface PublishOptions extends PublishCommonOptions {
93
+
94
+ /**
95
+ * Target architectures.
96
+ */
97
+ targets?: string[];
98
+
99
+ /**
100
+ * Paths to the extension to be packaged and published. Cannot be used together
101
+ * with `extensionFile`.
102
+ */
103
+ packagePath?: string[];
104
+ }
105
+
106
+ // Interface used internally by the doPublish method
107
+ interface InternalPublishOptions extends PublishCommonOptions {
108
+
109
+ /**
110
+ * Only one target for our internal command.
111
+ * Target architecture.
112
+ */
113
+ target?: string;
114
+
115
+ /**
116
+ * Only one path for our internal command.
117
+ * Path to the extension to be packaged and published. Cannot be used together
118
+ * with `extensionFile`.
119
+ */
120
+ packagePath?: string;
60
121
  }
61
122
 
62
- async function packageExtension(options: PublishOptions, registry: Registry): Promise<void> {
123
+ async function packageExtension(options: InternalPublishOptions, registry: Registry): Promise<void> {
63
124
  if (registry.requiresLicense) {
64
125
  await checkLicense(options.packagePath!);
65
126
  }
66
127
 
67
128
  options.extensionFile = await createTempFile({ postfix: '.vsix' });
68
129
  const createVSIXOptions: ICreateVSIXOptions = {
130
+ target: options.target,
69
131
  cwd: options.packagePath,
70
132
  packagePath: options.extensionFile,
71
133
  baseContentUrl: options.baseContentUrl,
72
134
  baseImagesUrl: options.baseImagesUrl,
73
- useYarn: options.yarn
135
+ useYarn: options.yarn,
136
+ preRelease: options.preRelease
74
137
  };
75
138
  await createVSIX(createVSIXOptions);
76
139
  }
package/src/registry.ts CHANGED
@@ -70,9 +70,12 @@ export class Registry {
70
70
  }
71
71
  }
72
72
 
73
- getMetadata(namespace: string, extension: string): Promise<Extension> {
73
+ getMetadata(namespace: string, extension: string, target?: string): Promise<Extension> {
74
74
  try {
75
- const path = `api/${encodeURIComponent(namespace)}/${encodeURIComponent(extension)}`;
75
+ let path = `api/${encodeURIComponent(namespace)}/${encodeURIComponent(extension)}`;
76
+ if (target) {
77
+ path += `/${encodeURIComponent(target)}`;
78
+ }
76
79
  return this.getJson(this.getUrl(path));
77
80
  } catch (err) {
78
81
  return Promise.reject(err);
@@ -240,6 +243,7 @@ export interface RegistryOptions {
240
243
 
241
244
  export interface Response {
242
245
  success?: string;
246
+ warning?: string;
243
247
  error?: string;
244
248
  }
245
249
 
@@ -252,6 +256,7 @@ export interface Extension extends Response {
252
256
  name: string;
253
257
  namespace: string;
254
258
  version: string;
259
+ targetPlatform: string;
255
260
  publishedBy: UserData;
256
261
  verified: boolean;
257
262
  // key: version, value: url