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

[now-cli][now-client] (Major) Remove legacy code #3840

Merged
merged 20 commits into from Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 12 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: 2 additions & 0 deletions examples/nextjs/.gitignore
Expand Up @@ -20,3 +20,5 @@ yarn-error.log*
# Environment Variables
.env
.env.build

.now
5 changes: 0 additions & 5 deletions packages/now-cli/package.json
Expand Up @@ -14,7 +14,6 @@
"preinstall": "node ./scripts/preinstall.js",
"test-unit": "nyc ava test/unit.js test/dev-builder.unit.js test/dev-router.unit.js test/dev-server.unit.js --serial --fail-fast --verbose",
"test-integration": "ava test/integration.js --serial --fail-fast",
"test-integration-v1": "ava test/integration-v1.js --serial --fail-fast",
"test-integration-now-dev": "ava test/dev/integration.js --serial --fail-fast --verbose",
"prepublishOnly": "yarn build",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
Expand Down Expand Up @@ -92,12 +91,10 @@
"@types/universal-analytics": "0.4.2",
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@zeit/dockerignore": "0.0.5",
"@zeit/fun": "0.11.2",
"@zeit/ncc": "0.18.5",
"@zeit/source-map-support": "0.6.2",
"ajv": "6.10.2",
"alpha-sort": "2.0.1",
"ansi-escapes": "3.0.0",
"ansi-regex": "3.0.0",
"arg": "2.0.0",
Expand Down Expand Up @@ -130,8 +127,6 @@
"get-port": "5.1.1",
"glob": "7.1.2",
"http-proxy": "1.17.0",
"ignore": "4.0.6",
AndyBitz marked this conversation as resolved.
Show resolved Hide resolved
"ini": "1.3.4",
"inquirer": "7.0.4",
"is-port-reachable": "3.0.0",
"is-url": "1.2.2",
Expand Down
29 changes: 2 additions & 27 deletions packages/now-cli/src/commands/alias/index.js
@@ -1,4 +1,3 @@
//
import chalk from 'chalk';

import { handleError } from '../../util/error';
Expand Down Expand Up @@ -31,15 +30,11 @@ const help = () => {
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
'DIR'
)} Path to the global ${'`.now`'} directory
-r ${chalk.bold.underline('RULES_FILE')}, --rules=${chalk.bold.underline(
'RULES_FILE'
)} Rules file
-d, --debug Debug mode [off]
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
'TOKEN'
)} Login token
-S, --scope Set a custom scope
-n, --no-verify Don't wait until instance count meets the previous alias constraints

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

Expand All @@ -65,30 +60,14 @@ const help = () => {
${chalk.dim('–')} ${chalk.dim(
'Protocols'
)} in the URLs are unneeded and ignored.

${chalk.gray('–')} Add and modify path based aliases for ${chalk.underline(
'zeit.ninja'
)}

${chalk.cyan(
`$ now alias ${chalk.underline('zeit.ninja')} -r ${chalk.underline(
'rules.json'
)}`
)}

Export effective routing rules

${chalk.cyan(
`$ now alias ls aliasId --json > ${chalk.underline('rules.json')}`
)}
`);
};

const COMMAND_CONFIG = {
default: 'set',
ls: ['ls', 'list'],
rm: ['rm', 'remove'],
set: ['set']
set: ['set'],
};

export default async function main(ctx) {
Expand All @@ -97,12 +76,8 @@ export default async function main(ctx) {
try {
argv = getArgs(ctx.argv.slice(2), {
'--json': Boolean,
'--no-verify': Boolean,
'--rules': String,
'--yes': Boolean,
'-n': '--no-verify',
'-r': '--rules',
'-y': '--yes'
'-y': '--yes',
});
} catch (err) {
handleError(err);
Expand Down
3 changes: 1 addition & 2 deletions packages/now-cli/src/commands/alias/ls.js
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import ms from 'ms';
import plural from 'pluralize';
import table from 'text-table';
import Now from '../../util';
import Now from '../../util/now';
import Client from '../../util/client.ts';
import getAliases from '../../util/alias/get-aliases';
import getScope from '../../util/get-scope.ts';
Expand Down Expand Up @@ -36,7 +36,6 @@ export default async function ls(ctx, opts, args, output) {
throw err;
}

// $FlowFixMe
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
const lsStamp = stamp();
let cancelWait;
Expand Down
18 changes: 10 additions & 8 deletions packages/now-cli/src/commands/alias/rm.js
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import ms from 'ms';
import table from 'text-table';
import Now from '../../util';
import Now from '../../util/now';
import cmd from '../../util/output/cmd.ts';
import Client from '../../util/client.ts';
import getScope from '../../util/get-scope.ts';
Expand All @@ -13,15 +13,18 @@ import { isValidName } from '../../util/is-valid-name';
import findAliasByAliasOrId from '../../util/alias/find-alias-by-alias-or-id';

export default async function rm(ctx, opts, args, output) {
const { authConfig: { token }, config } = ctx;
const {
authConfig: { token },
config,
} = ctx;
const { currentTeam } = config;
const { apiUrl } = ctx;
const { '--debug': debugEnabled } = opts;
const client = new Client({
apiUrl,
token,
currentTeam,
debug: debugEnabled
debug: debugEnabled,
});
let contextName = null;

Expand All @@ -36,7 +39,6 @@ export default async function rm(ctx, opts, args, output) {
throw err;
}

// $FlowFixMe
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
const [aliasOrId] = args;

Expand Down Expand Up @@ -70,7 +72,7 @@ export default async function rm(ctx, opts, args, output) {
}

const removeStamp = stamp();
if (!opts['--yes'] && !await confirmAliasRemove(output, alias)) {
if (!opts['--yes'] && !(await confirmAliasRemove(output, alias))) {
output.log('Aborted');
return 0;
}
Expand All @@ -93,13 +95,13 @@ async function confirmAliasRemove(output, alias) {
[
...(srcUrl ? [srcUrl] : []),
chalk.underline(alias.alias),
chalk.gray(`${ms(new Date() - new Date(alias.created))} ago`)
]
chalk.gray(`${ms(new Date() - new Date(alias.created))} ago`),
],
],
{
align: ['l', 'l', 'r'],
hsep: ' '.repeat(4),
stringLength: strlen
stringLength: strlen,
}
);

Expand Down