mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 12:57:46 +00:00
Compare commits
160 Commits
@vercel/st
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
621b53bc49 | ||
|
|
728b620355 | ||
|
|
7d16395038 | ||
|
|
59e1259688 | ||
|
|
169242157e | ||
|
|
db10ffd679 | ||
|
|
c0d0744c4e | ||
|
|
9da67423a5 | ||
|
|
51fe09d5e9 | ||
|
|
695bfbdd60 | ||
|
|
547e88228e | ||
|
|
9bfb5dd535 | ||
|
|
81ea84fae8 | ||
|
|
fa8bf07be4 | ||
|
|
cc9dce73ad | ||
|
|
bba7cbd411 | ||
|
|
9a3739bebd | ||
|
|
8c62de16ce | ||
|
|
e9333988d7 | ||
|
|
fb001ce7eb | ||
|
|
b399fe7037 | ||
|
|
88385b3c84 | ||
|
|
eed39913e1 | ||
|
|
03e9047bc9 | ||
|
|
0e35205bf1 | ||
|
|
e42fe34c4a | ||
|
|
3ece7ac969 | ||
|
|
4f832acf90 | ||
|
|
918726e01d | ||
|
|
dc2ddf867b | ||
|
|
ee1211416f | ||
|
|
570fd24e29 | ||
|
|
40681ad0f4 | ||
|
|
f20703b15d | ||
|
|
68eb197112 | ||
|
|
b8b87b96da | ||
|
|
967c24f1bb | ||
|
|
609f781234 | ||
|
|
998f6bf6e6 | ||
|
|
7511c2ef85 | ||
|
|
71425fac1f | ||
|
|
6973cd5989 | ||
|
|
24785ff50a | ||
|
|
aa3ad4478c | ||
|
|
f0d73049ca | ||
|
|
6cef07354a | ||
|
|
50af9f5b75 | ||
|
|
af76b134d8 | ||
|
|
c7640005fd | ||
|
|
3deed977ba | ||
|
|
b38c360e36 | ||
|
|
1595e48414 | ||
|
|
e6b0ee3e3c | ||
|
|
a247e31688 | ||
|
|
dc02e763a4 | ||
|
|
8567fc0de6 | ||
|
|
4f8f3d373f | ||
|
|
debb85b690 | ||
|
|
bfef989ada | ||
|
|
4e0b6c5eaf | ||
|
|
0ace69ef75 | ||
|
|
b7b7923f92 | ||
|
|
8167233c56 | ||
|
|
32ee6aba92 | ||
|
|
b48f7a7e6e | ||
|
|
a961c9b992 | ||
|
|
cf7c50d691 | ||
|
|
f4be388a1f | ||
|
|
c1bc53dea8 | ||
|
|
6855e3df54 | ||
|
|
0d39dbd1d9 | ||
|
|
509c85182a | ||
|
|
ae801e563d | ||
|
|
0e8278f490 | ||
|
|
0d302a6f48 | ||
|
|
4e4f5f28a2 | ||
|
|
5205a4ec4b | ||
|
|
2c15e496ed | ||
|
|
1f0ca46626 | ||
|
|
17cb5f1bc6 | ||
|
|
b095031292 | ||
|
|
f50bcbc0ba | ||
|
|
4bf6295d7a | ||
|
|
a4001ce10b | ||
|
|
2df3432d88 | ||
|
|
bcfc19de12 | ||
|
|
04381c669b | ||
|
|
0c7b54edad | ||
|
|
6d42816395 | ||
|
|
6fe6d05a42 | ||
|
|
50a201f145 | ||
|
|
701a02ae9d | ||
|
|
39f7586621 | ||
|
|
c4a39c8d29 | ||
|
|
3ac238cf08 | ||
|
|
8384813a0d | ||
|
|
c4587de439 | ||
|
|
d997dc4fbc | ||
|
|
d15b90bd4d | ||
|
|
5b31297f0c | ||
|
|
e232566cbe | ||
|
|
592689cad1 | ||
|
|
9b08e72f76 | ||
|
|
bd0e10cfe7 | ||
|
|
28436ade60 | ||
|
|
de0d2fba0b | ||
|
|
e0900128d6 | ||
|
|
8d15f30579 | ||
|
|
960c66584c | ||
|
|
1c8f91031a | ||
|
|
68cb23c3cc | ||
|
|
94f6ae2595 | ||
|
|
b92aeac84d | ||
|
|
00420b7a01 | ||
|
|
a5128790d0 | ||
|
|
ae9aa91f4f | ||
|
|
d4cef69cc9 | ||
|
|
323f67c31a | ||
|
|
63c499a826 | ||
|
|
ad436313e1 | ||
|
|
c414288b2f | ||
|
|
b07ff7431f | ||
|
|
79fde4475c | ||
|
|
855197c699 | ||
|
|
fbd9080859 | ||
|
|
b5c5b7b82c | ||
|
|
0a072ee850 | ||
|
|
0b56caba45 | ||
|
|
ab3db60824 | ||
|
|
f2f2ff2c67 | ||
|
|
ba7dafff71 | ||
|
|
987fb4d4f7 | ||
|
|
be74f79fa0 | ||
|
|
86886e6b60 | ||
|
|
e8a9000137 | ||
|
|
75ea68d445 | ||
|
|
a5a990995c | ||
|
|
cd7dcc6731 | ||
|
|
c4bd462b85 | ||
|
|
5fc266bd8a | ||
|
|
08b04d0bda | ||
|
|
92ae51c6a6 | ||
|
|
909c493d1e | ||
|
|
98b54ff61f | ||
|
|
3defd0b2fd | ||
|
|
5a7851a7f7 | ||
|
|
7f0caa7dec | ||
|
|
89b5aad367 | ||
|
|
c13775ba07 | ||
|
|
cc3c1d1eeb | ||
|
|
3aa2fbbb53 | ||
|
|
3a8b8aa03a | ||
|
|
d008617c0b | ||
|
|
8aecb99447 | ||
|
|
1793fa643f | ||
|
|
913683a8e6 | ||
|
|
0d1dc23d0d | ||
|
|
e829ce47c3 | ||
|
|
474770e9b0 | ||
|
|
e762d8d4e8 |
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -8,3 +8,7 @@ packages/*/test/* linguist-vendored
|
||||
# Go build fails with Windows line endings.
|
||||
*.go text eol=lf
|
||||
go.mod text eol=lf
|
||||
|
||||
# Mark certain files as "binary" -- hide diffs
|
||||
**/test/fixtures/**/git/**/* binary
|
||||
**/test/fixtures/**/git/**/* linguist-generated
|
||||
|
||||
8
.github/CONTRIBUTING.md
vendored
8
.github/CONTRIBUTING.md
vendored
@@ -23,7 +23,7 @@ Make sure all the tests pass before making changes.
|
||||
|
||||
## Verifying your change
|
||||
|
||||
Once you are done with your changes (we even suggest doing it along the way), make sure all the test still pass by running:
|
||||
Once you are done with your changes (we even suggest doing it along the way), make sure all the tests still pass by running:
|
||||
|
||||
```
|
||||
yarn test-unit
|
||||
@@ -64,7 +64,7 @@ Integration tests create deployments to your Vercel account using the `test` pro
|
||||
x-now-trace=iad1]
|
||||
```
|
||||
|
||||
In such cases you can visit the URL of the failed deployment and append `/_logs` so see the build error. In the case above, that would be https://test-8ashcdlew.vercel.app/_logs
|
||||
In such cases, you can visit the URL of the failed deployment and append `/_logs` to see the build error. In the case above, that would be https://test-8ashcdlew.vercel.app/_logs
|
||||
|
||||
The logs of this deployment will contain the actual error which may help you to understand what went wrong.
|
||||
|
||||
@@ -82,11 +82,11 @@ nodeFileTrace(['path/to/entrypoint.js'], {
|
||||
.then(e => console.error(e));
|
||||
```
|
||||
|
||||
When you run this script, you'll see all imported files. If anything file is missing, the bug is in [@vercel/nft](https://github.com/vercel/nft) and not the Builder.
|
||||
When you run this script, you'll see all the imported files. If anything file is missing, the bug is in [@vercel/nft](https://github.com/vercel/nft) and not the Builder.
|
||||
|
||||
## Deploy a Builder with existing project
|
||||
|
||||
Sometimes you want to test changes to a Builder against an existing project, maybe with `vercel dev` or an actual deployment. You can avoid publishing every Builder change to npm by uploading the Builder as a tarball.
|
||||
Sometimes you want to test changes to a Builder against an existing project, maybe with `vercel dev` or actual deployment. You can avoid publishing every Builder change to npm by uploading the Builder as a tarball.
|
||||
|
||||
1. Change directory to the desired Builder `cd ./packages/node`
|
||||
2. Run `yarn build` to compile typescript and other build steps
|
||||
|
||||
12
.github/workflows/test-integration-cli.yml
vendored
12
.github/workflows/test-integration-cli.yml
vendored
@@ -16,13 +16,15 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
node: [12]
|
||||
node: [14]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
TURBO_REMOTE_ONLY: true
|
||||
TURBO_TEAM: vercel
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
steps:
|
||||
- name: Conditionally set remote env
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
run: |
|
||||
echo "TURBO_REMOTE_ONLY=true" >> $GITHUB_ENV
|
||||
echo "TURBO_TEAM=vercel" >> $GITHUB_ENV
|
||||
echo "TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}" >> $GITHUB_ENV
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '1.13.15'
|
||||
|
||||
16
.github/workflows/test-unit.yml
vendored
16
.github/workflows/test-unit.yml
vendored
@@ -16,13 +16,15 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
node: [12]
|
||||
node: [14]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
TURBO_REMOTE_ONLY: true
|
||||
TURBO_TEAM: vercel
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
steps:
|
||||
- name: Conditionally set remote env
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
run: |
|
||||
echo "TURBO_REMOTE_ONLY=true" >> $GITHUB_ENV
|
||||
echo "TURBO_TEAM=vercel" >> $GITHUB_ENV
|
||||
echo "TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}" >> $GITHUB_ENV
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '1.13.15'
|
||||
@@ -39,9 +41,9 @@ jobs:
|
||||
- run: yarn install --network-timeout 1000000
|
||||
- run: yarn run build
|
||||
- run: yarn run lint
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run lint once
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 14 # only run lint once
|
||||
- run: yarn run test-unit
|
||||
- run: yarn workspace vercel run coverage
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run coverage once
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node == 14 # only run coverage once
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -38,10 +38,6 @@ jobs:
|
||||
runs-on: ${{ matrix.runner }}
|
||||
name: ${{matrix.scriptName}} (${{matrix.packageName}}, ${{matrix.chunkNumber}}, ${{ matrix.runner }})
|
||||
if: ${{ needs.setup.outputs['tests'] != '[]' }}
|
||||
env:
|
||||
TURBO_REMOTE_ONLY: true
|
||||
TURBO_TEAM: vercel
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
needs:
|
||||
- setup
|
||||
strategy:
|
||||
@@ -49,6 +45,12 @@ jobs:
|
||||
matrix:
|
||||
include: ${{ fromJson(needs.setup.outputs['tests']) }}
|
||||
steps:
|
||||
- name: Conditionally set remote env
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
run: |
|
||||
echo "TURBO_REMOTE_ONLY=true" >> $GITHUB_ENV
|
||||
echo "TURBO_TEAM=vercel" >> $GITHUB_ENV
|
||||
echo "TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}" >> $GITHUB_ENV
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
4
.prettierignore
Normal file
4
.prettierignore
Normal file
@@ -0,0 +1,4 @@
|
||||
# https://prettier.io/docs/en/ignore.html
|
||||
|
||||
# ignore this file with an intentional syntax error
|
||||
packages/cli/test/dev/fixtures/edge-function-error/api/edge-error-syntax.js
|
||||
@@ -1,18 +1 @@
|
||||
*
|
||||
|
||||
# general
|
||||
!utils/
|
||||
!utils/run.js
|
||||
!.yarnrc
|
||||
!yarn.lock
|
||||
!package.json
|
||||
!turbo.json
|
||||
|
||||
# api
|
||||
!api/
|
||||
!api/**
|
||||
|
||||
# packages
|
||||
!packages/
|
||||
!packages/frameworks
|
||||
!packages/frameworks/**
|
||||
packages/*/test/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import { join, dirname } from 'path';
|
||||
import execa from 'execa';
|
||||
import { getExampleList } from '../examples/example-list';
|
||||
import { mapOldToNew } from '../examples/map-old-to-new';
|
||||
|
||||
@@ -40,7 +41,32 @@ async function main() {
|
||||
JSON.stringify([...existingExamples, ...oldExamples])
|
||||
);
|
||||
|
||||
const { stdout: sha } = await execa('git', ['rev-parse', '--short', 'HEAD'], {
|
||||
cwd: repoRoot,
|
||||
});
|
||||
|
||||
const tarballsDir = join(pubDir, 'tarballs');
|
||||
const packagesDir = join(repoRoot, 'packages');
|
||||
const packages = await fs.readdir(packagesDir);
|
||||
for (const pkg of packages) {
|
||||
const fullDir = join(packagesDir, pkg);
|
||||
const packageJsonRaw = await fs.readFile(
|
||||
join(fullDir, 'package.json'),
|
||||
'utf-8'
|
||||
);
|
||||
const packageJson = JSON.parse(packageJsonRaw);
|
||||
const tarballName = `${packageJson.name
|
||||
.replace('@', '')
|
||||
.replace('/', '-')}-v${packageJson.version}-${sha.trim()}.tgz`;
|
||||
const destTarballPath = join(tarballsDir, `${packageJson.name}.tgz`);
|
||||
await fs.mkdir(dirname(destTarballPath), { recursive: true });
|
||||
await fs.copyFile(join(fullDir, tarballName), destTarballPath);
|
||||
}
|
||||
|
||||
console.log('Completed building static frontend.');
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
main().catch(err => {
|
||||
console.log('error running build:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"target": "ES2020",
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
||||
2
examples/create-react-app/.env.production
Normal file
2
examples/create-react-app/.env.production
Normal file
@@ -0,0 +1,2 @@
|
||||
# `REACT_APP` prefix is required to expose to client-side
|
||||
REACT_APP_VERCEL_ANALYTICS_ID=$VERCEL_ANALYTICS_ID
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.16.1",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"web-vitals": "^2.1.3"
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@testing-library/user-event": "^14.2.0",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
import { sendToVercelAnalytics } from './vitals';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
@@ -11,7 +12,4 @@ ReactDOM.render(
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
reportWebVitals(sendToVercelAnalytics);
|
||||
|
||||
40
examples/create-react-app/src/vitals.js
Normal file
40
examples/create-react-app/src/vitals.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
|
||||
|
||||
function getConnectionSpeed() {
|
||||
return 'connection' in navigator &&
|
||||
navigator['connection'] &&
|
||||
'effectiveType' in navigator['connection']
|
||||
? navigator['connection']['effectiveType']
|
||||
: '';
|
||||
}
|
||||
|
||||
export function sendToVercelAnalytics(metric) {
|
||||
const analyticsId = process.env.REACT_APP_VERCEL_ANALYTICS_ID;
|
||||
if (!analyticsId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const body = {
|
||||
dsn: analyticsId,
|
||||
id: metric.id,
|
||||
page: window.location.pathname,
|
||||
href: window.location.href,
|
||||
event_name: metric.name,
|
||||
value: metric.value.toString(),
|
||||
speed: getConnectionSpeed(),
|
||||
};
|
||||
|
||||
const blob = new Blob([new URLSearchParams(body).toString()], {
|
||||
// This content type is necessary for `sendBeacon`
|
||||
type: 'application/x-www-form-urlencoded',
|
||||
});
|
||||
if (navigator.sendBeacon) {
|
||||
navigator.sendBeacon(vitalsUrl, blob);
|
||||
} else
|
||||
fetch(vitalsUrl, {
|
||||
body: blob,
|
||||
method: 'POST',
|
||||
credentials: 'omit',
|
||||
keepalive: true,
|
||||
});
|
||||
}
|
||||
@@ -1484,10 +1484,10 @@
|
||||
"@svgr/plugin-svgo" "^5.5.0"
|
||||
loader-utils "^2.0.0"
|
||||
|
||||
"@testing-library/dom@^8.0.0":
|
||||
version "8.11.2"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.11.2.tgz#fc110c665a066c2287be765e4a35ba8dad737015"
|
||||
integrity sha512-idsS/cqbYudXcVWngc1PuWNmXs416oBy2g/7Q8QAUREt5Z3MUkAL2XJD7xazLJ6esDfqRDi/ZBxk+OPPXitHRw==
|
||||
"@testing-library/dom@^8.5.0":
|
||||
version "8.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.13.0.tgz#bc00bdd64c7d8b40841e27a70211399ad3af46f5"
|
||||
integrity sha512-9VHgfIatKNXQNaZTtLnalIy0jNZzY35a4S3oi08YAt9Hv1VsfZ/DfA45lM8D/UhtHBGJ4/lGwp0PZkVndRkoOQ==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.10.4"
|
||||
"@babel/runtime" "^7.12.5"
|
||||
@@ -1498,10 +1498,10 @@
|
||||
lz-string "^1.4.4"
|
||||
pretty-format "^27.0.2"
|
||||
|
||||
"@testing-library/jest-dom@^5.16.1":
|
||||
version "5.16.1"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.1.tgz#3db7df5ae97596264a7da9696fe14695ba02e51f"
|
||||
integrity sha512-ajUJdfDIuTCadB79ukO+0l8O+QwN0LiSxDaYUTI4LndbbUsGi6rWU1SCexXzBA2NSjlVB9/vbkasQIL3tmPBjw==
|
||||
"@testing-library/jest-dom@^5.16.4":
|
||||
version "5.16.4"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd"
|
||||
integrity sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.9.2"
|
||||
"@types/testing-library__jest-dom" "^5.9.1"
|
||||
@@ -1513,20 +1513,19 @@
|
||||
lodash "^4.17.15"
|
||||
redent "^3.0.0"
|
||||
|
||||
"@testing-library/react@^12.1.2":
|
||||
version "12.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.2.tgz#f1bc9a45943461fa2a598bb4597df1ae044cfc76"
|
||||
integrity sha512-ihQiEOklNyHIpo2Y8FREkyD1QAea054U0MVbwH1m8N9TxeFz+KoJ9LkqoKqJlzx2JDm56DVwaJ1r36JYxZM05g==
|
||||
"@testing-library/react@^13.3.0":
|
||||
version "13.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.3.0.tgz#bf298bfbc5589326bbcc8052b211f3bb097a97c5"
|
||||
integrity sha512-DB79aA426+deFgGSjnf5grczDPiL4taK3hFaa+M5q7q20Kcve9eQottOG5kZ74KEr55v0tU2CQormSSDK87zYQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
"@testing-library/dom" "^8.0.0"
|
||||
"@testing-library/dom" "^8.5.0"
|
||||
"@types/react-dom" "^18.0.0"
|
||||
|
||||
"@testing-library/user-event@^13.5.0":
|
||||
version "13.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-13.5.0.tgz#69d77007f1e124d55314a2b73fd204b333b13295"
|
||||
integrity sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
"@testing-library/user-event@^14.2.0":
|
||||
version "14.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.2.0.tgz#8293560f8f80a00383d6c755ec3e0b918acb1683"
|
||||
integrity sha512-+hIlG4nJS6ivZrKnOP7OGsDu9Fxmryj9vCl8x0ZINtTJcCHs2zLsYif5GzuRiBF2ck5GZG2aQr7Msg+EHlnYVQ==
|
||||
|
||||
"@tootallnate/once@1":
|
||||
version "1.1.2"
|
||||
@@ -1735,6 +1734,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.3.tgz#a3c65525b91fca7da00ab1a3ac2b5a2a4afbffbf"
|
||||
integrity sha512-QzSuZMBuG5u8HqYz01qtMdg/Jfctlnvj1z/lYnIDXs/golxw0fxtRAHd9KrzjR7Yxz1qVeI00o0kiO3PmVdJ9w==
|
||||
|
||||
"@types/prop-types@*":
|
||||
version "15.7.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
|
||||
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==
|
||||
|
||||
"@types/q@^1.5.1":
|
||||
version "1.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.5.tgz#75a2a8e7d8ab4b230414505d92335d1dcb53a6df"
|
||||
@@ -1750,6 +1754,22 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc"
|
||||
integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==
|
||||
|
||||
"@types/react-dom@^18.0.0":
|
||||
version "18.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.5.tgz#330b2d472c22f796e5531446939eacef8378444a"
|
||||
integrity sha512-OWPWTUrY/NIrjsAPkAk1wW9LZeIjSvkXRhclsFO8CZcZGCOg2G0YZy4ft+rOyYxy8B7ui5iZzi9OkDebZ7/QSA==
|
||||
dependencies:
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/react@*":
|
||||
version "18.0.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.9.tgz#d6712a38bd6cd83469603e7359511126f122e878"
|
||||
integrity sha512-9bjbg1hJHUm4De19L1cHiW0Jvx3geel6Qczhjd0qY5VKVE2X5+x77YxAepuCwVh4vrgZJdgEJw48zrhRIeF4Nw==
|
||||
dependencies:
|
||||
"@types/prop-types" "*"
|
||||
"@types/scheduler" "*"
|
||||
csstype "^3.0.2"
|
||||
|
||||
"@types/resolve@1.17.1":
|
||||
version "1.17.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
|
||||
@@ -1762,6 +1782,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.1.tgz#d8f1c0d0dc23afad6dc16a9e993a0865774b4065"
|
||||
integrity sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==
|
||||
|
||||
"@types/scheduler@*":
|
||||
version "0.16.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
|
||||
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==
|
||||
|
||||
"@types/serve-index@^1.9.1":
|
||||
version "1.9.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.1.tgz#1b5e85370a192c01ec6cec4735cf2917337a6278"
|
||||
@@ -3175,6 +3200,11 @@ cssstyle@^2.3.0:
|
||||
dependencies:
|
||||
cssom "~0.3.6"
|
||||
|
||||
csstype@^3.0.2:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2"
|
||||
integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==
|
||||
|
||||
damerau-levenshtein@^1.0.7:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7"
|
||||
@@ -3622,10 +3652,10 @@ escodegen@^2.0.0:
|
||||
optionalDependencies:
|
||||
source-map "~0.6.1"
|
||||
|
||||
eslint-config-react-app@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-7.0.0.tgz#0fa96d5ec1dfb99c029b1554362ab3fa1c3757df"
|
||||
integrity sha512-xyymoxtIt1EOsSaGag+/jmcywRuieQoA2JbPCjnw9HukFj9/97aGPoZVFioaotzk1K5Qt9sHO5EutZbkrAXS0g==
|
||||
eslint-config-react-app@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz#73ba3929978001c5c86274c017ea57eb5fa644b4"
|
||||
integrity sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA==
|
||||
dependencies:
|
||||
"@babel/core" "^7.16.0"
|
||||
"@babel/eslint-parser" "^7.16.3"
|
||||
@@ -6841,10 +6871,10 @@ react-app-polyfill@^3.0.0:
|
||||
regenerator-runtime "^0.13.9"
|
||||
whatwg-fetch "^3.6.2"
|
||||
|
||||
react-dev-utils@^12.0.0:
|
||||
version "12.0.0"
|
||||
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.0.tgz#4eab12cdb95692a077616770b5988f0adf806526"
|
||||
integrity sha512-xBQkitdxozPxt1YZ9O1097EJiVpwHr9FoAuEVURCKV0Av8NBERovJauzP7bo1ThvuhZ4shsQ1AJiu4vQpoT1AQ==
|
||||
react-dev-utils@^12.0.1:
|
||||
version "12.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.1.tgz#ba92edb4a1f379bd46ccd6bcd4e7bc398df33e73"
|
||||
integrity sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ==
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.16.0"
|
||||
address "^1.1.2"
|
||||
@@ -6865,25 +6895,24 @@ react-dev-utils@^12.0.0:
|
||||
open "^8.4.0"
|
||||
pkg-up "^3.1.0"
|
||||
prompts "^2.4.2"
|
||||
react-error-overlay "^6.0.10"
|
||||
react-error-overlay "^6.0.11"
|
||||
recursive-readdir "^2.2.2"
|
||||
shell-quote "^1.7.3"
|
||||
strip-ansi "^6.0.1"
|
||||
text-table "^0.2.0"
|
||||
|
||||
react-dom@^17.0.2:
|
||||
version "17.0.2"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"
|
||||
integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==
|
||||
react-dom@^18.1.0:
|
||||
version "18.1.0"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.1.0.tgz#7f6dd84b706408adde05e1df575b3a024d7e8a2f"
|
||||
integrity sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
scheduler "^0.20.2"
|
||||
scheduler "^0.22.0"
|
||||
|
||||
react-error-overlay@^6.0.10:
|
||||
version "6.0.10"
|
||||
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.10.tgz#0fe26db4fa85d9dbb8624729580e90e7159a59a6"
|
||||
integrity sha512-mKR90fX7Pm5seCOfz8q9F+66VCc1PGsWSBxKbITjfKVQHMNF2zudxHnMdJiB1fRCb+XsbQV9sO9DCkgsMQgBIA==
|
||||
react-error-overlay@^6.0.11:
|
||||
version "6.0.11"
|
||||
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb"
|
||||
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==
|
||||
|
||||
react-is@^16.13.1:
|
||||
version "16.13.1"
|
||||
@@ -6900,10 +6929,10 @@ react-refresh@^0.11.0:
|
||||
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
|
||||
integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==
|
||||
|
||||
react-scripts@5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.0.tgz#6547a6d7f8b64364ef95273767466cc577cb4b60"
|
||||
integrity sha512-3i0L2CyIlROz7mxETEdfif6Sfhh9Lfpzi10CtcGs1emDQStmZfWjJbAIMtRD0opVUjQuFWqHZyRZ9PPzKCFxWg==
|
||||
react-scripts@5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-5.0.1.tgz#6285dbd65a8ba6e49ca8d651ce30645a6d980003"
|
||||
integrity sha512-8VAmEm/ZAwQzJ+GOMLbBsTdDKOpuZh7RPs0UymvBR2vRk4iZWCskjbFnxqjrzoIvlNNRZ3QJFx6/qDSi6zSnaQ==
|
||||
dependencies:
|
||||
"@babel/core" "^7.16.0"
|
||||
"@pmmmwh/react-refresh-webpack-plugin" "^0.5.3"
|
||||
@@ -6921,7 +6950,7 @@ react-scripts@5.0.0:
|
||||
dotenv "^10.0.0"
|
||||
dotenv-expand "^5.1.0"
|
||||
eslint "^8.3.0"
|
||||
eslint-config-react-app "^7.0.0"
|
||||
eslint-config-react-app "^7.0.1"
|
||||
eslint-webpack-plugin "^3.1.1"
|
||||
file-loader "^6.2.0"
|
||||
fs-extra "^10.0.0"
|
||||
@@ -6938,7 +6967,7 @@ react-scripts@5.0.0:
|
||||
postcss-preset-env "^7.0.1"
|
||||
prompts "^2.4.2"
|
||||
react-app-polyfill "^3.0.0"
|
||||
react-dev-utils "^12.0.0"
|
||||
react-dev-utils "^12.0.1"
|
||||
react-refresh "^0.11.0"
|
||||
resolve "^1.20.0"
|
||||
resolve-url-loader "^4.0.0"
|
||||
@@ -6955,13 +6984,12 @@ react-scripts@5.0.0:
|
||||
optionalDependencies:
|
||||
fsevents "^2.3.2"
|
||||
|
||||
react@^17.0.2:
|
||||
version "17.0.2"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
|
||||
integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==
|
||||
react@^18.1.0:
|
||||
version "18.1.0"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890"
|
||||
integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
readable-stream@^2.0.1:
|
||||
version "2.3.7"
|
||||
@@ -7235,13 +7263,12 @@ saxes@^5.0.1:
|
||||
dependencies:
|
||||
xmlchars "^2.2.0"
|
||||
|
||||
scheduler@^0.20.2:
|
||||
version "0.20.2"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91"
|
||||
integrity sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==
|
||||
scheduler@^0.22.0:
|
||||
version "0.22.0"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.22.0.tgz#83a5d63594edf074add9a7198b1bae76c3db01b8"
|
||||
integrity sha512-6QAm1BgQI88NPYymgGQLCZgvep4FyePDWFpXVK+zNSUgHwlqpJy8VEh8Et0KxTACS4VWwMousBElAZOH9nkkoQ==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
schema-utils@2.7.0:
|
||||
version "2.7.0"
|
||||
@@ -8156,10 +8183,10 @@ wbuf@^1.1.0, wbuf@^1.7.3:
|
||||
dependencies:
|
||||
minimalistic-assert "^1.0.0"
|
||||
|
||||
web-vitals@^2.1.3:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-2.1.3.tgz#6dca59f41dbc3fcccdb889da06191b437b18f534"
|
||||
integrity sha512-+ijpniAzcnQicXaXIN0/eHQAiV/jMt1oHGHTmz7VdAJPPkzzDhmoYPSpLgJTuFtUh+jCjxCoeTZPg7Ic+g8o7w==
|
||||
web-vitals@^2.1.4:
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-2.1.4.tgz#76563175a475a5e835264d373704f9dde718290c"
|
||||
integrity sha512-sVWcwhU5mX6crfI5Vd2dC4qchyTqxV8URinzt25XqVh+bHEPGH4C3NPrNionCP7Obx59wrYEbNlw4Z8sjALzZg==
|
||||
|
||||
webidl-conversions@^4.0.2:
|
||||
version "4.0.2"
|
||||
|
||||
3
examples/remix/.eslintrc.js
Normal file
3
examples/remix/.eslintrc.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
|
||||
};
|
||||
8
examples/remix/.gitignore
vendored
8
examples/remix/.gitignore
vendored
@@ -1,7 +1,11 @@
|
||||
node_modules
|
||||
|
||||
.cache
|
||||
.env
|
||||
.vercel
|
||||
.output
|
||||
|
||||
public/build
|
||||
api/_build
|
||||
/build/
|
||||
/public/build
|
||||
/api/index.js
|
||||
/api/index.js.map
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
const { createRequestHandler } = require("@remix-run/vercel");
|
||||
|
||||
module.exports = createRequestHandler({
|
||||
build: require("./_build")
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RemixBrowser } from "@remix-run/react";
|
||||
import { hydrate } from "react-dom";
|
||||
import { RemixBrowser } from "remix";
|
||||
|
||||
hydrate(<RemixBrowser />, document);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { EntryContext } from "@remix-run/node";
|
||||
import { RemixServer } from "@remix-run/react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { RemixServer } from "remix";
|
||||
import type { EntryContext } from "remix";
|
||||
|
||||
export default function handleRequest(
|
||||
request: Request,
|
||||
@@ -16,6 +16,6 @@ export default function handleRequest(
|
||||
|
||||
return new Response("<!DOCTYPE html>" + markup, {
|
||||
status: responseStatusCode,
|
||||
headers: responseHeaders
|
||||
headers: responseHeaders,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { LinksFunction, MetaFunction } from "@remix-run/node";
|
||||
import {
|
||||
Link,
|
||||
Links,
|
||||
@@ -6,14 +7,13 @@ import {
|
||||
Outlet,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
useCatch
|
||||
} from "remix";
|
||||
import type { LinksFunction } from "remix";
|
||||
useCatch,
|
||||
} from "@remix-run/react";
|
||||
|
||||
import globalStylesUrl from "~/styles/global.css";
|
||||
import darkStylesUrl from "~/styles/dark.css";
|
||||
import globalStylesUrl from "~/styles/global.css";
|
||||
|
||||
// https://remix.run/api/app#links
|
||||
// https://remix.run/api/conventions#links
|
||||
export let links: LinksFunction = () => {
|
||||
return [
|
||||
{ rel: "stylesheet", href: globalStylesUrl },
|
||||
@@ -25,6 +25,12 @@ export let links: LinksFunction = () => {
|
||||
];
|
||||
};
|
||||
|
||||
// https://remix.run/api/conventions#meta
|
||||
export let meta: MetaFunction = () => ({
|
||||
charset: "utf-8",
|
||||
viewport: "width=device-width,initial-scale=1",
|
||||
});
|
||||
|
||||
// https://remix.run/api/conventions#default-export
|
||||
// https://remix.run/api/conventions#route-filenames
|
||||
export default function App() {
|
||||
@@ -37,7 +43,7 @@ export default function App() {
|
||||
);
|
||||
}
|
||||
|
||||
// https://remix.run/docs/en/v1/api/conventions#errorboundary
|
||||
// https://remix.run/api/conventions#errorboundary
|
||||
export function ErrorBoundary({ error }: { error: Error }) {
|
||||
console.error(error);
|
||||
return (
|
||||
@@ -57,7 +63,7 @@ export function ErrorBoundary({ error }: { error: Error }) {
|
||||
);
|
||||
}
|
||||
|
||||
// https://remix.run/docs/en/v1/api/conventions#catchboundary
|
||||
// https://remix.run/api/conventions#catchboundary
|
||||
export function CatchBoundary() {
|
||||
let caught = useCatch();
|
||||
|
||||
@@ -103,8 +109,6 @@ function Document({
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
{title ? <title>{title}</title> : null}
|
||||
<Meta />
|
||||
<Links />
|
||||
@@ -113,7 +117,7 @@ function Document({
|
||||
{children}
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
{process.env.NODE_ENV === "development" && <LiveReload />}
|
||||
<LiveReload />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Outlet } from "remix";
|
||||
import type { MetaFunction, LinksFunction } from "remix";
|
||||
import type { MetaFunction, LinksFunction } from "@remix-run/node";
|
||||
import { Outlet } from "@remix-run/react";
|
||||
|
||||
import stylesUrl from "~/styles/demos/about.css";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Link } from "remix";
|
||||
import { Link } from "@remix-run/react";
|
||||
|
||||
export default function AboutIndex() {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Link } from "remix";
|
||||
import { Link } from "@remix-run/react";
|
||||
|
||||
export default function AboutIndex() {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { ActionFunction } from "@remix-run/node";
|
||||
import { json, redirect } from "@remix-run/node";
|
||||
import { Form, useActionData } from "@remix-run/react";
|
||||
import { useEffect, useRef } from "react";
|
||||
import type { ActionFunction } from "remix";
|
||||
import { Form, json, useActionData, redirect } from "remix";
|
||||
|
||||
export function meta() {
|
||||
return { title: "Actions Demo" };
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCatch, Link, json, useLoaderData, Outlet } from "remix";
|
||||
import type { MetaFunction } from "@remix-run/node";
|
||||
import { json } from "@remix-run/node";
|
||||
import { Link, Outlet, useCatch, useLoaderData } from "@remix-run/react";
|
||||
|
||||
export function meta() {
|
||||
return { title: "Boundaries Demo" };
|
||||
}
|
||||
export let meta: MetaFunction = () => ({ title: "Boundaries Demo" });
|
||||
|
||||
export default function Boundaries() {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCatch, Link, json, useLoaderData } from "remix";
|
||||
import type { LoaderFunction, MetaFunction } from "remix";
|
||||
import type { LoaderFunction, MetaFunction } from "@remix-run/node";
|
||||
import { json } from "@remix-run/node";
|
||||
import { Link, useCatch, useLoaderData } from "@remix-run/react";
|
||||
|
||||
// The `$` in route filenames becomes a pattern that's parsed from the URL and
|
||||
// passed to your loaders so you can look up data.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCatch, Link, json, useLoaderData, Outlet } from "remix";
|
||||
import type { LoaderFunction } from "remix";
|
||||
import type { LoaderFunction } from "@remix-run/node";
|
||||
import { json } from "@remix-run/node";
|
||||
import { Link, Outlet, useCatch, useLoaderData } from "@remix-run/react";
|
||||
|
||||
export default function Boundaries() {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { MetaFunction, LoaderFunction } from "remix";
|
||||
import { useLoaderData, json, Link } from "remix";
|
||||
import type { MetaFunction, LoaderFunction } from "@remix-run/node";
|
||||
import { json } from "@remix-run/node";
|
||||
import { Link, useLoaderData } from "@remix-run/react";
|
||||
|
||||
type IndexData = {
|
||||
resources: Array<{ name: string; url: string }>;
|
||||
|
||||
8345
examples/remix/package-lock.json
generated
8345
examples/remix/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,28 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "remix-app-template",
|
||||
"description": "",
|
||||
"license": "",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "remix build",
|
||||
"dev": "remix dev",
|
||||
"postinstall": "remix setup node"
|
||||
"dev": "remix dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"@remix-run/react": "^1.0.6",
|
||||
"@remix-run/node": "^1.5.1",
|
||||
"@remix-run/react": "^1.5.1",
|
||||
"@remix-run/vercel": "^1.5.1",
|
||||
"@vercel/node": "^2.0.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"remix": "^1.0.6",
|
||||
"@remix-run/serve": "^1.0.6",
|
||||
"@remix-run/vercel": "^1.0.6"
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@remix-run/dev": "^1.0.6",
|
||||
"@types/react": "^17.0.24",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"typescript": "^4.1.2"
|
||||
"@remix-run/dev": "^1.5.1",
|
||||
"@remix-run/eslint-config": "^1.5.1",
|
||||
"@remix-run/serve": "^1.5.1",
|
||||
"@types/react": "^17.0.45",
|
||||
"@types/react-dom": "^17.0.17",
|
||||
"eslint": "^8.15.0",
|
||||
"typescript": "^4.6.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "14.x"
|
||||
},
|
||||
"sideEffects": false
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/**
|
||||
* @type {import('@remix-run/dev/config').AppConfig}
|
||||
* @type {import('@remix-run/dev').AppConfig}
|
||||
*/
|
||||
module.exports = {
|
||||
appDirectory: "app",
|
||||
browserBuildDirectory: "public/build",
|
||||
publicPath: "/build/",
|
||||
serverBuildDirectory: "api/_build"
|
||||
serverBuildTarget: "vercel",
|
||||
// When running locally in development mode, we use the built in remix
|
||||
// server. This does not understand the vercel lambda module format,
|
||||
// so we default back to the standard build output.
|
||||
server: process.env.NODE_ENV === "development" ? undefined : "./server.js",
|
||||
ignoredRouteFiles: ["**/.*"],
|
||||
// appDirectory: "app",
|
||||
// assetsBuildDirectory: "public/build",
|
||||
// serverBuildPath: "api/index.js",
|
||||
// publicPath: "/build/",
|
||||
};
|
||||
|
||||
4
examples/remix/server.js
Normal file
4
examples/remix/server.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as build from "@remix-run/dev/server-build";
|
||||
import { createRequestHandler } from "@remix-run/vercel";
|
||||
|
||||
export default createRequestHandler({ build, mode: process.env.NODE_ENV });
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"build": {
|
||||
"env": {
|
||||
"ENABLE_FILE_SYSTEM_API": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
1
examples/solidstart/.gitignore
vendored
1
examples/solidstart/.gitignore
vendored
@@ -2,6 +2,7 @@ dist
|
||||
worker
|
||||
.solid
|
||||
.vercel
|
||||
.output
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineConfig } from "vite";
|
||||
import solid from "solid-start";
|
||||
import vercel from "solid-start-vercel"
|
||||
import vercel from "solid-start-vercel";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [solid({ adapter: vercel() })]
|
||||
plugins: [solid({ adapter: vercel() })],
|
||||
});
|
||||
|
||||
1
examples/sveltekit/.gitignore
vendored
1
examples/sveltekit/.gitignore
vendored
@@ -7,3 +7,4 @@ node_modules
|
||||
.env.*
|
||||
!.env.example
|
||||
.vercel
|
||||
.output
|
||||
|
||||
13
examples/sveltekit/.prettierignore
Normal file
13
examples/sveltekit/.prettierignore
Normal file
@@ -0,0 +1,13 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
6
examples/sveltekit/.prettierrc
Normal file
6
examples/sveltekit/.prettierrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"printWidth": 100
|
||||
}
|
||||
@@ -14,31 +14,29 @@ If you're seeing this, you've probably already done this step. Congrats!
|
||||
|
||||
```bash
|
||||
# create a new project in the current directory
|
||||
npm init svelte@next
|
||||
npm init svelte
|
||||
|
||||
# create a new project in my-app
|
||||
npm init svelte@next my-app
|
||||
npm init svelte my-app
|
||||
```
|
||||
|
||||
> Note: the `@next` is temporary
|
||||
|
||||
## Developing
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||
Once you've created a project and installed dependencies with `pnpm install`, start a development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
pnpm run dev
|
||||
|
||||
# or start the server and open the app in a new browser tab
|
||||
npm run dev -- --open
|
||||
pnpm run dev -- --open
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
This uses the adapter-auto for SvelteKit, which detects Vercel and runs adapter-vercel on your behalf.
|
||||
To create a production version of your app:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.
|
||||
You can preview the production build with `npm run preview`.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"$lib": ["src/lib"],
|
||||
"$lib/*": ["src/lib/*"]
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
|
||||
}
|
||||
|
||||
1267
examples/sveltekit/package-lock.json
generated
1267
examples/sveltekit/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,30 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "sveltekit",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "svelte-kit dev",
|
||||
"build": "svelte-kit build",
|
||||
"package": "svelte-kit package",
|
||||
"preview": "svelte-kit preview"
|
||||
"preview": "svelte-kit preview",
|
||||
"prepare": "svelte-kit sync",
|
||||
"check": "svelte-check --tsconfig ./jsconfig.json",
|
||||
"check:watch": "svelte-check --tsconfig ./jsconfig.json --watch",
|
||||
"lint": "prettier --check --plugin-search-dir=. .",
|
||||
"format": "prettier --write --plugin-search-dir=. ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "next",
|
||||
"@sveltejs/kit": "next",
|
||||
"svelte": "^3.46.0"
|
||||
"@sveltejs/adapter-auto": "1.0.0-next.50",
|
||||
"@sveltejs/kit": "1.0.0-next.347",
|
||||
"@types/cookie": "^0.4.1",
|
||||
"prettier": "^2.5.1",
|
||||
"prettier-plugin-svelte": "^2.5.0",
|
||||
"svelte": "^3.46.0",
|
||||
"svelte-check": "^2.2.6",
|
||||
"typescript": "~4.6.2"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@fontsource/fira-mono": "^4.5.0",
|
||||
"@lukeed/uuid": "^2.0.0",
|
||||
"cookie": "^0.4.1"
|
||||
"cookie": "^0.4.1",
|
||||
"web-vitals": "^2.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
15
examples/sveltekit/src/app.d.ts
vendored
Normal file
15
examples/sveltekit/src/app.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/// <reference types="@sveltejs/kit" />
|
||||
|
||||
// See https://kit.svelte.dev/docs/types#app
|
||||
// for information about these interfaces
|
||||
declare namespace App {
|
||||
interface Locals {
|
||||
userid: string;
|
||||
}
|
||||
|
||||
// interface Platform {}
|
||||
|
||||
// interface Session {}
|
||||
|
||||
// interface Stuff {}
|
||||
}
|
||||
@@ -2,12 +2,11 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="description" content="Svelte demo app" />
|
||||
<link rel="icon" href="%svelte.assets%/favicon.png" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%svelte.head%
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body>
|
||||
<div>%svelte.body%</div>
|
||||
<div>%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import cookie from 'cookie';
|
||||
import { v4 as uuid } from '@lukeed/uuid';
|
||||
import * as cookie from 'cookie';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Handle} */
|
||||
export const handle = async ({ event, resolve }) => {
|
||||
const cookies = cookie.parse(event.request.headers.get('cookie') || '');
|
||||
event.locals.userid = cookies.userid || uuid();
|
||||
event.locals.userid = cookies['userid'] || crypto.randomUUID();
|
||||
|
||||
const response = await resolve(event);
|
||||
|
||||
if (!cookies.userid) {
|
||||
if (!cookies['userid']) {
|
||||
// if this is the first time the user has visited this app,
|
||||
// set a cookie so that we recognise them when they return
|
||||
response.headers.set(
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
$: displayed_count.set(count);
|
||||
$: offset = modulo($displayed_count, 1);
|
||||
|
||||
/**
|
||||
* @param {number} n
|
||||
* @param {number} m
|
||||
*/
|
||||
function modulo(n, m) {
|
||||
// handle negative numbers
|
||||
return ((n % m) + m) % m;
|
||||
@@ -50,6 +54,7 @@
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
touch-action: manipulation;
|
||||
color: var(--text-color);
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,36 @@ import { invalidate } from '$app/navigation';
|
||||
|
||||
// this action (https://svelte.dev/tutorial/actions) allows us to
|
||||
// progressively enhance a <form> that already works without JS
|
||||
/**
|
||||
* @param {HTMLFormElement} form
|
||||
* @param {{
|
||||
* pending?: ({ data, form }: { data: FormData; form: HTMLFormElement }) => void;
|
||||
* error?: ({
|
||||
* data,
|
||||
* form,
|
||||
* response,
|
||||
* error
|
||||
* }: {
|
||||
* data: FormData;
|
||||
* form: HTMLFormElement;
|
||||
* response: Response | null;
|
||||
* error: Error | null;
|
||||
* }) => void;
|
||||
* result?: ({
|
||||
* data,
|
||||
* form,
|
||||
* response
|
||||
* }: {
|
||||
* data: FormData;
|
||||
* response: Response;
|
||||
* form: HTMLFormElement;
|
||||
* }) => void;
|
||||
* }} [opts]
|
||||
*/
|
||||
export function enhance(form, { pending, error, result } = {}) {
|
||||
let current_token;
|
||||
|
||||
/** @param {SubmitEvent} e */
|
||||
async function handle_submit(e) {
|
||||
const token = (current_token = {});
|
||||
|
||||
@@ -37,7 +64,7 @@ export function enhance(form, { pending, error, result } = {}) {
|
||||
console.error(await response.text());
|
||||
}
|
||||
} catch (e) {
|
||||
if (error) {
|
||||
if (error && e instanceof Error) {
|
||||
error({ data, form, error: e, response: null });
|
||||
} else {
|
||||
throw e;
|
||||
|
||||
66
examples/sveltekit/src/lib/vitals.js
Normal file
66
examples/sveltekit/src/lib/vitals.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { getCLS, getFCP, getFID, getLCP, getTTFB } from 'web-vitals';
|
||||
|
||||
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals';
|
||||
|
||||
function getConnectionSpeed() {
|
||||
return 'connection' in navigator &&
|
||||
navigator['connection'] &&
|
||||
'effectiveType' in navigator['connection']
|
||||
? // @ts-ignore
|
||||
navigator['connection']['effectiveType']
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("web-vitals").Metric} metric
|
||||
* @param {{ params: { [s: string]: any; } | ArrayLike<any>; path: string; analyticsId: string; debug: boolean; }} options
|
||||
*/
|
||||
function sendToAnalytics(metric, options) {
|
||||
const page = Object.entries(options.params).reduce(
|
||||
(acc, [key, value]) => acc.replace(value, `[${key}]`),
|
||||
options.path
|
||||
);
|
||||
|
||||
const body = {
|
||||
dsn: options.analyticsId,
|
||||
id: metric.id,
|
||||
page,
|
||||
href: location.href,
|
||||
event_name: metric.name,
|
||||
value: metric.value.toString(),
|
||||
speed: getConnectionSpeed()
|
||||
};
|
||||
|
||||
if (options.debug) {
|
||||
console.log('[Analytics]', metric.name, JSON.stringify(body, null, 2));
|
||||
}
|
||||
|
||||
const blob = new Blob([new URLSearchParams(body).toString()], {
|
||||
// This content type is necessary for `sendBeacon`
|
||||
type: 'application/x-www-form-urlencoded'
|
||||
});
|
||||
if (navigator.sendBeacon) {
|
||||
navigator.sendBeacon(vitalsUrl, blob);
|
||||
} else
|
||||
fetch(vitalsUrl, {
|
||||
body: blob,
|
||||
method: 'POST',
|
||||
credentials: 'omit',
|
||||
keepalive: true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} options
|
||||
*/
|
||||
export function webVitals(options) {
|
||||
try {
|
||||
getFID((metric) => sendToAnalytics(metric, options));
|
||||
getTTFB((metric) => sendToAnalytics(metric, options));
|
||||
getLCP((metric) => sendToAnalytics(metric, options));
|
||||
getCLS((metric) => sendToAnalytics(metric, options));
|
||||
getFCP((metric) => sendToAnalytics(metric, options));
|
||||
} catch (err) {
|
||||
console.error('[Analytics]', err);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,19 @@
|
||||
<script>
|
||||
import Header from '$lib/header/Header.svelte';
|
||||
import { webVitals } from '$lib/vitals';
|
||||
import { browser } from '$app/env';
|
||||
import { page } from '$app/stores';
|
||||
import '../app.css';
|
||||
|
||||
let analyticsId = import.meta.env.VERCEL_ANALYTICS_ID;
|
||||
|
||||
$: if (browser && analyticsId) {
|
||||
webVitals({
|
||||
path: $page.url.pathname,
|
||||
params: $page.params,
|
||||
analyticsId
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<Header />
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<svelte:head>
|
||||
<title>About</title>
|
||||
<meta name="description" content="About this app" />
|
||||
</svelte:head>
|
||||
|
||||
<div class="content">
|
||||
@@ -26,8 +27,7 @@
|
||||
following into your command line and following the prompts:
|
||||
</p>
|
||||
|
||||
<!-- TODO lose the @next! -->
|
||||
<pre>npm init svelte@next</pre>
|
||||
<pre>npm init svelte</pre>
|
||||
|
||||
<p>
|
||||
The page you're looking at is purely static HTML, with no client-side interactivity needed.
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<svelte:head>
|
||||
<title>Home</title>
|
||||
<meta name="description" content="Svelte demo app" />
|
||||
</svelte:head>
|
||||
|
||||
<section>
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
|
||||
const base = 'https://api.svelte.dev';
|
||||
|
||||
/**
|
||||
* @param {string} method
|
||||
* @param {string} resource
|
||||
* @param {Record<string, unknown>} [data]
|
||||
*/
|
||||
export function api(method, resource, data) {
|
||||
return fetch(`${base}/${resource}`, {
|
||||
method,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { api } from './_api';
|
||||
|
||||
/** @type {import('./__types').RequestHandler} */
|
||||
export const get = async ({ locals }) => {
|
||||
// locals.userid comes from src/hooks.js
|
||||
const response = await api('get', `todos/${locals.userid}`);
|
||||
@@ -27,6 +28,7 @@ export const get = async ({ locals }) => {
|
||||
};
|
||||
};
|
||||
|
||||
/** @type {import('./index').RequestHandler} */
|
||||
export const post = async ({ request, locals }) => {
|
||||
const form = await request.formData();
|
||||
|
||||
@@ -46,6 +48,7 @@ const redirect = {
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {import('./index').RequestHandler} */
|
||||
export const patch = async ({ request, locals }) => {
|
||||
const form = await request.formData();
|
||||
|
||||
@@ -57,6 +60,7 @@ export const patch = async ({ request, locals }) => {
|
||||
return redirect;
|
||||
};
|
||||
|
||||
/** @type {import('./index').RequestHandler} */
|
||||
export const del = async ({ request, locals }) => {
|
||||
const form = await request.formData();
|
||||
|
||||
|
||||
@@ -3,11 +3,23 @@
|
||||
import { scale } from 'svelte/transition';
|
||||
import { flip } from 'svelte/animate';
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* uid: string;
|
||||
* created_at: Date;
|
||||
* text: string;
|
||||
* done: boolean;
|
||||
* pending_delete: boolean;
|
||||
* }} Todo
|
||||
*/
|
||||
|
||||
/** @type {Todo[]} */
|
||||
export let todos;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Todos</title>
|
||||
<meta name="description" content="A todo list app" />
|
||||
</svelte:head>
|
||||
|
||||
<div class="todos">
|
||||
|
||||
@@ -8,6 +8,11 @@ const config = {
|
||||
// Override http methods in the Todo forms
|
||||
methodOverride: {
|
||||
allowed: ['PATCH', 'DELETE']
|
||||
},
|
||||
vite: {
|
||||
define: {
|
||||
'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
1479
examples/sveltekit/yarn.lock
Normal file
1479
examples/sveltekit/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -30,8 +30,8 @@
|
||||
"npm-package-arg": "6.1.0",
|
||||
"prettier": "2.6.2",
|
||||
"ts-eager": "2.0.2",
|
||||
"ts-jest": "28.0.0-next.1",
|
||||
"turbo": "1.2.9"
|
||||
"ts-jest": "28.0.5",
|
||||
"turbo": "1.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
"lerna": "lerna",
|
||||
@@ -41,7 +41,7 @@
|
||||
"publish-from-github": "./utils/publish.sh",
|
||||
"changelog": "node utils/changelog.js",
|
||||
"build": "turbo run build",
|
||||
"vercel-build": "yarn build && cd api && node -r ts-eager/register ./_lib/script/build.ts",
|
||||
"vercel-build": "yarn build && yarn run pack && cd api && node -r ts-eager/register ./_lib/script/build.ts",
|
||||
"pre-commit": "lint-staged",
|
||||
"test": "jest --rootDir=\"test\" --testPathPattern=\"\\.test.js\"",
|
||||
"test-unit": "yarn test && turbo run test-unit",
|
||||
@@ -49,7 +49,8 @@
|
||||
"test-integration-once": "turbo run test-integration-once",
|
||||
"test-integration-dev": "turbo run test-integration-dev",
|
||||
"lint": "eslint . --ext .ts,.js",
|
||||
"prepare": "husky install"
|
||||
"prepare": "husky install",
|
||||
"pack": "cd utils && node -r ts-eager/register ./pack.ts"
|
||||
},
|
||||
"lint-staged": {
|
||||
"./{*,{api,packages,test,utils}/**/*}.{js,ts}": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "3.1.0",
|
||||
"version": "5.0.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
@@ -23,7 +23,7 @@
|
||||
"@types/cross-spawn": "6.0.0",
|
||||
"@types/end-of-stream": "^1.4.0",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/glob": "7.2.0",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/js-yaml": "3.12.1",
|
||||
"@types/ms": "0.7.31",
|
||||
@@ -31,7 +31,6 @@
|
||||
"@types/node-fetch": "^2.1.6",
|
||||
"@types/semver": "6.0.0",
|
||||
"@types/yazl": "2.4.2",
|
||||
"@vercel/frameworks": "0.9.1",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"aggregate-error": "3.0.1",
|
||||
"async-retry": "1.2.3",
|
||||
@@ -40,7 +39,7 @@
|
||||
"cross-spawn": "6.0.5",
|
||||
"end-of-stream": "1.4.1",
|
||||
"fs-extra": "10.0.0",
|
||||
"glob": "7.1.3",
|
||||
"glob": "8.0.3",
|
||||
"into-stream": "5.0.0",
|
||||
"js-yaml": "3.13.1",
|
||||
"minimatch": "3.0.4",
|
||||
|
||||
@@ -3,6 +3,7 @@ import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import Sema from 'async-sema';
|
||||
import spawn from 'cross-spawn';
|
||||
import { coerce, intersects, validRange } from 'semver';
|
||||
import { SpawnOptions } from 'child_process';
|
||||
import { deprecate } from 'util';
|
||||
import debug from '../debug';
|
||||
@@ -60,6 +61,13 @@ export interface SpawnOptionsExtended extends SpawnOptions {
|
||||
* Pretty formatted command that is being spawned for logging purposes.
|
||||
*/
|
||||
prettyCommand?: string;
|
||||
|
||||
/**
|
||||
* Returns instead of throwing an error when the process exits with a
|
||||
* non-0 exit code. When relevant, the returned object will include
|
||||
* the error code, stdout and stderr.
|
||||
*/
|
||||
ignoreNon0Exit?: boolean;
|
||||
}
|
||||
|
||||
export function spawnAsync(
|
||||
@@ -78,7 +86,7 @@ export function spawnAsync(
|
||||
|
||||
child.on('error', reject);
|
||||
child.on('close', (code, signal) => {
|
||||
if (code === 0) {
|
||||
if (code === 0 || opts.ignoreNon0Exit) {
|
||||
return resolve();
|
||||
}
|
||||
|
||||
@@ -122,7 +130,14 @@ export function execAsync(
|
||||
|
||||
child.on('error', reject);
|
||||
child.on('close', (code, signal) => {
|
||||
if (code !== 0) {
|
||||
if (code === 0 || opts.ignoreNon0Exit) {
|
||||
return resolve({
|
||||
code,
|
||||
stdout: Buffer.concat(stdoutList).toString(),
|
||||
stderr: Buffer.concat(stderrList).toString(),
|
||||
});
|
||||
}
|
||||
|
||||
const cmd = opts.prettyCommand
|
||||
? `Command "${opts.prettyCommand}"`
|
||||
: 'Command';
|
||||
@@ -133,13 +148,6 @@ export function execAsync(
|
||||
message: `${cmd} exited with ${code || signal}`,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return resolve({
|
||||
code,
|
||||
stdout: Buffer.concat(stdoutList).toString(),
|
||||
stderr: Buffer.concat(stderrList).toString(),
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -165,9 +173,30 @@ export async function execCommand(command: string, options: SpawnOptions = {}) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function getNodeBinPath({ cwd }: { cwd: string }) {
|
||||
const { stdout } = await execAsync('npm', ['bin'], { cwd });
|
||||
return stdout.trim();
|
||||
export async function getNodeBinPath({
|
||||
cwd,
|
||||
}: {
|
||||
cwd: string;
|
||||
}): Promise<string> {
|
||||
const { code, stdout, stderr } = await execAsync('npm', ['bin'], {
|
||||
cwd,
|
||||
prettyCommand: 'npm bin',
|
||||
|
||||
// in some rare cases, we saw `npm bin` exit with a non-0 code, but still
|
||||
// output the right bin path, so we ignore the exit code
|
||||
ignoreNon0Exit: true,
|
||||
});
|
||||
|
||||
const nodeBinPath = stdout.trim();
|
||||
|
||||
if (path.isAbsolute(nodeBinPath)) {
|
||||
return nodeBinPath;
|
||||
}
|
||||
|
||||
throw new NowBuildError({
|
||||
code: `BUILD_UTILS_GET_NODE_BIN_PATH`,
|
||||
message: `Running \`npm bin\` failed to return a valid bin path (code=${code}, stdout=${stdout}, stderr=${stderr})`,
|
||||
});
|
||||
}
|
||||
|
||||
async function chmodPlusX(fsPath: string) {
|
||||
@@ -204,8 +233,23 @@ export function getSpawnOptions(
|
||||
};
|
||||
|
||||
if (!meta.isDev) {
|
||||
// Ensure that the selected Node version is at the beginning of the `$PATH`
|
||||
opts.env.PATH = `/node${nodeVersion.major}/bin:${opts.env.PATH}`;
|
||||
let found = false;
|
||||
const oldPath = opts.env.PATH || process.env.PATH || '';
|
||||
|
||||
const pathSegments = oldPath.split(path.delimiter).map(segment => {
|
||||
if (/^\/node[0-9]+\/bin/.test(segment)) {
|
||||
found = true;
|
||||
return `/node${nodeVersion.major}/bin`;
|
||||
}
|
||||
return segment;
|
||||
});
|
||||
|
||||
if (!found) {
|
||||
// If we didn't find & replace, prepend at beginning of PATH
|
||||
pathSegments.unshift(`/node${nodeVersion.major}/bin`);
|
||||
}
|
||||
|
||||
opts.env.PATH = pathSegments.filter(Boolean).join(path.delimiter);
|
||||
}
|
||||
|
||||
return opts;
|
||||
@@ -217,9 +261,9 @@ export async function getNodeVersion(
|
||||
config: Config = {},
|
||||
meta: Meta = {}
|
||||
): Promise<NodeVersion> {
|
||||
const latest = getLatestNodeVersion();
|
||||
if (meta && meta.isDev) {
|
||||
// Use the system-installed version of `node` in PATH for `vercel dev`
|
||||
const latest = getLatestNodeVersion();
|
||||
return { ...latest, runtime: 'nodejs' };
|
||||
}
|
||||
const { packageJson } = await scanParentDirs(destPath, true);
|
||||
@@ -227,10 +271,27 @@ export async function getNodeVersion(
|
||||
let isAuto = true;
|
||||
if (packageJson && packageJson.engines && packageJson.engines.node) {
|
||||
const { node } = packageJson.engines;
|
||||
if (nodeVersion && nodeVersion !== node && !meta.isDev) {
|
||||
if (
|
||||
nodeVersion &&
|
||||
validRange(node) &&
|
||||
!intersects(nodeVersion, node) &&
|
||||
!meta.isDev
|
||||
) {
|
||||
console.warn(
|
||||
`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${nodeVersion}") will not apply. Learn More: http://vercel.link/node-version`
|
||||
);
|
||||
} else if (coerce(node)?.raw === node && !meta.isDev) {
|
||||
console.warn(
|
||||
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version`
|
||||
);
|
||||
} else if (
|
||||
validRange(node) &&
|
||||
intersects(`${latest.major + 1}.x`, node) &&
|
||||
!meta.isDev
|
||||
) {
|
||||
console.warn(
|
||||
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version`
|
||||
);
|
||||
}
|
||||
nodeVersion = node;
|
||||
isAuto = false;
|
||||
@@ -426,20 +487,31 @@ export function getEnvForPackageManager({
|
||||
env: { [x: string]: string | undefined };
|
||||
}) {
|
||||
const newEnv: { [x: string]: string | undefined } = { ...env };
|
||||
const oldPath = env.PATH + '';
|
||||
const npm7 = '/node16/bin-npm7';
|
||||
const pnpm7 = '/pnpm7/node_modules/.bin';
|
||||
const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === '1';
|
||||
if (cliType === 'npm') {
|
||||
if (
|
||||
typeof lockfileVersion === 'number' &&
|
||||
lockfileVersion >= 2 &&
|
||||
(nodeVersion?.major || 0) < 16
|
||||
(nodeVersion?.major || 0) < 16 &&
|
||||
!oldPath.includes(npm7) &&
|
||||
!corepackEnabled
|
||||
) {
|
||||
// Ensure that npm 7 is at the beginning of the `$PATH`
|
||||
newEnv.PATH = `/node16/bin-npm7:${env.PATH}`;
|
||||
console.log('Detected `package-lock.json` generated by npm 7...');
|
||||
newEnv.PATH = `${npm7}${path.delimiter}${oldPath}`;
|
||||
console.log('Detected `package-lock.json` generated by npm 7+...');
|
||||
}
|
||||
} else if (cliType === 'pnpm') {
|
||||
if (typeof lockfileVersion === 'number' && lockfileVersion === 5.4) {
|
||||
if (
|
||||
typeof lockfileVersion === 'number' &&
|
||||
lockfileVersion === 5.4 &&
|
||||
!oldPath.includes(pnpm7) &&
|
||||
!corepackEnabled
|
||||
) {
|
||||
// Ensure that pnpm 7 is at the beginning of the `$PATH`
|
||||
newEnv.PATH = `/pnpm7/node_modules/.bin:${env.PATH}`;
|
||||
newEnv.PATH = `${pnpm7}${path.delimiter}${oldPath}`;
|
||||
console.log('Detected `pnpm-lock.yaml` generated by pnpm 7...');
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -80,15 +80,6 @@ export {
|
||||
};
|
||||
|
||||
export { EdgeFunction } from './edge-function';
|
||||
export {
|
||||
detectBuilders,
|
||||
detectOutputDirectory,
|
||||
detectApiDirectory,
|
||||
detectApiExtensions,
|
||||
} from './detect-builders';
|
||||
export { detectFileSystemAPI } from './detect-file-system-api';
|
||||
export { detectFramework } from './detect-framework';
|
||||
export { DetectorFilesystem } from './detectors/filesystem';
|
||||
export { readConfigFile } from './fs/read-config-file';
|
||||
export { normalizePath } from './fs/normalize-path';
|
||||
|
||||
@@ -96,24 +87,3 @@ export * from './should-serve';
|
||||
export * from './schemas';
|
||||
export * from './types';
|
||||
export * from './errors';
|
||||
|
||||
/**
|
||||
* Helper function to support both `@vercel` and legacy `@now` official Runtimes.
|
||||
*/
|
||||
export const isOfficialRuntime = (desired: string, name?: string): boolean => {
|
||||
if (typeof name !== 'string') {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
name === `@vercel/${desired}` ||
|
||||
name === `@now/${desired}` ||
|
||||
name.startsWith(`@vercel/${desired}@`) ||
|
||||
name.startsWith(`@now/${desired}@`)
|
||||
);
|
||||
};
|
||||
|
||||
export const isStaticRuntime = (name?: string): boolean => {
|
||||
return isOfficialRuntime('static', name);
|
||||
};
|
||||
|
||||
export { workspaceManagers } from './workspaces/workspace-managers';
|
||||
|
||||
@@ -82,7 +82,7 @@ export interface BuildOptions {
|
||||
* is the Git Repository Root. This is only relevant for Monorepos.
|
||||
* See https://vercel.com/blog/monorepos
|
||||
*/
|
||||
repoRootPath?: string;
|
||||
repoRootPath: string;
|
||||
|
||||
/**
|
||||
* An arbitrary object passed by the user in the build definition defined
|
||||
@@ -123,7 +123,7 @@ export interface PrepareCacheOptions {
|
||||
* is the Git Repository Root. This is only relevant for Monorepos.
|
||||
* See https://vercel.com/blog/monorepos
|
||||
*/
|
||||
repoRootPath?: string;
|
||||
repoRootPath: string;
|
||||
|
||||
/**
|
||||
* An arbitrary object passed by the user in the build definition defined
|
||||
@@ -295,6 +295,7 @@ export interface PackageJson {
|
||||
readonly preferGlobal?: boolean;
|
||||
readonly private?: boolean;
|
||||
readonly publishConfig?: PackageJson.PublishConfig;
|
||||
readonly packageManager?: string;
|
||||
}
|
||||
|
||||
export interface NodeVersion {
|
||||
@@ -327,6 +328,7 @@ export interface ProjectSettings {
|
||||
buildCommand?: string | null;
|
||||
outputDirectory?: string | null;
|
||||
rootDirectory?: string | null;
|
||||
nodeVersion?: string;
|
||||
createdAt?: number;
|
||||
autoExposeSystemEnvs?: boolean;
|
||||
sourceFilesOutsideRootDirectory?: boolean;
|
||||
@@ -351,11 +353,41 @@ export interface BuilderV3 {
|
||||
|
||||
type ImageFormat = 'image/avif' | 'image/webp';
|
||||
|
||||
export type RemotePattern = {
|
||||
/**
|
||||
* Must be `http` or `https`.
|
||||
*/
|
||||
protocol?: 'http' | 'https';
|
||||
|
||||
/**
|
||||
* Can be literal or wildcard.
|
||||
* Single `*` matches a single subdomain.
|
||||
* Double `**` matches any number of subdomains.
|
||||
*/
|
||||
hostname: string;
|
||||
|
||||
/**
|
||||
* Can be literal port such as `8080` or empty string
|
||||
* meaning no port.
|
||||
*/
|
||||
port?: string;
|
||||
|
||||
/**
|
||||
* Can be literal or wildcard.
|
||||
* Single `*` matches a single path segment.
|
||||
* Double `**` matches any number of path segments.
|
||||
*/
|
||||
pathname?: string;
|
||||
};
|
||||
|
||||
export interface Images {
|
||||
domains: string[];
|
||||
remotePatterns?: RemotePattern[];
|
||||
sizes: number[];
|
||||
minimumCacheTTL?: number;
|
||||
formats?: ImageFormat[];
|
||||
dangerouslyAllowSVG?: boolean;
|
||||
contentSecurityPolicy?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,7 +428,9 @@ export interface BuildResultV2Typical {
|
||||
export type BuildResultV2 = BuildResultV2Typical | BuildResultBuildOutput;
|
||||
|
||||
export interface BuildResultV3 {
|
||||
output: Lambda;
|
||||
// TODO: use proper `Route` type from `routing-utils` (perhaps move types to a common package)
|
||||
routes?: any[];
|
||||
output: Lambda | EdgeFunction;
|
||||
}
|
||||
|
||||
export type BuildV2 = (options: BuildOptions) => Promise<BuildResultV2>;
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
import type { Framework } from '@vercel/frameworks';
|
||||
|
||||
/**
|
||||
* The supported list of workspace managers.
|
||||
*
|
||||
* This list is designed to work with the @see {@link detectFramework} function.
|
||||
*
|
||||
* @example
|
||||
* import { workspaceManagers as frameworkList } from '@vercel/build-utils/workspaces'
|
||||
* import { detectFramework } from '@vercel/build-utils'
|
||||
*
|
||||
* const fs = new GitDetectorFilesystem(...)
|
||||
* detectFramwork({ fs, frameworkList }) // returns the 'slug' field if detected, otherwise null
|
||||
*
|
||||
* @todo Will be used by the detect-eligible-projects API endpoint for a given git url.
|
||||
*/
|
||||
export const workspaceManagers: Array<Framework> = [
|
||||
{
|
||||
name: 'Yarn',
|
||||
slug: 'yarn',
|
||||
detectors: {
|
||||
every: [
|
||||
{
|
||||
path: 'package.json',
|
||||
matchContent:
|
||||
'"workspaces":\\s*(?:\\[[^\\]]*]|{[^}]*"packages":[^}]*})',
|
||||
},
|
||||
{
|
||||
path: 'yarn.lock',
|
||||
},
|
||||
],
|
||||
},
|
||||
// unused props - needed for typescript
|
||||
description: '',
|
||||
logo: '',
|
||||
settings: {
|
||||
buildCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
devCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
installCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
outputDirectory: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
},
|
||||
getOutputDirName: () => Promise.resolve(''),
|
||||
},
|
||||
{
|
||||
name: 'pnpm',
|
||||
slug: 'pnpm',
|
||||
detectors: {
|
||||
every: [
|
||||
{
|
||||
path: 'pnpm-workspace.yaml',
|
||||
},
|
||||
],
|
||||
},
|
||||
// unused props - needed for typescript
|
||||
description: '',
|
||||
logo: '',
|
||||
settings: {
|
||||
buildCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
devCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
installCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
outputDirectory: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
},
|
||||
getOutputDirName: () => Promise.resolve(''),
|
||||
},
|
||||
{
|
||||
name: 'npm',
|
||||
slug: 'npm',
|
||||
detectors: {
|
||||
every: [
|
||||
{
|
||||
path: 'package.json',
|
||||
matchContent:
|
||||
'"workspaces":\\s*(?:\\[[^\\]]*]|{[^}]*"packages":[^}]*})',
|
||||
},
|
||||
{
|
||||
path: 'package-lock.json',
|
||||
},
|
||||
],
|
||||
},
|
||||
// unused props - needed for typescript
|
||||
description: '',
|
||||
logo: '',
|
||||
settings: {
|
||||
buildCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
devCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
installCommand: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
outputDirectory: {
|
||||
value: '',
|
||||
placeholder: '',
|
||||
},
|
||||
},
|
||||
getOutputDirName: () => Promise.resolve(''),
|
||||
},
|
||||
];
|
||||
|
||||
export default workspaceManagers;
|
||||
@@ -1 +0,0 @@
|
||||
# users.rb
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"functions": {
|
||||
"api/users.rb": {
|
||||
"memory": 3008
|
||||
},
|
||||
"api/doesnt-exist.rb": {
|
||||
"memory": 768
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
# [id].py
|
||||
@@ -1 +0,0 @@
|
||||
# index
|
||||
@@ -1 +0,0 @@
|
||||
# project/[aid]/[bid]/index.py
|
||||
@@ -1 +0,0 @@
|
||||
# get
|
||||
@@ -1 +0,0 @@
|
||||
# post
|
||||
@@ -1 +0,0 @@
|
||||
This file should also be included
|
||||
@@ -1 +0,0 @@
|
||||
# date
|
||||
@@ -1 +0,0 @@
|
||||
# math
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"functions": {
|
||||
"api/users/post.py": {
|
||||
"memory": 3008
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,13 @@ checkPkgOrThrow('exeggcute');
|
||||
|
||||
// This is to satisfy `@vercel/static-build` which needs a `dist` directory.
|
||||
const { exec } = require('exeggcute');
|
||||
exec('mkdir dist', __dirname);
|
||||
exec('echo "node-env:RANDOMNESS_PLACEHOLDER" > dist/index.html', __dirname);
|
||||
exec('mkdir dist', __dirname)
|
||||
.then(() => {
|
||||
exec(
|
||||
'echo "node-env:RANDOMNESS_PLACEHOLDER" > dist/index.html',
|
||||
__dirname
|
||||
).then(() => {
|
||||
console.log('Success');
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
@@ -6,5 +6,10 @@ const b = require('./b');
|
||||
a();
|
||||
b();
|
||||
|
||||
exec('mkdir public', __dirname);
|
||||
exec('echo "Hello, World!" > public/index.html', __dirname);
|
||||
exec('mkdir public', __dirname)
|
||||
.then(() => {
|
||||
exec('echo "Hello, World!" > public/index.html', __dirname).then(() => {
|
||||
console.log('Success');
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
15
packages/build-utils/test/fixtures/26-multiple-lock-files-pnpm/a/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/26-multiple-lock-files-pnpm/a/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "a",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.2"
|
||||
}
|
||||
}
|
||||
15
packages/build-utils/test/fixtures/26-multiple-lock-files-pnpm/b/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/26-multiple-lock-files-pnpm/b/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "b",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cowsay": "^1.5.0"
|
||||
}
|
||||
}
|
||||
249
packages/build-utils/test/fixtures/26-multiple-lock-files-pnpm/pnpm-lock.yaml
generated
vendored
249
packages/build-utils/test/fixtures/26-multiple-lock-files-pnpm/pnpm-lock.yaml
generated
vendored
@@ -1,19 +1,260 @@
|
||||
lockfileVersion: 5.3
|
||||
lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
importers:
|
||||
|
||||
.:
|
||||
specifiers:
|
||||
once: ^1.4.0
|
||||
|
||||
dependencies:
|
||||
dependencies:
|
||||
once: 1.4.0
|
||||
|
||||
a:
|
||||
specifiers:
|
||||
debug: ^4.3.2
|
||||
dependencies:
|
||||
debug: 4.3.4
|
||||
|
||||
b:
|
||||
specifiers:
|
||||
cowsay: ^1.5.0
|
||||
dependencies:
|
||||
cowsay: 1.5.0
|
||||
|
||||
packages:
|
||||
|
||||
/ansi-regex/3.0.1:
|
||||
resolution: {integrity: sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==}
|
||||
engines: {node: '>=4'}
|
||||
dev: false
|
||||
|
||||
/ansi-regex/5.0.1:
|
||||
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/ansi-styles/4.3.0:
|
||||
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
color-convert: 2.0.1
|
||||
dev: false
|
||||
|
||||
/camelcase/5.3.1:
|
||||
resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==}
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/cliui/6.0.0:
|
||||
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
|
||||
dependencies:
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
wrap-ansi: 6.2.0
|
||||
dev: false
|
||||
|
||||
/color-convert/2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
dev: false
|
||||
|
||||
/color-name/1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
dev: false
|
||||
|
||||
/cowsay/1.5.0:
|
||||
resolution: {integrity: sha512-8Ipzr54Z8zROr/62C8f0PdhQcDusS05gKTS87xxdji8VbWefWly0k8BwGK7+VqamOrkv3eGsCkPtvlHzrhWsCA==}
|
||||
engines: {node: '>= 4'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
get-stdin: 8.0.0
|
||||
string-width: 2.1.1
|
||||
strip-final-newline: 2.0.0
|
||||
yargs: 15.4.1
|
||||
dev: false
|
||||
|
||||
/debug/4.3.4:
|
||||
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
||||
engines: {node: '>=6.0'}
|
||||
peerDependencies:
|
||||
supports-color: '*'
|
||||
peerDependenciesMeta:
|
||||
supports-color:
|
||||
optional: true
|
||||
dependencies:
|
||||
ms: 2.1.2
|
||||
dev: false
|
||||
|
||||
/decamelize/1.2.0:
|
||||
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/emoji-regex/8.0.0:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
dev: false
|
||||
|
||||
/find-up/4.1.0:
|
||||
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
locate-path: 5.0.0
|
||||
path-exists: 4.0.0
|
||||
dev: false
|
||||
|
||||
/get-caller-file/2.0.5:
|
||||
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
|
||||
engines: {node: 6.* || 8.* || >= 10.*}
|
||||
dev: false
|
||||
|
||||
/get-stdin/8.0.0:
|
||||
resolution: {integrity: sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==}
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/is-fullwidth-code-point/2.0.0:
|
||||
resolution: {integrity: sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==}
|
||||
engines: {node: '>=4'}
|
||||
dev: false
|
||||
|
||||
/is-fullwidth-code-point/3.0.0:
|
||||
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/locate-path/5.0.0:
|
||||
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
p-locate: 4.1.0
|
||||
dev: false
|
||||
|
||||
/ms/2.1.2:
|
||||
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
|
||||
dev: false
|
||||
|
||||
/once/1.4.0:
|
||||
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
|
||||
dependencies:
|
||||
wrappy: 1.0.2
|
||||
dev: false
|
||||
|
||||
/p-limit/2.3.0:
|
||||
resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==}
|
||||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
p-try: 2.2.0
|
||||
dev: false
|
||||
|
||||
/p-locate/4.1.0:
|
||||
resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
p-limit: 2.3.0
|
||||
dev: false
|
||||
|
||||
/p-try/2.2.0:
|
||||
resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==}
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/path-exists/4.0.0:
|
||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/require-directory/2.1.1:
|
||||
resolution: {integrity: sha1-jGStX9MNqxyXbiNE/+f3kqam30I=}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/require-main-filename/2.0.0:
|
||||
resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==}
|
||||
dev: false
|
||||
|
||||
/set-blocking/2.0.0:
|
||||
resolution: {integrity: sha1-BF+XgtARrppoA93TgrJDkrPYkPc=}
|
||||
dev: false
|
||||
|
||||
/string-width/2.1.1:
|
||||
resolution: {integrity: sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==}
|
||||
engines: {node: '>=4'}
|
||||
dependencies:
|
||||
is-fullwidth-code-point: 2.0.0
|
||||
strip-ansi: 4.0.0
|
||||
dev: false
|
||||
|
||||
/string-width/4.2.3:
|
||||
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
emoji-regex: 8.0.0
|
||||
is-fullwidth-code-point: 3.0.0
|
||||
strip-ansi: 6.0.1
|
||||
dev: false
|
||||
|
||||
/strip-ansi/4.0.0:
|
||||
resolution: {integrity: sha1-qEeQIusaw2iocTibY1JixQXuNo8=}
|
||||
engines: {node: '>=4'}
|
||||
dependencies:
|
||||
ansi-regex: 3.0.1
|
||||
dev: false
|
||||
|
||||
/strip-ansi/6.0.1:
|
||||
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
ansi-regex: 5.0.1
|
||||
dev: false
|
||||
|
||||
/strip-final-newline/2.0.0:
|
||||
resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==}
|
||||
engines: {node: '>=6'}
|
||||
dev: false
|
||||
|
||||
/which-module/2.0.0:
|
||||
resolution: {integrity: sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=}
|
||||
dev: false
|
||||
|
||||
/wrap-ansi/6.2.0:
|
||||
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
dev: false
|
||||
|
||||
/wrappy/1.0.2:
|
||||
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
|
||||
dev: false
|
||||
|
||||
/y18n/4.0.3:
|
||||
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
|
||||
dev: false
|
||||
|
||||
/yargs-parser/18.1.3:
|
||||
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
|
||||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
camelcase: 5.3.1
|
||||
decamelize: 1.2.0
|
||||
dev: false
|
||||
|
||||
/yargs/15.4.1:
|
||||
resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
cliui: 6.0.0
|
||||
decamelize: 1.2.0
|
||||
find-up: 4.1.0
|
||||
get-caller-file: 2.0.5
|
||||
require-directory: 2.1.1
|
||||
require-main-filename: 2.0.0
|
||||
set-blocking: 2.0.0
|
||||
string-width: 4.2.3
|
||||
which-module: 2.0.0
|
||||
y18n: 4.0.3
|
||||
yargs-parser: 18.1.3
|
||||
dev: false
|
||||
|
||||
144
packages/build-utils/test/integration.test.ts
vendored
144
packages/build-utils/test/integration.test.ts
vendored
@@ -5,7 +5,6 @@ import {
|
||||
testDeployment,
|
||||
// @ts-ignore
|
||||
} from '../../../test/lib/deployment/test-deployment';
|
||||
import { glob, detectBuilders } from '../src';
|
||||
|
||||
jest.setTimeout(4 * 60 * 1000);
|
||||
|
||||
@@ -32,7 +31,6 @@ const skipFixtures: string[] = [
|
||||
'08-zero-config-middleman',
|
||||
'21-npm-workspaces',
|
||||
'23-pnpm-workspaces',
|
||||
'27-yarn-workspaces',
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
@@ -79,145 +77,3 @@ for (const builder of buildersToTestWith) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it('Test `detectBuilders` and `detectRoutes`', async () => {
|
||||
const fixture = path.join(__dirname, 'fixtures', '01-zero-config-api');
|
||||
const pkg = await fs.readJSON(path.join(fixture, 'package.json'));
|
||||
const fileList = await glob('**', fixture);
|
||||
const files = Object.keys(fileList);
|
||||
|
||||
const probes = [
|
||||
{
|
||||
path: '/api/my-endpoint',
|
||||
mustContain: 'my-endpoint',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/other-endpoint',
|
||||
mustContain: 'other-endpoint',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/team/zeit',
|
||||
mustContain: 'team/zeit',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/user/myself',
|
||||
mustContain: 'user/myself',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/not-okay/',
|
||||
status: 404,
|
||||
},
|
||||
{
|
||||
path: '/api',
|
||||
status: 404,
|
||||
},
|
||||
{
|
||||
path: '/api/',
|
||||
status: 404,
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
mustContain: 'hello from index.txt',
|
||||
},
|
||||
];
|
||||
|
||||
const { builders, defaultRoutes } = await detectBuilders(files, pkg);
|
||||
|
||||
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
|
||||
|
||||
await fs.writeFile(
|
||||
path.join(fixture, 'now.json'),
|
||||
JSON.stringify(nowConfig, null, 2)
|
||||
);
|
||||
|
||||
const deployment = await testDeployment(
|
||||
{ builderUrl, buildUtilsUrl },
|
||||
fixture
|
||||
);
|
||||
expect(deployment).toBeDefined();
|
||||
});
|
||||
|
||||
it('Test `detectBuilders` with `index` files', async () => {
|
||||
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
|
||||
const pkg = await fs.readJSON(path.join(fixture, 'package.json'));
|
||||
const fileList = await glob('**', fixture);
|
||||
const files = Object.keys(fileList);
|
||||
|
||||
const probes = [
|
||||
{
|
||||
path: '/api/not-okay',
|
||||
status: 404,
|
||||
},
|
||||
{
|
||||
path: '/api',
|
||||
mustContain: 'hello from api/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/',
|
||||
mustContain: 'hello from api/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/index',
|
||||
mustContain: 'hello from api/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/index.js',
|
||||
mustContain: 'hello from api/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/date.js',
|
||||
mustContain: 'hello from api/date.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
// Someone might expect this to be `date.js`,
|
||||
// but I doubt that there is any case were both
|
||||
// `date/index.js` and `date.js` exists,
|
||||
// so it is not special cased
|
||||
path: '/api/date',
|
||||
mustContain: 'hello from api/date/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/date/',
|
||||
mustContain: 'hello from api/date/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/date/index',
|
||||
mustContain: 'hello from api/date/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/api/date/index.js',
|
||||
mustContain: 'hello from api/date/index.js',
|
||||
status: 200,
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
mustContain: 'hello from index.txt',
|
||||
},
|
||||
];
|
||||
|
||||
const { builders, defaultRoutes } = await detectBuilders(files, pkg);
|
||||
|
||||
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
|
||||
await fs.writeFile(
|
||||
path.join(fixture, 'now.json'),
|
||||
JSON.stringify(nowConfig, null, 2)
|
||||
);
|
||||
|
||||
const deployment = await testDeployment(
|
||||
{ builderUrl, buildUtilsUrl },
|
||||
fixture
|
||||
);
|
||||
expect(deployment).toBeDefined();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": "16.14.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
}
|
||||
29
packages/build-utils/test/unit.exec-async.test.ts
vendored
Normal file
29
packages/build-utils/test/unit.exec-async.test.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { execAsync, NowBuildError } from '../src';
|
||||
|
||||
it('should execute a command', async () => {
|
||||
const { code, stdout, stderr } = await execAsync('echo', ['hello']);
|
||||
|
||||
expect(code).toBe(0);
|
||||
expect(stdout).toContain('hello');
|
||||
expect(stderr).toBe('');
|
||||
});
|
||||
|
||||
it('should throw if the command exits with non-0 code', async () => {
|
||||
await expect(execAsync('find', ['unknown-file'])).rejects.toBeInstanceOf(
|
||||
NowBuildError
|
||||
);
|
||||
});
|
||||
|
||||
it('should return if the command exits with non-0 code and ignoreNon0Exit=true', async () => {
|
||||
const { code, stdout, stderr } = await execAsync('find', ['unknown-file'], {
|
||||
ignoreNon0Exit: true,
|
||||
});
|
||||
|
||||
expect(code).toBe(process.platform === 'win32' ? 2 : 1);
|
||||
expect(stdout).toBe('');
|
||||
expect(stderr).toContain(
|
||||
process.platform === 'win32'
|
||||
? 'Parameter format not correct'
|
||||
: 'No such file or directory'
|
||||
);
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import assert from 'assert';
|
||||
import { delimiter } from 'path';
|
||||
import { getEnvForPackageManager } from '../src';
|
||||
|
||||
describe('Test `getEnvForPackageManager()`', () => {
|
||||
@@ -34,7 +35,39 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
},
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
PATH: `/node16/bin-npm7:foo`,
|
||||
PATH: `/node16/bin-npm7${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set npm path if corepack enabled',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not prepend npm path again if already detected',
|
||||
args: {
|
||||
cliType: 'npm',
|
||||
nodeVersion: { major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
lockfileVersion: 2,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: `/node16/bin-npm7${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
PATH: `/node16/bin-npm7${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -97,7 +130,39 @@ describe('Test `getEnvForPackageManager()`', () => {
|
||||
},
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
PATH: '/pnpm7/node_modules/.bin:foo',
|
||||
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not set pnpm path if corepack is enabled',
|
||||
args: {
|
||||
cliType: 'pnpm',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 5.4,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
},
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
ENABLE_EXPERIMENTAL_COREPACK: '1',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'should not prepend pnpm path again if already detected',
|
||||
args: {
|
||||
cliType: 'pnpm',
|
||||
nodeVersion: { major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
lockfileVersion: 5.4,
|
||||
env: {
|
||||
FOO: 'bar',
|
||||
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
want: {
|
||||
FOO: 'bar',
|
||||
PATH: `/pnpm7/node_modules/.bin${delimiter}foo`,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
111
packages/build-utils/test/unit.get-spawn-options.test.ts
vendored
Normal file
111
packages/build-utils/test/unit.get-spawn-options.test.ts
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import { delimiter } from 'path';
|
||||
import { getSpawnOptions } from '../src';
|
||||
|
||||
describe('Test `getSpawnOptions()`', () => {
|
||||
const origProcessEnvPath = process.env.PATH;
|
||||
|
||||
beforeEach(() => {
|
||||
process.env.PATH = undefined;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env.PATH = origProcessEnvPath;
|
||||
});
|
||||
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
args: Parameters<typeof getSpawnOptions>;
|
||||
envPath: string | undefined;
|
||||
want: string | undefined;
|
||||
}> = [
|
||||
{
|
||||
name: 'should do nothing when isDev and node14',
|
||||
args: [
|
||||
{ isDev: true },
|
||||
{ major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
],
|
||||
envPath: '/foo',
|
||||
want: '/foo',
|
||||
},
|
||||
{
|
||||
name: 'should do nothing when isDev and node16',
|
||||
args: [
|
||||
{ isDev: true },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: '/foo',
|
||||
want: '/foo',
|
||||
},
|
||||
{
|
||||
name: 'should replace 14 with 16 when only path',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: '/node14/bin',
|
||||
want: '/node16/bin',
|
||||
},
|
||||
{
|
||||
name: 'should replace 14 with 16 at beginning',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: `/node14/bin${delimiter}/foo`,
|
||||
want: `/node16/bin${delimiter}/foo`,
|
||||
},
|
||||
{
|
||||
name: 'should replace 14 with 16 at end',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: `/foo${delimiter}/node14/bin`,
|
||||
want: `/foo${delimiter}/node16/bin`,
|
||||
},
|
||||
{
|
||||
name: 'should replace 14 with 16 in middle',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: `/foo${delimiter}/node14/bin${delimiter}/bar`,
|
||||
want: `/foo${delimiter}/node16/bin${delimiter}/bar`,
|
||||
},
|
||||
{
|
||||
name: 'should prepend 16 at beginning when nothing to replace',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: `/foo`,
|
||||
want: `/node16/bin${delimiter}/foo`,
|
||||
},
|
||||
{
|
||||
name: 'should prepend 16 at beginning no path input',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 16, range: '16.x', runtime: 'nodejs16.x' },
|
||||
],
|
||||
envPath: '',
|
||||
want: `/node16/bin`,
|
||||
},
|
||||
{
|
||||
name: 'should replace 12 with 14 when only path',
|
||||
args: [
|
||||
{ isDev: false },
|
||||
{ major: 14, range: '14.x', runtime: 'nodejs14.x' },
|
||||
],
|
||||
envPath: '/node12/bin',
|
||||
want: '/node14/bin',
|
||||
},
|
||||
];
|
||||
|
||||
for (const { name, args, envPath, want } of cases) {
|
||||
it(name, () => {
|
||||
process.env.PATH = envPath;
|
||||
const opts = getSpawnOptions(...args);
|
||||
expect(opts.env?.PATH).toBe(want);
|
||||
});
|
||||
}
|
||||
});
|
||||
21
packages/build-utils/test/unit.spawn-async.test.ts
vendored
Normal file
21
packages/build-utils/test/unit.spawn-async.test.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { spawnAsync, NowBuildError } from '../src';
|
||||
|
||||
it('should execute a command', async () => {
|
||||
// should resolve (it doesn't return anything, so it resolves with "undefined")
|
||||
await expect(spawnAsync('echo', ['hello'])).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should throw if the command exits with non-0 code', async () => {
|
||||
await expect(spawnAsync('find', ['unknown-file'])).rejects.toBeInstanceOf(
|
||||
NowBuildError
|
||||
);
|
||||
});
|
||||
|
||||
it('should return if the command exits with non-0 code and ignoreNon0Exit=true', async () => {
|
||||
// should resolve (it doesn't return anything, so it resolves with "undefined")
|
||||
await expect(
|
||||
spawnAsync('find', ['unknown-file'], {
|
||||
ignoreNon0Exit: true,
|
||||
})
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
50
packages/build-utils/test/unit.test.ts
vendored
50
packages/build-utils/test/unit.test.ts
vendored
@@ -18,6 +18,8 @@ import {
|
||||
Meta,
|
||||
} from '../src';
|
||||
|
||||
jest.setTimeout(7 * 1000);
|
||||
|
||||
async function expectBuilderError(promise: Promise<any>, pattern: string) {
|
||||
let result;
|
||||
try {
|
||||
@@ -277,7 +279,45 @@ it('should prefer package.json engines over project setting from config and warn
|
||||
]);
|
||||
});
|
||||
|
||||
it('should warn when package.json engines is exact version', async () => {
|
||||
expect(
|
||||
await getNodeVersion(
|
||||
path.join(__dirname, 'pkg-engine-node-exact'),
|
||||
undefined,
|
||||
{},
|
||||
{}
|
||||
)
|
||||
).toHaveProperty('range', '16.x');
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Warning: Detected "engines": { "node": "16.14.0" } in your `package.json` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should warn when package.json engines is greater than', async () => {
|
||||
expect(
|
||||
await getNodeVersion(
|
||||
path.join(__dirname, 'pkg-engine-node-greaterthan'),
|
||||
undefined,
|
||||
{},
|
||||
{}
|
||||
)
|
||||
).toHaveProperty('range', '16.x');
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Warning: Detected "engines": { "node": ">=16" } in your `package.json` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should not warn when package.json engines matches project setting from config', async () => {
|
||||
expect(
|
||||
await getNodeVersion(
|
||||
path.join(__dirname, 'pkg-engine-node'),
|
||||
undefined,
|
||||
{ nodeVersion: '14' },
|
||||
{}
|
||||
)
|
||||
).toHaveProperty('range', '14.x');
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
|
||||
expect(
|
||||
await getNodeVersion(
|
||||
path.join(__dirname, 'pkg-engine-node'),
|
||||
@@ -287,6 +327,16 @@ it('should not warn when package.json engines matches project setting from confi
|
||||
)
|
||||
).toHaveProperty('range', '14.x');
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
|
||||
expect(
|
||||
await getNodeVersion(
|
||||
path.join(__dirname, 'pkg-engine-node'),
|
||||
undefined,
|
||||
{ nodeVersion: '<15' },
|
||||
{}
|
||||
)
|
||||
).toHaveProperty('range', '14.x');
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('should get latest node version', async () => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext"],
|
||||
"lib": ["ES2020"],
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noEmitOnError": true,
|
||||
@@ -13,7 +13,7 @@
|
||||
"outDir": "./dist",
|
||||
"types": ["node", "jest"],
|
||||
"strict": true,
|
||||
"target": "es2019"
|
||||
"target": "ES2020"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "24.2.4",
|
||||
"version": "26.0.0",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -30,7 +30,6 @@
|
||||
"scripts/preinstall.js"
|
||||
],
|
||||
"ava": {
|
||||
"compileEnhancements": false,
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
@@ -40,15 +39,19 @@
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
"node": ">= 14"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "3.1.0",
|
||||
"@vercel/go": "1.4.3",
|
||||
"@vercel/node": "1.15.3",
|
||||
"@vercel/python": "2.3.3",
|
||||
"@vercel/ruby": "1.3.6",
|
||||
"update-notifier": "4.1.0"
|
||||
"@vercel/build-utils": "5.0.0",
|
||||
"@vercel/go": "2.0.4",
|
||||
"@vercel/next": "3.1.3",
|
||||
"@vercel/node": "2.4.0",
|
||||
"@vercel/python": "3.0.4",
|
||||
"@vercel/redwood": "1.0.5",
|
||||
"@vercel/remix": "1.0.5",
|
||||
"@vercel/ruby": "1.3.12",
|
||||
"@vercel/static-build": "1.0.4",
|
||||
"update-notifier": "5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alex_neo/jest-expect-message": "1.0.5",
|
||||
@@ -68,6 +71,7 @@
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/glob": "7.1.1",
|
||||
"@types/http-proxy": "1.16.2",
|
||||
"@types/ini": "1.3.31",
|
||||
"@types/inquirer": "7.3.1",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/jest-expect-message": "1.0.3",
|
||||
@@ -90,8 +94,10 @@
|
||||
"@types/update-notifier": "5.1.0",
|
||||
"@types/which": "1.3.2",
|
||||
"@types/write-json-file": "2.2.1",
|
||||
"@vercel/client": "11.0.3",
|
||||
"@vercel/frameworks": "0.9.1",
|
||||
"@types/yauzl-promise": "2.1.0",
|
||||
"@vercel/client": "12.0.4",
|
||||
"@vercel/frameworks": "1.0.2",
|
||||
"@vercel/fs-detectors": "1.0.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@zeit/fun": "0.11.2",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
@@ -126,11 +132,13 @@
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"fs-extra": "10.0.0",
|
||||
"get-port": "5.1.1",
|
||||
"git-last-commit": "1.0.1",
|
||||
"glob": "7.1.2",
|
||||
"http-proxy": "1.18.1",
|
||||
"ini": "3.0.0",
|
||||
"inquirer": "7.0.4",
|
||||
"is-docker": "2.2.1",
|
||||
"is-port-reachable": "3.0.0",
|
||||
"is-port-reachable": "3.1.0",
|
||||
"is-url": "1.2.2",
|
||||
"jaro-winkler": "0.2.8",
|
||||
"jsonlines": "0.1.1",
|
||||
@@ -167,7 +175,8 @@
|
||||
"utility-types": "2.1.0",
|
||||
"which": "2.0.2",
|
||||
"write-json-file": "2.2.0",
|
||||
"xdg-app-paths": "5.1.0"
|
||||
"xdg-app-paths": "5.1.0",
|
||||
"yauzl-promise": "2.1.3"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
|
||||
@@ -10,7 +10,6 @@ import confirm from '../../util/input/confirm';
|
||||
import findAliasByAliasOrId from '../../util/alias/find-alias-by-alias-or-id';
|
||||
|
||||
import { Alias } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import { isValidName } from '../../util/is-valid-name';
|
||||
import { getCommandName } from '../../util/pkg-name';
|
||||
|
||||
@@ -71,7 +70,7 @@ export default async function rm(
|
||||
}
|
||||
|
||||
const removeStamp = stamp();
|
||||
if (!opts['--yes'] && !(await confirmAliasRemove(output, alias))) {
|
||||
if (!opts['--yes'] && !(await confirmAliasRemove(client, alias))) {
|
||||
output.log('Aborted');
|
||||
return 0;
|
||||
}
|
||||
@@ -85,7 +84,7 @@ export default async function rm(
|
||||
return 0;
|
||||
}
|
||||
|
||||
async function confirmAliasRemove(output: Output, alias: Alias) {
|
||||
async function confirmAliasRemove(client: Client, alias: Alias) {
|
||||
const srcUrl = alias.deployment
|
||||
? chalk.underline(alias.deployment.url)
|
||||
: null;
|
||||
@@ -104,7 +103,7 @@ async function confirmAliasRemove(output: Output, alias: Alias) {
|
||||
}
|
||||
);
|
||||
|
||||
output.log(`The following alias will be removed permanently`);
|
||||
output.print(` ${tbl}\n`);
|
||||
return confirm(chalk.red('Are you sure?'), false);
|
||||
client.output.log(`The following alias will be removed permanently`);
|
||||
client.output.print(` ${tbl}\n`);
|
||||
return confirm(client, chalk.red('Are you sure?'), false);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ export default async function ({ creditCards, clear = false, contextName }) {
|
||||
}
|
||||
|
||||
console.log(''); // New line
|
||||
const stopSpinner = wait('Saving card');
|
||||
const stopSpinner = wait(process.stderr, 'Saving card');
|
||||
|
||||
try {
|
||||
const res = await creditCards.add({
|
||||
|
||||
@@ -174,7 +174,7 @@ export default async client => {
|
||||
)} ${chalk.gray(`[${elapsed}]`)}`;
|
||||
const choices = buildInquirerChoices(cards);
|
||||
|
||||
cardId = await listInput({
|
||||
cardId = await listInput(client, {
|
||||
message,
|
||||
choices,
|
||||
separator: true,
|
||||
@@ -187,6 +187,7 @@ export default async client => {
|
||||
if (cardId) {
|
||||
const label = `Are you sure that you to set this card as the default?`;
|
||||
const confirmation = await promptBool(label, {
|
||||
...client,
|
||||
trailing: '\n',
|
||||
});
|
||||
|
||||
@@ -250,7 +251,7 @@ export default async client => {
|
||||
)} under ${chalk.bold(contextName)} ${chalk.gray(`[${elapsed}]`)}`;
|
||||
const choices = buildInquirerChoices(cards);
|
||||
|
||||
cardId = await listInput({
|
||||
cardId = await listInput(client, {
|
||||
message,
|
||||
choices,
|
||||
separator: true,
|
||||
@@ -262,7 +263,7 @@ export default async client => {
|
||||
// typed `vercel billing rm <some-id>`) is valid
|
||||
if (cardId) {
|
||||
const label = `Are you sure that you want to remove this card?`;
|
||||
const confirmation = await promptBool(label);
|
||||
const confirmation = await promptBool(label, client);
|
||||
if (!confirmation) {
|
||||
console.log('Aborted');
|
||||
break;
|
||||
|
||||
@@ -14,8 +14,8 @@ import logo from '../../util/output/logo';
|
||||
import getArgs from '../../util/get-args';
|
||||
import Client from '../../util/client';
|
||||
import { getPkgName } from '../../util/pkg-name';
|
||||
import { Output } from '../../util/output';
|
||||
import { Deployment, PaginationOptions } from '../../types';
|
||||
import { normalizeURL } from '../../util/bisect/normalize-url';
|
||||
|
||||
interface DeploymentV6
|
||||
extends Pick<
|
||||
@@ -85,10 +85,10 @@ export default async function main(client: Client): Promise<number> {
|
||||
|
||||
let bad =
|
||||
argv['--bad'] ||
|
||||
(await prompt(output, `Specify a URL where the bug occurs:`));
|
||||
(await prompt(client, `Specify a URL where the bug occurs:`));
|
||||
let good =
|
||||
argv['--good'] ||
|
||||
(await prompt(output, `Specify a URL where the bug does not occur:`));
|
||||
(await prompt(client, `Specify a URL where the bug does not occur:`));
|
||||
let subpath = argv['--path'] || '';
|
||||
let run = argv['--run'] || '';
|
||||
const openEnabled = argv['--open'] || false;
|
||||
@@ -97,9 +97,7 @@ export default async function main(client: Client): Promise<number> {
|
||||
run = resolve(run);
|
||||
}
|
||||
|
||||
if (!bad.startsWith('https://')) {
|
||||
bad = `https://${bad}`;
|
||||
}
|
||||
bad = normalizeURL(bad);
|
||||
let parsed = parse(bad);
|
||||
if (!parsed.hostname) {
|
||||
output.error('Invalid input: no hostname provided');
|
||||
@@ -120,9 +118,7 @@ export default async function main(client: Client): Promise<number> {
|
||||
|
||||
const badDeploymentPromise = getDeployment(client, bad).catch(err => err);
|
||||
|
||||
if (!good.startsWith('https://')) {
|
||||
good = `https://${good}`;
|
||||
}
|
||||
good = normalizeURL(good);
|
||||
parsed = parse(good);
|
||||
if (!parsed.hostname) {
|
||||
output.error('Invalid input: no hostname provided');
|
||||
@@ -146,7 +142,7 @@ export default async function main(client: Client): Promise<number> {
|
||||
|
||||
if (!subpath) {
|
||||
subpath = await prompt(
|
||||
output,
|
||||
client,
|
||||
`Specify the URL subpath where the bug occurs:`
|
||||
);
|
||||
}
|
||||
@@ -394,10 +390,10 @@ function getCommit(deployment: DeploymentV6) {
|
||||
return { sha, message };
|
||||
}
|
||||
|
||||
async function prompt(output: Output, message: string): Promise<string> {
|
||||
async function prompt(client: Client, message: string): Promise<string> {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const { val } = await inquirer.prompt({
|
||||
const { val } = await client.prompt({
|
||||
type: 'input',
|
||||
name: 'val',
|
||||
message,
|
||||
@@ -405,7 +401,7 @@ async function prompt(output: Output, message: string): Promise<string> {
|
||||
if (val) {
|
||||
return val;
|
||||
} else {
|
||||
output.error('A value must be specified');
|
||||
client.output.error('A value must be specified');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
558
packages/cli/src/commands/build.ts
Normal file
558
packages/cli/src/commands/build.ts
Normal file
@@ -0,0 +1,558 @@
|
||||
import fs from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
import dotenv from 'dotenv';
|
||||
import { join, normalize, relative, resolve } from 'path';
|
||||
import {
|
||||
normalizePath,
|
||||
Files,
|
||||
FileFsRef,
|
||||
PackageJson,
|
||||
BuildOptions,
|
||||
Config,
|
||||
Meta,
|
||||
Builder,
|
||||
BuildResultV2,
|
||||
BuildResultV2Typical,
|
||||
BuildResultV3,
|
||||
NowBuildError,
|
||||
} from '@vercel/build-utils';
|
||||
import { detectBuilders } from '@vercel/fs-detectors';
|
||||
import minimatch from 'minimatch';
|
||||
import {
|
||||
appendRoutesToPhase,
|
||||
getTransformedRoutes,
|
||||
mergeRoutes,
|
||||
MergeRoutesProps,
|
||||
Route,
|
||||
} from '@vercel/routing-utils';
|
||||
import { VercelConfig } from '@vercel/client';
|
||||
|
||||
import pull from './pull';
|
||||
import { staticFiles as getFiles } from '../util/get-files';
|
||||
import Client from '../util/client';
|
||||
import getArgs from '../util/get-args';
|
||||
import cmd from '../util/output/cmd';
|
||||
import * as cli from '../util/pkg-name';
|
||||
import cliPkg from '../util/pkg';
|
||||
import readJSONFile from '../util/read-json-file';
|
||||
import { CantParseJSONFile } from '../util/errors-ts';
|
||||
import { readProjectSettings } from '../util/projects/project-settings';
|
||||
import { VERCEL_DIR } from '../util/projects/link';
|
||||
import confirm from '../util/input/confirm';
|
||||
import { emoji, prependEmoji } from '../util/emoji';
|
||||
import stamp from '../util/output/stamp';
|
||||
import {
|
||||
OUTPUT_DIR,
|
||||
PathOverride,
|
||||
writeBuildResult,
|
||||
} from '../util/build/write-build-result';
|
||||
import { importBuilders, BuilderWithPkg } from '../util/build/import-builders';
|
||||
import { initCorepack, cleanupCorepack } from '../util/build/corepack';
|
||||
|
||||
type BuildResult = BuildResultV2 | BuildResultV3;
|
||||
|
||||
const help = () => {
|
||||
return console.log(`
|
||||
${chalk.bold(`${cli.logo} ${cli.name} build`)}
|
||||
|
||||
${chalk.dim('Options:')}
|
||||
|
||||
-h, --help Output usage information
|
||||
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
|
||||
'FILE'
|
||||
)} Path to the local ${'`vercel.json`'} file
|
||||
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
|
||||
'DIR'
|
||||
)} Path to the global ${'`.vercel`'} directory
|
||||
--cwd [path] The current working directory
|
||||
--output [path] Directory where built assets should be written to
|
||||
--prod Build a production deployment
|
||||
-d, --debug Debug mode [off]
|
||||
-y, --yes Skip the confirmation prompt
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
${chalk.gray('–')} Build the project
|
||||
|
||||
${chalk.cyan(`$ ${cli.name} build`)}
|
||||
${chalk.cyan(`$ ${cli.name} build --cwd ./path-to-project`)}
|
||||
`);
|
||||
};
|
||||
|
||||
export default async function main(client: Client): Promise<number> {
|
||||
const { output } = client;
|
||||
|
||||
// Ensure that `vc build` is not being invoked recursively
|
||||
if (process.env.__VERCEL_BUILD_RUNNING) {
|
||||
output.error(
|
||||
`${cmd(
|
||||
`${cli.name} build`
|
||||
)} must not recursively invoke itself. Check the Build Command in the Project Settings or the ${cmd(
|
||||
'build'
|
||||
)} script in ${cmd('package.json')}`
|
||||
);
|
||||
output.error(
|
||||
`Learn More: https://vercel.link/recursive-invocation-of-commands`
|
||||
);
|
||||
return 1;
|
||||
} else {
|
||||
process.env.__VERCEL_BUILD_RUNNING = '1';
|
||||
}
|
||||
|
||||
// Parse CLI args
|
||||
const argv = getArgs(client.argv.slice(2), {
|
||||
'--cwd': String,
|
||||
'--output': String,
|
||||
'--prod': Boolean,
|
||||
'--yes': Boolean,
|
||||
});
|
||||
|
||||
if (argv['--help']) {
|
||||
help();
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Set the working directory if necessary
|
||||
if (argv['--cwd']) {
|
||||
process.chdir(argv['--cwd']);
|
||||
}
|
||||
const cwd = process.cwd();
|
||||
|
||||
// Build `target` influences which environment variables will be used
|
||||
const target = argv['--prod'] ? 'production' : 'preview';
|
||||
const yes = Boolean(argv['--yes']);
|
||||
|
||||
// TODO: read project settings from the API, fall back to local `project.json` if that fails
|
||||
|
||||
// Read project settings, and pull them from Vercel if necessary
|
||||
let project = await readProjectSettings(join(cwd, VERCEL_DIR));
|
||||
const isTTY = process.stdin.isTTY;
|
||||
while (!project?.settings) {
|
||||
let confirmed = yes;
|
||||
if (!confirmed) {
|
||||
if (!isTTY) {
|
||||
client.output.print(
|
||||
`No Project Settings found locally. Run ${cli.getCommandName(
|
||||
'pull --yes'
|
||||
)} to retreive them.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
confirmed = await confirm(
|
||||
client,
|
||||
`No Project Settings found locally. Run ${cli.getCommandName(
|
||||
'pull'
|
||||
)} for retrieving them?`,
|
||||
true
|
||||
);
|
||||
}
|
||||
if (!confirmed) {
|
||||
client.output.print(`Aborted. No Project Settings retrieved.\n`);
|
||||
return 0;
|
||||
}
|
||||
const { argv: originalArgv } = client;
|
||||
client.argv = [
|
||||
...originalArgv.slice(0, 2),
|
||||
'pull',
|
||||
`--environment`,
|
||||
target,
|
||||
];
|
||||
const result = await pull(client);
|
||||
if (result !== 0) {
|
||||
return result;
|
||||
}
|
||||
client.argv = originalArgv;
|
||||
project = await readProjectSettings(join(cwd, VERCEL_DIR));
|
||||
}
|
||||
|
||||
// TODO: load env vars from the API, fall back to local files if that fails
|
||||
|
||||
const envPath = await checkExists([
|
||||
join(cwd, VERCEL_DIR, `.env.${target}.local`),
|
||||
join(cwd, `.env`),
|
||||
]);
|
||||
if (envPath) {
|
||||
dotenv.config({ path: envPath, debug: client.output.isDebugEnabled() });
|
||||
output.log(`Loaded env from "${relative(cwd, envPath)}"`);
|
||||
}
|
||||
|
||||
// Some build processes use these env vars to platform detect Vercel
|
||||
process.env.VERCEL = '1';
|
||||
process.env.NOW_BUILDER = '1';
|
||||
|
||||
const workPath = join(cwd, project.settings.rootDirectory || '.');
|
||||
|
||||
// Load `package.json` and `vercel.json` files
|
||||
const [pkg, vercelConfig] = await Promise.all([
|
||||
readJSONFile<PackageJson>(join(workPath, 'package.json')),
|
||||
readJSONFile<VercelConfig>(join(workPath, 'vercel.json')).then(
|
||||
config => config || readJSONFile<VercelConfig>(join(workPath, 'now.json'))
|
||||
),
|
||||
]);
|
||||
if (pkg instanceof CantParseJSONFile) throw pkg;
|
||||
if (vercelConfig instanceof CantParseJSONFile) throw vercelConfig;
|
||||
|
||||
// Get a list of source files
|
||||
const files = (await getFiles(workPath, client)).map(f =>
|
||||
normalizePath(relative(workPath, f))
|
||||
);
|
||||
|
||||
const routesResult = getTransformedRoutes({ nowConfig: vercelConfig || {} });
|
||||
if (routesResult.error) {
|
||||
output.prettyError(routesResult.error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (vercelConfig?.builds && vercelConfig.functions) {
|
||||
output.prettyError({
|
||||
message:
|
||||
'The `functions` property cannot be used in conjunction with the `builds` property. Please remove one of them.',
|
||||
link: 'https://vercel.link/functions-and-builds',
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
let builds = vercelConfig?.builds || [];
|
||||
let zeroConfigRoutes: Route[] = [];
|
||||
|
||||
if (builds.length > 0) {
|
||||
output.warn(
|
||||
'Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings'
|
||||
);
|
||||
builds = builds.map(b => expandBuild(files, b)).flat();
|
||||
} else {
|
||||
// Zero config
|
||||
|
||||
// Detect the Vercel Builders that will need to be invoked
|
||||
const detectedBuilders = await detectBuilders(files, pkg, {
|
||||
...vercelConfig,
|
||||
projectSettings: project.settings,
|
||||
featHandleMiss: true,
|
||||
});
|
||||
|
||||
if (detectedBuilders.errors && detectedBuilders.errors.length > 0) {
|
||||
output.prettyError(detectedBuilders.errors[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (const w of detectedBuilders.warnings) {
|
||||
console.log(
|
||||
`Warning: ${w.message} ${w.action || 'Learn More'}: ${w.link}`
|
||||
);
|
||||
}
|
||||
|
||||
if (detectedBuilders.builders) {
|
||||
builds = detectedBuilders.builders;
|
||||
} else {
|
||||
builds = [{ src: '**', use: '@vercel/static' }];
|
||||
}
|
||||
|
||||
zeroConfigRoutes.push(...(detectedBuilders.redirectRoutes || []));
|
||||
zeroConfigRoutes.push(
|
||||
...appendRoutesToPhase({
|
||||
routes: [],
|
||||
newRoutes: detectedBuilders.rewriteRoutes,
|
||||
phase: 'filesystem',
|
||||
})
|
||||
);
|
||||
zeroConfigRoutes = appendRoutesToPhase({
|
||||
routes: zeroConfigRoutes,
|
||||
newRoutes: detectedBuilders.errorRoutes,
|
||||
phase: 'error',
|
||||
});
|
||||
zeroConfigRoutes.push(...(detectedBuilders.defaultRoutes || []));
|
||||
}
|
||||
|
||||
const builderSpecs = new Set(builds.map(b => b.use));
|
||||
|
||||
let buildersWithPkgs: Map<string, BuilderWithPkg>;
|
||||
try {
|
||||
buildersWithPkgs = await importBuilders(builderSpecs, cwd, output);
|
||||
} catch (err: any) {
|
||||
output.prettyError(err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Populate Files -> FileFsRef mapping
|
||||
const filesMap: Files = {};
|
||||
for (const path of files) {
|
||||
const fsPath = join(workPath, path);
|
||||
const { mode } = await fs.stat(fsPath);
|
||||
filesMap[path] = new FileFsRef({ mode, fsPath });
|
||||
}
|
||||
|
||||
// Delete output directory from potential previous build
|
||||
const outputDir = argv['--output']
|
||||
? resolve(argv['--output'])
|
||||
: join(cwd, OUTPUT_DIR);
|
||||
await fs.remove(outputDir);
|
||||
|
||||
const buildStamp = stamp();
|
||||
|
||||
// Create fresh new output directory
|
||||
await fs.mkdirp(outputDir);
|
||||
|
||||
const ops: Promise<Error | void>[] = [];
|
||||
|
||||
// Write the `detectedBuilders` result to output dir
|
||||
ops.push(
|
||||
fs.writeJSON(
|
||||
join(outputDir, 'builds.json'),
|
||||
{
|
||||
'//': 'This file was generated by the `vercel build` command. It is not part of the Build Output API.',
|
||||
target,
|
||||
argv: process.argv,
|
||||
builds: builds.map(build => {
|
||||
const builderWithPkg = buildersWithPkgs.get(build.use);
|
||||
if (!builderWithPkg) {
|
||||
throw new Error(`Failed to load Builder "${build.use}"`);
|
||||
}
|
||||
const { builder, pkg: builderPkg } = builderWithPkg;
|
||||
return {
|
||||
require: builderPkg.name,
|
||||
requirePath: builderWithPkg.path,
|
||||
apiVersion: builder.version,
|
||||
...build,
|
||||
};
|
||||
}),
|
||||
},
|
||||
{
|
||||
spaces: 2,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// The `meta` config property is re-used for each Builder
|
||||
// invocation so that Builders can share state between
|
||||
// subsequent entrypoint builds.
|
||||
const meta: Meta = {
|
||||
skipDownload: true,
|
||||
cliVersion: cliPkg.version,
|
||||
};
|
||||
|
||||
// Execute Builders for detected entrypoints
|
||||
// TODO: parallelize builds
|
||||
const buildResults: Map<Builder, BuildResult> = new Map();
|
||||
const overrides: PathOverride[] = [];
|
||||
const repoRootPath = cwd;
|
||||
const rootPackageJsonPath = repoRootPath || workPath;
|
||||
const corepackShimDir = await initCorepack({ cwd, rootPackageJsonPath });
|
||||
|
||||
for (const build of builds) {
|
||||
if (typeof build.src !== 'string') continue;
|
||||
|
||||
const builderWithPkg = buildersWithPkgs.get(build.use);
|
||||
if (!builderWithPkg) {
|
||||
throw new Error(`Failed to load Builder "${build.use}"`);
|
||||
}
|
||||
const { builder, pkg: builderPkg } = builderWithPkg;
|
||||
|
||||
const buildConfig: Config = {
|
||||
outputDirectory: project.settings.outputDirectory ?? undefined,
|
||||
...build.config,
|
||||
projectSettings: project.settings,
|
||||
installCommand: project.settings.installCommand ?? undefined,
|
||||
devCommand: project.settings.devCommand ?? undefined,
|
||||
buildCommand: project.settings.buildCommand ?? undefined,
|
||||
framework: project.settings.framework,
|
||||
nodeVersion: project.settings.nodeVersion,
|
||||
};
|
||||
const buildOptions: BuildOptions = {
|
||||
files: filesMap,
|
||||
entrypoint: build.src,
|
||||
workPath,
|
||||
repoRootPath,
|
||||
config: buildConfig,
|
||||
meta,
|
||||
};
|
||||
output.debug(
|
||||
`Building entrypoint "${build.src}" with "${builderPkg.name}"`
|
||||
);
|
||||
const buildResult = await builder.build(buildOptions);
|
||||
|
||||
// Store the build result to generate the final `config.json` after
|
||||
// all builds have completed
|
||||
buildResults.set(build, buildResult);
|
||||
|
||||
// Start flushing the file outputs to the filesystem asynchronously
|
||||
ops.push(
|
||||
writeBuildResult(
|
||||
outputDir,
|
||||
buildResult,
|
||||
build,
|
||||
builder,
|
||||
builderPkg,
|
||||
vercelConfig?.cleanUrls
|
||||
).then(
|
||||
override => {
|
||||
if (override) overrides.push(override);
|
||||
},
|
||||
err => err
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (corepackShimDir) {
|
||||
cleanupCorepack(corepackShimDir);
|
||||
}
|
||||
|
||||
// Wait for filesystem operations to complete
|
||||
// TODO render progress bar?
|
||||
let hadError = false;
|
||||
const errors = await Promise.all(ops);
|
||||
for (const error of errors) {
|
||||
if (error) {
|
||||
hadError = true;
|
||||
output.prettyError(error);
|
||||
}
|
||||
}
|
||||
if (hadError) return 1;
|
||||
|
||||
// Merge existing `config.json` file into the one that will be produced
|
||||
const configPath = join(outputDir, 'config.json');
|
||||
// TODO: properly type
|
||||
const existingConfig = await readJSONFile<any>(configPath);
|
||||
if (existingConfig instanceof CantParseJSONFile) {
|
||||
throw existingConfig;
|
||||
}
|
||||
if (existingConfig) {
|
||||
if (existingConfig.overrides) {
|
||||
overrides.push(existingConfig.overrides);
|
||||
}
|
||||
// Find the `Build` entry for this config file and update the build result
|
||||
for (const [build, buildResult] of buildResults.entries()) {
|
||||
if ('buildOutputPath' in buildResult) {
|
||||
output.debug(`Using "config.json" for "${build.use}`);
|
||||
buildResults.set(build, existingConfig);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const builderRoutes: MergeRoutesProps['builds'] = Array.from(
|
||||
buildResults.entries()
|
||||
)
|
||||
.filter(b => 'routes' in b[1] && Array.isArray(b[1].routes))
|
||||
.map(b => {
|
||||
return {
|
||||
use: b[0].use,
|
||||
entrypoint: b[0].src!,
|
||||
routes: (b[1] as BuildResultV2Typical).routes,
|
||||
};
|
||||
});
|
||||
if (zeroConfigRoutes.length) {
|
||||
builderRoutes.unshift({
|
||||
use: '@vercel/zero-config-routes',
|
||||
entrypoint: '/',
|
||||
routes: zeroConfigRoutes,
|
||||
});
|
||||
}
|
||||
const mergedRoutes = mergeRoutes({
|
||||
userRoutes: routesResult.routes,
|
||||
builds: builderRoutes,
|
||||
});
|
||||
|
||||
const mergedImages = mergeImages(buildResults.values());
|
||||
const mergedWildcard = mergeWildcard(buildResults.values());
|
||||
const mergedOverrides: Record<string, PathOverride> =
|
||||
overrides.length > 0 ? Object.assign({}, ...overrides) : undefined;
|
||||
|
||||
// Write out the final `config.json` file based on the
|
||||
// user configuration and Builder build results
|
||||
// TODO: properly type
|
||||
const config = {
|
||||
version: 3,
|
||||
routes: mergedRoutes,
|
||||
images: mergedImages,
|
||||
wildcard: mergedWildcard,
|
||||
overrides: mergedOverrides,
|
||||
};
|
||||
await fs.writeJSON(join(outputDir, 'config.json'), config, { spaces: 2 });
|
||||
|
||||
const relOutputDir = relative(cwd, outputDir);
|
||||
output.print(
|
||||
`${prependEmoji(
|
||||
`Build Completed in ${chalk.bold(
|
||||
relOutputDir.startsWith('..') ? outputDir : relOutputDir
|
||||
)} ${chalk.gray(buildStamp())}`,
|
||||
emoji('success')
|
||||
)}\n`
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function expandBuild(files: string[], build: Builder): Builder[] {
|
||||
if (!build.use) {
|
||||
throw new NowBuildError({
|
||||
code: `invalid_build_specification`,
|
||||
message: 'Field `use` is missing in build specification',
|
||||
link: 'https://vercel.com/docs/configuration#project/builds',
|
||||
action: 'View Documentation',
|
||||
});
|
||||
}
|
||||
|
||||
let src = normalize(build.src || '**');
|
||||
if (src === '.' || src === './') {
|
||||
throw new NowBuildError({
|
||||
code: `invalid_build_specification`,
|
||||
message: 'A build `src` path resolves to an empty string',
|
||||
link: 'https://vercel.com/docs/configuration#project/builds',
|
||||
action: 'View Documentation',
|
||||
});
|
||||
}
|
||||
|
||||
if (src[0] === '/') {
|
||||
// Remove a leading slash so that the globbing is relative
|
||||
// to `cwd` instead of the root of the filesystem.
|
||||
src = src.substring(1);
|
||||
}
|
||||
|
||||
const matches = files.filter(
|
||||
name => name === src || minimatch(name, src, { dot: true })
|
||||
);
|
||||
|
||||
return matches.map(m => {
|
||||
return {
|
||||
...build,
|
||||
src: m,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function mergeImages(
|
||||
buildResults: Iterable<BuildResult>
|
||||
): BuildResultV2Typical['images'] {
|
||||
let images: BuildResultV2Typical['images'] = undefined;
|
||||
for (const result of buildResults) {
|
||||
if ('images' in result && result.images) {
|
||||
images = Object.assign({} || images, result.images);
|
||||
}
|
||||
}
|
||||
return images;
|
||||
}
|
||||
|
||||
function mergeWildcard(
|
||||
buildResults: Iterable<BuildResult>
|
||||
): BuildResultV2Typical['wildcard'] {
|
||||
let wildcard: BuildResultV2Typical['wildcard'] = undefined;
|
||||
for (const result of buildResults) {
|
||||
if ('wildcard' in result && result.wildcard) {
|
||||
if (!wildcard) wildcard = [];
|
||||
wildcard.push(...result.wildcard);
|
||||
}
|
||||
}
|
||||
return wildcard;
|
||||
}
|
||||
|
||||
async function checkExists(paths: Iterable<string>) {
|
||||
for (const path of paths) {
|
||||
try {
|
||||
await fs.stat(path);
|
||||
return path;
|
||||
} catch (err: any) {
|
||||
if (err.code !== 'ENOENT') throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,9 @@ import {
|
||||
import { SchemaValidationFailed } from '../../util/errors';
|
||||
import purchaseDomainIfAvailable from '../../util/domains/purchase-domain-if-available';
|
||||
import confirm from '../../util/input/confirm';
|
||||
import editProjectSettings from '../../util/input/edit-project-settings';
|
||||
import editProjectSettings, {
|
||||
PartialProjectSettings,
|
||||
} from '../../util/input/edit-project-settings';
|
||||
import {
|
||||
getLinkedProject,
|
||||
linkFolderToProject,
|
||||
@@ -63,6 +65,7 @@ import { help } from './args';
|
||||
import { getDeploymentChecks } from '../../util/deploy/get-deployment-checks';
|
||||
import parseTarget from '../../util/deploy/parse-target';
|
||||
import getPrebuiltJson from '../../util/deploy/get-prebuilt-json';
|
||||
import { createGitMeta } from '../../util/deploy/create-git-meta';
|
||||
|
||||
export default async (client: Client) => {
|
||||
const { output } = client;
|
||||
@@ -157,12 +160,12 @@ export default async (client: Client) => {
|
||||
}
|
||||
}
|
||||
|
||||
const { log, debug, error, prettyError, isTTY } = output;
|
||||
const { log, debug, error, prettyError } = output;
|
||||
|
||||
const quiet = !isTTY;
|
||||
const quiet = !client.stdout.isTTY;
|
||||
|
||||
// check paths
|
||||
const pathValidation = await validatePaths(output, paths);
|
||||
const pathValidation = await validatePaths(client, paths);
|
||||
|
||||
if (!pathValidation.valid) {
|
||||
return pathValidation.exitCode;
|
||||
@@ -240,6 +243,7 @@ export default async (client: Client) => {
|
||||
const shouldStartSetup =
|
||||
autoConfirm ||
|
||||
(await confirm(
|
||||
client,
|
||||
`Set up and deploy ${chalk.cyan(`“${toHumanPath(path)}”`)}?`,
|
||||
true
|
||||
));
|
||||
@@ -284,7 +288,7 @@ export default async (client: Client) => {
|
||||
|
||||
if (typeof projectOrNewProjectName === 'string') {
|
||||
newProjectName = projectOrNewProjectName;
|
||||
rootDirectory = await inputRootDirectory(path, output, autoConfirm);
|
||||
rootDirectory = await inputRootDirectory(client, path, autoConfirm);
|
||||
} else {
|
||||
project = projectOrNewProjectName;
|
||||
rootDirectory = project.rootDirectory;
|
||||
@@ -415,6 +419,8 @@ export default async (client: Client) => {
|
||||
parseMeta(argv['--meta'])
|
||||
);
|
||||
|
||||
const gitMetadata = await createGitMeta(path, output);
|
||||
|
||||
// Merge dotenv config, `env` from vercel.json, and `--env` / `-e` arguments
|
||||
const deploymentEnv = Object.assign(
|
||||
{},
|
||||
@@ -453,6 +459,15 @@ export default async (client: Client) => {
|
||||
let deployStamp = stamp();
|
||||
let deployment = null;
|
||||
|
||||
const localConfigurationOverrides: PartialProjectSettings = {
|
||||
buildCommand: localConfig?.buildCommand,
|
||||
devCommand: localConfig?.devCommand,
|
||||
framework: localConfig?.framework,
|
||||
commandForIgnoringBuildStep: localConfig?.ignoreCommand,
|
||||
installCommand: localConfig?.installCommand,
|
||||
outputDirectory: localConfig?.outputDirectory,
|
||||
};
|
||||
|
||||
try {
|
||||
const createArgs: any = {
|
||||
name: project ? project.name : newProjectName,
|
||||
@@ -468,6 +483,7 @@ export default async (client: Client) => {
|
||||
nowConfig: localConfig,
|
||||
regions,
|
||||
meta,
|
||||
gitMetadata,
|
||||
deployStamp,
|
||||
target,
|
||||
skipAutoDetectionConfirmation: autoConfirm,
|
||||
@@ -475,7 +491,12 @@ export default async (client: Client) => {
|
||||
|
||||
if (!localConfig.builds || localConfig.builds.length === 0) {
|
||||
// Only add projectSettings for zero config deployments
|
||||
createArgs.projectSettings = { sourceFilesOutsideRootDirectory };
|
||||
createArgs.projectSettings =
|
||||
status === 'not_linked'
|
||||
? {
|
||||
sourceFilesOutsideRootDirectory,
|
||||
}
|
||||
: { ...localConfigurationOverrides, sourceFilesOutsideRootDirectory };
|
||||
}
|
||||
|
||||
deployment = await createDeploy(
|
||||
@@ -501,9 +522,11 @@ export default async (client: Client) => {
|
||||
}
|
||||
|
||||
const settings = await editProjectSettings(
|
||||
output,
|
||||
client,
|
||||
projectSettings,
|
||||
framework
|
||||
framework,
|
||||
false,
|
||||
localConfigurationOverrides
|
||||
);
|
||||
|
||||
// deploy again, but send projectSettings this time
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { resolve, join } from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import DevServer from '../../util/dev/server';
|
||||
import parseListen from '../../util/dev/parse-listen';
|
||||
@@ -12,6 +13,7 @@ import setupAndLink from '../../util/link/setup-and-link';
|
||||
import getSystemEnvValues from '../../util/env/get-system-env-values';
|
||||
import { getCommandName } from '../../util/pkg-name';
|
||||
import param from '../../util/output/param';
|
||||
import { OUTPUT_DIR } from '../../util/build/write-build-result';
|
||||
|
||||
type Options = {
|
||||
'--listen': string;
|
||||
@@ -98,6 +100,23 @@ export default async function dev(
|
||||
]);
|
||||
}
|
||||
|
||||
// This is just for tests - can be removed once project settings
|
||||
// are respected locally in `.vercel/project.json`
|
||||
if (process.env.VERCEL_DEV_COMMAND) {
|
||||
devCommand = process.env.VERCEL_DEV_COMMAND;
|
||||
}
|
||||
|
||||
// If there is no Development Command, we must delete the
|
||||
// v3 Build Output because it will incorrectly be detected by
|
||||
// @vercel/static-build in BuildOutputV3.getBuildOutputDirectory()
|
||||
if (!devCommand) {
|
||||
const outputDir = join(cwd, OUTPUT_DIR);
|
||||
if (await fs.pathExists(outputDir)) {
|
||||
output.log(`Removing ${OUTPUT_DIR}`);
|
||||
await fs.remove(outputDir);
|
||||
}
|
||||
}
|
||||
|
||||
const devServer = new DevServer(cwd, {
|
||||
output,
|
||||
devCommand,
|
||||
|
||||
@@ -46,7 +46,7 @@ export default async function add(
|
||||
|
||||
const addStamp = stamp();
|
||||
const { domain, data: argData } = parsedParams;
|
||||
const data = await getDNSData(output, argData);
|
||||
const data = await getDNSData(client, argData);
|
||||
if (!data) {
|
||||
output.log(`Aborted`);
|
||||
return 1;
|
||||
|
||||
@@ -87,7 +87,8 @@ export default async function buy(
|
||||
!(await promptBool(
|
||||
`Buy now for ${chalk.bold(`$${price}`)} (${`${period}yr${
|
||||
period > 1 ? 's' : ''
|
||||
}`})?`
|
||||
}`})?`,
|
||||
client
|
||||
))
|
||||
) {
|
||||
return 0;
|
||||
@@ -99,7 +100,7 @@ export default async function buy(
|
||||
: `Auto renew every ${renewalPrice.period} years for ${chalk.bold(
|
||||
`$${price}`
|
||||
)}?`,
|
||||
{ defaultValue: true }
|
||||
{ ...client, defaultValue: true }
|
||||
);
|
||||
|
||||
let buyResult;
|
||||
|
||||
@@ -150,17 +150,7 @@ export default async function inspect(
|
||||
`This Domain is not configured properly. To configure it you should either:`,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
boxen: {
|
||||
margin: {
|
||||
left: 2,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
top: 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
null
|
||||
);
|
||||
output.print(
|
||||
` ${chalk.grey('a)')} ` +
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user