@extrahorizon/exh-cli 1.9.0-dev-95-fe9cf7f → 1.9.0-feat-88-d8aa116

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.
@@ -90,13 +90,6 @@ async function validateConfig(config) {
90
90
  else {
91
91
  throw new Error('Code path not specified');
92
92
  }
93
- if (config.executionCredentials && config.environment) {
94
- const restrictedProperties = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
95
- const foundProperties = Object.keys(config.environment).filter(key => restrictedProperties.includes(key));
96
- if (foundProperties.length > 0) {
97
- throw new Error(`❌ Environment variables [${foundProperties.join(', ')}] may not be provided when using executionCredentials`);
98
- }
99
- }
100
93
  assertExecutionPermission(config.executionPermission);
101
94
  return true;
102
95
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.syncFunctionUser = exports.zipFileFromDirectory = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const os_1 = require("os");
6
- const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
7
6
  const archiver = require("archiver");
8
7
  const chalk = require("chalk");
9
8
  const uuid_1 = require("uuid");
@@ -63,21 +62,10 @@ async function syncFunctionUser(sdk, data) {
63
62
  currentFunction?.environmentVariables?.API_OAUTH_CONSUMER_KEY?.value &&
64
63
  currentFunction?.environmentVariables?.API_OAUTH_CONSUMER_SECRET?.value);
65
64
  if (!hasExistingCredentials) {
66
- throw new Error('❌ The user for the task-config.json executionCredentials exists, but no credentials were found in the Function environmentVariables');
67
- }
68
- const taskUserSdk = (0, javascript_sdk_1.createOAuth1Client)({
69
- host: currentFunction.environmentVariables.API_HOST.value,
70
- tokenSecret: currentFunction.environmentVariables.API_OAUTH_TOKEN_SECRET.value,
71
- token: currentFunction.environmentVariables.API_OAUTH_TOKEN.value,
72
- consumerKey: currentFunction.environmentVariables.API_OAUTH_CONSUMER_KEY.value,
73
- consumerSecret: currentFunction.environmentVariables.API_OAUTH_CONSUMER_SECRET.value,
74
- });
75
- const taskUser = await taskUserSdk.users.me();
76
- if (taskUser.id !== user.id) {
77
- throw new Error(`❌ The credentials found in the Function (${taskUser.email}) do not match the user found for the task-config.json executionCredentials (${user.email})`);
65
+ throw new Error('❌ No credentials were found for the existing user');
78
66
  }
79
67
  console.log(chalk.white('⚙️ Reusing existing user credentials...'));
80
- const userRole = user.roles?.find(({ name }) => name === roleName);
68
+ const userRole = user.roles.find(({ name }) => name === roleName);
81
69
  if (!userRole) {
82
70
  await assignRoleToUser(sdk, user.id, role.id);
83
71
  }
@@ -38,20 +38,21 @@ async function asyncExec(cmd) {
38
38
  exports.asyncExec = asyncExec;
39
39
  function loadAndAssertCredentials() {
40
40
  const credentials = {};
41
+ let credentialsFile;
41
42
  let errorMessage = '';
42
43
  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
- }
44
+ credentialsFile = fs.readFileSync(constants_1.EXH_CONFIG_FILE, 'utf-8');
51
45
  }
52
46
  catch (e) {
53
47
  errorMessage += 'Couldn\'t open ~/.exh/credentials. ';
54
48
  }
49
+ const credentialFileLines = credentialsFile.split(/\r?\n/);
50
+ for (const credentialFileLine of credentialFileLines) {
51
+ const [key, value] = credentialFileLine.split('=');
52
+ if (key && value) {
53
+ credentials[key.trim()] = value.trim();
54
+ }
55
+ }
55
56
  const requiredEnvVariables = ['API_HOST', 'API_OAUTH_CONSUMER_KEY', 'API_OAUTH_CONSUMER_SECRET', 'API_OAUTH_TOKEN', 'API_OAUTH_TOKEN_SECRET'];
56
57
  for (const key of requiredEnvVariables) {
57
58
  if (credentials[key] && !process.env[key]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.9.0-dev-95-fe9cf7f",
3
+ "version": "1.9.0-feat-88-d8aa116",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",