netlify-cli 24.3.0 → 24.4.0

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/switch/index.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW,gBAOlD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/switch/index.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW,gBAQlD,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export const createSwitchCommand = (program) => program
2
2
  .command('switch')
3
3
  .description('Switch your active Netlify account')
4
+ .option('--email <email>', 'Switch to the account matching this email address')
4
5
  .action(async (options, command) => {
5
6
  const { switchCommand } = await import('./switch.js');
6
7
  await switchCommand(options, command);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/switch/index.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAoB,EAAE,EAAE,CAC1D,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,OAAoB,EAAE,EAAE;IAC5D,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IACrD,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/switch/index.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAoB,EAAE,EAAE,CAC1D,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,iBAAiB,EAAE,mDAAmD,CAAC;KAC9E,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,OAAoB,EAAE,EAAE;IAC5D,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IACrD,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
1
  import { OptionValues } from 'commander';
2
2
  import BaseCommand from '../base-command.js';
3
- export declare const switchCommand: (_options: OptionValues, command: BaseCommand) => Promise<void>;
3
+ export declare const switchCommand: (options: OptionValues, command: BaseCommand) => Promise<void>;
4
4
  //# sourceMappingURL=switch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/commands/switch/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAK5C,eAAO,MAAM,aAAa,GAAU,UAAU,YAAY,EAAE,SAAS,WAAW,kBA+B/E,CAAA"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/commands/switch/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAIxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAK5C,eAAO,MAAM,aAAa,GAAU,SAAS,YAAY,EAAE,SAAS,WAAW,kBA4C9E,CAAA"}
@@ -2,16 +2,25 @@ import inquirer from 'inquirer';
2
2
  import { chalk, log } from '../../utils/command-helpers.js';
3
3
  import { login } from '../login/login.js';
4
4
  const LOGIN_NEW = 'I would like to login to a new account';
5
- export const switchCommand = async (_options, command) => {
6
- const availableUsersChoices = Object.values(command.netlify.globalConfig.get('users') || {}).reduce((prev, current) =>
7
- // @ts-expect-error TS(2769) FIXME: No overload matches this call.
8
- Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }), {});
5
+ export const switchCommand = async (options, command) => {
6
+ const users = (command.netlify.globalConfig.get('users') || {});
7
+ const availableUsersChoices = Object.values(users).reduce((prev, current) => Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }), {});
8
+ if (options.email) {
9
+ const matchedUser = Object.values(users).find((user) => user.email === options.email);
10
+ if (matchedUser) {
11
+ command.netlify.globalConfig.set('userId', matchedUser.id);
12
+ log('');
13
+ log(`You're now using ${chalk.bold(availableUsersChoices[matchedUser.id])}.`);
14
+ return;
15
+ }
16
+ log(`No account found matching ${chalk.bold(options.email)}, showing all available accounts.`);
17
+ log('');
18
+ }
9
19
  const { accountSwitchChoice } = await inquirer.prompt([
10
20
  {
11
21
  type: 'list',
12
22
  name: 'accountSwitchChoice',
13
23
  message: 'Please select the account you want to use:',
14
- // @ts-expect-error TS(2769) FIXME: No overload matches this call.
15
24
  choices: [...Object.entries(availableUsersChoices).map(([, val]) => val), LOGIN_NEW],
16
25
  },
17
26
  ]);
@@ -19,7 +28,6 @@ export const switchCommand = async (_options, command) => {
19
28
  await login({ new: true }, command);
20
29
  }
21
30
  else {
22
- // @ts-expect-error TS(2769) FIXME: No overload matches this call.
23
31
  const selectedAccount = Object.entries(availableUsersChoices).find(([, availableUsersChoice]) => availableUsersChoice === accountSwitchChoice);
24
32
  // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
25
33
  command.netlify.globalConfig.set('userId', selectedAccount[0]);
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/commands/switch/switch.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AAE3D,OAAO,EAAE,KAAK,EAA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