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.

51 lines
1.4 KiB

9 years ago
#!/usr/bin/env node
import minimist from 'minimist';
import { resolve } from 'path';
import { spawn } from 'cross-spawn-async';
9 years ago
import checkUpdate from '../lib/check-update';
const argv = minimist(process.argv.slice(2));
// options
const debug = argv.debug || argv.d;
// auto-update checking
const update = checkUpdate({ debug });
const exit = (code) => {
update.then(() => process.exit(code));
// don't wait for updates more than a second
// when the process really wants to exit
setTimeout(() => process.exit(code), 1000);
};
const defaultCommand = 'deploy';
Add zeit world (wip) (#67) * alias: clean up the alias (trailing and leading dots) * alias: improve domain validation and implement zeit.world * is-zeit-world: detect valid zeit.world nameservers * package: add domain-regex dep * now-alias: fix edge case with older aliases or removed deployments * alias: move listing aliases and retrying to `index` * index: generalize retrying and alias listing * alias: remove `retry` dep * now-remove: print out alias warning * typo * now-alias: prevent double lookup * now: add domain / domains command * now-deploy: document `domain` * agent: allow for tls-less, agent-less requests while testing * is-zeit-world: fix nameserver typo * dns: as-promised * now-alias: fix `rm` table * now-alias: no longer admit argument after `alias ls` @rase- please verify this, but I think it was overkill? * admit "aliases" as an alternative to alias * make domain name resolution, creation and verification reusable * index: add nameserver discover, domain setup functions (reused between alias and domains) * now-domains: add command * domains: commands * package: bump eslint * now-alias: simplify sort * now-domains: sort list * now-domains: improve deletion and output of empty elements * errors: improve output * domains: add more debug output * domains: extra logging * errors: improve logging * now-remove: improve `now rm` error handling * index: more reasonable retrying * alias: support empty dns configurations * dns: remove ns fn * alias: improve post-dns-editing verification * index: remove unneeded dns lookup * index: implement new `getNameservers` * index: customizable retries * alias: improve error * improve error handling and cert retrying * customizable retries * alias: better error handling * alias: display both error messages * better error handling * improve error handling for certificate verification errors * alias: set up a `*` CNAME to simplify further aliases * alias: fewer retries for certs, more spaced out (prevent rate limiting issues) * alias: ultimate error handling * add whois fallback * adjust timer labels for whois fallback * index: whois fallback also upon 500 errors * alias: fix error message * fix duplicate aliases declaration
9 years ago
const commands = new Set([defaultCommand, 'list', 'ls', 'rm', 'remove', 'alias', 'aliases', 'ln', 'domain', 'domains']);
const aliases = new Map([['ls', 'list'], ['rm', 'remove'], ['ln', 'alias'], ['aliases', 'alias'], ['domain', 'domains']]);
9 years ago
let cmd = argv._[0];
let args = [];
if ('help' === cmd) {
cmd = argv._[1];
if (!commands.has(cmd)) cmd = defaultCommand;
args.push('--help');
}
9 years ago
if (commands.has(cmd)) {
cmd = aliases.get(cmd) || cmd;
args = args.concat(process.argv.slice(3));
9 years ago
} else {
cmd = defaultCommand;
args = args.concat(process.argv.slice(2));
9 years ago
}
let bin = resolve(__dirname, 'now-' + cmd);
if (process.enclose) {
args.unshift("--entrypoint", bin);
bin = process.execPath;
}
9 years ago
const proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
proc.on('close', (code) => exit(code));
proc.on('error', () => exit(1));