mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-12 04:22:14 +00:00
Compare commits
9 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a400b9b29d | ||
|
|
b549c37149 | ||
|
|
30d5e64291 | ||
|
|
47c2c361d2 | ||
|
|
438576fc7c | ||
|
|
b30343ef7b | ||
|
|
2dc0dfa572 | ||
|
|
9ee54b3dd6 | ||
|
|
9d67e0bc06 |
@@ -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.4",
|
||||
"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.2-canary.0",
|
||||
"@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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "24.1.1-canary.6",
|
||||
"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.4",
|
||||
"@vercel/go": "1.3.3-canary.4",
|
||||
"@vercel/node": "1.14.2-canary.5",
|
||||
"@vercel/python": "2.2.3-canary.4",
|
||||
"@vercel/ruby": "1.3.3-canary.4",
|
||||
"@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.5",
|
||||
"@vercel/client": "11.0.0",
|
||||
"@vercel/fetch-retry": "5.0.3",
|
||||
"@vercel/frameworks": "0.7.2-canary.0",
|
||||
"@vercel/frameworks": "0.8.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@zeit/fun": "0.11.2",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "10.4.2-canary.5",
|
||||
"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.4",
|
||||
"@vercel/build-utils": "2.16.0",
|
||||
"@zeit/fetch": "5.2.0",
|
||||
"async-retry": "1.2.3",
|
||||
"async-sema": "3.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "0.7.2-canary.0",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/go",
|
||||
"version": "1.3.3-canary.4",
|
||||
"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.4",
|
||||
"@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.5",
|
||||
"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.4",
|
||||
"@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.4",
|
||||
"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.4",
|
||||
"@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;
|
||||
}
|
||||
@@ -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,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"]
|
||||
}
|
||||
|
||||
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.4",
|
||||
"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.4"
|
||||
"@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.4",
|
||||
"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.4",
|
||||
"@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.4",
|
||||
"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.4",
|
||||
"@vercel/frameworks": "0.7.2-canary.0",
|
||||
"@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,6 +754,7 @@ export const build: BuildV2 = async ({
|
||||
|
||||
export const prepareCache: PrepareCache = async ({
|
||||
entrypoint,
|
||||
repoRootPath,
|
||||
workPath,
|
||||
config,
|
||||
}) => {
|
||||
@@ -783,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
|
||||
|
||||
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:
|
||||
|
||||
32
packages/static-build/test/prepare-cache.test.ts
vendored
32
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 },
|
||||
|
||||
@@ -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