Matheus Fernandes
8 years ago
No known key found for this signature in database
GPG Key ID: DD07CA4EA7B65C4F
18 changed files with
48 additions and
42 deletions
-
bin/now-alias.js
-
bin/now-billing.js
-
bin/now-certs.js
-
bin/now-deploy.js
-
bin/now-dns.js
-
bin/now-domains.js
-
bin/now-list.js
-
bin/now-logs.js
-
bin/now-open.js
-
bin/now-remove.js
-
bin/now-scale.js
-
bin/now-secrets.js
-
bin/now-teams.js
-
bin/now-upgrade.js
-
bin/teams/add.js
-
bin/teams/invite.js
-
bin/teams/switch.js
-
lib/cfg.js
|
|
@ -104,11 +104,11 @@ if (argv.help) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -90,11 +90,11 @@ if (argv.help || !subcommand) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -83,11 +83,11 @@ if (argv.help || !subcommand) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -200,7 +200,7 @@ if (deploymentName || wantsPublic) { |
|
|
|
let alwaysForwardNpm |
|
|
|
|
|
|
|
Promise.resolve().then(async () => { |
|
|
|
let config = await cfg.read() |
|
|
|
let config = await cfg.read({token: argv.token}) |
|
|
|
alwaysForwardNpm = config.forwardNpm |
|
|
|
|
|
|
|
if (argv.h || argv.help) { |
|
|
@ -209,7 +209,7 @@ Promise.resolve().then(async () => { |
|
|
|
} else if (argv.v || argv.version) { |
|
|
|
console.log(version) |
|
|
|
process.exit(0) |
|
|
|
} else if (!(argv.token || config.token) || shouldLogin) { |
|
|
|
} else if (!config.token || shouldLogin) { |
|
|
|
let token |
|
|
|
try { |
|
|
|
token = await login(apiUrl) |
|
|
|
|
|
@ -77,11 +77,11 @@ if (argv.help || !subcommand) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -119,11 +119,11 @@ if (argv.help || !subcommand) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -68,11 +68,11 @@ if (argv.config) { |
|
|
|
} |
|
|
|
|
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
process.exit(1) |
|
|
|
|
|
@ -98,11 +98,11 @@ if (maybeURL(deploymentIdOrURL)) { |
|
|
|
|
|
|
|
Promise.resolve() |
|
|
|
.then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || login(apiUrl) |
|
|
|
token = config.token || login(apiUrl) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
process.exit(1) |
|
|
|
|
|
@ -62,11 +62,11 @@ if (argv.config) { |
|
|
|
} |
|
|
|
|
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
process.exit(1) |
|
|
|
|
|
@ -77,11 +77,11 @@ if (argv.config) { |
|
|
|
} |
|
|
|
|
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = (await argv.token) || config.token || login(apiUrl) |
|
|
|
token = config.token || login(apiUrl) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
process.exit(1) |
|
|
|
|
|
@ -81,11 +81,11 @@ if (argv.help) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -87,11 +87,11 @@ if (argv.help || !subcommand) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -85,11 +85,11 @@ if (argv.help || !subcommand) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
@ -115,17 +115,17 @@ async function run({ token, config: { currentTeam } }) { |
|
|
|
switch (subcommand) { |
|
|
|
case 'switch': |
|
|
|
case 'change': { |
|
|
|
await require(resolve(__dirname, 'teams', 'switch.js'))(teams, args) |
|
|
|
await require(resolve(__dirname, 'teams', 'switch.js'))({teams, args, token}) |
|
|
|
break |
|
|
|
} |
|
|
|
case 'add': |
|
|
|
case 'create': { |
|
|
|
await require(resolve(__dirname, 'teams', 'add.js'))(teams) |
|
|
|
await require(resolve(__dirname, 'teams', 'add.js'))({teams, token}) |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
case 'invite': { |
|
|
|
await require(resolve(__dirname, 'teams', 'invite.js'))(teams, args) |
|
|
|
await require(resolve(__dirname, 'teams', 'invite.js'))({teams, args, token}) |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -80,11 +80,11 @@ if (argv.help) { |
|
|
|
exit(0) |
|
|
|
} else { |
|
|
|
Promise.resolve().then(async () => { |
|
|
|
const config = await cfg.read() |
|
|
|
const config = await cfg.read({token: argv.token}) |
|
|
|
|
|
|
|
let token |
|
|
|
try { |
|
|
|
token = argv.token || config.token || (await login(apiUrl)) |
|
|
|
token = config.token || (await login(apiUrl)) |
|
|
|
} catch (err) { |
|
|
|
error(`Authentication error – ${err.message}`) |
|
|
|
exit(1) |
|
|
|
|
|
@ -34,7 +34,7 @@ function gracefulExit() { |
|
|
|
const teamUrlPrefix = rightPad('Team URL', 14) + chalk.gray('zeit.co/') |
|
|
|
const teamNamePrefix = rightPad('Team Name', 14) |
|
|
|
|
|
|
|
module.exports = async function(teams) { |
|
|
|
module.exports = async function({teams, token}) { |
|
|
|
let slug |
|
|
|
let team |
|
|
|
let elapsed |
|
|
@ -118,7 +118,10 @@ module.exports = async function(teams) { |
|
|
|
await cfg.merge({ currentTeam: team }) |
|
|
|
stopSpinner() |
|
|
|
|
|
|
|
await require('./invite')(teams, [], { |
|
|
|
await require('./invite')({ |
|
|
|
teams, |
|
|
|
args: [], |
|
|
|
token, |
|
|
|
introMsg: 'Invite your team mates! When done, press enter on an empty field', |
|
|
|
noopMsg: `You can invite team mates later by running ${cmd('now teams invite')}` |
|
|
|
}) |
|
|
|
|
|
@ -60,12 +60,13 @@ function emailAutoComplete(value, teamSlug) { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = async function( |
|
|
|
module.exports = async function({ |
|
|
|
teams, |
|
|
|
args, |
|
|
|
{ introMsg, noopMsg = 'No changes made' } = {} |
|
|
|
) { |
|
|
|
const { user, currentTeam } = await cfg.read() |
|
|
|
token, |
|
|
|
introMsg, noopMsg = 'No changes made' |
|
|
|
} = {}) { |
|
|
|
const { user, currentTeam } = await cfg.read({token}) |
|
|
|
|
|
|
|
domains.push(user.email.split('@')[1]) |
|
|
|
|
|
|
|
|
|
@ -15,10 +15,10 @@ async function updateCurrentTeam({ cfg, newTeam } = {}) { |
|
|
|
await cfg.merge({ currentTeam: newTeam }) |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = async function(teams, args) { |
|
|
|
module.exports = async function({teams, args, token}) { |
|
|
|
let stopSpinner = wait('Fetching teams') |
|
|
|
const list = (await teams.ls()).teams |
|
|
|
let { user, currentTeam } = await cfg.read() |
|
|
|
let { user, currentTeam } = await cfg.read({token}) |
|
|
|
const accountIsCurrent = !currentTeam |
|
|
|
stopSpinner() |
|
|
|
|
|
|
|
|
|
@ -39,13 +39,15 @@ function save(data) { |
|
|
|
* @return {Object} |
|
|
|
*/ |
|
|
|
async function read({ force = false, token, apiUrl } = {}) { |
|
|
|
let existing = null |
|
|
|
let existing = {} |
|
|
|
try { |
|
|
|
existing = fs.readFileSync(file, 'utf8') |
|
|
|
existing = JSON.parse(existing) |
|
|
|
} catch (err) {} |
|
|
|
|
|
|
|
if (!existing && force && token) { |
|
|
|
// Will happen if `force`d or if `--token` is used and it's different from
|
|
|
|
// The one that's stored (which can be `undefined`)
|
|
|
|
if ((force && token) || (token && token !== existing.token) ) { |
|
|
|
const user = await getUser({ token, apiUrl }) |
|
|
|
if (user) { |
|
|
|
return { |
|
|
@ -60,7 +62,7 @@ async function read({ force = false, token, apiUrl } = {}) { |
|
|
|
return {} |
|
|
|
} |
|
|
|
|
|
|
|
if (!existing) { |
|
|
|
if (!existing.token) { |
|
|
|
return {} |
|
|
|
} |
|
|
|
|
|
|
|