bdy 1.26.6-dev → 1.26.7-dev

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.26.6-dev",
4
+ "version": "1.26.7-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://buddy.works/docs/cli",
@@ -49,9 +49,7 @@ function cliIndex() {
49
49
  : options);
50
50
  });
51
51
  program.hook('preAction', pre_1.default);
52
- program.configureHelp({
53
- formatHelp: utils_1.formatHelp,
54
- });
52
+ program.configureHelp(utils_1.helpConfiguration);
55
53
  // root options must come before the subcommand, so -v here can't
56
54
  // shadow subcommand flags like `sandbox create -v <variable>`
57
55
  program.enablePositionalOptions();
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildInjection = exports.parseVarFile = void 0;
6
+ exports.buildInjection = exports.effectiveVariables = exports.parseVarFile = void 0;
7
7
  const node_os_1 = require("node:os");
8
8
  const node_path_1 = require("node:path");
9
9
  const utils_1 = require("../../utils");
@@ -33,6 +33,22 @@ const parseVarFile = (spec) => {
33
33
  return { key, path: (0, node_path_1.resolve)(path) };
34
34
  };
35
35
  exports.parseVarFile = parseVarFile;
36
+ /**
37
+ * The variables of an environment that apply: GET /variables?environment_id=
38
+ * lists the environment's own variables first, then its bases nearest first,
39
+ * so the first variable of a key wins - a disabled one too, which leaves the
40
+ * key out rather than letting a base fill it.
41
+ */
42
+ const effectiveVariables = (variables) => {
43
+ const seen = new Set();
44
+ return variables.filter((v) => {
45
+ if (seen.has(v.key))
46
+ return false;
47
+ seen.add(v.key);
48
+ return true;
49
+ });
50
+ };
51
+ exports.effectiveVariables = effectiveVariables;
36
52
  /**
37
53
  * What goes into the command, from GET /variables?environment_id=: the
38
54
  * environment's own variables first, then its bases nearest first, so the
@@ -40,7 +56,7 @@ exports.parseVarFile = parseVarFile;
40
56
  *
41
57
  * VAR variables go into the process environment - all of them, or only the
42
58
  * ones named by --var. File variables go only where --var-file puts them,
43
- * with their password/passphrase as KEY_PASSWORD/KEY_PASSPHRASE.
59
+ * with their password/passphrase as <KEY>_PASSWORD/<KEY>_PASSPHRASE.
44
60
  *
45
61
  * An encrypted value the API did not decrypt fails the whole run: injecting
46
62
  * the masked form would hand the command a wrong secret without a word. The
@@ -50,11 +66,7 @@ exports.parseVarFile = parseVarFile;
50
66
  * with the flag on, the token's scope.
51
67
  */
