@extrahorizon/exh-cli 1.10.0-dev-108-6b89c8f → 1.10.0-dev-111-f2a13ab

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.
@@ -29,7 +29,7 @@ const handler = async function init({ name, path }) {
29
29
  exports.handler = handler;
30
30
  function createSchema(name) {
31
31
  return {
32
- $schema: `https://swagger.extrahorizon.com/cli/${(0, util_1.getCliVersion)()}/config-json-schemas/Schema.json`,
32
+ $schema: (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/Schema.json'),
33
33
  name,
34
34
  description: `The ${name} schema`,
35
35
  createMode: 'allUsers',
@@ -34,7 +34,7 @@ async function changePackageFile(name) {
34
34
  }
35
35
  try {
36
36
  const taskConfig = JSON.parse((await (0, promises_1.readFile)(`${name}/task-config.json`)).toString());
37
- taskConfig.$schema = `https://swagger.extrahorizon.com/cli/${(0, util_1.getCliVersion)()}/config-json-schemas/TaskConfig.json`;
37
+ taskConfig.$schema = (0, util_1.getSwaggerDocumentationUrl)('config-json-schemas/TaskConfig.json');
38
38
  taskConfig.name = name;
39
39
  taskConfig.description = `${name} task`;
40
40
  await (0, promises_1.writeFile)(`${name}/task-config.json`, JSON.stringify(taskConfig, null, 4));
@@ -2,5 +2,5 @@ import * as yargs from 'yargs';
2
2
  export declare function epilogue(y: yargs.Argv): yargs.Argv;
3
3
  export declare function asyncExec(cmd: string): Promise<string>;
4
4
  export declare function loadAndAssertCredentials(): void;
5
- export declare function getCliVersion(): any;
5
+ export declare function getSwaggerDocumentationUrl(subPath: string): string;
6
6
  export declare function getAjvErrorStrings(errors: any[]): string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAjvErrorStrings = exports.getCliVersion = exports.loadAndAssertCredentials = exports.asyncExec = exports.epilogue = void 0;
3
+ exports.getAjvErrorStrings = exports.getSwaggerDocumentationUrl = exports.loadAndAssertCredentials = exports.asyncExec = exports.epilogue = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
@@ -66,12 +66,20 @@ function loadAndAssertCredentials() {
66
66
  }
67
67
  }
68
68
  exports.loadAndAssertCredentials = loadAndAssertCredentials;
69
- function getCliVersion() {
69
+ function getSwaggerDocumentationUrl(subPath) {
70
70
  const packageJsonPath = path.join(__dirname, '../../package.json');
71
71
  const packageJsonString = fs.readFileSync(packageJsonPath, 'utf-8');
72
- return JSON.parse(packageJsonString).version;
72
+ const packageVersion = JSON.parse(packageJsonString).version;
73
+ if (packageVersion.match(/^\d+\.\d+\.\d+$/)) {
74
+ return `https://swagger.extrahorizon.com/cli/${packageVersion}/${subPath}`;
75
+ }
76
+ if (packageVersion.match(/^\d+\.\d+\.\d+-.*$/)) {
77
+ const versionParts = packageVersion.split('-');
78
+ return `https://swagger.extrahorizon.com/cli/${versionParts[0]}-dev/${subPath}`;
79
+ }
80
+ throw new Error(`Unknown CLI version format: ${packageVersion}`);
73
81
  }
74
- exports.getCliVersion = getCliVersion;
82
+ exports.getSwaggerDocumentationUrl = getSwaggerDocumentationUrl;
75
83
  function getAjvErrorStrings(errors) {
76
84
  return errors.map(error => {
77
85
  let message = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.10.0-dev-108-6b89c8f",
3
+ "version": "1.10.0-dev-111-f2a13ab",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",