diff --git a/.changeset/silver-papers-lick.md b/.changeset/silver-papers-lick.md new file mode 100644 index 000000000..b96ae1a21 --- /dev/null +++ b/.changeset/silver-papers-lick.md @@ -0,0 +1,17 @@ +--- +"@slack/cli-test": major +--- + +fix: remove default "--app deployed" global flag from commands + +Commands running for a specific app must now provide the "app" argument: + +```diff + await SlackCLI.app.delete({ + appPath: "my-app", + team: "T0123456789", ++ app: "deployed", + }); +``` + +The options "local" or "deployed" or app ID all remain available to use. diff --git a/packages/cli-test/src/cli/cli-process.test.ts b/packages/cli-test/src/cli/cli-process.test.ts index 2c8ade63a..cf411a380 100644 --- a/packages/cli-test/src/cli/cli-process.test.ts +++ b/packages/cli-test/src/cli/cli-process.test.ts @@ -98,18 +98,22 @@ describe('SlackCLIProcess class', () => { await cmd.execAsync(); sandbox.assert.calledWith(spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--skip-update'])); }); - it('should default to `--app deployed` but allow overriding that via the `app` parameter', async () => { + it('should only pass `--app` when explicitly provided via the `app` parameter', async () => { let cmd = new SlackCLIProcess(['help']); await cmd.execAsync(); + sandbox.assert.neverCalledWith(spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--app'])); + spawnProcessSpy.resetHistory(); + cmd = new SlackCLIProcess(['help'], { app: 'local' }); + await cmd.execAsync(); + sandbox.assert.calledWith(spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--app', 'local'])); + spawnProcessSpy.resetHistory(); + cmd = new SlackCLIProcess(['help'], { app: 'deployed' }); + await cmd.execAsync(); sandbox.assert.calledWith( spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--app', 'deployed']), ); - spawnProcessSpy.resetHistory(); - cmd = new SlackCLIProcess(['help'], { app: 'local' }); - await cmd.execAsync(); - sandbox.assert.calledWith(spawnProcessSpy, sinon.match.string, sinon.match.array.contains(['--app', 'local'])); }); it('should default to `--force` but allow overriding that via the `force` parameter', async () => { let cmd = new SlackCLIProcess(['help']); diff --git a/packages/cli-test/src/cli/cli-process.ts b/packages/cli-test/src/cli/cli-process.ts index 32cc5ba45..1ca61954f 100644 --- a/packages/cli-test/src/cli/cli-process.ts +++ b/packages/cli-test/src/cli/cli-process.ts @@ -131,11 +131,9 @@ export class SlackCLIProcess { if (opts.team) { cmd = cmd.concat(['--team', opts.team]); } - // App instance; defaults to `deployed` + // App instance if (opts.app) { cmd = cmd.concat(['--app', opts.app]); - } else { - cmd = cmd.concat(['--app', 'deployed']); } // Ignore warnings via --force; defaults to true if (opts.force || typeof opts.force === 'undefined') { @@ -149,9 +147,10 @@ export class SlackCLIProcess { cmd = cmd.concat(['--verbose']); } } else { - cmd = cmd.concat(['--skip-update', '--force', '--app', 'deployed']); + cmd = cmd.concat(['--skip-update', '--force']); } cmd = cmd.concat(this.command); + if (this.commandOptions) { for (const [key, value] of Object.entries(this.commandOptions)) { if (key && value) {