heroku 10.0.0-beta.2 → 10.0.0-beta.3

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,17 +1,18 @@
1
1
  import { Command } from '@heroku-cli/command';
2
2
  export default class RunInside extends Command {
3
3
  static description: string;
4
- static example: string;
4
+ static strict: boolean;
5
+ static args: {
6
+ dyno_name: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
7
+ command: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
8
+ };
5
9
  static flags: {
6
10
  app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
- remote: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
11
  'exit-code': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
12
  listen: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ 'no-launcher': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ remote: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
15
  };
11
- static args: {
12
- DYNO_NAME: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
13
- COMMAND: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
14
- };
15
- static strict: boolean;
16
+ static examples: string[];
16
17
  run(): Promise<void>;
17
18
  }
@@ -3,20 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
5
  const debug_1 = require("debug");
6
+ const tsheredoc_1 = require("tsheredoc");
6
7
  const dyno_1 = require("../../lib/run/dyno");
7
8
  const helpers_1 = require("../../lib/run/helpers");
8
- const tsheredoc_1 = require("tsheredoc");
9
9
  const debug = (0, debug_1.default)('heroku:run:inside');
10
10
  class RunInside extends command_1.Command {
11
11
  async run() {
12
- const { flags, args } = await this.parse(RunInside);
12
+ const { args, argv, flags } = await this.parse(RunInside);
13
+ const { dyno_name: dynoName } = args;
14
+ const { app: appName, 'exit-code': exitCode, listen, 'no-launcher': noLauncher } = flags;
15
+ const prependLauncher = !noLauncher;
16
+ const { body: app } = await this.heroku.get(`/apps/${appName}`, {
17
+ headers: { Accept: 'application/vnd.heroku+json; version=3.sdk' },
18
+ });
19
+ const appStackIsCnb = app.stack.name === 'cnb';
13
20
  const opts = {
14
- 'exit-code': flags['exit-code'],
15
- app: flags.app,
16
- command: (0, helpers_1.buildCommand)([args.COMMAND]),
17
- dyno: args.DYNO_NAME,
21
+ app: appName,
22
+ command: (0, helpers_1.buildCommand)(argv.slice(1), appStackIsCnb && prependLauncher),
23
+ dyno: dynoName,
24
+ 'exit-code': exitCode,
18
25
  heroku: this.heroku,
19
- listen: flags.listen,
26
+ listen,
20
27
  };
21
28
  const dyno = new dyno_1.default(opts);
22
29
  try {
@@ -34,23 +41,42 @@ class RunInside extends command_1.Command {
34
41
  }
35
42
  }
36
43
  exports.default = RunInside;
37
- RunInside.description = 'run a one-off process inside an existing heroku dyno (for Fir-generation apps only)';
38
- RunInside.example = (0, tsheredoc_1.default) `
39
- Run bash
40
- $ heroku run:inside web-848cd4f64d-pvpr2 bash
41
- Run a command supplied by a script
42
- $ heroku run:inside web-848cd4f64d-pvpr2 -- myscript.sh
43
- Run a command declared for the worker process type in a Procfile
44
- $ heroku run:inside worker
45
- `;
44
+ RunInside.description = 'run a command inside an existing dyno (for Fir-generation apps only)';
45
+ RunInside.strict = false;
46
+ RunInside.args = {
47
+ dyno_name: core_1.Args.string({
48
+ description: 'name of the dyno to run command inside',
49
+ required: true,
50
+ }),
51
+ command: core_1.Args.string({
52
+ description: 'command to run (Heroku automatically prepends ‘launcher’ to the command)',
53
+ required: true,
54
+ }),
55
+ };
46
56
  RunInside.flags = {
47
57
  app: command_1.flags.app({ required: true }),
48
- remote: command_1.flags.remote(),
49
- 'exit-code': command_1.flags.boolean({ char: 'x', description: 'passthrough the exit code of the remote command' }),
58
+ 'exit-code': command_1.flags.boolean({
59
+ char: 'x',
60
+ description: 'passthrough the exit code of the remote command',
61
+ }),
50
62
  listen: command_1.flags.boolean({ description: 'listen on a local port', hidden: true }),
63
+ 'no-launcher': command_1.flags.boolean({
64
+ description: 'don’t prepend ‘launcher’ before a command',
65
+ default: false,
66
+ }),
67
+ remote: command_1.flags.remote(),
51
68
  };
52
- RunInside.args = {
53
- DYNO_NAME: core_1.Args.string({ required: true, description: 'name of the dyno to run command inside' }),
54
- COMMAND: core_1.Args.string({ required: true, description: 'command to run' }),
55
- };
56
- RunInside.strict = false;
69
+ RunInside.examples = [
70
+ (0, tsheredoc_1.default) `
71
+ Run bash
72
+ heroku run:inside web-848cd4f64d-pvpr2 bash -a my-app
73
+ `,
74
+ (0, tsheredoc_1.default) `
75
+ Run a command supplied by a script taking option flags
76
+ heroku run:inside web-848cd4f64d-pvpr2 -a my-app -- myscript.sh -x --log-level=warn
77
+ `,
78
+ (0, tsheredoc_1.default) `
79
+ Run a command declared for the worker process type in a Procfile
80
+ heroku run:inside web-848cd4f64d-pvpr2 worker -a my-app
81
+ `,
82
+ ];
@@ -1,3 +1,3 @@
1
1
  export declare function revertSortedArgs(processArgs: Array<string>, argv: Array<string>): string[];
2
- export declare function buildCommand(args: Array<string>): string;
2
+ export declare function buildCommand(args: Array<string>, prependLauncher?: boolean): string;
3
3
  export declare function buildEnvFromFlag(flag: string): {};
@@ -26,11 +26,12 @@ function revertSortedArgs(processArgs, argv) {
26
26
  return originalInputOrder;
27
27
  }
28
28
  exports.revertSortedArgs = revertSortedArgs;
29
- function buildCommand(args) {
29
+ function buildCommand(args, prependLauncher = false) {
30
+ const prependText = prependLauncher ? 'launcher ' : '';
30
31
  if (args.length === 1) {
31
32
  // do not add quotes around arguments if there is only one argument
32
33
  // `heroku run "rake test"` should work like `heroku run rake test`
33
- return args[0];
34
+ return `${prependText}${args[0]}`;
34
35
  }
35
36
  let cmd = '';
36
37
  for (let arg of args) {
@@ -39,7 +40,7 @@ function buildCommand(args) {
39
40
  }
40
41
  cmd = cmd + ' ' + arg;
41
42
  }
42
- return cmd.trim();
43
+ return `${prependText}${cmd.trim()}`;
43
44
  }
44
45
  exports.buildCommand = buildCommand;
45
46
  function buildEnvFromFlag(flag) {