Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/silver-papers-lick.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 9 additions & 5 deletions packages/cli-test/src/cli/cli-process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
Comment on lines 102 to +104

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 praise: Thanks for covering these cases!

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']);
Expand Down
7 changes: 3 additions & 4 deletions packages/cli-test/src/cli/cli-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -149,9 +147,10 @@ export class SlackCLIProcess {
cmd = cmd.concat(['--verbose']);
}
} else {
cmd = cmd.concat(['--skip-update', '--force', '--app', 'deployed']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪓 praise: Nice!

🔮 note: I have hope to split "force" into more meaningful flags and perhaps we use an environment variable to skip updates in later changes. I'm hoping we avoid having defaults exposed for each command.

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) {
Expand Down
Loading