Compare commits

...

24 Commits

Author SHA1 Message Date
Tim Neutkens
f4e95eb59c Publish
- @now/next@0.0.79-canary.7
2018-11-19 01:36:53 +01:00
Tim Neutkens
a6cdaccd34 @now/next add integration test for custom dependencies 2018-11-19 01:35:22 +01:00
Tim Neutkens
4f5fe8eba8 @now/next Fix normalizePackageJson types 2018-11-19 01:06:14 +01:00
Tim Neutkens
7239013989 Don’t run build on tags, only branches 2018-11-19 00:44:15 +01:00
Tim Neutkens
75000ee334 Publish
- @now/next@0.0.79-canary.6
2018-11-19 00:40:04 +01:00
Tim Neutkens
5319610d59 @now/next add normalized package.json logging 2018-11-19 00:39:37 +01:00
Tim Neutkens
6df0d69afa Add passing test for real world package.json 2018-11-19 00:28:48 +01:00
Tim Neutkens
65b191f6b9 Publish
- @now/build-utils@0.4.30-canary.5
 - @now/cgi@0.0.13-canary.5
 - @now/go@0.2.10-canary.5
 - @now/html-minifier@1.0.6-canary.5
 - @now/lambda@0.4.7-canary.5
 - @now/md@0.4.7-canary.5
 - @now/mdx-deck@0.4.16-canary.5
 - @now/next@0.0.79-canary.5
 - @now/node-bridge@0.1.9-canary.5
 - @now/node-server@0.4.24-canary.5
 - @now/node@0.4.26-canary.5
 - @now/optipng@0.4.7-canary.5
 - @now/php@0.4.11-canary.5
 - @now/python@0.0.40-canary.5
 - @now/static-build@0.4.15-canary.5
2018-11-18 17:04:46 +01:00
Tim Neutkens
115f62bbba Set gopath temporarily 2018-11-18 17:02:23 +01:00
Tim Neutkens
cdf6a98a18 Publish
- @now/build-utils@0.4.30-canary.4
 - @now/cgi@0.0.13-canary.4
 - @now/go@0.2.10-canary.4
 - @now/html-minifier@1.0.6-canary.4
 - @now/lambda@0.4.7-canary.4
 - @now/md@0.4.7-canary.4
 - @now/mdx-deck@0.4.16-canary.4
 - @now/next@0.0.79-canary.4
 - @now/node-bridge@0.1.9-canary.4
 - @now/node-server@0.4.24-canary.4
 - @now/node@0.4.26-canary.4
 - @now/optipng@0.4.7-canary.4
 - @now/php@0.4.11-canary.4
 - @now/python@0.0.40-canary.4
 - @now/static-build@0.4.15-canary.4
2018-11-18 16:50:10 +01:00
Tim Neutkens
bb75dfd993 Manually get dependencies 2018-11-18 16:48:57 +01:00
Tim Neutkens
b63062cfc5 Publish
- @now/build-utils@0.4.30-canary.3
 - @now/cgi@0.0.13-canary.3
 - @now/go@0.2.10-canary.3
 - @now/html-minifier@1.0.6-canary.3
 - @now/lambda@0.4.7-canary.3
 - @now/md@0.4.7-canary.3
 - @now/mdx-deck@0.4.16-canary.3
 - @now/next@0.0.79-canary.3
 - @now/node-bridge@0.1.9-canary.3
 - @now/node-server@0.4.24-canary.3
 - @now/node@0.4.26-canary.3
 - @now/optipng@0.4.7-canary.3
 - @now/php@0.4.11-canary.3
 - @now/python@0.0.40-canary.3
 - @now/static-build@0.4.15-canary.3
2018-11-18 16:23:55 +01:00
Tim Neutkens
5ad6dabd96 Use if/else so that build will fail when lerna fails 2018-11-18 16:23:10 +01:00
Tim Neutkens
30060bee07 Publish
- @now/build-utils@0.4.30-canary.2
 - @now/cgi@0.0.13-canary.2
 - @now/go@0.2.10-canary.2
 - @now/html-minifier@1.0.6-canary.2
 - @now/lambda@0.4.7-canary.2
 - @now/md@0.4.7-canary.2
 - @now/mdx-deck@0.4.16-canary.2
 - @now/next@0.0.79-canary.2
 - @now/node-bridge@0.1.9-canary.2
 - @now/node-server@0.4.24-canary.2
 - @now/node@0.4.26-canary.2
 - @now/optipng@0.4.7-canary.2
 - @now/php@0.4.11-canary.2
 - @now/python@0.0.40-canary.2
 - @now/static-build@0.4.15-canary.2