52
68
  const buildInjection = (variables, environment, vars, varFiles) => {
53
- const byKey = new Map();
54
- for (const variable of variables) {
55
- if (!byKey.has(variable.key))
56
- byKey.set(variable.key, variable);
57
- }
69
+ const byKey = new Map((0, exports.effectiveVariables)(variables).map((v) => [v.key, v]));
58
70
  const find = (key) => {
59
71
  const variable = byKey.get(key);
60
72
  if (!variable) {
@@ -8,6 +8,7 @@ const texts_1 = require("../../texts");
8
8
  const output_1 = __importDefault(require("../../output"));
9
9
  const input_1 = __importDefault(require("../../input"));
10
10
  const scope_1 = require("./scope");
11
+ const injection_1 = require("./injection");
11
12
  const commandVariableList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_VARIABLE_LIST, {
12
13
  requiredScopes: [utils_1.REST_API_SCOPE.VARIABLE_READ],
13
14
  examples: texts_1.EXAMPLE_VARIABLE_LIST,
@@ -27,19 +28,24 @@ commandVariableList.action(async (options) => {
27
28
  const client = input_1.default.restApiTokenClient();
28
29
  const params = await (0, scope_1.resolveVariableScope)(client, workspace, project, scope, options);
29
30
  const result = await client.getVariables(workspace, params);
30
- const variables = result.variables || [];
31
31
  if (options.format === 'json') {
32
- output_1.default.json(variables);
32
+ output_1.default.json(result.variables || []);
33
33
  }
34
34
  else {
35
+ // An environment's list also carries the variables of its base
36
+ // environments; text shows only the ones that apply, as inject does,
37
+ // and where an inherited one comes from (base_environment).
38
+ const variables = (0, injection_1.effectiveVariables)(result.variables || []);
35
39
  if (variables.length === 0) {
36
40
  output_1.default.exitNormal(texts_1.TXT_VARIABLE_NOT_FOUND);
37
41
  }
38
- const data = [
39
- ['KEY', 'VALUE', 'TYPE', 'ENCRYPTED', 'SETTABLE', 'SCOPE'],
40
- ];
42
+ const inherited = variables.some((v) => v.base_environment);
43
+ const header = ['KEY', 'VALUE', 'TYPE', 'ENCRYPTED', 'SETTABLE', 'SCOPE'];
44
+ if (inherited)
45
+ header.push('INHERITED FROM');
46
+ const data = [header];
41
47
  for (const variable of variables) {
42
- data.push([
48
+ const row = [
43
49
  variable.key,
44
50
  (0, scope_1.variableValueOf)(variable, 40),
45
51
  variable.type || '-',
@@ -47,7 +53,12 @@ commandVariableList.action(async (options) => {
47
53
  variable.settable ? 'true' : 'false',
48
54
  // the list is exact-scope and its items carry no owner object
49
55
  scope,
50
- ]);
56
+ ];
57
+ if (inherited) {
58
+ const base = variable.base_environment;
59
+ row.push(base ? base.identifier || base.name || base.id : '-');
60
+ }
61
+ data.push(row);
51
62
  }
52
63
  output_1.default.table(data);
53
64
  }
@@ -1263,7 +1263,7 @@ exports.OPTION_VARIABLE_ENABLE = 'Enable the variable';
1263
1263
  exports.OPTION_VARIABLE_DISABLE = 'Disable the variable. A disabled variable is not injected anywhere';
1264
1264
  exports.OPTION_VARIABLE_INJECT_ENVIRONMENT = 'Environment identifier (required). Its variables and those of its base environments are injected, its own winning. Looked up in the project first (--project, BUDDY_PROJECT or the linked project), then in the workspace; --scope picks exactly one of them';
1265
1265
  exports.OPTION_VARIABLE_INJECT_VAR = 'Inject only this VAR variable into the environment of the command; repeatable. By default every VAR variable of the environment is injected';
1266
- exports.OPTION_VARIABLE_INJECT_VAR_FILE = 'Write a file variable (FILE, SSH_KEY, SSH_PUBLIC_KEY, GPG_KEY, P12, IOS_KEYCHAIN, IOS_PROVISION_PROFILES) to a new file at PATH for the time of the command, then delete it; repeatable. Its password and passphrase go into KEY_PASSWORD and KEY_PASSPHRASE';
1266
+ exports.OPTION_VARIABLE_INJECT_VAR_FILE = 'Write a file variable (FILE, SSH_KEY, SSH_PUBLIC_KEY, GPG_KEY, P12, IOS_KEYCHAIN, IOS_PROVISION_PROFILES) to a new file at PATH for the time of the command, then delete it; repeatable. Its password and passphrase go into <KEY>_PASSWORD and <KEY>_PASSPHRASE, e.g. DEPLOY_KEY_PASSPHRASE';
1267
1267
  exports.OPTION_VARIABLE_INJECT_NO_MASKING = 'Do not mask encrypted values in the output of the command. The command then gets the terminal directly, which interactive programs need';
1268
1268
  exports.OPTION_VARIABLE_INJECT_WAIT = 'With masking: how many seconds to wait, after the command exited, for its output to close - a process it left in the background keeps it open. Past that bdy stops passing the output on and exits with 1 (such a process gets SIGPIPE on its next write). 0 waits without a limit. Time a slow reader of the output holds it up is not counted';
1269
1269
  exports.OPTION_VARIABLE_INJECT_COMMAND = 'Command to run with its arguments, after --';
@@ -37,8 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.VARIABLE_TYPE = exports.VARIABLE_SCOPE = exports.TARGET_SCOPE = exports.PROJECT_SOURCE_INTEGRATION_TYPES = exports.PROJECT_SOURCE_ALIASES = exports.PROJECT_SOURCE = exports.PROJECT_STATUS = exports.PROJECT_ACCESS = exports.DOMAIN_TYPE = exports.ARTIFACT_VERSION_STATUS = exports.ARTIFACT_TYPE = exports.SANDBOX_SNAPSHOT_STATUS = exports.SANDBOX_APP_STATUS = exports.SANDBOX_SETUP_STATUS = exports.SANDBOX_EXEC_STATUS = exports.SANDBOX_EXEC_RUNTIME = exports.SANDBOX_STATUS = exports.REST_API_ENDPOINT = exports.REST_API_REGION = exports.DEFAULT_SANDBOX_CP_USER = exports.ARTIFACT_DEFAULT_VERSION = exports.SUGGESTED_BROWSER_VERSION = exports.AGENT_TUNNEL_REPLACE_TIMEOUT_MS = exports.AGENT_UPDATE_STATUS_TTL_MS = exports.AGENT_UPDATE_PROBATION_MS = exports.AGENT_UPDATE_MAX_ATTEMPTS = exports.AGENT_FETCH_RETRY_MAX = exports.AGENT_FETCH_RETRY_MIN = exports.SSH_HANDSHAKE_TIMEOUT = exports.TUNNEL_SSH_FORWARD_IDLE_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.getSshIdent = exports.TUNNEL_SSH_IDENT_SHARED_H1 = exports.TUNNEL_SSH_IDENT_SHARED_H2 = exports.TUNNEL_CLIENT_IP_HEADER = exports.TUNNEL_H2_WINDOW_SIZE = exports.TUNNEL_HTTP2_SHED_LOG_INTERVAL = exports.TUNNEL_HTTP2_MAX_SESSIONS = exports.TUNNEL_HTTP1_CHANNEL_KEEPALIVE = exports.TUNNEL_HTTP2_SESSION_IDLE_TIMEOUT = exports.TUNNEL_HTTP_RETRY_AFTER = exports.TUNNEL_HTTP_MAX_INFLIGHT = exports.TUNNEL_HTTP_CB_MIN_REQUESTS = exports.TUNNEL_HTTP_CB_WINDOW = exports.TUNNEL_MAX_REQUEST_SIZE_TO_SYNC = exports.TUNNEL_HTTP_LOG_MAX_REQUESTS = exports.TUNNEL_HTTP_LOG_MAX_BODY = exports.TUNNEL_HTTP_RATE_WINDOW = exports.TUNNEL_HTTP_RATE_LIMIT = exports.REST_API_SCOPE = void 0;
40
- exports.getServiceUser = exports.getRealTargetHost = exports.isWindows = exports.isLinux = exports.isOsx = exports.isDocker = exports.truncate = exports.sleep = exports.getLatestVersion = exports.getVersionEnv = exports.getCurrentVersionWithoutEnv = exports.isVersionNewer = exports.getVersionWithoutEnv = exports.parseVersion = exports.getVersion = exports.isInstalledByChoco = exports.isInstalledByApt = exports.isInstalledByBrew = exports.isInstalledByNpm = exports.isNpmGlobalWritable = exports.isPathWritable = exports.tryGetEmail = exports.execLocally = exports.getHomeDirectory = exports.HOME_DIR_NAME = exports.chownToHomeOwner = exports.isDomainAvailable = exports.sandboxScopeOptions = exports.newCommand = exports.formatBytes = exports.formatHelp = exports.getPlatform = exports.getHostname = exports.isStringRegExp = exports.getWorkingDir = exports.getRootDir = exports.TARGET_ONLY_PORT_REGEX = exports.TARGET_HTTP_REGEX = exports.TARGET_TCP_TLS_REGEX = exports.ApiErrorTunnelsDisabled = exports.ApiErrorWorkspaceFlagged = exports.ApiErrorTunnelLimitReached = exports.ApiErrorAgentLimitReached = exports.ApiErrorDomainRestricted = exports.ApiErrorTargetInvalid = exports.ApiErrorWrongToken = exports.ApiErrorFailedToConnect = exports.ApiErrorAgentNotFound = exports.ARTIFACT_AUTH_TYPE = exports.TARGET_EXEC_STATUS = void 0;
41
- exports.findArtifactReadme = exports.isPathInside = exports.getComposerReadmePath = exports.parseComposerJson = exports.ARTIFACT_README_NAMES = exports.ARTIFACT_README_SIZE_LIMIT = exports.filterIgnoredEntries = exports.parseIgnorePatterns = exports.ARTIFACT_IGNORE_DEFAULT = exports.createZip = exports.getGitName = exports.getGitEmail = exports.MCP_TOOL_CATEGORIES = exports.getBasicCommandTls = exports.getBasicCommandHttp = exports.getBasicCommandSandboxEndpoint = exports.getBasicCommandTcp = exports.getCurrentUser = void 0;
40
+ exports.getRealTargetHost = exports.isWindows = exports.isLinux = exports.isOsx = exports.isDocker = exports.truncate = exports.sleep = exports.getLatestVersion = exports.getVersionEnv = exports.getCurrentVersionWithoutEnv = exports.isVersionNewer = exports.getVersionWithoutEnv = exports.parseVersion = exports.getVersion = exports.isInstalledByChoco = exports.isInstalledByApt = exports.isInstalledByBrew = exports.isInstalledByNpm = exports.isNpmGlobalWritable = exports.isPathWritable = exports.tryGetEmail = exports.execLocally = exports.getHomeDirectory = exports.HOME_DIR_NAME = exports.chownToHomeOwner = exports.isDomainAvailable = exports.sandboxScopeOptions = exports.newCommand = exports.helpConfiguration = exports.formatBytes = exports.formatHelp = exports.getPlatform = exports.getHostname = exports.isStringRegExp = exports.getWorkingDir = exports.getRootDir = exports.TARGET_ONLY_PORT_REGEX = exports.TARGET_HTTP_REGEX = exports.TARGET_TCP_TLS_REGEX = exports.ApiErrorTunnelsDisabled = exports.ApiErrorWorkspaceFlagged = exports.ApiErrorTunnelLimitReached = exports.ApiErrorAgentLimitReached = exports.ApiErrorDomainRestricted = exports.ApiErrorTargetInvalid = exports.ApiErrorWrongToken = exports.ApiErrorFailedToConnect = exports.ApiErrorAgentNotFound = exports.ARTIFACT_AUTH_TYPE = exports.TARGET_EXEC_STATUS = void 0;
41
+ exports.findArtifactReadme = exports.isPathInside = exports.getComposerReadmePath = exports.parseComposerJson = exports.ARTIFACT_README_NAMES = exports.ARTIFACT_README_SIZE_LIMIT = exports.filterIgnoredEntries = exports.parseIgnorePatterns = exports.ARTIFACT_IGNORE_DEFAULT = exports.createZip = exports.getGitName = exports.getGitEmail = exports.MCP_TOOL_CATEGORIES = exports.getBasicCommandTls = exports.getBasicCommandHttp = exports.getBasicCommandSandboxEndpoint = exports.getBasicCommandTcp = exports.getCurrentUser = exports.getServiceUser = void 0;
42
42
  exports.executionExitCode = executionExitCode;
43
43
  exports.apiErrorCodeToClass = apiErrorCodeToClass;
44
44
  exports.isFile = isFile;
@@ -72,6 +72,7 @@ const node_sea_1 = require("node:sea");
72
72
  const node_zlib_1 = __importDefault(require("node:zlib"));
73
73
  const node_stream_1 = require("node:stream");
74
74
  const promises_1 = require("node:stream/promises");
75
+ const commander_1 = require("commander");
75
76
  const cliCommand_1 = __importDefault(require("./cliCommand"));
76
77
  const node_os_1 = __importStar(require("node:os"));
77
78
  const node_net_1 = __importDefault(require("node:net"));
@@ -579,13 +580,33 @@ const formatBytes = (bytes) => {
579
580
  return `${bytes}GB`;
580
581
  };
581
582
  exports.formatBytes = formatBytes;
583
+ // Commander names a command in help by its first alias only (`inject|exec`),
584
+ // so every other alias (`run`) worked but was nowhere to be seen.
585
+ const withAllAliases = (cmd, text) => {
586
+ const aliases = cmd.aliases();
587
+ if (aliases.length < 2)
588
+ return text;
589
+ return text.replace(`${cmd.name()}|${aliases[0]}`, [cmd.name(), ...aliases].join('|'));
590
+ };
591
+ exports.helpConfiguration = {
592
+ formatHelp: exports.formatHelp,
593
+ subcommandTerm(cmd) {
594
+ return withAllAliases(cmd, commander_1.Help.prototype.subcommandTerm.call(this, cmd));
595
+ },
596
+ commandUsage(cmd) {
597
+ // the command's own name comes last, after its ancestors'
598
+ const usage = commander_1.Help.prototype.commandUsage.call(this, cmd);
599
+ const at = usage.lastIndexOf(`${cmd.name()}|`);
600
+ if (at < 0)
601
+ return usage;
602
+ return usage.slice(0, at) + withAllAliases(cmd, usage.slice(at));
603
+ },
604
+ };
582
605
  const newCommand = (name, desc, metadata) => {
583
606
  const cmd = new cliCommand_1.default(name, metadata);
584
607
  if (desc)
585
608
  cmd.description(desc);
586
- cmd.configureHelp({
587
- formatHelp: exports.formatHelp,
588
- });
609
+ cmd.configureHelp(exports.helpConfiguration);
589
610
  return cmd;
590
611
  };
591
612
  exports.newCommand = newCommand;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.26.6-dev",
4
+ "version": "1.26.7-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://buddy.works/docs/cli",