mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-12 04:22:14 +00:00
Compare commits
80 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c76dfbe8c9 | ||
|
|
ed6f3cc27e | ||
|
|
7b0186bffe | ||
|
|
45e22b6b60 | ||
|
|
b2bfae6e2e | ||
|
|
b6ed718f52 | ||
|
|
a84c4a37e6 | ||
|
|
d2ba06c6cb | ||
|
|
06e7753df0 | ||
|
|
235a9c3300 | ||
|
|
1b70402325 | ||
|
|
c76781fac9 | ||
|
|
451e0b0cfb | ||
|
|
cf477d45b2 | ||
|
|
cdd2d69e07 | ||
|
|
43f1f8b257 | ||
|
|
34055e3599 | ||
|
|
26abb0a85a | ||
|
|
a1e337e0dd | ||
|
|
b72ead480f | ||
|
|
77cf68105f | ||
|
|
d800f55dfa | ||
|
|
9dde99f19e | ||
|
|
fae7a083fc | ||
|
|
cbd651d6ee | ||
|
|
6077a706d1 | ||
|
|
cedc82dd9e | ||
|
|
b420006401 | ||
|
|
8ba604e8fc | ||
|
|
fadeee4568 | ||
|
|
2b15ba7f46 | ||
|
|
4cdfd0e58c | ||
|
|
b3ccb5f3ef | ||
|
|
584acc43b7 | ||
|
|
f64be93b94 | ||
|
|
9abd31769e | ||
|
|
09e3b35e74 | ||
|
|
8aa9a0ea05 | ||
|
|
b2d0ed74c6 | ||
|
|
aef936af0f | ||
|
|
501be936c0 | ||
|
|
7eba282af5 | ||
|
|
cf3e4bd726 | ||
|
|
ee5361b00e | ||
|
|
bd929dd5c5 | ||
|
|
4ee064bb61 | ||
|
|
312a2090a6 | ||
|
|
a82f117217 | ||
|
|
e908378486 | ||
|
|
8cda5263eb | ||
|
|
a24fd64bce | ||
|
|
0c515a46d5 | ||
|
|
f19690dc32 | ||
|
|
6b2a1c3866 | ||
|
|
1e54d606d7 | ||
|
|
c4ab0ebe9c | ||
|
|
321f1232a1 | ||
|
|
8a8203e149 | ||
|
|
33527165e7 | ||
|
|
db10383bc8 | ||
|
|
56960e506e | ||
|
|
a17f3a96ec | ||
|
|
9ff86a896c | ||
|
|
6ccb4354f9 | ||
|
|
82ba932447 | ||
|
|
b995618afb | ||
|
|
c897b24417 | ||
|
|
e64b2e1993 | ||
|
|
9358a5469e | ||
|
|
2a24210b7d | ||
|
|
2644a59984 | ||
|
|
4eeb8c298c | ||
|
|
0351f02dff | ||
|
|
0d7fa2f912 | ||
|
|
3b646880e7 | ||
|
|
350a0e5f36 | ||
|
|
5c21d400bd | ||
|
|
04029013a6 | ||
|
|
c65e7fa883 | ||
|
|
27b68be93f |
@@ -1,7 +1,12 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
examples
|
examples
|
||||||
|
|
||||||
|
packages/node/src/bridge.ts
|
||||||
|
|
||||||
packages/*/test/fixtures
|
packages/*/test/fixtures
|
||||||
|
|
||||||
|
# cli
|
||||||
packages/cli/@types
|
packages/cli/@types
|
||||||
packages/cli/download
|
packages/cli/download
|
||||||
packages/cli/dist
|
packages/cli/dist
|
||||||
@@ -9,9 +14,24 @@ packages/cli/test/dev/fixtures
|
|||||||
packages/cli/bin
|
packages/cli/bin
|
||||||
packages/cli/link
|
packages/cli/link
|
||||||
packages/cli/src/util/dev/templates/*.ts
|
packages/cli/src/util/dev/templates/*.ts
|
||||||
|
|
||||||
|
# client
|
||||||
packages/client/tests/fixtures
|
packages/client/tests/fixtures
|
||||||
packages/client/lib
|
packages/client/lib
|
||||||
packages/node/src/bridge.ts
|
|
||||||
|
# node-bridge
|
||||||
packages/node-bridge/bridge.js
|
packages/node-bridge/bridge.js
|
||||||
packages/node-bridge/launcher.js
|
packages/node-bridge/launcher.js
|
||||||
|
packages/node-bridge/helpers.js
|
||||||
|
packages/node-bridge/source-map-support.js
|
||||||
|
|
||||||
|
# middleware
|
||||||
packages/middleware/src/entries.js
|
packages/middleware/src/entries.js
|
||||||
|
|
||||||
|
# static-build
|
||||||
|
packages/static-build/test/fixtures
|
||||||
|
packages/static-build/test/build-fixtures
|
||||||
|
packages/static-build/test/cache-fixtures
|
||||||
|
|
||||||
|
# redwood
|
||||||
|
packages/redwood/test/fixtures
|
||||||
|
|||||||
6
.github/CONTRIBUTING.md
vendored
6
.github/CONTRIBUTING.md
vendored
@@ -16,17 +16,17 @@ yarn install
|
|||||||
yarn bootstrap
|
yarn bootstrap
|
||||||
yarn build
|
yarn build
|
||||||
yarn lint
|
yarn lint
|
||||||
yarn test
|
yarn test-unit
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure all the tests pass before making changes.
|
Make sure all the tests pass before making changes.
|
||||||
|
|
||||||
## Verifying your change
|
## Verifying your change
|
||||||
|
|
||||||
Once you are done with your changes (we even suggest doing it along the way), make sure all the test still run by running:
|
Once you are done with your changes (we even suggest doing it along the way), make sure all the test still pass by running:
|
||||||
|
|
||||||
```
|
```
|
||||||
yarn build && yarn test
|
yarn test-unit
|
||||||
```
|
```
|
||||||
|
|
||||||
from the root of the project.
|
from the root of the project.
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ A Runtime is an npm module that implements the following interface:
|
|||||||
interface Runtime {
|
interface Runtime {
|
||||||
version: number;
|
version: number;
|
||||||
build: (options: BuildOptions) => Promise<BuildResult>;
|
build: (options: BuildOptions) => Promise<BuildResult>;
|
||||||
analyze?: (options: AnalyzeOptions) => Promise<string>;
|
|
||||||
prepareCache?: (options: PrepareCacheOptions) => Promise<CacheOutputs>;
|
prepareCache?: (options: PrepareCacheOptions) => Promise<CacheOutputs>;
|
||||||
shouldServe?: (options: ShouldServeOptions) => Promise<boolean>;
|
shouldServe?: (options: ShouldServeOptions) => Promise<boolean>;
|
||||||
startDevServer?: (
|
startDevServer?: (
|
||||||
@@ -72,26 +71,6 @@ export async function build(options: BuildOptions) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### `analyze()`
|
|
||||||
|
|
||||||
An **optional** exported function that returns a unique fingerprint used for the
|
|
||||||
purpose of [build
|
|
||||||
de-duplication](https://vercel.com/docs/v2/platform/deployments#deduplication).
|
|
||||||
If the `analyze()` function is not supplied, then a random fingerprint is
|
|
||||||
assigned to each build.
|
|
||||||
|
|
||||||
**Example:**
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { AnalyzeOptions } from '@vercel/build-utils';
|
|
||||||
|
|
||||||
export async function analyze(options: AnalyzeOptions) {
|
|
||||||
// Do calculations to generate a fingerprint based off the source code here…
|
|
||||||
|
|
||||||
return 'fingerprint goes here';
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `prepareCache()`
|
### `prepareCache()`
|
||||||
|
|
||||||
An **optional** exported function that is executed after [`build()`](#build) is
|
An **optional** exported function that is executed after [`build()`](#build) is
|
||||||
|
|||||||
46
api/_lib/script/build.ts
Normal file
46
api/_lib/script/build.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import fs from 'fs/promises';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { getExampleList } from '../examples/example-list';
|
||||||
|
import { mapOldToNew } from '../examples/map-old-to-new';
|
||||||
|
|
||||||
|
const repoRoot = join(__dirname, '..', '..', '..');
|
||||||
|
const pubDir = join(repoRoot, 'public');
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log(`Building static frontend ${repoRoot}...`);
|
||||||
|
|
||||||
|
await fs.rm(pubDir, { recursive: true, force: true });
|
||||||
|
await fs.mkdir(pubDir);
|
||||||
|
|
||||||
|
const examples = await getExampleList();
|
||||||
|
const pathListAll = join(pubDir, 'list-all.json');
|
||||||
|
await fs.writeFile(pathListAll, JSON.stringify(examples));
|
||||||
|
|
||||||
|
const exampleDirs = await fs.readdir(join(repoRoot, 'examples'), {
|
||||||
|
withFileTypes: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const existingExamples = exampleDirs
|
||||||
|
.filter(dir => dir.isDirectory())
|
||||||
|
.map(dir => ({
|
||||||
|
name: dir.name,
|
||||||
|
visible: true,
|
||||||
|
suggestions: [],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const oldExamples = Object.keys(mapOldToNew).map(key => ({
|
||||||
|
name: key,
|
||||||
|
visible: false,
|
||||||
|
suggestions: mapOldToNew[key],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const pathList = join(pubDir, 'list.json');
|
||||||
|
await fs.writeFile(
|
||||||
|
pathList,
|
||||||
|
JSON.stringify([...existingExamples, ...oldExamples])
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('Completed building static frontend.');
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(console.error);
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { VercelRequest, VercelResponse } from '@vercel/node';
|
|
||||||
import { getExampleList } from '../_lib/examples/example-list';
|
|
||||||
import { withApiHandler } from '../_lib/util/with-api-handler';
|
|
||||||
|
|
||||||
export default withApiHandler(async function (
|
|
||||||
req: VercelRequest,
|
|
||||||
res: VercelResponse
|
|
||||||
) {
|
|
||||||
res.status(200).json(await getExampleList());
|
|
||||||
});
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { extract } from '../_lib/examples/extract';
|
|
||||||
import { summary } from '../_lib/examples/summary';
|
|
||||||
import { VercelRequest, VercelResponse } from '@vercel/node';
|
|
||||||
import { mapOldToNew } from '../_lib/examples/map-old-to-new';
|
|
||||||
import { withApiHandler } from '../_lib/util/with-api-handler';
|
|
||||||
|
|
||||||
export default withApiHandler(async function (
|
|
||||||
req: VercelRequest,
|
|
||||||
res: VercelResponse
|
|
||||||
) {
|
|
||||||
await extract('https://github.com/vercel/vercel/archive/main.zip', '/tmp');
|
|
||||||
const exampleList = summary('/tmp/vercel-main/examples');
|
|
||||||
|
|
||||||
const existingExamples = Array.from(exampleList).map(key => ({
|
|
||||||
name: key,
|
|
||||||
visible: true,
|
|
||||||
suggestions: [],
|
|
||||||
}));
|
|
||||||
|
|
||||||
const oldExamples = Object.keys(mapOldToNew).map(key => ({
|
|
||||||
name: key,
|
|
||||||
visible: false,
|
|
||||||
suggestions: mapOldToNew[key],
|
|
||||||
}));
|
|
||||||
|
|
||||||
res.status(200).json([...existingExamples, ...oldExamples]);
|
|
||||||
});
|
|
||||||
20
examples/eleventy/LICENSE.md
Normal file
20
examples/eleventy/LICENSE.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
MIT License
|
||||||
|
Copyright (c) 2022 Zach Leatherman @zachleat
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,5 +1,19 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/11ty/eleventy-base-blog.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Zach Leatherman",
|
||||||
|
"email": "zachleatherman@gmail.com",
|
||||||
|
"url": "https://zachleat.com/"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/11ty/eleventy-base-blog/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/11ty/eleventy-base-blog#readme",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "eleventy",
|
"build": "eleventy",
|
||||||
"watch": "eleventy --watch",
|
"watch": "eleventy --watch",
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ async function main() {
|
|||||||
// if it's an empty string, just ignore it
|
// if it's an empty string, just ignore it
|
||||||
if (!formatted) return false;
|
if (!formatted) return false;
|
||||||
|
|
||||||
let type = url.substr(-3) == 'css' ? 'style' : 'script';
|
let type = url.slice(-3) == 'css' ? 'style' : 'script';
|
||||||
results += `</${formatted}>;rel=preload;as=${type},`;
|
results += `</${formatted}>;rel=preload;as=${type},`;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
1
examples/nextjs/.gitignore
vendored
1
examples/nextjs/.gitignore
vendored
@@ -23,6 +23,7 @@
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
module.exports = {
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = nextConfig
|
||||||
|
|||||||
6477
examples/nextjs/package-lock.json
generated
6477
examples/nextjs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,12 @@
|
|||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"next": "^12.0.8",
|
"next": "12.1.0",
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
"react-dom": "17.0.2"
|
"react-dom": "17.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "8.7.0",
|
"eslint": "8.9.0",
|
||||||
"eslint-config-next": "^12.0.8"
|
"eslint-config-next": "12.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1633
examples/nextjs/yarn.lock
Normal file
1633
examples/nextjs/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ export default function Index() {
|
|||||||
<p>
|
<p>
|
||||||
Wait a sec...<em>its children</em>? To understand what we mean by
|
Wait a sec...<em>its children</em>? To understand what we mean by
|
||||||
this,{" "}
|
this,{" "}
|
||||||
<a href="https://remix.run/tutorial/4-nested-routes-params">
|
<a href="https://remix.run/docs/en/v1/guides/routing">
|
||||||
read all about nested routes in the docs
|
read all about nested routes in the docs
|
||||||
</a>
|
</a>
|
||||||
.
|
.
|
||||||
|
|||||||
3
examples/sanity/.env.template
Normal file
3
examples/sanity/.env.template
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Run `vercel env pull` to generate a .env file from your Vercel project
|
||||||
|
SANITY_STUDIO_API_PROJECT_ID=
|
||||||
|
SANITY_STUDIO_API_DATASET=
|
||||||
12
examples/sanity/.npmignore
Normal file
12
examples/sanity/.npmignore
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Logs
|
||||||
|
/logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Compiled sanity studio
|
||||||
|
/dist
|
||||||
29
examples/sanity/README.md
Normal file
29
examples/sanity/README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Sanity Blogging Content Studio
|
||||||
|
|
||||||
|
Congratulations, you have now installed Sanity Studio, an open source real-time content editing environment connected to the Sanity backend.
|
||||||
|
|
||||||
|
Now you can do the following things:
|
||||||
|
|
||||||
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
||||||
|
- Check out the example frontend: [React/Next.js](https://github.com/sanity-io/tutorial-sanity-blog-react-next)
|
||||||
|
- [Read the blog post about this template](https://www.sanity.io/blog/build-your-own-blog-with-sanity-and-next-js?utm_source=readme)
|
||||||
|
- [Join the community Slack](https://slack.sanity.io/?utm_source=readme)
|
||||||
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
||||||
|
|
||||||
|
## Develop locally
|
||||||
|
|
||||||
|
Install dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx @sanity/cli install
|
||||||
|
```
|
||||||
|
|
||||||
|
Pull down environment variables from your Vercel project (requires the [Vercel CLI](https://vercel.com/cli)):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
vercel env pull
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
You can also run `npx @sanity/init` in this repo and agree to reconfigure it. You'll then be able to select from existing projects. The CLI will update `sanity.json` with the project ID and dataset name.
|
||||||
7
examples/sanity/config/.checksums
Normal file
7
examples/sanity/config/.checksums
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"#": "Used by Sanity to keep track of configuration file checksums, do not delete or modify!",
|
||||||
|
"@sanity/default-layout": "bb034f391ba508a6ca8cd971967cbedeb131c4d19b17b28a0895f32db5d568ea",
|
||||||
|
"@sanity/default-login": "6fb6d3800aa71346e1b84d95bbcaa287879456f2922372bb0294e30b968cd37f",
|
||||||
|
"@sanity/form-builder": "b38478227ba5e22c91981da4b53436df22e48ff25238a55a973ed620be5068aa",
|
||||||
|
"@sanity/data-aspects": "d199e2c199b3e26cd28b68dc84d7fc01c9186bf5089580f2e2446994d36b3cb6"
|
||||||
|
}
|
||||||
3
examples/sanity/config/@sanity/data-aspects.json
Normal file
3
examples/sanity/config/@sanity/data-aspects.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"listOptions": {}
|
||||||
|
}
|
||||||
6
examples/sanity/config/@sanity/default-layout.json
Normal file
6
examples/sanity/config/@sanity/default-layout.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"toolSwitcher": {
|
||||||
|
"order": [],
|
||||||
|
"hidden": []
|
||||||
|
}
|
||||||
|
}
|
||||||
7
examples/sanity/config/@sanity/default-login.json
Normal file
7
examples/sanity/config/@sanity/default-login.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"providers": {
|
||||||
|
"mode": "append",
|
||||||
|
"redirectOnSingle": false,
|
||||||
|
"entries": []
|
||||||
|
}
|
||||||
|
}
|
||||||
5
examples/sanity/config/@sanity/form-builder.json
Normal file
5
examples/sanity/config/@sanity/form-builder.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"images": {
|
||||||
|
"directUploads": true
|
||||||
|
}
|
||||||
|
}
|
||||||
30
examples/sanity/package.json
Normal file
30
examples/sanity/package.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "verceltemplateblogstudio",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "This is the public list of examples for **Vercel**",
|
||||||
|
"main": "package.json",
|
||||||
|
"author": "Knut Melvær <knut@sanity.io>",
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"start": "sanity start",
|
||||||
|
"build": "sanity build"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"sanity"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@sanity/core": "^2.26",
|
||||||
|
"@sanity/default-layout": "^2.26",
|
||||||
|
"@sanity/default-login": "^2.26",
|
||||||
|
"@sanity/desk-tool": "^2.26",
|
||||||
|
"@sanity/vision": "^2.26",
|
||||||
|
"prop-types": "^15.7",
|
||||||
|
"react": "^17.0",
|
||||||
|
"react-dom": "^17.0",
|
||||||
|
"styled-components": "^5.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sanity/cli": "^2.26"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
examples/sanity/plugins/.gitkeep
Normal file
1
examples/sanity/plugins/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
User-specific packages can be placed here
|
||||||
29
examples/sanity/sanity.json
Normal file
29
examples/sanity/sanity.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"project": {
|
||||||
|
"name": "vercel-template-blog-studio"
|
||||||
|
},
|
||||||
|
"api": {
|
||||||
|
"projectId": "YOUR_PROJECT_ID",
|
||||||
|
"dataset": "YOUR_DATASET_NAME"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@sanity/base",
|
||||||
|
"@sanity/default-layout",
|
||||||
|
"@sanity/default-login",
|
||||||
|
"@sanity/desk-tool"
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"development": {
|
||||||
|
"plugins": [
|
||||||
|
"@sanity/vision"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parts": [
|
||||||
|
{
|
||||||
|
"name": "part:@sanity/base/schema",
|
||||||
|
"path": "./schemas/schema"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
48
examples/sanity/schemas/author.js
Normal file
48
examples/sanity/schemas/author.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
export default {
|
||||||
|
name: 'author',
|
||||||
|
title: 'Author',
|
||||||
|
type: 'document',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
title: 'Name',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'slug',
|
||||||
|
title: 'Slug',
|
||||||
|
type: 'slug',
|
||||||
|
options: {
|
||||||
|
source: 'name',
|
||||||
|
maxLength: 96,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'image',
|
||||||
|
title: 'Image',
|
||||||
|
type: 'image',
|
||||||
|
options: {
|
||||||
|
hotspot: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'bio',
|
||||||
|
title: 'Bio',
|
||||||
|
type: 'array',
|
||||||
|
of: [
|
||||||
|
{
|
||||||
|
title: 'Block',
|
||||||
|
type: 'block',
|
||||||
|
styles: [{title: 'Normal', value: 'normal'}],
|
||||||
|
lists: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
preview: {
|
||||||
|
select: {
|
||||||
|
title: 'name',
|
||||||
|
media: 'image',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
65
examples/sanity/schemas/blockContent.js
Normal file
65
examples/sanity/schemas/blockContent.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* This is the schema definition for the rich text fields used for
|
||||||
|
* for this blog studio. When you import it in schemas.js it can be
|
||||||
|
* reused in other parts of the studio with:
|
||||||
|
* {
|
||||||
|
* name: 'someName',
|
||||||
|
* title: 'Some title',
|
||||||
|
* type: 'blockContent'
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
title: 'Block Content',
|
||||||
|
name: 'blockContent',
|
||||||
|
type: 'array',
|
||||||
|
of: [
|
||||||
|
{
|
||||||
|
title: 'Block',
|
||||||
|
type: 'block',
|
||||||
|
// Styles let you set what your user can mark up blocks with. These
|
||||||
|
// correspond with HTML tags, but you can set any title or value
|
||||||
|
// you want and decide how you want to deal with it where you want to
|
||||||
|
// use your content.
|
||||||
|
styles: [
|
||||||
|
{title: 'Normal', value: 'normal'},
|
||||||
|
{title: 'H1', value: 'h1'},
|
||||||
|
{title: 'H2', value: 'h2'},
|
||||||
|
{title: 'H3', value: 'h3'},
|
||||||
|
{title: 'H4', value: 'h4'},
|
||||||
|
{title: 'Quote', value: 'blockquote'},
|
||||||
|
],
|
||||||
|
lists: [{title: 'Bullet', value: 'bullet'}],
|
||||||
|
// Marks let you mark up inline text in the block editor.
|
||||||
|
marks: {
|
||||||
|
// Decorators usually describe a single property – e.g. a typographic
|
||||||
|
// preference or highlighting by editors.
|
||||||
|
decorators: [
|
||||||
|
{title: 'Strong', value: 'strong'},
|
||||||
|
{title: 'Emphasis', value: 'em'},
|
||||||
|
],
|
||||||
|
// Annotations can be any object structure – e.g. a link or a footnote.
|
||||||
|
annotations: [
|
||||||
|
{
|
||||||
|
title: 'URL',
|
||||||
|
name: 'link',
|
||||||
|
type: 'object',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
title: 'URL',
|
||||||
|
name: 'href',
|
||||||
|
type: 'url',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// You can add additional types here. Note that you can't use
|
||||||
|
// primitive types such as 'string' and 'number' in the same array
|
||||||
|
// as a block type.
|
||||||
|
{
|
||||||
|
type: 'image',
|
||||||
|
options: {hotspot: true},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
17
examples/sanity/schemas/category.js
Normal file
17
examples/sanity/schemas/category.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
name: 'category',
|
||||||
|
title: 'Category',
|
||||||
|
type: 'document',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
title: 'Title',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
title: 'Description',
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
65
examples/sanity/schemas/post.js
Normal file
65
examples/sanity/schemas/post.js
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
export default {
|
||||||
|
name: 'post',
|
||||||
|
title: 'Post',
|
||||||
|
type: 'document',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'title',
|
||||||
|
title: 'Title',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'slug',
|
||||||
|
title: 'Slug',
|
||||||
|
type: 'slug',
|
||||||
|
options: {
|
||||||
|
source: 'title',
|
||||||
|
maxLength: 96,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'author',
|
||||||
|
title: 'Author',
|
||||||
|
type: 'reference',
|
||||||
|
to: {type: 'author'},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'mainImage',
|
||||||
|
title: 'Main image',
|
||||||
|
type: 'image',
|
||||||
|
options: {
|
||||||
|
hotspot: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'categories',
|
||||||
|
title: 'Categories',
|
||||||
|
type: 'array',
|
||||||
|
of: [{type: 'reference', to: {type: 'category'}}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publishedAt',
|
||||||
|
title: 'Published at',
|
||||||
|
type: 'datetime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'body',
|
||||||
|
title: 'Body',
|
||||||
|
type: 'blockContent',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
preview: {
|
||||||
|
select: {
|
||||||
|
title: 'title',
|
||||||
|
author: 'author.name',
|
||||||
|
media: 'mainImage',
|
||||||
|
},
|
||||||
|
prepare(selection) {
|
||||||
|
const {author} = selection
|
||||||
|
return Object.assign({}, selection, {
|
||||||
|
subtitle: author && `by ${author}`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
29
examples/sanity/schemas/schema.js
Normal file
29
examples/sanity/schemas/schema.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// First, we must import the schema creator
|
||||||
|
import createSchema from 'part:@sanity/base/schema-creator'
|
||||||
|
|
||||||
|
// Then import schema types from any plugins that might expose them
|
||||||
|
import schemaTypes from 'all:part:@sanity/base/schema-type'
|
||||||
|
|
||||||
|
// We import object and document schemas
|
||||||
|
import blockContent from './blockContent'
|
||||||
|
import category from './category'
|
||||||
|
import post from './post'
|
||||||
|
import author from './author'
|
||||||
|
|
||||||
|
// Then we give our schema to the builder and provide the result to Sanity
|
||||||
|
export default createSchema({
|
||||||
|
// We name our schema
|
||||||
|
name: 'default',
|
||||||
|
// Then proceed to concatenate our document type
|
||||||
|
// to the ones provided by any plugins that are installed
|
||||||
|
types: schemaTypes.concat([
|
||||||
|
// The following are document types which will appear
|
||||||
|
// in the studio.
|
||||||
|
post,
|
||||||
|
author,
|
||||||
|
category,
|
||||||
|
// When added to this list, object types can be used as
|
||||||
|
// { type: 'typename' } in other document schemas
|
||||||
|
blockContent,
|
||||||
|
]),
|
||||||
|
})
|
||||||
1
examples/sanity/static/.gitkeep
Normal file
1
examples/sanity/static/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Files placed here will be served by the Sanity server under the `/static`-prefix
|
||||||
BIN
examples/sanity/static/favicon.ico
Normal file
BIN
examples/sanity/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
6
examples/sanity/tsconfig.json
Normal file
6
examples/sanity/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
// Note: This config is only used to help editors like VS Code understand/resolve
|
||||||
|
// parts, the actual transpilation is done by babel. Any compiler configuration in
|
||||||
|
// here will be ignored.
|
||||||
|
"include": ["./node_modules/@sanity/base/types/**/*.ts", "./**/*.ts", "./**/*.tsx"]
|
||||||
|
}
|
||||||
9911
examples/sanity/yarn.lock
Normal file
9911
examples/sanity/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ export class AppProfile {
|
|||||||
|
|
||||||
normalize(name: string): string {
|
normalize(name: string): string {
|
||||||
if (name) {
|
if (name) {
|
||||||
return name.substr(0, 1).toUpperCase() + name.substr(1).toLowerCase();
|
return name.slice(0, 1).toUpperCase() + name.slice(1).toLowerCase();
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
670
examples/sveltekit/package-lock.json
generated
670
examples/sveltekit/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"name": "sveltekit",
|
||||||
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "svelte-kit dev",
|
"dev": "svelte-kit dev",
|
||||||
"build": "svelte-kit build",
|
"build": "svelte-kit build",
|
||||||
@@ -9,7 +11,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "next",
|
"@sveltejs/adapter-auto": "next",
|
||||||
"@sveltejs/kit": "next",
|
"@sveltejs/kit": "next",
|
||||||
"svelte": "^3.44.0"
|
"svelte": "^3.46.0"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
%svelte.head%
|
%svelte.head%
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="svelte">%svelte.body%</div>
|
<div>%svelte.body%</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
1
examples/sveltekit/src/global.d.ts
vendored
1
examples/sveltekit/src/global.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
/// <reference types="@sveltejs/kit" />
|
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
import cookie from 'cookie';
|
import cookie from 'cookie';
|
||||||
import { v4 as uuid } from '@lukeed/uuid';
|
import { v4 as uuid } from '@lukeed/uuid';
|
||||||
|
|
||||||
export const handle = async ({ request, resolve }) => {
|
export const handle = async ({ event, resolve }) => {
|
||||||
const cookies = cookie.parse(request.headers.cookie || '');
|
const cookies = cookie.parse(event.request.headers.get('cookie') || '');
|
||||||
request.locals.userid = cookies.userid || uuid();
|
event.locals.userid = cookies.userid || uuid();
|
||||||
|
|
||||||
const response = await resolve(request);
|
const response = await resolve(event);
|
||||||
|
|
||||||
if (!cookies.userid) {
|
if (!cookies.userid) {
|
||||||
// if this is the first time the user has visited this app,
|
// if this is the first time the user has visited this app,
|
||||||
// set a cookie so that we recognise them when they return
|
// set a cookie so that we recognise them when they return
|
||||||
response.headers['set-cookie'] = cookie.serialize('userid', request.locals.userid, {
|
response.headers.set(
|
||||||
|
'set-cookie',
|
||||||
|
cookie.serialize('userid', event.locals.userid, {
|
||||||
path: '/',
|
path: '/',
|
||||||
httpOnly: true
|
httpOnly: true
|
||||||
});
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<div class="counter-viewport">
|
<div class="counter-viewport">
|
||||||
<div class="counter-digits" style="transform: translate(0, {100 * offset}%)">
|
<div class="counter-digits" style="transform: translate(0, {100 * offset}%)">
|
||||||
<strong style="top: -100%" aria-hidden="true">{Math.floor($displayed_count + 1)}</strong>
|
<strong class="hidden" aria-hidden="true">{Math.floor($displayed_count + 1)}</strong>
|
||||||
<strong>{Math.floor($displayed_count)}</strong>
|
<strong>{Math.floor($displayed_count)}</strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -94,4 +94,9 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
top: -100%;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { invalidate } from '$app/navigation';
|
||||||
|
|
||||||
// this action (https://svelte.dev/tutorial/actions) allows us to
|
// this action (https://svelte.dev/tutorial/actions) allows us to
|
||||||
// progressively enhance a <form> that already works without JS
|
// progressively enhance a <form> that already works without JS
|
||||||
export function enhance(form, { pending, error, result }) {
|
export function enhance(form, { pending, error, result } = {}) {
|
||||||
let current_token;
|
let current_token;
|
||||||
|
|
||||||
async function handle_submit(e) {
|
async function handle_submit(e) {
|
||||||
@@ -8,31 +10,35 @@ export function enhance(form, { pending, error, result }) {
|
|||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const body = new FormData(form);
|
const data = new FormData(form);
|
||||||
|
|
||||||
if (pending) pending(body, form);
|
if (pending) pending({ data, form });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(form.action, {
|
const response = await fetch(form.action, {
|
||||||
method: form.method,
|
method: form.method,
|
||||||
headers: {
|
headers: {
|
||||||
accept: 'application/json'
|
accept: 'application/json'
|
||||||
},
|
},
|
||||||
body
|
body: data
|
||||||
});
|
});
|
||||||
|
|
||||||
if (token !== current_token) return;
|
if (token !== current_token) return;
|
||||||
|
|
||||||
if (res.ok) {
|
if (response.ok) {
|
||||||
result(res, form);
|
if (result) result({ data, form, response });
|
||||||
|
|
||||||
|
const url = new URL(form.action);
|
||||||
|
url.search = url.hash = '';
|
||||||
|
invalidate(url.href);
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
error(res, null, form);
|
error({ data, form, error: null, response });
|
||||||
} else {
|
} else {
|
||||||
console.error(await res.text());
|
console.error(await response.text());
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (error) {
|
if (error) {
|
||||||
error(null, e, form);
|
error({ data, form, error: e, response: null });
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import { api } from './_api';
|
|
||||||
|
|
||||||
// PATCH /todos/:uid.json
|
|
||||||
export const patch = async (request) => {
|
|
||||||
return api(request, `todos/${request.locals.userid}/${request.params.uid}`, {
|
|
||||||
text: request.body.get('text'),
|
|
||||||
done: request.body.has('done') ? !!request.body.get('done') : undefined
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// DELETE /todos/:uid.json
|
|
||||||
export const del = async (request) => {
|
|
||||||
return api(request, `todos/${request.locals.userid}/${request.params.uid}`);
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This module is used by the /todos.json and /todos/[uid].json
|
This module is used by the /todos endpoint to
|
||||||
endpoints to make calls to api.svelte.dev, which stores todos
|
make calls to api.svelte.dev, which stores todos
|
||||||
for each user. The leading underscore indicates that this is
|
for each user. The leading underscore indicates that this is
|
||||||
a private module, _not_ an endpoint — visiting /todos/_api
|
a private module, _not_ an endpoint — visiting /todos/_api
|
||||||
will net you a 404 response.
|
will net you a 404 response.
|
||||||
@@ -11,35 +11,12 @@
|
|||||||
|
|
||||||
const base = 'https://api.svelte.dev';
|
const base = 'https://api.svelte.dev';
|
||||||
|
|
||||||
export async function api(request, resource, data) {
|
export function api(method, resource, data) {
|
||||||
// user must have a cookie set
|
return fetch(`${base}/${resource}`, {
|
||||||
if (!request.locals.userid) {
|
method,
|
||||||
return { status: 401 };
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await fetch(`${base}/${resource}`, {
|
|
||||||
method: request.method,
|
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json'
|
'content-type': 'application/json'
|
||||||
},
|
},
|
||||||
body: data && JSON.stringify(data)
|
body: data && JSON.stringify(data)
|
||||||
});
|
});
|
||||||
|
|
||||||
// if the request came from a <form> submission, the browser's default
|
|
||||||
// behaviour is to show the URL corresponding to the form's "action"
|
|
||||||
// attribute. in those cases, we want to redirect them back to the
|
|
||||||
// /todos page, rather than showing the response
|
|
||||||
if (res.ok && request.method !== 'GET' && request.headers.accept !== 'application/json') {
|
|
||||||
return {
|
|
||||||
status: 303,
|
|
||||||
headers: {
|
|
||||||
location: '/todos'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
status: res.status,
|
|
||||||
body: await res.json()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
66
examples/sveltekit/src/routes/todos/index.js
Normal file
66
examples/sveltekit/src/routes/todos/index.js
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import { api } from './_api';
|
||||||
|
|
||||||
|
export const get = async ({ locals }) => {
|
||||||
|
// locals.userid comes from src/hooks.js
|
||||||
|
const response = await api('get', `todos/${locals.userid}`);
|
||||||
|
|
||||||
|
if (response.status === 404) {
|
||||||
|
// user hasn't created a todo list.
|
||||||
|
// start with an empty array
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
todos: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
todos: await response.json()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: response.status
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const post = async ({ request, locals }) => {
|
||||||
|
const form = await request.formData();
|
||||||
|
|
||||||
|
await api('post', `todos/${locals.userid}`, {
|
||||||
|
text: form.get('text')
|
||||||
|
});
|
||||||
|
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
// If the user has JavaScript disabled, the URL will change to
|
||||||
|
// include the method override unless we redirect back to /todos
|
||||||
|
const redirect = {
|
||||||
|
status: 303,
|
||||||
|
headers: {
|
||||||
|
location: '/todos'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const patch = async ({ request, locals }) => {
|
||||||
|
const form = await request.formData();
|
||||||
|
|
||||||
|
await api('patch', `todos/${locals.userid}/${form.get('uid')}`, {
|
||||||
|
text: form.has('text') ? form.get('text') : undefined,
|
||||||
|
done: form.has('done') ? !!form.get('done') : undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
return redirect;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const del = async ({ request, locals }) => {
|
||||||
|
const form = await request.formData();
|
||||||
|
|
||||||
|
await api('delete', `todos/${locals.userid}/${form.get('uid')}`);
|
||||||
|
|
||||||
|
return redirect;
|
||||||
|
};
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { api } from './_api';
|
|
||||||
|
|
||||||
// GET /todos.json
|
|
||||||
export const get = async (request) => {
|
|
||||||
// request.locals.userid comes from src/hooks.js
|
|
||||||
const response = await api(request, `todos/${request.locals.userid}`);
|
|
||||||
|
|
||||||
if (response.status === 404) {
|
|
||||||
// user hasn't created a todo list.
|
|
||||||
// start with an empty array
|
|
||||||
return { body: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
|
|
||||||
// POST /todos.json
|
|
||||||
export const post = async (request) => {
|
|
||||||
const response = await api(request, `todos/${request.locals.userid}`, {
|
|
||||||
// because index.svelte posts a FormData object,
|
|
||||||
// request.body is _also_ a (readonly) FormData
|
|
||||||
// object, which allows us to get form data
|
|
||||||
// with the `body.get(key)` method
|
|
||||||
text: request.body.get('text')
|
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
@@ -1,40 +1,9 @@
|
|||||||
<script context="module">
|
|
||||||
import { enhance } from '$lib/form';
|
|
||||||
|
|
||||||
// see https://kit.svelte.dev/docs#loading
|
|
||||||
export const load = async ({ fetch }) => {
|
|
||||||
const res = await fetch('/todos.json');
|
|
||||||
|
|
||||||
if (res.ok) {
|
|
||||||
const todos = await res.json();
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: { todos }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const { message } = await res.json();
|
|
||||||
|
|
||||||
return {
|
|
||||||
error: new Error(message)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { enhance } from '$lib/form';
|
||||||
import { scale } from 'svelte/transition';
|
import { scale } from 'svelte/transition';
|
||||||
import { flip } from 'svelte/animate';
|
import { flip } from 'svelte/animate';
|
||||||
|
|
||||||
export let todos;
|
export let todos;
|
||||||
|
|
||||||
async function patch(res) {
|
|
||||||
const todo = await res.json();
|
|
||||||
|
|
||||||
todos = todos.map((t) => {
|
|
||||||
if (t.uid === todo.uid) return todo;
|
|
||||||
return t;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -46,13 +15,10 @@
|
|||||||
|
|
||||||
<form
|
<form
|
||||||
class="new"
|
class="new"
|
||||||
action="/todos.json"
|
action="/todos"
|
||||||
method="post"
|
method="post"
|
||||||
use:enhance={{
|
use:enhance={{
|
||||||
result: async (res, form) => {
|
result: async ({ form }) => {
|
||||||
const created = await res.json();
|
|
||||||
todos = [...todos, created];
|
|
||||||
|
|
||||||
form.reset();
|
form.reset();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -68,41 +34,33 @@
|
|||||||
animate:flip={{ duration: 200 }}
|
animate:flip={{ duration: 200 }}
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
action="/todos/{todo.uid}.json?_method=PATCH"
|
action="/todos?_method=PATCH"
|
||||||
method="post"
|
method="post"
|
||||||
use:enhance={{
|
use:enhance={{
|
||||||
pending: (data) => {
|
pending: ({ data }) => {
|
||||||
todo.done = !!data.get('done');
|
todo.done = !!data.get('done');
|
||||||
},
|
}
|
||||||
result: patch
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<input type="hidden" name="uid" value={todo.uid} />
|
||||||
<input type="hidden" name="done" value={todo.done ? '' : 'true'} />
|
<input type="hidden" name="done" value={todo.done ? '' : 'true'} />
|
||||||
<button class="toggle" aria-label="Mark todo as {todo.done ? 'not done' : 'done'}" />
|
<button class="toggle" aria-label="Mark todo as {todo.done ? 'not done' : 'done'}" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form
|
<form class="text" action="/todos?_method=PATCH" method="post" use:enhance>
|
||||||
class="text"
|
<input type="hidden" name="uid" value={todo.uid} />
|
||||||
action="/todos/{todo.uid}.json?_method=PATCH"
|
|
||||||
method="post"
|
|
||||||
use:enhance={{
|
|
||||||
result: patch
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input aria-label="Edit todo" type="text" name="text" value={todo.text} />
|
<input aria-label="Edit todo" type="text" name="text" value={todo.text} />
|
||||||
<button class="save" aria-label="Save todo" />
|
<button class="save" aria-label="Save todo" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
action="/todos/{todo.uid}.json?_method=DELETE"
|
action="/todos?_method=DELETE"
|
||||||
method="post"
|
method="post"
|
||||||
use:enhance={{
|
use:enhance={{
|
||||||
pending: () => (todo.pending_delete = true),
|
pending: () => (todo.pending_delete = true)
|
||||||
result: () => {
|
|
||||||
todos = todos.filter((t) => t.uid !== todo.uid);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<input type="hidden" name="uid" value={todo.uid} />
|
||||||
<button class="delete" aria-label="Delete todo" disabled={todo.pending_delete} />
|
<button class="delete" aria-label="Delete todo" disabled={todo.pending_delete} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -158,7 +116,7 @@
|
|||||||
.done {
|
.done {
|
||||||
transform: none;
|
transform: none;
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, 0.1));
|
filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.1));
|
||||||
}
|
}
|
||||||
|
|
||||||
form.text {
|
form.text {
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ const config = {
|
|||||||
kit: {
|
kit: {
|
||||||
adapter: adapter(),
|
adapter: adapter(),
|
||||||
|
|
||||||
// hydrate the <div id="svelte"> element in src/app.html
|
// Override http methods in the Todo forms
|
||||||
target: '#svelte'
|
methodOverride: {
|
||||||
|
allowed: ['PATCH', 'DELETE']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
17
package.json
17
package.json
@@ -32,7 +32,6 @@
|
|||||||
"@typescript-eslint/parser": "4.28.0",
|
"@typescript-eslint/parser": "4.28.0",
|
||||||
"async-retry": "1.2.3",
|
"async-retry": "1.2.3",
|
||||||
"buffer-replace": "1.0.0",
|
"buffer-replace": "1.0.0",
|
||||||
"cheerio": "1.0.0-rc.3",
|
|
||||||
"eslint": "7.29.0",
|
"eslint": "7.29.0",
|
||||||
"eslint-config-prettier": "8.3.0",
|
"eslint-config-prettier": "8.3.0",
|
||||||
"eslint-plugin-jest": "24.3.6",
|
"eslint-plugin-jest": "24.3.6",
|
||||||
@@ -43,8 +42,9 @@
|
|||||||
"node-fetch": "2.6.1",
|
"node-fetch": "2.6.1",
|
||||||
"npm-package-arg": "6.1.0",
|
"npm-package-arg": "6.1.0",
|
||||||
"prettier": "2.3.1",
|
"prettier": "2.3.1",
|
||||||
|
"ts-eager": "2.0.2",
|
||||||
"ts-jest": "27.0.4",
|
"ts-jest": "27.0.4",
|
||||||
"turbo": "1.0.18"
|
"turbo": "1.1.9"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lerna": "lerna",
|
"lerna": "lerna",
|
||||||
@@ -54,9 +54,10 @@
|
|||||||
"publish-from-github": "./utils/publish.sh",
|
"publish-from-github": "./utils/publish.sh",
|
||||||
"changelog": "node utils/changelog.js",
|
"changelog": "node utils/changelog.js",
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"vercel-build": "mkdir -p public && echo '<a href=\"https://vercel.com/import\">Import</a>' > public/output.html",
|
"vercel-build": "yarn build && cd api && node -r ts-eager/register ./_lib/script/build.ts",
|
||||||
"pre-commit": "lint-staged",
|
"pre-commit": "lint-staged",
|
||||||
"test-unit": "node utils/run.js test-unit",
|
"test": "jest --rootDir=\"test\" --testPathPattern=\"\\.test.js\"",
|
||||||
|
"test-unit": "yarn test && node utils/run.js test-unit",
|
||||||
"test-integration-cli": "node utils/run.js test-integration-cli",
|
"test-integration-cli": "node utils/run.js test-integration-cli",
|
||||||
"test-integration-once": "node utils/run.js test-integration-once",
|
"test-integration-once": "node utils/run.js test-integration-once",
|
||||||
"test-integration-dev": "node utils/run.js test-integration-dev",
|
"test-integration-dev": "node utils/run.js test-integration-dev",
|
||||||
@@ -102,6 +103,14 @@
|
|||||||
"es6": true
|
"es6": true
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"no-restricted-syntax": [
|
||||||
|
"warn",
|
||||||
|
"WithStatement",
|
||||||
|
{
|
||||||
|
"message": "substr() is deprecated, use slice() or substring() instead",
|
||||||
|
"selector": "MemberExpression > Identifier[name='substr']"
|
||||||
|
}
|
||||||
|
],
|
||||||
"require-atomic-updates": 0,
|
"require-atomic-updates": 0,
|
||||||
"@typescript-eslint/ban-ts-comment": 0,
|
"@typescript-eslint/ban-ts-comment": 0,
|
||||||
"@typescript-eslint/camelcase": 0,
|
"@typescript-eslint/camelcase": 0,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
/src
|
/src
|
||||||
/test
|
/test
|
||||||
|
/tsconfig.json
|
||||||
|
/.turbo
|
||||||
|
/jest.config.js
|
||||||
tmp
|
tmp
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@vercel/build-utils",
|
"name": "@vercel/build-utils",
|
||||||
"version": "2.14.0",
|
"version": "2.15.1-canary.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"types": "./dist/index.d.js",
|
"types": "./dist/index.d.js",
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
"@types/node-fetch": "^2.1.6",
|
"@types/node-fetch": "^2.1.6",
|
||||||
"@types/semver": "6.0.0",
|
"@types/semver": "6.0.0",
|
||||||
"@types/yazl": "^2.4.1",
|
"@types/yazl": "^2.4.1",
|
||||||
"@vercel/frameworks": "0.6.0",
|
"@vercel/frameworks": "0.7.1-canary.0",
|
||||||
"@vercel/ncc": "0.24.0",
|
"@vercel/ncc": "0.24.0",
|
||||||
"aggregate-error": "3.0.1",
|
"aggregate-error": "3.0.1",
|
||||||
"async-retry": "1.2.3",
|
"async-retry": "1.2.3",
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ function getPublicBuilder(
|
|||||||
typeof builder.src === 'string' &&
|
typeof builder.src === 'string' &&
|
||||||
isOfficialRuntime('static', builder.use) &&
|
isOfficialRuntime('static', builder.use) &&
|
||||||
/^.*\/\*\*\/\*$/.test(builder.src) &&
|
/^.*\/\*\*\/\*$/.test(builder.src) &&
|
||||||
builder.config &&
|
builder.config?.zeroConfig === true
|
||||||
builder.config.zeroConfig === true
|
|
||||||
) {
|
) {
|
||||||
return builder as Builder & { src: string };
|
return builder as Builder & { src: string };
|
||||||
}
|
}
|
||||||
|
|||||||
44
packages/build-utils/src/edge-function.ts
Normal file
44
packages/build-utils/src/edge-function.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import type { Files } from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Edge Functions output
|
||||||
|
*/
|
||||||
|
export class EdgeFunction {
|
||||||
|
type: 'EdgeFunction';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A display name for the edge function.
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The deployment target.
|
||||||
|
* Only v8-worker is currently supported.
|
||||||
|
*/
|
||||||
|
deploymentTarget: 'v8-worker';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entrypoint for the edge function.
|
||||||
|
*/
|
||||||
|
entrypoint: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of files to be included in the edge function bundle.
|
||||||
|
*/
|
||||||
|
files: Files;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra environment variables in use for the user code, to be
|
||||||
|
* assigned to the edge function.
|
||||||
|
*/
|
||||||
|
envVarsInUse?: string[];
|
||||||
|
|
||||||
|
constructor(params: Omit<EdgeFunction, 'type'>) {
|
||||||
|
this.type = 'EdgeFunction';
|
||||||
|
this.name = params.name;
|
||||||
|
this.deploymentTarget = params.deploymentTarget;
|
||||||
|
this.entrypoint = params.entrypoint;
|
||||||
|
this.files = params.files;
|
||||||
|
this.envVarsInUse = params.envVarsInUse;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import intoStream from 'into-stream';
|
import intoStream from 'into-stream';
|
||||||
import { File } from './types';
|
import { FileBase } from './types';
|
||||||
|
|
||||||
interface FileBlobOptions {
|
interface FileBlobOptions {
|
||||||
mode?: number;
|
mode?: number;
|
||||||
@@ -14,7 +14,7 @@ interface FromStreamOptions {
|
|||||||
stream: NodeJS.ReadableStream;
|
stream: NodeJS.ReadableStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class FileBlob implements File {
|
export default class FileBlob implements FileBase {
|
||||||
public type: 'FileBlob';
|
public type: 'FileBlob';
|
||||||
public mode: number;
|
public mode: number;
|
||||||
public data: string | Buffer;
|
public data: string | Buffer;
|
||||||
@@ -48,6 +48,10 @@ export default class FileBlob implements File {
|
|||||||
return new FileBlob({ mode, contentType, data });
|
return new FileBlob({ mode, contentType, data });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async toStreamAsync(): Promise<NodeJS.ReadableStream> {
|
||||||
|
return this.toStream();
|
||||||
|
}
|
||||||
|
|
||||||
toStream(): NodeJS.ReadableStream {
|
toStream(): NodeJS.ReadableStream {
|
||||||
return intoStream(this.data);
|
return intoStream(this.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
|
|||||||
import multiStream from 'multistream';
|
import multiStream from 'multistream';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import Sema from 'async-sema';
|
import Sema from 'async-sema';
|
||||||
import { File } from './types';
|
import { FileBase } from './types';
|
||||||
|
|
||||||
const semaToPreventEMFILE = new Sema(20);
|
const semaToPreventEMFILE = new Sema(20);
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ interface FromStreamOptions {
|
|||||||
fsPath: string;
|
fsPath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileFsRef implements File {
|
class FileFsRef implements FileBase {
|
||||||
public type: 'FileFsRef';
|
public type: 'FileFsRef';
|
||||||
public mode: number;
|
public mode: number;
|
||||||
public fsPath: string;
|
public fsPath: string;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fetch from 'node-fetch';
|
|||||||
import multiStream from 'multistream';
|
import multiStream from 'multistream';
|
||||||
import retry from 'async-retry';
|
import retry from 'async-retry';
|
||||||
import Sema from 'async-sema';
|
import Sema from 'async-sema';
|
||||||
import { File } from './types';
|
import { FileBase } from './types';
|
||||||
|
|
||||||
interface FileRefOptions {
|
interface FileRefOptions {
|
||||||
mode?: number;
|
mode?: number;
|
||||||
@@ -23,7 +23,7 @@ class BailableError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class FileRef implements File {
|
export default class FileRef implements FileBase {
|
||||||
public type: 'FileRef';
|
public type: 'FileRef';
|
||||||
public mode: number;
|
public mode: number;
|
||||||
public digest: string;
|
public digest: string;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import debug from '../debug';
|
|||||||
import FileFsRef from '../file-fs-ref';
|
import FileFsRef from '../file-fs-ref';
|
||||||
import { File, Files, Meta } from '../types';
|
import { File, Files, Meta } from '../types';
|
||||||
import { remove, mkdirp, readlink, symlink } from 'fs-extra';
|
import { remove, mkdirp, readlink, symlink } from 'fs-extra';
|
||||||
|
import streamToBuffer from './stream-to-buffer';
|
||||||
|
|
||||||
export interface DownloadedFiles {
|
export interface DownloadedFiles {
|
||||||
[filePath: string]: FileFsRef;
|
[filePath: string]: FileFsRef;
|
||||||
@@ -15,20 +16,45 @@ export function isSymbolicLink(mode: number): boolean {
|
|||||||
return (mode & S_IFMT) === S_IFLNK;
|
return (mode & S_IFMT) === S_IFLNK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function prepareSymlinkTarget(
|
||||||
|
file: File,
|
||||||
|
fsPath: string
|
||||||
|
): Promise<string> {
|
||||||
|
const mkdirPromise = mkdirp(path.dirname(fsPath));
|
||||||
|
if (file.type === 'FileFsRef') {
|
||||||
|
const [target] = await Promise.all([readlink(file.fsPath), mkdirPromise]);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.type === 'FileRef' || file.type === 'FileBlob') {
|
||||||
|
const targetPathBufferPromise = await streamToBuffer(
|
||||||
|
await file.toStreamAsync()
|
||||||
|
);
|
||||||
|
const [targetPathBuffer] = await Promise.all([
|
||||||
|
targetPathBufferPromise,
|
||||||
|
mkdirPromise,
|
||||||
|
]);
|
||||||
|
return targetPathBuffer.toString('utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
`file.type "${(file as any).type}" not supported for symlink`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async function downloadFile(file: File, fsPath: string): Promise<FileFsRef> {
|
async function downloadFile(file: File, fsPath: string): Promise<FileFsRef> {
|
||||||
const { mode } = file;
|
const { mode } = file;
|
||||||
if (mode && isSymbolicLink(mode) && file.type === 'FileFsRef') {
|
|
||||||
const [target] = await Promise.all([
|
if (isSymbolicLink(mode)) {
|
||||||
readlink((file as FileFsRef).fsPath),
|
const target = await prepareSymlinkTarget(file, fsPath);
|
||||||
mkdirp(path.dirname(fsPath)),
|
|
||||||
]);
|
|
||||||
await symlink(target, fsPath);
|
await symlink(target, fsPath);
|
||||||
return FileFsRef.fromFsPath({ mode, fsPath });
|
return FileFsRef.fromFsPath({ mode, fsPath });
|
||||||
} else {
|
}
|
||||||
|
|
||||||
const stream = file.toStream();
|
const stream = file.toStream();
|
||||||
return FileFsRef.fromStream({ mode, stream, fsPath });
|
return FileFsRef.fromStream({ mode, stream, fsPath });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function removeFile(basePath: string, fileMatched: string) {
|
async function removeFile(basePath: string, fileMatched: string) {
|
||||||
const file = path.join(basePath, fileMatched);
|
const file = path.join(basePath, fileMatched);
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ export default async function glob(
|
|||||||
const files = await vanillaGlob(pattern, options);
|
const files = await vanillaGlob(pattern, options);
|
||||||
|
|
||||||
for (const relativePath of files) {
|
for (const relativePath of files) {
|
||||||
const fsPath = normalizePath(path.join(options.cwd!, relativePath));
|
const fsPath = normalizePath(path.join(options.cwd, relativePath));
|
||||||
let stat: Stats = options.statCache![fsPath] as Stats;
|
let stat: Stats = options.statCache[fsPath] as Stats;
|
||||||
assert(
|
assert(
|
||||||
stat,
|
stat,
|
||||||
`statCache does not contain value for ${relativePath} (resolved to ${fsPath})`
|
`statCache does not contain value for ${relativePath} (resolved to ${fsPath})`
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import { deprecate } from 'util';
|
|||||||
import { NowBuildError } from '../errors';
|
import { NowBuildError } from '../errors';
|
||||||
import { Meta, PackageJson, NodeVersion, Config } from '../types';
|
import { Meta, PackageJson, NodeVersion, Config } from '../types';
|
||||||
import { getSupportedNodeVersion, getLatestNodeVersion } from './node-version';
|
import { getSupportedNodeVersion, getLatestNodeVersion } from './node-version';
|
||||||
|
import { readConfigFile } from './read-config-file';
|
||||||
|
|
||||||
export type CliType = 'yarn' | 'npm';
|
export type CliType = 'yarn' | 'npm' | 'pnpm';
|
||||||
|
|
||||||
export interface ScanParentDirsResult {
|
export interface ScanParentDirsResult {
|
||||||
/**
|
/**
|
||||||
* "yarn" or "npm", depending on the presence of lockfiles.
|
* "yarn", "npm", or "pnpm" depending on the presence of lockfiles.
|
||||||
*/
|
*/
|
||||||
cliType: CliType;
|
cliType: CliType;
|
||||||
/**
|
/**
|
||||||
@@ -252,7 +253,7 @@ export async function scanParentDirs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const [packageLockJson, hasYarnLock] = await Promise.all([
|
const [packageLockJson, hasYarnLock, pnpmLockYaml] = await Promise.all([
|
||||||
fs
|
fs
|
||||||
.readJson(path.join(currentDestPath, 'package-lock.json'))
|
.readJson(path.join(currentDestPath, 'package-lock.json'))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -263,17 +264,26 @@ export async function scanParentDirs(
|
|||||||
throw error;
|
throw error;
|
||||||
}),
|
}),
|
||||||
fs.pathExists(path.join(currentDestPath, 'yarn.lock')),
|
fs.pathExists(path.join(currentDestPath, 'yarn.lock')),
|
||||||
|
readConfigFile<{ lockfileVersion: number }>(
|
||||||
|
path.join(currentDestPath, 'pnpm-lock.yaml')
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (packageLockJson && !hasYarnLock) {
|
if (packageLockJson && !hasYarnLock && !pnpmLockYaml) {
|
||||||
cliType = 'npm';
|
cliType = 'npm';
|
||||||
lockfileVersion = packageLockJson.lockfileVersion;
|
lockfileVersion = packageLockJson.lockfileVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!packageLockJson && !hasYarnLock && pnpmLockYaml) {
|
||||||
|
cliType = 'pnpm';
|
||||||
|
// just ensure that it is read as a number and not a string
|
||||||
|
lockfileVersion = Number(pnpmLockYaml.lockfileVersion);
|
||||||
|
}
|
||||||
|
|
||||||
// Only stop iterating if a lockfile was found, because it's possible
|
// Only stop iterating if a lockfile was found, because it's possible
|
||||||
// that the lockfile is in a higher path than where the `package.json`
|
// that the lockfile is in a higher path than where the `package.json`
|
||||||
// file was found.
|
// file was found.
|
||||||
if (packageLockJson || hasYarnLock) {
|
if (packageLockJson || hasYarnLock || pnpmLockYaml) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,6 +351,13 @@ export async function runNpmInstall(
|
|||||||
commandArgs = args
|
commandArgs = args
|
||||||
.filter(a => a !== '--prefer-offline')
|
.filter(a => a !== '--prefer-offline')
|
||||||
.concat(['install', '--no-audit', '--unsafe-perm']);
|
.concat(['install', '--no-audit', '--unsafe-perm']);
|
||||||
|
} else if (cliType === 'pnpm') {
|
||||||
|
// PNPM's install command is similar to NPM's but without the audit nonsense
|
||||||
|
// @see options https://pnpm.io/cli/install
|
||||||
|
opts.prettyCommand = 'pnpm install';
|
||||||
|
commandArgs = args
|
||||||
|
.filter(a => a !== '--prefer-offline')
|
||||||
|
.concat(['install', '--unsafe-perm']);
|
||||||
} else {
|
} else {
|
||||||
opts.prettyCommand = 'yarn install';
|
opts.prettyCommand = 'yarn install';
|
||||||
commandArgs = ['install', ...args];
|
commandArgs = ['install', ...args];
|
||||||
@@ -448,6 +465,8 @@ export async function runPackageJsonScript(
|
|||||||
|
|
||||||
if (cliType === 'npm') {
|
if (cliType === 'npm') {
|
||||||
opts.prettyCommand = `npm run ${scriptName}`;
|
opts.prettyCommand = `npm run ${scriptName}`;
|
||||||
|
} else if (cliType === 'pnpm') {
|
||||||
|
opts.prettyCommand = `pnpm run ${scriptName}`;
|
||||||
} else {
|
} else {
|
||||||
opts.prettyCommand = `yarn run ${scriptName}`;
|
opts.prettyCommand = `yarn run ${scriptName}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export {
|
|||||||
getIgnoreFilter,
|
getIgnoreFilter,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export { EdgeFunction } from './edge-function';
|
||||||
export {
|
export {
|
||||||
detectBuilders,
|
detectBuilders,
|
||||||
detectOutputDirectory,
|
detectOutputDirectory,
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ import Sema from 'async-sema';
|
|||||||
import { ZipFile } from 'yazl';
|
import { ZipFile } from 'yazl';
|
||||||
import minimatch from 'minimatch';
|
import minimatch from 'minimatch';
|
||||||
import { readlink } from 'fs-extra';
|
import { readlink } from 'fs-extra';
|
||||||
import { Files, Config } from './types';
|
|
||||||
import FileFsRef from './file-fs-ref';
|
|
||||||
import { isSymbolicLink } from './fs/download';
|
import { isSymbolicLink } from './fs/download';
|
||||||
import streamToBuffer from './fs/stream-to-buffer';
|
import streamToBuffer from './fs/stream-to-buffer';
|
||||||
|
import type { Files, Config } from './types';
|
||||||
|
|
||||||
interface Environment {
|
interface Environment {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LambdaOptions {
|
export type LambdaOptions = LambdaOptionsWithFiles | LambdaOptionsWithZipBuffer;
|
||||||
files: Files;
|
|
||||||
|
export interface LambdaOptionsBase {
|
||||||
handler: string;
|
handler: string;
|
||||||
runtime: string;
|
runtime: string;
|
||||||
memory?: number;
|
memory?: number;
|
||||||
@@ -21,10 +21,21 @@ export interface LambdaOptions {
|
|||||||
environment?: Environment;
|
environment?: Environment;
|
||||||
allowQuery?: string[];
|
allowQuery?: string[];
|
||||||
regions?: string[];
|
regions?: string[];
|
||||||
|
supportsMultiPayloads?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LambdaOptionsWithFiles extends LambdaOptionsBase {
|
||||||
|
files: Files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use `LambdaOptionsWithFiles` instead.
|
||||||
|
*/
|
||||||
|
export interface LambdaOptionsWithZipBuffer extends LambdaOptionsBase {
|
||||||
/**
|
/**
|
||||||
* @deprecated Use `files` property instead.
|
* @deprecated Use `files` property instead.
|
||||||
*/
|
*/
|
||||||
zipBuffer?: Buffer;
|
zipBuffer: Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GetLambdaOptionsFromFunctionOptions {
|
interface GetLambdaOptionsFromFunctionOptions {
|
||||||
@@ -34,7 +45,7 @@ interface GetLambdaOptionsFromFunctionOptions {
|
|||||||
|
|
||||||
export class Lambda {
|
export class Lambda {
|
||||||
type: 'Lambda';
|
type: 'Lambda';
|
||||||
files: Files;
|
files?: Files;
|
||||||
handler: string;
|
handler: string;
|
||||||
runtime: string;
|
runtime: string;
|
||||||
memory?: number;
|
memory?: number;
|
||||||
@@ -46,9 +57,10 @@ export class Lambda {
|
|||||||
* @deprecated Use `await lambda.createZip()` instead.
|
* @deprecated Use `await lambda.createZip()` instead.
|
||||||
*/
|
*/
|
||||||
zipBuffer?: Buffer;
|
zipBuffer?: Buffer;
|
||||||
|
supportsMultiPayloads?: boolean;
|
||||||
|
|
||||||
constructor({
|
constructor(opts: LambdaOptions) {
|
||||||
files,
|
const {
|
||||||
handler,
|
handler,
|
||||||
runtime,
|
runtime,
|
||||||
maxDuration,
|
maxDuration,
|
||||||
@@ -56,10 +68,13 @@ export class Lambda {
|
|||||||
environment = {},
|
environment = {},
|
||||||
allowQuery,
|
allowQuery,
|
||||||
regions,
|
regions,
|
||||||
zipBuffer,
|
supportsMultiPayloads,
|
||||||
}: LambdaOptions) {
|
} = opts;
|
||||||
if (!zipBuffer) {
|
if ('files' in opts) {
|
||||||
assert(typeof files === 'object', '"files" must be an object');
|
assert(typeof opts.files === 'object', '"files" must be an object');
|
||||||
|
}
|
||||||
|
if ('zipBuffer' in opts) {
|
||||||
|
assert(Buffer.isBuffer(opts.zipBuffer), '"zipBuffer" must be a Buffer');
|
||||||
}
|
}
|
||||||
assert(typeof handler === 'string', '"handler" is not a string');
|
assert(typeof handler === 'string', '"handler" is not a string');
|
||||||
assert(typeof runtime === 'string', '"runtime" is not a string');
|
assert(typeof runtime === 'string', '"runtime" is not a string');
|
||||||
@@ -81,6 +96,13 @@ export class Lambda {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (supportsMultiPayloads !== undefined) {
|
||||||
|
assert(
|
||||||
|
typeof supportsMultiPayloads === 'boolean',
|
||||||
|
'"supportsMultiPayloads" is not a boolean'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (regions !== undefined) {
|
if (regions !== undefined) {
|
||||||
assert(Array.isArray(regions), '"regions" is not an Array');
|
assert(Array.isArray(regions), '"regions" is not an Array');
|
||||||
assert(
|
assert(
|
||||||
@@ -89,7 +111,7 @@ export class Lambda {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.type = 'Lambda';
|
this.type = 'Lambda';
|
||||||
this.files = files;
|
this.files = 'files' in opts ? opts.files : undefined;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
@@ -97,12 +119,16 @@ export class Lambda {
|
|||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.allowQuery = allowQuery;
|
this.allowQuery = allowQuery;
|
||||||
this.regions = regions;
|
this.regions = regions;
|
||||||
this.zipBuffer = zipBuffer;
|
this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
|
||||||
|
this.supportsMultiPayloads = supportsMultiPayloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createZip(): Promise<Buffer> {
|
async createZip(): Promise<Buffer> {
|
||||||
let { zipBuffer } = this;
|
let { zipBuffer } = this;
|
||||||
if (!zipBuffer) {
|
if (!zipBuffer) {
|
||||||
|
if (!this.files) {
|
||||||
|
throw new Error('`files` is not defined');
|
||||||
|
}
|
||||||
await sema.acquire();
|
await sema.acquire();
|
||||||
try {
|
try {
|
||||||
zipBuffer = await createZip(this.files);
|
zipBuffer = await createZip(this.files);
|
||||||
@@ -136,7 +162,7 @@ export async function createZip(files: Files): Promise<Buffer> {
|
|||||||
for (const name of names) {
|
for (const name of names) {
|
||||||
const file = files[name];
|
const file = files[name];
|
||||||
if (file.mode && isSymbolicLink(file.mode) && file.type === 'FileFsRef') {
|
if (file.mode && isSymbolicLink(file.mode) && file.type === 'FileFsRef') {
|
||||||
const symlinkTarget = await readlink((file as FileFsRef).fsPath);
|
const symlinkTarget = await readlink(file.fsPath);
|
||||||
symlinkTargets.set(name, symlinkTarget);
|
symlinkTargets.set(name, symlinkTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +176,7 @@ export async function createZip(files: Files): Promise<Buffer> {
|
|||||||
if (typeof symlinkTarget === 'string') {
|
if (typeof symlinkTarget === 'string') {
|
||||||
zipFile.addBuffer(Buffer.from(symlinkTarget, 'utf8'), name, opts);
|
zipFile.addBuffer(Buffer.from(symlinkTarget, 'utf8'), name, opts);
|
||||||
} else {
|
} else {
|
||||||
const stream = file.toStream() as import('stream').Readable;
|
const stream = file.toStream();
|
||||||
stream.on('error', reject);
|
stream.on('error', reject);
|
||||||
zipFile.addReadStream(stream, name, opts);
|
zipFile.addReadStream(stream, name, opts);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Lambda, LambdaOptions } from './lambda';
|
import { Lambda, LambdaOptionsWithFiles } from './lambda';
|
||||||
|
|
||||||
interface NodejsLambdaOptions extends LambdaOptions {
|
interface NodejsLambdaOptions extends LambdaOptionsWithFiles {
|
||||||
shouldAddHelpers: boolean;
|
shouldAddHelpers: boolean;
|
||||||
shouldAddSourcemapSupport: boolean;
|
shouldAddSourcemapSupport: boolean;
|
||||||
awsLambdaHandler?: string;
|
awsLambdaHandler?: string;
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import FileBlob from './file-blob';
|
import { File } from './types';
|
||||||
import FileFsRef from './file-fs-ref';
|
|
||||||
import FileRef from './file-ref';
|
|
||||||
import { Lambda } from './lambda';
|
import { Lambda } from './lambda';
|
||||||
|
|
||||||
interface PrerenderOptions {
|
interface PrerenderOptions {
|
||||||
expiration: number | false;
|
expiration: number | false;
|
||||||
lambda: Lambda;
|
lambda: Lambda;
|
||||||
fallback: FileBlob | FileFsRef | FileRef | null;
|
fallback: File | null;
|
||||||
group?: number;
|
group?: number;
|
||||||
bypassToken?: string | null /* optional to be non-breaking change */;
|
bypassToken?: string | null /* optional to be non-breaking change */;
|
||||||
allowQuery?: string[];
|
allowQuery?: string[];
|
||||||
@@ -16,7 +14,7 @@ export class Prerender {
|
|||||||
public type: 'Prerender';
|
public type: 'Prerender';
|
||||||
public expiration: number | false;
|
public expiration: number | false;
|
||||||
public lambda: Lambda;
|
public lambda: Lambda;
|
||||||
public fallback: FileBlob | FileFsRef | FileRef | null;
|
public fallback: File | null;
|
||||||
public group?: number;
|
public group?: number;
|
||||||
public bypassToken: string | null;
|
public bypassToken: string | null;
|
||||||
public allowQuery?: string[];
|
public allowQuery?: string[];
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
import FileRef from './file-ref';
|
import type FileRef from './file-ref';
|
||||||
import FileFsRef from './file-fs-ref';
|
import type FileFsRef from './file-fs-ref';
|
||||||
import { Lambda } from './lambda';
|
import type FileBlob from './file-blob';
|
||||||
|
import type { Lambda } from './lambda';
|
||||||
|
import type { Prerender } from './prerender';
|
||||||
|
import type { EdgeFunction } from './edge-function';
|
||||||
|
|
||||||
export interface Env {
|
export interface Env {
|
||||||
[name: string]: string | undefined;
|
[name: string]: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface File {
|
export type File = FileRef | FileFsRef | FileBlob;
|
||||||
|
export interface FileBase {
|
||||||
type: string;
|
type: string;
|
||||||
mode: number;
|
mode: number;
|
||||||
contentType?: string;
|
contentType?: string;
|
||||||
toStream: () => NodeJS.ReadableStream;
|
toStream: () => NodeJS.ReadableStream;
|
||||||
toStreamAsync?: () => Promise<NodeJS.ReadableStream>;
|
toStreamAsync?: () => Promise<NodeJS.ReadableStream>;
|
||||||
/**
|
|
||||||
* The absolute path to the file in the filesystem
|
|
||||||
*/
|
|
||||||
fsPath?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Files {
|
export interface Files {
|
||||||
@@ -23,16 +23,6 @@ export interface Files {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
[key: string]:
|
|
||||||
| string
|
|
||||||
| string[]
|
|
||||||
| boolean
|
|
||||||
| number
|
|
||||||
| { [key: string]: string }
|
|
||||||
| BuilderFunctions
|
|
||||||
| ProjectSettings
|
|
||||||
| undefined
|
|
||||||
| null;
|
|
||||||
maxLambdaSize?: string;
|
maxLambdaSize?: string;
|
||||||
includeFiles?: string | string[];
|
includeFiles?: string | string[];
|
||||||
excludeFiles?: string | string[];
|
excludeFiles?: string | string[];
|
||||||
@@ -51,6 +41,7 @@ export interface Config {
|
|||||||
devCommand?: string;
|
devCommand?: string;
|
||||||
framework?: string | null;
|
framework?: string | null;
|
||||||
nodeVersion?: string;
|
nodeVersion?: string;
|
||||||
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Meta {
|
export interface Meta {
|
||||||
@@ -63,35 +54,7 @@ export interface Meta {
|
|||||||
env?: Env;
|
env?: Env;
|
||||||
buildEnv?: Env;
|
buildEnv?: Env;
|
||||||
avoidTopLevelInstall?: boolean;
|
avoidTopLevelInstall?: boolean;
|
||||||
}
|
[key: string]: unknown;
|
||||||
|
|
||||||
export interface AnalyzeOptions {
|
|
||||||
/**
|
|
||||||
* All source files of the project
|
|
||||||
*/
|
|
||||||
files: {
|
|
||||||
[filePath: string]: FileRef;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name of entrypoint file for this particular build job. Value
|
|
||||||
* `files[entrypoint]` is guaranteed to exist and be a valid File reference.
|
|
||||||
* `entrypoint` is always a discrete file and never a glob, since globs are
|
|
||||||
* expanded into separate builds at deployment time.
|
|
||||||
*/
|
|
||||||
entrypoint: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A writable temporary directory where you are encouraged to perform your
|
|
||||||
* build process. This directory will be populated with the restored cache.
|
|
||||||
*/
|
|
||||||
workPath: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An arbitrary object passed by the user in the build definition defined
|
|
||||||
* in `vercel.json`.
|
|
||||||
*/
|
|
||||||
config: Config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BuildOptions {
|
export interface BuildOptions {
|
||||||
@@ -394,10 +357,10 @@ export interface Images {
|
|||||||
|
|
||||||
export interface BuildResultV2 {
|
export interface BuildResultV2 {
|
||||||
// TODO: use proper `Route` type from `routing-utils` (perhaps move types to a common package)
|
// TODO: use proper `Route` type from `routing-utils` (perhaps move types to a common package)
|
||||||
routes: any[];
|
routes?: any[];
|
||||||
images?: Images;
|
images?: Images;
|
||||||
output: {
|
output: {
|
||||||
[key: string]: File | Lambda;
|
[key: string]: File | Lambda | Prerender | EdgeFunction;
|
||||||
};
|
};
|
||||||
wildcard?: Array<{
|
wildcard?: Array<{
|
||||||
domain: string;
|
domain: string;
|
||||||
|
|||||||
15
packages/build-utils/test/fixtures/22-pnpm/package.json
vendored
Normal file
15
packages/build-utils/test/fixtures/22-pnpm/package.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "22-pnpm",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "mkdir -p public && (printf \"pnpm version: \" && pnpm -v) > public/index.txt"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"once": "^1.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
19
packages/build-utils/test/fixtures/22-pnpm/pnpm-lock.yaml
generated
vendored
Normal file
19
packages/build-utils/test/fixtures/22-pnpm/pnpm-lock.yaml
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
lockfileVersion: 5.3
|
||||||
|
|
||||||
|
specifiers:
|
||||||
|
once: ^1.4.0
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
once: 1.4.0
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
/once/1.4.0:
|
||||||
|
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
|
||||||
|
dependencies:
|
||||||
|
wrappy: 1.0.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/wrappy/1.0.2:
|
||||||
|
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
|
||||||
|
dev: false
|
||||||
11
packages/build-utils/test/fixtures/22-pnpm/vercel.json
vendored
Normal file
11
packages/build-utils/test/fixtures/22-pnpm/vercel.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"builds": [{ "src": "package.json", "use": "@vercel/static-build" }],
|
||||||
|
"probes": [
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"mustContain": "pnpm version: 6",
|
||||||
|
"logMustContain": "pnpm run build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
5
packages/build-utils/test/fixtures/23-pnpm-workspaces/c/package.json
vendored
Normal file
5
packages/build-utils/test/fixtures/23-pnpm-workspaces/c/package.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"name": "c",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "0.1.0"
|
||||||
|
}
|
||||||
8
packages/build-utils/test/fixtures/23-pnpm-workspaces/d/package.json
vendored
Normal file
8
packages/build-utils/test/fixtures/23-pnpm-workspaces/d/package.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "d",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"once": "1.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
packages/build-utils/test/fixtures/23-pnpm-workspaces/package.json
vendored
Normal file
6
packages/build-utils/test/fixtures/23-pnpm-workspaces/package.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"name": "23-pnpm-workspaces",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
27
packages/build-utils/test/fixtures/23-pnpm-workspaces/pnpm-lock.yaml
generated
vendored
Normal file
27
packages/build-utils/test/fixtures/23-pnpm-workspaces/pnpm-lock.yaml
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
lockfileVersion: 5.3
|
||||||
|
|
||||||
|
importers:
|
||||||
|
|
||||||
|
.:
|
||||||
|
specifiers: {}
|
||||||
|
|
||||||
|
c:
|
||||||
|
specifiers: {}
|
||||||
|
|
||||||
|
d:
|
||||||
|
specifiers:
|
||||||
|
once: 1.4.0
|
||||||
|
devDependencies:
|
||||||
|
once: 1.4.0
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
/once/1.4.0:
|
||||||
|
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
|
||||||
|
dependencies:
|
||||||
|
wrappy: 1.0.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/wrappy/1.0.2:
|
||||||
|
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
|
||||||
|
dev: true
|
||||||
3
packages/build-utils/test/fixtures/23-pnpm-workspaces/pnpm-workspace.yaml
vendored
Normal file
3
packages/build-utils/test/fixtures/23-pnpm-workspaces/pnpm-workspace.yaml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
packages:
|
||||||
|
- 'c'
|
||||||
|
- 'd'
|
||||||
1
packages/build-utils/test/fixtures/24-pnpm-hoisted/.gitignore
vendored
Normal file
1
packages/build-utils/test/fixtures/24-pnpm-hoisted/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.vercel
|
||||||
1
packages/build-utils/test/fixtures/24-pnpm-hoisted/.npmrc
vendored
Normal file
1
packages/build-utils/test/fixtures/24-pnpm-hoisted/.npmrc
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node-linker=hoisted
|
||||||
5
packages/build-utils/test/fixtures/24-pnpm-hoisted/a/index.js
vendored
Normal file
5
packages/build-utils/test/fixtures/24-pnpm-hoisted/a/index.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const once = require('once');
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
once(() => {});
|
||||||
|
};
|
||||||
5
packages/build-utils/test/fixtures/24-pnpm-hoisted/b/index.js
vendored
Normal file
5
packages/build-utils/test/fixtures/24-pnpm-hoisted/b/index.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const once = require('once');
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
once(() => {});
|
||||||
|
};
|
||||||
10
packages/build-utils/test/fixtures/24-pnpm-hoisted/index.js
vendored
Normal file
10
packages/build-utils/test/fixtures/24-pnpm-hoisted/index.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const { exec } = require('exeggcute');
|
||||||
|
|
||||||
|
const a = require('./a');
|
||||||
|
const b = require('./b');
|
||||||
|
|
||||||
|
a();
|
||||||
|
b();
|
||||||
|
|
||||||
|
exec('mkdir public', __dirname);
|
||||||
|
exec('echo "Hello, World!" > public/index.html', __dirname);
|
||||||
11
packages/build-utils/test/fixtures/24-pnpm-hoisted/package.json
vendored
Normal file
11
packages/build-utils/test/fixtures/24-pnpm-hoisted/package.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"private": "true",
|
||||||
|
"name": "24-pnpm-hoisted",
|
||||||
|
"scripts": {
|
||||||
|
"build": "ls -Al node_modules && node index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"exeggcute": "^1.0.0",
|
||||||
|
"once": "^1.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
25
packages/build-utils/test/fixtures/24-pnpm-hoisted/pnpm-lock.yaml
generated
vendored
Normal file
25
packages/build-utils/test/fixtures/24-pnpm-hoisted/pnpm-lock.yaml
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
lockfileVersion: 5.3
|
||||||
|
|
||||||
|
specifiers:
|
||||||
|
exeggcute: ^1.0.0
|
||||||
|
once: ^1.4.0
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
exeggcute: 1.0.0
|
||||||
|
once: 1.4.0
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
/exeggcute/1.0.0:
|
||||||
|
resolution: {integrity: sha1-qLXakIhjGCDm9ggx4CvEc5mnbBU=}
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/once/1.4.0:
|
||||||
|
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
|
||||||
|
dependencies:
|
||||||
|
wrappy: 1.0.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
|
/wrappy/1.0.2:
|
||||||
|
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
|
||||||
|
dev: false
|
||||||
20
packages/build-utils/test/fixtures/24-pnpm-hoisted/vercel.json
vendored
Normal file
20
packages/build-utils/test/fixtures/24-pnpm-hoisted/vercel.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"probes": [
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"mustContain": "Hello, World!"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"logMustContain": "once"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"logMustContain": "exeggcute"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"logMustContain": "wrappy"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ const skipFixtures: string[] = [
|
|||||||
'07-zero-config-jekyll',
|
'07-zero-config-jekyll',
|
||||||
'08-zero-config-middleman',
|
'08-zero-config-middleman',
|
||||||
'21-npm-workspaces',
|
'21-npm-workspaces',
|
||||||
|
'23-pnpm-workspaces',
|
||||||
];
|
];
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
|||||||
87
packages/build-utils/test/unit.test.ts
vendored
87
packages/build-utils/test/unit.test.ts
vendored
@@ -1,7 +1,7 @@
|
|||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs, { readlink } from 'fs-extra';
|
||||||
import { strict as assert } from 'assert';
|
import { strict as assert, strictEqual } from 'assert';
|
||||||
import { createZip } from '../src/lambda';
|
import { createZip } from '../src/lambda';
|
||||||
import { getSupportedNodeVersion } from '../src/fs/node-version';
|
import { getSupportedNodeVersion } from '../src/fs/node-version';
|
||||||
import download from '../src/fs/download';
|
import download from '../src/fs/download';
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
runNpmInstall,
|
runNpmInstall,
|
||||||
runPackageJsonScript,
|
runPackageJsonScript,
|
||||||
scanParentDirs,
|
scanParentDirs,
|
||||||
|
FileBlob,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
async function expectBuilderError(promise: Promise<any>, pattern: string) {
|
async function expectBuilderError(promise: Promise<any>, pattern: string) {
|
||||||
@@ -47,7 +48,7 @@ afterEach(() => {
|
|||||||
console.warn = originalConsoleWarn;
|
console.warn = originalConsoleWarn;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should re-create symlinks properly', async () => {
|
it('should re-create FileFsRef symlinks properly', async () => {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
console.log('Skipping test on windows');
|
console.log('Skipping test on windows');
|
||||||
return;
|
return;
|
||||||
@@ -69,6 +70,72 @@ it('should re-create symlinks properly', async () => {
|
|||||||
assert(linkStat.isSymbolicLink());
|
assert(linkStat.isSymbolicLink());
|
||||||
assert(linkDirStat.isSymbolicLink());
|
assert(linkDirStat.isSymbolicLink());
|
||||||
assert(aStat.isFile());
|
assert(aStat.isFile());
|
||||||
|
|
||||||
|
const [linkDirContents, linkTextContents] = await Promise.all([
|
||||||
|
readlink(path.join(outDir, 'link-dir')),
|
||||||
|
readlink(path.join(outDir, 'link.txt')),
|
||||||
|
]);
|
||||||
|
|
||||||
|
strictEqual(linkDirContents, 'dir');
|
||||||
|
strictEqual(linkTextContents, './a.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should re-create FileBlob symlinks properly', async () => {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
console.log('Skipping test on windows');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = {
|
||||||
|
'a.txt': new FileBlob({
|
||||||
|
mode: 33188,
|
||||||
|
contentType: undefined,
|
||||||
|
data: 'a text',
|
||||||
|
}),
|
||||||
|
'dir/b.txt': new FileBlob({
|
||||||
|
mode: 33188,
|
||||||
|
contentType: undefined,
|
||||||
|
data: 'b text',
|
||||||
|
}),
|
||||||
|
'link-dir': new FileBlob({
|
||||||
|
mode: 41453,
|
||||||
|
contentType: undefined,
|
||||||
|
data: 'dir',
|
||||||
|
}),
|
||||||
|
'link.txt': new FileBlob({
|
||||||
|
mode: 41453,
|
||||||
|
contentType: undefined,
|
||||||
|
data: 'a.txt',
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
strictEqual(Object.keys(files).length, 4);
|
||||||
|
|
||||||
|
const outDir = path.join(__dirname, 'symlinks-out');
|
||||||
|
await fs.remove(outDir);
|
||||||
|
|
||||||
|
const files2 = await download(files, outDir);
|
||||||
|
strictEqual(Object.keys(files2).length, 4);
|
||||||
|
|
||||||
|
const [linkStat, linkDirStat, aStat, dirStat] = await Promise.all([
|
||||||
|
fs.lstat(path.join(outDir, 'link.txt')),
|
||||||
|
fs.lstat(path.join(outDir, 'link-dir')),
|
||||||
|
fs.lstat(path.join(outDir, 'a.txt')),
|
||||||
|
fs.lstat(path.join(outDir, 'dir')),
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert(linkStat.isSymbolicLink());
|
||||||
|
assert(linkDirStat.isSymbolicLink());
|
||||||
|
assert(aStat.isFile());
|
||||||
|
assert(dirStat.isDirectory());
|
||||||
|
|
||||||
|
const [linkDirContents, linkTextContents] = await Promise.all([
|
||||||
|
readlink(path.join(outDir, 'link-dir')),
|
||||||
|
readlink(path.join(outDir, 'link.txt')),
|
||||||
|
]);
|
||||||
|
|
||||||
|
strictEqual(linkDirContents, 'dir');
|
||||||
|
strictEqual(linkTextContents, 'a.txt');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create zip files with symlinks properly', async () => {
|
it('should create zip files with symlinks properly', async () => {
|
||||||
@@ -332,3 +399,17 @@ it('should detect npm Workspaces', async () => {
|
|||||||
expect(result.cliType).toEqual('npm');
|
expect(result.cliType).toEqual('npm');
|
||||||
expect(result.lockfileVersion).toEqual(2);
|
expect(result.lockfileVersion).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should detect pnpm', async () => {
|
||||||
|
const fixture = path.join(__dirname, 'fixtures', '22-pnpm');
|
||||||
|
const result = await scanParentDirs(fixture);
|
||||||
|
expect(result.cliType).toEqual('pnpm');
|
||||||
|
expect(result.lockfileVersion).toEqual(5.3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should detect pnpm Workspaces', async () => {
|
||||||
|
const fixture = path.join(__dirname, 'fixtures', '23-pnpm-workspaces/a');
|
||||||
|
const result = await scanParentDirs(fixture);
|
||||||
|
expect(result.cliType).toEqual('pnpm');
|
||||||
|
expect(result.lockfileVersion).toEqual(5.3);
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vercel",
|
"name": "vercel",
|
||||||
"version": "24.0.0",
|
"version": "24.0.2-canary.0",
|
||||||
"preferGlobal": true,
|
"preferGlobal": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"description": "The command-line interface for Vercel",
|
"description": "The command-line interface for Vercel",
|
||||||
@@ -43,11 +43,11 @@
|
|||||||
"node": ">= 12"
|
"node": ">= 12"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vercel/build-utils": "2.14.0",
|
"@vercel/build-utils": "2.15.1-canary.0",
|
||||||
"@vercel/go": "1.3.0",
|
"@vercel/go": "1.3.2-canary.0",
|
||||||
"@vercel/node": "1.13.0",
|
"@vercel/node": "1.14.1-canary.0",
|
||||||
"@vercel/python": "2.2.0",
|
"@vercel/python": "2.2.2-canary.0",
|
||||||
"@vercel/ruby": "1.3.0",
|
"@vercel/ruby": "1.3.2-canary.0",
|
||||||
"update-notifier": "4.1.0"
|
"update-notifier": "4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -88,9 +88,9 @@
|
|||||||
"@types/update-notifier": "5.1.0",
|
"@types/update-notifier": "5.1.0",
|
||||||
"@types/which": "1.3.2",
|
"@types/which": "1.3.2",
|
||||||
"@types/write-json-file": "2.2.1",
|
"@types/write-json-file": "2.2.1",
|
||||||
"@vercel/client": "10.3.0",
|
"@vercel/client": "10.4.1-canary.0",
|
||||||
"@vercel/fetch-retry": "5.0.3",
|
"@vercel/fetch-retry": "5.0.3",
|
||||||
"@vercel/frameworks": "0.6.0",
|
"@vercel/frameworks": "0.7.1-canary.0",
|
||||||
"@vercel/ncc": "0.24.0",
|
"@vercel/ncc": "0.24.0",
|
||||||
"@vercel/nft": "0.17.5",
|
"@vercel/nft": "0.17.5",
|
||||||
"@zeit/fun": "0.11.2",
|
"@zeit/fun": "0.11.2",
|
||||||
@@ -161,7 +161,6 @@
|
|||||||
"title": "3.4.1",
|
"title": "3.4.1",
|
||||||
"tmp-promise": "1.0.3",
|
"tmp-promise": "1.0.3",
|
||||||
"tree-kill": "1.2.2",
|
"tree-kill": "1.2.2",
|
||||||
"ts-eager": "2.0.2",
|
|
||||||
"ts-node": "8.3.0",
|
"ts-node": "8.3.0",
|
||||||
"typescript": "4.3.4",
|
"typescript": "4.3.4",
|
||||||
"universal-analytics": "0.4.20",
|
"universal-analytics": "0.4.20",
|
||||||
|
|||||||
@@ -892,8 +892,8 @@ const parseEnv = (env?: string[] | Dictionary<string>) => {
|
|||||||
if (equalsSign === -1) {
|
if (equalsSign === -1) {
|
||||||
key = e;
|
key = e;
|
||||||
} else {
|
} else {
|
||||||
key = e.substr(0, equalsSign);
|
key = e.slice(0, equalsSign);
|
||||||
value = e.substr(equalsSign + 1);
|
value = e.slice(equalsSign + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
o[key] = value;
|
o[key] = value;
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ async function fetchExampleList(client: Client) {
|
|||||||
const url = `${EXAMPLE_API}/v2/list.json`;
|
const url = `${EXAMPLE_API}/v2/list.json`;
|
||||||
|
|
||||||
const body = await client.fetch<Example[]>(url);
|
const body = await client.fetch<Example[]>(url);
|
||||||
|
client.output.stopSpinner();
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const emailAutoComplete = (value: string, teamSlug: string) => {
|
|||||||
domains.unshift(teamSlug);
|
domains.unshift(teamSlug);
|
||||||
for (const domain of domains) {
|
for (const domain of domains) {
|
||||||
if (domain.startsWith(host)) {
|
if (domain.startsWith(host)) {
|
||||||
suggestion = domain.substr(host.length);
|
suggestion = domain.slice(host.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ export async function executeBuild(
|
|||||||
// Convert the JSON-ified output map back into their corresponding `File`
|
// Convert the JSON-ified output map back into their corresponding `File`
|
||||||
// subclass type instances.
|
// subclass type instances.
|
||||||
for (const name of Object.keys(output)) {
|
for (const name of Object.keys(output)) {
|
||||||
const obj = output[name] as File;
|
const obj = output[name] as File | Lambda;
|
||||||
let lambda: BuiltLambda;
|
let lambda: BuiltLambda;
|
||||||
let fileRef: FileFsRef;
|
let fileRef: FileFsRef;
|
||||||
let fileBlob: FileBlob;
|
let fileBlob: FileBlob;
|
||||||
|
|||||||
@@ -42,12 +42,15 @@ export default async function getConfig(
|
|||||||
if (localConfig instanceof CantParseJSONFile) {
|
if (localConfig instanceof CantParseJSONFile) {
|
||||||
return localConfig;
|
return localConfig;
|
||||||
}
|
}
|
||||||
if (localConfig !== null) {
|
|
||||||
|
if (localConfig === null) {
|
||||||
|
return new CantFindConfig([humanizePath(localFilePath)]);
|
||||||
|
}
|
||||||
|
|
||||||
config = localConfig;
|
config = localConfig;
|
||||||
config[fileNameSymbol] = configFile;
|
config[fileNameSymbol] = configFile;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Then try with `vercel.json` or `now.json` in the same directory
|
// Then try with `vercel.json` or `now.json` in the same directory
|
||||||
const vercelFilePath = path.resolve(localPath, 'vercel.json');
|
const vercelFilePath = path.resolve(localPath, 'vercel.json');
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export async function staticFiles(
|
|||||||
// but we don't ignore if the user is explicitly listing files
|
// but we don't ignore if the user is explicitly listing files
|
||||||
// under the now namespace, or using files in combination with gitignore
|
// under the now namespace, or using files in combination with gitignore
|
||||||
const accepts = (file: string) => {
|
const accepts = (file: string) => {
|
||||||
const relativePath = file.substr(prefixLength);
|
const relativePath = file.slice(prefixLength);
|
||||||
|
|
||||||
if (relativePath === '') {
|
if (relativePath === '') {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ export default function humanizePath(path: string) {
|
|||||||
const resolved = resolve(path);
|
const resolved = resolve(path);
|
||||||
const _homedir = homedir();
|
const _homedir = homedir();
|
||||||
return resolved.indexOf(_homedir) === 0
|
return resolved.indexOf(_homedir) === 0
|
||||||
? `~${resolved.substr(_homedir.length)}`
|
? `~${resolved.slice(_homedir.length)}`
|
||||||
: resolved;
|
: resolved;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,22 +180,22 @@ export default function text({
|
|||||||
}
|
}
|
||||||
char = placeholder[value.length + caretOffset];
|
char = placeholder[value.length + caretOffset];
|
||||||
value =
|
value =
|
||||||
value.substr(0, value.length + caretOffset - 2) +
|
value.substring(0, value.length + caretOffset - 2) +
|
||||||
char +
|
char +
|
||||||
value.substr(value.length + caretOffset - 1);
|
value.slice(value.length + caretOffset - 1);
|
||||||
caretOffset--;
|
caretOffset--;
|
||||||
} else {
|
} else {
|
||||||
char = placeholder[value.length + caretOffset - 1];
|
char = placeholder[value.length + caretOffset - 1];
|
||||||
value =
|
value =
|
||||||
value.substr(0, value.length + caretOffset - 1) +
|
value.substring(0, value.length + caretOffset - 1) +
|
||||||
char +
|
char +
|
||||||
value.substr(value.length + caretOffset);
|
value.slice(value.length + caretOffset);
|
||||||
}
|
}
|
||||||
caretOffset--;
|
caretOffset--;
|
||||||
} else {
|
} else {
|
||||||
value =
|
value =
|
||||||
value.substr(0, value.length + caretOffset - 1) +
|
value.substring(0, value.length + caretOffset - 1) +
|
||||||
value.substr(value.length + caretOffset);
|
value.slice(value.length + caretOffset);
|
||||||
}
|
}
|
||||||
suggestion = '';
|
suggestion = '';
|
||||||
} else if (resolveChars.has(data)) {
|
} else if (resolveChars.has(data)) {
|
||||||
@@ -222,9 +222,9 @@ export default function text({
|
|||||||
return;
|
return;
|
||||||
} else if (!ansiRegex().test(data)) {
|
} else if (!ansiRegex().test(data)) {
|
||||||
let tmp =
|
let tmp =
|
||||||
value.substr(0, value.length + caretOffset) +
|
value.substring(0, value.length + caretOffset) +
|
||||||
data +
|
data +
|
||||||
value.substr(value.length + caretOffset);
|
value.slice(value.length + caretOffset);
|
||||||
|
|
||||||
if (mask) {
|
if (mask) {
|
||||||
if (/\d/.test(data) && caretOffset !== 0) {
|
if (/\d/.test(data) && caretOffset !== 0) {
|
||||||
@@ -236,9 +236,9 @@ export default function text({
|
|||||||
|
|
||||||
if (value[value.length + caretOffset + 1] === ' ') {
|
if (value[value.length + caretOffset + 1] === ' ') {
|
||||||
tmp =
|
tmp =
|
||||||
value.substr(0, value.length + caretOffset) +
|
value.substring(0, value.length + caretOffset) +
|
||||||
formattedData +
|
formattedData +
|
||||||
value.substr(value.length + caretOffset + formattedData.length);
|
value.slice(value.length + caretOffset + formattedData.length);
|
||||||
|
|
||||||
caretOffset += formattedData.length + 1;
|
caretOffset += formattedData.length + 1;
|
||||||
|
|
||||||
@@ -247,9 +247,9 @@ export default function text({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmp =
|
tmp =
|
||||||
value.substr(0, value.length + caretOffset) +
|
value.substring(0, value.length + caretOffset) +
|
||||||
formattedData +
|
formattedData +
|
||||||
value.substr(value.length + caretOffset + formattedData.length);
|
value.slice(value.length + caretOffset + formattedData.length);
|
||||||
|
|
||||||
caretOffset += formattedData.length;
|
caretOffset += formattedData.length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,6 @@
|
|||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"autobuild": "rollup -c -w",
|
"autobuild": "rollup -c -w",
|
||||||
"start": "sirv public --single --port $PORT",
|
"start": "sirv public --single --port $PORT",
|
||||||
"start:dev": "sirv public --single --dev --port $PORT"
|
"dev": "sirv public --single --dev --port $PORT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
packages/cli/test/dev/fixtures/41-tsconfig-jsx/.gitignore
vendored
Normal file
3
packages/cli/test/dev/fixtures/41-tsconfig-jsx/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.vercel
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import type { VercelApiHandler } from '@vercel/node';
|
||||||
|
|
||||||
|
const handler: VercelApiHandler = (req, res) => {
|
||||||
|
res.send('working');
|
||||||
|
};
|
||||||
|
|
||||||
|
export default handler;
|
||||||
16
packages/cli/test/dev/fixtures/41-tsconfig-jsx/index.html
Normal file
16
packages/cli/test/dev/fixtures/41-tsconfig-jsx/index.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" />
|
||||||
|
<title>Solid App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
|
||||||
|
<script src="/src/index.tsx" type="module"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
2473
packages/cli/test/dev/fixtures/41-tsconfig-jsx/package-lock.json
generated
Normal file
2473
packages/cli/test/dev/fixtures/41-tsconfig-jsx/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
packages/cli/test/dev/fixtures/41-tsconfig-jsx/package.json
Normal file
21
packages/cli/test/dev/fixtures/41-tsconfig-jsx/package.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "vite-template-solid",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"scripts": {
|
||||||
|
"start": "vite",
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vite build",
|
||||||
|
"serve": "vite preview"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@vercel/node": "^1.13.0",
|
||||||
|
"typescript": "^4.6.2",
|
||||||
|
"vite": "^2.8.5",
|
||||||
|
"vite-plugin-solid": "^2.2.5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"solid-js": "^1.3.9"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
.App {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
animation: logo-spin infinite 20s linear;
|
||||||
|
height: 40vmin;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
background-color: #282c34;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: calc(10px + 2vmin);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
color: #b318f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes logo-spin {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
packages/cli/test/dev/fixtures/41-tsconfig-jsx/src/App.tsx
Normal file
27
packages/cli/test/dev/fixtures/41-tsconfig-jsx/src/App.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import type { Component } from "solid-js";
|
||||||
|
|
||||||
|
import logo from "./logo.svg";
|
||||||
|
import styles from "./App.module.css";
|
||||||
|
|
||||||
|
const App: Component = () => {
|
||||||
|
return (
|
||||||
|
<div class={styles.App}>
|
||||||
|
<header class={styles.header}>
|
||||||
|
<img src={logo} class={styles.logo} alt="logo" />
|
||||||
|
<p>
|
||||||
|
Edit <code>src/App.tsx</code> and save to reload.
|
||||||
|
</p>
|
||||||
|
<a
|
||||||
|
class={styles.link}
|
||||||
|
href="https://github.com/solidjs/solid"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Learn Solid Test 2
|
||||||
|
</a>
|
||||||
|
</header>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user