@extrahorizon/exh-cli 1.13.0-dev-185-2ec8f03 → 1.13.0-dev-187-6a4e090

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
@@ -10,6 +10,7 @@
10
10
  * The CLI automatically resolves the template id based on the provided template name.
11
11
  * Removed validation for v1 templates, focusing on improved support for v2 templates in JetBrains IDEs using the provided JSON schemas via `$schema`.
12
12
  * Updated `exh tasks sync` to create users with `activationMode: 'manual'`, preventing unnecessary activation emails.
13
+ * Made file argument optional for `exh dispatchers sync`, defaults to `./dispatchers.json` when no file argument is provided.
13
14
  * Deprecated `exh tasks create-repo` in favor of the new `exh tasks init` command.
14
15
  * Deprecated the use of `templateId` in mail actions, recommending `templateName` instead.
15
16
 
@@ -3,9 +3,10 @@ export declare const command = "sync";
3
3
  export declare const desc = "Synchronize Dispatchers, if a declared Dispatcher does not exist, it will be created";
4
4
  export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "file" | "clean"> & import("yargs").InferredOptionTypes<{
5
5
  file: {
6
- demandOption: true;
6
+ demandOption: false;
7
7
  describe: string;
8
8
  type: "string";
9
+ default: string;
9
10
  };
10
11
  clean: {
11
12
  demandOption: false;
@@ -7,9 +7,10 @@ exports.command = 'sync';
7
7
  exports.desc = 'Synchronize Dispatchers, if a declared Dispatcher does not exist, it will be created';
8
8
  const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
9
9
  file: {
10
- demandOption: true,
10
+ demandOption: false,
11
11
  describe: 'Path to the file containing the Dispatcher(s) configuration',
12
12
  type: 'string',
13
+ default: './dispatchers.json',
13
14
  },
14
15
  clean: {
15
16
  demandOption: false,
package/build/exh.d.ts CHANGED
@@ -2,3 +2,4 @@ import { OAuth1Client } from '@extrahorizon/javascript-sdk';
2
2
  export declare function sdkAuth(): Promise<OAuth1Client>;
3
3
  export declare function getSdk(): OAuth1Client;
4
4
  export declare function getNewSdkInstance(): OAuth1Client;
5
+ export declare function writeCredentialsToFile(host: string, consumerKey: string, consumerSecret: string, token: string, tokenSecret: string): void;
package/build/exh.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNewSdkInstance = exports.getSdk = exports.sdkAuth = void 0;
3
+ exports.writeCredentialsToFile = exports.getNewSdkInstance = exports.getSdk = exports.sdkAuth = void 0;
4
+ const fs = require("fs");
4
5
  const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
5
- const util_1 = require("./helpers/util");
6
+ const chalk = require("chalk");
7
+ const constants_1 = require("./constants");
6
8
  let sdk = null;
7
9
  async function sdkAuth() {
8
- (0, util_1.loadAndAssertCredentials)();
10
+ loadAndAssertCredentials();
9
11
  sdk = getNewSdkInstance();
10
12
  try {
11
13
  await sdk.auth.authenticate({
@@ -34,3 +36,47 @@ function getNewSdkInstance() {
34
36
  });
35
37
  }
36
38
  exports.getNewSdkInstance = getNewSdkInstance;
39
+ function loadAndAssertCredentials() {
40
+ const credentials = {};
41
+ let errorMessage = '';
42
+ try {
43
+ const credentialsFile = fs.readFileSync(constants_1.EXH_CONFIG_FILE, 'utf-8');
44
+ const credentialFileLines = credentialsFile.split(/\r?\n/);
45
+ for (const credentialFileLine of credentialFileLines) {
46
+ const [key, value] = credentialFileLine.split('=');
47
+ if (key && value) {
48
+ credentials[key.trim()] = value.trim();
49
+ }
50
+ }
51
+ }
52
+ catch (e) {
53
+ errorMessage += 'Couldn\'t open ~/.exh/credentials. ';
54
+ }
55
+ const requiredEnvVariables = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
56
+ for (const key of requiredEnvVariables) {
57
+ if (credentials[key] && !process.env[key]) {
58
+ process.env[key] = credentials[key];
59
+ }
60
+ }
61
+ const missingEnvironmentVariables = requiredEnvVariables.filter(key => !process.env[key]);
62
+ if (missingEnvironmentVariables.length > 0) {
63
+ errorMessage += `Missing environment variables: ${missingEnvironmentVariables.join(',')}`;
64
+ throw new Error(`Failed to retrieve all credentials. ${errorMessage}`);
65
+ }
66
+ }
67
+ function writeCredentialsToFile(host, consumerKey, consumerSecret, token, tokenSecret) {
68
+ try {
69
+ fs.statSync(constants_1.EXH_CONFIG_FILE_DIR);
70
+ }
71
+ catch (err) {
72
+ fs.mkdirSync(constants_1.EXH_CONFIG_FILE_DIR);
73
+ }
74
+ fs.writeFileSync(constants_1.EXH_CONFIG_FILE, `API_HOST=${host}
75
+ API_OAUTH_CONSUMER_KEY=${consumerKey}
76
+ API_OAUTH_CONSUMER_SECRET=${consumerSecret}
77
+ API_OAUTH_TOKEN=${token}
78
+ API_OAUTH_TOKEN_SECRET=${tokenSecret}
79
+ `);
80
+ console.log(chalk.green('Wrote credentials to', constants_1.EXH_CONFIG_FILE));
81
+ }
82
+ exports.writeCredentialsToFile = writeCredentialsToFile;
@@ -1,7 +1,6 @@
1
1
  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
- export declare function loadAndAssertCredentials(): void;
5
4
  export declare function getSwaggerDocumentationUrl(subPath: string): string;
6
5
  export declare function ajvValidate<T>(schema: any, data: any): asserts data is T;
7
6
  export declare function getAjvErrorStrings(errors: any[]): string[];
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAjvErrorStrings = exports.ajvValidate = exports.getSwaggerDocumentationUrl = exports.loadAndAssertCredentials = exports.asyncExec = exports.epilogue = void 0;
3
+ exports.getAjvErrorStrings = exports.ajvValidate = exports.getSwaggerDocumentationUrl = 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");
7
7
  const ajv_1 = require("ajv");
8
8
  const chalk = require("chalk");
9
- const constants_1 = require("../constants");
10
9
  const error_1 = require("./error");
11
10
  function epilogue(y) {
12
11
  return y.epilogue('Visit https://docs.extrahorizon.com/extrahorizon-cli/ for more information.').fail((msg, err, argv) => {
@@ -38,35 +37,6 @@ async function asyncExec(cmd) {
38
37
  });
39
38
  }
40
39
  exports.asyncExec = asyncExec;
41
- function loadAndAssertCredentials() {
42
- const credentials = {};
43
- let errorMessage = '';
44
- try {
45
- const credentialsFile = fs.readFileSync(constants_1.EXH_CONFIG_FILE, 'utf-8');
46
- const credentialFileLines = credentialsFile.split(/\r?\n/);
47
- for (const credentialFileLine of credentialFileLines) {
48
- const [key, value] = credentialFileLine.split('=');
49
- if (key && value) {
50
- credentials[key.trim()] = value.trim();
51
- }
52
- }
53
- }
54
- catch (e) {
55
- errorMessage += 'Couldn\'t open ~/.exh/credentials. ';
56
- }
57
- const requiredEnvVariables = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
58
- for (const key of requiredEnvVariables) {
59
- if (credentials[key] && !process.env[key]) {
60
- process.env[key] = credentials[key];
61
- }
62
- }
63
- const missingEnvironmentVariables = requiredEnvVariables.filter(key => !process.env[key]);
64
- if (missingEnvironmentVariables.length > 0) {
65
- errorMessage += `Missing environment variables: ${missingEnvironmentVariables.join(',')}`;
66
- throw new Error(`Failed to retrieve all credentials. ${errorMessage}`);
67
- }
68
- }
69
- exports.loadAndAssertCredentials = loadAndAssertCredentials;
70
40
  function getSwaggerDocumentationUrl(subPath) {
71
41
  const packageJsonPath = path.join(__dirname, '../../package.json');
72
42
  const packageJsonString = fs.readFileSync(packageJsonPath, 'utf-8');
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.whoami = exports.login = void 0;
4
- const fs = require("fs/promises");
5
4
  const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
6
- const chalk = require("chalk");
7
- const constants_1 = require("../constants");
5
+ const exh_1 = require("../exh");
8
6
  const authRepository = require("../repositories/auth");
9
7
  async function login(host, email, password, consumerKey, consumerSecret) {
10
8
  const sdk = (0, javascript_sdk_1.createOAuth1Client)({
@@ -16,19 +14,7 @@ async function login(host, email, password, consumerKey, consumerSecret) {
16
14
  email,
17
15
  password,
18
16
  });
19
- try {
20
- await fs.stat(constants_1.EXH_CONFIG_FILE_DIR);
21
- }
22
- catch (err) {
23
- await fs.mkdir(constants_1.EXH_CONFIG_FILE_DIR);
24
- }
25
- await fs.writeFile(constants_1.EXH_CONFIG_FILE, `API_HOST=${host}
26
- API_OAUTH_CONSUMER_KEY=${consumerKey}
27
- API_OAUTH_CONSUMER_SECRET=${consumerSecret}
28
- API_OAUTH_TOKEN=${response.token}
29
- API_OAUTH_TOKEN_SECRET=${response.tokenSecret}
30
- `);
31
- console.log(chalk.green('Wrote credentials to', constants_1.EXH_CONFIG_FILE));
17
+ (0, exh_1.writeCredentialsToFile)(host, consumerKey, consumerSecret, response.token, response.tokenSecret);
32
18
  }
33
19
  exports.login = login;
34
20
  async function whoami() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.13.0-dev-185-2ec8f03",
3
+ "version": "1.13.0-dev-187-6a4e090",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",