mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-24 03:39:11 +00:00
Compare commits
30 Commits
@now/node@
...
@now/cgi@1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aee33f040d | ||
|
|
b100677b3b | ||
|
|
9241b3ae2f | ||
|
|
1088da6871 | ||
|
|
f7b4dd4458 | ||
|
|
fb85b6b27a | ||
|
|
2e5e9b9a6f | ||
|
|
d3cc306e5b | ||
|
|
d6c6a2a271 | ||
|
|
6171a58ae3 | ||
|
|
5a6d1a135f | ||
|
|
68deab9007 | ||
|
|
d6114e2bef | ||
|
|
5fdc55f3fb | ||
|
|
751b166536 | ||
|
|
6ffc8d97f4 | ||
|
|
67a80d6b83 | ||
|
|
934cf772bc | ||
|
|
b01a24afdb | ||
|
|
0ad75b52bf | ||
|
|
050772e78a | ||
|
|
7c05dc1420 | ||
|
|
bdd25ac727 | ||
|
|
3a27328828 | ||
|
|
c076a5620f | ||
|
|
2bd8ef9eed | ||
|
|
500014f2fc | ||
|
|
17687e9bcd | ||
|
|
90354e9fe7 | ||
|
|
6236631beb |
@@ -340,6 +340,10 @@ jobs:
|
||||
- run:
|
||||
name: Running Unit Tests
|
||||
command: yarn test-unit --clean false
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- packages/now-cli/.nyc_output
|
||||
|
||||
coverage:
|
||||
docker:
|
||||
@@ -349,12 +353,6 @@ jobs:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: Compiling `now dev` HTML error templates
|
||||
command: node packages/now-cli/scripts/compile-templates.js
|
||||
- run:
|
||||
name: Run unit tests
|
||||
command: yarn workspace now run test-unit
|
||||
- run:
|
||||
name: Run coverage report
|
||||
command: yarn workspace now run coverage
|
||||
|
||||
@@ -6,7 +6,7 @@ A Runtime is an npm module that exposes a `build` function and optionally an `an
|
||||
Official Runtimes are published to [npmjs.com](https://npmjs.com) as a package and referenced in the `use` property of the `now.json` configuration file.
|
||||
However, the `use` property will work with any [npm install argument](https://docs.npmjs.com/cli/install) such as a git repo url which is useful for testing your Runtime.
|
||||
|
||||
See the [Runtimes Documentation](https://zeit.co/docs/v2/advanced/runtimes) to view example usage.
|
||||
See the [Runtimes Documentation](https://zeit.co/docs/runtimes) to view example usage.
|
||||
|
||||
## Runtime Exports
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/build-utils",
|
||||
"version": "1.1.1",
|
||||
"version": "1.2.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
@@ -32,9 +32,9 @@
|
||||
"aggregate-error": "3.0.1",
|
||||
"async-retry": "1.2.3",
|
||||
"async-sema": "2.1.4",
|
||||
"boxen": "4.2.0",
|
||||
"cross-spawn": "6.0.5",
|
||||
"end-of-stream": "1.4.1",
|
||||
"execa": "^1.0.0",
|
||||
"fs-extra": "7.0.0",
|
||||
"glob": "7.1.3",
|
||||
"into-stream": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import minimatch from 'minimatch';
|
||||
import { valid as validSemver } from 'semver';
|
||||
import { PackageJson, Builder, Config, BuilderFunctions } from './types';
|
||||
import {
|
||||
Builder,
|
||||
Config,
|
||||
BuilderFunctions,
|
||||
DetectorResult,
|
||||
DetectorOutput,
|
||||
} from './types';
|
||||
|
||||
interface ErrorResponse {
|
||||
code: string;
|
||||
@@ -12,26 +18,6 @@ interface Options {
|
||||
functions?: BuilderFunctions;
|
||||
}
|
||||
|
||||
const src = 'package.json';
|
||||
const config: Config = { zeroConfig: true };
|
||||
|
||||
const MISSING_BUILD_SCRIPT_ERROR: ErrorResponse = {
|
||||
code: 'missing_build_script',
|
||||
message:
|
||||
'Your `package.json` file is missing a `build` property inside the `scripts` property.' +
|
||||
'\nMore details: https://zeit.co/docs/v2/platform/frequently-asked-questions#missing-build-script',
|
||||
};
|
||||
|
||||
// Static builders are special cased in `@now/static-build`
|
||||
function getBuilders({ tag }: Options = {}): Map<string, Builder> {
|
||||
const withTag = tag ? `@${tag}` : '';
|
||||
const config = { zeroConfig: true };
|
||||
|
||||
return new Map<string, Builder>([
|
||||
['next', { src, use: `@now/next${withTag}`, config }],
|
||||
]);
|
||||
}
|
||||
|
||||
// Must be a function to ensure that the returned
|
||||
// object won't be a reference
|
||||
function getApiBuilders({ tag }: Pick<Options, 'tag'> = {}): Builder[] {
|
||||
@@ -47,13 +33,8 @@ function getApiBuilders({ tag }: Pick<Options, 'tag'> = {}): Builder[] {
|
||||
];
|
||||
}
|
||||
|
||||
function hasPublicDirectory(files: string[]) {
|
||||
return files.some(name => name.startsWith('public/'));
|
||||
}
|
||||
|
||||
function hasBuildScript(pkg: PackageJson | undefined) {
|
||||
const { scripts = {} } = pkg || {};
|
||||
return Boolean(scripts && scripts['build']);
|
||||
function hasDirectory(fileName: string, files: string[]) {
|
||||
return files.some(name => name.startsWith(`${fileName}/`));
|
||||
}
|
||||
|
||||
function getApiFunctionBuilder(
|
||||
@@ -91,39 +72,49 @@ function getApiFunctionBuilder(
|
||||
return use ? { use, src, config } : prevBuilder;
|
||||
}
|
||||
|
||||
async function detectFrontBuilder(
|
||||
pkg: PackageJson,
|
||||
function detectFrontBuilder(
|
||||
detectorResult: Partial<DetectorOutput>,
|
||||
builders: Builder[],
|
||||
options: Options
|
||||
): Promise<Builder> {
|
||||
): Builder {
|
||||
const { tag } = options;
|
||||
const withTag = tag ? `@${tag}` : '';
|
||||
for (const [dependency, builder] of getBuilders(options)) {
|
||||
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
||||
|
||||
// Return the builder when a dependency matches
|
||||
if (deps[dependency]) {
|
||||
if (options.functions) {
|
||||
Object.entries(options.functions).forEach(([key, func]) => {
|
||||
// When the builder is not used yet we'll use it for the frontend
|
||||
if (
|
||||
builders.every(
|
||||
b => !(b.config && b.config.functions && b.config.functions[key])
|
||||
)
|
||||
) {
|
||||
if (!builder.config) builder.config = {};
|
||||
if (!builder.config.functions) builder.config.functions = {};
|
||||
builder.config.functions[key] = { ...func };
|
||||
}
|
||||
});
|
||||
}
|
||||
const { framework, buildCommand, outputDirectory } = detectorResult;
|
||||
|
||||
return builder;
|
||||
}
|
||||
const frameworkSlug = framework ? framework.slug : null;
|
||||
|
||||
const config: Config = {
|
||||
zeroConfig: true,
|
||||
};
|
||||
|
||||
if (buildCommand) {
|
||||
config.buildCommand = buildCommand;
|
||||
}
|
||||
|
||||
// By default we'll choose the `static-build` builder
|
||||
return { src, use: `@now/static-build${withTag}`, config };
|
||||
if (outputDirectory) {
|
||||
config.outputDirectory = outputDirectory;
|
||||
}
|
||||
|
||||
// All unused functions will be used for the frontend
|
||||
if (options.functions) {
|
||||
Object.entries(options.functions).forEach(([key, func]) => {
|
||||
if (
|
||||
builders.every(
|
||||
b => !(b.config && b.config.functions && b.config.functions[key])
|
||||
)
|
||||
) {
|
||||
config.functions = config.functions || {};
|
||||
config.functions[key] = { ...func };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (frameworkSlug === 'next') {
|
||||
return { src: 'package.json', use: `@now/next${withTag}`, config };
|
||||
}
|
||||
|
||||
return { src: 'package.json', use: `@now/static-build${withTag}`, config };
|
||||
}
|
||||
|
||||
// Files that match a specific pattern will get ignored
|
||||
@@ -139,10 +130,6 @@ export function getIgnoreApiFilter(optionsOrBuilders: Options | Builder[]) {
|
||||
}
|
||||
|
||||
return (file: string) => {
|
||||
if (!file.startsWith('api/')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.includes('/.')) {
|
||||
return false;
|
||||
}
|
||||
@@ -169,10 +156,7 @@ export function sortFiles(fileA: string, fileB: string) {
|
||||
return fileA.localeCompare(fileB);
|
||||
}
|
||||
|
||||
async function detectApiBuilders(
|
||||
files: string[],
|
||||
options: Options
|
||||
): Promise<Builder[]> {
|
||||
function detectApiBuilders(files: string[], options: Options): Builder[] {
|
||||
const builds = files
|
||||
.sort(sortFiles)
|
||||
.filter(getIgnoreApiFilter(options))
|
||||
@@ -188,10 +172,10 @@ async function detectApiBuilders(
|
||||
|
||||
// When a package has files that conflict with `/api` routes
|
||||
// e.g. Next.js pages/api we'll check it here and return an error.
|
||||
async function checkConflictingFiles(
|
||||
function checkConflictingFiles(
|
||||
files: string[],
|
||||
builders: Builder[]
|
||||
): Promise<ErrorResponse | null> {
|
||||
): ErrorResponse | null {
|
||||
// For Next.js
|
||||
if (builders.some(b => b.use.startsWith('@now/next'))) {
|
||||
const hasApiPages = files.some(file => file.startsWith('pages/api/'));
|
||||
@@ -211,10 +195,10 @@ async function checkConflictingFiles(
|
||||
|
||||
// When e.g. Next.js receives a `functions` property it has to make sure,
|
||||
// that it can handle those files, otherwise there are unused functions.
|
||||
async function checkUnusedFunctionsOnFrontendBuilder(
|
||||
function checkUnusedFunctionsOnFrontendBuilder(
|
||||
files: string[],
|
||||
builder: Builder
|
||||
): Promise<ErrorResponse | null> {
|
||||
): ErrorResponse | null {
|
||||
const { config: { functions = undefined } = {} } = builder;
|
||||
|
||||
if (!functions) return null;
|
||||
@@ -231,7 +215,9 @@ async function checkUnusedFunctionsOnFrontendBuilder(
|
||||
) {
|
||||
return {
|
||||
code: 'unused_function',
|
||||
message: `The function for ${matchedFile} can't be handled by any builder`,
|
||||
message:
|
||||
`The function for "${matchedFile}" can't be handled by any runtime. ` +
|
||||
`Please provide one with the "runtime" option.`,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -241,8 +227,6 @@ async function checkUnusedFunctionsOnFrontendBuilder(
|
||||
}
|
||||
|
||||
function validateFunctions(files: string[], { functions = {} }: Options) {
|
||||
const apiBuilders = getApiBuilders();
|
||||
|
||||
for (const [path, func] of Object.entries(functions)) {
|
||||
if (path.length > 256) {
|
||||
return {
|
||||
@@ -312,15 +296,6 @@ function validateFunctions(files: string[], { functions = {} }: Options) {
|
||||
'Function Runtimes must have a valid version, for example `now-php@1.0.0`.',
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
apiBuilders.some(b => func.runtime && func.runtime.startsWith(b.use))
|
||||
) {
|
||||
return {
|
||||
code: 'invalid_function_runtime',
|
||||
message: `The function Runtime ${func.runtime} is not a Community Runtime and must not be specified.`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (func.includeFiles !== undefined) {
|
||||
@@ -349,7 +324,7 @@ function validateFunctions(files: string[], { functions = {} }: Options) {
|
||||
// to determine what builders to use
|
||||
export async function detectBuilders(
|
||||
files: string[],
|
||||
pkg?: PackageJson | undefined | null,
|
||||
detectorResult: Partial<DetectorResult> | null = null,
|
||||
options: Options = {}
|
||||
): Promise<{
|
||||
builders: Builder[] | null;
|
||||
@@ -370,19 +345,23 @@ export async function detectBuilders(
|
||||
}
|
||||
|
||||
// Detect all builders for the `api` directory before anything else
|
||||
const builders = await detectApiBuilders(files, options);
|
||||
const builders = detectApiBuilders(files, options);
|
||||
|
||||
if (pkg && hasBuildScript(pkg)) {
|
||||
const frontendBuilder = await detectFrontBuilder(pkg, builders, options);
|
||||
if (detectorResult && detectorResult.buildCommand) {
|
||||
const frontendBuilder = detectFrontBuilder(
|
||||
detectorResult,
|
||||
builders,
|
||||
options
|
||||
);
|
||||
builders.push(frontendBuilder);
|
||||
|
||||
const conflictError = await checkConflictingFiles(files, builders);
|
||||
const conflictError = checkConflictingFiles(files, builders);
|
||||
|
||||
if (conflictError) {
|
||||
warnings.push(conflictError);
|
||||
}
|
||||
|
||||
const unusedFunctionError = await checkUnusedFunctionsOnFrontendBuilder(
|
||||
const unusedFunctionError = checkUnusedFunctionsOnFrontendBuilder(
|
||||
files,
|
||||
frontendBuilder
|
||||
);
|
||||
@@ -394,34 +373,35 @@ export async function detectBuilders(
|
||||
warnings,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
if (pkg && builders.length === 0) {
|
||||
// We only show this error when there are no api builders
|
||||
// since the dependencies of the pkg could be used for those
|
||||
errors.push(MISSING_BUILD_SCRIPT_ERROR);
|
||||
return { errors, warnings, builders: null };
|
||||
}
|
||||
|
||||
// We allow a `public` directory
|
||||
// when there are no build steps
|
||||
if (hasPublicDirectory(files)) {
|
||||
builders.push({
|
||||
use: '@now/static',
|
||||
src: 'public/**/*',
|
||||
config,
|
||||
});
|
||||
} else if (
|
||||
builders.length > 0 &&
|
||||
files.some(f => !f.startsWith('api/') && f !== 'package.json')
|
||||
) {
|
||||
// Everything besides the api directory
|
||||
// and package.json can be served as static files
|
||||
builders.push({
|
||||
use: '@now/static',
|
||||
src: '!{api/**,package.json}',
|
||||
config,
|
||||
});
|
||||
}
|
||||
} else if (
|
||||
detectorResult &&
|
||||
detectorResult.outputDirectory &&
|
||||
hasDirectory(detectorResult.outputDirectory, files)
|
||||
) {
|
||||
builders.push({
|
||||
use: '@now/static',
|
||||
src: [...detectorResult.outputDirectory.split('/'), '**', '*']
|
||||
.filter(Boolean)
|
||||
.join('/'),
|
||||
config: { zeroConfig: true },
|
||||
});
|
||||
} else if (hasDirectory('public', files)) {
|
||||
builders.push({
|
||||
use: '@now/static',
|
||||
src: 'public/**/*',
|
||||
config: { zeroConfig: true },
|
||||
});
|
||||
} else if (
|
||||
builders.length > 0 &&
|
||||
files.some(f => !f.startsWith('api/') && f !== 'package.json')
|
||||
) {
|
||||
// Everything besides the api directory
|
||||
// and package.json can be served as static files
|
||||
builders.push({
|
||||
use: '@now/static',
|
||||
src: '!{api/**,package.json}',
|
||||
config: { zeroConfig: true },
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -217,7 +217,10 @@ async function detectApiRoutes(
|
||||
for (const file of sortedFiles) {
|
||||
// We only consider every file in the api directory
|
||||
// as we will strip extensions as well as resolving "[segments]"
|
||||
if (!file.startsWith('api/')) {
|
||||
if (
|
||||
!file.startsWith('api/') &&
|
||||
!builders.some(b => b.src === file && b.config!.functions)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -271,14 +274,16 @@ async function detectApiRoutes(
|
||||
return { defaultRoutes, error: null };
|
||||
}
|
||||
|
||||
function hasPublicBuilder(builders: Builder[]): boolean {
|
||||
return builders.some(
|
||||
function getPublicBuilder(builders: Builder[]): Builder | null {
|
||||
const builder = builders.find(
|
||||
builder =>
|
||||
builder.use === '@now/static' &&
|
||||
builder.src === 'public/**/*' &&
|
||||
/^.*\/\*\*\/\*$/.test(builder.src) &&
|
||||
builder.config &&
|
||||
builder.config.zeroConfig === true
|
||||
);
|
||||
|
||||
return builder || null;
|
||||
}
|
||||
|
||||
export async function detectRoutes(
|
||||
@@ -286,11 +291,14 @@ export async function detectRoutes(
|
||||
builders: Builder[]
|
||||
): Promise<RoutesResult> {
|
||||
const routesResult = await detectApiRoutes(files, builders);
|
||||
const publicBuilder = getPublicBuilder(builders);
|
||||
|
||||
if (routesResult.defaultRoutes && publicBuilder) {
|
||||
const directory = publicBuilder.src.replace('/**/*', '');
|
||||
|
||||
if (routesResult.defaultRoutes && hasPublicBuilder(builders)) {
|
||||
routesResult.defaultRoutes.push({
|
||||
src: '/(.*)',
|
||||
dest: '/public/$1',
|
||||
dest: `/${directory}/$1`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectAngular({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasAngular = await hasDependency('@angular/cli');
|
||||
if (!hasAngular) return false;
|
||||
const version = await getDependencyVersion('@angular/cli');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'ng build',
|
||||
buildDirectory: 'dist',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'ng build',
|
||||
outputDirectory: 'dist',
|
||||
devCommand: 'ng serve --port $PORT',
|
||||
framework: {
|
||||
slug: '@angular/cli',
|
||||
version,
|
||||
},
|
||||
minNodeRange: '10.x',
|
||||
routes: [
|
||||
{
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectBrunch({
|
||||
fs: { hasDependency, exists },
|
||||
fs: { exists, getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasBrunch = await hasDependency('brunch');
|
||||
if (!hasBrunch) return false;
|
||||
const version = await getDependencyVersion('brunch');
|
||||
if (!version) return false;
|
||||
|
||||
const hasConfig = await exists('brunch-config.js');
|
||||
if (!hasConfig) return false;
|
||||
|
||||
return {
|
||||
buildCommand: 'brunch build --production',
|
||||
buildDirectory: 'public',
|
||||
buildCommand:
|
||||
(await getPackageJsonBuildCommand()) || 'brunch build --production',
|
||||
outputDirectory: 'public',
|
||||
devCommand: 'brunch watch --server --port $PORT',
|
||||
framework: {
|
||||
slug: 'brunch',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectCreateReactAppEjected({
|
||||
fs: { hasDependency },
|
||||
fs: { getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasReactDevUtils = await hasDependency('react-dev-utils');
|
||||
if (!hasReactDevUtils) {
|
||||
const version = await getDependencyVersion('react-dev-utils');
|
||||
if (!version) {
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
buildCommand: 'node scripts/build.js',
|
||||
buildDirectory: 'build',
|
||||
outputDirectory: 'build',
|
||||
devCommand: 'node scripts/start.js',
|
||||
framework: {
|
||||
slug: 'react-dev-utils',
|
||||
version,
|
||||
},
|
||||
devVariables: { BROWSER: 'none' },
|
||||
routes: [
|
||||
{
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectCreateReactApp({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasReactScripts = await hasDependency('react-scripts');
|
||||
if (!hasReactScripts) {
|
||||
const version = await getDependencyVersion('react-scripts');
|
||||
if (!version) {
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
buildCommand: 'react-scripts build',
|
||||
buildDirectory: 'build',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'react-scripts build',
|
||||
outputDirectory: 'build',
|
||||
devCommand: 'react-scripts start',
|
||||
devVariables: { BROWSER: 'none' },
|
||||
framework: {
|
||||
slug: 'react-scripts',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
src: '/static/(.*)',
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectDocusaurus({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasDocusaurus = await hasDependency('docusaurus');
|
||||
if (!hasDocusaurus) return false;
|
||||
const version = await getDependencyVersion('docusaurus');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'docusaurus-build',
|
||||
buildDirectory: 'build',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'docusaurus-build',
|
||||
outputDirectory: 'build',
|
||||
devCommand: 'docusaurus-start --port $PORT',
|
||||
framework: {
|
||||
slug: 'docusaurus',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectEleventy({
|
||||
fs: { hasDependency },
|
||||
fs: { getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasEleventy = await hasDependency('@11ty/eleventy');
|
||||
if (!hasEleventy) return false;
|
||||
const version = await getDependencyVersion('@11ty/eleventy');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'npx @11ty/eleventy',
|
||||
buildDirectory: '_site',
|
||||
outputDirectory: '_site',
|
||||
devCommand: 'npx @11ty/eleventy --serve --watch --port $PORT',
|
||||
framework: {
|
||||
slug: '@11ty/eleventy',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectEmber({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasEmber = await hasDependency('ember-cli');
|
||||
if (!hasEmber) return false;
|
||||
const version = await getDependencyVersion('ember-cli');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'ember build',
|
||||
buildDirectory: 'dist',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'ember build',
|
||||
outputDirectory: 'dist',
|
||||
devCommand: 'ember serve --port $PORT',
|
||||
framework: {
|
||||
slug: 'ember-cli',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
handle: 'filesystem',
|
||||
|
||||
@@ -102,6 +102,31 @@ export default abstract class DetectorFilesystem {
|
||||
const { dependencies = {}, devDependencies = {} } = pkg || {};
|
||||
return name in dependencies || name in devDependencies;
|
||||
};
|
||||
|
||||
public isNpm = async (): Promise<boolean> => {
|
||||
return this.exists('package-lock.json');
|
||||
};
|
||||
|
||||
public getPackageJsonCommand = async (
|
||||
name: string
|
||||
): Promise<string | null> => {
|
||||
const pkg = await this.readPackageJson();
|
||||
const { scripts = {} } = pkg || {};
|
||||
return scripts[name] || null;
|
||||
};
|
||||
|
||||
public getPackageJsonBuildCommand = async (): Promise<string | null> => {
|
||||
const buildCommand = (await this.isNpm())
|
||||
? 'npm run build'
|
||||
: 'yarn run build';
|
||||
return (await this.getPackageJsonCommand('build')) ? buildCommand : null;
|
||||
};
|
||||
|
||||
public getDependencyVersion = async (name: string): Promise<string> => {
|
||||
const pkg = await this.readPackageJson();
|
||||
const { dependencies = {}, devDependencies = {} } = pkg || {};
|
||||
return dependencies[name] || devDependencies[name];
|
||||
};
|
||||
}
|
||||
|
||||
async function nullEnoent<T>(p: Promise<T>): Promise<T | null> {
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectGatsby({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasGatsby = await hasDependency('gatsby');
|
||||
if (!hasGatsby) {
|
||||
const version = await getDependencyVersion('gatsby');
|
||||
if (!version) {
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
buildCommand: 'gatsby build',
|
||||
buildDirectory: 'public',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'gatsby build',
|
||||
outputDirectory: 'public',
|
||||
devCommand: 'gatsby develop -p $PORT',
|
||||
framework: {
|
||||
slug: 'gatsby',
|
||||
version,
|
||||
},
|
||||
cachePattern: '.cache/**',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectGenericNodeProject({
|
||||
fs: { isNpm, getPackageJsonCommand },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const useNpm = await isNpm();
|
||||
const devCommand = await getPackageJsonCommand('dev');
|
||||
const buildCommand = await getPackageJsonCommand('build');
|
||||
|
||||
if (!buildCommand) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
buildCommand: `${useNpm ? 'npm' : 'yarn'} run build`,
|
||||
devCommand: `${useNpm ? 'npm' : 'yarn'} run ${
|
||||
devCommand ? 'dev' : 'build'
|
||||
}`,
|
||||
outputDirectory: 'public',
|
||||
};
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectGridsome({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasGridsome = await hasDependency('gridsome');
|
||||
if (!hasGridsome) {
|
||||
const version = await getDependencyVersion('gridsome');
|
||||
if (!version) {
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
buildCommand: 'gridsome build',
|
||||
buildDirectory: 'dist',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'gridsome build',
|
||||
outputDirectory: 'dist',
|
||||
devCommand: 'gridsome develop -p $PORT',
|
||||
framework: {
|
||||
slug: 'gridsom',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectHexo({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasHexo = await hasDependency('hexo');
|
||||
if (!hasHexo) return false;
|
||||
const version = await getDependencyVersion('hexo');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'hexo generate',
|
||||
buildDirectory: 'public',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'hexo generate',
|
||||
outputDirectory: 'public',
|
||||
devCommand: 'hexo server --port $PORT',
|
||||
framework: {
|
||||
slug: 'hexo',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@ export default async function detectHugo({
|
||||
}
|
||||
return {
|
||||
buildCommand: 'hugo',
|
||||
buildDirectory: config.publishDir || 'public',
|
||||
outputDirectory: config.publishDir || 'public',
|
||||
devCommand: 'hugo server -D -w -p $PORT',
|
||||
framework: {
|
||||
slug: 'hugo',
|
||||
version: 'latest',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import docusaurus from './docusaurus';
|
||||
import eleventy from './eleventy';
|
||||
import ember from './ember';
|
||||
import gatsby from './gatsby';
|
||||
import genericNodeProject from './generic-node-project';
|
||||
import gridsome from './gridsome';
|
||||
import hexo from './hexo';
|
||||
import hugo from './hugo';
|
||||
@@ -81,5 +82,8 @@ export async function detectDefaults(
|
||||
d = params.detectors || detectors;
|
||||
result = await firstTruthy(d.map(detector => detector(params)));
|
||||
}
|
||||
if (!result) {
|
||||
result = await genericNodeProject(params);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@ export default async function detectJekyll({
|
||||
}
|
||||
return {
|
||||
buildCommand: 'jekyll build',
|
||||
buildDirectory: config.destination || '_site',
|
||||
outputDirectory: config.destination || '_site',
|
||||
devCommand: 'bundle exec jekyll serve --watch --port $PORT',
|
||||
framework: {
|
||||
slug: 'jekyll',
|
||||
version: 'latest',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@ export default async function detectMiddleman({
|
||||
|
||||
return {
|
||||
buildCommand: 'bundle exec middleman build',
|
||||
buildDirectory: 'build',
|
||||
outputDirectory: 'build',
|
||||
devCommand: 'bundle exec middleman server -p $PORT',
|
||||
framework: {
|
||||
slug: 'middleman',
|
||||
version: 'latest',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectNext({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasNext = await hasDependency('next');
|
||||
if (!hasNext) return false;
|
||||
const version = await getDependencyVersion('next');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'next build',
|
||||
buildDirectory: 'build',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'next build',
|
||||
outputDirectory: '.next/static',
|
||||
devCommand: 'next -p $PORT',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectPolymer({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasPolymer = await hasDependency('polymer-cli');
|
||||
if (!hasPolymer) return false;
|
||||
const version = await getDependencyVersion('polymer-cli');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'polymer build',
|
||||
buildDirectory: 'build',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'polymer build',
|
||||
outputDirectory: 'build',
|
||||
devCommand: 'polymer serve --port $PORT',
|
||||
framework: {
|
||||
slug: 'polymer-cli',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
handle: 'filesystem',
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectPreact({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasPreact = await hasDependency('preact-cli');
|
||||
if (!hasPreact) return false;
|
||||
const version = await getDependencyVersion('preact-cli');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'preact build',
|
||||
buildDirectory: 'build',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'preact build',
|
||||
outputDirectory: 'build',
|
||||
devCommand: 'preact watch --port $PORT',
|
||||
framework: {
|
||||
slug: 'preact-cli',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
handle: 'filesystem',
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectSaber({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasSaber = await hasDependency('saber');
|
||||
if (!hasSaber) return false;
|
||||
const version = await getDependencyVersion('saber');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'saber build',
|
||||
buildDirectory: 'public',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'saber build',
|
||||
outputDirectory: 'public',
|
||||
devCommand: 'saber --port $PORT',
|
||||
routes: [
|
||||
{
|
||||
@@ -23,5 +23,9 @@ export default async function detectSaber({
|
||||
dest: '404.html',
|
||||
},
|
||||
],
|
||||
framework: {
|
||||
slug: 'saber',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectSapper({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasSapper = await hasDependency('sapper');
|
||||
if (!hasSapper) return false;
|
||||
const version = await getDependencyVersion('sapper');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'sapper export',
|
||||
buildDirectory: '__sapper__/export',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'sapper export',
|
||||
outputDirectory: '__sapper__/export',
|
||||
devCommand: 'sapper dev --port $PORT',
|
||||
framework: {
|
||||
slug: 'sapper',
|
||||
version,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectStencil({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasStencil = await hasDependency('@stencil/core');
|
||||
if (!hasStencil) return false;
|
||||
const version = await getDependencyVersion('@stencil/core');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'stencil build',
|
||||
buildDirectory: 'www',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'stencil build',
|
||||
outputDirectory: 'www',
|
||||
devCommand: 'stencil build --dev --watch --serve --port $PORT',
|
||||
framework: {
|
||||
slug: '@stencil/core',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
handle: 'filesystem',
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectSvelte({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasSvelte = await hasDependency('sirv-cli');
|
||||
if (!hasSvelte) return false;
|
||||
const version = await getDependencyVersion('sirv-cli');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'rollup -c',
|
||||
buildDirectory: 'public',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'rollup -c',
|
||||
outputDirectory: 'public',
|
||||
devCommand: 'sirv public --single --dev --port $PORT',
|
||||
framework: {
|
||||
slug: 'sirv-cli',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
handle: 'filesystem',
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectUmiJS({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasUmi = await hasDependency('umi');
|
||||
if (!hasUmi) return false;
|
||||
const version = await getDependencyVersion('umi');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'umi build',
|
||||
buildDirectory: 'dist',
|
||||
buildCommand: (await getPackageJsonBuildCommand()) || 'umi build',
|
||||
outputDirectory: 'dist',
|
||||
devCommand: 'umi dev --port $PORT',
|
||||
framework: {
|
||||
slug: 'umi',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
handle: 'filesystem',
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import { DetectorParameters, DetectorResult } from '../types';
|
||||
|
||||
export default async function detectVue({
|
||||
fs: { hasDependency },
|
||||
fs: { getPackageJsonBuildCommand, getDependencyVersion },
|
||||
}: DetectorParameters): Promise<DetectorResult> {
|
||||
const hasVue = await hasDependency('@vue/cli-service');
|
||||
if (!hasVue) return false;
|
||||
const version = await getDependencyVersion('@vue/cli-service');
|
||||
if (!version) return false;
|
||||
return {
|
||||
buildCommand: 'vue-cli-service build',
|
||||
buildDirectory: 'dist',
|
||||
buildCommand:
|
||||
(await getPackageJsonBuildCommand()) || 'vue-cli-service build',
|
||||
outputDirectory: 'dist',
|
||||
devCommand: 'vue-cli-service serve --port $PORT',
|
||||
framework: {
|
||||
slug: '@vue/cli-service',
|
||||
version,
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
src: '^/[^/]*\\.(js|txt|ico|json)',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'path';
|
||||
import debug from '../debug';
|
||||
import FileFsRef from '../file-fs-ref';
|
||||
import { File, Files, Meta } from '../types';
|
||||
import { remove, mkdirp, readlink, symlink } from 'fs-extra';
|
||||
@@ -39,8 +40,12 @@ export default async function download(
|
||||
basePath: string,
|
||||
meta?: Meta
|
||||
): Promise<DownloadedFiles> {
|
||||
const { isDev = false, skipDownload = false, filesChanged = null, filesRemoved = null } =
|
||||
meta || {};
|
||||
const {
|
||||
isDev = false,
|
||||
skipDownload = false,
|
||||
filesChanged = null,
|
||||
filesRemoved = null,
|
||||
} = meta || {};
|
||||
|
||||
if (isDev || skipDownload) {
|
||||
// In `now dev`, the `download()` function is a no-op because
|
||||
@@ -48,11 +53,14 @@ export default async function download(
|
||||
// source files are already available.
|
||||
return files as DownloadedFiles;
|
||||
}
|
||||
debug('Downloading deployment source files...');
|
||||
|
||||
const start = Date.now();
|
||||
const files2: DownloadedFiles = {};
|
||||
const filenames = Object.keys(files);
|
||||
|
||||
await Promise.all(
|
||||
Object.keys(files).map(async name => {
|
||||
filenames.map(async name => {
|
||||
// If the file does not exist anymore, remove it.
|
||||
if (Array.isArray(filesRemoved) && filesRemoved.includes(name)) {
|
||||
await removeFile(basePath, name);
|
||||
@@ -71,5 +79,8 @@ export default async function download(
|
||||
})
|
||||
);
|
||||
|
||||
const duration = Date.now() - start;
|
||||
debug(`Downloaded ${filenames.length} source files: ${duration}ms`);
|
||||
|
||||
return files2;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
import { intersects } from 'semver';
|
||||
import boxen from 'boxen';
|
||||
import { NodeVersion } from '../types';
|
||||
import debug from '../debug';
|
||||
|
||||
const supportedOptions: NodeVersion[] = [
|
||||
const allOptions: NodeVersion[] = [
|
||||
{ major: 12, range: '12.x', runtime: 'nodejs12.x' },
|
||||
{ major: 10, range: '10.x', runtime: 'nodejs10.x' },
|
||||
{ major: 8, range: '8.10.x', runtime: 'nodejs8.10' },
|
||||
{
|
||||
major: 8,
|
||||
range: '8.10.x',
|
||||
runtime: 'nodejs8.10',
|
||||
discontinueDate: new Date('2020-01-06'),
|
||||
},
|
||||
];
|
||||
|
||||
const supportedOptions = allOptions.filter(o => !isDiscontinued(o));
|
||||
|
||||
// This version should match Fargate's default in the PATH
|
||||
// Today that is Node 8
|
||||
export const defaultSelection = supportedOptions.find(
|
||||
@@ -28,13 +36,14 @@ export async function getSupportedNodeVersion(
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const found = supportedOptions.some(o => {
|
||||
const found = allOptions.some(o => {
|
||||
// the array is already in order so return the first
|
||||
// match which will be the newest version of node
|
||||
selection = o;
|
||||
return intersects(o.range, engineRange);
|
||||
});
|
||||
if (found) {
|
||||
const discontinued = isDiscontinued(selection);
|
||||
if (found && !discontinued) {
|
||||
if (!silent) {
|
||||
debug(
|
||||
'Found `engines` in `package.json`, selecting range: ' +
|
||||
@@ -42,15 +51,50 @@ export async function getSupportedNodeVersion(
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!silent) {
|
||||
throw new Error(
|
||||
'Found `engines` in `package.json` with an unsupported node range: ' +
|
||||
engineRange +
|
||||
'\nPlease use one of the following supported ranges: ' +
|
||||
JSON.stringify(supportedOptions.map(o => o.range))
|
||||
);
|
||||
}
|
||||
throw new Error(
|
||||
'Found `engines` in `package.json` with an unsupported Node.js version range: ' +
|
||||
engineRange +
|
||||
'\nPlease use one of the following supported ranges: ' +
|
||||
JSON.stringify(supportedOptions.map(o => o.range)) +
|
||||
(discontinued
|
||||
? '\nThis change is the result of a decision made by an upstream infrastructure provider (AWS).' +
|
||||
'\nRead more: https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html'
|
||||
: '')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const { range, discontinueDate } = selection;
|
||||
if (discontinueDate && !isDiscontinued(selection)) {
|
||||
const d = discontinueDate.toISOString().split('T')[0];
|
||||
const validRanges = supportedOptions
|
||||
.filter(o => !o.discontinueDate)
|
||||
.map(o => o.range);
|
||||
const prevTerm = process.env.TERM;
|
||||
if (!prevTerm) {
|
||||
// workaround for https://github.com/sindresorhus/term-size/issues/13
|
||||
process.env.TERM = 'xterm';
|
||||
}
|
||||
console.warn(
|
||||
boxen(
|
||||
'NOTICE' +
|
||||
'\n' +
|
||||
`\nNode.js version ${range} has reached end-of-life.` +
|
||||
`\nAs a result, deployments created on or after ${d} will fail to build.` +
|
||||
'\nPlease use one of the following supported `engines` in `package.json`: ' +
|
||||
JSON.stringify(validRanges) +
|
||||
'\nThis change is the result of a decision made by an upstream infrastructure provider (AWS).' +
|
||||
'\nRead more: https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html',
|
||||
{ padding: 1 }
|
||||
)
|
||||
);
|
||||
process.env.TERM = prevTerm;
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
function isDiscontinued({ discontinueDate }: NodeVersion): boolean {
|
||||
const today = new Date();
|
||||
return discontinueDate !== undefined && discontinueDate <= today;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import FileFsRef from './file-fs-ref';
|
||||
import FileRef from './file-ref';
|
||||
import { Lambda, createLambda, getLambdaOptionsFromFunction } from './lambda';
|
||||
import { Prerender } from './prerender';
|
||||
import download, { DownloadedFiles } from './fs/download';
|
||||
import download, { DownloadedFiles, isSymbolicLink } from './fs/download';
|
||||
import getWriteableDirectory from './fs/get-writable-directory';
|
||||
import glob from './fs/glob';
|
||||
import rename from './fs/rename';
|
||||
@@ -52,8 +52,10 @@ export {
|
||||
detectBuilders,
|
||||
detectRoutes,
|
||||
debug,
|
||||
isSymbolicLink,
|
||||
getLambdaOptionsFromFunction,
|
||||
};
|
||||
|
||||
export { detectDefaults } from './detectors';
|
||||
export * from './schemas';
|
||||
export * from './types';
|
||||
|
||||
61
packages/now-build-utils/src/schemas.ts
Normal file
61
packages/now-build-utils/src/schemas.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
export const functionsSchema = {
|
||||
type: 'object',
|
||||
minProperties: 1,
|
||||
maxProperties: 50,
|
||||
additionalProperties: false,
|
||||
patternProperties: {
|
||||
'^.{1,256}$': {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
runtime: {
|
||||
type: 'string',
|
||||
maxLength: 256,
|
||||
},
|
||||
memory: {
|
||||
// Number between 128 and 3008 in steps of 64
|
||||
enum: Object.keys(Array.from({ length: 50 }))
|
||||
.slice(2, 48)
|
||||
.map(x => Number(x) * 64),
|
||||
},
|
||||
maxDuration: {
|
||||
type: 'number',
|
||||
minimum: 1,
|
||||
maximum: 900,
|
||||
},
|
||||
includeFiles: {
|
||||
type: 'string',
|
||||
maxLength: 256,
|
||||
},
|
||||
excludeFiles: {
|
||||
type: 'string',
|
||||
maxLength: 256,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const buildsSchema = {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
maxItems: 128,
|
||||
items: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['use'],
|
||||
properties: {
|
||||
src: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
maxLength: 4096,
|
||||
},
|
||||
use: {
|
||||
type: 'string',
|
||||
minLength: 3,
|
||||
maxLength: 256,
|
||||
},
|
||||
config: { type: 'object' },
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -304,6 +304,7 @@ export interface NodeVersion {
|
||||
major: number;
|
||||
range: string;
|
||||
runtime: string;
|
||||
discontinueDate?: Date;
|
||||
}
|
||||
|
||||
export interface Builder {
|
||||
@@ -353,7 +354,7 @@ export interface DetectorParameters {
|
||||
|
||||
export interface DetectorOutput {
|
||||
buildCommand: string;
|
||||
buildDirectory: string;
|
||||
outputDirectory: string;
|
||||
buildVariables?: Env;
|
||||
devCommand?: string;
|
||||
devVariables?: Env;
|
||||
@@ -365,6 +366,10 @@ export interface DetectorOutput {
|
||||
redirects?: NowRedirect[];
|
||||
headers?: NowHeader[];
|
||||
trailingSlash?: boolean;
|
||||
framework?: {
|
||||
slug: string;
|
||||
version: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type DetectorResult = DetectorOutput | false;
|
||||
|
||||
@@ -4,13 +4,34 @@ const {
|
||||
packAndDeploy,
|
||||
testDeployment,
|
||||
} = require('../../../test/lib/deployment/test-deployment');
|
||||
const { glob, detectBuilders, detectRoutes } = require('../');
|
||||
const {
|
||||
glob,
|
||||
detectBuilders,
|
||||
detectRoutes,
|
||||
DetectorFilesystem,
|
||||
detectDefaults,
|
||||
} = require('../');
|
||||
|
||||
jest.setTimeout(4 * 60 * 1000);
|
||||
|
||||
const builderUrl = '@canary';
|
||||
let buildUtilsUrl;
|
||||
|
||||
class LocalFilesystem extends DetectorFilesystem {
|
||||
constructor(dir) {
|
||||
super();
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
_exists(name) {
|
||||
return fs.pathExists(path.join(this.dir, name));
|
||||
}
|
||||
|
||||
_readFile(name) {
|
||||
return fs.readFile(path.join(this.dir, name));
|
||||
}
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
const buildUtilsPath = path.resolve(__dirname, '..');
|
||||
buildUtilsUrl = await packAndDeploy(buildUtilsPath);
|
||||
@@ -67,7 +88,9 @@ for (const builder of buildersToTestWith) {
|
||||
|
||||
it('Test `detectBuilders` and `detectRoutes`', async () => {
|
||||
const fixture = path.join(__dirname, 'fixtures', '01-zero-config-api');
|
||||
const pkg = await fs.readJSON(path.join(fixture, 'package.json'));
|
||||
const detectorResult = await detectDefaults({
|
||||
fs: new LocalFilesystem(fixture),
|
||||
});
|
||||
const fileList = await glob('**', fixture);
|
||||
const files = Object.keys(fileList);
|
||||
|
||||
@@ -110,7 +133,7 @@ it('Test `detectBuilders` and `detectRoutes`', async () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detectorResult);
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
|
||||
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
|
||||
@@ -128,7 +151,9 @@ it('Test `detectBuilders` and `detectRoutes`', async () => {
|
||||
|
||||
it('Test `detectBuilders` and `detectRoutes` with `index` files', async () => {
|
||||
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
|
||||
const pkg = await fs.readJSON(path.join(fixture, 'package.json'));
|
||||
const detectorResult = await detectDefaults({
|
||||
fs: new LocalFilesystem(fixture),
|
||||
});
|
||||
const fileList = await glob('**', fixture);
|
||||
const files = Object.keys(fileList);
|
||||
|
||||
@@ -192,7 +217,7 @@ it('Test `detectBuilders` and `detectRoutes` with `index` files', async () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detectorResult);
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
|
||||
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
|
||||
|
||||
@@ -67,8 +67,8 @@ test('detectDefaults() - angular', async () => {
|
||||
const fs = new LocalFilesystem(dir);
|
||||
const result = await detectDefaults({ fs });
|
||||
if (!result) throw new Error('Expected result');
|
||||
assert.equal(result.buildDirectory, 'dist');
|
||||
assert.deepEqual(result.buildCommand, 'ng build');
|
||||
assert.equal(result.outputDirectory, 'dist');
|
||||
assert.deepEqual(result.buildCommand, 'yarn run build');
|
||||
});
|
||||
|
||||
test('detectDefaults() - brunch', async () => {
|
||||
@@ -76,8 +76,8 @@ test('detectDefaults() - brunch', async () => {
|
||||
const fs = new LocalFilesystem(dir);
|
||||
const result = await detectDefaults({ fs });
|
||||
if (!result) throw new Error('Expected result');
|
||||
assert.equal(result.buildDirectory, 'public');
|
||||
assert.deepEqual(result.buildCommand, 'brunch build --production');
|
||||
assert.equal(result.outputDirectory, 'public');
|
||||
assert.deepEqual(result.buildCommand, 'yarn run build');
|
||||
});
|
||||
|
||||
test('detectDefaults() - hugo', async () => {
|
||||
@@ -85,7 +85,7 @@ test('detectDefaults() - hugo', async () => {
|
||||
const fs = new LocalFilesystem(dir);
|
||||
const result = await detectDefaults({ fs });
|
||||
if (!result) throw new Error('Expected result');
|
||||
assert.equal(result.buildDirectory, 'public');
|
||||
assert.equal(result.outputDirectory, 'public');
|
||||
assert.deepEqual(result.buildCommand, 'hugo');
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ test('detectDefaults() - jekyll', async () => {
|
||||
const fs = new LocalFilesystem(dir);
|
||||
const result = await detectDefaults({ fs });
|
||||
if (!result) throw new Error('Expected result');
|
||||
assert.equal(result.buildDirectory, '_site');
|
||||
assert.equal(result.outputDirectory, '_site');
|
||||
assert.deepEqual(result.buildCommand, 'jekyll build');
|
||||
});
|
||||
|
||||
@@ -103,6 +103,6 @@ test('detectDefaults() - middleman', async () => {
|
||||
const fs = new LocalFilesystem(dir);
|
||||
const result = await detectDefaults({ fs });
|
||||
if (!result) throw new Error('Expected result');
|
||||
assert.equal(result.buildDirectory, 'build');
|
||||
assert.equal(result.outputDirectory, 'build');
|
||||
assert.deepEqual(result.buildCommand, 'bundle exec middleman build');
|
||||
});
|
||||
|
||||
399
packages/now-build-utils/test/unit.test.js
vendored
399
packages/now-build-utils/test/unit.test.js
vendored
@@ -1,9 +1,14 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const execa = require('execa');
|
||||
const assert = require('assert');
|
||||
const { createZip } = require('../dist/lambda');
|
||||
const { glob, download, detectBuilders, detectRoutes } = require('../');
|
||||
const {
|
||||
glob,
|
||||
download,
|
||||
detectBuilders,
|
||||
detectRoutes,
|
||||
spawnAsync,
|
||||
} = require('../');
|
||||
const {
|
||||
getSupportedNodeVersion,
|
||||
defaultSelection,
|
||||
@@ -39,7 +44,7 @@ it('should create zip files with symlinks properly', async () => {
|
||||
await fs.mkdirp(outDir);
|
||||
|
||||
await fs.writeFile(outFile, await createZip(files));
|
||||
await execa('unzip', [outFile], { cwd: outDir });
|
||||
await spawnAsync('unzip', [outFile], { cwd: outDir });
|
||||
|
||||
const [linkStat, aStat] = await Promise.all([
|
||||
fs.lstat(path.join(outDir, 'link.txt')),
|
||||
@@ -110,42 +115,34 @@ it('should support require by path for legacy builders', () => {
|
||||
});
|
||||
|
||||
describe('Test `detectBuilders`', () => {
|
||||
it('package.json + no build', async () => {
|
||||
const pkg = { dependencies: { next: '9.0.0' } };
|
||||
it('package.json + no build command', async () => {
|
||||
const detected = { framework: { slug: 'next', version: '9.0.0' } };
|
||||
const files = ['package.json', 'pages/index.js', 'public/index.html'];
|
||||
const { builders, errors } = await detectBuilders(files, pkg);
|
||||
expect(builders).toBe(null);
|
||||
expect(errors.length).toBe(1);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
expect(builders.length).toBe(1);
|
||||
expect(builders[0].src).toBe('public/**/*');
|
||||
expect(builders[0].use).toBe('@now/static');
|
||||
});
|
||||
|
||||
it('package.json + no build + next', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
it('package.json + build command + next', async () => {
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
const files = ['package.json', 'pages/index.js'];
|
||||
const { builders, errors } = await detectBuilders(files, pkg);
|
||||
const { builders, errors } = await detectBuilders(files, detected);
|
||||
expect(builders[0].use).toBe('@now/next');
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it('package.json + no build + next', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
devDependencies: { next: '9.0.0' },
|
||||
};
|
||||
const files = ['package.json', 'pages/index.js'];
|
||||
const { builders, errors } = await detectBuilders(files, pkg);
|
||||
expect(builders[0].use).toBe('@now/next');
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it('package.json + no build', async () => {
|
||||
const pkg = {};
|
||||
it('no detectors + no build command', async () => {
|
||||
const files = ['package.json'];
|
||||
const { builders, errors } = await detectBuilders(files, pkg);
|
||||
const { builders, errors } = await detectBuilders(files, {});
|
||||
expect(builders).toBe(null);
|
||||
expect(errors.length).toBe(1);
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it('static file', async () => {
|
||||
@@ -155,7 +152,7 @@ describe('Test `detectBuilders`', () => {
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it('no package.json + public', async () => {
|
||||
it('no package.json + public + api', async () => {
|
||||
const files = ['api/users.js', 'public/index.html'];
|
||||
const { builders, errors } = await detectBuilders(files);
|
||||
expect(builders[1].use).toBe('@now/static');
|
||||
@@ -173,7 +170,7 @@ describe('Test `detectBuilders`', () => {
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it('package.json + no build + root + api', async () => {
|
||||
it('no package.json + no build command + root + api', async () => {
|
||||
const files = ['index.html', 'api/[endpoint].js', 'static/image.png'];
|
||||
const { builders, errors } = await detectBuilders(files);
|
||||
expect(builders[0].use).toBe('@now/node');
|
||||
@@ -198,13 +195,17 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('api + next + public', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
devDependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['package.json', 'api/endpoint.js', 'public/index.html'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
expect(builders[0].use).toBe('@now/node');
|
||||
expect(builders[0].src).toBe('api/endpoint.js');
|
||||
expect(builders[1].use).toBe('@now/next');
|
||||
@@ -213,13 +214,17 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('api + next + raw static', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
devDependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['package.json', 'api/endpoint.js', 'index.html'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
expect(builders[0].use).toBe('@now/node');
|
||||
expect(builders[0].src).toBe('api/endpoint.js');
|
||||
expect(builders[1].use).toBe('@now/next');
|
||||
@@ -263,61 +268,85 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('next + public', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
devDependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['package.json', 'public/index.html', 'README.md'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
expect(builders[0].use).toBe('@now/next');
|
||||
expect(builders[0].src).toBe('package.json');
|
||||
expect(builders.length).toBe(1);
|
||||
});
|
||||
|
||||
it('nuxt', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'nuxt build' },
|
||||
dependencies: { nuxt: '2.8.1' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: '@vue/cli-service',
|
||||
version: '2.8.1',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['package.json', 'pages/index.js'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
expect(builders[0].use).toBe('@now/static-build');
|
||||
expect(builders[0].src).toBe('package.json');
|
||||
expect(builders.length).toBe(1);
|
||||
});
|
||||
|
||||
it('nuxt + tag canary', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'nuxt build' },
|
||||
dependencies: { nuxt: '2.8.1' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: '@vue/cli-service',
|
||||
version: '2.8.1',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['package.json', 'pages/index.js'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg, { tag: 'canary' });
|
||||
const { builders } = await detectBuilders(files, detected, {
|
||||
tag: 'canary',
|
||||
});
|
||||
expect(builders[0].use).toBe('@now/static-build@canary');
|
||||
expect(builders[0].src).toBe('package.json');
|
||||
expect(builders.length).toBe(1);
|
||||
});
|
||||
|
||||
it('package.json with no build + api', async () => {
|
||||
const pkg = { dependencies: { next: '9.0.0' } };
|
||||
it('no build command + api', async () => {
|
||||
const detected = {
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
const files = ['package.json', 'api/[endpoint].js'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
expect(builders[0].use).toBe('@now/node');
|
||||
expect(builders[0].src).toBe('api/[endpoint].js');
|
||||
expect(builders.length).toBe(1);
|
||||
});
|
||||
|
||||
it('package.json with no build + public directory', async () => {
|
||||
const pkg = { dependencies: { next: '9.0.0' } };
|
||||
it('no build command + public directory', async () => {
|
||||
const detected = {
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
const files = ['package.json', 'public/index.html'];
|
||||
|
||||
const { builders, errors } = await detectBuilders(files, pkg);
|
||||
expect(builders).toBe(null);
|
||||
expect(errors.length).toBe(1);
|
||||
const { builders, errors } = await detectBuilders(files, detected);
|
||||
expect(builders.length).toBe(1);
|
||||
expect(errors).toBe(null);
|
||||
});
|
||||
|
||||
it('no package.json + api', async () => {
|
||||
@@ -336,17 +365,23 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('package.json + api + canary', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = [
|
||||
'pages/index.js',
|
||||
'api/[endpoint].js',
|
||||
'api/[endpoint]/[id].js',
|
||||
];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg, { tag: 'canary' });
|
||||
const { builders } = await detectBuilders(files, detected, {
|
||||
tag: 'canary',
|
||||
});
|
||||
expect(builders[0].use).toBe('@now/node@canary');
|
||||
expect(builders[1].use).toBe('@now/node@canary');
|
||||
expect(builders[2].use).toBe('@now/next@canary');
|
||||
@@ -354,17 +389,23 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('package.json + api + latest', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = [
|
||||
'pages/index.js',
|
||||
'api/[endpoint].js',
|
||||
'api/[endpoint]/[id].js',
|
||||
];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg, { tag: 'latest' });
|
||||
const { builders } = await detectBuilders(files, detected, {
|
||||
tag: 'latest',
|
||||
});
|
||||
expect(builders[0].use).toBe('@now/node@latest');
|
||||
expect(builders[1].use).toBe('@now/node@latest');
|
||||
expect(builders[2].use).toBe('@now/next@latest');
|
||||
@@ -372,17 +413,21 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('package.json + api + random tag', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = [
|
||||
'pages/index.js',
|
||||
'api/[endpoint].js',
|
||||
'api/[endpoint]/[id].js',
|
||||
];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg, { tag: 'haha' });
|
||||
const { builders } = await detectBuilders(files, detected, { tag: 'haha' });
|
||||
expect(builders[0].use).toBe('@now/node@haha');
|
||||
expect(builders[1].use).toBe('@now/node@haha');
|
||||
expect(builders[2].use).toBe('@now/next@haha');
|
||||
@@ -390,13 +435,20 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('next.js pages/api + api', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['api/user.js', 'pages/api/user.js'];
|
||||
|
||||
const { warnings, errors, builders } = await detectBuilders(files, pkg);
|
||||
const { warnings, errors, builders } = await detectBuilders(
|
||||
files,
|
||||
detected
|
||||
);
|
||||
|
||||
expect(errors).toBe(null);
|
||||
expect(warnings[0]).toBeDefined();
|
||||
@@ -420,9 +472,12 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('functions with nextjs', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
const functions = {
|
||||
'pages/api/teams/**': {
|
||||
@@ -435,7 +490,7 @@ describe('Test `detectBuilders`', () => {
|
||||
'pages/index.js',
|
||||
'pages/api/teams/members.ts',
|
||||
];
|
||||
const { builders, errors } = await detectBuilders(files, pkg, {
|
||||
const { builders, errors } = await detectBuilders(files, detected, {
|
||||
functions,
|
||||
});
|
||||
|
||||
@@ -446,6 +501,7 @@ describe('Test `detectBuilders`', () => {
|
||||
use: '@now/next',
|
||||
config: {
|
||||
zeroConfig: true,
|
||||
buildCommand: 'yarn build',
|
||||
functions: {
|
||||
'pages/api/teams/**': {
|
||||
memory: 128,
|
||||
@@ -457,9 +513,12 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('extend with functions', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
const functions = {
|
||||
'api/users/*.ts': {
|
||||
@@ -476,7 +535,7 @@ describe('Test `detectBuilders`', () => {
|
||||
'api/users/[id].ts',
|
||||
'api/teams/members.ts',
|
||||
];
|
||||
const { builders } = await detectBuilders(files, pkg, { functions });
|
||||
const { builders } = await detectBuilders(files, detected, { functions });
|
||||
|
||||
expect(builders.length).toBe(3);
|
||||
expect(builders[0]).toEqual({
|
||||
@@ -509,6 +568,7 @@ describe('Test `detectBuilders`', () => {
|
||||
use: '@now/next',
|
||||
config: {
|
||||
zeroConfig: true,
|
||||
buildCommand: 'yarn build',
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -607,31 +667,23 @@ describe('Test `detectBuilders`', () => {
|
||||
});
|
||||
|
||||
it('Do not allow functions that are not used by @now/next', async () => {
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
dependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const functions = { 'test.js': { memory: 1024 } };
|
||||
const files = ['pages/index.js', 'test.js'];
|
||||
|
||||
const { errors } = await detectBuilders(files, pkg, { functions });
|
||||
const { errors } = await detectBuilders(files, detected, { functions });
|
||||
|
||||
expect(errors).toBeDefined();
|
||||
expect(errors[0].code).toBe('unused_function');
|
||||
});
|
||||
|
||||
it('Do not allow function non Community Runtimes', async () => {
|
||||
const functions = {
|
||||
'api/test.js': { memory: 128, runtime: '@now/node@1.0.0' },
|
||||
};
|
||||
const files = ['api/test.js'];
|
||||
|
||||
const { errors } = await detectBuilders(files, null, { functions });
|
||||
|
||||
expect(errors).toBeDefined();
|
||||
expect(errors[0].code).toBe('invalid_function_runtime');
|
||||
});
|
||||
|
||||
it('Must include includeFiles config property', async () => {
|
||||
const functions = {
|
||||
'api/test.js': { includeFiles: 'text/include.txt' },
|
||||
@@ -731,6 +783,145 @@ describe('Test `detectBuilders`', () => {
|
||||
expect(errors).not.toBe(null);
|
||||
expect(errors[0].code).toBe('invalid_function_source');
|
||||
});
|
||||
|
||||
it('Custom static output directory', async () => {
|
||||
const detected = {
|
||||
outputDirectory: 'dist',
|
||||
};
|
||||
|
||||
const files = ['dist/index.html', 'dist/style.css'];
|
||||
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
|
||||
expect(builders.length).toBe(1);
|
||||
expect(builders[0].src).toBe('dist/**/*');
|
||||
expect(builders[0].use).toBe('@now/static');
|
||||
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
|
||||
expect(defaultRoutes.length).toBe(1);
|
||||
expect(defaultRoutes[0].src).toBe('/(.*)');
|
||||
expect(defaultRoutes[0].dest).toBe('/dist/$1');
|
||||
});
|
||||
|
||||
it('Custom static output directory with api', async () => {
|
||||
const detected = {
|
||||
outputDirectory: 'output',
|
||||
};
|
||||
|
||||
const files = ['api/user.ts', 'output/index.html', 'output/style.css'];
|
||||
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
|
||||
expect(builders.length).toBe(2);
|
||||
expect(builders[1].src).toBe('output/**/*');
|
||||
expect(builders[1].use).toBe('@now/static');
|
||||
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
|
||||
expect(defaultRoutes.length).toBe(3);
|
||||
expect(defaultRoutes[1].status).toBe(404);
|
||||
expect(defaultRoutes[2].src).toBe('/(.*)');
|
||||
expect(defaultRoutes[2].dest).toBe('/output/$1');
|
||||
});
|
||||
|
||||
it('Custom directory for Serverless Functions', async () => {
|
||||
const files = ['server/_lib/db.ts', 'server/user.ts', 'server/team.ts'];
|
||||
|
||||
const functions = {
|
||||
'server/**/*.ts': {
|
||||
memory: 128,
|
||||
runtime: '@now/node@1.2.1',
|
||||
},
|
||||
};
|
||||
|
||||
const { builders } = await detectBuilders(files, null, { functions });
|
||||
|
||||
expect(builders.length).toBe(3);
|
||||
expect(builders[0]).toEqual({
|
||||
use: '@now/node@1.2.1',
|
||||
src: 'server/team.ts',
|
||||
config: {
|
||||
zeroConfig: true,
|
||||
functions: {
|
||||
'server/**/*.ts': {
|
||||
memory: 128,
|
||||
runtime: '@now/node@1.2.1',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(builders[1]).toEqual({
|
||||
use: '@now/node@1.2.1',
|
||||
src: 'server/user.ts',
|
||||
config: {
|
||||
zeroConfig: true,
|
||||
functions: {
|
||||
'server/**/*.ts': {
|
||||
memory: 128,
|
||||
runtime: '@now/node@1.2.1',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
// This is expected, since only "api + full static" is supported
|
||||
// no other directory, so everything else will be deployed
|
||||
expect(builders[2].use).toBe('@now/static');
|
||||
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
|
||||
expect(defaultRoutes.length).toBe(3);
|
||||
expect(defaultRoutes[0].dest).toBe('/server/team.ts');
|
||||
expect(defaultRoutes[0].src).toBe('^/server/(team\\/|team|team\\.ts)$');
|
||||
expect(defaultRoutes[1].dest).toBe('/server/user.ts');
|
||||
expect(defaultRoutes[1].src).toBe('^/server/(user\\/|user|user\\.ts)$');
|
||||
expect(defaultRoutes[2].status).toBe(404);
|
||||
});
|
||||
|
||||
it('Custom directory for Serverless Functions + Next.js', async () => {
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const functions = {
|
||||
'server/**/*.ts': {
|
||||
runtime: '@now/node@1.2.1',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['package.json', 'pages/index.ts', 'server/user.ts'];
|
||||
|
||||
const { builders } = await detectBuilders(files, detected, { functions });
|
||||
|
||||
expect(builders.length).toBe(2);
|
||||
expect(builders[0]).toEqual({
|
||||
use: '@now/node@1.2.1',
|
||||
src: 'server/user.ts',
|
||||
config: {
|
||||
zeroConfig: true,
|
||||
functions,
|
||||
},
|
||||
});
|
||||
expect(builders[1]).toEqual({
|
||||
use: '@now/next',
|
||||
src: 'package.json',
|
||||
config: {
|
||||
buildCommand: 'yarn build',
|
||||
zeroConfig: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
|
||||
expect(defaultRoutes.length).toBe(2);
|
||||
expect(defaultRoutes[0].dest).toBe('/server/user.ts');
|
||||
expect(defaultRoutes[0].src).toBe('^/server/(user\\/|user|user\\.ts)$');
|
||||
expect(defaultRoutes[1].status).toBe(404);
|
||||
});
|
||||
});
|
||||
|
||||
it('Test `detectRoutes`', async () => {
|
||||
@@ -804,13 +995,17 @@ it('Test `detectRoutes`', async () => {
|
||||
}
|
||||
|
||||
{
|
||||
const pkg = {
|
||||
scripts: { build: 'next build' },
|
||||
devDependencies: { next: '9.0.0' },
|
||||
const detected = {
|
||||
buildCommand: 'yarn build',
|
||||
framework: {
|
||||
slug: 'next',
|
||||
version: '9.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
const files = ['public/index.html', 'api/[endpoint].js'];
|
||||
|
||||
const { builders } = await detectBuilders(files, pkg);
|
||||
const { builders } = await detectBuilders(files, detected);
|
||||
const { defaultRoutes } = await detectRoutes(files, builders);
|
||||
expect(defaultRoutes[1].status).toBe(404);
|
||||
expect(defaultRoutes[1].src).toBe('/api(\\/.*)?$');
|
||||
|
||||
@@ -3,6 +3,7 @@ const { mkdirp, copyFile } = require('fs-extra');
|
||||
|
||||
const {
|
||||
glob,
|
||||
debug,
|
||||
download,
|
||||
shouldServe,
|
||||
createLambda,
|
||||
@@ -14,7 +15,6 @@ exports.analyze = ({ files, entrypoint }) => files[entrypoint].digest;
|
||||
exports.version = 3;
|
||||
|
||||
exports.build = async ({ workPath, files, entrypoint, meta, config }) => {
|
||||
console.log('downloading files...');
|
||||
const outDir = await getWritableDirectory();
|
||||
|
||||
await download(files, workPath, meta);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/cgi",
|
||||
"version": "1.0.1-canary.0",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "now",
|
||||
"version": "16.6.3",
|
||||
"version": "16.7.0",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Now",
|
||||
@@ -146,7 +146,6 @@
|
||||
"ora": "3.4.0",
|
||||
"pcre-to-regexp": "1.0.0",
|
||||
"pluralize": "7.0.0",
|
||||
"pre-commit": "1.2.2",
|
||||
"printf": "0.2.5",
|
||||
"progress": "2.0.3",
|
||||
"promisepipe": "3.0.0",
|
||||
|
||||
@@ -38,7 +38,6 @@ import {
|
||||
} from '../../util/errors-ts';
|
||||
import { SchemaValidationFailed } from '../../util/errors';
|
||||
import purchaseDomainIfAvailable from '../../util/domains/purchase-domain-if-available';
|
||||
import handleCertError from '../../util/certs/handle-cert-error';
|
||||
import isWildcardAlias from '../../util/alias/is-wildcard-alias';
|
||||
import shouldDeployDir from '../../util/deploy/should-deploy-dir';
|
||||
|
||||
@@ -382,15 +381,13 @@ export default async function main(
|
||||
return 1;
|
||||
}
|
||||
|
||||
const deploymentResponse = handleCertError(
|
||||
output,
|
||||
await getDeploymentByIdOrHost(now, contextName, deployment.id, 'v10')
|
||||
const deploymentResponse = await getDeploymentByIdOrHost(
|
||||
now,
|
||||
contextName,
|
||||
deployment.id,
|
||||
'v10'
|
||||
);
|
||||
|
||||
if (deploymentResponse === 1) {
|
||||
return deploymentResponse;
|
||||
}
|
||||
|
||||
if (
|
||||
deploymentResponse instanceof DeploymentNotFound ||
|
||||
deploymentResponse instanceof DeploymentPermissionDenied ||
|
||||
@@ -400,10 +397,6 @@ export default async function main(
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (handleCertError(output, deployment) === 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (deployment === null) {
|
||||
error('Uploading failed. Please try again.');
|
||||
return 1;
|
||||
|
||||
@@ -70,7 +70,6 @@ import {
|
||||
InvalidRegionOrDCForScale,
|
||||
} from '../../util/errors';
|
||||
import { SchemaValidationFailed } from '../../util/errors';
|
||||
import handleCertError from '../../util/certs/handle-cert-error';
|
||||
import readPackage from '../../util/read-package';
|
||||
|
||||
interface Env {
|
||||
@@ -801,11 +800,6 @@ async function sync({
|
||||
createArgs
|
||||
);
|
||||
|
||||
const handledResult = handleCertError(output, deployment);
|
||||
if (handledResult === 1) {
|
||||
return handledResult;
|
||||
}
|
||||
|
||||
if (
|
||||
deployment instanceof DomainNotFound ||
|
||||
deployment instanceof NotDomainOwner ||
|
||||
|
||||
@@ -18,7 +18,7 @@ export default async function dev(
|
||||
output: Output
|
||||
) {
|
||||
output.dim(
|
||||
`Now CLI ${pkg.version} dev (beta) — https://zeit.co/feedback/dev`
|
||||
`Now CLI ${pkg.version} dev (beta) — https://zeit.co/feedback`
|
||||
);
|
||||
|
||||
const [dir = '.'] = args;
|
||||
|
||||
@@ -10,6 +10,7 @@ import formatDate from '../../util/format-date';
|
||||
import formatNSTable from '../../util/format-ns-table';
|
||||
import getDomainByName from '../../util/domains/get-domain-by-name';
|
||||
import getScope from '../../util/get-scope';
|
||||
import getDomainPrice from '../../util/domains/get-domain-price';
|
||||
|
||||
type Options = {
|
||||
'--debug': boolean;
|
||||
@@ -23,7 +24,7 @@ export default async function inspect(
|
||||
) {
|
||||
const {
|
||||
authConfig: { token },
|
||||
config
|
||||
config,
|
||||
} = ctx;
|
||||
const { currentTeam } = config;
|
||||
const { apiUrl } = ctx;
|
||||
@@ -61,7 +62,12 @@ export default async function inspect(
|
||||
}
|
||||
|
||||
output.debug(`Fetching domain info`);
|
||||
const domain = await getDomainByName(client, contextName, domainName);
|
||||
const [domain, renewalPrice] = await Promise.all([
|
||||
getDomainByName(client, contextName, domainName),
|
||||
getDomainPrice(client, domainName, 'renewal')
|
||||
.then(res => (res instanceof Error ? null : res.price))
|
||||
.catch(() => null),
|
||||
]);
|
||||
if (domain instanceof DomainNotFound) {
|
||||
output.error(
|
||||
`Domain not found by "${domainName}" under ${chalk.bold(contextName)}`
|
||||
@@ -104,24 +110,35 @@ export default async function inspect(
|
||||
` ${chalk.cyan('Bought At')}\t\t\t${formatDate(domain.boughtAt)}\n`
|
||||
);
|
||||
output.print(
|
||||
` ${chalk.cyan('Transferred At')}\t\t${formatDate(domain.transferredAt)}\n`
|
||||
` ${chalk.cyan('Transferred At')}\t\t${formatDate(
|
||||
domain.transferredAt
|
||||
)}\n`
|
||||
);
|
||||
output.print(
|
||||
` ${chalk.cyan('Expires At')}\t\t\t${formatDate(domain.expiresAt)}\n`
|
||||
);
|
||||
output.print(
|
||||
` ${chalk.cyan('NS Verified At')}\t\t${formatDate(domain.nsVerifiedAt)}\n`
|
||||
` ${chalk.cyan('NS Verified At')}\t\t${formatDate(
|
||||
domain.nsVerifiedAt
|
||||
)}\n`
|
||||
);
|
||||
output.print(
|
||||
` ${chalk.cyan('TXT Verified At')}\t\t${formatDate(domain.txtVerifiedAt)}\n`
|
||||
` ${chalk.cyan('TXT Verified At')}\t\t${formatDate(
|
||||
domain.txtVerifiedAt
|
||||
)}\n`
|
||||
);
|
||||
output.print(` ${chalk.cyan('CDN Enabled')}\t\t${true}\n`);
|
||||
if (renewalPrice && domain.boughtAt) {
|
||||
output.print(
|
||||
` ${chalk.cyan('Renewal Price')}\t\t$${renewalPrice} USD\n`
|
||||
);
|
||||
}
|
||||
output.print(` ${chalk.cyan('CDN Enabled')}\t\t\t${true}\n`);
|
||||
output.print('\n');
|
||||
|
||||
output.print(chalk.bold(' Nameservers\n\n'));
|
||||
output.print(
|
||||
`${formatNSTable(domain.intendedNameservers, domain.nameservers, {
|
||||
extraSpace: ' '
|
||||
extraSpace: ' ',
|
||||
})}\n`
|
||||
);
|
||||
output.print('\n');
|
||||
@@ -129,7 +146,7 @@ export default async function inspect(
|
||||
output.print(chalk.bold(' Verification Record\n\n'));
|
||||
output.print(
|
||||
`${dnsTable([['_now', 'TXT', domain.verificationRecord]], {
|
||||
extraSpace: ' '
|
||||
extraSpace: ' ',
|
||||
})}\n`
|
||||
);
|
||||
output.print('\n');
|
||||
|
||||
@@ -22,6 +22,8 @@ import {
|
||||
PackageJson,
|
||||
detectBuilders,
|
||||
detectRoutes,
|
||||
detectDefaults,
|
||||
DetectorFilesystem,
|
||||
} from '@now/build-utils';
|
||||
|
||||
import { once } from '../once';
|
||||
@@ -100,6 +102,25 @@ function sortBuilders(buildA: Builder, buildB: Builder) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
class DevDetectorFilesystem extends DetectorFilesystem {
|
||||
private dir: string;
|
||||
private files: string[];
|
||||
|
||||
constructor(dir: string, files: string[]) {
|
||||
super();
|
||||
this.dir = dir;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
_exists(name: string): Promise<boolean> {
|
||||
return Promise.resolve(this.files.includes(name));
|
||||
}
|
||||
|
||||
_readFile(name: string): Promise<Buffer> {
|
||||
return fs.readFile(join(this.dir, name));
|
||||
}
|
||||
}
|
||||
|
||||
export default class DevServer {
|
||||
public cwd: string;
|
||||
public debug: boolean;
|
||||
@@ -477,8 +498,6 @@ export default class DevServer {
|
||||
return this.cachedNowConfig;
|
||||
}
|
||||
|
||||
const pkg = await this.getPackageJson();
|
||||
|
||||
// The default empty `now.json` is used to serve all files as static
|
||||
// when no `now.json` is present
|
||||
let config: NowConfig = this.cachedNowConfig || { version: 2 };
|
||||
@@ -526,11 +545,19 @@ export default class DevServer {
|
||||
|
||||
// no builds -> zero config
|
||||
if (!config.builds || config.builds.length === 0) {
|
||||
const { builders, warnings, errors } = await detectBuilders(files, pkg, {
|
||||
tag: getDistTag(cliVersion) === 'canary' ? 'canary' : 'latest',
|
||||
functions: config.functions,
|
||||
const detectorResult = await detectDefaults({
|
||||
fs: new DevDetectorFilesystem(this.cwd, files),
|
||||
});
|
||||
|
||||
const { builders, warnings, errors } = await detectBuilders(
|
||||
files,
|
||||
detectorResult,
|
||||
{
|
||||
tag: getDistTag(cliVersion) === 'canary' ? 'canary' : 'latest',
|
||||
functions: config.functions,
|
||||
}
|
||||
);
|
||||
|
||||
if (errors) {
|
||||
this.output.error(errors[0].message);
|
||||
await this.exit();
|
||||
@@ -575,29 +602,6 @@ export default class DevServer {
|
||||
return config;
|
||||
}
|
||||
|
||||
async getPackageJson(): Promise<PackageJson | null> {
|
||||
const pkgPath = join(this.cwd, 'package.json');
|
||||
let pkg: PackageJson | null = null;
|
||||
|
||||
this.output.debug('Reading `package.json` file');
|
||||
|
||||
try {
|
||||
pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
this.output.debug('No `package.json` file present');
|
||||
} else if (err.name === 'SyntaxError') {
|
||||
this.output.warn(
|
||||
`There is a syntax error in the \`package.json\` file: ${err.message}`
|
||||
);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
return pkg;
|
||||
}
|
||||
|
||||
async tryValidateOrExit(
|
||||
config: NowConfig,
|
||||
validate: (c: NowConfig) => string | null
|
||||
|
||||
@@ -8,62 +8,10 @@ import {
|
||||
trailingSlashSchema,
|
||||
} from '@now/routing-utils';
|
||||
import { NowConfig } from './types';
|
||||
import { functionsSchema, buildsSchema } from '@now/build-utils';
|
||||
|
||||
const ajv = new Ajv();
|
||||
|
||||
const buildsSchema = {
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
maxItems: 128,
|
||||
items: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['use'],
|
||||
properties: {
|
||||
src: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
maxLength: 4096,
|
||||
},
|
||||
use: {
|
||||
type: 'string',
|
||||
minLength: 3,
|
||||
maxLength: 256,
|
||||
},
|
||||
config: { type: 'object' },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const functionsSchema = {
|
||||
type: 'object',
|
||||
minProperties: 1,
|
||||
maxProperties: 50,
|
||||
additionalProperties: false,
|
||||
patternProperties: {
|
||||
'^.{1,256}$': {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
runtime: {
|
||||
type: 'string',
|
||||
maxLength: 256,
|
||||
},
|
||||
memory: {
|
||||
enum: Object.keys(Array.from({ length: 50 }))
|
||||
.slice(2, 48)
|
||||
.map(x => Number(x) * 64),
|
||||
},
|
||||
maxDuration: {
|
||||
type: 'number',
|
||||
minimum: 1,
|
||||
maximum: 900,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const validateBuilds = ajv.compile(buildsSchema);
|
||||
const validateRoutes = ajv.compile(routesSchema);
|
||||
const validateCleanUrls = ajv.compile(cleanUrlsSchema);
|
||||
|
||||
@@ -1097,7 +1097,7 @@ export class LambdaSizeExceededError extends NowError<
|
||||
size
|
||||
).toLowerCase()}) exceeds the maximum size limit (${bytes(
|
||||
maxLambdaSize
|
||||
).toLowerCase()}). Learn more: https://zeit.co/docs/v2/deployments/concepts/lambdas/#maximum-bundle-size`,
|
||||
).toLowerCase()}).`,
|
||||
meta: { size, maxLambdaSize },
|
||||
});
|
||||
}
|
||||
|
||||
1
packages/now-cli/test/dev/fixtures/public-and-server-as-api/.gitignore
vendored
Normal file
1
packages/now-cli/test/dev/fixtures/public-and-server-as-api/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!public
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"functions": {
|
||||
"server/**/*.js": {
|
||||
"runtime": "@now/node@1.2.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
This is content.
|
||||
@@ -0,0 +1,3 @@
|
||||
export default (req, res) => {
|
||||
res.end(`current hour: ${Math.floor(Date.now() / 10000)}`);
|
||||
};
|
||||
@@ -1114,8 +1114,7 @@ if (satisfies(process.version, '>= 8.9.0')) {
|
||||
// start `now dev` detached in child_process
|
||||
dev.unref();
|
||||
|
||||
const result = await fetchWithRetry(`http://localhost:${port}`, 80);
|
||||
const response = await result;
|
||||
const response = await fetchWithRetry(`http://localhost:${port}`, 80);
|
||||
|
||||
validateResponseHeaders(t, response);
|
||||
|
||||
@@ -1134,8 +1133,10 @@ if (satisfies(process.version, '>= 8.9.0')) {
|
||||
test(
|
||||
'[now dev] Use runtime from the functions property',
|
||||
testFixtureStdio('custom-runtime', async (t, port) => {
|
||||
const result = await fetchWithRetry(`http://localhost:${port}/api/user`, 3);
|
||||
const response = await result;
|
||||
const response = await fetchWithRetry(
|
||||
`http://localhost:${port}/api/user`,
|
||||
3
|
||||
);
|
||||
|
||||
validateResponseHeaders(t, response);
|
||||
|
||||
@@ -1143,3 +1144,20 @@ test(
|
||||
t.regex(body, /Hello, from Bash!/gm);
|
||||
})
|
||||
);
|
||||
|
||||
test(
|
||||
'[now dev] Use public with a custom Serverless Function in `server/date.js',
|
||||
testFixtureStdio('public-and-server-as-api', async (t, port) => {
|
||||
const response = await fetchWithRetry(
|
||||
`http://localhost:${port}/server/date`
|
||||
);
|
||||
|
||||
validateResponseHeaders(t, response);
|
||||
|
||||
t.is(response.status, 200);
|
||||
t.is(
|
||||
await response.text(),
|
||||
`current hour: ${Math.floor(Date.now() / 10000)}`
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -466,10 +466,10 @@ CMD ["node", "index.js"]`,
|
||||
autoAlias: true,
|
||||
autoJobCancelation: true,
|
||||
enabled: true,
|
||||
silent: true
|
||||
}
|
||||
})
|
||||
}
|
||||
silent: true,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
for (const typeName of Object.keys(spec)) {
|
||||
|
||||
49
packages/now-cli/test/integration.js
vendored
49
packages/now-cli/test/integration.js
vendored
@@ -493,6 +493,35 @@ test('list the payment methods', async t => {
|
||||
t.true(stdout.startsWith(`> 0 cards found under ${contextName}`));
|
||||
});
|
||||
|
||||
test('domains inspect', async t => {
|
||||
const domainName = `inspect-${contextName}.org`;
|
||||
|
||||
const addRes = await execa(
|
||||
binaryPath,
|
||||
[`domains`, `add`, domainName, ...defaultArgs],
|
||||
{ reject: false }
|
||||
);
|
||||
t.is(addRes.exitCode, 0);
|
||||
|
||||
const { stderr, exitCode } = await execa(
|
||||
binaryPath,
|
||||
['domains', 'inspect', domainName, ...defaultArgs],
|
||||
{
|
||||
reject: false,
|
||||
}
|
||||
);
|
||||
|
||||
const rmRes = await execa(
|
||||
binaryPath,
|
||||
[`domains`, `rm`, domainName, ...defaultArgs],
|
||||
{ reject: false, input: 'y' }
|
||||
);
|
||||
t.is(rmRes.exitCode, 0);
|
||||
|
||||
t.is(exitCode, 0);
|
||||
t.true(!stderr.includes(`Renewal Price`));
|
||||
});
|
||||
|
||||
test('try to purchase a domain', async t => {
|
||||
const { stderr, stdout, exitCode } = await execa(
|
||||
binaryPath,
|
||||
@@ -767,7 +796,19 @@ test('create wildcard alias for deployment', async t => {
|
||||
t.true(stdout.startsWith(goal));
|
||||
|
||||
// Send a test request to the alias
|
||||
const response = await fetch(`https://test.${contextName}.now.sh`);
|
||||
// Retries to make sure we consider the time it takes to update
|
||||
const response = await retry(
|
||||
async () => {
|
||||
const response = await fetch(`https://test.${contextName}.now.sh`);
|
||||
|
||||
if (response.ok) {
|
||||
return response;
|
||||
}
|
||||
|
||||
throw new Error(`Error: Returned code ${response.status}`);
|
||||
},
|
||||
{ retries: 3 }
|
||||
);
|
||||
const content = await response.text();
|
||||
|
||||
t.true(response.ok);
|
||||
@@ -2040,10 +2081,10 @@ test('fail to deploy a Lambda with a specific runtime but without a locked versi
|
||||
});
|
||||
|
||||
test('ensure `github` and `scope` are not sent to the API', async t => {
|
||||
const directory = fixture('github-and-scope-config');
|
||||
const output = await execute([directory]);
|
||||
const directory = fixture('github-and-scope-config');
|
||||
const output = await execute([directory]);
|
||||
|
||||
t.is(output.exitCode, 0, formatOutput(output));
|
||||
t.is(output.exitCode, 0, formatOutput(output));
|
||||
});
|
||||
|
||||
test.after.always(async () => {
|
||||
|
||||
@@ -70,7 +70,6 @@ Learn more: https://github.com/golang/go/wiki/Modules
|
||||
`);
|
||||
}
|
||||
|
||||
debug('Downloading user files...');
|
||||
const entrypointArr = entrypoint.split(sep);
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/go",
|
||||
"version": "1.0.1-canary.0",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/go",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/next",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/next-js",
|
||||
|
||||
@@ -10,25 +10,15 @@ process.on('unhandledRejection', err => {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
async function main(cwd: string) {
|
||||
const next = require(resolveFrom(cwd, 'next'));
|
||||
const app = next({ dev: true, dir: cwd });
|
||||
process.once('message', async ({ dir, runtimeEnv }) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const next = require(resolveFrom(dir, 'next'));
|
||||
const app = next({ dev: true, dir });
|
||||
const handler = app.getRequestHandler();
|
||||
|
||||
const openPort = await getPort({
|
||||
port: [5000, 4000],
|
||||
});
|
||||
|
||||
const [openPort] = await Promise.all([getPort(), app.prepare()]);
|
||||
const url = `http://localhost:${openPort}`;
|
||||
|
||||
// Prepare for incoming requests
|
||||
await app.prepare();
|
||||
|
||||
// The runtime env vars are passed in to `argv[2]`
|
||||
// as a base64-encoded JSON string
|
||||
const runtimeEnv = JSON.parse(
|
||||
Buffer.from(process.argv[2], 'base64').toString()
|
||||
);
|
||||
syncEnvVars(process.env, process.env, runtimeEnv);
|
||||
|
||||
createServer((req, res) => {
|
||||
@@ -39,6 +29,4 @@ async function main(cwd: string) {
|
||||
process.send(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main(process.cwd());
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
readFile,
|
||||
unlink as unlinkFile,
|
||||
writeFile,
|
||||
lstatSync,
|
||||
} from 'fs-extra';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -162,24 +163,20 @@ const name = '[@now/next]';
|
||||
const urls: stringMap = {};
|
||||
|
||||
function startDevServer(entryPath: string, runtimeEnv: EnvConfig) {
|
||||
// The runtime env vars are encoded and passed in as `argv[2]`, so that the
|
||||
// dev-server process can replace them onto `process.env` after the Next.js
|
||||
// "prepare" step
|
||||
const encodedEnv = Buffer.from(JSON.stringify(runtimeEnv)).toString('base64');
|
||||
|
||||
// `env` is omitted since that
|
||||
// makes it default to `process.env`
|
||||
const forked = fork(path.join(__dirname, 'dev-server.js'), [encodedEnv], {
|
||||
// `env` is omitted since that makes it default to `process.env`
|
||||
const forked = fork(path.join(__dirname, 'dev-server.js'), [], {
|
||||
cwd: entryPath,
|
||||
execArgv: [],
|
||||
});
|
||||
|
||||
const getUrl = () =>
|
||||
new Promise<string>((resolve, reject) => {
|
||||
forked.on('message', resolve);
|
||||
forked.on('error', reject);
|
||||
forked.once('message', resolve);
|
||||
forked.once('error', reject);
|
||||
});
|
||||
|
||||
forked.send({ dir: entryPath, runtimeEnv });
|
||||
|
||||
return { forked, getUrl };
|
||||
}
|
||||
|
||||
@@ -201,7 +198,6 @@ export const build = async ({
|
||||
const entryPath = path.join(workPath, entryDirectory);
|
||||
const dotNextStatic = path.join(entryPath, '.next/static');
|
||||
|
||||
debug(`${name} Downloading user files...`);
|
||||
await download(files, workPath, meta);
|
||||
|
||||
const pkg = await readPackageJson(entryPath);
|
||||
@@ -338,6 +334,27 @@ export const build = async ({
|
||||
env.NODE_OPTIONS = `--max_old_space_size=${memoryToConsume}`;
|
||||
await runPackageJsonScript(entryPath, shouldRunScript, { ...spawnOpts, env });
|
||||
|
||||
const routesManifest = await getRoutesManifest(entryPath, realNextVersion);
|
||||
const rewrites: Route[] = [];
|
||||
const redirects: Route[] = [];
|
||||
|
||||
if (routesManifest) {
|
||||
switch (routesManifest.version) {
|
||||
case 1: {
|
||||
redirects.push(...convertRedirects(routesManifest.redirects));
|
||||
rewrites.push(...convertRewrites(routesManifest.rewrites));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// update MIN_ROUTES_MANIFEST_VERSION in ./utils.ts
|
||||
throw new Error(
|
||||
'This version of `@now/next` does not support the version of Next.js you are trying to deploy.\n' +
|
||||
'Please upgrade your `@now/next` builder and try again. Contact support if this continues to happen.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isLegacy) {
|
||||
debug('Running npm install --production...');
|
||||
await runNpmInstall(
|
||||
@@ -583,9 +600,11 @@ export const build = async ({
|
||||
// Initial files are manually added to the lambda later
|
||||
return;
|
||||
}
|
||||
const { mode } = lstatSync(path.join(workPath, file));
|
||||
|
||||
files[file] = new FileFsRef({
|
||||
fsPath: path.join(workPath, file),
|
||||
mode,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -821,8 +840,6 @@ export const build = async ({
|
||||
let dynamicPrefix = path.join('/', entryDirectory);
|
||||
dynamicPrefix = dynamicPrefix === '/' ? '' : dynamicPrefix;
|
||||
|
||||
const routesManifest = await getRoutesManifest(entryPath, realNextVersion);
|
||||
|
||||
const dynamicRoutes = await getDynamicRoutes(
|
||||
entryPath,
|
||||
entryDirectory,
|
||||
@@ -836,26 +853,6 @@ export const build = async ({
|
||||
})
|
||||
);
|
||||
|
||||
const rewrites: Route[] = [];
|
||||
const redirects: Route[] = [];
|
||||
|
||||
if (routesManifest) {
|
||||
switch (routesManifest.version) {
|
||||
case 1: {
|
||||
redirects.push(...convertRedirects(routesManifest.redirects));
|
||||
rewrites.push(...convertRewrites(routesManifest.rewrites));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// update MIN_ROUTES_MANIFEST_VERSION in ./utils.ts
|
||||
throw new Error(
|
||||
'This version of `@now/next` does not support the version of Next.js you are trying to deploy.\n' +
|
||||
'Please upgrade your `@now/next` builder and try again. Contact support if this continues to happen.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
output: {
|
||||
...publicDirectoryFiles,
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
streamToBuffer,
|
||||
Lambda,
|
||||
Route,
|
||||
isSymbolicLink,
|
||||
} from '@now/build-utils';
|
||||
|
||||
type stringMap = { [key: string]: string };
|
||||
@@ -340,6 +341,7 @@ export async function getRoutesManifest(
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const routesManifest: RoutesManifest = require(pathRoutesManifest);
|
||||
|
||||
return routesManifest;
|
||||
@@ -454,11 +456,20 @@ function syncEnvVars(base: EnvConfig, removeEnv: EnvConfig, addEnv: EnvConfig) {
|
||||
export const ExperimentalTraceVersion = `9.0.4-canary.1`;
|
||||
|
||||
export type PseudoLayer = {
|
||||
[fileName: string]: {
|
||||
crc32: number;
|
||||
compBuffer: Buffer;
|
||||
uncompressedSize: number;
|
||||
};
|
||||
[fileName: string]: PseudoFile | PseudoSymbolicLink;
|
||||
};
|
||||
|
||||
export type PseudoFile = {
|
||||
isSymlink: false;
|
||||
crc32: number;
|
||||
compBuffer: Buffer;
|
||||
uncompressedSize: number;
|
||||
};
|
||||
|
||||
export type PseudoSymbolicLink = {
|
||||
isSymlink: true;
|
||||
file: FileFsRef;
|
||||
symlinkTarget: string;
|
||||
};
|
||||
|
||||
const compressBuffer = (buf: Buffer): Promise<Buffer> => {
|
||||
@@ -481,13 +492,22 @@ export async function createPseudoLayer(files: {
|
||||
|
||||
for (const fileName of Object.keys(files)) {
|
||||
const file = files[fileName];
|
||||
const origBuffer = await streamToBuffer(file.toStream());
|
||||
const compBuffer = await compressBuffer(origBuffer);
|
||||
pseudoLayer[fileName] = {
|
||||
compBuffer,
|
||||
crc32: crc32.unsigned(origBuffer),
|
||||
uncompressedSize: origBuffer.byteLength,
|
||||
};
|
||||
|
||||
if (isSymbolicLink(file.mode)) {
|
||||
pseudoLayer[fileName] = {
|
||||
file,
|
||||
isSymlink: true,
|
||||
symlinkTarget: await fs.readlink(file.fsPath),
|
||||
} as PseudoSymbolicLink;
|
||||
} else {
|
||||
const origBuffer = await streamToBuffer(file.toStream());
|
||||
const compBuffer = await compressBuffer(origBuffer);
|
||||
pseudoLayer[fileName] = {
|
||||
compBuffer,
|
||||
crc32: crc32.unsigned(origBuffer),
|
||||
uncompressedSize: origBuffer.byteLength,
|
||||
} as PseudoFile;
|
||||
}
|
||||
}
|
||||
|
||||
return pseudoLayer;
|
||||
@@ -520,10 +540,31 @@ export async function createLambdaFromPseudoLayers({
|
||||
const zipFile = new ZipFile();
|
||||
const addedFiles = new Set();
|
||||
|
||||
const names = Object.keys(files).sort();
|
||||
const symlinkTargets = new Map<string, string>();
|
||||
|
||||
for (const name of names) {
|
||||
const file = files[name];
|
||||
if (file.mode && isSymbolicLink(file.mode) && file.type === 'FileFsRef') {
|
||||
const symlinkTarget = await fs.readlink((file as FileFsRef).fsPath);
|
||||
symlinkTargets.set(name, symlinkTarget);
|
||||
}
|
||||
}
|
||||
|
||||
// apply pseudo layers (already compressed objects)
|
||||
for (const layer of layers) {
|
||||
for (const seedKey of Object.keys(layer)) {
|
||||
const { compBuffer, crc32, uncompressedSize } = layer[seedKey];
|
||||
const item = layer[seedKey];
|
||||
|
||||
if (item.isSymlink) {
|
||||
const { symlinkTarget, file } = item;
|
||||
|
||||
zipFile.addBuffer(Buffer.from(symlinkTarget, 'utf8'), seedKey, {
|
||||
mode: file.mode,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
const { compBuffer, crc32, uncompressedSize } = item;
|
||||
|
||||
// @ts-ignore: `addDeflatedBuffer` is a valid function, but missing on the type
|
||||
zipFile.addDeflatedBuffer(compBuffer, seedKey, {
|
||||
@@ -539,8 +580,16 @@ export async function createLambdaFromPseudoLayers({
|
||||
// was already added in a pseudo layer
|
||||
if (addedFiles.has(fileName)) continue;
|
||||
const file = files[fileName];
|
||||
const fileBuffer = await streamToBuffer(file.toStream());
|
||||
zipFile.addBuffer(fileBuffer, fileName);
|
||||
const symlinkTarget = symlinkTargets.get(fileName);
|
||||
|
||||
if (typeof symlinkTarget === 'string') {
|
||||
zipFile.addBuffer(Buffer.from(symlinkTarget, 'utf8'), fileName, {
|
||||
mode: file.mode,
|
||||
});
|
||||
} else {
|
||||
const fileBuffer = await streamToBuffer(file.toStream());
|
||||
zipFile.addBuffer(fileBuffer, fileName);
|
||||
}
|
||||
}
|
||||
zipFile.end();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "^9.1.2-canary.8",
|
||||
"next": "^9.1.6-canary.1",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6"
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import React from 'react';
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticParams() {
|
||||
export async function unstable_getStaticPaths () {
|
||||
return [
|
||||
'/blog/post-1/comment-1',
|
||||
{ post: 'post-2', comment: 'comment-2' },
|
||||
{ params: { post: 'post-2', comment: 'comment-2' } },
|
||||
'/blog/post-1337/comment-1337',
|
||||
];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps({ params }) {
|
||||
export async function unstable_getStaticProps ({ params }) {
|
||||
return {
|
||||
props: {
|
||||
post: params.post,
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import React from 'react'
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticParams () {
|
||||
export async function unstable_getStaticPaths () {
|
||||
return [
|
||||
'/blog/post-1',
|
||||
{ post: 'post-2' },
|
||||
{ params: { post: 'post-2' } },
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
export async function unstable_getStaticProps ({ params }) {
|
||||
if (params.post === 'post-10') {
|
||||
|
||||
6
packages/now-next/test/fixtures/09-yarn-workspaces/.gitignore
vendored
Normal file
6
packages/now-next/test/fixtures/09-yarn-workspaces/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
.next
|
||||
.env
|
||||
tsconfig.tsbuildinfo
|
||||
.DS_Store
|
||||
*.log
|
||||
5
packages/now-next/test/fixtures/09-yarn-workspaces/lerna.json
vendored
Normal file
5
packages/now-next/test/fixtures/09-yarn-workspaces/lerna.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"packages": ["packages/*"],
|
||||
"npmClient": "yarn",
|
||||
"version": "0.0.0"
|
||||
}
|
||||
11
packages/now-next/test/fixtures/09-yarn-workspaces/now.json
vendored
Normal file
11
packages/now-next/test/fixtures/09-yarn-workspaces/now.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "packages/web/next.config.js", "use": "@now/next" }],
|
||||
"routes": [{ "src": "/(.*)", "dest": "/packages/web/$1", "continue": true }],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/",
|
||||
"mustContain": "hello world <!-- -->6"
|
||||
}
|
||||
]
|
||||
}
|
||||
14
packages/now-next/test/fixtures/09-yarn-workspaces/package.json
vendored
Normal file
14
packages/now-next/test/fixtures/09-yarn-workspaces/package.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"private": true,
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
"packages/*"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "lerna run build --scope=@jimmy/common"
|
||||
},
|
||||
"devDependencies": {
|
||||
"lerna": "^3.19.0"
|
||||
}
|
||||
}
|
||||
1
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/dist/index.d.ts
vendored
Normal file
1
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/dist/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const add: (a: number, b: number) => number;
|
||||
6
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/dist/index.js
vendored
Normal file
6
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/dist/index.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.add = (a, b) => {
|
||||
return a + b;
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/dist/index.js.map
vendored
Normal file
1
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/dist/index.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAa,QAAA,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;IAC1C,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC"}
|
||||
14
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/package.json
vendored
Normal file
14
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/package.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "@jimmy/common",
|
||||
"version": "1.0.64",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"watch": "tsc -w",
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^3.7.3"
|
||||
}
|
||||
}
|
||||
3
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/src/index.ts
vendored
Normal file
3
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/src/index.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export const add = (a: number, b: number) => {
|
||||
return a + b;
|
||||
};
|
||||
32
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/tsconfig.json
vendored
Normal file
32
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/tsconfig.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"removeComments": true,
|
||||
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
"composite": true,
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"lib": ["dom", "es2017", "esnext.asynciterable", "es2017.object"],
|
||||
"declaration": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
|
||||
"exclude": ["dist"]
|
||||
}
|
||||
2029
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/tsconfig.tsbuildinfo
vendored
Normal file
2029
packages/now-next/test/fixtures/09-yarn-workspaces/packages/common/tsconfig.tsbuildinfo
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/next-env.d.ts
vendored
Normal file
2
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/types/global" />
|
||||
1
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/next.config.js
vendored
Normal file
1
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/next.config.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = {};
|
||||
24
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/package.json
vendored
Normal file
24
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/package.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@jimmy/web",
|
||||
"version": "1.0.67",
|
||||
"scripts": {
|
||||
"dev": "next",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jimmy/common": "^1.0.64",
|
||||
"next": "^9.1.4",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-syntax-class-properties": "^7.7.4",
|
||||
"@types/next": "^9.0.0",
|
||||
"@types/node": "^12.12.14",
|
||||
"@types/react": "^16.9.15",
|
||||
"@types/react-dom": "16.9.4",
|
||||
"typescript": "3.7.3"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
||||
58
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/pages/_app.tsx
vendored
Normal file
58
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/pages/_app.tsx
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import App from "next/app";
|
||||
import React from "react";
|
||||
|
||||
class MyApp extends App<any> {
|
||||
static async getInitialProps() {
|
||||
console.log("i am props");
|
||||
return { q: 5, pageProps: {} };
|
||||
}
|
||||
|
||||
render() {
|
||||
const { Component, pageProps } = this.props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>yo</div>
|
||||
<Component {...pageProps} />
|
||||
<style jsx global>
|
||||
{`
|
||||
html {
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
body,
|
||||
body > div {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
div,
|
||||
input,
|
||||
form,
|
||||
li,
|
||||
ul {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default MyApp;
|
||||
5
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/pages/index.tsx
vendored
Normal file
5
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/pages/index.tsx
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { add } from "@jimmy/common";
|
||||
|
||||
export default () => {
|
||||
return <div>hello world {add(1, 5)}</div>;
|
||||
};
|
||||
26
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/tsconfig.json
vendored
Normal file
26
packages/now-next/test/fixtures/09-yarn-workspaces/packages/web/tsconfig.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"jsx": "preserve",
|
||||
"lib": ["dom", "es2017"],
|
||||
"baseUrl": ".",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"noEmit": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"isolatedModules": true,
|
||||
"removeComments": false,
|
||||
"preserveConstEnums": true,
|
||||
"sourceMap": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"exclude": ["dist", ".next", "out", "next.config.js"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
|
||||
}
|
||||
8464
packages/now-next/test/fixtures/09-yarn-workspaces/yarn.lock
vendored
Normal file
8464
packages/now-next/test/fixtures/09-yarn-workspaces/yarn.lock
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ const FOUR_MINUTES = 240000;
|
||||
|
||||
beforeAll(() => {
|
||||
process.env.NEXT_TELEMETRY_DISABLED = '1';
|
||||
})
|
||||
});
|
||||
|
||||
it(
|
||||
'Should build the standard example',
|
||||
|
||||
@@ -8,7 +8,7 @@ jest.setTimeout(45000);
|
||||
|
||||
beforeAll(() => {
|
||||
process.env.NEXT_TELEMETRY_DISABLED = '1';
|
||||
})
|
||||
});
|
||||
|
||||
describe('build meta dev', () => {
|
||||
const files = {
|
||||
@@ -18,40 +18,40 @@ describe('build meta dev', () => {
|
||||
module.exports = {
|
||||
target: 'serverless'
|
||||
}
|
||||
`
|
||||
`,
|
||||
}),
|
||||
'pages/index.js': new FileBlob({
|
||||
mode: 0o777,
|
||||
data: `
|
||||
export default () => 'Index page'
|
||||
`
|
||||
`,
|
||||
}),
|
||||
'pages/nested/[param].js': new FileBlob({
|
||||
mode: 0o777,
|
||||
data: `
|
||||
export default () => 'Dynamic page'
|
||||
`
|
||||
`,
|
||||
}),
|
||||
'pages/nested/page.tsx': new FileBlob({
|
||||
mode: 0o777,
|
||||
data: `
|
||||
export default () => 'Nested page'
|
||||
`
|
||||
`,
|
||||
}),
|
||||
'pages/api/test.js': new FileBlob({
|
||||
mode: 0o777,
|
||||
data: `
|
||||
export default (req, res) => res.status(200).end('API Route')
|
||||
`
|
||||
`,
|
||||
}),
|
||||
// This file should be omitted because `pages/index.js` will use the same route
|
||||
'public/index': new FileBlob({
|
||||
mode: 0o777,
|
||||
data: 'text'
|
||||
data: 'text',
|
||||
}),
|
||||
'public/data.txt': new FileBlob({
|
||||
mode: 0o777,
|
||||
data: 'data'
|
||||
data: 'data',
|
||||
}),
|
||||
'package.json': new FileBlob({
|
||||
mode: 0o777,
|
||||
@@ -71,8 +71,8 @@ describe('build meta dev', () => {
|
||||
"typescript": "3"
|
||||
}
|
||||
}
|
||||
`
|
||||
})
|
||||
`,
|
||||
}),
|
||||
};
|
||||
const entrypoint = 'next.config.js';
|
||||
const workPath = path.join(
|
||||
@@ -92,7 +92,7 @@ describe('build meta dev', () => {
|
||||
await execa('yarn', ['install'], {
|
||||
cwd: workPath,
|
||||
env: process.env,
|
||||
reject: true
|
||||
reject: true,
|
||||
});
|
||||
|
||||
const meta = { isDev: true, requestPath: null };
|
||||
@@ -100,11 +100,11 @@ describe('build meta dev', () => {
|
||||
files,
|
||||
workPath,
|
||||
entrypoint,
|
||||
meta
|
||||
meta,
|
||||
});
|
||||
routes.forEach(route => {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
route.dest = route.dest.replace(':4000', ':5000');
|
||||
route.dest = route.dest.replace(/:\d+/, ':5000');
|
||||
});
|
||||
expect(output).toEqual({});
|
||||
expect(routes).toEqual([
|
||||
@@ -116,9 +116,9 @@ describe('build meta dev', () => {
|
||||
{ src: '/api/test', dest: 'http://localhost:5000/api/test' },
|
||||
{
|
||||
src: '^/(nested\\/([^\\/]+?)(?:\\/)?)$',
|
||||
dest: 'http://localhost:5000/$1'
|
||||
dest: 'http://localhost:5000/$1',
|
||||
},
|
||||
{ src: '/data.txt', dest: 'http://localhost:5000/data.txt' }
|
||||
{ src: '/data.txt', dest: 'http://localhost:5000/data.txt' },
|
||||
]);
|
||||
expect(watch).toEqual([
|
||||
'next.config.js',
|
||||
@@ -128,7 +128,7 @@ describe('build meta dev', () => {
|
||||
'pages/api/test.js',
|
||||
'public/index',
|
||||
'public/data.txt',
|
||||
'package.json'
|
||||
'package.json',
|
||||
]);
|
||||
childProcesses.forEach(cp => cp.kill());
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/node",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/node-js",
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
shouldServe,
|
||||
Config,
|
||||
debug,
|
||||
isSymbolicLink,
|
||||
} from '@now/build-utils';
|
||||
export { shouldServe };
|
||||
export { NowRequest, NowResponse } from './types';
|
||||
@@ -55,13 +56,6 @@ const BRIDGE_FILENAME = '___now_bridge';
|
||||
const HELPERS_FILENAME = '___now_helpers';
|
||||
const SOURCEMAP_SUPPORT_FILENAME = '__sourcemap_support';
|
||||
|
||||
const S_IFMT = 61440; /* 0170000 type of file */
|
||||
const S_IFLNK = 40960; /* 0120000 symbolic link */
|
||||
|
||||
function isSymbolicLink(mode: number): boolean {
|
||||
return (mode & S_IFMT) === S_IFLNK;
|
||||
}
|
||||
|
||||
async function downloadInstallAndBundle({
|
||||
files,
|
||||
entrypoint,
|
||||
@@ -69,10 +63,7 @@ async function downloadInstallAndBundle({
|
||||
config,
|
||||
meta,
|
||||
}: DownloadOptions) {
|
||||
debug('Downloading user files...');
|
||||
const downloadTime = Date.now();
|
||||
const downloadedFiles = await download(files, workPath, meta);
|
||||
debug(`download complete [${Date.now() - downloadTime}ms]`);
|
||||
|
||||
console.log('Installing dependencies...');
|
||||
const installTime = Date.now();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/python",
|
||||
"version": "1.0.1-canary.0",
|
||||
"version": "1.0.1",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/python",
|
||||
|
||||
@@ -77,7 +77,6 @@ export const build = async ({
|
||||
meta = {},
|
||||
config,
|
||||
}: BuildOptions) => {
|
||||
debug('Downloading user files...');
|
||||
let downloadedFiles = await download(originalFiles, workPath, meta);
|
||||
|
||||
if (meta.isDev) {
|
||||
|
||||
@@ -84,8 +84,6 @@ export const build = async ({
|
||||
entrypoint,
|
||||
config,
|
||||
}: BuildOptions) => {
|
||||
debug('downloading files...');
|
||||
|
||||
await download(files, workPath);
|
||||
|
||||
const { gemHome, bundlerPath } = await installBundler();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@now/ruby",
|
||||
"author": "Nathan Cahill <nathan@nathancahill.com>",
|
||||
"version": "1.0.1-canary.0",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/ruby",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/static-build",
|
||||
"version": "0.13.1",
|
||||
"version": "0.14.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/static-builds",
|
||||
|
||||
@@ -175,7 +175,6 @@ export async function build({
|
||||
config,
|
||||
meta = {},
|
||||
}: BuildOptions) {
|
||||
debug('Downloading user files...');
|
||||
await download(files, workPath, meta);
|
||||
|
||||
const mountpoint = path.dirname(entrypoint);
|
||||
|
||||
111
yarn.lock
111
yarn.lock
@@ -1485,6 +1485,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-3.0.0.tgz#549eeacd0a8fecfaa459334583a4edcee738e6db"
|
||||
integrity sha512-ZF43+CIIlzngQe8/Zo7L1kpY9W8O6rO006VDz3c5iM21ddtXWxCEyOXyft+q4pVF2tGqvrVuVrEDH1+gJEi1fQ==
|
||||
|
||||
"@types/color-name@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
|
||||
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
|
||||
|
||||
"@types/content-type@1.1.3":
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/content-type/-/content-type-1.1.3.tgz#3688bd77fc12f935548eef102a4e34c512b03a07"
|
||||
@@ -2306,6 +2311,11 @@ ansi-regex@^4.0.0, ansi-regex@^4.1.0:
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
|
||||
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
|
||||
|
||||
ansi-regex@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
|
||||
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
|
||||
|
||||
ansi-styles@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
|
||||
@@ -2325,6 +2335,14 @@ ansi-styles@^4.0.0:
|
||||
dependencies:
|
||||
color-convert "^2.0.1"
|
||||
|
||||
ansi-styles@^4.1.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.0.tgz#5681f0dcf7ae5880a7841d8831c4724ed9cc0172"
|
||||
integrity sha512-7kFQgnEaMdRtwf6uSfUnVr9gSGC7faurn+J/Mv90/W+iTtN0405/nLdopfMWwchyxhbGYl6TC4Sccn9TUkGAgg==
|
||||
dependencies:
|
||||
"@types/color-name" "^1.1.1"
|
||||
color-convert "^2.0.1"
|
||||
|
||||
any-observable@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/any-observable/-/any-observable-0.3.0.tgz#af933475e5806a67d0d7df090dd5e8bef65d119b"
|
||||
@@ -2826,6 +2844,20 @@ blueimp-md5@^2.10.0:
|
||||
resolved "https://registry.yarnpkg.com/blueimp-md5/-/blueimp-md5-2.11.1.tgz#b1f6b6218d13cdedbf5743f32b3023b2afefcbd3"
|
||||
integrity sha512-4UiOAmql2XO0Sws07OVzYdCKK0K2Va5g6AVgYXoGhEQiKrdSOefjUCm1frPk6E+xiIOHRqaFg+TUGo7cClKg5g==
|
||||
|
||||
boxen@4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/boxen/-/boxen-4.2.0.tgz#e411b62357d6d6d36587c8ac3d5d974daa070e64"
|
||||
integrity sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ==
|
||||
dependencies:
|
||||
ansi-align "^3.0.0"
|
||||
camelcase "^5.3.1"
|
||||
chalk "^3.0.0"
|
||||
cli-boxes "^2.2.0"
|
||||
string-width "^4.1.0"
|
||||
term-size "^2.1.0"
|
||||
type-fest "^0.8.1"
|
||||
widest-line "^3.1.0"
|
||||
|
||||
boxen@^3.0.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/boxen/-/boxen-3.2.0.tgz#fbdff0de93636ab4450886b6ff45b92d098f45eb"
|
||||
@@ -3168,6 +3200,14 @@ chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.1, chalk@^2.4.
|
||||
escape-string-regexp "^1.0.5"
|
||||
supports-color "^5.3.0"
|
||||
|
||||
chalk@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
|
||||
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
|
||||
dependencies:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
chardet@^0.4.0:
|
||||
version "0.4.2"
|
||||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
|
||||
@@ -3463,7 +3503,7 @@ concat-map@0.0.1:
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
|
||||
concat-stream@^1.4.7, concat-stream@^1.5.0:
|
||||
concat-stream@^1.5.0:
|
||||
version "1.6.2"
|
||||
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
|
||||
integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==
|
||||
@@ -8277,11 +8317,6 @@ os-name@^3.0.0:
|
||||
macos-release "^2.2.0"
|
||||
windows-release "^3.1.0"
|
||||
|
||||
os-shim@^0.1.2:
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917"
|
||||
integrity sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=
|
||||
|
||||
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
|
||||
@@ -8767,15 +8802,6 @@ posix-character-classes@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
||||
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
|
||||
|
||||
pre-commit@1.2.2:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/pre-commit/-/pre-commit-1.2.2.tgz#dbcee0ee9de7235e57f79c56d7ce94641a69eec6"
|
||||
integrity sha1-287g7p3nI15X95xW186UZBpp7sY=
|
||||
dependencies:
|
||||
cross-spawn "^5.0.1"
|
||||
spawn-sync "^1.0.15"
|
||||
which "1.2.x"
|
||||
|
||||
prelude-ls@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
|
||||
@@ -9870,14 +9896,6 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
spawn-sync@^1.0.15:
|
||||
version "1.0.15"
|
||||
resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476"
|
||||
integrity sha1-sAeZVX63+wyDdsKdROih6mfldHY=
|
||||
dependencies:
|
||||
concat-stream "^1.4.7"
|
||||
os-shim "^0.1.2"
|
||||
|
||||
spawn-wrap@^1.4.2:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.2.tgz#cff58e73a8224617b6561abdc32586ea0c82248c"
|
||||
@@ -10065,6 +10083,15 @@ string-width@^3.0.0, string-width@^3.1.0:
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
strip-ansi "^5.1.0"
|
||||
|
||||
string-width@^4.0.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5"
|
||||
integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
string-width@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.1.0.tgz#ba846d1daa97c3c596155308063e075ed1c99aff"
|
||||
@@ -10118,6 +10145,13 @@ strip-ansi@^4.0.0:
|
||||
dependencies:
|
||||
ansi-regex "^3.0.0"
|
||||
|
||||
strip-ansi@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
|
||||
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.0"
|
||||
|
||||
strip-bom-buf@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-bom-buf/-/strip-bom-buf-2.0.0.tgz#ff9c223937f8e7154b77e9de9bde094186885c15"
|
||||
@@ -10253,6 +10287,13 @@ supports-color@^7.0.0:
|
||||
dependencies:
|
||||
has-flag "^4.0.0"
|
||||
|
||||
supports-color@^7.1.0:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1"
|
||||
integrity sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==
|
||||
dependencies:
|
||||
has-flag "^4.0.0"
|
||||
|
||||
symbol-observable@^1.0.4, symbol-observable@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
|
||||
@@ -10359,6 +10400,11 @@ term-size@^1.2.0:
|
||||
dependencies:
|
||||
execa "^0.7.0"
|
||||
|
||||
term-size@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.1.0.tgz#3aec444c07a7cf936e157c1dc224b590c3c7eef2"
|
||||
integrity sha512-I42EWhJ+2aeNQawGx1VtpO0DFI9YcfuvAMNIdKyf/6sRbHJ4P+ZQ/zIT87tE+ln1ymAGcCJds4dolfSAS0AcNg==
|
||||
|
||||
test-exclude@^5.1.0, test-exclude@^5.2.3:
|
||||
version "5.2.3"
|
||||
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0"
|
||||
@@ -10675,6 +10721,11 @@ type-fest@^0.6.0:
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
|
||||
integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==
|
||||
|
||||
type-fest@^0.8.1:
|
||||
version "0.8.1"
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
|
||||
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==
|
||||
|
||||
typedarray-to-buffer@^3.1.5:
|
||||
version "3.1.5"
|
||||
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
|
||||
@@ -11068,13 +11119,6 @@ which@1, which@1.3.1, which@^1.1.2, which@^1.2.9, which@^1.3.0, which@^1.3.1:
|
||||
dependencies:
|
||||
isexe "^2.0.0"
|
||||
|
||||
which@1.2.x:
|
||||
version "1.2.14"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
|
||||
integrity sha1-mofEN48D6CfOyvGs31bHNsAcFOU=
|
||||
dependencies:
|
||||
isexe "^2.0.0"
|
||||
|
||||
which@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-2.0.1.tgz#f1cf94d07a8e571b6ff006aeb91d0300c47ef0a4"
|
||||
@@ -11096,6 +11140,13 @@ widest-line@^2.0.0:
|
||||
dependencies:
|
||||
string-width "^2.1.1"
|
||||
|
||||
widest-line@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca"
|
||||
integrity sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==
|
||||
dependencies:
|
||||
string-width "^4.0.0"
|
||||
|
||||
windows-release@^3.1.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/windows-release/-/windows-release-3.2.0.tgz#8122dad5afc303d833422380680a79cdfa91785f"
|
||||
|
||||
Reference in New Issue
Block a user