Skip to content

Commit

Permalink
cli-test: expose --slackdev flag as qa option to all commands (#1799)
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj authored May 29, 2024
1 parent a0e01c5 commit 1938408
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 34 deletions.
16 changes: 10 additions & 6 deletions packages/cli-test/src/cli/commands/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import commandError from '../command-error';
export const del = async function appDelete(
appPath: string,
teamFlag: string,
options?: { isLocalApp?: boolean },
options?: { isLocalApp?: boolean, qa?: boolean },
): Promise<string> {
// TODO: breaking change, separate params vs single-param-object
// TODO: breaking change, separate params vs single-param-object, probably should reflect global vs command CLI flags
const appEnvironment = options?.isLocalApp ? 'local' : 'deployed';
const cmd = new SlackCLIProcess('app delete --force', { team: teamFlag }, {
const cmd = new SlackCLIProcess('app delete --force', { team: teamFlag, qa: options?.qa }, {
'--app': appEnvironment,
});
try {
Expand All @@ -33,9 +33,13 @@ export const del = async function appDelete(
* @param teamFlag team domain where the app will be installed
* @returns command output
*/
export const install = async function workspaceInstall(appPath: string, teamFlag: string): Promise<string> {
// TODO: breaking change, separate params vs single-param-object
const cmd = new SlackCLIProcess('app install', { team: teamFlag });
export const install = async function workspaceInstall(
appPath: string,
teamFlag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: breaking change, separate params vs single-param-object, probably should reflect global vs command CLI flags
const cmd = new SlackCLIProcess('app install', { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down
14 changes: 10 additions & 4 deletions packages/cli-test/src/cli/commands/collaborator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export const add = async function collaboratorsAdd(
appPath: string,
teamFlag: string,
collaboratorEmail: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
const cmd = new SlackCLIProcess(`collaborators add ${collaboratorEmail}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`collaborators add ${collaboratorEmail}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -31,9 +32,13 @@ export const add = async function collaboratorsAdd(
* @param teamFlag team domain to list collaborators for
* @returns command output
*/
export const list = async function collaboratorsList(appPath: string, teamFlag: string): Promise<string> {
export const list = async function collaboratorsList(
appPath: string,
teamFlag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
const cmd = new SlackCLIProcess('collaborators list', { team: teamFlag });
const cmd = new SlackCLIProcess('collaborators list', { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -55,9 +60,10 @@ export const remove = async function collaboratorsRemove(
appPath: string,
teamFlag: string,
collaboratorEmail: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
const cmd = new SlackCLIProcess(`collaborators remove ${collaboratorEmail}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`collaborators remove ${collaboratorEmail}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down
14 changes: 10 additions & 4 deletions packages/cli-test/src/cli/commands/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export const add = async function envAdd(
teamFlag: string,
secretKey: string,
secretValue: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
const cmd = new SlackCLIProcess(`env add ${secretKey} ${secretValue}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`env add ${secretKey} ${secretValue}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -33,9 +34,13 @@ export const add = async function envAdd(
* @param teamFlag team domain to list env vars for
* @returns command output
*/
export const list = async function envList(appPath: string, teamFlag: string): Promise<string> {
export const list = async function envList(
appPath: string,
teamFlag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
const cmd = new SlackCLIProcess('env list', { team: teamFlag });
const cmd = new SlackCLIProcess('env list', { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -57,9 +62,10 @@ export const remove = async function envRemove(
appPath: string,
teamFlag: string,
secretKey: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
const cmd = new SlackCLIProcess(`env remove ${secretKey}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`env remove ${secretKey}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/commands/external-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export const externalAuth = async function externalAuth(
teamFlag: string,
provider: string,
flags: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate parameters vs single-param-object
// TODO: this is a generic entry point to the `external-auth` suite of commands, and today `flags` is abused to
// specify the actual sub-command. easy, but lazy, not sure if best approach
const cmd = new SlackCLIProcess(`external-auth ${flags}`, { team: teamFlag }, {
const cmd = new SlackCLIProcess(`external-auth ${flags}`, { team: teamFlag, qa: options?.qa }, {
'--provider': provider,
});
try {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/commands/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export const access = async function functionAccess(
appPath: string,
teamFlag: string,
flags: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: breaking change, separate params vs single-param-object
const cmd = new SlackCLIProcess(`function access ${flags}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`function access ${flags}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-test/src/cli/commands/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import commandError from '../command-error';
*/
export const validate = async function manifestValidate(
appPath: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: breaking change, separate params vs single-param-object
const cmd = new SlackCLIProcess('manifest validate');
const cmd = new SlackCLIProcess('manifest validate', options);
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down
20 changes: 16 additions & 4 deletions packages/cli-test/src/cli/commands/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default {
teamFlag,
flag,
localApp = true,
qa = false,
}: {
/** Path to app */
appPath: string;
Expand All @@ -27,9 +28,11 @@ export default {
flag?: string;
/** Whether to operate on the local or deployed app */
localApp?: boolean; // TODO: this option is provided inconsistently across commands (breaking change)
/** Whether to operate against --slackdev or production */
qa?: boolean; // TODO: this option is provided inconsistently across commands (breaking change)
}): Promise<string> {
const appEnvironment = localApp ? 'local' : 'deployed';
const cmd = new SlackCLIProcess(`activity ${flag}`, { team: teamFlag }, {
const cmd = new SlackCLIProcess(`activity ${flag}`, { team: teamFlag, qa }, {
'--app': appEnvironment,
});
try {
Expand All @@ -52,6 +55,7 @@ export default {
teamFlag,
stringToWaitFor,
localApp = true,
qa = false,
}: {
/** Path to app */
appPath: string;
Expand All @@ -61,9 +65,11 @@ export default {
stringToWaitFor: string;
/** Whether to operate on the local or deployed app */
localApp?: boolean;
/** Whether to operate against --slackdev or production */
qa?: boolean; // TODO: this option is provided inconsistently across commands (breaking change)
}): Promise<ShellProcess> {
const appEnvironment = localApp ? 'local' : 'deployed';
const cmd = new SlackCLIProcess('activity --tail', { team: teamFlag }, {
const cmd = new SlackCLIProcess('activity --tail', { team: teamFlag, qa }, {
'--app': appEnvironment,
});
try {
Expand Down Expand Up @@ -112,6 +118,7 @@ export default {
teamFlag,
hideTriggers = true,
orgWorkspaceGrantFlag,
qa = false,
}: {
/** Path to app */
appPath: string;
Expand All @@ -124,8 +131,10 @@ export default {
* to request grant access to in AAA scenarios
*/
orgWorkspaceGrantFlag?: string;
/** Whether to operate against --slackdev or production */
qa?: boolean; // TODO: this option is provided inconsistently across commands (breaking change)
}): Promise<string> {
const cmd = new SlackCLIProcess('deploy', { team: teamFlag }, {
const cmd = new SlackCLIProcess('deploy', { team: teamFlag, qa }, {
'--hide-triggers': hideTriggers,
'--org-workspace-grant': orgWorkspaceGrantFlag,
});
Expand All @@ -150,6 +159,7 @@ export default {
cleanup = true,
hideTriggers = true,
orgWorkspaceGrantFlag,
qa = false,
}: {
/** Path to app */
appPath: string;
Expand All @@ -164,8 +174,10 @@ export default {
* to request grant access to in AAA scenarios
*/
orgWorkspaceGrantFlag?: string;
/** Whether to operate against --slackdev or production */
qa?: boolean; // TODO: this option is provided inconsistently across commands (breaking change)
}): Promise<ShellProcess> {
const cmd = new SlackCLIProcess('run', { team: teamFlag }, {
const cmd = new SlackCLIProcess('run', { team: teamFlag, qa }, {
'--cleanup': cleanup,
'--hide-triggers': hideTriggers,
'--org-workspace-grant': orgWorkspaceGrantFlag,
Expand Down
51 changes: 38 additions & 13 deletions packages/cli-test/src/cli/commands/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ import commandError from '../command-error';
* @param flags specification of trigger access, e.g. --trigger-id Ft0143UPTAV8 --everyone
* @returns command output
*/
export const access = async function triggerAccess(appPath: string, teamFlag: string, flags: string): Promise<string> {
export const access = async function triggerAccess(
appPath: string,
teamFlag: string,
flags: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate params vs. single-param-object
// TODO: access requires --trigger-id so add that to parameters (breaking change)
const cmd = new SlackCLIProcess(`trigger access ${flags}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`trigger access ${flags}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down Expand Up @@ -46,12 +51,12 @@ export const create = async function triggerCreate({
options?: { // TODO: must be a better way of exposing these options
/** Local app for local run sessions */
localApp?: boolean;
/** Install app by selecting "Install to a new team" */
installApp?: boolean; // TODO: this isn't even used?
/** Whether to run against --slackdev or production */
qa?: boolean;
};
}): Promise<string> {
const appEnvironment = options?.localApp ? 'local' : 'deployed';
const cmd = new SlackCLIProcess(`trigger create ${flag}`, { team: teamFlag }, {
const cmd = new SlackCLIProcess(`trigger create ${flag}`, { team: teamFlag, qa: options?.qa }, {
'--app': appEnvironment,
'--org-workspace-grant': orgWorkspaceGrantFlag,
});
Expand All @@ -72,10 +77,15 @@ export const create = async function triggerCreate({
* @param flag
* @returns command output
*/
export const del = async function triggerDelete(appPath: string, teamFlag: string, flag: string): Promise<string> {
export const del = async function triggerDelete(
appPath: string,
teamFlag: string,
flag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate params vs. single-param-object
// TODO: delete requires --trigger-id so add that to parameters (breaking change)
const cmd = new SlackCLIProcess(`trigger delete ${flag}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`trigger delete ${flag}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -93,10 +103,15 @@ export const del = async function triggerDelete(appPath: string, teamFlag: strin
* @param flag arbitrary additional flags
* @returns command output
*/
export const info = async function triggerInfo(appPath: string, teamFlag: string, flag: string): Promise<string> {
export const info = async function triggerInfo(
appPath: string,
teamFlag: string,
flag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: getting trigger info necessitates passing a trigger ID, so that should be exposed in the parameters here
// TODO: (breaking change) separate params vs. single-param-object
const cmd = new SlackCLIProcess(`trigger info ${flag}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`trigger info ${flag}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -114,9 +129,14 @@ export const info = async function triggerInfo(appPath: string, teamFlag: string
* @param flag arbitrary additional flags to pass
* @returns command output
*/
export const list = async function triggerList(appPath: string, teamFlag: string, flag: string): Promise<string> {
export const list = async function triggerList(
appPath: string,
teamFlag: string,
flag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate params vs. single-param-object
const cmd = new SlackCLIProcess(`trigger list ${flag}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`trigger list ${flag}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand All @@ -134,9 +154,14 @@ export const list = async function triggerList(appPath: string, teamFlag: string
* @param flag arbitrary additional flags to pass to command
* @returns command output
*/
export const update = async function triggerUpdate(appPath: string, teamFlag: string, flag: string): Promise<string> {
export const update = async function triggerUpdate(
appPath: string,
teamFlag: string,
flag: string,
options?: { qa?: boolean },
): Promise<string> {
// TODO: (breaking change) separate params vs. single-param-object
const cmd = new SlackCLIProcess(`trigger update ${flag}`, { team: teamFlag });
const cmd = new SlackCLIProcess(`trigger update ${flag}`, { team: teamFlag, qa: options?.qa });
try {
const proc = await cmd.execAsync({
cwd: appPath,
Expand Down

0 comments on commit 1938408

Please sign in to comment.