@microtronics/studio-cli 0.23.0 → 0.24.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 CHANGED
@@ -1,11 +1,19 @@
1
1
 
2
2
 
3
- ## 0.23.0 (2025-02-25)
3
+ ## 0.24.0 (2025-03-10)
4
4
 
5
5
 
6
6
  ### Features
7
7
 
8
- * **studio-cli:** support to create an application with an existing id ([3dbde64](https://bitbucket.org/microtronics-core/vscode-studio/commits/3dbde64241244a2493b8452ed47f3a37dc90cc71))
8
+ * **studio-cli:** correct server version to allow app type addon ([1ff035c](https://bitbucket.org/microtronics-core/vscode-studio/commits/1ff035c30ced5018228646b28b0855ba8202aceb))
9
+ * **studio-core:** support to download a specific app version ([30bd6b2](https://bitbucket.org/microtronics-core/vscode-studio/commits/30bd6b23db14790c55771de4d4d1622bab26edc7))
10
+
11
+ ## 0.23.0 (2025-02-25)
12
+
13
+
14
+ ### Features
15
+
16
+ * **studio-cli:** support to create an application with an existing id ([3dbde64](https://bitbucket.org/microtronics-core/vscode-studio/commits/3dbde64241244a2493b8452ed47f3a37dc90cc71))
9
17
  * **studio-cli:** use semver api calls for `wynni` environment ([3fa1af3](https://bitbucket.org/microtronics-core/vscode-studio/commits/3fa1af3343c6cda3b73862797ee37d4c696da547))
10
18
 
11
19
  ## 0.22.0 (2025-02-25)
@@ -310,6 +310,30 @@ declare interface components {
310
310
  /** @description Information about what went/is wrong */
311
311
  reason: string;
312
312
  };
313
+ DeviceAssignment: {
314
+ /**
315
+ * @description null if not assigned
316
+ * @enum {string|null}
317
+ */
318
+ type?: "MT360" | "ONE" | "myDatanet" | null;
319
+ /** @description Url of the assigned server. null if not assigned */
320
+ url?: string | null;
321
+ /** @description If the assigned server is a myDatanet server. This contains the myDatanet server version */
322
+ version?: string | null;
323
+ /** @description Indicates if this device can only be aquired with an registration code */
324
+ registrationCode?: boolean;
325
+ };
326
+ ServerInfo: {
327
+ /** @description The uniqe identifier of the server */
328
+ id?: string;
329
+ /** @description The human readable name of the server */
330
+ name?: string;
331
+ /**
332
+ * @description The actual server version
333
+ * @example 51v011
334
+ */
335
+ version?: string;
336
+ };
313
337
  };
314
338
  responses: never;
315
339
  parameters: {
@@ -332,8 +356,8 @@ declare interface components {
332
356
  /** @description version of the application. Either integer or for new applications semver */
333
357
  ApplicationVersion: string | number;
334
358
  ApplicationVersionInSemver: boolean;
335
- /** @description version of the library. Formatted as semantic version */
336
- ApplicationFileName: "release-notes.md";
359
+ /** @description File that can be downloaded */
360
+ ApplicationFileName: "release-notes.md" | "app.tar.gz";
337
361
  /** @description User Id */
338
362
  MemberId: string;
339
363
  /** @description User Id */
@@ -1598,19 +1622,21 @@ export declare namespace Dependencies {
1598
1622
  * Install the given library with the version that the semver range accepts
1599
1623
  * @param cwd
1600
1624
  * @param fs
1625
+ * @param env
1601
1626
  * @param token
1602
1627
  * @param publisherIdName
1603
1628
  * @param version
1604
1629
  * @param development - install as development dependency
1605
1630
  */
1606
- export function installDependency(cwd: URI, fs: LocalFS, token: string | null, publisherIdName: string, version: string | null, development?: boolean): Promise<undefined>;
1631
+ export function installDependency(cwd: URI, fs: LocalFS, env: Globals.ENV, token: string | null, publisherIdName: string, version: string | null, development?: boolean): Promise<undefined>;
1607
1632
  /**
1608
1633
  * Install all dependencies that are referenced within the studio manifest
1609
1634
  * @param cwd
1610
1635
  * @param fs
1636
+ * @param env
1611
1637
  * @param token
1612
1638
  */
1613
- export function installDependencies(cwd: URI, fs: LocalFS, token: string | null): Promise<void>;
1639
+ export function installDependencies(cwd: URI, fs: LocalFS, env: Globals.ENV, token: string | null): Promise<void>;
1614
1640
  /**
1615
1641
  * Uninstall the given library
1616
1642
  * Validates if the library is any sub-dependency of any other library
@@ -2171,12 +2197,12 @@ export declare namespace Manifest {
2171
2197
  * @param manifest
2172
2198
  * @param env
2173
2199
  */
2174
- export function validateBasicManifest(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest | null, env?: Globals.ENV): Promise<void>;
2200
+ export function validateBasicManifest(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest | null): Promise<void>;
2175
2201
  export function validateLibraryName(libraryName: string): "Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character." | "The library name is beyond permissible length of 20 characters." | null;
2176
2202
  export function validateProjectName(name: string, isLibrary?: boolean): "Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character." | "The library name is beyond permissible length of 20 characters." | "Project name can only contain 'A' through 'Z', 'a' through 'z', '0' through '9', ' ', '_' and '-'. The Project name must start with an alphabetic or numeric character." | "The project name is beyond permissible length of 40 characters." | null;
2177
2203
  export function validateDescription(description: string): "The description must have at least 5 characters." | null;
2178
2204
  export function validatePublisherId(publisher: string): "No publisher set yet" | "Publisher can only contain 'A' through 'Z', 'a' through 'z', '0' through '9' and '-'. The Publisher start with an alphabetic or numeric character." | null;
2179
- export function validatePublisherOnline(token: Registry.AuthToken, publisher: string): Promise<string | null>;
2205
+ export function validatePublisherOnline(token: Registry.AuthToken, publisher: string, env: Globals.ENV): Promise<string | null>;
2180
2206
  export function validateRegistryAllowedBackends(allowedBackends: undefined | null | string | string[]): Promise<string | null>;
2181
2207
  export function validateRegistryAllowedApplications(allowedApplications: undefined | null | string | string[]): Promise<string | null>;
2182
2208
  export function validateApplicationIcon(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest): Promise<void>;
@@ -2208,7 +2234,7 @@ export declare namespace Package {
2208
2234
  * @param allowedBackends
2209
2235
  * @param env
2210
2236
  */
2211
- export function release(cwd: URI, fs: LocalFS, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env?: Globals.ENV): Promise<void>;
2237
+ export function release(cwd: URI, fs: LocalFS, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env: Globals.ENV): Promise<void>;
2212
2238
  /**
2213
2239
  * Publish an application model tag
2214
2240
  * @param cwd
@@ -2218,7 +2244,7 @@ export declare namespace Package {
2218
2244
  * @param allowedBackends
2219
2245
  * @param env
2220
2246
  */
2221
- export function releaseAPM(cwd: URI, fs: LocalFS, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends?: Registry.ApiNewApplication['allowedBackends'], env?: Globals.ENV): Promise<void>;
2247
+ export function releaseAPM(cwd: URI, fs: LocalFS, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env: Globals.ENV): Promise<void>;
2222
2248
  /**
2223
2249
  * Publish a library project
2224
2250
  * @param cwd
@@ -2226,7 +2252,7 @@ export declare namespace Package {
2226
2252
  * @param token
2227
2253
  * @param env
2228
2254
  */
2229
- export function releaseLibrary(cwd: URI, fs: LocalFS, token: Registry.AuthToken, env?: Globals.ENV): Promise<void>;
2255
+ export function releaseLibrary(cwd: URI, fs: LocalFS, token: Registry.AuthToken, env: Globals.ENV): Promise<void>;
2230
2256
  /**
2231
2257
  * Read the projects README.md file
2232
2258
  * validates if the file content is the initial content
@@ -2247,8 +2273,9 @@ export declare namespace Package {
2247
2273
  * @param cwd
2248
2274
  * @param fs
2249
2275
  * @param token
2276
+ * @param env
2250
2277
  */
2251
- export function validatePublishSettings(cwd: URI, fs: LocalFS, token: Registry.AuthToken): Promise<void>;
2278
+ export function validatePublishSettings(cwd: URI, fs: LocalFS, token: Registry.AuthToken, env: Globals.ENV): Promise<void>;
2252
2279
  }
2253
2280
 
2254
2281
  /**
@@ -3464,7 +3491,7 @@ declare interface paths {
3464
3491
  applicationId: components["parameters"]["ApplicationId"];
3465
3492
  /** @description version of the application. Either integer or for new applications semver */
3466
3493
  applicationVersion: components["parameters"]["ApplicationVersion"];
3467
- /** @description version of the library. Formatted as semantic version */
3494
+ /** @description File that can be downloaded */
3468
3495
  applicationFileName: components["parameters"]["ApplicationFileName"];
3469
3496
  };
3470
3497
  cookie?: never;
@@ -3534,13 +3561,14 @@ declare interface paths {
3534
3561
  applicationId: components["parameters"]["ApplicationId"];
3535
3562
  /** @description version of the application. Either integer or for new applications semver */
3536
3563
  applicationVersion: components["parameters"]["ApplicationVersion"];
3537
- /** @description version of the library. Formatted as semantic version */
3564
+ /** @description File that can be downloaded */
3538
3565
  applicationFileName: components["parameters"]["ApplicationFileName"];
3539
3566
  };
3540
3567
  cookie?: never;
3541
3568
  };
3542
3569
  requestBody?: {
3543
3570
  content: {
3571
+ "application/gzip": string;
3544
3572
  "application/octet-stream": string;
3545
3573
  };
3546
3574
  };
@@ -4300,6 +4328,156 @@ declare interface paths {
4300
4328
  patch?: never;
4301
4329
  trace?: never;
4302
4330
  };
4331
+ "/devices/{serialNumber}/assignment": {
4332
+ parameters: {
4333
+ query?: never;
4334
+ header?: never;
4335
+ path?: never;
4336
+ cookie?: never;
4337
+ };
4338
+ /** Get the assignment information of the given device */
4339
+ get: {
4340
+ parameters: {
4341
+ query?: never;
4342
+ header?: never;
4343
+ path: {
4344
+ /** @description Serial number of the device */
4345
+ serialNumber: string;
4346
+ };
4347
+ cookie?: never;
4348
+ };
4349
+ requestBody?: never;
4350
+ responses: {
4351
+ /** @description successful operation */
4352
+ 200: {
4353
+ headers: {
4354
+ [name: string]: unknown;
4355
+ };
4356
+ content: {
4357
+ "application/json": components["schemas"]["DeviceAssignment"];
4358
+ };
4359
+ };
4360
+ /** @description unauthorized */
4361
+ 401: {
4362
+ headers: {
4363
+ [name: string]: unknown;
4364
+ };
4365
+ content: {
4366
+ "application/json": components["schemas"]["ErrorResponse"];
4367
+ };
4368
+ };
4369
+ /** @description device not found */
4370
+ 404: {
4371
+ headers: {
4372
+ [name: string]: unknown;
4373
+ };
4374
+ content: {
4375
+ "application/json": components["schemas"]["ErrorResponse"];
4376
+ };
4377
+ };
4378
+ /** @description unprocessable entity */
4379
+ 422: {
4380
+ headers: {
4381
+ [name: string]: unknown;
4382
+ };
4383
+ content: {
4384
+ "application/json": components["schemas"]["ErrorResponse"];
4385
+ };
4386
+ };
4387
+ /** @description internal server error */
4388
+ 500: {
4389
+ headers: {
4390
+ [name: string]: unknown;
4391
+ };
4392
+ content: {
4393
+ "application/json": components["schemas"]["ErrorResponse"];
4394
+ };
4395
+ };
4396
+ };
4397
+ };
4398
+ put?: never;
4399
+ post?: never;
4400
+ delete?: never;
4401
+ options?: never;
4402
+ head?: never;
4403
+ patch?: never;
4404
+ trace?: never;
4405
+ };
4406
+ "/servers/{serverDomain}": {
4407
+ parameters: {
4408
+ query?: never;
4409
+ header?: never;
4410
+ path?: never;
4411
+ cookie?: never;
4412
+ };
4413
+ /** Get information about a specific server */
4414
+ get: {
4415
+ parameters: {
4416
+ query?: never;
4417
+ header?: never;
4418
+ path: {
4419
+ /** @description The public domain of the server */
4420
+ serverDomain: string;
4421
+ };
4422
+ cookie?: never;
4423
+ };
4424
+ requestBody?: never;
4425
+ responses: {
4426
+ /** @description successful operation */
4427
+ 200: {
4428
+ headers: {
4429
+ [name: string]: unknown;
4430
+ };
4431
+ content: {
4432
+ "application/json": components["schemas"]["ServerInfo"];
4433
+ };
4434
+ };
4435
+ /** @description unauthorized */
4436
+ 401: {
4437
+ headers: {
4438
+ [name: string]: unknown;
4439
+ };
4440
+ content: {
4441
+ "application/json": components["schemas"]["ErrorResponse"];
4442
+ };
4443
+ };
4444
+ /** @description device not found */
4445
+ 404: {
4446
+ headers: {
4447
+ [name: string]: unknown;
4448
+ };
4449
+ content: {
4450
+ "application/json": components["schemas"]["ErrorResponse"];
4451
+ };
4452
+ };
4453
+ /** @description unprocessable entity */
4454
+ 422: {
4455
+ headers: {
4456
+ [name: string]: unknown;
4457
+ };
4458
+ content: {
4459
+ "application/json": components["schemas"]["ErrorResponse"];
4460
+ };
4461
+ };
4462
+ /** @description internal server error */
4463
+ 500: {
4464
+ headers: {
4465
+ [name: string]: unknown;
4466
+ };
4467
+ content: {
4468
+ "application/json": components["schemas"]["ErrorResponse"];
4469
+ };
4470
+ };
4471
+ };
4472
+ };
4473
+ put?: never;
4474
+ post?: never;
4475
+ delete?: never;
4476
+ options?: never;
4477
+ head?: never;
4478
+ patch?: never;
4479
+ trace?: never;
4480
+ };
4303
4481
  }
4304
4482
 
4305
4483
  export declare namespace Registry {
@@ -4307,7 +4485,7 @@ export declare namespace Registry {
4307
4485
  /**
4308
4486
  * Get the actual api url based on the STUDIO_ENV
4309
4487
  */
4310
- const getAPIUrl: () => {
4488
+ const getAPIUrl: (env: Globals.ENV) => {
4311
4489
  baseUrl: string;
4312
4490
  };
4313
4491
  export type LibraryProfile = components['schemas']['LibraryDetailInformation'];
@@ -4317,31 +4495,32 @@ export declare namespace Registry {
4317
4495
  * @param token
4318
4496
  * @param publisherId
4319
4497
  * @param libraryId
4498
+ * @param env
4320
4499
  */
4321
- export function getLibraryProfile(token: AuthToken, publisherId: string, libraryId: string): Promise<LibraryProfile>;
4322
- export function fetchCustomContent(token: AuthToken, contentURL: string, json?: boolean, env?: Globals.ENV): Promise<ArrayBuffer | any>;
4500
+ export function getLibraryProfile(token: AuthToken, publisherId: string, libraryId: string, env: Globals.ENV): Promise<LibraryProfile>;
4501
+ export function fetchCustomContent(token: AuthToken, contentURL: string, json?: boolean): Promise<ArrayBuffer | any>;
4323
4502
  export type Publisher = components['schemas']['Publisher'];
4324
- export function getPublisher(token: AuthToken, publisherId: string): Promise<Publisher | null>;
4503
+ export function getPublisher(token: AuthToken, publisherId: string, env: Globals.ENV): Promise<Publisher | null>;
4325
4504
  export type ApiNewApplication = components['schemas']['NewApplication'] & {
4326
4505
  type?: string | Manifest.ProjectTypes;
4327
4506
  };
4328
- export function createNewApplication(token: AuthToken, publisherId: string, newApplication: ApiNewApplication, env?: Globals.ENV): Promise<string | null | undefined>;
4507
+ export function createNewApplication(token: AuthToken, publisherId: string, newApplication: ApiNewApplication, env: Globals.ENV): Promise<string | null | undefined>;
4329
4508
  export type ApplicationDetailInformation = components['schemas']['ApplicationDetailInformation'];
4330
- export function getExistingApplication(token: AuthToken, publisherId: string, applicationId: string, env?: Globals.ENV): Promise<ApplicationDetailInformation>;
4331
- export function updateExistingApplication(token: AuthToken, publisherId: string, applicationId: string, updatedApplication: ApiNewApplication, env?: Globals.ENV): Promise<null | undefined>;
4509
+ export function getExistingApplication(token: AuthToken, publisherId: string, applicationId: string, env: Globals.ENV): Promise<ApplicationDetailInformation>;
4510
+ export function updateExistingApplication(token: AuthToken, publisherId: string, applicationId: string, updatedApplication: ApiNewApplication, env: Globals.ENV): Promise<null | undefined>;
4332
4511
  export type ApplicationVersionUpdate = components['schemas']['ApplicationVersionUpdate'];
4333
- export function updateExistingApplicationVersion(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string | number, updatedApplicationVersion: ApplicationVersionUpdate, env?: Globals.ENV): Promise<null | undefined>;
4512
+ export function updateExistingApplicationVersion(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string, updatedApplicationVersion: ApplicationVersionUpdate, env: Globals.ENV): Promise<null | undefined>;
4334
4513
  export type CreatedTagInfo = paths['/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}']['post']['responses']['201']['content']['application/json'];
4335
- export function publishApplicationVersion(token: AuthToken, publisherId: string, applicationId: string, version: string, apmTagBuffer: FormData, env?: Globals.ENV): Promise<CreatedTagInfo>;
4514
+ export function publishApplicationVersion(token: AuthToken, publisherId: string, applicationId: string, version: string, apmTagBuffer: FormData, env: Globals.ENV): Promise<CreatedTagInfo>;
4336
4515
  export type LibraryFiles = {
4337
4516
  'studio.json': Uint8Array;
4338
4517
  'library.tar.gz': Uint8Array;
4339
4518
  'README.md': Uint8Array;
4340
4519
  'CHANGELOG.md': Uint8Array;
4341
4520
  };
4342
- export function publishLibraryVersion(token: AuthToken, publisherId: string, libraryId: string, libraryVersion: string, files: LibraryFiles, env?: Globals.ENV): Promise<void>;
4521
+ export function publishLibraryVersion(token: AuthToken, publisherId: string, libraryId: string, libraryVersion: string, files: LibraryFiles, env: Globals.ENV): Promise<void>;
4343
4522
  export type ApplicationFileName = components['parameters']['ApplicationFileName'];
4344
- export function updateApplicationFile(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string, applicationFileName: ApplicationFileName, blob: Uint8Array, env?: Globals.ENV): Promise<void>;
4523
+ export function updateApplicationFile(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string, applicationFileName: ApplicationFileName, blob: Uint8Array, env: Globals.ENV): Promise<void>;
4345
4524
  }
4346
4525
 
4347
4526
  declare function uriToMemFsPath(path: URI): string;
@@ -196,19 +196,20 @@ var Dependencies;
196
196
  * Install the given library with the version that the semver range accepts
197
197
  * @param cwd
198
198
  * @param fs
199
+ * @param env
199
200
  * @param token
200
201
  * @param publisherIdName
201
202
  * @param version
202
203
  * @param development - install as development dependency
203
204
  */
204
- async function installDependency(cwd, fs, token, publisherIdName, version, development = false) {
205
+ async function installDependency(cwd, fs, env, token, publisherIdName, version, development = false) {
205
206
  const [publisherId, libraryName] = publisherIdName.split('/');
206
207
  if (version && (await isDependencyInstalled(cwd, fs, publisherId, libraryName, version))) {
207
208
  return;
208
209
  }
209
210
  // just remove any existing version of this library.
210
211
  await removeExisting(cwd, fs, libraryName);
211
- const libraryProfile = await registryAPI_1.Registry.getLibraryProfile(token, publisherId, libraryName);
212
+ const libraryProfile = await registryAPI_1.Registry.getLibraryProfile(token, publisherId, libraryName, env);
212
213
  const versionToDownload = version
213
214
  ? libraryProfile.versions?.find(versionInfo => {
214
215
  return semver.eq(versionInfo.name, Dependencies.rangeToVersion(version));
@@ -228,7 +229,7 @@ var Dependencies;
228
229
  await validateDependencyTree(cwd, fs, newDependencies, development);
229
230
  // install sub dependencies first
230
231
  for (const [libraryName, libraryVersion] of Object.entries(librarySubDependencies)) {
231
- await installDependency(cwd, fs, token, libraryName, libraryVersion, development);
232
+ await installDependency(cwd, fs, env, token, libraryName, libraryVersion, development);
232
233
  }
233
234
  const libraryArchive = versionToDownload.files.find(file => {
234
235
  return file.name === 'library.tar.gz';
@@ -254,9 +255,10 @@ var Dependencies;
254
255
  * Install all dependencies that are referenced within the studio manifest
255
256
  * @param cwd
256
257
  * @param fs
258
+ * @param env
257
259
  * @param token
258
260
  */
259
- async function installDependencies(cwd, fs, token) {
261
+ async function installDependencies(cwd, fs, env, token) {
260
262
  const manifest = await manifest_1.Manifest.read(cwd, fs);
261
263
  const dependencies = manifest.libraryDependencies || {};
262
264
  const devDependencies = manifest.libraryDevDependencies || {};
@@ -264,7 +266,7 @@ var Dependencies;
264
266
  for (const [libraryName, libraryVersion] of Object.entries(allDependencies)) {
265
267
  const isDevelopment = Object.hasOwn(devDependencies, libraryName);
266
268
  // update the tree version with the actual installed version
267
- await installDependency(cwd, fs, token, libraryName, libraryVersion, isDevelopment);
269
+ await installDependency(cwd, fs, env, token, libraryName, libraryVersion, isDevelopment);
268
270
  }
269
271
  console.log(`Installed ${Object.entries(allDependencies).length} dependencies`);
270
272
  }
package/out/main.js CHANGED
@@ -35,6 +35,7 @@ function handleStudioEnv(env) {
35
35
  if (env && env !== globals_1.Globals.ENV.production) {
36
36
  console.log(`Using STUDIO_ENV=${env}`);
37
37
  }
38
+ return process.env.STUDIO_ENV;
38
39
  }
39
40
  function getStudioApiToken(opts) {
40
41
  return opts?.token || null;
@@ -58,17 +59,17 @@ program
58
59
  .addOption(optionStudioEnv)
59
60
  .addOption(optionStudioToken)
60
61
  .action(async (dependencies, opts) => {
61
- handleStudioEnv(opts.env);
62
+ const env = handleStudioEnv(opts.env);
62
63
  const apiToken = getStudioApiToken(opts);
63
64
  try {
64
65
  if (dependencies.length > 0) {
65
66
  for (const dependency of dependencies) {
66
67
  const [libraryId, version] = dependency.split('@');
67
- await installDependency(cwd, cliFS_1.cliFS, apiToken, libraryId, version || null);
68
+ await installDependency(cwd, cliFS_1.cliFS, env, apiToken, libraryId, version || null);
68
69
  }
69
70
  }
70
71
  else {
71
- return await installDependencies(cwd, cliFS_1.cliFS, apiToken);
72
+ return await installDependencies(cwd, cliFS_1.cliFS, env, apiToken);
72
73
  }
73
74
  }
74
75
  catch (e) {
@@ -91,7 +92,7 @@ program
91
92
  .addOption(optionStudioEnv)
92
93
  .addOption(optionStudioToken)
93
94
  .action(async (opts) => {
94
- handleStudioEnv(opts.env);
95
+ const env = handleStudioEnv(opts.env);
95
96
  const token = getStudioApiToken(opts);
96
97
  let allowedBackends = null;
97
98
  if (opts.allowedBackends) {
@@ -101,7 +102,7 @@ program
101
102
  throw new Error(errorMessage);
102
103
  }
103
104
  }
104
- await package_1.Package.release(cwd, cliFS_1.cliFS, token, opts.phase, allowedBackends, opts.env);
105
+ await package_1.Package.release(cwd, cliFS_1.cliFS, token, opts.phase, allowedBackends, env);
105
106
  });
106
107
  module.exports = function (argv) {
107
108
  program.parse(argv);
package/out/manifest.js CHANGED
@@ -9,14 +9,13 @@ const helper_1 = require("./helper");
9
9
  const image_dimensions_1 = require("image-dimensions");
10
10
  const file_type_checker_1 = require("file-type-checker");
11
11
  const registryAPI_1 = require("./registryAPI");
12
- const globals_1 = require("./globals");
13
12
  const preload_1 = __importDefault(require("semver/preload"));
14
13
  const DeviceProfiles_1 = require("./DeviceProfiles");
15
14
  const apm_1 = require("./package/apm");
16
15
  var isNumeric = helper_1.Helper.isNumeric;
17
16
  const PRODUCT_ID_SUPPORTED = '52v007';
18
- // todo fill with actual version
19
- const ADDON_SUPPORTED = '52v099';
17
+ const SEMVER_SUPPORTED = '53v001';
18
+ const ADDON_SUPPORTED = '54v001';
20
19
  // Cache to reduce the disk read requests
21
20
  const manifestCache = {
22
21
  _manifest: null,
@@ -154,11 +153,11 @@ var Manifest;
154
153
  * @param manifest
155
154
  * @param env
156
155
  */
157
- async function validateBasicManifest(cwd, fs, manifest, env = globals_1.Globals.ENV.production) {
156
+ async function validateBasicManifest(cwd, fs, manifest) {
158
157
  if (!manifest) {
159
158
  manifest = await read(cwd, fs);
160
159
  }
161
- validateProjectVersion(manifest, env);
160
+ validateProjectVersion(manifest);
162
161
  validatePOVSettings(manifest);
163
162
  validateBLOSettings(manifest);
164
163
  }
@@ -227,8 +226,8 @@ var Manifest;
227
226
  return null;
228
227
  }
229
228
  Manifest.validatePublisherId = validatePublisherId;
230
- async function validatePublisherOnline(token, publisher) {
231
- const exists = await registryAPI_1.Registry.getPublisher(token, publisher);
229
+ async function validatePublisherOnline(token, publisher, env) {
230
+ const exists = await registryAPI_1.Registry.getPublisher(token, publisher, env);
232
231
  if (!exists) {
233
232
  return `Publisher '${publisher}' does not exist.`;
234
233
  }
@@ -311,7 +310,7 @@ var Manifest;
311
310
  const { engines } = manifest;
312
311
  // validate vor server versions >=52v006
313
312
  if (engines?.backend &&
314
- !engines.backend.match(/(^[5-9][2-9]|[6-9]\d+|\d{3,})v(0(0[6-9]|[1-9]\d)|[1-9]\d{2}|[1-9]\d{3,})$/)) {
313
+ !engines.backend.match(/(^[5-9][2-9]|[6-9]\d+|\d{3,})v(0(0[0-9]|[1-9]\d)|[1-9]\d{2}|[1-9]\d{3,})$/)) {
315
314
  throw new Error('Setting "engines.backend" is invalid');
316
315
  }
317
316
  validateHwFwOrProductId(manifest);
@@ -409,12 +408,12 @@ function validateAddonSupported(manifest) {
409
408
  /**
410
409
  * Check based on the current env if the given version string is correct
411
410
  * @param manifest
412
- * @param env
413
411
  */
414
- function validateProjectVersion(manifest, env) {
415
- if ([globals_1.Globals.ENV.lucky, globals_1.Globals.ENV.wynni].includes(env) || Manifest.isLibrary(manifest)) {
412
+ function validateProjectVersion(manifest) {
413
+ const serverVersion = manifest.engines?.backend || '00v000';
414
+ if (serverVersion >= SEMVER_SUPPORTED || Manifest.isLibrary(manifest)) {
416
415
  if (!preload_1.default.valid(manifest.version)) {
417
- throw new Error('"version" has to be a semantic version string!"');
416
+ throw new Error(`From "engines.backend" version >= ${SEMVER_SUPPORTED} onwards "version" has to be a semantic version string!"`);
418
417
  }
419
418
  }
420
419
  else {
@@ -151,7 +151,7 @@ var APM;
151
151
  const manifest = await manifest_1.Manifest.read(cwd, fs);
152
152
  if (!preventCreation) {
153
153
  // throws if the specific setting is invalid
154
- await package_1.Package.validatePublishSettings(cwd, fs, token);
154
+ await package_1.Package.validatePublishSettings(cwd, fs, token, env);
155
155
  }
156
156
  const { registry } = manifest;
157
157
  let applicationId = registry?.id;
@@ -12,7 +12,6 @@ const compiler_1 = require("../dlo/compiler");
12
12
  const scriptRunner_1 = require("../scriptRunner");
13
13
  const registryAPI_1 = require("../registryAPI");
14
14
  const manifest_1 = require("../manifest");
15
- const globals_1 = require("../globals");
16
15
  const library_1 = require("./library");
17
16
  const dfiles_1 = require("../dfiles/dfiles");
18
17
  var Package;
@@ -51,7 +50,7 @@ var Package;
51
50
  * @param allowedBackends
52
51
  * @param env
53
52
  */
54
- async function release(cwd, fs, token, releasePhase, allowedBackends, env = globals_1.Globals.ENV.production) {
53
+ async function release(cwd, fs, token, releasePhase, allowedBackends, env) {
55
54
  const manifest = await manifest_1.Manifest.read(cwd, fs);
56
55
  if (manifest_1.Manifest.isLibrary(manifest)) {
57
56
  await releaseLibrary(cwd, fs, token, env);
@@ -70,11 +69,11 @@ var Package;
70
69
  * @param allowedBackends
71
70
  * @param env
72
71
  */
73
- async function releaseAPM(cwd, fs, token, releasePhase, allowedBackends = null, env = globals_1.Globals.ENV.production) {
72
+ async function releaseAPM(cwd, fs, token, releasePhase, allowedBackends = null, env) {
74
73
  if (!Object.values(apm_1.APM.TagPhase).includes(releasePhase)) {
75
74
  throw new Error(`ReleasePhase: ${releasePhase} is not a valid release phase`);
76
75
  }
77
- await manifest_1.Manifest.validateBasicManifest(cwd, fs, null, env);
76
+ await manifest_1.Manifest.validateBasicManifest(cwd, fs, null);
78
77
  const application = await apm_1.APM.validateAccess(cwd, fs, token, false, env);
79
78
  if (!application) {
80
79
  return;
@@ -90,7 +89,7 @@ var Package;
90
89
  // update tag with content
91
90
  await registryAPI_1.Registry.updateExistingApplicationVersion(token, manifest.publisher, manifest.registry?.id, manifest.version, {
92
91
  allowedBackends
93
- }, globals_1.Globals.ENV.lucky);
92
+ }, env);
94
93
  console.log(`Tag "${newTag.version}" with phase "${newTag.phase}" shared with ${[...allowedBackends].join(';')}!`);
95
94
  }
96
95
  console.log(`Tag "${newTag.version}" with phase "${newTag.phase}" published!`);
@@ -103,10 +102,10 @@ var Package;
103
102
  * @param token
104
103
  * @param env
105
104
  */
106
- async function releaseLibrary(cwd, fs, token, env = globals_1.Globals.ENV.production) {
105
+ async function releaseLibrary(cwd, fs, token, env) {
107
106
  const manifest = await manifest_1.Manifest.read(cwd, fs);
108
- await manifest_1.Manifest.validateBasicManifest(cwd, fs, manifest, env);
109
- await validatePublishSettings(cwd, fs, token);
107
+ await manifest_1.Manifest.validateBasicManifest(cwd, fs, manifest);
108
+ await validatePublishSettings(cwd, fs, token, env);
110
109
  // build the complete project
111
110
  await buildAll(cwd, fs);
112
111
  const archive = await library_1.Library.createArchive(cwd, fs);
@@ -162,8 +161,9 @@ var Package;
162
161
  * @param cwd
163
162
  * @param fs
164
163
  * @param token
164
+ * @param env
165
165
  */
166
- async function validatePublishSettings(cwd, fs, token) {
166
+ async function validatePublishSettings(cwd, fs, token, env) {
167
167
  const manifest = await manifest_1.Manifest.read(cwd, fs);
168
168
  const { name, publisher, description } = manifest;
169
169
  const invalidName = manifest_1.Manifest.validateProjectName(name, manifest_1.Manifest.isLibrary(manifest));
@@ -174,7 +174,7 @@ var Package;
174
174
  if (invalidDescription) {
175
175
  throw new Error(`description: ${invalidDescription}`);
176
176
  }
177
- const invalidPublisher = manifest_1.Manifest.validatePublisherId(publisher) || (await manifest_1.Manifest.validatePublisherOnline(token, publisher));
177
+ const invalidPublisher = manifest_1.Manifest.validatePublisherId(publisher) || (await manifest_1.Manifest.validatePublisherOnline(token, publisher, env));
178
178
  if (invalidPublisher) {
179
179
  throw new Error(`publisher: ${invalidPublisher}`);
180
180
  }
@@ -8,6 +8,7 @@ exports.buildAuthHeader = buildAuthHeader;
8
8
  require("cross-fetch/polyfill");
9
9
  const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
10
10
  const globals_1 = require("./globals");
11
+ const preload_1 = __importDefault(require("semver/preload"));
11
12
  const { GET, POST, PUT } = (0, openapi_fetch_1.default)();
12
13
  function buildAuthHeader(token) {
13
14
  if (token) {
@@ -20,12 +21,12 @@ var Registry;
20
21
  /**
21
22
  * Get the actual api url based on the STUDIO_ENV
22
23
  */
23
- Registry.getAPIUrl = () => {
24
+ Registry.getAPIUrl = (env) => {
24
25
  let url = 'https://api.registry.microtronics.com';
25
- if (process.env.STUDIO_ENV === 'lucky') {
26
+ if (env === globals_1.Globals.ENV.lucky) {
26
27
  url = 'https://api.registry.lucky.ci.microtronics.com';
27
28
  }
28
- else if (process.env.STUDIO_ENV === 'wynni') {
29
+ else if (env === globals_1.Globals.ENV.wynni) {
29
30
  url = 'https://api.registry.wynni.ci.microtronics.com';
30
31
  }
31
32
  return { baseUrl: url + '/v1' };
@@ -35,10 +36,11 @@ var Registry;
35
36
  * @param token
36
37
  * @param publisherId
37
38
  * @param libraryId
39
+ * @param env
38
40
  */
39
- async function getLibraryProfile(token, publisherId, libraryId) {
41
+ async function getLibraryProfile(token, publisherId, libraryId, env) {
40
42
  const { data, error } = await GET('/publisher/{publisherId}/libraries/{libraryId}', {
41
- ...Registry.getAPIUrl(),
43
+ ...Registry.getAPIUrl(env),
42
44
  headers: { ...buildAuthHeader(token) },
43
45
  params: {
44
46
  path: {
@@ -53,12 +55,12 @@ var Registry;
53
55
  return data;
54
56
  }
55
57
  Registry.getLibraryProfile = getLibraryProfile;
56
- async function fetchCustomContent(token, contentURL, json = false, env = globals_1.Globals.ENV.production) {
58
+ async function fetchCustomContent(token, contentURL, json = false) {
57
59
  const response = await fetch(contentURL, {
58
60
  // @ts-ignore
59
61
  headers: {
60
62
  ...buildAuthHeader(token),
61
- ...headerBasedOnEnv(env)
63
+ ...injectSemverHeader(true)
62
64
  }
63
65
  });
64
66
  if (response.status === 200) {
@@ -74,10 +76,10 @@ var Registry;
74
76
  }
75
77
  }
76
78
  Registry.fetchCustomContent = fetchCustomContent;
77
- async function getPublisher(token, publisherId) {
79
+ async function getPublisher(token, publisherId, env) {
78
80
  try {
79
81
  const { data, error } = await GET('/publisher/{publisherId}', {
80
- ...Registry.getAPIUrl(),
82
+ ...Registry.getAPIUrl(env),
81
83
  headers: { ...buildAuthHeader(token) },
82
84
  params: {
83
85
  path: {
@@ -97,13 +99,13 @@ var Registry;
97
99
  }
98
100
  }
99
101
  Registry.getPublisher = getPublisher;
100
- async function createNewApplication(token, publisherId, newApplication, env = globals_1.Globals.ENV.production) {
102
+ async function createNewApplication(token, publisherId, newApplication, env) {
101
103
  try {
102
104
  const { data, error } = await POST('/packages/{publisherId}/applications', {
103
- ...Registry.getAPIUrl(),
105
+ ...Registry.getAPIUrl(env),
104
106
  headers: {
105
107
  ...buildAuthHeader(token),
106
- ...headerBasedOnEnv(env)
108
+ ...injectSemverHeader(true)
107
109
  },
108
110
  params: {
109
111
  path: {
@@ -125,12 +127,12 @@ var Registry;
125
127
  }
126
128
  }
127
129
  Registry.createNewApplication = createNewApplication;
128
- async function getExistingApplication(token, publisherId, applicationId, env = globals_1.Globals.ENV.production) {
130
+ async function getExistingApplication(token, publisherId, applicationId, env) {
129
131
  const { data, error } = await GET('/publisher/{publisherId}/applications/{applicationId}', {
130
- ...Registry.getAPIUrl(),
132
+ ...Registry.getAPIUrl(env),
131
133
  headers: {
132
134
  ...buildAuthHeader(token),
133
- ...headerBasedOnEnv(env)
135
+ ...injectSemverHeader(true)
134
136
  },
135
137
  params: {
136
138
  path: {
@@ -145,13 +147,13 @@ var Registry;
145
147
  return data;
146
148
  }
147
149
  Registry.getExistingApplication = getExistingApplication;
148
- async function updateExistingApplication(token, publisherId, applicationId, updatedApplication, env = globals_1.Globals.ENV.production) {
150
+ async function updateExistingApplication(token, publisherId, applicationId, updatedApplication, env) {
149
151
  try {
150
152
  const { error } = await PUT(`/packages/{publisherId}/applications/{applicationId}`, {
151
- ...Registry.getAPIUrl(),
153
+ ...Registry.getAPIUrl(env),
152
154
  headers: {
153
155
  ...buildAuthHeader(token),
154
- ...headerBasedOnEnv(env)
156
+ ...injectSemverHeader(true)
155
157
  },
156
158
  params: {
157
159
  path: {
@@ -174,13 +176,14 @@ var Registry;
174
176
  }
175
177
  }
176
178
  Registry.updateExistingApplication = updateExistingApplication;
177
- async function updateExistingApplicationVersion(token, publisherId, applicationId, applicationVersion, updatedApplicationVersion, env = globals_1.Globals.ENV.production) {
179
+ async function updateExistingApplicationVersion(token, publisherId, applicationId, applicationVersion, updatedApplicationVersion, env) {
180
+ const isSemver = !preload_1.default.valid(applicationVersion);
178
181
  try {
179
182
  const { error } = await PUT(`/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}`, {
180
- ...Registry.getAPIUrl(),
183
+ ...Registry.getAPIUrl(env),
181
184
  headers: {
182
185
  ...buildAuthHeader(token),
183
- ...headerBasedOnEnv(env)
186
+ ...injectSemverHeader(isSemver)
184
187
  },
185
188
  params: {
186
189
  path: {
@@ -204,12 +207,13 @@ var Registry;
204
207
  }
205
208
  }
206
209
  Registry.updateExistingApplicationVersion = updateExistingApplicationVersion;
207
- async function publishApplicationVersion(token, publisherId, applicationId, version, apmTagBuffer, env = globals_1.Globals.ENV.production) {
210
+ async function publishApplicationVersion(token, publisherId, applicationId, version, apmTagBuffer, env) {
211
+ const isSemver = !!preload_1.default.valid(version);
208
212
  const { data, error } = await POST('/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}', {
209
- ...Registry.getAPIUrl(),
213
+ ...Registry.getAPIUrl(env),
210
214
  headers: {
211
215
  ...buildAuthHeader(token),
212
- ...headerBasedOnEnv(env)
216
+ ...injectSemverHeader(isSemver)
213
217
  },
214
218
  params: {
215
219
  path: {
@@ -237,13 +241,13 @@ var Registry;
237
241
  'library.tar.gz': 'application/gzip',
238
242
  'studio.json': 'application/json'
239
243
  };
240
- async function publishLibraryVersion(token, publisherId, libraryId, libraryVersion, files, env = globals_1.Globals.ENV.production) {
244
+ async function publishLibraryVersion(token, publisherId, libraryId, libraryVersion, files, env) {
241
245
  try {
242
246
  const { error } = await POST('/packages/{publisherId}/libraries/{libraryId}/versions/{libraryVersion}', {
243
- ...Registry.getAPIUrl(),
247
+ ...Registry.getAPIUrl(env),
244
248
  headers: {
245
249
  ...buildAuthHeader(token),
246
- ...headerBasedOnEnv(env)
250
+ ...injectSemverHeader(true)
247
251
  },
248
252
  params: {
249
253
  path: {
@@ -279,12 +283,13 @@ var Registry;
279
283
  }
280
284
  }
281
285
  Registry.publishLibraryVersion = publishLibraryVersion;
282
- async function updateApplicationFile(token, publisherId, applicationId, applicationVersion, applicationFileName, blob, env = globals_1.Globals.ENV.production) {
286
+ async function updateApplicationFile(token, publisherId, applicationId, applicationVersion, applicationFileName, blob, env) {
287
+ const isSemver = !!preload_1.default.valid(applicationVersion);
283
288
  const { error } = await POST('/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{applicationFileName}', {
284
- ...Registry.getAPIUrl(),
289
+ ...Registry.getAPIUrl(env),
285
290
  headers: {
286
291
  ...buildAuthHeader(token),
287
- ...headerBasedOnEnv(env),
292
+ ...injectSemverHeader(isSemver),
288
293
  'Content-Type': 'application/octet-stream'
289
294
  },
290
295
  params: {
@@ -310,10 +315,9 @@ var Registry;
310
315
  /**
311
316
  * inject the X-Semver header for application based requests
312
317
  * with this header the semver versioning is required
313
- * @param env
314
318
  */
315
- function headerBasedOnEnv(env) {
316
- if ([globals_1.Globals.ENV.lucky, globals_1.Globals.ENV.wynni].includes(env)) {
319
+ function injectSemverHeader(useSemver = false) {
320
+ if (useSemver) {
317
321
  return { 'X-Semver': 'true' };
318
322
  }
319
323
  return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./dist/studio-cli.d.ts",
@@ -20,7 +20,7 @@
20
20
  "test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
21
21
  "watch:test": "npm run test -- --watch",
22
22
  "prepublishOnly": "npm run build",
23
- "build:registryApiTypings": "npx openapi-typescript https://api.registry.wynni.ci.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
23
+ "build:registryApiTypings": "npx openapi-typescript https://api.registry.lucky.ci.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
24
24
  },
25
25
  "author": "Microtronics",
26
26
  "license": "ISC",