Compare commits

...

11 Commits

Author SHA1 Message Date
Steven
a400b9b29d Publish Stable
- @vercel/build-utils@2.16.0
 - vercel@24.2.0
 - @vercel/client@11.0.0
 - @vercel/frameworks@0.8.0
 - @vercel/go@1.4.0
 - @vercel/node-bridge@2.2.1
 - @vercel/node@1.15.0
 - @vercel/python@2.3.0
 - @vercel/redwood@0.8.0
 - @vercel/routing-utils@1.13.2
 - @vercel/ruby@1.3.3
 - @vercel/static-build@0.24.0
 - @vercel/static-config@1.0.0
2022-04-29 14:11:32 -04:00
Steven
b549c37149 [build-utils][static-build] Replace 00a0 with space (#7732) 2022-04-28 22:25:24 -04:00
Nathan Rajlich
30d5e64291 Publish Canary
- @vercel/build-utils@2.15.2-canary.6
 - vercel@24.1.1-canary.8
 - @vercel/client@10.4.2-canary.7
 - @vercel/go@1.3.3-canary.6
 - @vercel/node@1.14.2-canary.7
 - @vercel/python@2.2.3-canary.6
 - @vercel/redwood@0.7.1-canary.6
 - @vercel/ruby@1.3.3-canary.6
 - @vercel/static-build@0.23.2-canary.6
2022-04-28 17:50:59 -07:00
Nathan Rajlich
47c2c361d2 [build-utils] Update "yazl" dependency (#7734)
The older version of "yazl" was using `new Buffer()` which causes
deprecation warnings to be printed. The latest version avoids that.
2022-04-28 17:47:10 -07:00
Nathan Rajlich
438576fc7c Publish Canary
- @vercel/build-utils@2.15.2-canary.5
 - vercel@24.1.1-canary.7
 - @vercel/client@10.4.2-canary.6
 - @vercel/frameworks@0.7.2-canary.1
 - @vercel/go@1.3.3-canary.5
 - @vercel/node@1.14.2-canary.6
 - @vercel/python@2.2.3-canary.5
 - @vercel/redwood@0.7.1-canary.5
 - @vercel/ruby@1.3.3-canary.5
 - @vercel/static-build@0.23.2-canary.5
 - @vercel/static-config@1.0.0-canary.1
2022-04-28 11:53:39 -07:00
Steven
b30343ef7b [tests] Bump dependencies for jest/eslint/prettier/turbo/etc (#7727) 2022-04-28 14:52:46 -04:00
Ethan Arrowood
2dc0dfa572 [node][static-build][redwood] Add root path pattern to prepareCache() (#7710) 2022-04-27 21:17:44 -07:00
Steven
9ee54b3dd6 [static-build] Resolve git.io links (#7722)
https://github.blog/changelog/2022-04-25-git-io-deprecation/
2022-04-26 21:57:12 -04:00
Steven
9d67e0bc06 [python] Add discontinue date for Python 3.6 (#7709)
This PR does a few things:
- Changes the existing warning message for Python 3.6 to print a discontinue date
- Will automatically fail new Python 3.6 deployments created after that date
- Consolidates logic to make Python version selection work in a similar manner to Node.js version selection
- Changes tests from JS to TS
2022-04-26 15:49:19 -04:00
Steven
466135cf84 Publish Canary
- @vercel/build-utils@2.15.2-canary.4
 - vercel@24.1.1-canary.6
 - @vercel/client@10.4.2-canary.5
 - @vercel/go@1.3.3-canary.4
 - @vercel/node@1.14.2-canary.5
 - @vercel/python@2.2.3-canary.4
 - @vercel/redwood@0.7.1-canary.4
 - @vercel/ruby@1.3.3-canary.4
 - @vercel/static-build@0.23.2-canary.4
2022-04-25 12:49:34 -04:00
Steven
eab2e229dc [build-utils] Add warning for experimental Node.js (#7717) 2022-04-25 12:49:04 -04:00
50 changed files with 1451 additions and 1378 deletions

View File

@@ -15,7 +15,7 @@ cache:
env: env:
global: global:
# See https://git.io/vdao3 for details. # See https://github.com/ember-cli/ember-cli/blob/master/docs/build-concurrency.md
- JOBS=1 - JOBS=1
script: script:

View File

@@ -15,23 +15,23 @@
"lerna": "3.16.4" "lerna": "3.16.4"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "4.28.0", "@typescript-eslint/eslint-plugin": "5.21.0",
"@typescript-eslint/parser": "4.28.0", "@typescript-eslint/parser": "5.21.0",
"async-retry": "1.2.3", "async-retry": "1.2.3",
"buffer-replace": "1.0.0", "buffer-replace": "1.0.0",
"eslint": "7.29.0", "eslint": "8.14.0",
"eslint-config-prettier": "8.3.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "24.3.6", "eslint-plugin-jest": "26.1.5",
"husky": "6.0.0", "husky": "7.0.4",
"jest": "27.3.1", "jest": "28.0.2",
"json5": "2.1.1", "json5": "2.1.1",
"lint-staged": "9.2.5", "lint-staged": "9.2.5",
"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.6.2",
"ts-eager": "2.0.2", "ts-eager": "2.0.2",
"ts-jest": "27.0.4", "ts-jest": "28.0.0-next.1",
"turbo": "1.2.2" "turbo": "1.2.5"
}, },
"scripts": { "scripts": {
"lerna": "lerna", "lerna": "lerna",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/build-utils", "name": "@vercel/build-utils",
"version": "2.15.2-canary.3", "version": "2.16.0",
"license": "MIT", "license": "MIT",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.js", "types": "./dist/index.d.js",
@@ -23,14 +23,14 @@
"@types/end-of-stream": "^1.4.0", "@types/end-of-stream": "^1.4.0",
"@types/fs-extra": "9.0.13", "@types/fs-extra": "9.0.13",
"@types/glob": "^7.1.1", "@types/glob": "^7.1.1",
"@types/jest": "27.0.1", "@types/jest": "27.4.1",
"@types/js-yaml": "3.12.1", "@types/js-yaml": "3.12.1",
"@types/ms": "0.7.31", "@types/ms": "0.7.31",
"@types/multistream": "2.1.1", "@types/multistream": "2.1.1",
"@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.2",
"@vercel/frameworks": "0.7.2-canary.0", "@vercel/frameworks": "0.8.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",
@@ -47,6 +47,6 @@
"node-fetch": "2.6.1", "node-fetch": "2.6.1",
"semver": "6.1.1", "semver": "6.1.1",
"typescript": "4.3.4", "typescript": "4.3.4",
"yazl": "2.4.3" "yazl": "2.5.1"
} }
} }

View File

@@ -44,10 +44,6 @@ export async function getSupportedNodeVersion(
): Promise<NodeVersion> { ): Promise<NodeVersion> {
let selection: NodeVersion = getLatestNodeVersion(); let selection: NodeVersion = getLatestNodeVersion();
if (process.env.ENABLE_EXPERIMENTAL_NODE16 === '1') {
return { major: 16, range: '16.x', runtime: 'nodejs16.x' };
}
if (engineRange) { if (engineRange) {
const found = const found =
validRange(engineRange) && validRange(engineRange) &&

View File

@@ -222,6 +222,12 @@ export async function getNodeVersion(
const latest = getLatestNodeVersion(); const latest = getLatestNodeVersion();
return { ...latest, runtime: 'nodejs' }; 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); const { packageJson } = await scanParentDirs(destPath, true);
let { nodeVersion } = config; let { nodeVersion } = config;
let isAuto = true; let isAuto = true;
@@ -544,7 +550,7 @@ export async function runPipInstall(
meta?: Meta meta?: Meta
) { ) {
if (meta && meta.isDev) { if (meta && meta.isDev) {
debug('Skipping dependency installation because dev mode is enabled'); debug('Skipping dependency installation because dev mode is enabled');
return; return;
} }

View File

@@ -282,7 +282,9 @@ it('should select nodejs16.x with ENABLE_EXPERIMENTAL_NODE16', async () => {
const result = await getNodeVersion('/tmp', undefined, {}, {}); const result = await getNodeVersion('/tmp', undefined, {}, {});
delete process.env.ENABLE_EXPERIMENTAL_NODE16; delete process.env.ENABLE_EXPERIMENTAL_NODE16;
expect(result).toEqual({ major: 16, range: '16.x', runtime: 'nodejs16.x' }); expect(result).toEqual({ major: 16, range: '16.x', runtime: 'nodejs16.x' });
expect(warningMessages).toStrictEqual([]); expect(warningMessages).toStrictEqual([
'Warning: Using experimental Node.js 16.x due to ENABLE_EXPERIMENTAL_NODE16=1',
]);
}); });
it('should get latest node version', async () => { it('should get latest node version', async () => {

View File

@@ -1,6 +1,6 @@
{ {
"name": "vercel", "name": "vercel",
"version": "24.1.1-canary.5", "version": "24.2.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.15.2-canary.3", "@vercel/build-utils": "2.16.0",
"@vercel/go": "1.3.3-canary.3", "@vercel/go": "1.4.0",
"@vercel/node": "1.14.2-canary.4", "@vercel/node": "1.15.0",
"@vercel/python": "2.2.3-canary.3", "@vercel/python": "2.3.0",
"@vercel/ruby": "1.3.3-canary.3", "@vercel/ruby": "1.3.3",
"update-notifier": "4.1.0" "update-notifier": "4.1.0"
}, },
"devDependencies": { "devDependencies": {
@@ -69,7 +69,7 @@
"@types/glob": "7.1.1", "@types/glob": "7.1.1",
"@types/http-proxy": "1.16.2", "@types/http-proxy": "1.16.2",
"@types/inquirer": "7.3.1", "@types/inquirer": "7.3.1",
"@types/jest": "27.0.1", "@types/jest": "27.4.1",
"@types/jest-expect-message": "1.0.3", "@types/jest-expect-message": "1.0.3",
"@types/load-json-file": "2.0.7", "@types/load-json-file": "2.0.7",
"@types/mime-types": "2.1.0", "@types/mime-types": "2.1.0",
@@ -90,9 +90,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.4.2-canary.4", "@vercel/client": "11.0.0",
"@vercel/fetch-retry": "5.0.3", "@vercel/fetch-retry": "5.0.3",
"@vercel/frameworks": "0.7.2-canary.0", "@vercel/frameworks": "0.8.0",
"@vercel/ncc": "0.24.0", "@vercel/ncc": "0.24.0",
"@zeit/fun": "0.11.2", "@zeit/fun": "0.11.2",
"@zeit/source-map-support": "0.6.2", "@zeit/source-map-support": "0.6.2",

View File

@@ -15,7 +15,7 @@ cache:
env: env:
global: global:
# See https://git.io/vdao3 for details. # See https://github.com/ember-cli/ember-cli/blob/master/docs/build-concurrency.md
- JOBS=1 - JOBS=1
script: script:

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/client", "name": "@vercel/client",
"version": "10.4.2-canary.4", "version": "11.0.0",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"homepage": "https://vercel.com", "homepage": "https://vercel.com",
@@ -24,7 +24,7 @@
"devDependencies": { "devDependencies": {
"@types/async-retry": "1.4.1", "@types/async-retry": "1.4.1",
"@types/fs-extra": "7.0.0", "@types/fs-extra": "7.0.0",
"@types/jest": "27.0.1", "@types/jest": "27.4.1",
"@types/minimatch": "3.0.5", "@types/minimatch": "3.0.5",
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
"@types/node": "12.0.4", "@types/node": "12.0.4",
@@ -41,7 +41,7 @@
] ]
}, },
"dependencies": { "dependencies": {
"@vercel/build-utils": "2.15.2-canary.3", "@vercel/build-utils": "2.16.0",
"@zeit/fetch": "5.2.0", "@zeit/fetch": "5.2.0",
"async-retry": "1.2.3", "async-retry": "1.2.3",
"async-sema": "3.0.0", "async-sema": "3.0.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/frameworks", "name": "@vercel/frameworks",
"version": "0.7.2-canary.0", "version": "0.8.0",
"main": "./dist/frameworks.js", "main": "./dist/frameworks.js",
"types": "./dist/frameworks.d.ts", "types": "./dist/frameworks.d.ts",
"files": [ "files": [
@@ -16,11 +16,11 @@
"js-yaml": "3.13.1" "js-yaml": "3.13.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "27.0.1", "@types/jest": "27.4.1",
"@types/js-yaml": "3.12.1", "@types/js-yaml": "3.12.1",
"@types/node": "12.0.4", "@types/node": "12.0.4",
"@types/node-fetch": "2.5.8", "@types/node-fetch": "2.5.8",
"@vercel/routing-utils": "1.13.1", "@vercel/routing-utils": "1.13.2",
"ajv": "6.12.2", "ajv": "6.12.2",
"typescript": "4.3.4" "typescript": "4.3.4"
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/go", "name": "@vercel/go",
"version": "1.3.3-canary.3", "version": "1.4.0",
"license": "MIT", "license": "MIT",
"main": "./dist/index", "main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go", "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -24,7 +24,7 @@
"@types/fs-extra": "^5.0.5", "@types/fs-extra": "^5.0.5",
"@types/node-fetch": "^2.3.0", "@types/node-fetch": "^2.3.0",
"@types/tar": "^4.0.0", "@types/tar": "^4.0.0",
"@vercel/build-utils": "2.15.2-canary.3", "@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0", "@vercel/ncc": "0.24.0",
"async-retry": "1.3.1", "async-retry": "1.3.1",
"execa": "^1.0.0", "execa": "^1.0.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/node-bridge", "name": "@vercel/node-bridge",
"version": "2.2.1-canary.0", "version": "2.2.1",
"license": "MIT", "license": "MIT",
"main": "./index.js", "main": "./index.js",
"repository": { "repository": {

View File

@@ -1,3 +1,4 @@
/dist /dist
/test/fixtures/**/types.d.ts /test/fixtures/**/types.d.ts
/test/fixtures/11-symlinks/symlink /test/fixtures/11-symlinks/symlink
!test/cache-fixtures/**

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/node", "name": "@vercel/node",
"version": "1.14.2-canary.4", "version": "1.15.0",
"license": "MIT", "license": "MIT",
"main": "./dist/index", "main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js", "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -12,6 +12,7 @@
"scripts": { "scripts": {
"build": "node build", "build": "node build",
"test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.js", "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" "prepublishOnly": "node build"
}, },
"files": [ "files": [
@@ -19,7 +20,7 @@
], ],
"dependencies": { "dependencies": {
"@types/node": "*", "@types/node": "*",
"@vercel/node-bridge": "2.2.1-canary.0", "@vercel/node-bridge": "2.2.1",
"ts-node": "8.9.1", "ts-node": "8.9.1",
"typescript": "4.3.4" "typescript": "4.3.4"
}, },
@@ -32,7 +33,7 @@
"@types/cookie": "0.3.3", "@types/cookie": "0.3.3",
"@types/etag": "1.8.0", "@types/etag": "1.8.0",
"@types/test-listen": "1.1.0", "@types/test-listen": "1.1.0",
"@vercel/build-utils": "2.15.2-canary.3", "@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0", "@vercel/ncc": "0.24.0",
"@vercel/nft": "0.18.1", "@vercel/nft": "0.18.1",
"content-type": "1.0.4", "content-type": "1.0.4",

View File

@@ -380,9 +380,8 @@ export const build: BuildV3 = async ({
return { output: lambda }; return { output: lambda };
}; };
export const prepareCache: PrepareCache = async ({ workPath }) => { export const prepareCache: PrepareCache = ({ repoRootPath, workPath }) => {
const cache = await glob('node_modules/**', workPath); return glob('**/node_modules/**', repoRootPath || workPath);
return cache;
}; };
export const startDevServer: StartDevServer = async opts => { export const startDevServer: StartDevServer = async opts => {

View File

0
packages/node/test/cache-fixtures/node_modules/file generated vendored Normal file
View File

View 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();
});
});

View File

@@ -0,0 +1,5 @@
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/python", "name": "@vercel/python",
"version": "2.2.3-canary.3", "version": "2.3.0",
"main": "./dist/index.js", "main": "./dist/index.js",
"license": "MIT", "license": "MIT",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python", "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -15,12 +15,14 @@
}, },
"scripts": { "scripts": {
"build": "node build", "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" "prepublishOnly": "node build"
}, },
"devDependencies": { "devDependencies": {
"@types/execa": "^0.9.0", "@types/execa": "^0.9.0",
"@vercel/build-utils": "2.15.2-canary.3", "@types/jest": "27.4.1",
"@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0", "@vercel/ncc": "0.24.0",
"execa": "^1.0.0", "execa": "^1.0.0",
"typescript": "4.3.4" "typescript": "4.3.4"

View File

@@ -16,6 +16,7 @@ import {
NowBuildError, NowBuildError,
} from '@vercel/build-utils'; } from '@vercel/build-utils';
import { installRequirement, installRequirementsFile } from './install'; import { installRequirement, installRequirementsFile } from './install';
import { getLatestPythonVersion, getSupportedPythonVersion } from './version';
async function pipenvConvert(cmd: string, srcDir: string) { async function pipenvConvert(cmd: string, srcDir: string) {
debug('Running pipfile2req...'); debug('Running pipfile2req...');
@@ -59,9 +60,7 @@ export const build = async ({
meta = {}, meta = {},
config, config,
}: BuildOptions) => { }: BuildOptions) => {
let pipPath = meta.isDev ? 'pip3' : 'pip3.9'; let pythonVersion = getLatestPythonVersion(meta);
let pythonPath = meta.isDev ? 'python3' : 'python3.9';
let pythonRuntime = meta.isDev ? 'python3' : 'python3.9';
workPath = await downloadFilesInWorkPath({ workPath = await downloadFilesInWorkPath({
workPath, workPath,
@@ -91,8 +90,8 @@ export const build = async ({
console.log('Installing required dependencies...'); console.log('Installing required dependencies...');
await installRequirement({ await installRequirement({
pythonPath, pythonPath: pythonVersion.pythonPath,
pipPath, pipPath: pythonVersion.pipPath,
dependency: 'werkzeug', dependency: 'werkzeug',
version: '1.0.1', version: '1.0.1',
workPath, workPath,
@@ -114,25 +113,10 @@ export const build = async ({
try { try {
const json = await readFile(join(pipfileLockDir, 'Pipfile.lock'), 'utf8'); const json = await readFile(join(pipfileLockDir, 'Pipfile.lock'), 'utf8');
const obj = JSON.parse(json); const obj = JSON.parse(json);
const version = obj?._meta?.requires?.python_version; pythonVersion = getSupportedPythonVersion({
if (!meta.isDev) { isDev: meta.isDev,
if (version === '3.6') { pipLockPythonVersion: obj?._meta?.requires?.python_version,
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`
);
}
}
} catch (err) { } catch (err) {
throw new NowBuildError({ throw new NowBuildError({
code: 'INVALID_PIPFILE_LOCK', code: 'INVALID_PIPFILE_LOCK',
@@ -146,8 +130,8 @@ export const build = async ({
// it into a separate folder. // it into a separate folder.
const tempDir = await getWriteableDirectory(); const tempDir = await getWriteableDirectory();
await installRequirement({ await installRequirement({
pythonPath, pythonPath: pythonVersion.pythonPath,
pipPath, pipPath: pythonVersion.pipPath,
dependency: 'pipfile-requirements', dependency: 'pipfile-requirements',
version: '0.3.0', version: '0.3.0',
workPath: tempDir, workPath: tempDir,
@@ -169,8 +153,8 @@ export const build = async ({
debug('Found local "requirements.txt"'); debug('Found local "requirements.txt"');
const requirementsTxtPath = fsFiles[requirementsTxt].fsPath; const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
await installRequirementsFile({ await installRequirementsFile({
pythonPath, pythonPath: pythonVersion.pythonPath,
pipPath, pipPath: pythonVersion.pipPath,
filePath: requirementsTxtPath, filePath: requirementsTxtPath,
workPath, workPath,
meta, meta,
@@ -179,8 +163,8 @@ export const build = async ({
debug('Found global "requirements.txt"'); debug('Found global "requirements.txt"');
const requirementsTxtPath = fsFiles['requirements.txt'].fsPath; const requirementsTxtPath = fsFiles['requirements.txt'].fsPath;
await installRequirementsFile({ await installRequirementsFile({
pythonPath, pythonPath: pythonVersion.pythonPath,
pipPath, pipPath: pythonVersion.pipPath,
filePath: requirementsTxtPath, filePath: requirementsTxtPath,
workPath, workPath,
meta, meta,
@@ -205,9 +189,6 @@ export const build = async ({
await writeFile(join(workPath, `${handlerPyFilename}.py`), handlerPyContents); 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 = { const globOptions: GlobOptions = {
cwd: workPath, cwd: workPath,
ignore: ignore:
@@ -219,7 +200,7 @@ export const build = async ({
const lambda = await createLambda({ const lambda = await createLambda({
files: await glob('**', globOptions), files: await glob('**', globOptions),
handler: `${handlerPyFilename}.vc_handler`, handler: `${handlerPyFilename}.vc_handler`,
runtime, runtime: pythonVersion.runtime,
environment: {}, environment: {},
}); });

View 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;
}

View File

@@ -5,7 +5,7 @@
{ {
"path": "/", "path": "/",
"mustContain": "wsgi:RANDOMNESS_PLACEHOLDER", "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"
} }
] ]
} }

View File

@@ -8,7 +8,7 @@
{ {
"path": "/", "path": "/",
"mustContain": "RANDOMNESS_PLACEHOLDER:env", "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"
} }
] ]
} }

View File

@@ -5,7 +5,7 @@
{ {
"path": "/", "path": "/",
"mustContain": "pip:RANDOMNESS_PLACEHOLDER", "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."
} }
] ]
} }

View File

@@ -12,7 +12,7 @@ const {
jest.setTimeout(4 * 60 * 1000); jest.setTimeout(4 * 60 * 1000);
const buildUtilsUrl = '@canary'; const buildUtilsUrl = '@canary';
let builderUrl; let builderUrl: string;
beforeAll(async () => { beforeAll(async () => {
const builderPath = path.resolve(__dirname, '..'); const builderPath = path.resolve(__dirname, '..');

4
packages/python/test/tsconfig.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["*.test.ts"]
}

75
packages/python/test/unit.test.ts vendored Normal file
View 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',
]);
});

View File

@@ -11,8 +11,10 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"outDir": "dist", "outDir": "dist",
"types": ["node"], "types": ["node", "jest"],
"strict": true, "strict": true,
"target": "es2018" "target": "es2018"
} },
"include": ["src/**/*"],
"exclude": ["node_modules"]
} }

1
packages/redwood/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
!test/cache-fixtures/**

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/redwood", "name": "@vercel/redwood",
"version": "0.7.1-canary.3", "version": "0.8.0",
"main": "./dist/index.js", "main": "./dist/index.js",
"license": "MIT", "license": "MIT",
"homepage": "https://vercel.com/docs", "homepage": "https://vercel.com/docs",
@@ -15,17 +15,18 @@
"scripts": { "scripts": {
"build": "node build.js", "build": "node build.js",
"test-integration-once": "jest --env node --verbose --runInBand --bail test/test.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" "prepublishOnly": "node build.js"
}, },
"dependencies": { "dependencies": {
"@vercel/nft": "0.18.1", "@vercel/nft": "0.18.1",
"@vercel/routing-utils": "1.13.1", "@vercel/routing-utils": "1.13.2",
"semver": "6.1.1" "semver": "6.1.1"
}, },
"devDependencies": { "devDependencies": {
"@types/aws-lambda": "8.10.19", "@types/aws-lambda": "8.10.19",
"@types/node": "*", "@types/node": "*",
"@types/semver": "6.0.0", "@types/semver": "6.0.0",
"@vercel/build-utils": "2.15.2-canary.3" "@vercel/build-utils": "2.16.0"
} }
} }

View File

@@ -316,7 +316,6 @@ function hasScript(scriptName: string, pkg: PackageJson | null) {
return typeof scripts[scriptName] === 'string'; return typeof scripts[scriptName] === 'string';
} }
export const prepareCache: PrepareCache = async ({ workPath }) => { export const prepareCache: PrepareCache = ({ repoRootPath, workPath }) => {
const cache = await glob('**/node_modules/**', workPath); return glob('**/node_modules/**', repoRootPath || workPath);
return cache;
}; };

View File

View File

View 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();
});
});

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/routing-utils", "name": "@vercel/routing-utils",
"version": "1.13.1", "version": "1.13.2",
"description": "Vercel routing utilities", "description": "Vercel routing utilities",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View File

@@ -1,7 +1,7 @@
{ {
"name": "@vercel/ruby", "name": "@vercel/ruby",
"author": "Nathan Cahill <nathan@nathancahill.com>", "author": "Nathan Cahill <nathan@nathancahill.com>",
"version": "1.3.3-canary.3", "version": "1.3.3",
"license": "MIT", "license": "MIT",
"main": "./dist/index", "main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby", "homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -22,7 +22,7 @@
"devDependencies": { "devDependencies": {
"@types/fs-extra": "8.0.0", "@types/fs-extra": "8.0.0",
"@types/semver": "6.0.0", "@types/semver": "6.0.0",
"@vercel/build-utils": "2.15.2-canary.3", "@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0", "@vercel/ncc": "0.24.0",
"execa": "2.0.4", "execa": "2.0.4",
"fs-extra": "^7.0.1", "fs-extra": "^7.0.1",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/static-build", "name": "@vercel/static-build",
"version": "0.23.2-canary.3", "version": "0.24.0",
"license": "MIT", "license": "MIT",
"main": "./dist/index", "main": "./dist/index",
"homepage": "https://vercel.com/docs/build-step", "homepage": "https://vercel.com/docs/build-step",
@@ -35,10 +35,10 @@
"@types/ms": "0.7.31", "@types/ms": "0.7.31",
"@types/node-fetch": "2.5.4", "@types/node-fetch": "2.5.4",
"@types/promise-timeout": "1.3.0", "@types/promise-timeout": "1.3.0",
"@vercel/build-utils": "2.15.2-canary.3", "@vercel/build-utils": "2.16.0",
"@vercel/frameworks": "0.7.2-canary.0", "@vercel/frameworks": "0.8.0",
"@vercel/ncc": "0.24.0", "@vercel/ncc": "0.24.0",
"@vercel/routing-utils": "1.13.1", "@vercel/routing-utils": "1.13.2",
"get-port": "5.0.0", "get-port": "5.0.0",
"is-port-reachable": "2.0.1", "is-port-reachable": "2.0.1",
"ms": "2.1.2", "ms": "2.1.2",

View File

@@ -451,7 +451,7 @@ export const build: BuildV2 = async ({
const opts = { const opts = {
env: { env: {
...process.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_BIN: 'vendor/bin',
BUNDLE_CACHE_PATH: 'vendor/cache', BUNDLE_CACHE_PATH: 'vendor/cache',
BUNDLE_PATH: 'vendor/bundle', BUNDLE_PATH: 'vendor/bundle',
@@ -466,7 +466,7 @@ export const build: BuildV2 = async ({
isBundleInstall = true; isBundleInstall = true;
} }
if (existsSync(requirementsPath)) { if (existsSync(requirementsPath)) {
debug('Detected requirements.txt'); debug('Detected requirements.txt');
printInstall(); printInstall();
await runPipInstall( await runPipInstall(
workPath, workPath,
@@ -754,6 +754,7 @@ export const build: BuildV2 = async ({
export const prepareCache: PrepareCache = async ({ export const prepareCache: PrepareCache = async ({
entrypoint, entrypoint,
repoRootPath,
workPath, workPath,
config, config,
}) => { }) => {
@@ -783,7 +784,7 @@ export const prepareCache: PrepareCache = async ({
// Default cache files // Default cache files
Object.assign( Object.assign(
cacheFiles, cacheFiles,
await glob('{.shadow-cljs,node_modules}/**', workPath) await glob('**/{.shadow-cljs,node_modules}/**', repoRootPath || workPath)
); );
// Framework cache files // Framework cache files

View File

View 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)_
--- ---

View File

@@ -9,7 +9,7 @@ import Profile from '../routes/profile';
export default class App extends Component { export default class App extends Component {
/** Gets fired when the route changes. /** 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 * @param {string} event.url The newly routed URL
*/ */
handleRoute = e => { handleRoute = e => {

View File

@@ -15,7 +15,7 @@ cache:
env: env:
global: global:
# See https://git.io/vdao3 for details. # See https://github.com/ember-cli/ember-cli/blob/master/docs/build-concurrency.md
- JOBS=1 - JOBS=1
script: script:

View File

@@ -1,3 +1,4 @@
import { FileFsRef } from '@vercel/build-utils';
import path from 'path'; import path from 'path';
import { prepareCache } from '../src'; import { prepareCache } from '../src';
@@ -15,6 +16,37 @@ describe('prepareCache()', () => {
expect(files['index.js']).toBeUndefined(); 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 () => { test('should cache index.js and other/file2.js as defined in .vercel_build_output/config/build.json', async () => {
const files = await prepareCache({ const files = await prepareCache({
config: { zeroConfig: true }, config: { zeroConfig: true },

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vercel/static-config", "name": "@vercel/static-config",
"version": "1.0.0-canary.0", "version": "1.0.0",
"license": "MIT", "license": "MIT",
"main": "./dist/index", "main": "./dist/index",
"repository": { "repository": {
@@ -22,7 +22,7 @@
"ts-morph": "12.0.0" "ts-morph": "12.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "27.0.2", "@types/jest": "27.4.1",
"@types/node": "*" "@types/node": "*"
}, },
"jest": { "jest": {

2348
yarn.lock

File diff suppressed because it is too large Load Diff