Compare commits

..

11 Commits

Author SHA1 Message Date
Steven
75aefdddd6 Publish Stable
- @now/build-utils@1.1.1
 - now@16.6.3
 - now-client@6.0.0
 - @now/next@2.1.1
 - @now/node@1.2.1
 - @now/routing-utils@1.4.0
 - @now/static-build@0.13.1
2019-12-09 08:03:47 -05:00
Steven
566d82e873 Publish Canary
- now@16.6.3-canary.0
 - @now/next@2.1.1-canary.1
 - @now/node@1.2.1-canary.0
 - @now/routing-utils@1.3.4-canary.6
 - @now/static-build@0.13.1-canary.1
2019-12-06 19:49:27 -05:00
Steven
44ae0b654e [now-routing-utils] Use 308 status code (#3392)
We decided that all of the new properties should default to 301 status code for any redirects.
2019-12-07 00:38:26 +00:00
Steven
d8cfaae596 [now-node][now-next][now-static-build] Remove lockfiles from cache (#3391)
The lock files should not be cached because the user may wish to make a new deployment without a `yarn.lock` or `package-lock.json`.

This recently started causing problems because of the order of downloading cache changed from before user files to after user files.

So we need to be extra careful to only cache outputs and not source files.
2019-12-06 23:35:17 +00:00
Steven
a40e0f21ee Publish Canary
- @now/build-utils@1.1.1-canary.2
2019-12-06 15:57:33 -05:00
Steven
ac1f506c98 [now-build-utils] Add --no-audit flag to npm install (#3390)
This PR will reduce deployment time when a `package-lock.json` file is found by avoiding the audit step which usually [sends audit reports](https://docs.npmjs.com/cli/audit#description) to the registry.

The [--no-audit](https://docs.npmjs.com/cli/install) flag was introduced in [npm@6](
https://medium.com/npm-inc/announcing-npm-6-5d0b1799a905) which shipped with Node 10. However, using the flag with npm@5 does not do anything which is great because npm@5 doesn't audit. So this PR is backwards compatible.

### Performance

I tried `npm install` and `npm install --no-audit` with a large project, [StateOfJS](a9fa6d47f9/homepages/stateofjs), which has 2206 packages (audited 21778 packages).

I made sure to `rm -rf node_modules` each time and ran both commands 5 times to make sure it was always faster with `--no-audit`.

- Before: 61 seconds
- After: 49 seconds
2019-12-06 20:48:30 +00:00
Steven
68d5bdcf3d [script] Fix stable publish script (#3389)
Since we switched to a single branch (instead of master/canary), lerna gets confused about which packages to publish because stable and canary releases are in the same branch.

This PR fixes the confusion by looking at the git history and using [--force-publish](https://github.com/lerna/lerna/tree/master/commands/version#--force-publish) on the changed packages.

In order to avoid confusion for the person publishing, I removed the `yarn publish-stable` script in favor of `yarn changelog` which will print the change log and emit a script that can be used to publish stable.

<details><summary>View Example Output</summary>
<p>

```
$ yarn changelog
yarn run v1.19.1
$ node changelog.js
Changes since the last Stable release (21fe0a2):

- [now-cli] Change `--debug` to avoid debugging builders (#3386) [Steven]
- [now-next] Update routes for new check: true behavior (#3383) [JJ Kasper]
- [now-build-utils] Update Detectors API (#3384) [Nathan Rajlich]
- [now-client] Bump version (#3385) [Andy]
- [now-client] (Major) Split `now-client` options (#3382) [Andy]
- [now-cli][now-client] Fix user agent (#3381) [Steven]
- [now-client] Fix `main` in package.json (#3344) [Max]
- [now-build-utils] Change `script` to `scripts` in error message (#3376) [Andy]
- [now-cli] Add support for `check: true` routes in `now dev` (#3364) [Steven]
- [now-cli] Fix preinstall script on windows when `LOCALAPPDATA` is missing (#3365) [Steven]
- [now dev] skip installing already installed versioned runtimes (#3354) [Tommaso De Rossi]
- [now-routing-utils] Update `path-to-regexp` to v6.1.0 (#3361) [Steven]
- [now-routing-utils] Add mergeRoutes function (#3358) [Steven]
- [docs] Remove deprecated LambdaRuntimes (#3346) [Steven]
- [now-routing-utils] Add support for `check: true` (#3343) [Steven]
- [now-static-build] Cache `.cache` folder for gatsby deployments (#3260) (#3342) [Luc]

To publish a stable release, execute the following:

git pull && lerna version --message 'Publish Stable' --exact --force-publish=@now/build-utils,now,now-client,@now/next,@now/routing-utils,@now/static-build
```

</p>
</details>
2019-12-06 19:31:38 +00:00
Andy Bitz
beb51f8c67 Publish Stable
- now@16.6.2
2019-12-06 13:48:44 +01:00
Andy
b881cb7111 [now-cli] Remove github property from payload before sending it (#3388)
* [now-cli] Remove `github` property from payload before sending it

* Add test and remove unused one

* Remove .only

* Remove unused fixture

* Use correct github properties
2019-12-06 13:47:16 +01:00
Andy Bitz
d83bc59257 Publish Stable
- now@16.6.1
2019-12-06 00:18:57 +01:00
Steven
5be9f297de [now-cli] Change --debug to avoid debugging builders (#3386)
* [now-cli] Change `--debug` to avoid debugging builders

* Fix tests

* Replace test with on/off
2019-12-06 00:11:22 +01:00
26 changed files with 104 additions and 145 deletions

View File

@@ -12,12 +12,31 @@ if (!commit) {
throw new Error('Unable to find last publish commit');
}
const log = execSync(`git log --pretty=format:"- %s [%an]" ${commit}...HEAD`)
.toString()
.trim()
.split('\n')
.filter(line => !line.startsWith('- Publish Canary '))
.join('\n');
const log =
execSync(`git log --pretty=format:"- %s [%an]" ${commit}...HEAD`)
.toString()
.trim()
.split('\n')
.filter(line => !line.startsWith('- Publish Canary '))
.join('\n') || 'NO CHANGES DETECTED';
console.log(`Changes since the last Stable release (${commit.slice(0, 7)}):`);
console.log(`\n${log}\n`);
const pkgs =
Array.from(
new Set(
execSync(`git diff --name-only ${commit}...HEAD`)
.toString()
.trim()
.split('\n')
.filter(line => line.startsWith('packages/'))
.map(line => line.split('/')[1])
.map(pkgName => require(`./packages/${pkgName}/package.json`).name)
)
).join(',') || 'now';
console.log('To publish a stable release, execute the following:');
console.log(
`\ngit pull && lerna version --message 'Publish Stable' --exact --force-publish=${pkgs}\n`
);

View File

@@ -30,7 +30,7 @@
"scripts": {
"lerna": "lerna",
"bootstrap": "lerna bootstrap",
"publish-stable": "git pull && lerna version --message 'Publish Stable' --exact",
"publish-stable": "echo 'Run `yarn changelog` for instructions'",
"publish-canary": "git pull && lerna version prerelease --preid canary --message 'Publish Canary' --exact",
"publish-from-github": "./.circleci/publish.sh",
"changelog": "node changelog.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/build-utils",
"version": "1.1.1-canary.1",
"version": "1.1.1",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

View File

@@ -155,7 +155,7 @@ export async function runNpmInstall(
commandArgs = args.filter(a => a !== '--prefer-offline');
await spawnAsync(
'npm',
commandArgs.concat(['install', '--unsafe-perm']),
commandArgs.concat(['install', '--no-audit', '--unsafe-perm']),
opts
);
} else {

View File

@@ -1,6 +1,6 @@
{
"name": "now",
"version": "16.6.1-canary.1",
"version": "16.6.3",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Now",

View File

@@ -294,15 +294,11 @@ export default async function main(
parseEnv(argv['--env'])
);
// Enable debug mode for builders
const buildDebugEnv = debugEnabled ? { NOW_BUILDER_DEBUG: '1' } : {};
// Merge build env out of `build.env` from now.json, and `--build-env` args
const deploymentBuildEnv = Object.assign(
{},
parseEnv(localConfig.build && localConfig.build.env),
parseEnv(argv['--build-env']),
buildDebugEnv
parseEnv(argv['--build-env'])
);
// If there's any undefined values, then inherit them from this process

View File

@@ -83,12 +83,6 @@ async function createBuildProcess(
NOW_REGION: 'dev1',
};
// Builders won't show debug logs by default.
// The `NOW_BUILDER_DEBUG` env variable enables them.
if (debugEnabled) {
env.NOW_BUILDER_DEBUG = '1';
}
const buildProcess = fork(modulePath, [], {
cwd: workPath,
env,

View File

@@ -134,6 +134,7 @@ export default class Now extends EventEmitter {
// Ignore specific items from Now.json
delete requestBody.scope;
delete requestBody.github;
if (isLegacy) {
// Read `registry.npmjs.org` authToken from .npmrc

View File

@@ -307,10 +307,10 @@ test(
await testPath(200, '/sub', 'Sub Index Page');
await testPath(200, '/sub/another', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(301, '/index.html', '', { Location: '/' });
await testPath(301, '/about.html', '', { Location: '/about' });
await testPath(301, '/sub/index.html', '', { Location: '/sub' });
await testPath(301, '/sub/another.html', '', { Location: '/sub/another' });
await testPath(308, '/index.html', '', { Location: '/' });
await testPath(308, '/about.html', '', { Location: '/about' });
await testPath(308, '/sub/index.html', '', { Location: '/sub' });
await testPath(308, '/sub/another.html', '', { Location: '/sub/another' });
})
);
@@ -324,10 +324,10 @@ test(
await testPath(200, '/sub/', 'Sub Index Page');
await testPath(200, '/sub/another/', 'Sub Another Page');
await testPath(200, '/style.css/', 'body { color: green }');
await testPath(301, '/index.html', '', { Location: '/' });
await testPath(301, '/about.html', '', { Location: '/about/' });
await testPath(301, '/sub/index.html', '', { Location: '/sub/' });
await testPath(301, '/sub/another.html', '', {
await testPath(308, '/index.html', '', { Location: '/' });
await testPath(308, '/about.html', '', { Location: '/about/' });
await testPath(308, '/sub/index.html', '', { Location: '/sub/' });
await testPath(308, '/sub/another.html', '', {
Location: '/sub/another/',
});
}
@@ -344,9 +344,9 @@ test(
await testPath(200, '/sub/index.html/', 'Sub Index Page');
await testPath(200, '/sub/another.html/', 'Sub Another Page');
await testPath(200, '/style.css/', 'body { color: green }');
await testPath(307, '/about.html', '', { Location: '/about.html/' });
await testPath(307, '/sub', '', { Location: '/sub/' });
await testPath(307, '/sub/another.html', '', {
await testPath(308, '/about.html', '', { Location: '/about.html/' });
await testPath(308, '/sub', '', { Location: '/sub/' });
await testPath(308, '/sub/another.html', '', {
Location: '/sub/another.html/',
});
})
@@ -362,9 +362,9 @@ test(
await testPath(200, '/sub/index.html', 'Sub Index Page');
await testPath(200, '/sub/another.html', 'Sub Another Page');
await testPath(200, '/style.css', 'body { color: green }');
await testPath(307, '/about.html/', '', { Location: '/about.html' });
await testPath(307, '/sub/', '', { Location: '/sub' });
await testPath(307, '/sub/another.html/', '', {
await testPath(308, '/about.html/', '', { Location: '/about.html' });
await testPath(308, '/sub/', '', { Location: '/sub' });
await testPath(308, '/sub/another.html/', '', {
Location: '/sub/another.html',
});
})

View File

@@ -122,11 +122,6 @@ module.exports = async session => {
'single-dotfile': {
'.testing': 'i am a dotfile',
},
'config-alias-property': {
'now.json':
'{ "alias": "test.now.sh", "builds": [ { "src": "*.html", "use": "@now/static" } ] }',
'index.html': '<span>test alias</span',
},
'config-scope-property-email': {
'now.json': `{ "scope": "${session}@zeit.pub", "builds": [ { "src": "*.html", "use": "@now/static" } ], "version": 2 }`,
'index.html': '<span>test scope email</span',
@@ -204,7 +199,7 @@ fs.writeFileSync(
'index.js',
fs
.readFileSync('index.js', 'utf8')
.replace('BUILD_ENV_DEBUG', process.env.NOW_BUILDER_DEBUG),
.replace('BUILD_ENV_DEBUG', process.env.NOW_BUILDER_DEBUG ? 'on' : 'off'),
);
`,
'index.js': `
@@ -463,6 +458,18 @@ CMD ["node", "index.js"]`,
},
}),
},
'github-and-scope-config': {
'index.txt': 'I Am a Website!',
'now.json': JSON.stringify({
scope: 'i-do-not-exist',
github: {
autoAlias: true,
autoJobCancelation: true,
enabled: true,
silent: true
}
})
}
};
for (const typeName of Object.keys(spec)) {

View File

@@ -1427,35 +1427,6 @@ test('ensure we render a prompt when deploying home directory', async t => {
t.true(stderr.includes('> Aborted'));
});
test('ensure the `alias` property is not sent to the API', async t => {
const directory = fixture('config-alias-property');
const { stdout, stderr, exitCode } = await execa(
binaryPath,
[directory, '--public', '--name', session, ...defaultArgs, '--force'],
{
reject: false,
}
);
console.log(stderr);
console.log(stdout);
console.log(exitCode);
// Ensure the exit code is right
t.is(exitCode, 0);
// Test if the output is really a URL
const { href, host } = new URL(stdout);
t.is(host.split('-')[0], session);
// Send a test request to the deployment
const response = await fetch(href);
const contentType = response.headers.get('content-type');
t.is(contentType, 'text/html; charset=utf-8');
});
test('ensure the `scope` property works with email', async t => {
const directory = fixture('config-scope-property-email');
@@ -1995,7 +1966,7 @@ test('use `--debug` CLI flag', async t => {
// get the content
const response = await fetch(href);
const content = await response.text();
t.is(content.trim(), '1');
t.is(content.trim(), 'off');
});
test('try to deploy non-existing path', async t => {

View File

@@ -919,35 +919,6 @@ test('ensure we render a prompt when deploying home directory', async t => {
t.true(stderr.includes('> Aborted'));
});
test('ensure the `alias` property is not sent to the API', async t => {
const directory = fixture('config-alias-property');
const { stdout, stderr, exitCode } = await execa(
binaryPath,
[directory, '--public', '--name', session, ...defaultArgs, '--force'],
{
reject: false,
}
);
console.log(stderr);
console.log(stdout);
console.log(exitCode);
// Ensure the exit code is right
t.is(exitCode, 0);
// Test if the output is really a URL
const { href, host } = new URL(stdout);
t.is(host.split('-')[0], session);
// Send a test request to the deployment
const response = await fetch(href);
const contentType = response.headers.get('content-type');
t.is(contentType, 'text/html; charset=utf-8');
});
test('ensure the `scope` property works with email', async t => {
const directory = fixture('config-scope-property-email');
@@ -1456,7 +1427,7 @@ test('use `--debug` CLI flag', async t => {
// get the content
const response = await fetch(href);
const content = await response.text();
t.is(content.trim(), '1');
t.is(content.trim(), 'off');
});
test('try to deploy non-existing path', async t => {
@@ -2056,7 +2027,6 @@ test('deploy a Lambda with a specific runtime', async t => {
t.is(build.use, 'now-php@0.0.7', JSON.stringify(build, null, 2));
});
// We need to skip this test until `now-php` supports Runtime version 3
test('fail to deploy a Lambda with a specific runtime but without a locked version', async t => {
const directory = fixture('lambda-with-invalid-runtime');
const output = await execute([directory]);
@@ -2069,6 +2039,13 @@ test('fail to deploy a Lambda with a specific runtime but without a locked versi
);
});
test('ensure `github` and `scope` are not sent to the API', async t => {
const directory = fixture('github-and-scope-config');
const output = await execute([directory]);
t.is(output.exitCode, 0, formatOutput(output));
});
test.after.always(async () => {
// Make sure the token gets revoked
await execa(binaryPath, ['logout', ...defaultArgs]);

View File

@@ -1,6 +1,6 @@
{
"name": "now-client",
"version": "6.0.0-canary.1",
"version": "6.0.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://zeit.co",

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "2.1.1-canary.0",
"version": "2.1.1",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/next-js",

View File

@@ -910,7 +910,7 @@ export const build = async ({
export const prepareCache = async ({
workPath,
entrypoint,
}: PrepareCacheOptions) => {
}: PrepareCacheOptions): Promise<Files> => {
debug('Preparing cache...');
const entryDirectory = path.dirname(entrypoint);
const entryPath = path.join(workPath, entryDirectory);
@@ -930,8 +930,6 @@ export const prepareCache = async ({
const cache = {
...(await glob(path.join(cacheEntrypoint, 'node_modules/**'), workPath)),
...(await glob(path.join(cacheEntrypoint, '.next/cache/**'), workPath)),
...(await glob(path.join(cacheEntrypoint, 'package-lock.json'), workPath)),
...(await glob(path.join(cacheEntrypoint, 'yarn.lock'), workPath)),
};
debug('Cache file manifest produced');
return cache;

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node",
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/node-js",

View File

@@ -393,10 +393,9 @@ export async function build({
return { output: lambda, watch };
}
export async function prepareCache({ workPath }: PrepareCacheOptions) {
return {
...(await glob('node_modules/**', workPath)),
...(await glob('package-lock.json', workPath)),
...(await glob('yarn.lock', workPath)),
};
export async function prepareCache({
workPath,
}: PrepareCacheOptions): Promise<Files> {
const cache = await glob('node_modules/**', workPath);
return cache;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@now/routing-utils",
"version": "1.3.4-canary.5",
"version": "1.4.0",
"description": "ZEIT Now routing utilities",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",

View File

@@ -30,12 +30,12 @@ export function convertCleanUrls(
routes.push({
src: '^/(?:(.+)/)?index(?:\\.html)?/?$',
headers: { Location: loc },
status: 301,
status: 308,
});
routes.push({
src: '^/(.*)\\.html/?$',
headers: { Location: loc },
status: 301,
status: 308,
});
}
return routes;
@@ -48,7 +48,7 @@ export function convertRedirects(redirects: NowRedirect[]): Route[] {
const route: Route = {
src,
headers: { Location: loc },
status: r.statusCode || 307,
status: r.statusCode || 308,
};
return route;
});
@@ -84,13 +84,13 @@ export function convertTrailingSlash(enable: boolean): Route[] {
routes.push({
src: '^/(.*[^\\/])$',
headers: { Location: '/$1/' },
status: 307,
status: 308,
});
} else {
routes.push({
src: '^/(.*)\\/$',
headers: { Location: '/$1' },
status: 307,
status: 308,
});
}
return routes;

View File

@@ -501,12 +501,12 @@ describe('getTransformedRoutes', () => {
{
src: '^/(?:(.+)/)?index(?:\\.html)?/?$',
headers: { Location: '/$1' },
status: 301,
status: 308,
},
{
src: '^/(.*)\\.html/?$',
headers: { Location: '/$1' },
status: 301,
status: 308,
},
{
src: '^/help$',

View File

@@ -58,12 +58,12 @@ test('convertCleanUrls true', () => {
{
src: '^/(?:(.+)/)?index(?:\\.html)?/?$',
headers: { Location: '/$1' },
status: 301,
status: 308,
},
{
src: '^/(.*)\\.html/?$',
headers: { Location: '/$1' },
status: 301,
status: 308,
},
];
deepEqual(actual, expected);
@@ -94,12 +94,12 @@ test('convertCleanUrls true, trailingSlash true', () => {
{
src: '^/(?:(.+)/)?index(?:\\.html)?/?$',
headers: { Location: '/$1/' },
status: 301,
status: 308,
},
{
src: '^/(.*)\\.html/?$',
headers: { Location: '/$1/' },
status: 301,
status: 308,
},
];
deepEqual(actual, expected);
@@ -165,12 +165,12 @@ test('convertRedirects', () => {
{
src: '^\\/some\\/old\\/path$',
headers: { Location: '/some/new/path' },
status: 307,
status: 308,
},
{
src: '^\\/next(\\.js)?$',
headers: { Location: 'https://nextjs.org' },
status: 307,
status: 308,
},
{
src: '^\\/firebase(?:\\/(.*))$',
@@ -180,12 +180,12 @@ test('convertRedirects', () => {
{
src: '^\\/projects(?:\\/([^\\/#\\?]+?))(?:\\/([^\\/#\\?]+?))$',
headers: { Location: '/projects.html?id=$1&action=$2' },
status: 307,
status: 308,
},
{
src: '^\\/old(?:\\/([^\\/#\\?]+?))\\/path$',
headers: { Location: '/new/path/$1' },
status: 307,
status: 308,
},
];
@@ -310,7 +310,7 @@ test('convertTrailingSlash enabled', () => {
{
src: '^/(.*[^\\/])$',
headers: { Location: '/$1/' },
status: 307,
status: 308,
},
];
deepEqual(actual, expected);
@@ -328,7 +328,7 @@ test('convertTrailingSlash disabled', () => {
{
src: '^/(.*)\\/$',
headers: { Location: '/$1' },
status: 307,
status: 308,
},
];
deepEqual(actual, expected);

View File

@@ -1,6 +1,6 @@
{
"name": "@now/static-build",
"version": "0.13.1-canary.0",
"version": "0.13.1",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/static-builds",
@@ -14,7 +14,8 @@
},
"scripts": {
"build": "./build.sh",
"test-integration-once": "jest --env node --verbose --runInBand",
"test-unit": "jest --env node --verbose --runInBand test/unit.test.js",
"test-integration-once": "jest --env node --verbose --runInBand test/integration.test.js",
"prepublishOnly": "./build.sh"
},
"devDependencies": {

View File

@@ -415,12 +415,9 @@ export async function build({
export async function prepareCache({
entrypoint,
workPath,
}: PrepareCacheOptions) {
}: PrepareCacheOptions): Promise<Files> {
// default cache paths
const defaultCacheFiles = await glob(
'{node_modules/**,package-lock.json,yarn.lock}',
workPath
);
const defaultCacheFiles = await glob('node_modules/**', workPath);
// framework specific cache paths
let frameworkCacheFiles: { [path: string]: FileFsRef } | null = null;

View File

@@ -0,0 +1 @@
file2

View File

@@ -2,26 +2,24 @@ const { prepareCache } = require('../dist');
const path = require('path');
describe('prepareCache', () => {
test('should cache yarn.lock, package-lock.json and node_modules', async () => {
test('should cache node_modules', async () => {
const files = await prepareCache({
workPath: path.resolve(__dirname, './cache-fixtures/default'),
entrypoint: 'index.js',
});
expect(files['yarn.lock']).toBeDefined();
expect(files['package-lock.json']).toBeDefined();
expect(files['node_modules/file']).toBeDefined();
expect(files['index.js']).toBeUndefined();
});
test('should cache `.cache` folder for gatsby deployments', async () => {
test('should cache node_modules and `.cache` folder for gatsby deployments', async () => {
const files = await prepareCache({
workPath: path.resolve(__dirname, './cache-fixtures/gatsby'),
entrypoint: 'package.json',
});
expect(files['node_modules/file2']).toBeDefined();
expect(files['.cache/file']).toBeDefined();
expect(files['yarn.lock']).toBeDefined();
expect(files['package.json']).toBeUndefined();
});
});