[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 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 ```bash
npx ts-node src/index.ts yarn dev deploy
npx ts-node src/index.ts login yarn dev whoami
npx ts-node src/index.ts switch --debug yarn dev login
npx ts-node src/index.ts dev yarn dev switch --debug
``` ```
When you are satisfied with your changes, make a commit and create a pull request! When you are satisfied with your changes, make a commit and create a pull request!

View File

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

View File

@@ -27,33 +27,31 @@ function envToString(key: string) {
} }
async function main() { async function main() {
const isDev = process.argv[2] === '--dev'; // Read the secrets from GitHub Actions and generate a file.
// During local development, these secrets will be empty.
await createConstants();
if (!isDev) { // `vercel dev` uses chokidar to watch the filesystem, but opts-out of the
// Read the secrets from GitHub Actions and generate a file. // `fsevents` feature using `useFsEvents: false`, so delete the module here so
// During local development, these secrets will be empty. // that it is not compiled by ncc, which makes the npm package size larger
await createConstants(); // than necessary.
await remove(join(dirRoot, '../../node_modules/fsevents'));
// `vercel dev` uses chokidar to watch the filesystem, but opts-out of the // Compile the `doT.js` template files for `vercel dev`
// `fsevents` feature using `useFsEvents: false`, so delete the module here so console.log();
// that it is not compiled by ncc, which makes the npm package size larger await execa(process.execPath, [join(__dirname, 'compile-templates.js')], {
// than necessary. stdio: 'inherit',
await remove(join(dirRoot, '../../node_modules/fsevents')); });
// Compile the `doT.js` template files for `vercel dev`
console.log();
await execa(process.execPath, [join(__dirname, 'compile-templates.js')], {
stdio: 'inherit',
});
}
// Do the initial `ncc` build // Do the initial `ncc` build
console.log(); console.log();
const args = ['ncc', 'build', '--external', 'update-notifier']; const args = [
if (isDev) { 'ncc',
args.push('--source-map'); 'build',
} '--external',
args.push('src/index.ts'); 'update-notifier',
'src/index.ts',
];
await execa('yarn', args, { stdio: 'inherit', cwd: dirRoot }); await execa('yarn', args, { stdio: 'inherit', cwd: dirRoot });
// `ncc` has some issues with `@vercel/fun`'s runtime files: // `ncc` has some issues with `@vercel/fun`'s runtime files: