|
@ -28,7 +28,7 @@ const NOW_AUTH_CONFIG_PATH = configFiles.getAuthConfigFilePath() |
|
|
|
|
|
|
|
|
const GLOBAL_COMMANDS = new Set(['help']) |
|
|
const GLOBAL_COMMANDS = new Set(['help']) |
|
|
|
|
|
|
|
|
const main = async (argv_): Promise<number> => { |
|
|
const main = async (argv_) => { |
|
|
await checkForUpdates() |
|
|
await checkForUpdates() |
|
|
|
|
|
|
|
|
const argv = mri(argv_, { |
|
|
const argv = mri(argv_, { |
|
@ -64,7 +64,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!nowDirExists) { |
|
|
if (!nowDirExists) { |
|
@ -91,7 +91,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let config |
|
|
let config |
|
@ -107,7 +107,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
@ -119,7 +119,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
config = getDefaultCfg() |
|
|
config = getDefaultCfg() |
|
@ -133,7 +133,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -149,7 +149,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let authConfig = null |
|
|
let authConfig = null |
|
@ -165,7 +165,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
@ -178,7 +178,7 @@ const main = async (argv_): Promise<number> => { |
|
|
'No `credentials` list found inside' |
|
|
'No `credentials` list found inside' |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (const [i, { provider }] of authConfig.credentials.entries()) { |
|
|
for (const [i, { provider }] of authConfig.credentials.entries()) { |
|
@ -189,7 +189,7 @@ const main = async (argv_): Promise<number> => { |
|
|
`Missing \`provider\` key in entry with index ${i}` |
|
|
`Missing \`provider\` key in entry with index ${i}` |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!(provider in providers)) { |
|
|
if (!(provider in providers)) { |
|
@ -199,7 +199,7 @@ const main = async (argv_): Promise<number> => { |
|
|
`Unknown provider "${provider}"` |
|
|
`Unknown provider "${provider}"` |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
@ -210,7 +210,7 @@ const main = async (argv_): Promise<number> => { |
|
|
)}": ` + err.message
|
|
|
)}": ` + err.message
|
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
authConfig = getDefaultAuthCfg() |
|
|
authConfig = getDefaultAuthCfg() |
|
@ -225,7 +225,7 @@ const main = async (argv_): Promise<number> => { |
|
|
err.message |
|
|
err.message |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -250,7 +250,7 @@ const main = async (argv_): Promise<number> => { |
|
|
`An unexpected error occurred in config ${subcommand}: ${err.stack}` |
|
|
`An unexpected error occurred in config ${subcommand}: ${err.stack}` |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -269,7 +269,7 @@ const main = async (argv_): Promise<number> => { |
|
|
'Both a directory and a provider are known' |
|
|
'Both a directory and a provider are known' |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
suppliedProvider = targetOrSubcommand |
|
|
suppliedProvider = targetOrSubcommand |
|
@ -299,12 +299,13 @@ const main = async (argv_): Promise<number> => { |
|
|
`"${NOW_CONFIG_PATH}" is not a valid provider` |
|
|
`"${NOW_CONFIG_PATH}" is not a valid provider` |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const provider: Object = providers[suppliedProvider || defaultProvider] |
|
|
const providerName = suppliedProvider || defaultProvider |
|
|
|
|
|
const provider: Object = providers[providerName] |
|
|
|
|
|
|
|
|
let subcommand |
|
|
let subcommand |
|
|
|
|
|
|
|
@ -324,7 +325,7 @@ const main = async (argv_): Promise<number> => { |
|
|
'Both a directory and a subcommand are known' |
|
|
'Both a directory and a subcommand are known' |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (subcommandExists) { |
|
|
if (subcommandExists) { |
|
@ -353,14 +354,17 @@ const main = async (argv_): Promise<number> => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
return provider[subcommand](ctx) |
|
|
await provider[subcommand](ctx) |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
console.error( |
|
|
console.error( |
|
|
error( |
|
|
error( |
|
|
`An unexpected error occurred in provider ${subcommand}: ${err.stack}` |
|
|
`An unexpected error occurred in provider ${subcommand}: ${err.stack}` |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
return 1 |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (providerName === 'gcp') { |
|
|
|
|
|
process.exit() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|