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
9 changes: 5 additions & 4 deletions commands/app/secret/add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Argv, ArgumentsCamelCase } from 'yargs';
import { logger } from '@hubspot/local-dev-lib/logger';
import { addAppSecret } from '@hubspot/local-dev-lib/api/devSecrets';
import { logError } from '../../../lib/errorHandlers/index';
import { trackCommandUsage } from '../../../lib/usageTracking';
Expand All @@ -18,6 +17,7 @@ import {
YargsCommandModule,
} from '../../../types/Yargs';
import { makeYargsBuilder } from '../../../lib/yargsUtils';
import { uiLogger } from '../../../lib/ui/logger';

const command = 'add [name]';
const describe = commands.app.subcommands.secret.subcommands.add.describe;
Expand All @@ -37,6 +37,8 @@ async function handler(
const appSecretApp = await selectAppPrompt(derivedAccountId, args.app);

if (!appSecretApp) {
uiLogger.log('');
uiLogger.log(commands.app.subcommands.secret.subcommands.add.errors.noApps);
process.exit(EXIT_CODES.ERROR);
}

Expand All @@ -57,10 +59,9 @@ async function handler(
secretValue
);

logger.log('');
logger.success(
uiLogger.log('');
uiLogger.success(
commands.app.subcommands.secret.subcommands.add.success(
derivedAccountId,
appSecretApp.name,
appSecretName
)
Expand Down
11 changes: 5 additions & 6 deletions commands/app/secret/delete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Argv, ArgumentsCamelCase } from 'yargs';
import { logger } from '@hubspot/local-dev-lib/logger';
import {
deleteAppSecret,
fetchAppSecrets,
Expand All @@ -18,6 +17,7 @@ import {
YargsCommandModule,
} from '../../../types/Yargs';
import { makeYargsBuilder } from '../../../lib/yargsUtils';
import { uiLogger } from '../../../lib/ui/logger';

const command = 'delete [name]';
const describe = commands.app.subcommands.secret.subcommands.delete.describe;
Expand Down Expand Up @@ -59,7 +59,7 @@ async function handler(
}

if (appSecrets.length === 0) {
logger.error(
uiLogger.error(
commands.app.subcommands.secret.subcommands.delete.errors.noSecrets
);
process.exit(EXIT_CODES.ERROR);
Expand All @@ -84,7 +84,7 @@ async function handler(
));

if (!confirmDelete) {
logger.log(
uiLogger.log(
commands.app.subcommands.secret.subcommands.delete.deleteCanceled
);
process.exit(EXIT_CODES.SUCCESS);
Expand All @@ -97,10 +97,9 @@ async function handler(
appSecretToDelete!
);

logger.log('');
logger.success(
uiLogger.log('');
uiLogger.success(
commands.app.subcommands.secret.subcommands.delete.success(
derivedAccountId,
appSecretApp.name,
appSecretToDelete!
)
Expand Down
13 changes: 6 additions & 7 deletions commands/app/secret/list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Argv, ArgumentsCamelCase } from 'yargs';
import { logger } from '@hubspot/local-dev-lib/logger';
import { fetchAppSecrets } from '@hubspot/local-dev-lib/api/devSecrets';
import { logError } from '../../../lib/errorHandlers/index';
import { trackCommandUsage } from '../../../lib/usageTracking';
Expand All @@ -14,6 +13,7 @@ import {
} from '../../../types/Yargs';
import { makeYargsBuilder } from '../../../lib/yargsUtils';
import { selectAppPrompt } from '../../../lib/prompts/selectAppPrompt';
import { uiLogger } from '../../../lib/ui/logger';

const command = 'list';
const describe = commands.app.subcommands.secret.subcommands.list.describe;
Expand Down Expand Up @@ -52,21 +52,20 @@ async function handler(
}

if (appSecrets.length === 0) {
logger.log('');
logger.log(
uiLogger.log('');
uiLogger.log(
commands.app.subcommands.secret.subcommands.list.errors.noSecrets
);
} else {
logger.log('');
logger.log(
uiLogger.log('');
uiLogger.log(
commands.app.subcommands.secret.subcommands.list.success(
derivedAccountId,
appSecretApp.name
)
);

appSecrets.forEach(secret => {
logger.log(`- ${secret}`);
uiLogger.log(`- ${secret}`);
});
}

Expand Down
9 changes: 4 additions & 5 deletions commands/app/secret/update.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Argv, ArgumentsCamelCase } from 'yargs';
import { logger } from '@hubspot/local-dev-lib/logger';
import {
fetchAppSecrets,
updateAppSecret,
Expand All @@ -19,6 +18,7 @@ import {
YargsCommandModule,
} from '../../../types/Yargs';
import { makeYargsBuilder } from '../../../lib/yargsUtils';
import { uiLogger } from '../../../lib/ui/logger';

const command = 'update [name]';
const describe = commands.app.subcommands.secret.subcommands.update.describe;
Expand Down Expand Up @@ -60,7 +60,7 @@ async function handler(
}

if (appSecrets.length === 0) {
logger.error(
uiLogger.error(
commands.app.subcommands.secret.subcommands.update.errors.noSecrets
);
process.exit(EXIT_CODES.ERROR);
Expand All @@ -82,10 +82,9 @@ async function handler(
secretValue
);

logger.log('');
logger.success(
uiLogger.log('');
uiLogger.success(
commands.app.subcommands.secret.subcommands.update.success(
derivedAccountId,
appSecretApp.name,
appSecretToUpdate!
)
Expand Down
22 changes: 12 additions & 10 deletions lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ export const commands = {
`Project profile ${chalk.bold(profileName)} was successfully added`,
},
prompts: {
namePrompt: '[name] Enter a name for the new project profile: ',
namePrompt: 'Enter a name for the new project profile: ',
emptyName: 'Profile name cannot be empty',
targetAccountPrompt:
'[target-account] Select a target account for this profile',
Expand Down Expand Up @@ -1613,13 +1613,16 @@ export const commands = {
positionals: {
name: 'Name of the secret',
},
errors: {
noApps: `Please create a new app to add an app secret. Use ${uiCommandReference('hs project create')} to create a new project and begin the app creation process.`,
},
options: {
app: 'The app id to set the secret for',
},
example:
'Add a secret named "my-secret" to the app with ID 1234567890',
success: (accountId: number, appName: string, secretName: string) =>
`The secret "${secretName}" was added to "${appName}" in ${uiAccountDescription(accountId)}`,
success: (appName: string, secretName: string) =>
`App secret "${secretName}" was added to "${appName}"`,
},
delete: {
describe: 'Delete an app secret.',
Expand All @@ -1639,8 +1642,8 @@ export const commands = {
},
example:
'Delete a secret named "my-secret" from the app with ID 1234567890',
success: (accountId: number, appName: string, secretName: string) =>
`The secret "${secretName}" was removed from "${appName}" in ${uiAccountDescription(accountId)}`,
success: (appName: string, secretName: string) =>
`App secret "${secretName}" was removed from "${appName}"`,
},
list: {
describe: 'List all app secrets.',
Expand All @@ -1651,8 +1654,7 @@ export const commands = {
errors: {
noSecrets: 'No secrets found for the given app',
},
success: (accountId: number, appName: string) =>
`Showing secrets for "${appName}" in ${uiAccountDescription(accountId)}:`,
success: (appName: string) => `Showing secrets for "${appName}":`,
},
update: {
describe: 'Update an app secret.',
Expand All @@ -1668,8 +1670,8 @@ export const commands = {
},
example:
'Update a secret named "my-secret" for the app with ID 1234567890',
success: (accountId: number, appName: string, secretName: string) =>
`The secret "${secretName}" was updated in "${appName}" in ${uiAccountDescription(accountId)}`,
success: (appName: string, secretName: string) =>
`App secret "${secretName}" was updated in "${appName}"`,
},
},
},
Expand Down Expand Up @@ -3429,7 +3431,7 @@ export const lib = {
selectAppPrompt: {
selectAppId: '[--app] Select an app:',
errors: {
noApps: 'No apps found for the given account',
noApps: 'No apps were found for the given account.',
invalidAppId: 'Invalid app id',
},
},
Expand Down