mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 12:57:46 +00:00
Compare commits
25 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a400b9b29d | ||
|
|
b549c37149 | ||
|
|
30d5e64291 | ||
|
|
47c2c361d2 | ||
|
|
438576fc7c | ||
|
|
b30343ef7b | ||
|
|
2dc0dfa572 | ||
|
|
9ee54b3dd6 | ||
|
|
9d67e0bc06 | ||
|
|
466135cf84 | ||
|
|
eab2e229dc | ||
|
|
698b89a2ba | ||
|
|
bae2a2e4df | ||
|
|
57916bb712 | ||
|
|
12bbd4e8eb | ||
|
|
4e4c7023dc | ||
|
|
41805790e7 | ||
|
|
6ad77ae8e1 | ||
|
|
e8daf36cd7 | ||
|
|
c319a2c499 | ||
|
|
a410baa797 | ||
|
|
625568e659 | ||
|
|
41868c1fe0 | ||
|
|
1b644f1218 | ||
|
|
29ea0fb06b |
@@ -307,15 +307,15 @@ This is a [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere
|
||||
|
||||
This is an abstract enumeration type that is implemented by one of the following possible `String` values:
|
||||
|
||||
- `nodejs14.x`
|
||||
- `nodejs12.x`
|
||||
- `nodejs10.x`
|
||||
- `go1.x`
|
||||
- `java11`
|
||||
- `python3.9`
|
||||
- `python3.6`
|
||||
- `dotnetcore2.1`
|
||||
- `ruby2.5`
|
||||
- `provided`
|
||||
- `dotnet6`
|
||||
- `dotnetcore3.1`
|
||||
- `ruby2.7`
|
||||
- `provided.al2`
|
||||
|
||||
## `@vercel/build-utils` Helper Functions
|
||||
|
||||
|
||||
1
examples/amp/.gitignore
vendored
1
examples/amp/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
.env
|
||||
@@ -1,19 +0,0 @@
|
||||
# AMP Example
|
||||
|
||||
This directory is a brief example of an [AMP](https://amp.dev/) site that can be deployed to Vercel with zero configuration.
|
||||
|
||||
## Deploy Your Own
|
||||
|
||||
Deploy your own AMP project with Vercel.
|
||||
|
||||
[](https://vercel.com/new/clone?repository-url=https://github.com/vercel/vercel/tree/main/examples/amp)
|
||||
|
||||
_Live Example: https://amp-template.vercel.app_
|
||||
|
||||
### How We Created This Example
|
||||
|
||||
To get started deploying AMP with Vercel, you can use the [Vercel CLI](https://vercel.com/download) to initialize the project:
|
||||
|
||||
```shell
|
||||
$ vercel init amp
|
||||
```
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html ⚡>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,minimum-scale=1" />
|
||||
<link rel="shortcut icon" href="favicon.png">
|
||||
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
||||
<link rel="canonical" href="index.html" />
|
||||
<title>AMP Website</title>
|
||||
<script async src="https://cdn.ampproject.org/v0.js"></script>
|
||||
<style amp-custom>
|
||||
body > * {
|
||||
margin: 3rem 1rem;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
color: #525252;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
h4 {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.2rem;
|
||||
line-height: 2rem;
|
||||
}
|
||||
|
||||
.links {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.links a {
|
||||
margin: 0 10px;
|
||||
font-size: 1rem;
|
||||
color: #005af0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<amp-img width=150 height=150 layout="fixed" class="logo" src="logo.png"></amp-img>
|
||||
<h3>Welcome to your AMP page</h3>
|
||||
<p>AMP is a web component framework to <br> easily create user-first websites, stories, ads and emails.</p>
|
||||
|
||||
<h4>Links</h4>
|
||||
<div class="links">
|
||||
<a href="https://amp.dev/">Homepage</a>
|
||||
<a href="https://amp.dev/documentation/guides-and-tutorials/?format=websites">Tutorials</a>
|
||||
<a href="https://amp.dev/documentation/examples/">Examples</a>
|
||||
<a href="https://blog.amp.dev">Blog</a>
|
||||
</div>
|
||||
|
||||
<h4>Ready to get started?</h4>
|
||||
<div class="links">
|
||||
<a href="https://amp.dev/documentation/guides-and-tutorials/start/create/?format=websites">Create your first AMP page</a>
|
||||
</div>
|
||||
|
||||
<h4>Get involved</h4>
|
||||
<div class="links">
|
||||
<a href="https://twitter.com/amphtml">Twitter</a>
|
||||
<a href="https://amphtml.slack.com">Slack</a>
|
||||
<a href="https://amp.dev/events/amp-conf-2019">AMP Conf</a>
|
||||
<a href="https://amp.dev/events/amp-roadshow">AMP Roadshow</a>
|
||||
</div>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
@@ -15,7 +15,7 @@ cache:
|
||||
|
||||
env:
|
||||
global:
|
||||
# See https://git.io/vdao3 for details.
|
||||
# See https://github.com/ember-cli/ember-cli/blob/master/docs/build-concurrency.md
|
||||
- JOBS=1
|
||||
|
||||
script:
|
||||
|
||||
20
package.json
20
package.json
@@ -15,23 +15,23 @@
|
||||
"lerna": "3.16.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "4.28.0",
|
||||
"@typescript-eslint/parser": "4.28.0",
|
||||
"@typescript-eslint/eslint-plugin": "5.21.0",
|
||||
"@typescript-eslint/parser": "5.21.0",
|
||||
"async-retry": "1.2.3",
|
||||
"buffer-replace": "1.0.0",
|
||||
"eslint": "7.29.0",
|
||||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-jest": "24.3.6",
|
||||
"husky": "6.0.0",
|
||||
"jest": "27.3.1",
|
||||
"eslint": "8.14.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-jest": "26.1.5",
|
||||
"husky": "7.0.4",
|
||||
"jest": "28.0.2",
|
||||
"json5": "2.1.1",
|
||||
"lint-staged": "9.2.5",
|
||||
"node-fetch": "2.6.1",
|
||||
"npm-package-arg": "6.1.0",
|
||||
"prettier": "2.3.1",
|
||||
"prettier": "2.6.2",
|
||||
"ts-eager": "2.0.2",
|
||||
"ts-jest": "27.0.4",
|
||||
"turbo": "1.2.2"
|
||||
"ts-jest": "28.0.0-next.1",
|
||||
"turbo": "1.2.5"
|
||||
},
|
||||
"scripts": {
|
||||
"lerna": "lerna",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "2.15.2-canary.2",
|
||||
"version": "2.16.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
@@ -23,14 +23,14 @@
|
||||
"@types/end-of-stream": "^1.4.0",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/jest": "27.0.1",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/js-yaml": "3.12.1",
|
||||
"@types/ms": "0.7.31",
|
||||
"@types/multistream": "2.1.1",
|
||||
"@types/node-fetch": "^2.1.6",
|
||||
"@types/semver": "6.0.0",
|
||||
"@types/yazl": "^2.4.1",
|
||||
"@vercel/frameworks": "0.7.1",
|
||||
"@types/yazl": "2.4.2",
|
||||
"@vercel/frameworks": "0.8.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"aggregate-error": "3.0.1",
|
||||
"async-retry": "1.2.3",
|
||||
@@ -47,6 +47,6 @@
|
||||
"node-fetch": "2.6.1",
|
||||
"semver": "6.1.1",
|
||||
"typescript": "4.3.4",
|
||||
"yazl": "2.4.3"
|
||||
"yazl": "2.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,12 @@ export async function getNodeVersion(
|
||||
const latest = getLatestNodeVersion();
|
||||
return { ...latest, runtime: 'nodejs' };
|
||||
}
|
||||
if (process.env.ENABLE_EXPERIMENTAL_NODE16 === '1') {
|
||||
console.warn(
|
||||
'Warning: Using experimental Node.js 16.x due to ENABLE_EXPERIMENTAL_NODE16=1'
|
||||
);
|
||||
return { major: 16, range: '16.x', runtime: 'nodejs16.x' };
|
||||
}
|
||||
const { packageJson } = await scanParentDirs(destPath, true);
|
||||
let { nodeVersion } = config;
|
||||
let isAuto = true;
|
||||
@@ -544,7 +550,7 @@ export async function runPipInstall(
|
||||
meta?: Meta
|
||||
) {
|
||||
if (meta && meta.isDev) {
|
||||
debug('Skipping dependency installation because dev mode is enabled');
|
||||
debug('Skipping dependency installation because dev mode is enabled');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
10
packages/build-utils/test/unit.test.ts
vendored
10
packages/build-utils/test/unit.test.ts
vendored
@@ -277,6 +277,16 @@ it('should not warn when package.json engines matches project setting from confi
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('should select nodejs16.x with ENABLE_EXPERIMENTAL_NODE16', async () => {
|
||||
process.env.ENABLE_EXPERIMENTAL_NODE16 = '1';
|
||||
const result = await getNodeVersion('/tmp', undefined, {}, {});
|
||||
delete process.env.ENABLE_EXPERIMENTAL_NODE16;
|
||||
expect(result).toEqual({ major: 16, range: '16.x', runtime: 'nodejs16.x' });
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Warning: Using experimental Node.js 16.x due to ENABLE_EXPERIMENTAL_NODE16=1',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should get latest node version', async () => {
|
||||
expect(getLatestNodeVersion()).toHaveProperty('major', 14);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "24.1.1-canary.3",
|
||||
"version": "24.2.0",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -43,11 +43,11 @@
|
||||
"node": ">= 12"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@vercel/go": "1.3.3-canary.2",
|
||||
"@vercel/node": "1.14.2-canary.3",
|
||||
"@vercel/python": "2.2.3-canary.2",
|
||||
"@vercel/ruby": "1.3.3-canary.2",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@vercel/go": "1.4.0",
|
||||
"@vercel/node": "1.15.0",
|
||||
"@vercel/python": "2.3.0",
|
||||
"@vercel/ruby": "1.3.3",
|
||||
"update-notifier": "4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -69,7 +69,7 @@
|
||||
"@types/glob": "7.1.1",
|
||||
"@types/http-proxy": "1.16.2",
|
||||
"@types/inquirer": "7.3.1",
|
||||
"@types/jest": "27.0.1",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/jest-expect-message": "1.0.3",
|
||||
"@types/load-json-file": "2.0.7",
|
||||
"@types/mime-types": "2.1.0",
|
||||
@@ -90,9 +90,9 @@
|
||||
"@types/update-notifier": "5.1.0",
|
||||
"@types/which": "1.3.2",
|
||||
"@types/write-json-file": "2.2.1",
|
||||
"@vercel/client": "10.4.2-canary.2",
|
||||
"@vercel/client": "11.0.0",
|
||||
"@vercel/fetch-retry": "5.0.3",
|
||||
"@vercel/frameworks": "0.7.1",
|
||||
"@vercel/frameworks": "0.8.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@zeit/fun": "0.11.2",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
|
||||
@@ -181,6 +181,21 @@ export default async (client: Client) => {
|
||||
);
|
||||
}
|
||||
|
||||
// build `--prebuilt`
|
||||
if (argv['--prebuilt']) {
|
||||
const prebuiltExists = await fs.pathExists(join(path, '.vercel/output'));
|
||||
if (!prebuiltExists) {
|
||||
error(
|
||||
`The ${param(
|
||||
'--prebuilt'
|
||||
)} option was used, but no prebuilt output found in ".vercel/output". Run ${getCommandName(
|
||||
'build'
|
||||
)} to generate a local build.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve `project` and `org` from .vercel
|
||||
const link = await getLinkedProject(client, path);
|
||||
|
||||
@@ -195,14 +210,6 @@ export default async (client: Client) => {
|
||||
let sourceFilesOutsideRootDirectory: boolean | undefined = true;
|
||||
|
||||
if (status === 'not_linked') {
|
||||
// In the future this will need to be implemented in both the CLI and vercel.com/new at the same time
|
||||
if (localConfig?.projectSettings) {
|
||||
output.error(
|
||||
'Unexpected property detected in vercel.json: "projectSettings"'
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const shouldStartSetup =
|
||||
autoConfirm ||
|
||||
(await confirm(
|
||||
@@ -468,10 +475,7 @@ export default async (client: Client) => {
|
||||
|
||||
if (!localConfig.builds || localConfig.builds.length === 0) {
|
||||
// Only add projectSettings for zero config deployments
|
||||
createArgs.projectSettings = {
|
||||
...localConfig.projectSettings,
|
||||
sourceFilesOutsideRootDirectory,
|
||||
};
|
||||
createArgs.projectSettings = { sourceFilesOutsideRootDirectory };
|
||||
}
|
||||
|
||||
deployment = await createDeploy(
|
||||
@@ -503,10 +507,7 @@ export default async (client: Client) => {
|
||||
);
|
||||
|
||||
// deploy again, but send projectSettings this time
|
||||
createArgs.projectSettings = {
|
||||
...settings,
|
||||
...localConfig.projectSettings,
|
||||
};
|
||||
createArgs.projectSettings = settings;
|
||||
|
||||
deployStamp = stamp();
|
||||
createArgs.deployStamp = deployStamp;
|
||||
|
||||
6
packages/cli/src/commands/env/pull.ts
vendored
6
packages/cli/src/commands/env/pull.ts
vendored
@@ -1,5 +1,6 @@
|
||||
import chalk from 'chalk';
|
||||
import { closeSync, openSync, promises, readSync } from 'fs';
|
||||
import { outputFile } from 'fs-extra';
|
||||
import { closeSync, openSync, readSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { Project, ProjectEnvTarget } from '../../types';
|
||||
import Client from '../../util/client';
|
||||
@@ -12,7 +13,6 @@ import { Output } from '../../util/output';
|
||||
import param from '../../util/output/param';
|
||||
import stamp from '../../util/output/stamp';
|
||||
import { getCommandName } from '../../util/pkg-name';
|
||||
const { writeFile } = promises;
|
||||
|
||||
const CONTENTS_PREFIX = '# Created by Vercel CLI\n';
|
||||
|
||||
@@ -111,7 +111,7 @@ export default async function pull(
|
||||
.join('\n') +
|
||||
'\n';
|
||||
|
||||
await writeFile(fullPath, contents, 'utf8');
|
||||
await outputFile(fullPath, contents, 'utf8');
|
||||
|
||||
output.print(
|
||||
`${prependEmoji(
|
||||
|
||||
@@ -585,73 +585,73 @@ const main = async () => {
|
||||
let func: any;
|
||||
switch (targetCommand) {
|
||||
case 'alias':
|
||||
func = await import('./commands/alias');
|
||||
func = require('./commands/alias').default;
|
||||
break;
|
||||
case 'billing':
|
||||
func = await import('./commands/billing');
|
||||
func = require('./commands/billing').default;
|
||||
break;
|
||||
case 'bisect':
|
||||
func = await import('./commands/bisect');
|
||||
func = require('./commands/bisect').default;
|
||||
break;
|
||||
case 'certs':
|
||||
func = await import('./commands/certs');
|
||||
func = require('./commands/certs').default;
|
||||
break;
|
||||
case 'deploy':
|
||||
func = await import('./commands/deploy');
|
||||
func = require('./commands/deploy').default;
|
||||
break;
|
||||
case 'dev':
|
||||
func = await import('./commands/dev');
|
||||
func = require('./commands/dev').default;
|
||||
break;
|
||||
case 'dns':
|
||||
func = await import('./commands/dns');
|
||||
func = require('./commands/dns').default;
|
||||
break;
|
||||
case 'domains':
|
||||
func = await import('./commands/domains');
|
||||
func = require('./commands/domains').default;
|
||||
break;
|
||||
case 'env':
|
||||
func = await import('./commands/env');
|
||||
func = require('./commands/env').default;
|
||||
break;
|
||||
case 'init':
|
||||
func = await import('./commands/init');
|
||||
func = require('./commands/init').default;
|
||||
break;
|
||||
case 'inspect':
|
||||
func = await import('./commands/inspect');
|
||||
func = require('./commands/inspect').default;
|
||||
break;
|
||||
case 'link':
|
||||
func = await import('./commands/link');
|
||||
func = require('./commands/link').default;
|
||||
break;
|
||||
case 'list':
|
||||
func = await import('./commands/list');
|
||||
func = require('./commands/list').default;
|
||||
break;
|
||||
case 'logs':
|
||||
func = await import('./commands/logs');
|
||||
func = require('./commands/logs').default;
|
||||
break;
|
||||
case 'login':
|
||||
func = await import('./commands/login');
|
||||
func = require('./commands/login').default;
|
||||
break;
|
||||
case 'logout':
|
||||
func = await import('./commands/logout');
|
||||
func = require('./commands/logout').default;
|
||||
break;
|
||||
case 'projects':
|
||||
func = await import('./commands/projects');
|
||||
func = require('./commands/projects').default;
|
||||
break;
|
||||
case 'pull':
|
||||
func = await import('./commands/pull');
|
||||
func = require('./commands/pull').default;
|
||||
break;
|
||||
case 'remove':
|
||||
func = await import('./commands/remove');
|
||||
func = require('./commands/remove').default;
|
||||
break;
|
||||
case 'secrets':
|
||||
func = await import('./commands/secrets');
|
||||
func = require('./commands/secrets').default;
|
||||
break;
|
||||
case 'teams':
|
||||
func = await import('./commands/teams');
|
||||
func = require('./commands/teams').default;
|
||||
break;
|
||||
case 'update':
|
||||
func = await import('./commands/update');
|
||||
func = require('./commands/update').default;
|
||||
break;
|
||||
case 'whoami':
|
||||
func = await import('./commands/whoami');
|
||||
func = require('./commands/whoami').default;
|
||||
break;
|
||||
default:
|
||||
func = null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { writeFile } from 'fs-extra';
|
||||
import { outputJSON } from 'fs-extra';
|
||||
import { Org, Project, ProjectLink } from '../../types';
|
||||
import { getLinkFromDir, VERCEL_DIR, VERCEL_DIR_PROJECT } from './link';
|
||||
import { join } from 'path';
|
||||
@@ -22,21 +22,22 @@ export async function writeProjectSettings(
|
||||
project: Project,
|
||||
org: Org
|
||||
) {
|
||||
return await writeFile(
|
||||
join(cwd, VERCEL_DIR, VERCEL_DIR_PROJECT),
|
||||
JSON.stringify({
|
||||
projectId: project.id,
|
||||
orgId: org.id,
|
||||
settings: {
|
||||
buildCommand: project.buildCommand,
|
||||
devCommand: project.devCommand,
|
||||
outputDirectory: project.outputDirectory,
|
||||
directoryListing: project.directoryListing,
|
||||
rootDirectory: project.rootDirectory,
|
||||
framework: project.framework,
|
||||
},
|
||||
})
|
||||
);
|
||||
const data = {
|
||||
projectId: project.id,
|
||||
orgId: org.id,
|
||||
settings: {
|
||||
buildCommand: project.buildCommand,
|
||||
devCommand: project.devCommand,
|
||||
outputDirectory: project.outputDirectory,
|
||||
directoryListing: project.directoryListing,
|
||||
rootDirectory: project.rootDirectory,
|
||||
framework: project.framework,
|
||||
},
|
||||
};
|
||||
const path = join(cwd, VERCEL_DIR, VERCEL_DIR_PROJECT);
|
||||
return await outputJSON(path, data, {
|
||||
spaces: 2,
|
||||
});
|
||||
}
|
||||
|
||||
export async function readProjectSettings(cwd: string) {
|
||||
|
||||
@@ -31,6 +31,15 @@ describe('deploy', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject deploying a directory that does not contain ".vercel/output" when `--prebuilt` is used', async () => {
|
||||
client.setArgv('deploy', __dirname, '--prebuilt');
|
||||
const exitCode = await deploy(client);
|
||||
expect(exitCode).toEqual(1);
|
||||
expect(client.outputBuffer).toEqual(
|
||||
'Error! The "--prebuilt" option was used, but no prebuilt output found in ".vercel/output". Run `vercel build` to generate a local build.\n'
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject deploying "version: 1"', async () => {
|
||||
client.setArgv('deploy');
|
||||
client.localConfig = {
|
||||
|
||||
@@ -28,6 +28,42 @@ describe('pull', () => {
|
||||
expect(devFileHasDevEnv).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should handle pulling with env vars (headless mode)', async () => {
|
||||
try {
|
||||
process.env.VERCEL_PROJECT_ID = 'vercel-pull-next';
|
||||
process.env.VERCEL_ORG_ID = 'team_dummy';
|
||||
|
||||
const cwd = setupFixture('vercel-pull-next');
|
||||
|
||||
// Remove the `.vercel` dir to ensure that the `pull`
|
||||
// command creates a new one based on env vars
|
||||
await fs.remove(path.join(cwd, '.vercel'));
|
||||
|
||||
useUser();
|
||||
useTeams('team_dummy');
|
||||
useProject({
|
||||
...defaultProject,
|
||||
id: 'vercel-pull-next',
|
||||
name: 'vercel-pull-next',
|
||||
});
|
||||
client.setArgv('pull', cwd);
|
||||
const exitCode = await pull(client);
|
||||
expect(exitCode, client.outputBuffer).toEqual(0);
|
||||
|
||||
const config = await fs.readJSON(path.join(cwd, '.vercel/project.json'));
|
||||
expect(config).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"orgId": "team_dummy",
|
||||
"projectId": "vercel-pull-next",
|
||||
"settings": Object {},
|
||||
}
|
||||
`);
|
||||
} finally {
|
||||
delete process.env.VERCEL_PROJECT_ID;
|
||||
delete process.env.VERCEL_ORG_ID;
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle --environment=preview flag', async () => {
|
||||
const cwd = setupFixture('vercel-pull-next');
|
||||
useUser();
|
||||
|
||||
@@ -15,7 +15,7 @@ cache:
|
||||
|
||||
env:
|
||||
global:
|
||||
# See https://git.io/vdao3 for details.
|
||||
# See https://github.com/ember-cli/ember-cli/blob/master/docs/build-concurrency.md
|
||||
- JOBS=1
|
||||
|
||||
script:
|
||||
|
||||
@@ -413,10 +413,6 @@ module.exports = async function prepare(session, binaryPath) {
|
||||
projectId: 'QmRoBYhejkkmssotLZr8tWgewPdPcjYucYUNERFbhJrRNi',
|
||||
}),
|
||||
},
|
||||
'project-settings-overrides': {
|
||||
'vercel.json': '{}',
|
||||
'package.json': '{}',
|
||||
},
|
||||
};
|
||||
|
||||
for (const [typeName, needed] of Object.entries(spec)) {
|
||||
|
||||
145
packages/cli/test/integration.js
vendored
145
packages/cli/test/integration.js
vendored
@@ -18,7 +18,6 @@ import fs, {
|
||||
copy,
|
||||
ensureDir,
|
||||
exists,
|
||||
mkdir,
|
||||
} from 'fs-extra';
|
||||
import logo from '../src/util/output/logo';
|
||||
import sleep from '../src/util/sleep';
|
||||
@@ -2149,11 +2148,6 @@ const verifyExampleAngular = (cwd, dir) =>
|
||||
fs.existsSync(path.join(cwd, dir, 'tsconfig.json')) &&
|
||||
fs.existsSync(path.join(cwd, dir, 'angular.json'));
|
||||
|
||||
const verifyExampleAmp = (cwd, dir) =>
|
||||
fs.existsSync(path.join(cwd, dir, 'index.html')) &&
|
||||
fs.existsSync(path.join(cwd, dir, 'logo.png')) &&
|
||||
fs.existsSync(path.join(cwd, dir, 'favicon.png'));
|
||||
|
||||
test('initialize example "angular"', async t => {
|
||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||||
const cwd = tmpDir.name;
|
||||
@@ -2188,21 +2182,6 @@ test('initialize example ("angular") to specified directory', async t => {
|
||||
t.true(verifyExampleAngular(cwd, 'ang'), formatOutput({ stdout, stderr }));
|
||||
});
|
||||
|
||||
test('initialize selected example ("amp")', async t => {
|
||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||||
const cwd = tmpDir.name;
|
||||
const goal = '> Success! Initialized "amp" example in';
|
||||
|
||||
const { stdout, stderr, exitCode } = await execute(['init'], {
|
||||
cwd,
|
||||
input: '\n',
|
||||
});
|
||||
|
||||
t.is(exitCode, 0, formatOutput({ stdout, stderr }));
|
||||
t.true(stderr.includes(goal), formatOutput({ stdout, stderr }));
|
||||
t.true(verifyExampleAmp(cwd, 'amp'), formatOutput({ stdout, stderr }));
|
||||
});
|
||||
|
||||
test('initialize example to existing directory with "-f"', async t => {
|
||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||||
const cwd = tmpDir.name;
|
||||
@@ -3682,127 +3661,3 @@ test('[vc link] should support the `--project` flag', async t => {
|
||||
formatOutput(output)
|
||||
);
|
||||
});
|
||||
|
||||
test('vercel.json projectSettings overrides', async t => {
|
||||
// create project directory and get path to vercel.json
|
||||
const projectName = 'project-settings-overrides';
|
||||
const directory = fixture(projectName);
|
||||
const vercelJsonPath = path.join(directory, 'vercel.json');
|
||||
|
||||
async function deploy(expectedStatusCode = 0) {
|
||||
// deploy and assert deployment is successful
|
||||
const deployment = await execa(
|
||||
binaryPath,
|
||||
[directory, ...defaultArgs, '--public', '--confirm'],
|
||||
{ reject: false }
|
||||
);
|
||||
t.is(
|
||||
deployment.exitCode,
|
||||
expectedStatusCode,
|
||||
formatOutput({
|
||||
stderr: deployment.stderr,
|
||||
stdout: deployment.stdout,
|
||||
})
|
||||
);
|
||||
return deployment;
|
||||
}
|
||||
|
||||
// Test that deployment fails with override settings on new deployments
|
||||
await writeFile(
|
||||
vercelJsonPath,
|
||||
JSON.stringify({
|
||||
projectSettings: {
|
||||
outputDirectory: 'output',
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
let deployment = await deploy(1);
|
||||
|
||||
t.true(
|
||||
deployment.stderr.includes(
|
||||
'Error! Unexpected property detected in vercel.json: "projectSettings"'
|
||||
)
|
||||
);
|
||||
|
||||
// Make sure vercel.json is empty for first deployment
|
||||
await writeFile(vercelJsonPath, JSON.stringify({}));
|
||||
|
||||
deployment = await deploy();
|
||||
|
||||
// create and write override project settings
|
||||
const BUILD_COMMAND =
|
||||
'mkdir output && echo "Hello, World 1" >> output/index.txt';
|
||||
const OUTPUT_DIRECTORY = 'output';
|
||||
|
||||
await writeFile(
|
||||
vercelJsonPath,
|
||||
JSON.stringify({
|
||||
projectSettings: {
|
||||
buildCommand: BUILD_COMMAND,
|
||||
outputDirectory: OUTPUT_DIRECTORY,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
deployment = await deploy();
|
||||
|
||||
// assert the command were executed
|
||||
let page = await fetch(deployment.stdout);
|
||||
let text = await page.text();
|
||||
t.is(text, `Hello, World 1\n`);
|
||||
|
||||
// Failure Case
|
||||
await writeFile(
|
||||
vercelJsonPath,
|
||||
JSON.stringify({
|
||||
projectSettings: {
|
||||
invalidProjectSetting: 'invalid project setting',
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// Deployment should fail
|
||||
deployment = await deploy(1);
|
||||
t.true(
|
||||
deployment.stderr.includes(
|
||||
'Error! Invalid request: `projectSettings` should NOT have additional property `invalidProjectSetting`.'
|
||||
)
|
||||
);
|
||||
|
||||
// Test Next.js Framework deployment
|
||||
await mkdir(`${directory}/pages`);
|
||||
await writeFile(
|
||||
`${directory}/pages/index.js`,
|
||||
`export default () => 'Hello, World 2'`
|
||||
);
|
||||
await writeFile(
|
||||
vercelJsonPath,
|
||||
JSON.stringify({
|
||||
projectSettings: {
|
||||
framework: 'nextjs',
|
||||
},
|
||||
})
|
||||
);
|
||||
await writeFile(
|
||||
`${directory}/package.json`,
|
||||
JSON.stringify({
|
||||
scripts: {
|
||||
dev: 'next',
|
||||
start: 'next start',
|
||||
build: 'next build',
|
||||
},
|
||||
dependencies: {
|
||||
next: 'latest',
|
||||
react: 'latest',
|
||||
'react-dom': 'latest',
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
deployment = await deploy();
|
||||
|
||||
page = await fetch(deployment.stdout);
|
||||
text = await page.text();
|
||||
t.true(text.includes(`Hello, World 2`));
|
||||
});
|
||||
|
||||
@@ -152,6 +152,7 @@ export function useProject(project: Partial<Project> = defaultProject) {
|
||||
if (typeof target === 'string') {
|
||||
const targetEnvs = envs.filter(env => env.target.includes(target));
|
||||
res.json({ envs: targetEnvs });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json({ envs });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "10.4.2-canary.2",
|
||||
"version": "11.0.0",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"homepage": "https://vercel.com",
|
||||
@@ -24,7 +24,7 @@
|
||||
"devDependencies": {
|
||||
"@types/async-retry": "1.4.1",
|
||||
"@types/fs-extra": "7.0.0",
|
||||
"@types/jest": "27.0.1",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/minimatch": "3.0.5",
|
||||
"@types/ms": "0.7.30",
|
||||
"@types/node": "12.0.4",
|
||||
@@ -41,7 +41,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@zeit/fetch": "5.2.0",
|
||||
"async-retry": "1.2.3",
|
||||
"async-sema": "3.0.0",
|
||||
|
||||
@@ -126,27 +126,6 @@ export async function* deploy(
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
files.size === 1 &&
|
||||
deploymentOptions.builds === undefined &&
|
||||
deploymentOptions.routes === undefined &&
|
||||
deploymentOptions.cleanUrls === undefined &&
|
||||
deploymentOptions.rewrites === undefined &&
|
||||
deploymentOptions.redirects === undefined &&
|
||||
deploymentOptions.headers === undefined &&
|
||||
deploymentOptions.trailingSlash === undefined
|
||||
) {
|
||||
debug(`Assigning '/' route for single file deployment`);
|
||||
const filePath = Array.from(files.values())[0].names[0];
|
||||
|
||||
deploymentOptions.routes = [
|
||||
{
|
||||
src: '/',
|
||||
dest: `/${filePath.split('/').pop()}`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
if (!deploymentOptions.name) {
|
||||
deploymentOptions.name =
|
||||
clientOptions.defaultName || getDefaultName(files, clientOptions);
|
||||
|
||||
1
packages/frameworks/logos/next-dark.svg
Normal file
1
packages/frameworks/logos/next-dark.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.428.013c-.103.01-.431.042-.727.066C14.883.693 8.497 4.37 4.453 10.024A23.754 23.754 0 0 0 .216 20.51C.023 21.828 0 22.217 0 24.005c0 1.787.023 2.177.216 3.495 1.304 9.012 7.718 16.584 16.417 19.39 1.558.501 3.2.844 5.068 1.05.727.08 3.87.08 4.598 0 3.224-.356 5.954-1.154 8.648-2.529.412-.21.492-.267.436-.314-.038-.028-1.797-2.388-3.909-5.24l-3.838-5.184-4.809-7.117c-2.646-3.913-4.824-7.112-4.842-7.112-.019-.005-.038 3.157-.047 7.018-.014 6.76-.019 7.033-.103 7.192-.122.23-.216.324-.413.427-.15.075-.282.09-.99.09h-.812l-.216-.137a.878.878 0 0 1-.314-.342l-.099-.211.01-9.407.014-9.41.145-.184c.075-.098.235-.225.347-.286.193-.094.268-.103 1.08-.103.957 0 1.116.038 1.365.31.07.075 2.674 3.997 5.79 8.721s7.376 11.175 9.469 14.342l3.8 5.756.192-.127c1.704-1.107 3.505-2.683 4.932-4.325a23.888 23.888 0 0 0 5.65-12.268c.192-1.319.215-1.708.215-3.495 0-1.788-.023-2.177-.216-3.495-1.304-9.013-7.718-16.584-16.417-19.39C29.832.623 28.199.28 26.369.074c-.45-.047-3.551-.099-3.94-.061zm9.825 14.515a.947.947 0 0 1 .474.554c.038.122.047 2.73.038 8.608l-.014 8.436-1.488-2.28-1.492-2.28v-6.132c0-3.964.019-6.193.047-6.3a.957.957 0 0 1 .465-.592c.192-.098.262-.108 1-.108.694 0 .816.01.97.094z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "0.7.1",
|
||||
"version": "0.8.0",
|
||||
"main": "./dist/frameworks.js",
|
||||
"types": "./dist/frameworks.d.ts",
|
||||
"files": [
|
||||
@@ -16,11 +16,11 @@
|
||||
"js-yaml": "3.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.0.1",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/js-yaml": "3.12.1",
|
||||
"@types/node": "12.0.4",
|
||||
"@types/node-fetch": "2.5.8",
|
||||
"@vercel/routing-utils": "1.13.1",
|
||||
"@vercel/routing-utils": "1.13.2",
|
||||
"ajv": "6.12.2",
|
||||
"typescript": "4.3.4"
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ export const frameworks = [
|
||||
slug: 'nextjs',
|
||||
demo: 'https://nextjs-template.vercel.app',
|
||||
logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/next.svg',
|
||||
darkModeLogo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/next-dark.svg',
|
||||
screenshot:
|
||||
'https://assets.vercel.com/image/upload/v1647366075/front/import/nextjs.png',
|
||||
tagline:
|
||||
|
||||
@@ -60,6 +60,11 @@ export interface Framework {
|
||||
* @example "https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/next.svg"
|
||||
*/
|
||||
logo: string;
|
||||
/**
|
||||
* An additional URL to the logo of the framework optimized for dark mode
|
||||
* @example "https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/next-dark.svg"
|
||||
*/
|
||||
darkModeLogo?: string;
|
||||
/**
|
||||
* A URL to a screenshot of the demo
|
||||
* @example "https://assets.vercel.com/image/upload/v1647366075/front/import/nextjs.png"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/go",
|
||||
"version": "1.3.3-canary.2",
|
||||
"version": "1.4.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
||||
@@ -24,7 +24,7 @@
|
||||
"@types/fs-extra": "^5.0.5",
|
||||
"@types/node-fetch": "^2.3.0",
|
||||
"@types/tar": "^4.0.0",
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"async-retry": "1.3.1",
|
||||
"execa": "^1.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/node-bridge",
|
||||
"version": "2.2.1-canary.0",
|
||||
"version": "2.2.1",
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"repository": {
|
||||
|
||||
1
packages/node/.gitignore
vendored
1
packages/node/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/dist
|
||||
/test/fixtures/**/types.d.ts
|
||||
/test/fixtures/11-symlinks/symlink
|
||||
!test/cache-fixtures/**
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/node",
|
||||
"version": "1.14.2-canary.3",
|
||||
"version": "1.15.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
||||
@@ -12,6 +12,7 @@
|
||||
"scripts": {
|
||||
"build": "node build",
|
||||
"test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.js",
|
||||
"test-unit": "jest --env node --verbose --bail test/prepare-cache.test.js",
|
||||
"prepublishOnly": "node build"
|
||||
},
|
||||
"files": [
|
||||
@@ -19,7 +20,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@vercel/node-bridge": "2.2.1-canary.0",
|
||||
"@vercel/node-bridge": "2.2.1",
|
||||
"ts-node": "8.9.1",
|
||||
"typescript": "4.3.4"
|
||||
},
|
||||
@@ -32,7 +33,7 @@
|
||||
"@types/cookie": "0.3.3",
|
||||
"@types/etag": "1.8.0",
|
||||
"@types/test-listen": "1.1.0",
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@vercel/nft": "0.18.1",
|
||||
"content-type": "1.0.4",
|
||||
|
||||
@@ -380,9 +380,8 @@ export const build: BuildV3 = async ({
|
||||
return { output: lambda };
|
||||
};
|
||||
|
||||
export const prepareCache: PrepareCache = async ({ workPath }) => {
|
||||
const cache = await glob('node_modules/**', workPath);
|
||||
return cache;
|
||||
export const prepareCache: PrepareCache = ({ repoRootPath, workPath }) => {
|
||||
return glob('**/node_modules/**', repoRootPath || workPath);
|
||||
};
|
||||
|
||||
export const startDevServer: StartDevServer = async opts => {
|
||||
|
||||
0
packages/node/test/cache-fixtures/foo/node_modules/file
generated
vendored
Normal file
0
packages/node/test/cache-fixtures/foo/node_modules/file
generated
vendored
Normal file
0
packages/node/test/cache-fixtures/index.js
Normal file
0
packages/node/test/cache-fixtures/index.js
Normal file
0
packages/node/test/cache-fixtures/node_modules/file
generated
vendored
Normal file
0
packages/node/test/cache-fixtures/node_modules/file
generated
vendored
Normal file
28
packages/node/test/prepare-cache.test.js
vendored
Normal file
28
packages/node/test/prepare-cache.test.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
const path = require('path');
|
||||
const { prepareCache } = require('../dist');
|
||||
|
||||
describe('prepareCache()', () => {
|
||||
test('should cache **/node_modules/**', async () => {
|
||||
const files = await prepareCache({
|
||||
repoRootPath: path.resolve(__dirname, './cache-fixtures/'),
|
||||
});
|
||||
|
||||
expect(files['foo/node_modules/file']).toBeDefined();
|
||||
expect(files['node_modules/file']).toBeDefined();
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should ignore root modules', async () => {
|
||||
const files = await prepareCache({
|
||||
workPath: path.resolve(__dirname, './cache-fixtures/foo/'),
|
||||
});
|
||||
|
||||
expect(files['node_modules/file']).toBeDefined();
|
||||
expect(
|
||||
files['node_modules/file'].fsPath.includes(
|
||||
'cache-fixtures/foo/node_modules/file'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
});
|
||||
5
packages/python/jest.config.js
Normal file
5
packages/python/jest.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/python",
|
||||
"version": "2.2.3-canary.2",
|
||||
"version": "2.3.0",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
||||
@@ -15,12 +15,14 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node build",
|
||||
"test-integration-once": "jest --env node --verbose --runInBand --bail",
|
||||
"test-unit": "jest --env node --verbose --runInBand --bail test/unit.test.ts ",
|
||||
"test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.ts",
|
||||
"prepublishOnly": "node build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/execa": "^0.9.0",
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@types/jest": "27.4.1",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "^1.0.0",
|
||||
"typescript": "4.3.4"
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
NowBuildError,
|
||||
} from '@vercel/build-utils';
|
||||
import { installRequirement, installRequirementsFile } from './install';
|
||||
import { getLatestPythonVersion, getSupportedPythonVersion } from './version';
|
||||
|
||||
async function pipenvConvert(cmd: string, srcDir: string) {
|
||||
debug('Running pipfile2req...');
|
||||
@@ -59,9 +60,7 @@ export const build = async ({
|
||||
meta = {},
|
||||
config,
|
||||
}: BuildOptions) => {
|
||||
let pipPath = meta.isDev ? 'pip3' : 'pip3.9';
|
||||
let pythonPath = meta.isDev ? 'python3' : 'python3.9';
|
||||
let pythonRuntime = meta.isDev ? 'python3' : 'python3.9';
|
||||
let pythonVersion = getLatestPythonVersion(meta);
|
||||
|
||||
workPath = await downloadFilesInWorkPath({
|
||||
workPath,
|
||||
@@ -91,8 +90,8 @@ export const build = async ({
|
||||
console.log('Installing required dependencies...');
|
||||
|
||||
await installRequirement({
|
||||
pythonPath,
|
||||
pipPath,
|
||||
pythonPath: pythonVersion.pythonPath,
|
||||
pipPath: pythonVersion.pipPath,
|
||||
dependency: 'werkzeug',
|
||||
version: '1.0.1',
|
||||
workPath,
|
||||
@@ -114,25 +113,10 @@ export const build = async ({
|
||||
try {
|
||||
const json = await readFile(join(pipfileLockDir, 'Pipfile.lock'), 'utf8');
|
||||
const obj = JSON.parse(json);
|
||||
const version = obj?._meta?.requires?.python_version;
|
||||
if (!meta.isDev) {
|
||||
if (version === '3.6') {
|
||||
pipPath = 'pip3.6';
|
||||
pythonPath = 'python3.6';
|
||||
pythonRuntime = 'python3.6';
|
||||
console.warn(
|
||||
`Warning: Python version "${version}" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade. http://vercel.link/python-version`
|
||||
);
|
||||
} else if (version === '3.9') {
|
||||
pipPath = 'pip3.9';
|
||||
pythonPath = 'python3.9';
|
||||
pythonRuntime = 'python3.9';
|
||||
} else {
|
||||
console.warn(
|
||||
`Warning: Invalid Python version "${version}" detected in Pipfile.lock will be ignored. http://vercel.link/python-version`
|
||||
);
|
||||
}
|
||||
}
|
||||
pythonVersion = getSupportedPythonVersion({
|
||||
isDev: meta.isDev,
|
||||
pipLockPythonVersion: obj?._meta?.requires?.python_version,
|
||||
});
|
||||
} catch (err) {
|
||||
throw new NowBuildError({
|
||||
code: 'INVALID_PIPFILE_LOCK',
|
||||
@@ -146,8 +130,8 @@ export const build = async ({
|
||||
// it into a separate folder.
|
||||
const tempDir = await getWriteableDirectory();
|
||||
await installRequirement({
|
||||
pythonPath,
|
||||
pipPath,
|
||||
pythonPath: pythonVersion.pythonPath,
|
||||
pipPath: pythonVersion.pipPath,
|
||||
dependency: 'pipfile-requirements',
|
||||
version: '0.3.0',
|
||||
workPath: tempDir,
|
||||
@@ -169,8 +153,8 @@ export const build = async ({
|
||||
debug('Found local "requirements.txt"');
|
||||
const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
|
||||
await installRequirementsFile({
|
||||
pythonPath,
|
||||
pipPath,
|
||||
pythonPath: pythonVersion.pythonPath,
|
||||
pipPath: pythonVersion.pipPath,
|
||||
filePath: requirementsTxtPath,
|
||||
workPath,
|
||||
meta,
|
||||
@@ -179,8 +163,8 @@ export const build = async ({
|
||||
debug('Found global "requirements.txt"');
|
||||
const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
|
||||
await installRequirementsFile({
|
||||
pythonPath,
|
||||
pipPath,
|
||||
pythonPath: pythonVersion.pythonPath,
|
||||
pipPath: pythonVersion.pipPath,
|
||||
filePath: requirementsTxtPath,
|
||||
workPath,
|
||||
meta,
|
||||
@@ -205,9 +189,6 @@ export const build = async ({
|
||||
|
||||
await writeFile(join(workPath, `${handlerPyFilename}.py`), handlerPyContents);
|
||||
|
||||
// Use the system-installed version of `python3` when running via `vercel dev`
|
||||
const runtime = meta.isDev ? 'python3' : pythonRuntime;
|
||||
|
||||
const globOptions: GlobOptions = {
|
||||
cwd: workPath,
|
||||
ignore:
|
||||
@@ -219,7 +200,7 @@ export const build = async ({
|
||||
const lambda = await createLambda({
|
||||
files: await glob('**', globOptions),
|
||||
handler: `${handlerPyFilename}.vc_handler`,
|
||||
runtime,
|
||||
runtime: pythonVersion.runtime,
|
||||
environment: {},
|
||||
});
|
||||
|
||||
|
||||
95
packages/python/src/version.ts
Normal file
95
packages/python/src/version.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { NowBuildError } from '@vercel/build-utils';
|
||||
|
||||
interface PythonVersion {
|
||||
version: string;
|
||||
pipPath: string;
|
||||
pythonPath: string;
|
||||
runtime: string;
|
||||
discontinueDate?: Date;
|
||||
}
|
||||
|
||||
// The order must be most recent first
|
||||
const allOptions: PythonVersion[] = [
|
||||
{
|
||||
version: '3.9',
|
||||
pipPath: 'pip3.9',
|
||||
pythonPath: 'python3.9',
|
||||
runtime: 'python3.9',
|
||||
},
|
||||
{
|
||||
version: '3.6',
|
||||
pipPath: 'pip3.6',
|
||||
pythonPath: 'python3.6',
|
||||
runtime: 'python3.6',
|
||||
discontinueDate: new Date('2022-07-18'),
|
||||
},
|
||||
];
|
||||
|
||||
const upstreamProvider =
|
||||
'This change is the result of a decision made by an upstream infrastructure provider (AWS)';
|
||||
|
||||
function getDevPythonVersion(): PythonVersion {
|
||||
// Use the system-installed version of `python3` when running `vercel dev`
|
||||
return {
|
||||
version: '3',
|
||||
pipPath: 'pip3',
|
||||
pythonPath: 'python3',
|
||||
runtime: 'python3',
|
||||
};
|
||||
}
|
||||
export function getLatestPythonVersion({
|
||||
isDev,
|
||||
}: {
|
||||
isDev?: boolean;
|
||||
}): PythonVersion {
|
||||
if (isDev) {
|
||||
return getDevPythonVersion();
|
||||
}
|
||||
return allOptions[0];
|
||||
}
|
||||
|
||||
export function getSupportedPythonVersion({
|
||||
isDev,
|
||||
pipLockPythonVersion,
|
||||
}: {
|
||||
isDev?: boolean;
|
||||
pipLockPythonVersion: string | undefined;
|
||||
}): PythonVersion {
|
||||
if (isDev) {
|
||||
return getDevPythonVersion();
|
||||
}
|
||||
let selection = getLatestPythonVersion({ isDev: false });
|
||||
|
||||
if (typeof pipLockPythonVersion === 'string') {
|
||||
const found = allOptions.find(o => o.version === pipLockPythonVersion);
|
||||
if (found) {
|
||||
selection = found;
|
||||
} else {
|
||||
console.warn(
|
||||
`Warning: Python version "${pipLockPythonVersion}" detected in Pipfile.lock is invalid and will be ignored. http://vercel.link/python-version`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isDiscontinued(selection)) {
|
||||
throw new NowBuildError({
|
||||
code: 'BUILD_UTILS_PYTHON_VERSION_DISCONTINUED',
|
||||
link: 'http://vercel.link/python-version',
|
||||
message: `Python version "${selection.version}" detected in Pipfile.lock is discontinued and must be upgraded. ${upstreamProvider}.`,
|
||||
});
|
||||
}
|
||||
|
||||
if (selection.discontinueDate) {
|
||||
const d = selection.discontinueDate.toISOString().split('T')[0];
|
||||
console.warn(
|
||||
`Error: Python version "${selection.version}" detected in Pipfile.lock is deprecated. Deployments created on or after ${d} will fail to build. ${upstreamProvider}. http://vercel.link/python-version`
|
||||
);
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
function isDiscontinued({ discontinueDate }: PythonVersion): boolean {
|
||||
const today = Date.now();
|
||||
return discontinueDate !== undefined && discontinueDate.getTime() <= today;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
from sanic import Sanic
|
||||
from sanic.response import json
|
||||
app = Sanic()
|
||||
app = Sanic(name='test')
|
||||
|
||||
@app.route('/')
|
||||
@app.route('/<path:path>')
|
||||
|
||||
@@ -1,2 +1,23 @@
|
||||
sanic==19.6.0
|
||||
flask==1.0.2
|
||||
sanic==20.12.6
|
||||
flask==2.1.1
|
||||
# below is meant to lock the version of transitive deps
|
||||
aiofiles==0.8.0; python_version >= "3.6" and python_version < "4.0"
|
||||
certifi==2021.10.8
|
||||
click==8.1.2; python_version >= "3.7"
|
||||
h11==0.9.0
|
||||
httpcore==0.11.1; python_version >= "3.6"
|
||||
httptools==0.4.0; python_version >= "3.5"
|
||||
httpx==0.15.4; python_version >= "3.6"
|
||||
idna==3.3
|
||||
importlib-metadata==4.11.3; python_version < "3.10"
|
||||
itsdangerous==2.1.2; python_version >= "3.7"
|
||||
jinja2==3.1.1; python_version >= "3.7"
|
||||
markupsafe==2.1.1; python_version >= "3.7"
|
||||
multidict==5.2.0; python_version >= "3.6"
|
||||
rfc3986[idna2008]==1.5.0
|
||||
sniffio==1.2.0; python_version >= "3.5"
|
||||
ujson==5.2.0; sys_platform != "win32" and implementation_name == "cpython"
|
||||
uvloop==0.16.0; sys_platform != "win32" and implementation_name == "cpython"
|
||||
websockets==9.1; python_full_version >= "3.6.1"
|
||||
werkzeug==2.1.1; python_version >= "3.7"
|
||||
zipp==3.8.0; python_version >= "3.7"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"path": "/",
|
||||
"mustContain": "wsgi:RANDOMNESS_PLACEHOLDER",
|
||||
"logMustContain": "Warning: Python version \"3.6\" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade."
|
||||
"logMustContain": "Python version \"3.6\" detected in Pipfile.lock is deprecated. Deployments created on or after 2022-07-18 will fail to build"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{
|
||||
"path": "/",
|
||||
"mustContain": "RANDOMNESS_PLACEHOLDER:env",
|
||||
"logMustContain": "Warning: Python version \"3.6\" detected in Pipfile.lock will reach End-Of-Life December 2021. Please upgrade."
|
||||
"logMustContain": "Python version \"3.6\" detected in Pipfile.lock is deprecated. Deployments created on or after 2022-07-18 will fail to build"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"path": "/",
|
||||
"mustContain": "pip:RANDOMNESS_PLACEHOLDER",
|
||||
"logMustContain": "Warning: Invalid Python version \"3.7\" detected in Pipfile.lock will be ignored."
|
||||
"logMustContain": "Python version \"3.7\" detected in Pipfile.lock is invalid and will be ignored."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
12
packages/python/test/fixtures/09-url-params/Pipfile
vendored
Normal file
12
packages/python/test/fixtures/09-url-params/Pipfile
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
flask = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.9"
|
||||
123
packages/python/test/fixtures/09-url-params/Pipfile.lock
generated
vendored
Normal file
123
packages/python/test/fixtures/09-url-params/Pipfile.lock
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "f7f1cea682a03d85328caf2f88382c4380283d3892a9ba31b374784fb29536c4"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.9"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:24e1a4a9ec5bf6299411369b208c1df2188d9eb8d916302fe6bf03faed227f1e",
|
||||
"sha256:479707fe14d9ec9a0757618b7a100a0ae4c4e236fac5b7f80ca68028141a1a72"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==8.1.2"
|
||||
},
|
||||
"flask": {
|
||||
"hashes": [
|
||||
"sha256:8a4cf32d904cf5621db9f0c9fbcd7efabf3003f22a04e4d0ce790c7137ec5264",
|
||||
"sha256:a8c9bd3e558ec99646d177a9739c41df1ded0629480b4c8d2975412f3c9519c8"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"importlib-metadata": {
|
||||
"hashes": [
|
||||
"sha256:1208431ca90a8cca1a6b8af391bb53c1a2db74e5d1cef6ddced95d4b2062edc6",
|
||||
"sha256:ea4c597ebf37142f827b8f39299579e31685c31d3a438b59f469406afd0f2539"
|
||||
],
|
||||
"markers": "python_version < '3.10'",
|
||||
"version": "==4.11.3"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"hashes": [
|
||||
"sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44",
|
||||
"sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.2"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:539835f51a74a69f41b848a9645dbdc35b4f20a3b601e2d9a7e22947b15ff119",
|
||||
"sha256:640bed4bb501cbd17194b3cace1dc2126f5b619cf068a726b98192a0fde74ae9"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==3.1.1"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003",
|
||||
"sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88",
|
||||
"sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5",
|
||||
"sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7",
|
||||
"sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a",
|
||||
"sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603",
|
||||
"sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1",
|
||||
"sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135",
|
||||
"sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247",
|
||||
"sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6",
|
||||
"sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601",
|
||||
"sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77",
|
||||
"sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02",
|
||||
"sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e",
|
||||
"sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63",
|
||||
"sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f",
|
||||
"sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980",
|
||||
"sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b",
|
||||
"sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812",
|
||||
"sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff",
|
||||
"sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96",
|
||||
"sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1",
|
||||
"sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925",
|
||||
"sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a",
|
||||
"sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6",
|
||||
"sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e",
|
||||
"sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f",
|
||||
"sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4",
|
||||
"sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f",
|
||||
"sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3",
|
||||
"sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c",
|
||||
"sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a",
|
||||
"sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417",
|
||||
"sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a",
|
||||
"sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a",
|
||||
"sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37",
|
||||
"sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452",
|
||||
"sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933",
|
||||
"sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a",
|
||||
"sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"werkzeug": {
|
||||
"hashes": [
|
||||
"sha256:3c5493ece8268fecdcdc9c0b112211acd006354723b280d643ec732b6d4063d6",
|
||||
"sha256:f8e89a20aeabbe8a893c24a461d3ee5dad2123b05cc6abd73ceed01d39c3ae74"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"zipp": {
|
||||
"hashes": [
|
||||
"sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad",
|
||||
"sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==3.8.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Flask==1.0.2
|
||||
12
packages/python/test/fixtures/20-multivalue-header/Pipfile
vendored
Normal file
12
packages/python/test/fixtures/20-multivalue-header/Pipfile
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
flask = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.9"
|
||||
123
packages/python/test/fixtures/20-multivalue-header/Pipfile.lock
generated
vendored
Normal file
123
packages/python/test/fixtures/20-multivalue-header/Pipfile.lock
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "f7f1cea682a03d85328caf2f88382c4380283d3892a9ba31b374784fb29536c4"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.9"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:24e1a4a9ec5bf6299411369b208c1df2188d9eb8d916302fe6bf03faed227f1e",
|
||||
"sha256:479707fe14d9ec9a0757618b7a100a0ae4c4e236fac5b7f80ca68028141a1a72"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==8.1.2"
|
||||
},
|
||||
"flask": {
|
||||
"hashes": [
|
||||
"sha256:8a4cf32d904cf5621db9f0c9fbcd7efabf3003f22a04e4d0ce790c7137ec5264",
|
||||
"sha256:a8c9bd3e558ec99646d177a9739c41df1ded0629480b4c8d2975412f3c9519c8"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"importlib-metadata": {
|
||||
"hashes": [
|
||||
"sha256:1208431ca90a8cca1a6b8af391bb53c1a2db74e5d1cef6ddced95d4b2062edc6",
|
||||
"sha256:ea4c597ebf37142f827b8f39299579e31685c31d3a438b59f469406afd0f2539"
|
||||
],
|
||||
"markers": "python_version < '3.10'",
|
||||
"version": "==4.11.3"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"hashes": [
|
||||
"sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44",
|
||||
"sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.2"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:539835f51a74a69f41b848a9645dbdc35b4f20a3b601e2d9a7e22947b15ff119",
|
||||
"sha256:640bed4bb501cbd17194b3cace1dc2126f5b619cf068a726b98192a0fde74ae9"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==3.1.1"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003",
|
||||
"sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88",
|
||||
"sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5",
|
||||
"sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7",
|
||||
"sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a",
|
||||
"sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603",
|
||||
"sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1",
|
||||
"sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135",
|
||||
"sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247",
|
||||
"sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6",
|
||||
"sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601",
|
||||
"sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77",
|
||||
"sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02",
|
||||
"sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e",
|
||||
"sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63",
|
||||
"sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f",
|
||||
"sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980",
|
||||
"sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b",
|
||||
"sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812",
|
||||
"sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff",
|
||||
"sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96",
|
||||
"sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1",
|
||||
"sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925",
|
||||
"sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a",
|
||||
"sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6",
|
||||
"sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e",
|
||||
"sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f",
|
||||
"sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4",
|
||||
"sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f",
|
||||
"sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3",
|
||||
"sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c",
|
||||
"sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a",
|
||||
"sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417",
|
||||
"sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a",
|
||||
"sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a",
|
||||
"sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37",
|
||||
"sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452",
|
||||
"sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933",
|
||||
"sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a",
|
||||
"sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"werkzeug": {
|
||||
"hashes": [
|
||||
"sha256:3c5493ece8268fecdcdc9c0b112211acd006354723b280d643ec732b6d4063d6",
|
||||
"sha256:f8e89a20aeabbe8a893c24a461d3ee5dad2123b05cc6abd73ceed01d39c3ae74"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"zipp": {
|
||||
"hashes": [
|
||||
"sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad",
|
||||
"sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==3.8.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Flask==1.0.2
|
||||
@@ -12,7 +12,7 @@ const {
|
||||
|
||||
jest.setTimeout(4 * 60 * 1000);
|
||||
const buildUtilsUrl = '@canary';
|
||||
let builderUrl;
|
||||
let builderUrl: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
const builderPath = path.resolve(__dirname, '..');
|
||||
4
packages/python/test/tsconfig.json
vendored
Normal file
4
packages/python/test/tsconfig.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["*.test.ts"]
|
||||
}
|
||||
75
packages/python/test/unit.test.ts
vendored
Normal file
75
packages/python/test/unit.test.ts
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import { getSupportedPythonVersion } from '../src/version';
|
||||
|
||||
let warningMessages: string[];
|
||||
const originalConsoleWarn = console.warn;
|
||||
const realDateNow = Date.now.bind(global.Date);
|
||||
beforeEach(() => {
|
||||
warningMessages = [];
|
||||
console.warn = m => {
|
||||
warningMessages.push(m);
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
console.warn = originalConsoleWarn;
|
||||
global.Date.now = realDateNow;
|
||||
});
|
||||
|
||||
it('should only match supported versions, otherwise throw an error', async () => {
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '3.9' })
|
||||
).toHaveProperty('runtime', 'python3.9');
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '3.6' })
|
||||
).toHaveProperty('runtime', 'python3.6');
|
||||
});
|
||||
|
||||
it('should ignore minor version in vercel dev', async () => {
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '3.9', isDev: true })
|
||||
).toHaveProperty('runtime', 'python3');
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '3.6', isDev: true })
|
||||
).toHaveProperty('runtime', 'python3');
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '999', isDev: true })
|
||||
).toHaveProperty('runtime', 'python3');
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('should select latest version when no Piplock detected', async () => {
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: undefined })
|
||||
).toHaveProperty('runtime', 'python3.9');
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('should select latest version and warn when invalid Piplock detected', async () => {
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '999' })
|
||||
).toHaveProperty('runtime', 'python3.9');
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Warning: Python version "999" detected in Pipfile.lock is invalid and will be ignored. http://vercel.link/python-version',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should throw for discontinued versions', async () => {
|
||||
global.Date.now = () => new Date('2022-07-31').getTime();
|
||||
expect(() =>
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '3.6' })
|
||||
).toThrow(
|
||||
'Python version "3.6" detected in Pipfile.lock is discontinued and must be upgraded. This change is the result of a decision made by an upstream infrastructure provider (AWS).'
|
||||
);
|
||||
expect(warningMessages).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('should warn for deprecated versions, soon to be discontinued', async () => {
|
||||
global.Date.now = () => new Date('2021-07-01').getTime();
|
||||
|
||||
expect(
|
||||
getSupportedPythonVersion({ pipLockPythonVersion: '3.6' })
|
||||
).toHaveProperty('runtime', 'python3.6');
|
||||
expect(warningMessages).toStrictEqual([
|
||||
'Error: Python version "3.6" detected in Pipfile.lock is deprecated. Deployments created on or after 2022-07-18 will fail to build. This change is the result of a decision made by an upstream infrastructure provider (AWS). http://vercel.link/python-version',
|
||||
]);
|
||||
});
|
||||
@@ -11,8 +11,10 @@
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"outDir": "dist",
|
||||
"types": ["node"],
|
||||
"types": ["node", "jest"],
|
||||
"strict": true,
|
||||
"target": "es2018"
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ __vc_variables = dir(__vc_module)
|
||||
def format_headers(headers, decode=False):
|
||||
keyToList = {}
|
||||
for key, value in headers.items():
|
||||
if decode:
|
||||
if decode and 'decode' in dir(key) and 'decode' in dir(value):
|
||||
key = key.decode()
|
||||
value = value.decode()
|
||||
if key not in keyToList:
|
||||
@@ -102,7 +102,7 @@ elif 'app' in __vc_variables:
|
||||
if isinstance(s, str):
|
||||
s = s.encode(charset)
|
||||
return s.decode("latin1", errors)
|
||||
|
||||
|
||||
def vc_handler(event, context):
|
||||
payload = json.loads(event['body'])
|
||||
|
||||
|
||||
1
packages/redwood/.gitignore
vendored
Normal file
1
packages/redwood/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!test/cache-fixtures/**
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/redwood",
|
||||
"version": "0.7.1-canary.2",
|
||||
"version": "0.8.0",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -15,17 +15,18 @@
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"test-integration-once": "jest --env node --verbose --runInBand --bail test/test.js",
|
||||
"test-unit": "jest --env node --verbose --bail test/prepare-cache.test.js",
|
||||
"prepublishOnly": "node build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/nft": "0.18.1",
|
||||
"@vercel/routing-utils": "1.13.1",
|
||||
"@vercel/routing-utils": "1.13.2",
|
||||
"semver": "6.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/aws-lambda": "8.10.19",
|
||||
"@types/node": "*",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "2.15.2-canary.2"
|
||||
"@vercel/build-utils": "2.16.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +316,6 @@ function hasScript(scriptName: string, pkg: PackageJson | null) {
|
||||
return typeof scripts[scriptName] === 'string';
|
||||
}
|
||||
|
||||
export const prepareCache: PrepareCache = async ({ workPath }) => {
|
||||
const cache = await glob('**/node_modules/**', workPath);
|
||||
return cache;
|
||||
export const prepareCache: PrepareCache = ({ repoRootPath, workPath }) => {
|
||||
return glob('**/node_modules/**', repoRootPath || workPath);
|
||||
};
|
||||
|
||||
0
packages/redwood/test/cache-fixtures/foo/node_modules/file
generated
vendored
Normal file
0
packages/redwood/test/cache-fixtures/foo/node_modules/file
generated
vendored
Normal file
0
packages/redwood/test/cache-fixtures/index.js
Normal file
0
packages/redwood/test/cache-fixtures/index.js
Normal file
0
packages/redwood/test/cache-fixtures/node_modules/file
generated
vendored
Normal file
0
packages/redwood/test/cache-fixtures/node_modules/file
generated
vendored
Normal file
28
packages/redwood/test/prepare-cache.test.js
vendored
Normal file
28
packages/redwood/test/prepare-cache.test.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
const path = require('path');
|
||||
const { prepareCache } = require('../dist');
|
||||
|
||||
describe('prepareCache()', () => {
|
||||
test('should cache **/node_modules/**', async () => {
|
||||
const files = await prepareCache({
|
||||
repoRootPath: path.resolve(__dirname, './cache-fixtures/'),
|
||||
});
|
||||
|
||||
expect(files['foo/node_modules/file']).toBeDefined();
|
||||
expect(files['node_modules/file']).toBeDefined();
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should ignore root modules', async () => {
|
||||
const files = await prepareCache({
|
||||
workPath: path.resolve(__dirname, './cache-fixtures/foo/'),
|
||||
});
|
||||
|
||||
expect(files['node_modules/file']).toBeDefined();
|
||||
expect(
|
||||
files['node_modules/file'].fsPath.includes(
|
||||
'cache-fixtures/foo/node_modules/file'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/routing-utils",
|
||||
"version": "1.13.1",
|
||||
"version": "1.13.2",
|
||||
"description": "Vercel routing utilities",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@vercel/ruby",
|
||||
"author": "Nathan Cahill <nathan@nathancahill.com>",
|
||||
"version": "1.3.3-canary.2",
|
||||
"version": "1.3.3",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
|
||||
@@ -22,7 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "8.0.0",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "2.0.4",
|
||||
"fs-extra": "^7.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/static-build",
|
||||
"version": "0.23.2-canary.2",
|
||||
"version": "0.24.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/build-step",
|
||||
@@ -35,10 +35,10 @@
|
||||
"@types/ms": "0.7.31",
|
||||
"@types/node-fetch": "2.5.4",
|
||||
"@types/promise-timeout": "1.3.0",
|
||||
"@vercel/build-utils": "2.15.2-canary.2",
|
||||
"@vercel/frameworks": "0.7.1",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@vercel/frameworks": "0.8.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@vercel/routing-utils": "1.13.1",
|
||||
"@vercel/routing-utils": "1.13.2",
|
||||
"get-port": "5.0.0",
|
||||
"is-port-reachable": "2.0.1",
|
||||
"ms": "2.1.2",
|
||||
|
||||
@@ -451,7 +451,7 @@ export const build: BuildV2 = async ({
|
||||
const opts = {
|
||||
env: {
|
||||
...process.env,
|
||||
// See more: https://git.io/JtDwx
|
||||
// See more: https://github.com/rubygems/rubygems/blob/a82d04856deba58be6b90f681a5e42a7c0f2baa7/bundler/lib/bundler/man/bundle-config.1.ronn
|
||||
BUNDLE_BIN: 'vendor/bin',
|
||||
BUNDLE_CACHE_PATH: 'vendor/cache',
|
||||
BUNDLE_PATH: 'vendor/bundle',
|
||||
@@ -466,7 +466,7 @@ export const build: BuildV2 = async ({
|
||||
isBundleInstall = true;
|
||||
}
|
||||
if (existsSync(requirementsPath)) {
|
||||
debug('Detected requirements.txt');
|
||||
debug('Detected requirements.txt');
|
||||
printInstall();
|
||||
await runPipInstall(
|
||||
workPath,
|
||||
@@ -754,18 +754,28 @@ export const build: BuildV2 = async ({
|
||||
|
||||
export const prepareCache: PrepareCache = async ({
|
||||
entrypoint,
|
||||
repoRootPath,
|
||||
workPath,
|
||||
config,
|
||||
}) => {
|
||||
const cacheFiles: Files = {};
|
||||
|
||||
// Build Output API v3 cache files
|
||||
const configV3 = await BuildOutputV3.readConfig(workPath);
|
||||
if (configV3?.cache && Array.isArray(configV3.cache)) {
|
||||
for (const cacheGlob of configV3.cache) {
|
||||
Object.assign(cacheFiles, await glob(cacheGlob, workPath));
|
||||
}
|
||||
return cacheFiles;
|
||||
}
|
||||
|
||||
// File System API v1 cache files
|
||||
const buildConfig = await BuildOutputV1.readBuildOutputConfig<BuildConfig>({
|
||||
const buildConfigV1 = await BuildOutputV1.readBuildOutputConfig<BuildConfig>({
|
||||
workPath,
|
||||
configFileName: 'build.json',
|
||||
});
|
||||
if (buildConfig?.cache && Array.isArray(buildConfig.cache)) {
|
||||
for (const cacheGlob of buildConfig.cache) {
|
||||
if (buildConfigV1?.cache && Array.isArray(buildConfigV1.cache)) {
|
||||
for (const cacheGlob of buildConfigV1.cache) {
|
||||
Object.assign(cacheFiles, await glob(cacheGlob, workPath));
|
||||
}
|
||||
return cacheFiles;
|
||||
@@ -774,7 +784,7 @@ export const prepareCache: PrepareCache = async ({
|
||||
// Default cache files
|
||||
Object.assign(
|
||||
cacheFiles,
|
||||
await glob('{.shadow-cljs,node_modules}/**', workPath)
|
||||
await glob('**/{.shadow-cljs,node_modules}/**', repoRootPath || workPath)
|
||||
);
|
||||
|
||||
// Framework cache files
|
||||
|
||||
@@ -21,3 +21,16 @@ export async function getBuildOutputDirectory(
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export async function readConfig(
|
||||
path: string
|
||||
): Promise<{ cache?: string[] } | undefined> {
|
||||
try {
|
||||
const outputDir = join(path, BUILD_OUTPUT_DIR);
|
||||
const configPath = join(outputDir, 'config.json');
|
||||
return JSON.parse(await fs.readFile(configPath, 'utf8'));
|
||||
} catch (err: any) {
|
||||
if (err.code !== 'ENOENT') throw err;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
1
packages/static-build/test/cache-fixtures/build-output-api-v3/.gitignore
vendored
Normal file
1
packages/static-build/test/cache-fixtures/build-output-api-v3/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!.vercel
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 3,
|
||||
"cache": ["some-dir/**", "another.txt"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
another
|
||||
@@ -0,0 +1 @@
|
||||
File that shouldn't be cached
|
||||
@@ -0,0 +1 @@
|
||||
one
|
||||
@@ -0,0 +1 @@
|
||||
two
|
||||
0
packages/static-build/test/cache-fixtures/root-path/foo/node_modules/file
generated
vendored
Normal file
0
packages/static-build/test/cache-fixtures/root-path/foo/node_modules/file
generated
vendored
Normal file
0
packages/static-build/test/cache-fixtures/root-path/node_modules/file
generated
vendored
Normal file
0
packages/static-build/test/cache-fixtures/root-path/node_modules/file
generated
vendored
Normal file
@@ -1,4 +1,4 @@
|
||||
_Psst — looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)_
|
||||
_Psst — looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)_
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import Profile from '../routes/profile';
|
||||
|
||||
export default class App extends Component {
|
||||
/** Gets fired when the route changes.
|
||||
* @param {Object} event "change" event from [preact-router](http://git.io/preact-router)
|
||||
* @param {Object} event "change" event from https://github.com/preactjs/preact-router
|
||||
* @param {string} event.url The newly routed URL
|
||||
*/
|
||||
handleRoute = e => {
|
||||
|
||||
@@ -15,7 +15,7 @@ cache:
|
||||
|
||||
env:
|
||||
global:
|
||||
# See https://git.io/vdao3 for details.
|
||||
# See https://github.com/ember-cli/ember-cli/blob/master/docs/build-concurrency.md
|
||||
- JOBS=1
|
||||
|
||||
script:
|
||||
|
||||
46
packages/static-build/test/prepare-cache.test.ts
vendored
46
packages/static-build/test/prepare-cache.test.ts
vendored
@@ -1,3 +1,4 @@
|
||||
import { FileFsRef } from '@vercel/build-utils';
|
||||
import path from 'path';
|
||||
import { prepareCache } from '../src';
|
||||
|
||||
@@ -15,6 +16,37 @@ describe('prepareCache()', () => {
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should cache **/node_modules/**', async () => {
|
||||
const files = await prepareCache({
|
||||
config: { zeroConfig: true },
|
||||
repoRootPath: path.resolve(__dirname, './cache-fixtures/root-path'),
|
||||
workPath: path.resolve(__dirname, './cache-fixtures/root-path/foo'),
|
||||
entrypoint: 'index.js',
|
||||
files: {},
|
||||
});
|
||||
|
||||
expect(files['foo/node_modules/file']).toBeDefined();
|
||||
expect(files['node_modules/file']).toBeDefined();
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should ignore root modules', async () => {
|
||||
const files = await prepareCache({
|
||||
config: { zeroConfig: true },
|
||||
workPath: path.resolve(__dirname, './cache-fixtures/root-path/foo'),
|
||||
entrypoint: 'index.js',
|
||||
files: {},
|
||||
});
|
||||
|
||||
expect(files['node_modules/file']).toBeDefined();
|
||||
expect(
|
||||
(files['node_modules/file'] as FileFsRef).fsPath.includes(
|
||||
'cache-fixtures/root-path/foo/node_modules/file'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(files['index.js']).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should cache index.js and other/file2.js as defined in .vercel_build_output/config/build.json', async () => {
|
||||
const files = await prepareCache({
|
||||
config: { zeroConfig: true },
|
||||
@@ -59,4 +91,18 @@ describe('prepareCache()', () => {
|
||||
expect(files['_config.yml']).toBeUndefined();
|
||||
expect(files['_posts/hello.markdown']).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should cache Build Output API v3 "cache" assets from `config.json` file', async () => {
|
||||
const files = await prepareCache({
|
||||
config: {},
|
||||
workPath: path.resolve(__dirname, './cache-fixtures/build-output-api-v3'),
|
||||
entrypoint: 'package.json',
|
||||
files: {},
|
||||
});
|
||||
expect(Object.keys(files).sort()).toStrictEqual([
|
||||
'another.txt',
|
||||
'some-dir/one.txt',
|
||||
'some-dir/two.txt',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/static-config",
|
||||
"version": "1.0.0-canary.0",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"repository": {
|
||||
@@ -22,7 +22,7 @@
|
||||
"ts-morph": "12.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.0.2",
|
||||
"@types/jest": "27.4.1",
|
||||
"@types/node": "*"
|
||||
},
|
||||
"jest": {
|
||||
|
||||
Reference in New Issue
Block a user