Compare commits

..

35 Commits

Author SHA1 Message Date
Andy Bitz
6076b12067 Publish
- @now/build-utils@0.8.4
 - @now/static-build@0.7.1
2019-07-12 06:35:38 +02:00
Andy
5c7eba6049 [now-static-build] Fix warning and framework support (#750)
* [now-static-build] Fix template string

* [now-static-build] Handle different dist dir for Angular

* Fix type issue

* Fix hexo test

* Log more

* Change hexo test

* Adjust Hexo test

* Removed extra logging

* Continue with prev test

* Use @now/node@canary

* Fix tests

* Increase timeout

* Increase timeout

* Add framework

* Reset timeout for now-build-utils

* Increase timeout

* Adjust test
2019-07-12 06:34:03 +02:00
Andy Bitz
3ed99a5b25 Publish
- @now/next@0.5.4
2019-07-10 23:43:45 +02:00
Andy
f8b08926f2 [now-next] Create a serverless config by creating a new config (#688)
* [now-next] Create a serverless config by creating a new config

* Adjust config for promises

* Add tests and fixes

* Fix the tests

* Always create the config for non-dev mode

* Removed unused version

* Handle promises

* Adjust test

* Removed semver check

* Removed import

* Try tests

* Update tests

* Log results

* Add more logging

* More logging

* Fixed typo and removed logging
2019-07-10 23:43:03 +02:00
Andy Bitz
354e80b3e3 Publish
- @now/build-utils@0.8.3
2019-07-10 17:47:53 +02:00
Andy Bitz
0cfb4a8466 Revert "Remove deprecated builders (#733)"
This reverts commit 6766e9a099.
2019-07-10 17:44:31 +02:00
Andy Bitz
8facd2845f Revert "[now-node-server] Remove package source code (#721)"
This reverts commit d327426c93.
2019-07-10 17:44:28 +02:00
Andy Bitz
9dae464fa6 Revert "Publish"
This reverts commit 6ff4b25d79.
2019-07-10 17:43:42 +02:00
Andy Bitz
6ff4b25d79 Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 17:39:49 +02:00
Steven
6766e9a099 Remove deprecated builders (#733)
* Remove deprecated builders

* Update comment so that tests  run
2019-07-10 17:38:59 +02:00
Steven
d327426c93 [now-node-server] Remove package source code (#721)
* [now-node-server] Remove package

* Update comment so tests run
2019-07-10 17:36:07 +02:00
Andy Bitz
47f73c856f Revert "Remove deprecated builders (#733)"
This reverts commit 9d15c35623.
2019-07-10 17:34:33 +02:00
Andy Bitz
9fdd247773 Revert "[now-node-server] Remove package source code (#721)"
This reverts commit a55ce5da8f.
2019-07-10 17:34:31 +02:00
Andy Bitz
fe59cabf15 Revert "Publish"
This reverts commit da37a9bc06.
2019-07-10 15:30:00 +02:00
Andy Bitz
da37a9bc06 Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 15:19:34 +02:00
Andy
bad779be1f Use --pure-lockfile on build (#738)
* Use --pure-lockfile on build

* Add --pure-lockfile to publish
2019-07-10 15:17:31 +02:00
Andy Bitz
5eb5deb8eb Revert "Publish"
This reverts commit f9afee7dba.
2019-07-10 15:09:42 +02:00
Andy Bitz
f9afee7dba Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 14:28:37 +02:00
Andy
547e9ed684 Add --pure-lockfile option (#737) 2019-07-10 14:26:31 +02:00
Andy Bitz
68d2927cbf Revert "Publish"
This reverts commit ca7f716432.
2019-07-10 14:16:22 +02:00
Andy Bitz
ca7f716432 Publish
- @now/build-utils@0.8.3
 - @now/node@0.11.2
2019-07-10 14:02:12 +02:00
Steven
9d15c35623 Remove deprecated builders (#733)
* Remove deprecated builders

* Update comment so that tests  run
2019-07-10 13:51:37 +02:00
Steven
a55ce5da8f [now-node-server] Remove package source code (#721)
* [now-node-server] Remove package

* Update comment so tests run
2019-07-10 13:49:40 +02:00
Connor Davis
f0a06b797e Update CODEOWNERS 2019-07-10 13:46:33 +02:00
Andy
0a77f43832 [now-build-utils] Add warnings and simpler routes (#734)
* [now-build-utils] Add warnings

* Make routes regexes simpler

* Adjust tests

* Adjust tests

* Fix tests

* Remove now-build script check
2019-07-10 13:46:13 +02:00
Andy Bitz
4ce0d31688 Publish
- @now/bash@1.0.1
 - @now/go@0.5.5
 - @now/python@0.2.11
2019-07-09 01:09:23 +02:00
Andy
280802615f [now-bash][now-go][now-python] Support zero config (#723)
* [now-bash][now-go][now-python] Support zero config

* Remove default config
2019-07-09 01:01:27 +02:00
Andy Bitz
c7db281065 Publish
- @now/build-utils@0.8.2
2019-07-08 17:14:04 +02:00
Andy
ca00739041 [now-build-utils] Fix default routes on windows and adjust error message (#720)
* [now-build-utils] Fix default routes on windows and adjust error message

* Remove extra condition
2019-07-08 17:13:29 +02:00
Andy Bitz
11f8b17599 Publish
- @now/build-utils@0.8.1
2019-07-08 12:40:23 +02:00
Andy Bitz
970ab7d5c5 Revert "Fixed yarn.lock (#717)"
This reverts commit 5bfbd63e13.
2019-07-08 12:39:19 +02:00
Andy Bitz
71c082dccd Revert "Publish"
This reverts commit 76a185eb90.
2019-07-08 12:34:31 +02:00
Andy Bitz
76a185eb90 Publish
- @now/build-utils@0.8.1
2019-07-08 12:23:30 +02:00
Andy
8c0f3d107d [now-build-utils] Ignore dot and underscore prefix for api directory (#718)
* [now-build-utils] Add support for `_` and `.` prefixes in `api/`

 * Remove log statement

* Ignore dot and underscore prefix for api directory

* Set one builder per file if there are files to ignore

* Always return all builds with their exact match
2019-07-08 12:22:40 +02:00
Leo Lamprecht
5bfbd63e13 Fixed yarn.lock (#717)
This reverts commit d83b09ffbd.
2019-07-07 16:00:20 +00:00
79 changed files with 8213 additions and 68 deletions

2
.github/CODEOWNERS vendored
View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
module.exports = async function () {
return {};
};

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1 @@
module.exports = {};

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1 @@
module.exports = new Promise(res => res({}));

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1 @@
module.exports = () => ({});

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next" }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "8.1.0",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/next", "config": { "zeroConfig": true } }]
}

View File

@@ -0,0 +1,7 @@
{
"dependencies": {
"next": "latest",
"react": "latest",
"react-dom": "latest"
}
}

View File

@@ -0,0 +1,3 @@
const F = () => 'Goodbye World!';
F.getInitialProps = async () => ({});
export default F;

View File

@@ -0,0 +1 @@
export default () => 'Hello World!';

View File

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

View File

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

View File

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

View File

@@ -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);
return join(base, content[0]);
// 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;
},
},
];

View File

@@ -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'
);

View 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

View 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

View 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
```

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

View 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'.

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

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

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

View File

@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types": ["jasmine", "jasminewd2", "node"]
}
}

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

View 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" }
]
}

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

View 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: '\`';
}

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

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

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

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

View File

@@ -0,0 +1,3 @@
export const environment = {
production: true,
};

View 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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

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

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

View 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
*/

View File

@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */

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

View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"include": ["src/**/*.ts"],
"exclude": ["src/test.ts", "src/**/*.spec.ts"]
}

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

View 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"]
}

View 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"]
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -6,7 +6,7 @@
"build": "hexo generate"
},
"hexo": {
"version": ""
"version": "3.9.0"
},
"dependencies": {
"hexo": "^3.9.0",

View File

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

View File

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

View File

@@ -52,6 +52,7 @@ async function runBuildLambda(inputPath) {
return {
analyzeResult,
buildResult,
workPath,
};
}