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:
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:

View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/build-utils",
"version": "2.15.2-canary.3",
"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"
}
}

View File

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

View File

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

View File

@@ -282,7 +282,9 @@ it('should select nodejs16.x with ENABLE_EXPERIMENTAL_NODE16', async () => {
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([]);
expect(warningMessages).toStrictEqual([
'Warning: Using experimental Node.js 16.x due to ENABLE_EXPERIMENTAL_NODE16=1',
]);
});
it('should get latest node version', async () => {

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "24.1.1-canary.5",
"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.3",
"@vercel/go": "1.3.3-canary.3",
"@vercel/node": "1.14.2-canary.4",
"@vercel/python": "2.2.3-canary.3",
"@vercel/ruby": "1.3.3-canary.3",
"@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.4",
"@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",

View File

@@ -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:

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "10.4.2-canary.4",
"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.3",
"@vercel/build-utils": "2.16.0",
"@zeit/fetch": "5.2.0",
"async-retry": "1.2.3",
"async-sema": "3.0.0",

View File

@@ -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"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/go",
"version": "1.3.3-canary.3",
"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.3",
"@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0",
"async-retry": "1.3.1",
"execa": "^1.0.0",

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "1.14.2-canary.4",
"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.3",
"@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0",
"@vercel/nft": "0.18.1",
"content-type": "1.0.4",

View File

@@ -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 => {

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",
"version": "2.2.3-canary.3",
"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.3",
"@types/jest": "27.4.1",
"@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0",
"execa": "^1.0.0",
"typescript": "4.3.4"

View File

@@ -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: {},
});

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": "/",
"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": "/",
"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": "/",
"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);
const buildUtilsUrl = '@canary';
let builderUrl;
let builderUrl: string;
beforeAll(async () => {
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,
"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
View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/redwood",
"version": "0.7.1-canary.3",
"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.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';
}
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);
};

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",
"version": "1.13.1",
"version": "1.13.2",
"description": "Vercel routing utilities",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",

View File

@@ -1,7 +1,7 @@
{
"name": "@vercel/ruby",
"author": "Nathan Cahill <nathan@nathancahill.com>",
"version": "1.3.3-canary.3",
"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.3",
"@vercel/build-utils": "2.16.0",
"@vercel/ncc": "0.24.0",
"execa": "2.0.4",
"fs-extra": "^7.0.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/static-build",
"version": "0.23.2-canary.3",
"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.3",
"@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",

View File

@@ -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

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 {
/** 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 => {

View File

@@ -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:

View File

@@ -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 },

View File

@@ -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": {

2348
yarn.lock

File diff suppressed because it is too large Load Diff