You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.2 KiB

#!/usr/bin/env node
// Native
const {resolve} = require('path')
// Packages
const nodeVersion = require('node-version')
const updateNotifier = require('update-notifier')
const chalk = require('chalk')
const pkgUp = require('pkg-up')
// Ours
const {error} = require('../lib/error')
8 years ago
// Throw an error if node version is too low
if (nodeVersion.major < 6) {
error('Now requires at least version 6 of Node. Please upgrade!')
process.exit(1)
}
9 years ago
pkgUp().then(packagePath => {
const pkg = require(packagePath)
// Only check for updates in the npm version
if (!process.pkg && pkg.dist) {
const notifier = updateNotifier({pkg})
const update = notifier.update
if (update) {
let message = `Update available! ${chalk.red(update.current)}${chalk.green(update.latest)} \n`
message += `Run ${chalk.magenta('npm i -g now')} to update!\n`
message += `${chalk.magenta('Changelog:')} https://github.com/zeit/now-cli/releases/tag/${update.latest}`
notifier.notify({message})
}
}
})
8 years ago
// This command will be run if no other sub command is specified
const defaultCommand = 'deploy'
const commands = new Set([
defaultCommand,
'help',
'list',
'ls',
'rm',
'remove',
'alias',
'aliases',
'ln',
'domain',
'domains',
'dns',
'cert',
'certs',
'secret',
Add `now billing` and `now upgrade` (#309) * Add the skeleton of `now cc` * Add the `ls` command * Add `inquirer` dependency * Add the `set-default` command * Fix typo * Show the real number of cards when selecting the default one * Add the `ls` command * Fix: Do not throw if there&#39;s no cards in the account * Add `blessed` dependency * Add the first sketch of `now cc add` * Add instructions * Add labels * Save every element in the `elements` array instead of variables * Tweaks * Fix: update the element attribute if it&#39;s not a special case * Add the `name` input; Add moving between inputs; Make the state more reliable * Auto &#34;detect&#34; if the input is losing focus * Remove useless stuff * Add the ability to move between the fields with tab/shift+tab * Add CCV field * Make the cycling between the fields &#34;infinite&#34; * Add expiration date field and allow only numbers in the CCV field * The form shouldn&#39;t have a fixed height * Add the address box and label * Add the address fields * Remove blessed stuff * Add preliminary input field * output utils * add prompt for booleans * fix @matheuss linting problems * remove example * lint * error and info helpers * helper for embedded commands * Remove useless stuff * Add `trailing` option * Add `resolveChars` option * Add `validate` option * Add `strip-ansi` dependency * Add `credit-card` dependency * Add credit card masking * Add support for expiration date mask * Make things simpler * Add auto completion support * Always show the `card_` id prefix * Add `@google/maps` dependency * Always print the initial value if it&#39;s available * Add `stripe` dependency * Add `add()` method * Add billing related utils * Add `now cc add` * Rename `cc` to `billing` * Fix: log only one blank line * Refactor * Add list input component * This shouldn&#39;t be here * Add `code` output util * Add `now upgrade | downgrade` * add build step * make it more future-proof * more reliable build * remove lock for now * Hide the CCV * Print the new line before `Saving card` * Use the new `success` component * Add confirmation steps for `cc rm` and `cc set-default` * Temporarily monket patch Inquirer * Build before testing * Run the tests using the built files * Fix the `prepublish` script and run the `build` one before packaging * Improve `now help`
8 years ago
'secrets',
'cc',
'billing',
'upgrade',
'downgrade'
])
const aliases = new Map([
['ls', 'list'],
['rm', 'remove'],
['ln', 'alias'],
['aliases', 'alias'],
['domain', 'domains'],
['cert', 'certs'],
Add `now billing` and `now upgrade` (#309) * Add the skeleton of `now cc` * Add the `ls` command * Add `inquirer` dependency * Add the `set-default` command * Fix typo * Show the real number of cards when selecting the default one * Add the `ls` command * Fix: Do not throw if there&#39;s no cards in the account * Add `blessed` dependency * Add the first sketch of `now cc add` * Add instructions * Add labels * Save every element in the `elements` array instead of variables * Tweaks * Fix: update the element attribute if it&#39;s not a special case * Add the `name` input; Add moving between inputs; Make the state more reliable * Auto &#34;detect&#34; if the input is losing focus * Remove useless stuff * Add the ability to move between the fields with tab/shift+tab * Add CCV field * Make the cycling between the fields &#34;infinite&#34; * Add expiration date field and allow only numbers in the CCV field * The form shouldn&#39;t have a fixed height * Add the address box and label * Add the address fields * Remove blessed stuff * Add preliminary input field * output utils * add prompt for booleans * fix @matheuss linting problems * remove example * lint * error and info helpers * helper for embedded commands * Remove useless stuff * Add `trailing` option * Add `resolveChars` option * Add `validate` option * Add `strip-ansi` dependency * Add `credit-card` dependency * Add credit card masking * Add support for expiration date mask * Make things simpler * Add auto completion support * Always show the `card_` id prefix * Add `@google/maps` dependency * Always print the initial value if it&#39;s available * Add `stripe` dependency * Add `add()` method * Add billing related utils * Add `now cc add` * Rename `cc` to `billing` * Fix: log only one blank line * Refactor * Add list input component * This shouldn&#39;t be here * Add `code` output util * Add `now upgrade | downgrade` * add build step * make it more future-proof * more reliable build * remove lock for now * Hide the CCV * Print the new line before `Saving card` * Use the new `success` component * Add confirmation steps for `cc rm` and `cc set-default` * Temporarily monket patch Inquirer * Build before testing * Run the tests using the built files * Fix the `prepublish` script and run the `build` one before packaging * Improve `now help`
8 years ago
['secret', 'secrets'],
['cc', 'billing'],
['downgrade', 'upgrade']
])
let cmd = defaultCommand
const args = process.argv.slice(2)
const index = args.findIndex(a => commands.has(a))
9 years ago
if (index > -1) {
cmd = args[index]
args.splice(index, 1)
if (cmd === 'help') {
if (index < args.length && commands.has(args[index])) {
cmd = args[index]
args.splice(index, 1)
} else {
cmd = defaultCommand
}
args.unshift('--help')
}
9 years ago
cmd = aliases.get(cmd) || cmd
9 years ago
}
const bin = resolve(__dirname, 'now-' + cmd + '.js')
// Prepare process.argv for subcommand
process.argv = process.argv.slice(0, 2).concat(args)
8 years ago
// Load sub command
// With custom parameter to make "pkg" happy
require(bin, 'may-exclude')