Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --scope flag and scope config property #1939

Merged
merged 22 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion errors/env-no-secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ now -e VARIABLE_NAME=@secret-name

In addition, ensure that the secret (`@secret-name` in the example above) exists in the current scope (the team or user account that you're using).

You can run `now switch` or `--team` to switch to a different team or user.
You can run `now switch` or `--scope` to switch to a different team or user.
11 changes: 11 additions & 0 deletions errors/missing-scope-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Missing Scope Value

#### Why This Error Occurred

The `--scope` flag was specified, but there's no value for it available.

#### Possible Ways to Fix It

In order to make it work, you need to specify a value for the `--scope` flag. This needs to be the slug or ID of the team as which you'd like to act or the username or ID of a user you'd like to act as.

As an example, if your team URL is `https://zeit.co/teams/zeit`, you would set `--scope` to `zeit`.
11 changes: 0 additions & 11 deletions errors/missing-team-value.md

This file was deleted.

2 changes: 1 addition & 1 deletion errors/no-token-allowed.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ In turn, they would have to take the value of the `--token` flag into considerat

#### Possible Ways to Fix It

Specify a value for the `--team` flag. This needs to be the slug of the team as which you'd like to act. As an example, if your team URL is `https://zeit.co/teams/zeit`, the slug is `zeit`.
Specify a value for the `--scope` flag. This needs to be the slug or ID of the team as which you'd like to act (as an example, if your team URL is `https://zeit.co/teams/zeit`, the value can be `zeit`) or the username or ID of a user you'd like to act as.
10 changes: 10 additions & 0 deletions errors/scope-not-accessible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Scope Not Accessible

#### Why This Error Occurred

You specified the `--scope` flag and specified the ID or slug of a team that you're not a part of or a user whose account you don't own. This problem could also occur if your user credentials aren't valid anymore.

#### Possible Ways to Fix It

- Make sure commands like `now ls` work just fine. This will ensure that your user credentials are valid. If it's not working correctly, please log in again using `now login`.
- Ensure that the scope you specified using `--scope` shows up in the output of `now switch`. If it doesn't, you're either not part of the team (if you specified a team) or you logged into the wrong user account.
11 changes: 11 additions & 0 deletions errors/scope-not-existent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Scope Not Existent

#### Why This Error Occurred

You specified the `--scope` flag and specified the ID or slug of a team that does not exist or that you're not a part of. Similiarily you might have specified the ID or username of user whose account you don't own.

#### Possible Ways to Fix It

If you're sure the specified team exists, please make sure that you're a part of it (ask an owner of the team to invite you). If you specified the identifier of a user, make sure you are actually the owner of this account.

Otherwise, either create a team with the specified slug or ensure that the identifier is correct if you're sure that the scope exists.
10 changes: 0 additions & 10 deletions errors/team-not-accessible.md

This file was deleted.

11 changes: 0 additions & 11 deletions errors/team-not-existent.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/commands/alias/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope
-n, --no-verify Don't wait until instance count meets the previous alias constraints

${chalk.dim('Examples:')}
Expand Down
23 changes: 7 additions & 16 deletions src/commands/alias/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ export default async function set(
) {
const {
authConfig: { token },
config
config,
localConfig
} = ctx;

const { currentTeam } = config;
const { apiUrl } = ctx;
const setStamp = stamp();
Expand Down Expand Up @@ -108,16 +110,8 @@ export default async function set(
const targets = await getTargetsForAlias(
output,
args,
opts['--local-config']
localConfig
);
if (targets instanceof ERRORS.CantFindConfig) {
output.error(
`Couldn't find a project configuration file at \n ${targets.meta.paths.join(
' or\n '
)}`
);
return 1;
}

if (targets instanceof ERRORS.NoAliasInConfig) {
output.error(`Couldn't find an alias in config`);
Expand All @@ -131,11 +125,6 @@ export default async function set(
return 1;
}

if (targets instanceof ERRORS.CantParseJSONFile) {
output.error(`Couldn't parse JSON file ${targets.meta.file}.`);
return 1;
}

if (rules) {
// If we have rules for path alias we assign them to the domain
for (const target of targets) {
Expand Down Expand Up @@ -171,8 +160,10 @@ export default async function set(
args,
opts['--local-config'],
user,
contextName
contextName,
localConfig
);

if (deployment instanceof ERRORS.DeploymentNotFound) {
output.error(
`Failed to find deployment "${deployment.meta.id}" under ${chalk.bold(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/billing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/certs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope
--challenge-only Only show challenges needed to issue a cert
--crt ${chalk.bold.underline('FILE')} Certificate file
--key ${chalk.bold.underline(
Expand Down
54 changes: 46 additions & 8 deletions src/commands/deploy/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import note from '../../util/output/note';

export const latestHelp = () => `
${chalk.bold(`${logo} now`)} [options] <command | path>

${chalk.dim('Commands:')}

${chalk.dim('Cloud')}

deploy [path] Performs a deployment ${chalk.bold(
'(default)'
)}
Expand All @@ -22,15 +25,19 @@ export const latestHelp = () => `
scale [args] Scales the instance count of a deployment
init [example] Initialize an example project
help [cmd] Displays complete help for [cmd]

${chalk.dim('Administrative')}

billing | cc [cmd] Manages your credit cards and billing methods
upgrade | downgrade [plan] Upgrades or downgrades your plan
teams [team] Manages your teams
teams Manages your teams
switch [scope] Switches between teams and your personal account
login [email] Logs into your account or creates a new one
logout Logs out of your account
whoami Displays the current scope
whoami Shows the username of the currently logged in user

${chalk.dim('Options:')}

-h, --help Output usage information
-v, --version Output the version number
-V, --platform-version Set the platform version to deploy to
Expand Down Expand Up @@ -59,25 +66,35 @@ export const latestHelp = () => `
'`-m KEY=value`'
)}). Can appear many times.
-C, --no-clipboard Do not attempt to copy URL to clipboard
-T, --team Set a custom team scope
-S, --scope Set a custom scope
--regions Set default regions to enable the deployment on
--target Deploy to either 'staging' or 'production' aliases
${note(
`To view the usage information for Now 1.0, run ${code(
'now help deploy-v1'
)}`
)}

${chalk.dim('Examples:')}

${chalk.gray('–')} Deploy the current directory

${chalk.cyan('$ now')}

${chalk.gray('–')} Deploy a custom path

${chalk.cyan('$ now /usr/src/project')}

${chalk.gray('–')} Deploy with environment variables

${chalk.cyan('$ now -e NODE_ENV=production -e SECRET=@mysql-secret')}

${chalk.gray('–')} Show the usage information for the sub command ${chalk.dim(
'`list`'
)}

${chalk.cyan('$ now help list')}

`;

export const latestArgs = {
Expand Down Expand Up @@ -173,8 +190,11 @@ export const legacyArgs = argList;

export const legacyHelp = () => `
${chalk.bold(`${logo} now`)} [options] <command | path>

${chalk.dim('Commands:')}

${chalk.dim('Cloud')}

deploy [path] Performs a deployment ${chalk.bold(
'(default)'
)}
Expand All @@ -190,15 +210,19 @@ export const legacyHelp = () => `
scale [args] Scales the instance count of a deployment
init [example] Initialize an example project
help [cmd] Displays complete help for [cmd]

${chalk.dim('Administrative')}

billing | cc [cmd] Manages your credit cards and billing methods
upgrade | downgrade [plan] Upgrades or downgrades your plan
teams [team] Manages your teams
switch Switches between teams and your account
login Logs into your account or creates a new one
teams Manages your teams
switch [scope] Switches between teams and your account
login [email] Logs into your account or creates a new one
logout Logs out of your account
whoami Displays the currently logged in username
whoami Shows the username of the currently logged in user

${chalk.dim('Options:')}

-h, --help Output usage information
-v, --version Output the version number
-V, --platform-version Set the platform version to deploy to
Expand Down Expand Up @@ -233,25 +257,39 @@ export const legacyHelp = () => `
-C, --no-clipboard Do not attempt to copy URL to clipboard
-N, --forward-npm Forward login information to install private npm modules
--session-affinity Session affinity, \`ip\` or \`random\` (default) to control session affinity
-T, --team Set a custom team scope
-S, --scope Set a custom scope
--regions Set default regions or DCs to enable the deployment on
--no-scale Skip scaling rules deploying with the default presets
--no-verify Skip step of waiting until instance count meets given constraints

${chalk.dim(`Enforceable Types (by default, it's detected automatically):`)}

--npm Node.js application
--docker Docker container
--static Static file hosting

${chalk.dim('Examples:')}

${chalk.gray('–')} Deploy the current directory

${chalk.cyan('$ now')}

${chalk.gray('–')} Deploy a custom path

${chalk.cyan('$ now /usr/src/project')}

${chalk.gray('–')} Deploy a GitHub repository

${chalk.cyan('$ now user/repo#ref')}

${chalk.gray('–')} Deploy with environment variables

${chalk.cyan('$ now -e NODE_ENV=production -e SECRET=@mysql-secret')}

${chalk.gray('–')} Show the usage information for the sub command ${chalk.dim(
'`list`'
)}

${chalk.cyan('$ now help list')}

`;
2 changes: 1 addition & 1 deletion src/commands/dns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/domains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const help = () => {
'TOKEN'
)} Login token
-d, --debug Debug mode [off]
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope
-a, --all See all instances for each deployment (requires [app])
-m, --meta Filter deployments by metadata (e.g.: ${chalk.dim(
'`-m KEY=value`'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const help = () => {
--until=${chalk.bold.underline(
'UNTIL'
)} Only return logs before date (ISO 8601), ignored for ${'`-f`'}
-T, --team Set a custom team scope
-S, --scope Set a custom scope
-o ${chalk.bold.underline('MODE')}, --output=${chalk.bold.underline(
'MODE'
)} Specify the output format (${Object.keys(logPrinters).join(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const help = () => {
)} Login token
-y, --yes Skip confirmation
-s, --safe Skip deployments with an active alias
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const help = () => {
'TOKEN'
)} Login token
-d, --debug Debug mode [off]
-T, --team Set a custom team scope
-S, --scope Set a custom scope
-n, --no-verify Skip step of waiting until instance count meets given constraints
-t, --verify-timeout How long to wait for verification to complete [5m]

Expand Down
2 changes: 1 addition & 1 deletion src/commands/secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const help = () => {
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-T, --team Set a custom team scope
-S, --scope Set a custom scope

${chalk.dim('Examples:')}

Expand Down