Commit Graph

20 Commits

Author SHA1 Message Date
Chris Barber
222710f612 Add type-check and unify tsconfig (#10667)
This adds a new `pnpm type-check` that leverages `turbo` to validate the TypeScript code. This can be run at the top-level or for an individual package.

The `test-lint` workflow will run it after linting and doing the prettier check.

As apart of this effort, each package's `tsconfig.json` has been simplified. There's a new top-level `tsconfig.base.json` file that extends the Vercel Style Guide for TypeScript. Each package's `tsconfig.json` has been audited and previously suppressed rules that no longer apply have been removed. The result is each package's `tsconfig.json` is greatly simplified and we can control common settings in the base config while keeping the flexibility of package-level overrides.

Lastly, in `package/cli`, `pnpm build` calls `scripts/build.mjs` which calls `scripts/compile-templates.mjs`. The `compile-templates.mjs` file was generating invalid TypeScript code. I've fixed it and now it's happier than ever.

Note: In order to run `pnpm type-check`, you must first `pnpm build` because we need the `.d.ts` definition files.
2023-10-09 11:58:23 +00:00
Nathan Rajlich
1a5bd6c5b9 [cli] Use "esbuild" (#10555) 2023-09-22 09:25:26 -03:00
Steven
7e791ee080 [cli] Remove preinstall script (#10157)
This will solve two of the warnings from [Socket.dev](https://socket.dev/npm/package/vercel):

<img width="1126" alt="image" src="https://github.com/vercel/vercel/assets/229881/c890c973-4f5a-44d9-9b96-2580a1e40ed0">

This preinstall script isn't necessary to run Vercel CLI, its only used to improve the error message in two cases:

- The system has `node` version prior to 14.x (3 years ago)
- The system still has `now` installed but should be using `vercel` (last shipped 3 years ago)

The usage of `preinstall` scripts have gone out of style due to security audits so we should remove this script now.
2023-06-28 22:30:49 +00:00
Steven
bada86b8d6 [tests] Add prettier check (#9664)
This PR fixes the formatting on several files that were never run through `prettier`.

It also makes sure to run `prettier` in CI to to [fail fast](https://github.com/vercel/vercel/actions/runs/4408442998/jobs/7723453978) when the incorrect formatting is attempted.
2023-03-13 19:55:59 +00:00
Ethan Arrowood
9c768b98b7 [tests] Migrate from yarn to pnpm (#9198)
<picture data-single-emoji=":pnpm:" title=":pnpm:"><img class="emoji" src="https://single-emoji.vercel.app/api/emoji/eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..4mJzrO94AnSn0Pue.4apgaKtTUdQ-wxNyahjdJj28u8bbXreLoTA8AGqYjLta3MrsFvbo9DsQFth4CoIkBgXFhQ5_BVcKNfYbwLg4bKzyIvItKe4OFS8AzG7Kkicz2kUUZk0.nXyK_PvHzZFGA-MQB6XHfA" alt=":pnpm:" width="20" height="auto" align="absmiddle"></picture> 

yarn has become increasingly more difficult to use as the v1 we rely on no longer receives updates. pnpm is faster and is actively maintained. 

This PR migrates us to pnpm.
2023-01-11 23:35:13 +00:00
Chris Barber
e1aaf8080b [cli] Replace update-notifier dependency with build in (#9098)
This PR replaces the `update-notifier` dependency with a custom implementation.

There are a few reasons: the dependency is quite large, it requires ESM in order to update, can sometimes suggest an update to an older version, and used dependencies with known security issues.

The result looks like:

<img width="768" alt="image" src="https://user-images.githubusercontent.com/97262/208452226-b7508299-f830-4d42-a96a-7646ec8227aa.png">

Note: This PR is the successor to https://github.com/vercel/vercel/pull/8090.
2023-01-11 03:45:36 +00:00
Lee Robinson
2e0cbf10de [cli] Revert replace update-notifier dependency with built in (#9000)
Reverts https://github.com/vercel/vercel/pull/8090.


![image](https://user-images.githubusercontent.com/9113740/205410222-efd63ff6-8094-4cba-8316-559845c64289.png)
2022-12-02 18:20:11 -06:00
Steven
577fd3e979 [cli] Replace update-notifier dependency with built in (#8090)
This PR replaces the `update-notifier` dependency with a custom
implementation.

There are a few reasons: the dependency is quite large, it requires ESM
in order to update, and can sometimes suggest an update to an older
version. For example:


![image](https://user-images.githubusercontent.com/229881/195891579-c8c047a6-51ec-45f2-b597-daf927f48203.png)


- Related to #8038

Co-authored-by: Chris Barber <chris.barber@vercel.com>
Co-authored-by: Chris Barber <chris@cb1inc.com>
Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-01 17:07:52 -06:00
Steven
675c3e2915 [cli] Change error message from Error! to Error: (#8498)
We have code that tries to detect and highlight errors in the build logs, however it doesn't look for `Error!`, only `Error:`.

We could update that highlight code or we could update Vercel CLI to make it consistent.

This PR is the latter.
2022-09-01 13:12:41 -04:00
Nathan Rajlich
081b38466b [cli] Update to TypeScript v4.7.4 (#8232) 2022-07-25 16:08:14 -07:00
Nathan Rajlich
fb3601d178 [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.
2022-07-22 22:39:10 +00:00
Steven
fd9142b6f3 [cli] Bump @vercel/fun to 1.0.4 (#8198)
Bump `@vercel/fun` to [1.0.4](https://github.com/vercel/fun/releases/tag/1.0.4)
2022-07-21 00:00:03 +00:00
JJ Kasper
c43db1788c [tests] Add cross platform chunked testing and leverage turbo more (#7795)
* [tests] Use `turbo` for unit tests

* .

* .

* Revert "."

This reverts commit 3d6204fef3fda3c7b4bf08955a186fe806d7c597.

* Add "src/util/constants.ts" to outputs

* .

* Add `@vercel/node-bridge` outputs

* .

* Mac and Windows

* .

* Node 14

* .

* .

* Add templates to CLI output

* Run only selected test files

* Add cross platform testing

* make test paths relative and have minimum per chunk

* add install arg

* update shell

* bump cache key

* use backslashes on windows

* pass tests as arg

* update script name

* update turbo config

* forward turbo args correctly

* dont use backslashes

* chunk integration tests instead

* update env

* separate static-build tests

* ensure unit test turbo cache is saved

* ensure turbo cache is saved for dev/cli

* fix cache key and update timeout

* Increase static-build unit test timeout

* Leverage turbo remote caching instead of actions/cache

* apply suggestions and test chunking itself

* update other ci jobs

* fix test collecting

Co-authored-by: Nathan Rajlich <n@n8.io>
2022-05-18 13:27:20 -07:00
Gary Borton
979e4b674a [cli] Bundle middleware deps (#6932)
* Use ncc to bundle middleware plugin, move dependencies to devDependencies, remove querystring

* Switch from globby (deprecated dependencies) to glob in middleware plugin.

* Bundle the node-plugin and middleware-plugin into cli.
2021-11-02 17:08:02 -04:00
Nathan Rajlich
44868d79b6 Add initial vercel-plugin-middleware (#6892)
* Add initial `vercel-plugin-middleware`

* Ignore `entries.js` from ESLint

* Add `runDevMiddleware()` stub

* Add test

* Add support for "_middleware.{js,ts}" to `vercel dev` (#6880)

* Add websandbox from next.js codebase.

* Use node-fetch instead of next's polyfilled fetch.

* Handle middleware rewrites.

* Add response, headers, and request to websandbox context.

* Move websandbox dependency to middleware plugin.

* Add integration tests, update websandbox to support ts files and json imports.

* commit yarn.lock changes after rebasing

* Clean up left over console.logs, fix some tsc issues, and rebase issue.

* Fix failing test and eslint.

* Fix middleware test on windows.

* [examples] Update Vercel Next.js example template to 12.0.1 (#6905)

* Mark the Plugins as external to CLI's ncc build

* [cli] Improve tracing in vc build (#6898)

* [cli] Fix tracing for `vc build`

* Ignore object when there are no changes

* Make Next < 12 work with FS API w/ nft

* Update packages/cli/src/commands/build.ts

Co-authored-by: Nathan Rajlich <n@n8.io>

* Document how Next.js processing works in build

* [cli] Fix static assets (#6906)

* Make sure output path is .next

* Fix up require-server-files for processing

* Fix typo

* Move static

* Update static rename

Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>

* Publish Canary

 - vercel@23.1.3-canary.17
 - @vercel/client@10.2.3-canary.15
 - @vercel/static-config@0.0.1-canary.0

* [cli] Ignore `.env` and `.gitignore` in "vc build" (#6910)

* Publish Canary

 - vercel@23.1.3-canary.18

* Pass workPath to plugins.

The new plugin architecture doesn't pass a full BuildOptions object, previous
to this commit it wasn't passing any options at all. I've added workingPath to
support running dev/build from directories other than the project root.

* Remove error state when package.json exists, but no build script

This allows vercel build to continue working for projects that are not using
frameworks, but use package.json to manage dependencies.

* Fix types, pull in middleware header fix from next.js

Next js PR w/ the header fix:
https://github.com/vercel/next.js/pull/30560

* Fix missing entries file for vc build.

* Update call signature of middleware when using vc build.

Co-authored-by: Drew Bredvick <dbredvick@gmail.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>

Co-authored-by: Gary Borton <gdborton@gmail.com>
Co-authored-by: Drew Bredvick <dbredvick@gmail.com>
Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
Co-authored-by: Andy Bitz <artzbitz@gmail.com>
Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
2021-10-29 17:15:20 -07:00
Steven
702cb9e29c [all] Revert to @vercel/ncc@0.24.0 (#6749) 2021-09-21 22:17:06 -04:00
Steven
a2e4186ccb [all] Bump ncc to 0.31.1 (#6700)
https://github.com/vercel/ncc/releases/tag/0.31.0

https://github.com/vercel/ncc/releases/tag/0.31.1
2021-09-13 20:20:48 +00:00
Nathan Rajlich
676a3d2568 [cli] Refactor src/index to TypeScript (#6602)
Refactors the CLI entrypoint `src/index.js` to TypeScript.
2021-08-27 19:48:31 +00:00
Nathan Rajlich
f221f041d0 Update @vercel/ncc to v0.29.2 (#6605) 2021-08-27 10:03:36 -07:00
ernestd
cfae7ec3c2 [all] Remove now prefix in packages (#5928)
* remove prefix from codeowners

* remove references from ignore files

* Remove prefix from package json and tests

* Add run js without prefixes

* Rename package folders

* Delete auto generated test files

* Remove now-node in integration test

* Put back deleted vercel json files

* Remove eol

* Add styfle suggestion to comment in utils/run.js

Co-authored-by: Steven <steven@ceriously.com>
2021-03-05 16:55:30 -08:00