2018-11-18 16:14:10 +01:00
Tim Neutkens
dd48a1c6d3 Fall back to showing did not publish 2018-11-18 16:11:46 +01:00
Tim Neutkens
24d45736f1 If describe fails force null 2018-11-18 16:06:36 +01:00
Tim Neutkens
d839fdbe81 Only run on exact tag matches 2018-11-18 15:59:03 +01:00
Tim Neutkens
cfdcd2f8d0 Make git describe not fail on no tag 2018-11-18 15:53:20 +01:00
Tim Neutkens
b3cac2b372 Manually match tags and publish 2018-11-18 15:46:22 +01:00
Tim Neutkens
9d27d69656 Publish
- @now/build-utils@0.4.30-canary.1
 - @now/cgi@0.0.13-canary.1
 - @now/go@0.2.10-canary.1
 - @now/html-minifier@1.0.6-canary.1
 - @now/lambda@0.4.7-canary.1
 - @now/md@0.4.7-canary.1
 - @now/mdx-deck@0.4.16-canary.1
 - @now/next@0.0.79-canary.1
 - @now/node-bridge@0.1.9-canary.1
 - @now/node-server@0.4.24-canary.1
 - @now/node@0.4.26-canary.1
 - @now/optipng@0.4.7-canary.1
 - @now/php@0.4.11-canary.1
 - @now/python@0.0.40-canary.1
 - @now/static-build@0.4.15-canary.1
2018-11-18 14:55:52 +01:00
Tim Neutkens
04197b250c Run build for tags 2018-11-18 14:52:57 +01:00
Tim Neutkens
ce6f43eae7 Publish
- @now/build-utils@0.4.30-canary.0
 - @now/cgi@0.0.13-canary.0
 - @now/go@0.2.10-canary.0
 - @now/html-minifier@1.0.6-canary.0
 - @now/lambda@0.4.7-canary.0
 - @now/md@0.4.7-canary.0
 - @now/mdx-deck@0.4.16-canary.0
 - @now/next@0.0.79-canary.0
 - @now/node-bridge@0.1.9-canary.0
 - @now/node-server@0.4.24-canary.0
 - @now/node@0.4.26-canary.0
 - @now/optipng@0.4.7-canary.0
 - @now/php@0.4.11-canary.0
 - @now/python@0.0.40-canary.0
 - @now/static-build@0.4.15-canary.0
2018-11-18 14:49:58 +01:00
Tim Neutkens
2cfafe4054 Remove unused comment 2018-11-18 14:49:15 +01:00
Tim Neutkens
b195949881 Bring back canary publish job 2018-11-18 14:47:51 +01:00
24 changed files with 188 additions and 86 deletions

View File

@@ -24,65 +24,17 @@ jobs:
- run:
name: Tests
command: yarn test
# publish-canary:
# docker:
# - image: circleci/node:10
# working_directory: ~/repo
# steps:
# - checkout
# - run:
# name: Updating apt-get list
# command: sudo apt-get update
# - run:
# name: Installing the latest version of Go
# command: sudo apt-get install golang-go
# - run: yarn install
# - run: yarn bootstrap
# - run:
# name: Saving Authentication Information
# command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
# - run:
# name: Publishing to Canary Channel
# command: yarn run lerna publish from-git --npm-tag canary --yes
publish-stable:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- run:
name: Updating apt-get list
command: sudo apt-get update
name: Potentially save npm token
command: "([[ ! -z $NPM_TOKEN ]] && echo \"//registry.npmjs.org/:_authToken=$NPM_TOKEN\" >> ~/.npmrc) || echo \"Did not write npm token\""
- run:
name: Installing the latest version of Go
command: sudo apt-get install golang-go
- run: yarn install
- run: yarn bootstrap
- run:
name: Saving Authentication Information
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publishing to Stable Channel
command: yarn run lerna publish from-git --yes
name: Potentially publish canary release
command: "if ls ~/.npmrc >/dev/null 2>&1 && [[ $(git describe --exact-match 2> /dev/null || :) =~ -canary ]]; then yarn run lerna publish from-git --npm-tag canary --yes; else echo \"Did not publish\"; fi"
# - run:
# name: Potentially publish stable release
# command: "ls ~/.npmrc >/dev/null 2>&1 && [[ $(git describe --exact-match 2> /dev/null || :) =~ -canary ]] && yarn run lerna publish from-git --npm-tag canary --yes"
workflows:
version: 2
unscheduled:
build-and-deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- publish-stable:
requires:
- build
filters:
tags:
only: /^.*(\d+\.)(\d+\.)(\*|\d+)$/
branches:
ignore: /.*/
# - publish-canary:
# requires:
# - build
# filters:
# tags:
# only: /^.*canary.*($|\b)/
- build

View File

@@ -1,6 +1,6 @@
{
"name": "@now/build-utils",
"version": "0.4.29",
"version": "0.4.30-canary.5",
"dependencies": {
"async-retry": "1.2.3",
"async-sema": "2.1.4",

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash
export GOOS=linux
export GOARCH=amd64
export GOPATH=$HOME/go
go get github.com/aws/aws-lambda-go/events
go get github.com/aws/aws-lambda-go/lambda
go build -o handler main.go

View File

@@ -1,6 +1,6 @@
{
"name": "@now/cgi",
"version": "0.0.12",
"version": "0.0.13-canary.5",
"scripts": {
"test": "best -I test/*.js",
"prepublish": "./build.sh"

View File

@@ -1,6 +1,6 @@
{
"name": "@now/go",
"version": "0.2.9",
"version": "0.2.10-canary.5",
"scripts": {
"test": "best -I test/*.js",
"prepublish": "./build.sh"

View File

@@ -1,6 +1,6 @@
{
"name": "@now/html-minifier",
"version": "1.0.5",
"version": "1.0.6-canary.5",
"dependencies": {
"html-minifier": "3.5.21"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@now/lambda",
"version": "0.4.6",
"version": "0.4.7-canary.5",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@now/md",
"version": "0.4.6",
"version": "0.4.7-canary.5",
"dependencies": {
"rehype-document": "^2.2.0",
"rehype-format": "^2.3.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/mdx-deck",
"version": "0.4.15",
"version": "0.4.16-canary.5",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"
}

View File

@@ -90,7 +90,10 @@ exports.build = async ({ files, workPath, entrypoint }) => {
let downloadedFiles = await download(filesWithoutStaticDirectory, workPath);
console.log('normalizing package.json');
const packageJson = normalizePackageJson(readPackageJson(downloadedFiles));
const packageJson = normalizePackageJson(
await readPackageJson(downloadedFiles),
);
console.log('normalized package.json result: ', packageJson);
await writePackageJson(workPath, packageJson);
if (process.env.NPM_AUTH_TOKEN) {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "0.0.78",
"version": "0.0.79-canary.7",
"dependencies": {
"@now/node-bridge": "0.1.4",
"execa": "^1.0.0",

View File

@@ -113,7 +113,7 @@ function excludeStaticDirectory(files) {
/**
* Enforce specific package.json configuration for smallest possible lambda
* @param {Object} defaultPackageJson
* @param {{dependencies?: any, devDependencies?: any, scripts?: any}} defaultPackageJson
*/
function normalizePackageJson(defaultPackageJson = {}) {
return {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node-bridge",
"version": "0.1.8",
"version": "0.1.9-canary.5",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"
}

View File

@@ -1,8 +1,8 @@
{
"name": "@now/node-server",
"version": "0.4.23",
"version": "0.4.24-canary.5",
"dependencies": {
"@now/node-bridge": "^0.1.8",
"@now/node-bridge": "^0.1.9-canary.5",
"fs-extra": "7.0.1"
},
"peerDependencies": {

View File

@@ -1,8 +1,8 @@
{
"name": "@now/node",
"version": "0.4.25",
"version": "0.4.26-canary.5",
"dependencies": {
"@now/node-bridge": "^0.1.8",
"@now/node-bridge": "^0.1.9-canary.5",
"fs-extra": "7.0.1"
},
"peerDependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/optipng",
"version": "0.4.6",
"version": "0.4.7-canary.5",
"dependencies": {
"multipipe": "2.0.3",
"optipng": "1.1.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@now/php",
"version": "0.4.10",
"version": "0.4.11-canary.5",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@now/python",
"version": "0.0.39",
"version": "0.0.40-canary.5",
"main": "index.js",
"license": "MIT",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/static-build",
"version": "0.4.14",
"version": "0.4.15-canary.5",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"
}

View File

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

View File

@@ -0,0 +1,5 @@
{
"dependencies": {
"isomorphic-unfetch": "latest"
}
}

View File

@@ -0,0 +1,6 @@
import fetch from 'isomorphic-unfetch';
// Fake fetch
fetch('https://example.com');
export default () => 'test';

View File

@@ -3,20 +3,40 @@ const path = require('path');
const runBuildLambda = require('../../lib/run-build-lambda');
const TWO_MINUTES = 120000;
const FOUR_MINUTES = 240000;
it('Should build the standard example', async () => {
const { buildResult } = await runBuildLambda(path.join(__dirname, 'standard'));
expect(buildResult.index).toBeDefined();
const filePaths = Object.keys(buildResult);
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();
}, TWO_MINUTES);
it(
'Should build the standard example',
async () => {
const { buildResult } = await runBuildLambda(
path.join(__dirname, 'standard'),
);
expect(buildResult.index).toBeDefined();
const filePaths = Object.keys(buildResult);
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();
},
TWO_MINUTES,
);
it(
'Should build the custom dependency test',
async () => {
const { buildResult } = await runBuildLambda(
path.join(__dirname, 'custom-dependency'),
);
expect(buildResult.index).toBeDefined();
},
FOUR_MINUTES,
);
it('Should throw when package.json or next.config.js is not the "src"', async () => {
try {
await runBuildLambda(path.join(__dirname, 'no-package-json-and-next-config'));
await runBuildLambda(
path.join(__dirname, 'no-package-json-and-next-config'),
);
} catch (err) {
expect(err.message).toMatch(/package\.json/);
}

View File

@@ -289,4 +289,111 @@ describe('normalizePackageJson', () => {
},
});
});
// https://github.com/zeit/next.js/issues/5700
it('should normalize user report zeit/next.js#5700 correctly', () => {
const defaultPackage = {
version: '1.0.0',
scripts: {
dev: 'next',
build: 'next build',
start: 'next start',
test: "xo && stylelint './pages/**/*.js' && jest",
},
main: 'pages/index.js',
license: 'MIT',
devDependencies: {
'babel-plugin-styled-components': '^1.8.0',
'eslint-config-xo-react': '^0.17.0',
'eslint-plugin-react': '^7.11.1',
jest: '^23.6.0',
'jest-styled-components': '^6.3.1',
'react-test-renderer': '^16.6.3',
stylelint: '^9.8.0',
'stylelint-config-recommended': '^2.1.0',
'stylelint-config-styled-components': '^0.1.1',
'stylelint-processor-styled-components': '^1.5.1',
xo: '^0.23.0',
},
dependencies: {
consola: '^2.2.6',
fontfaceobserver: '^2.0.13',
next: '^7.0.2',
react: '^16.6.3',
'react-dom': '^16.6.3',
'styled-components': '^4.1.1',
},
xo: {
extends: 'xo-react',
envs: 'browser',
esnext: true,
ignores: [
'test',
'pages/_document.js',
'pages/index.js',
'pages/home.js',
],
rules: {
'react/no-unescaped-entities': null,
},
},
jest: {
testEnvironment: 'node',
},
};
const result = normalizePackageJson(defaultPackage);
expect(result).toEqual({
version: '1.0.0',
scripts: {
dev: 'next',
build: 'next build',
'now-build': 'next build',
start: 'next start',
test: "xo && stylelint './pages/**/*.js' && jest",
},
main: 'pages/index.js',
license: 'MIT',
devDependencies: {
'babel-plugin-styled-components': '^1.8.0',
'eslint-config-xo-react': '^0.17.0',
'eslint-plugin-react': '^7.11.1',
jest: '^23.6.0',
'jest-styled-components': '^6.3.1',
'react-test-renderer': '^16.6.3',
stylelint: '^9.8.0',
'stylelint-config-recommended': '^2.1.0',
'stylelint-config-styled-components': '^0.1.1',
'stylelint-processor-styled-components': '^1.5.1',
next: 'canary',
'next-server': undefined,
xo: '^0.23.0',
},
dependencies: {
'next-server': 'canary',
consola: '^2.2.6',
fontfaceobserver: '^2.0.13',
next: undefined,
react: '^16.6.3',
'react-dom': '^16.6.3',
'styled-components': '^4.1.1',
},
xo: {
extends: 'xo-react',
envs: 'browser',
esnext: true,
ignores: [
'test',
'pages/_document.js',
'pages/index.js',
'pages/home.js',
],
rules: {
'react/no-unescaped-entities': null,
},
},
jest: {
testEnvironment: 'node',
},
});
});
});