[cli] Add "dev" script, remove "build-dev" script (#8222)

I don't think anyone is using this command anymore in the world of M1.

Anyways, we should be using `ts-node` to execute the CLI from source code instead of skipping steps at build-time to iterate quickly.
This commit is contained in:
Nathan Rajlich
2022-07-22 15:39:10 -07:00
committed by GitHub
parent aebfb6812d
commit fb3601d178
3 changed files with 26 additions and 28 deletions

View File

@@ -53,13 +53,13 @@ At this point you can make modifications to the CLI source code and test them ou
cd packages/cli
```
From within the `packages/cli` directory, you can use the `ts-node` command line tool to quickly excute Vercel CLI from its TypeScript source code directly (without having to manually compile first). For example:
From within the `packages/cli` directory, you can use the "dev" script to quickly execute Vercel CLI from its TypeScript source code directly (without having to manually compile first). For example:
```bash
npx ts-node src/index.ts
npx ts-node src/index.ts login
npx ts-node src/index.ts switch --debug
npx ts-node src/index.ts dev
yarn dev deploy
yarn dev whoami
yarn dev login
yarn dev switch --debug
```
When you are satisfied with your changes, make a commit and create a pull request!

View File

@@ -19,7 +19,7 @@
"prepublishOnly": "yarn build",
"coverage": "codecov",
"build": "ts-node ./scripts/build.ts",
"build-dev": "ts-node ./scripts/build.ts --dev"
"dev": "ts-node ./src/index.ts"
},
"bin": {
"vc": "./dist/index.js",

View File

@@ -27,9 +27,6 @@ function envToString(key: string) {
}
async function main() {
const isDev = process.argv[2] === '--dev';
if (!isDev) {
// Read the secrets from GitHub Actions and generate a file.
// During local development, these secrets will be empty.
await createConstants();
@@ -45,15 +42,16 @@ async function main() {
await execa(process.execPath, [join(__dirname, 'compile-templates.js')], {
stdio: 'inherit',
});
}
// Do the initial `ncc` build
console.log();
const args = ['ncc', 'build', '--external', 'update-notifier'];
if (isDev) {
args.push('--source-map');
}
args.push('src/index.ts');
const args = [
'ncc',
'build',
'--external',
'update-notifier',
'src/index.ts',
];
await execa('yarn', args, { stdio: 'inherit', cwd: dirRoot });
// `ncc` has some issues with `@vercel/fun`'s runtime files: