Compare commits

..

11 Commits

Author SHA1 Message Date
Igor Klopov
77d445af71 Publish
- @now/bash@0.1.1
 - @now/build-utils@0.4.32
 - @now/cgi@0.0.15
 - @now/go@0.2.12
 - @now/html-minifier@1.0.7
 - @now/lambda@0.4.9
 - @now/md@0.4.9
 - @now/mdx-deck@0.4.18
 - @now/next@0.0.84
 - @now/node-bridge@0.1.10
 - @now/node-server@0.4.26
 - @now/node@0.4.28
 - @now/optipng@0.4.8
 - @now/php-bridge@0.4.13
 - @now/php@0.4.13
 - @now/static-build@0.4.17
 - @now/wordpress@0.4.14
2019-01-20 01:14:09 +03:00
Igor Klopov
79251ad180 [lerna] trying to set the order of package to publish 2019-01-20 00:01:16 +03:00
Igor Klopov
a215dc9103 [node-server] update tests for latest ncc 2019-01-19 23:23:44 +03:00
Nathan Rajlich
ea7d8f0f6c Update @zeit/ncc to v0.11.0 (#172) 2019-01-19 19:30:20 +03:00
Igor Klopov
2232efc984 fix misleading 'running npm install' messages in logs 2019-01-15 00:54:24 +03:00
Igor Klopov
b64ce0f3c0 [now-node] fix test for content-length 2019-01-14 03:27:15 +03:00
Igor Klopov
74233d50ad now/node: bump ncc 2019-01-12 05:20:37 +03:00
Nathan Rajlich
8aebec9fc3 Publish
- @now/bash@0.1.0
2019-01-10 12:27:59 -08:00
Igor Klopov
54584b7763 [tests] support NOW_TOKEN env var 2019-01-09 20:44:20 +03:00
Igor Klopov
d163fcbd71 [now-node-server] test for default content-type 2019-01-09 20:16:58 +03:00
Tim Neutkens
04c2996c76 [now-next] Add test for monorepo 2019-01-09 15:07:54 +01:00
38 changed files with 129 additions and 43 deletions

View File

@@ -2,7 +2,24 @@
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
"packages/now-build-utils",
"packages/now-node-bridge",
"packages/now-php-bridge",
"packages/now-bash",
"packages/now-cgi",
"packages/now-go",
"packages/now-html-minifier",
"packages/now-lambda",
"packages/now-md",
"packages/now-mdx-deck",
"packages/now-next",
"packages/now-node",
"packages/now-node-server",
"packages/now-optipng",
"packages/now-php",
"packages/now-python",
"packages/now-static-build",
"packages/now-wordpress"
],
"command": {
"publish": {

View File

@@ -1,6 +1,6 @@
{
"name": "@now/bash",
"version": "0.0.4-canary.2",
"version": "0.1.1",
"description": "Now 2.0 builder for HTTP endpoints written in Bash",
"main": "index.js",
"author": "Nathan Rajlich <nate@zeit.co>",

View File

@@ -55,7 +55,7 @@ async function scanParentDirs(destPath, scriptName) {
return { hasScript, hasPackageLockJson };
}
async function runNpmInstall(destPath, args = []) {
async function installDependencies(destPath, args = []) {
assert(path.isAbsolute(destPath));
let commandArgs = args;
@@ -102,6 +102,7 @@ async function runPackageJsonScript(destPath, scriptName) {
module.exports = {
runShellScript,
runNpmInstall,
installDependencies,
runNpmInstall: installDependencies,
runPackageJsonScript,
};

View File

@@ -1,6 +1,6 @@
{
"name": "@now/build-utils",
"version": "0.4.32-canary.6",
"version": "0.4.32",
"license": "MIT",
"dependencies": {
"async-retry": "1.2.3",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/cgi",
"version": "0.0.15-canary.0",
"version": "0.0.15",
"license": "MIT",
"scripts": {
"test": "best -I test/*.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/go",
"version": "0.2.12-canary.0",
"version": "0.2.12",
"license": "MIT",
"scripts": {
"test": "best -I test/*.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/html-minifier",
"version": "1.0.7-canary.0",
"version": "1.0.7",
"license": "MIT",
"dependencies": {
"html-minifier": "3.5.21"

View File

@@ -1,6 +1,6 @@
{
"name": "@now/lambda",
"version": "0.4.9-canary.0",
"version": "0.4.9",
"license": "MIT",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"

View File

@@ -1,6 +1,6 @@
{
"name": "@now/md",
"version": "0.4.9-canary.0",
"version": "0.4.9",
"license": "MIT",
"dependencies": {
"rehype-document": "^2.2.0",

View File

@@ -15,7 +15,7 @@ exports.build = async ({ files, entrypoint, workPath }) => {
const packageJson = { dependencies: { 'mdx-deck': '1.7.15' } };
const packageJsonPath = path.join(workPath, 'package.json');
await writeFile(packageJsonPath, JSON.stringify(packageJson));
console.log('running npm install...');
console.log('installing dependencies...');
process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1'; // TODO opts argument for runNpmInstall
await runNpmInstall(path.dirname(packageJsonPath), [
'--prod',

View File

@@ -1,6 +1,6 @@
{
"name": "@now/mdx-deck",
"version": "0.4.18-canary.1",
"version": "0.4.18",
"license": "MIT",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"

View File

@@ -168,7 +168,7 @@ exports.build = async ({ files, workPath, entrypoint }) => {
await writeNpmRc(workPath, process.env.NPM_AUTH_TOKEN);
}
console.log('running npm install...');
console.log('installing dependencies...');
await runNpmInstall(workPath, ['--prefer-offline']);
console.log('running user script...');
await runPackageJsonScript(workPath, 'now-build');

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "0.0.84-canary.0",
"version": "0.0.84",
"license": "MIT",
"dependencies": {
"@now/node-bridge": "0.1.4",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node-bridge",
"version": "0.1.10-canary.2",
"version": "0.1.10",
"license": "MIT",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"

View File

@@ -37,7 +37,7 @@ async function downloadInstallAndBundle(
console.log('downloading user files...');
const downloadedFiles = await download(files, userPath);
console.log('running npm install for user...');
console.log('installing dependencies for user\'s code...');
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint));
await runNpmInstall(entrypointFsDirname, npmArguments);
@@ -47,7 +47,7 @@ async function downloadInstallAndBundle(
'package.json': new FileBlob({
data: JSON.stringify({
dependencies: {
'@zeit/ncc': '0.6.0',
'@zeit/ncc': '0.11.0',
},
}),
}),
@@ -55,7 +55,7 @@ async function downloadInstallAndBundle(
nccPath,
);
console.log('running npm install for ncc...');
console.log('installing dependencies for ncc...');
await runNpmInstall(nccPath, npmArguments);
return [downloadedFiles, userPath, nccPath, entrypointFsDirname];
}
@@ -71,7 +71,8 @@ async function compile(workNccPath, downloadedFiles, entrypoint) {
preparedFiles[path.join('user', entrypoint)] = blob;
// eslint-disable-next-line no-restricted-syntax
for (const assetName of Object.keys(assets)) {
const blob2 = new FileBlob({ data: assets[assetName] });
const { source: data, permissions: mode } = assets[assetName];
const blob2 = new FileBlob({ data, mode });
preparedFiles[
path.join('user', path.dirname(entrypoint), assetName)
] = blob2;

View File

@@ -1,9 +1,9 @@
{
"name": "@now/node-server",
"version": "0.4.26-canary.7",
"version": "0.4.26",
"license": "MIT",
"dependencies": {
"@now/node-bridge": "^0.1.10-canary.2",
"@now/node-bridge": "^0.1.10",
"fs-extra": "7.0.1"
},
"peerDependencies": {

View File

@@ -0,0 +1,7 @@
const http = require('http');
const server = http.createServer((req, resp) => {
resp.end('RANDOMNESS_PLACEHOLDER');
});
server.listen();

View File

@@ -0,0 +1,6 @@
{
"version": 2,
"builds": [
{ "src": "index.js", "use": "@now/node-server" }
]
}

View File

@@ -0,0 +1,7 @@
const assert = require('assert');
module.exports = async ({ deploymentUrl, fetch, randomness }) => {
const resp = await fetch(`https://${deploymentUrl}/`);
assert.equal(resp.headers.get('content-type'), null);
assert.equal(await resp.text(), randomness);
};

View File

@@ -2,7 +2,7 @@ const http = require('http');
const isBundled = require('./is-bundled.js');
const server = http.createServer((req, resp) => {
resp.end(isBundled() ? 'RANDOMNESS_PLACEHOLDER:with-bundle' : '');
resp.end(isBundled() ? 'RANDOMNESS_PLACEHOLDER:with-bundle' : 'WITHOUT-BUNDLE-THAT-IS-WRONG');
});
server.listen();

View File

@@ -1,3 +1,4 @@
const path = require('path');
module.exports = () => path.basename(__filename) === 'index.js';
// eslint-disable-next-line no-eval
module.exports = () => path.basename(eval('__filename')) === 'index.js';

View File

@@ -2,7 +2,7 @@ const http = require('http');
const isBundled = require('./is-bundled.js');
const server = http.createServer((req, resp) => {
resp.end(isBundled() ? '' : 'RANDOMNESS_PLACEHOLDER:without-bundle');
resp.end(isBundled() ? 'WITH-BUNDLE-THAT-IS-WRONG' : 'RANDOMNESS_PLACEHOLDER:without-bundle');
});
server.listen();

View File

@@ -1,3 +1,4 @@
const path = require('path');
module.exports = () => path.basename(__filename) === 'index.js';
// eslint-disable-next-line no-eval
module.exports = () => path.basename(eval('__filename')) === 'index.js';

View File

@@ -35,7 +35,7 @@ async function downloadInstallAndBundle(
console.log('downloading user files...');
const downloadedFiles = await download(files, userPath);
console.log('running npm install for user...');
console.log('installing dependencies for user\'s code...');
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint));
await runNpmInstall(entrypointFsDirname, npmArguments);
@@ -45,7 +45,7 @@ async function downloadInstallAndBundle(
'package.json': new FileBlob({
data: JSON.stringify({
dependencies: {
'@zeit/ncc': '0.6.0',
'@zeit/ncc': '0.11.0',
},
}),
}),
@@ -53,7 +53,7 @@ async function downloadInstallAndBundle(
nccPath,
);
console.log('running npm install for ncc...');
console.log('installing dependencies for ncc...');
await runNpmInstall(nccPath, npmArguments);
return [downloadedFiles, nccPath, entrypointFsDirname];
}
@@ -69,7 +69,8 @@ async function compile(workNccPath, downloadedFiles, entrypoint) {
preparedFiles[path.join('user', entrypoint)] = blob;
// eslint-disable-next-line no-restricted-syntax
for (const assetName of Object.keys(assets)) {
const blob2 = new FileBlob({ data: assets[assetName] });
const { source: data, permissions: mode } = assets[assetName];
const blob2 = new FileBlob({ data, mode });
preparedFiles[
path.join('user', path.dirname(entrypoint), assetName)
] = blob2;

View File

@@ -1,9 +1,9 @@
{
"name": "@now/node",
"version": "0.4.28-canary.6",
"version": "0.4.28",
"license": "MIT",
"dependencies": {
"@now/node-bridge": "^0.1.10-canary.2",
"@now/node-bridge": "^0.1.10",
"fs-extra": "7.0.1"
},
"peerDependencies": {

View File

@@ -4,21 +4,24 @@ async function test1({ deploymentUrl, fetch, randomness }) {
const bodyMustBe = `${randomness}:content-length`;
const resp = await fetch(`https://${deploymentUrl}/test1.js`);
assert.equal(resp.status, 401);
assert.equal(resp.headers.get('content-length'), bodyMustBe.length);
assert.equal(await resp.text(), bodyMustBe);
assert.equal(resp.headers.get('content-length'), bodyMustBe.length);
}
async function test2({ deploymentUrl, fetch }) {
const bodyMustBe = '';
const resp = await fetch(`https://${deploymentUrl}/test2.js`);
assert.equal(resp.status, 502);
assert.equal(resp.status, 401);
assert.equal(await resp.text(), bodyMustBe);
assert.equal(resp.headers.get('content-length'), bodyMustBe.length);
}
async function test3({ deploymentUrl, fetch, randomness }) {
const bodyMustBe = `${randomness}:content-length`;
const resp = await fetch(`https://${deploymentUrl}/test3.js`);
assert.equal(resp.status, 401);
assert.equal(resp.headers.get('content-length'), null);
assert.equal(await resp.text(), bodyMustBe);
assert.equal(resp.headers.get('content-length'), null);
}
module.exports = async ({ deploymentUrl, fetch, randomness }) => {

View File

@@ -1,4 +1,4 @@
module.exports = (_, resp) => {
resp.writeHead(401, { 'content-length': 2 });
resp.end(`${process.env.RANDOMNESS_ENV_VAR}:content-length`);
resp.end();
};

View File

@@ -1,6 +1,6 @@
{
"name": "@now/optipng",
"version": "0.4.8-canary.0",
"version": "0.4.8",
"license": "MIT",
"dependencies": {
"multipipe": "2.0.3",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/php-bridge",
"version": "0.4.13-canary.1",
"version": "0.4.13",
"license": "MIT",
"dependencies": {
"fastcgi-client": "0.0.1"

View File

@@ -1,9 +1,9 @@
{
"name": "@now/php",
"version": "0.4.13-canary.2",
"version": "0.4.13",
"license": "MIT",
"dependencies": {
"@now/php-bridge": "^0.4.13-canary.1"
"@now/php-bridge": "^0.4.13"
},
"peerDependencies": {
"@now/build-utils": ">=0.0.1"

View File

@@ -1,6 +1,6 @@
{
"name": "@now/static-build",
"version": "0.4.17-canary.0",
"version": "0.4.17",
"license": "MIT",
"peerDependencies": {
"@now/build-utils": ">=0.0.1"

View File

@@ -1,9 +1,9 @@
{
"name": "@now/wordpress",
"version": "0.4.14-canary.1",
"version": "0.4.14",
"license": "MIT",
"dependencies": {
"@now/php-bridge": "^0.4.13-canary.1",
"@now/php-bridge": "^0.4.13",
"node-fetch": "2.3.0",
"yauzl": "2.10.0"
},

View File

@@ -20,6 +20,22 @@ it(
FOUR_MINUTES,
);
it(
'Should build the monorepo example',
async () => {
const { buildResult } = await runBuildLambda(
path.join(__dirname, 'monorepo'),
);
expect(buildResult['www/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();
},
FOUR_MINUTES,
);
it(
'Should build the legacy standard example',
async () => {

View File

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

View File

@@ -0,0 +1,3 @@
module.exports = {
target: 'serverless',
};

View File

@@ -0,0 +1,11 @@
{
"name": "monorepo",
"dependencies": {
"next": "^8.0.0-canary.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"scripts": {
"now-build": "next build"
}
}

View File

@@ -0,0 +1 @@
export default () => 'Index page';

View File

@@ -114,7 +114,11 @@ async function fetchWithAuth (url, opts = {}) {
if (!opts.headers.Authorization) {
if (!token) {
const { NOW_TOKEN_FACTORY_URL } = process.env;
const { NOW_TOKEN, NOW_TOKEN_FACTORY_URL } = process.env;
if (NOW_TOKEN) {
token = NOW_TOKEN;
} else
if (NOW_TOKEN_FACTORY_URL) {
const resp = await fetch(NOW_TOKEN_FACTORY_URL);
token = (await resp.json()).token;