mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-23 01:49:13 +00:00
Compare commits
35 Commits
@now/php@0
...
@now/stati
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6076b12067 | ||
|
|
5c7eba6049 | ||
|
|
3ed99a5b25 | ||
|
|
f8b08926f2 | ||
|
|
354e80b3e3 | ||
|
|
0cfb4a8466 | ||
|
|
8facd2845f | ||
|
|
9dae464fa6 | ||
|
|
6ff4b25d79 | ||
|
|
6766e9a099 | ||
|
|
d327426c93 | ||
|
|
47f73c856f | ||
|
|
9fdd247773 | ||
|
|
fe59cabf15 | ||
|
|
da37a9bc06 | ||
|
|
bad779be1f | ||
|
|
5eb5deb8eb | ||
|
|
f9afee7dba | ||
|
|
547e9ed684 | ||
|
|
68d2927cbf | ||
|
|
ca7f716432 | ||
|
|
9d15c35623 | ||
|
|
a55ce5da8f | ||
|
|
f0a06b797e | ||
|
|
0a77f43832 | ||
|
|
4ce0d31688 | ||
|
|
280802615f | ||
|
|
c7db281065 | ||
|
|
ca00739041 | ||
|
|
11f8b17599 | ||
|
|
970ab7d5c5 | ||
|
|
71c082dccd | ||
|
|
76a185eb90 | ||
|
|
8c0f3d107d | ||
|
|
5bfbd63e13 |
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -4,7 +4,7 @@
|
||||
* @styfle
|
||||
/packages/now-node @styfle @tootallnate @lucleray
|
||||
/packages/now-node-bridge @styfle @tootallnate @lucleray
|
||||
/packages/now-next @timer @dav-is
|
||||
/packages/now-next @timer
|
||||
/packages/now-go @styfle @sophearak
|
||||
/packages/now-python @styfle @sophearak
|
||||
/packages/now-rust @styfle @mike-engel @anmonteiro
|
||||
|
||||
12
.github/main.workflow
vendored
12
.github/main.workflow
vendored
@@ -18,21 +18,21 @@ action "1. Canary yarn install" {
|
||||
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
|
||||
needs = ["0. Canary PR not deleted"]
|
||||
runs = "yarn"
|
||||
args = "install"
|
||||
args = "--pure-lockfile install"
|
||||
}
|
||||
|
||||
action "2. Canary yarn run build" {
|
||||
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
|
||||
needs = ["1. Canary yarn install"]
|
||||
runs = "yarn"
|
||||
args = "run build"
|
||||
args = "--pure-lockfile run build"
|
||||
}
|
||||
|
||||
action "3. Canary yarn run publish" {
|
||||
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
|
||||
needs = ["2. Canary yarn run build"]
|
||||
runs = "yarn"
|
||||
args = "run publish-from-github"
|
||||
args = "--pure-lockfile run publish-from-github"
|
||||
secrets = ["NPM_TOKEN"]
|
||||
}
|
||||
|
||||
@@ -57,20 +57,20 @@ action "1. Master yarn install" {
|
||||
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
|
||||
needs = ["0. Master PR not deleted"]
|
||||
runs = "yarn"
|
||||
args = "install"
|
||||
args = "--pure-lockfile install"
|
||||
}
|
||||
|
||||
action "2. Master yarn run build" {
|
||||
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
|
||||
needs = ["1. Master yarn install"]
|
||||
runs = "yarn"
|
||||
args = "run build"
|
||||
args = "--pure-lockfile run build"
|
||||
}
|
||||
|
||||
action "3. Master yarn run publish" {
|
||||
uses = "actions/npm@59b64a598378f31e49cb76f27d6f3312b582f680"
|
||||
needs = ["2. Master yarn run build"]
|
||||
runs = "yarn"
|
||||
args = "run publish-from-github"
|
||||
args = "--pure-lockfile run publish-from-github"
|
||||
secrets = ["NPM_TOKEN"]
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ const {
|
||||
} = require('@now/build-utils'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
exports.config = {
|
||||
maxLambdaSize: '10mb',
|
||||
maxLambdaSize: '30mb',
|
||||
};
|
||||
|
||||
// From this list: https://import.pw/importpw/import/docs/config.md
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/bash",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Now 2.0 builder for HTTP endpoints written in Bash",
|
||||
"main": "index.js",
|
||||
"author": "Nathan Rajlich <nate@zeit.co>",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/build-utils",
|
||||
"version": "0.8.0",
|
||||
"version": "0.8.4",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -10,8 +10,8 @@ const BUILDERS = new Map<string, Builder>([
|
||||
]);
|
||||
|
||||
const API_BUILDERS: Builder[] = [
|
||||
{ src: 'api/**/*.js', use: '@now/node', config },
|
||||
{ src: 'api/**/*.ts', use: '@now/node', config },
|
||||
{ src: 'api/**/*.js', use: '@now/node@canary', config },
|
||||
{ src: 'api/**/*.ts', use: '@now/node@canary', config },
|
||||
{ src: 'api/**/*.rs', use: '@now/rust', config },
|
||||
{ src: 'api/**/*.go', use: '@now/go', config },
|
||||
{ src: 'api/**/*.php', use: '@now/php', config },
|
||||
@@ -20,28 +20,76 @@ const API_BUILDERS: Builder[] = [
|
||||
{ src: 'api/**/*.sh', use: '@now/bash', config },
|
||||
];
|
||||
|
||||
export async function detectBuilder(pkg: PackageJson): Promise<Builder> {
|
||||
interface Warning {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export async function detectBuilder(
|
||||
pkg: PackageJson
|
||||
): Promise<{
|
||||
builder: null | Builder;
|
||||
warnings: null | Warning[];
|
||||
}> {
|
||||
let warnings: null | Warning[] = null;
|
||||
|
||||
const scripts = pkg.scripts || {};
|
||||
|
||||
if (!scripts.build) {
|
||||
warnings = [
|
||||
{
|
||||
code: 'missing_build_script',
|
||||
message:
|
||||
'Your `package.json` file is missing a `build` property inside the `script` property',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
for (const [dependency, builder] of BUILDERS) {
|
||||
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
||||
|
||||
// Return the builder when a dependency matches
|
||||
if (deps[dependency]) {
|
||||
return builder;
|
||||
return { builder, warnings };
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no `build` and `now-build` script
|
||||
// we'll not select `@now/static-build`
|
||||
// since it would fail
|
||||
if (!scripts.build) {
|
||||
return { builder: null, warnings };
|
||||
}
|
||||
|
||||
// By default we'll choose the `static-build` builder
|
||||
return { src, use: '@now/static-build', config };
|
||||
const builder = { src, use: '@now/static-build', config };
|
||||
return { builder, warnings };
|
||||
}
|
||||
|
||||
// Files that match a specific pattern will get ignored
|
||||
export function ignoreApiFilter(file: string) {
|
||||
if (file.includes('/.')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.includes('/_')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function detectApiBuilders(
|
||||
files: string[]
|
||||
): Promise<Builder[] | null> {
|
||||
const builds = files.map(file => {
|
||||
return API_BUILDERS.find(({ src }): boolean => minimatch(file, src));
|
||||
const builds = files.filter(ignoreApiFilter).map(file => {
|
||||
const result = API_BUILDERS.find(
|
||||
({ src }): boolean => minimatch(file, src)
|
||||
);
|
||||
|
||||
return result ? { ...result, src: file } : null;
|
||||
});
|
||||
|
||||
// We can use `new Set` here since `builds` contains references to `API_BUILDERS`
|
||||
const finishedBuilds = Array.from(new Set(builds.filter(Boolean)));
|
||||
const finishedBuilds = builds.filter(Boolean);
|
||||
return finishedBuilds.length > 0 ? (finishedBuilds as Builder[]) : null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import path from 'path';
|
||||
import { Route } from './types';
|
||||
import { parse as parsePath } from 'path';
|
||||
import { ignoreApiFilter } from './detect-builder';
|
||||
|
||||
function joinPath(...segments: string[]) {
|
||||
const joinedPath = segments.join('/');
|
||||
return joinedPath.replace(/\/{2,}/g, '/');
|
||||
}
|
||||
|
||||
function concatArrayOfText(texts: string[]): string {
|
||||
if (texts.length <= 2) {
|
||||
return texts.join(' and ');
|
||||
}
|
||||
|
||||
const last = texts.pop();
|
||||
return `${texts.join(', ')}, and ${last}`;
|
||||
}
|
||||
@@ -11,7 +21,7 @@ function concatArrayOfText(texts: string[]): string {
|
||||
// It will return `null` if there are no brackets
|
||||
// and therefore no segment.
|
||||
function getSegmentName(segment: string): string | null {
|
||||
const { name } = path.parse(segment);
|
||||
const { name } = parsePath(segment);
|
||||
|
||||
if (name.startsWith('[') && name.endsWith(']')) {
|
||||
return name.slice(1, -1);
|
||||
@@ -23,7 +33,6 @@ function getSegmentName(segment: string): string | null {
|
||||
function createRouteFromPath(filePath: string): Route {
|
||||
const parts = filePath.split('/');
|
||||
|
||||
let append: string = '';
|
||||
let counter: number = 1;
|
||||
const query: string[] = [];
|
||||
|
||||
@@ -33,23 +42,12 @@ function createRouteFromPath(filePath: string): Route {
|
||||
const isLast = index === parts.length - 1;
|
||||
|
||||
if (name !== null) {
|
||||
// We can't use `URLSearchParams` because `$` would get escaped
|
||||
query.push(`${name}=$${counter++}`);
|
||||
|
||||
if (isLast) {
|
||||
// We append this to the last one
|
||||
// to make sure GET params still work
|
||||
// and are just appended to our GET params
|
||||
append += `$${counter++}`;
|
||||
return `([^\\/|\\?]+)\\/?(?:\\?(.*))?`;
|
||||
}
|
||||
|
||||
return `([^\\/]+)`;
|
||||
} else if (isLast) {
|
||||
// If it is the last part we want to remove the extension
|
||||
// and capture everything after that as regex group and append it
|
||||
const { name: fileName } = path.parse(segment);
|
||||
append += `$${counter++}`;
|
||||
return `${fileName}(.*)`;
|
||||
const { name: fileName } = parsePath(segment);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
return segment;
|
||||
@@ -57,9 +55,7 @@ function createRouteFromPath(filePath: string): Route {
|
||||
);
|
||||
|
||||
const src = `^/${srcParts.join('/')}$`;
|
||||
const dest = `/${filePath}${query.length ? '?' : ''}${query.join('&')}${
|
||||
query.length ? '&' : ''
|
||||
}${append}`;
|
||||
const dest = `/${filePath}?${query.join('&')}`;
|
||||
|
||||
return { src, dest };
|
||||
}
|
||||
@@ -101,8 +97,8 @@ function partiallyMatches(pathA: string, pathB: string): boolean {
|
||||
// got resolved, so we can check if they have conflicts
|
||||
function pathOccurrences(filePath: string, files: string[]): string[] {
|
||||
const getAbsolutePath = (unresolvedPath: string): string => {
|
||||
const { dir, name } = path.parse(unresolvedPath);
|
||||
const parts = path.join(dir, name).split('/');
|
||||
const { dir, name } = parsePath(unresolvedPath);
|
||||
const parts = joinPath(dir, name).split('/');
|
||||
return parts.map(part => part.replace(/\[.*\]/, '1')).join('/');
|
||||
};
|
||||
|
||||
@@ -183,7 +179,9 @@ export async function detectApiRoutes(
|
||||
|
||||
// The deepest routes need to be
|
||||
// the first ones to get handled
|
||||
const sortedFiles = files.sort(sortFilesBySegmentCount);
|
||||
const sortedFiles = files
|
||||
.filter(ignoreApiFilter)
|
||||
.sort(sortFilesBySegmentCount);
|
||||
|
||||
const defaultRoutes: Route[] = [];
|
||||
|
||||
@@ -196,8 +194,6 @@ export async function detectApiRoutes(
|
||||
|
||||
const conflictingSegment = getConflictingSegment(file);
|
||||
|
||||
console.log({ file, conflictingSegment });
|
||||
|
||||
if (conflictingSegment) {
|
||||
return {
|
||||
defaultRoutes: null,
|
||||
|
||||
@@ -139,7 +139,7 @@ for (const fixture of fs.readdirSync(fixturesPath)) {
|
||||
|
||||
// few foreign tests
|
||||
|
||||
const buildersToTestWith = ['now-node-server', 'now-static-build'];
|
||||
const buildersToTestWith = ['now-node', 'now-static-build'];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const builder of buildersToTestWith) {
|
||||
@@ -168,20 +168,21 @@ for (const builder of buildersToTestWith) {
|
||||
it('Test `detectBuilder`', async () => {
|
||||
{
|
||||
const pkg = { dependencies: { next: '1.0.0' } };
|
||||
const builder = await detectBuilder(pkg);
|
||||
const { builder, warnings } = await detectBuilder(pkg);
|
||||
expect(builder.use).toBe('@now/next');
|
||||
expect(warnings.length).toBe(1);
|
||||
}
|
||||
|
||||
{
|
||||
const pkg = { devDependencies: { next: '1.0.0' } };
|
||||
const builder = await detectBuilder(pkg);
|
||||
const { builder } = await detectBuilder(pkg);
|
||||
expect(builder.use).toBe('@now/next');
|
||||
}
|
||||
|
||||
{
|
||||
const pkg = {};
|
||||
const builder = await detectBuilder(pkg);
|
||||
expect(builder.use).toBe('@now/static-build');
|
||||
const { builder } = await detectBuilder(pkg);
|
||||
expect(builder).toBe(null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -190,7 +191,7 @@ it('Test `detectApiBuilders`', async () => {
|
||||
const files = ['package.json', 'api/user.js', 'api/team.js'];
|
||||
|
||||
const builders = await detectApiBuilders(files);
|
||||
expect(builders[0].use).toBe('@now/node');
|
||||
expect(builders[0].use).toBe('@now/node@canary');
|
||||
}
|
||||
|
||||
{
|
||||
@@ -198,7 +199,7 @@ it('Test `detectApiBuilders`', async () => {
|
||||
|
||||
const builders = await detectApiBuilders(files);
|
||||
expect(builders.some(({ use }) => use === '@now/go')).toBeTruthy();
|
||||
expect(builders.some(({ use }) => use === '@now/node')).toBeTruthy();
|
||||
expect(builders.some(({ use }) => use === '@now/node@canary')).toBeTruthy();
|
||||
}
|
||||
|
||||
{
|
||||
@@ -207,6 +208,18 @@ it('Test `detectApiBuilders`', async () => {
|
||||
const builders = await detectApiBuilders(files);
|
||||
expect(builders).toBe(null);
|
||||
}
|
||||
|
||||
{
|
||||
const files = [
|
||||
'api/users/[id].js',
|
||||
'api/_utils/handler.js',
|
||||
'api/users/.helper.js',
|
||||
'api/teams/_helper.js',
|
||||
];
|
||||
|
||||
const builders = await detectApiBuilders(files);
|
||||
expect(builders.length).toBe(1);
|
||||
}
|
||||
});
|
||||
|
||||
it('Test `detectApiRoutes`', async () => {
|
||||
@@ -244,4 +257,15 @@ it('Test `detectApiRoutes`', async () => {
|
||||
const { defaultRoutes } = await detectApiRoutes(files);
|
||||
expect(defaultRoutes.length).toBe(2);
|
||||
}
|
||||
|
||||
{
|
||||
const files = [
|
||||
'api/_utils/handler.js',
|
||||
'api/[endpoint]/.helper.js',
|
||||
'api/[endpoint]/[id].js',
|
||||
];
|
||||
|
||||
const builders = await detectApiBuilders(files);
|
||||
expect(builders.length).toBe(1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -120,7 +120,14 @@ Learn more: https://zeit.co/docs/v2/deployments/official-builders/go-now-go/#ent
|
||||
const parsedAnalyzed = JSON.parse(analyzed) as Analyzed;
|
||||
|
||||
if (meta.isDev) {
|
||||
const base = dirname(downloadedFiles['now.json'].fsPath);
|
||||
let base = null;
|
||||
|
||||
if (config && config.zeroConfig) {
|
||||
base = workPath;
|
||||
} else {
|
||||
base = dirname(downloadedFiles['now.json'].fsPath);
|
||||
}
|
||||
|
||||
const destNow = join(
|
||||
base,
|
||||
'.now',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/go",
|
||||
"version": "0.5.4",
|
||||
"version": "0.5.5",
|
||||
"license": "MIT",
|
||||
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/go-now-go",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/next",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next",
|
||||
|
||||
51
packages/now-next/src/create-serverless-config.ts
Normal file
51
packages/now-next/src/create-serverless-config.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
function getCustomData(importName: string) {
|
||||
return `
|
||||
module.exports = function(...args) {
|
||||
let original = require('./${importName}');
|
||||
|
||||
const finalConfig = {};
|
||||
const target = { target: 'serverless' };
|
||||
|
||||
if (typeof original === 'function' && original.constructor.name === 'AsyncFunction') {
|
||||
// AsyncFunctions will become promises
|
||||
original = original(...args);
|
||||
}
|
||||
|
||||
if (original instanceof Promise) {
|
||||
// Special case for promises, as it's currently not supported
|
||||
// and will just error later on
|
||||
return original
|
||||
.then((orignalConfig) => Object.assign(finalConfig, orignalConfig))
|
||||
.then((config) => Object.assign(config, target));
|
||||
} else if (typeof original === 'function') {
|
||||
Object.assign(finalConfig, original(...args));
|
||||
} else if (typeof original === 'object') {
|
||||
Object.assign(finalConfig, original);
|
||||
}
|
||||
|
||||
Object.assign(finalConfig, target);
|
||||
|
||||
return finalConfig;
|
||||
}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
function getDefaultData() {
|
||||
return `module.exports = { target: 'serverless' };`;
|
||||
}
|
||||
|
||||
export default async function createServerlessConfig(workPath: string) {
|
||||
const configPath = path.join(workPath, 'next.config.js');
|
||||
const backupConfigName = `next.config.original.${Date.now()}.js`;
|
||||
const backupConfigPath = path.join(workPath, backupConfigName);
|
||||
|
||||
if (fs.existsSync(configPath)) {
|
||||
await fs.rename(configPath, backupConfigPath);
|
||||
await fs.writeFile(configPath, getCustomData(backupConfigName));
|
||||
} else {
|
||||
await fs.writeFile(configPath, getDefaultData());
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ import {
|
||||
getDynamicRoutes,
|
||||
isDynamicRoute,
|
||||
} from './utils';
|
||||
import createServerlessConfig from './create-serverless-config';
|
||||
|
||||
interface BuildParamsMeta {
|
||||
isDev: boolean | undefined;
|
||||
@@ -165,8 +166,6 @@ export const build = async ({
|
||||
watch?: string[];
|
||||
childProcesses: ChildProcess[];
|
||||
}> => {
|
||||
process.env.__NEXT_BUILDER_EXPERIMENTAL_TARGET = 'serverless';
|
||||
|
||||
validateEntrypoint(entrypoint);
|
||||
|
||||
const entryDirectory = path.dirname(entrypoint);
|
||||
@@ -176,12 +175,16 @@ export const build = async ({
|
||||
console.log(`${name} Downloading user files...`);
|
||||
await download(files, workPath, meta);
|
||||
|
||||
const nodeVersion = await getNodeVersion(entryPath);
|
||||
const spawnOpts = getSpawnOptions(meta, nodeVersion);
|
||||
|
||||
const pkg = await readPackageJson(entryPath);
|
||||
const nextVersion = getNextVersion(pkg);
|
||||
|
||||
if (!meta.isDev) {
|
||||
await createServerlessConfig(workPath);
|
||||
}
|
||||
|
||||
const nodeVersion = await getNodeVersion(entryPath);
|
||||
const spawnOpts = getSpawnOptions(meta, nodeVersion);
|
||||
|
||||
if (!nextVersion) {
|
||||
throw new Error(
|
||||
'No Next.js version could be detected in "package.json". Make sure `"next"` is installed in "dependencies" or "devDependencies"'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* global it, expect */
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const runBuildLambda = require('../../../../test/lib/run-build-lambda');
|
||||
|
||||
const FOUR_MINUTES = 240000;
|
||||
@@ -111,3 +112,119 @@ it(
|
||||
},
|
||||
FOUR_MINUTES,
|
||||
);
|
||||
|
||||
it(
|
||||
'Should build the serverless-config example',
|
||||
async () => {
|
||||
const {
|
||||
workPath,
|
||||
buildResult: { output },
|
||||
} = await runBuildLambda(path.join(__dirname, 'serverless-config'));
|
||||
|
||||
expect(output.index).toBeDefined();
|
||||
expect(output.goodbye).toBeDefined();
|
||||
const filePaths = Object.keys(output);
|
||||
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
|
||||
const hasUnderScoreAppStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_app\.js$/));
|
||||
const hasUnderScoreErrorStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_error\.js$/));
|
||||
expect(hasUnderScoreAppStaticFile).toBeTruthy();
|
||||
expect(hasUnderScoreErrorStaticFile).toBeTruthy();
|
||||
expect(serverlessError).toBeTruthy();
|
||||
|
||||
const contents = await fs.readdir(workPath);
|
||||
|
||||
expect(contents.some(name => name === 'next.config.js')).toBeTruthy();
|
||||
expect(
|
||||
contents.some(name => name.includes('next.config.original.')),
|
||||
).toBeTruthy();
|
||||
},
|
||||
FOUR_MINUTES,
|
||||
);
|
||||
|
||||
it(
|
||||
'Should not build the serverless-config-async example',
|
||||
async () => {
|
||||
let error = null;
|
||||
|
||||
try {
|
||||
await runBuildLambda(path.join(__dirname, 'serverless-config-async'));
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
expect(error).not.toBe(null);
|
||||
},
|
||||
FOUR_MINUTES,
|
||||
);
|
||||
|
||||
it(
|
||||
'Should not build the serverless-config-promise example',
|
||||
async () => {
|
||||
let error = null;
|
||||
|
||||
try {
|
||||
await runBuildLambda(path.join(__dirname, 'serverless-config-promise'));
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
expect(error).not.toBe(null);
|
||||
},
|
||||
FOUR_MINUTES,
|
||||
);
|
||||
|
||||
it(
|
||||
'Should build the serverless-config-object example',
|
||||
async () => {
|
||||
const {
|
||||
workPath,
|
||||
buildResult: { output },
|
||||
} = await runBuildLambda(path.join(__dirname, 'serverless-config-object'));
|
||||
|
||||
expect(output['index.html']).toBeDefined();
|
||||
expect(output.goodbye).toBeDefined();
|
||||
const filePaths = Object.keys(output);
|
||||
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
|
||||
const hasUnderScoreAppStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_app\.js$/));
|
||||
const hasUnderScoreErrorStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_error\.js$/));
|
||||
expect(hasUnderScoreAppStaticFile).toBeTruthy();
|
||||
expect(hasUnderScoreErrorStaticFile).toBeTruthy();
|
||||
expect(serverlessError).toBeTruthy();
|
||||
|
||||
const contents = await fs.readdir(workPath);
|
||||
|
||||
expect(contents.some(name => name === 'next.config.js')).toBeTruthy();
|
||||
expect(
|
||||
contents.some(name => name.includes('next.config.original.')),
|
||||
).toBeTruthy();
|
||||
},
|
||||
FOUR_MINUTES,
|
||||
);
|
||||
|
||||
it(
|
||||
'Should build the serverless-no-config example',
|
||||
async () => {
|
||||
const {
|
||||
workPath,
|
||||
buildResult: { output },
|
||||
} = await runBuildLambda(path.join(__dirname, 'serverless-no-config'));
|
||||
|
||||
expect(output['index.html']).toBeDefined();
|
||||
expect(output.goodbye).toBeDefined();
|
||||
const filePaths = Object.keys(output);
|
||||
const serverlessError = filePaths.some(filePath => filePath.match(/_error/));
|
||||
const hasUnderScoreAppStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_app\.js$/));
|
||||
const hasUnderScoreErrorStaticFile = filePaths.some(filePath => filePath.match(/static.*\/pages\/_error\.js$/));
|
||||
expect(hasUnderScoreAppStaticFile).toBeTruthy();
|
||||
expect(hasUnderScoreErrorStaticFile).toBeTruthy();
|
||||
expect(serverlessError).toBeTruthy();
|
||||
|
||||
const contents = await fs.readdir(workPath);
|
||||
|
||||
expect(contents.some(name => name === 'next.config.js')).toBeTruthy();
|
||||
expect(
|
||||
contents.some(name => name.includes('next.config.original.')),
|
||||
).toBeFalsy();
|
||||
},
|
||||
FOUR_MINUTES,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = async function () {
|
||||
return {};
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/next" }]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "latest",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const F = () => 'Goodbye World!';
|
||||
F.getInitialProps = async () => ({});
|
||||
export default F;
|
||||
@@ -0,0 +1 @@
|
||||
export default () => 'Hello World!';
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = {};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/next" }]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "latest",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const F = () => 'Goodbye World!';
|
||||
F.getInitialProps = async () => ({});
|
||||
export default F;
|
||||
@@ -0,0 +1 @@
|
||||
export default () => 'Hello World!';
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = new Promise(res => res({}));
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/next" }]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "latest",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const F = () => 'Goodbye World!';
|
||||
F.getInitialProps = async () => ({});
|
||||
export default F;
|
||||
@@ -0,0 +1 @@
|
||||
export default () => 'Hello World!';
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = () => ({});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/next" }]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "8.1.0",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const F = () => 'Goodbye World!';
|
||||
F.getInitialProps = async () => ({});
|
||||
export default F;
|
||||
@@ -0,0 +1 @@
|
||||
export default () => 'Hello World!';
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "package.json", "use": "@now/next", "config": { "zeroConfig": true } }]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "latest",
|
||||
"react": "latest",
|
||||
"react-dom": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const F = () => 'Goodbye World!';
|
||||
F.getInitialProps = async () => ({});
|
||||
export default F;
|
||||
@@ -0,0 +1 @@
|
||||
export default () => 'Hello World!';
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/python",
|
||||
"version": "0.2.10",
|
||||
"version": "0.2.11",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/python-now-python",
|
||||
|
||||
@@ -92,12 +92,20 @@ export const build = async ({
|
||||
files: originalFiles,
|
||||
entrypoint,
|
||||
meta = {},
|
||||
config,
|
||||
}: BuildOptions) => {
|
||||
console.log('downloading files...');
|
||||
let downloadedFiles = await download(originalFiles, workPath, meta);
|
||||
|
||||
if (meta.isDev) {
|
||||
const base = dirname(downloadedFiles['now.json'].fsPath);
|
||||
let base = null;
|
||||
|
||||
if (config && config.zeroConfig) {
|
||||
base = workPath;
|
||||
} else {
|
||||
base = dirname(downloadedFiles['now.json'].fsPath);
|
||||
}
|
||||
|
||||
const destNow = join(base, '.now', 'cache', basename(entrypoint, '.py'));
|
||||
await download(downloadedFiles, destNow);
|
||||
downloadedFiles = await glob('**', destNow);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/static-build",
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.1",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/static-build-now-static-build",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { readdir } from 'fs';
|
||||
import { readdir, stat } from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { join } from 'path';
|
||||
|
||||
const readirPromise = promisify(readdir);
|
||||
const statPromise = promisify(stat);
|
||||
const isDir = async (file: string): Promise<boolean> =>
|
||||
(await statPromise(file)).isDirectory();
|
||||
|
||||
// Please note that is extremely important
|
||||
// that the `dependency` property needs
|
||||
@@ -76,7 +79,12 @@ export default [
|
||||
const location = join(dirPrefix, base);
|
||||
const content = await readirPromise(location);
|
||||
|
||||
// If there is only one file in it that is a dir we'll use it as dist dir
|
||||
if (content.length === 1 && (await isDir(join(location, content[0])))) {
|
||||
return join(base, content[0]);
|
||||
}
|
||||
|
||||
return base;
|
||||
},
|
||||
defaultRoutes: [
|
||||
{
|
||||
@@ -184,4 +192,20 @@ export default [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Docusaurus',
|
||||
dependency: 'docusaurus',
|
||||
getOutputDirName: async (dirPrefix: string) => {
|
||||
const base = 'build';
|
||||
const location = join(dirPrefix, base);
|
||||
const content = await readirPromise(location);
|
||||
|
||||
// If there is only one file in it that is a dir we'll use it as dist dir
|
||||
if (content.length === 1 && (await isDir(join(location, content[0])))) {
|
||||
return join(base, content[0]);
|
||||
}
|
||||
|
||||
return base;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -248,7 +248,7 @@ export async function build({
|
||||
);
|
||||
} else {
|
||||
if (meta.isDev) {
|
||||
console.log('WARN: "${devScript}" script is missing from package.json');
|
||||
console.log(`WARN: "${devScript}" script is missing from package.json`);
|
||||
console.log(
|
||||
'See the local development docs: https://zeit.co/docs/v2/deployments/official-builders/static-build-now-static-build/#local-development'
|
||||
);
|
||||
|
||||
13
packages/now-static-build/test/fixtures/14-angular-configured/.editorconfig
vendored
Normal file
13
packages/now-static-build/test/fixtures/14-angular-configured/.editorconfig
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
46
packages/now-static-build/test/fixtures/14-angular-configured/.gitignore
vendored
Normal file
46
packages/now-static-build/test/fixtures/14-angular-configured/.gitignore
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
# Only exists if Bazel was run
|
||||
/bazel-out
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events.json
|
||||
speed-measure-plugin.json
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
15
packages/now-static-build/test/fixtures/14-angular-configured/README.md
vendored
Normal file
15
packages/now-static-build/test/fixtures/14-angular-configured/README.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Angular with a Node.js API
|
||||
|
||||
This example shows a [Angular](https://angular.io/) project (located in `package.json`) powered by a Node.js API.
|
||||
|
||||
In order to deploy, run:
|
||||
|
||||
```
|
||||
now
|
||||
```
|
||||
|
||||
When editing a file, you can run the following command to spawn a local development server:
|
||||
|
||||
```
|
||||
now dev
|
||||
```
|
||||
109
packages/now-static-build/test/fixtures/14-angular-configured/angular.json
vendored
Normal file
109
packages/now-static-build/test/fixtures/14-angular-configured/angular.json
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"angular-node": {
|
||||
"projectType": "application",
|
||||
"schematics": {},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"aot": false,
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"styles": ["src/styles.css"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "2mb",
|
||||
"maximumError": "5mb"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "angular-node:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "angular-node:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "angular-node:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"karmaConfig": "karma.conf.js",
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"styles": ["src/styles.css"],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"tsconfig.app.json",
|
||||
"tsconfig.spec.json",
|
||||
"e2e/tsconfig.json"
|
||||
],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
},
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
"protractorConfig": "e2e/protractor.conf.js",
|
||||
"devServerTarget": "angular-node:serve"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "angular-node:serve:production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "angular-node"
|
||||
}
|
||||
12
packages/now-static-build/test/fixtures/14-angular-configured/browserslist
vendored
Normal file
12
packages/now-static-build/test/fixtures/14-angular-configured/browserslist
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
> 0.5%
|
||||
last 2 versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
||||
32
packages/now-static-build/test/fixtures/14-angular-configured/e2e/protractor.conf.js
vendored
Normal file
32
packages/now-static-build/test/fixtures/14-angular-configured/e2e/protractor.conf.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// @ts-check
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter } = require('jasmine-spec-reporter');
|
||||
|
||||
/**
|
||||
* @type { import("protractor").Config }
|
||||
*/
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: ['./src/**/*.e2e-spec.ts'],
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
},
|
||||
directConnect: true,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {},
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: require('path').join(__dirname, './tsconfig.json'),
|
||||
});
|
||||
jasmine
|
||||
.getEnv()
|
||||
.addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||
},
|
||||
};
|
||||
28
packages/now-static-build/test/fixtures/14-angular-configured/e2e/src/app.e2e-spec.ts
vendored
Normal file
28
packages/now-static-build/test/fixtures/14-angular-configured/e2e/src/app.e2e-spec.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { AppPage } from './app.po';
|
||||
import { browser, logging } from 'protractor';
|
||||
|
||||
describe('workspace-project App', () => {
|
||||
let page: AppPage;
|
||||
|
||||
beforeEach(() => {
|
||||
page = new AppPage();
|
||||
});
|
||||
|
||||
it('should display welcome message', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getTitleText()).toEqual('Welcome to angular-node!');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// Assert that there are no errors emitted from the browser
|
||||
const logs = await browser
|
||||
.manage()
|
||||
.logs()
|
||||
.get(logging.Type.BROWSER);
|
||||
expect(logs).not.toContain(
|
||||
jasmine.objectContaining({
|
||||
level: logging.Level.SEVERE,
|
||||
} as logging.Entry)
|
||||
);
|
||||
});
|
||||
});
|
||||
11
packages/now-static-build/test/fixtures/14-angular-configured/e2e/src/app.po.ts
vendored
Normal file
11
packages/now-static-build/test/fixtures/14-angular-configured/e2e/src/app.po.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { browser, by, element } from 'protractor';
|
||||
|
||||
export class AppPage {
|
||||
navigateTo() {
|
||||
return browser.get(browser.baseUrl) as Promise<any>;
|
||||
}
|
||||
|
||||
getTitleText() {
|
||||
return element(by.css('app-root h1')).getText() as Promise<string>;
|
||||
}
|
||||
}
|
||||
9
packages/now-static-build/test/fixtures/14-angular-configured/e2e/tsconfig.json
vendored
Normal file
9
packages/now-static-build/test/fixtures/14-angular-configured/e2e/tsconfig.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/e2e",
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"types": ["jasmine", "jasminewd2", "node"]
|
||||
}
|
||||
}
|
||||
32
packages/now-static-build/test/fixtures/14-angular-configured/karma.conf.js
vendored
Normal file
32
packages/now-static-build/test/fixtures/14-angular-configured/karma.conf.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
],
|
||||
client: {
|
||||
clearContext: false, // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, './coverage/angular-node'),
|
||||
reports: ['html', 'lcovonly', 'text-summary'],
|
||||
fixWebpackSourcePaths: true,
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false,
|
||||
restartOnFileChange: true,
|
||||
});
|
||||
};
|
||||
15
packages/now-static-build/test/fixtures/14-angular-configured/now.json
vendored
Normal file
15
packages/now-static-build/test/fixtures/14-angular-configured/now.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [
|
||||
{
|
||||
"src": "package.json",
|
||||
"use": "@now/static-build",
|
||||
"config": { "zeroConfig": true }
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{ "path": "/", "mustContain": "Angular + Node.js API" },
|
||||
{ "path": "/main-es2015.js", "mustContain": "Loading date..." },
|
||||
{ "path": "/iudieufwunifiwwnuwfuw", "mustContain": "Angular + Node.js API" }
|
||||
]
|
||||
}
|
||||
50
packages/now-static-build/test/fixtures/14-angular-configured/package.json
vendored
Normal file
50
packages/now-static-build/test/fixtures/14-angular-configured/package.json
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "angular",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
},
|
||||
"engines": {
|
||||
"node": "10.x"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "~8.1.0",
|
||||
"@angular/common": "~8.1.0",
|
||||
"@angular/compiler": "~8.1.0",
|
||||
"@angular/core": "~8.1.0",
|
||||
"@angular/forms": "~8.1.0",
|
||||
"@angular/platform-browser": "~8.1.0",
|
||||
"@angular/platform-browser-dynamic": "~8.1.0",
|
||||
"@angular/router": "~8.1.0",
|
||||
"rxjs": "~6.4.0",
|
||||
"tslib": "^1.9.0",
|
||||
"zone.js": "~0.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.801.0",
|
||||
"@angular/cli": "~8.1.0",
|
||||
"@angular/compiler-cli": "~8.1.0",
|
||||
"@angular/language-service": "~8.1.0",
|
||||
"@types/node": "~8.9.4",
|
||||
"@types/jasmine": "~3.3.8",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"codelyzer": "^5.0.0",
|
||||
"jasmine-core": "~3.4.0",
|
||||
"jasmine-spec-reporter": "~4.2.1",
|
||||
"karma": "~4.1.0",
|
||||
"karma-chrome-launcher": "~2.2.0",
|
||||
"karma-coverage-istanbul-reporter": "~2.0.1",
|
||||
"karma-jasmine": "~2.0.1",
|
||||
"karma-jasmine-html-reporter": "^1.4.0",
|
||||
"protractor": "~5.4.0",
|
||||
"ts-node": "~7.0.0",
|
||||
"tslint": "~5.15.0",
|
||||
"typescript": "~3.4.3"
|
||||
}
|
||||
}
|
||||
44
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.css
vendored
Normal file
44
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.css
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
main {
|
||||
align-content: center;
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
font-family: 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica',
|
||||
'Arial', sans-serif;
|
||||
hyphens: auto;
|
||||
line-height: 1.65;
|
||||
margin: 0 auto;
|
||||
max-width: 680px;
|
||||
min-height: 100vh;
|
||||
padding: 72px 0;
|
||||
text-align: center;
|
||||
}
|
||||
h1 {
|
||||
font-size: 45px;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
p {
|
||||
font-size: 16px;
|
||||
}
|
||||
a {
|
||||
border-bottom: 1px solid white;
|
||||
color: #0076ff;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
a:hover {
|
||||
border-bottom: 1px solid #0076ff;
|
||||
}
|
||||
code,
|
||||
pre {
|
||||
color: #d400ff;
|
||||
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
|
||||
Bitstream Vera Sans Mono, Courier New, monospace, serif;
|
||||
font-size: 0.92em;
|
||||
}
|
||||
code:before,
|
||||
code:after {
|
||||
content: '\`';
|
||||
}
|
||||
33
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.html
vendored
Normal file
33
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.html
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<!--The content below is only a placeholder and can be replaced.-->
|
||||
<main>
|
||||
<h1>{{ title }}</h1>
|
||||
<h2>
|
||||
Deployed with
|
||||
<a href="https://zeit.co/docs" target="_blank" rel="noreferrer noopener"
|
||||
>ZEIT Now</a
|
||||
>!
|
||||
</h2>
|
||||
<p>
|
||||
<a
|
||||
href="https://github.com/zeit/now-examples/blob/master/angular-node"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>This project</a
|
||||
>
|
||||
is an
|
||||
<a href="https://angular.io/">Angular</a>
|
||||
app with three directories,
|
||||
<code>/e2e</code>
|
||||
for tests,
|
||||
<code>/src</code> for components and content, and
|
||||
<code>/api</code>
|
||||
which contains a serverless
|
||||
<a href="https://nodejs.org/en/">Node.js</a>
|
||||
function. See
|
||||
<a href="/api/date"> <code>api/date</code> for the Date API with Node.js</a
|
||||
>.
|
||||
</p>
|
||||
<br />
|
||||
<h2>The date according to Node.js is:</h2>
|
||||
<p>{{ date }}</p>
|
||||
</main>
|
||||
31
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.spec.ts
vendored
Normal file
31
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.spec.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have as title 'angular-node'`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app.title).toEqual('angular-node');
|
||||
});
|
||||
|
||||
it('should render title in a h1 tag', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent).toContain(
|
||||
'Welcome to angular-node!'
|
||||
);
|
||||
});
|
||||
});
|
||||
14
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.ts
vendored
Normal file
14
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.component.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css'],
|
||||
})
|
||||
export class AppComponent {
|
||||
t = fetch('/api/date')
|
||||
.then(response => response.text())
|
||||
.then(date => (this.date = date));
|
||||
date = 'Loading date...';
|
||||
title = 'Angular + Node.js API';
|
||||
}
|
||||
12
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.module.ts
vendored
Normal file
12
packages/now-static-build/test/fixtures/14-angular-configured/src/app/app.module.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent],
|
||||
imports: [BrowserModule],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {}
|
||||
0
packages/now-static-build/test/fixtures/14-angular-configured/src/assets/.gitkeep
vendored
Normal file
0
packages/now-static-build/test/fixtures/14-angular-configured/src/assets/.gitkeep
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
};
|
||||
16
packages/now-static-build/test/fixtures/14-angular-configured/src/environments/environment.ts
vendored
Normal file
16
packages/now-static-build/test/fixtures/14-angular-configured/src/environments/environment.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
};
|
||||
|
||||
/*
|
||||
* For easier debugging in development mode, you can import the following file
|
||||
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||
*
|
||||
* This import should be commented out in production mode because it will have a negative impact
|
||||
* on performance if an error is thrown.
|
||||
*/
|
||||
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||
BIN
packages/now-static-build/test/fixtures/14-angular-configured/src/favicon.ico
vendored
Normal file
BIN
packages/now-static-build/test/fixtures/14-angular-configured/src/favicon.ico
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
14
packages/now-static-build/test/fixtures/14-angular-configured/src/index.html
vendored
Normal file
14
packages/now-static-build/test/fixtures/14-angular-configured/src/index.html
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Angular + Node.js API</title>
|
||||
<base href="/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
13
packages/now-static-build/test/fixtures/14-angular-configured/src/main.ts
vendored
Normal file
13
packages/now-static-build/test/fixtures/14-angular-configured/src/main.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic()
|
||||
.bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
||||
62
packages/now-static-build/test/fixtures/14-angular-configured/src/polyfills.ts
vendored
Normal file
62
packages/now-static-build/test/fixtures/14-angular-configured/src/polyfills.ts
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* This file includes polyfills needed by Angular and is loaded before the app.
|
||||
* You can add your own extra polyfills to this file.
|
||||
*
|
||||
* This file is divided into 2 sections:
|
||||
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
||||
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
||||
* file.
|
||||
*
|
||||
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
||||
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
||||
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
||||
*
|
||||
* Learn more in https://angular.io/guide/browser-support
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* BROWSER POLYFILLS
|
||||
*/
|
||||
|
||||
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
||||
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
||||
|
||||
/**
|
||||
* Web Animations `@angular/platform-browser/animations`
|
||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||
*/
|
||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||
|
||||
/**
|
||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||
* will put import in the top of bundle, so user need to create a separate file
|
||||
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||
* into that file, and then add the following code before importing zone.js.
|
||||
* import './zone-flags.ts';
|
||||
*
|
||||
* The flags allowed in zone-flags.ts are listed here.
|
||||
*
|
||||
* The following flags will work for all browsers.
|
||||
*
|
||||
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
*
|
||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||
*
|
||||
* (window as any).__Zone_enable_cross_context_check = true;
|
||||
*
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by default for Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
*/
|
||||
1
packages/now-static-build/test/fixtures/14-angular-configured/src/styles.css
vendored
Normal file
1
packages/now-static-build/test/fixtures/14-angular-configured/src/styles.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
20
packages/now-static-build/test/fixtures/14-angular-configured/src/test.ts
vendored
Normal file
20
packages/now-static-build/test/fixtures/14-angular-configured/src/test.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting,
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
9
packages/now-static-build/test/fixtures/14-angular-configured/tsconfig.app.json
vendored
Normal file
9
packages/now-static-build/test/fixtures/14-angular-configured/tsconfig.app.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["src/test.ts", "src/**/*.spec.ts"]
|
||||
}
|
||||
21
packages/now-static-build/test/fixtures/14-angular-configured/tsconfig.json
vendored
Normal file
21
packages/now-static-build/test/fixtures/14-angular-configured/tsconfig.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"downlevelIteration": true,
|
||||
"experimentalDecorators": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"target": "es2015",
|
||||
"typeRoots": ["node_modules/@types"],
|
||||
"lib": ["es2018", "dom"]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"fullTemplateTypeCheck": true,
|
||||
"strictInjectionParameters": true
|
||||
}
|
||||
}
|
||||
9
packages/now-static-build/test/fixtures/14-angular-configured/tsconfig.spec.json
vendored
Normal file
9
packages/now-static-build/test/fixtures/14-angular-configured/tsconfig.spec.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": ["jasmine", "node"]
|
||||
},
|
||||
"files": ["src/test.ts", "src/polyfills.ts"],
|
||||
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
58
packages/now-static-build/test/fixtures/14-angular-configured/tslint.json
vendored
Normal file
58
packages/now-static-build/test/fixtures/14-angular-configured/tslint.json
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"extends": "tslint:recommended",
|
||||
"rules": {
|
||||
"array-type": false,
|
||||
"arrow-parens": false,
|
||||
"deprecation": {
|
||||
"severity": "warning"
|
||||
},
|
||||
"component-class-suffix": true,
|
||||
"contextual-lifecycle": true,
|
||||
"directive-class-suffix": true,
|
||||
"directive-selector": [true, "attribute", "app", "camelCase"],
|
||||
"component-selector": [true, "element", "app", "kebab-case"],
|
||||
"import-blacklist": [true, "rxjs/Rx"],
|
||||
"interface-name": false,
|
||||
"max-classes-per-file": false,
|
||||
"max-line-length": [true, 140],
|
||||
"member-access": false,
|
||||
"member-ordering": [
|
||||
true,
|
||||
{
|
||||
"order": [
|
||||
"static-field",
|
||||
"instance-field",
|
||||
"static-method",
|
||||
"instance-method"
|
||||
]
|
||||
}
|
||||
],
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
|
||||
"no-empty": false,
|
||||
"no-inferrable-types": [true, "ignore-params"],
|
||||
"no-non-null-assertion": true,
|
||||
"no-redundant-jsdoc": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-requires": false,
|
||||
"object-literal-key-quotes": [true, "as-needed"],
|
||||
"object-literal-sort-keys": false,
|
||||
"ordered-imports": false,
|
||||
"quotemark": [true, "single"],
|
||||
"trailing-comma": false,
|
||||
"no-conflicting-lifecycle": true,
|
||||
"no-host-metadata-property": true,
|
||||
"no-input-rename": true,
|
||||
"no-inputs-metadata-property": true,
|
||||
"no-output-native": true,
|
||||
"no-output-on-prefix": true,
|
||||
"no-output-rename": true,
|
||||
"no-outputs-metadata-property": true,
|
||||
"template-banana-in-box": true,
|
||||
"template-no-negated-async": true,
|
||||
"use-lifecycle-interface": true,
|
||||
"use-pipe-transform-interface": true
|
||||
},
|
||||
"rulesDirectory": ["codelyzer"]
|
||||
}
|
||||
7052
packages/now-static-build/test/fixtures/14-angular-configured/yarn.lock
vendored
Normal file
7052
packages/now-static-build/test/fixtures/14-angular-configured/yarn.lock
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,6 @@
|
||||
"probes": [
|
||||
{ "path": "/", "mustContain": "Hello World" },
|
||||
{ "path": "/", "mustContain": "Hexo" },
|
||||
{ "path": "/2019/07/05/hello-world/", "mustContain": "Create a new post" }
|
||||
{ "path": "/archives", "mustContain": "Hello World" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"build": "hexo generate"
|
||||
},
|
||||
"hexo": {
|
||||
"version": ""
|
||||
"version": "3.9.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"hexo": "^3.9.0",
|
||||
|
||||
@@ -7,7 +7,7 @@ const {
|
||||
testDeployment,
|
||||
} = require('../../../test/lib/deployment/test-deployment.js');
|
||||
|
||||
jest.setTimeout(4 * 60 * 1000);
|
||||
jest.setTimeout(12 * 60 * 1000);
|
||||
const buildUtilsUrl = '@canary';
|
||||
let builderUrl;
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ async function testDeployment (
|
||||
fetchOpts.body = JSON.stringify(probe.body);
|
||||
}
|
||||
const { text, resp } = await fetchDeploymentUrl(probeUrl, fetchOpts);
|
||||
console.log('finished testing', JSON.stringify(probe));
|
||||
|
||||
if (probe.mustContain) {
|
||||
if (!text.includes(probe.mustContain)) {
|
||||
|
||||
@@ -52,6 +52,7 @@ async function runBuildLambda(inputPath) {
|
||||
return {
|
||||
analyzeResult,
|
||||
buildResult,
|
||||
workPath,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user