Compare commits

..

6 Commits

Author SHA1 Message Date
Nathan Rajlich
63cc9009c8 Publish Stable
- @vercel/frameworks@0.0.15
 - @vercel/build-utils@2.4.0
 - @vercel/cgi@1.0.6
 - vercel@19.1.0
 - @vercel/client@8.1.0
 - @vercel/go@1.1.2
 - @vercel/next@2.6.6
 - @vercel/node-bridge@1.3.1
 - @vercel/node@1.7.0
 - @vercel/python@1.2.2
 - @vercel/routing-utils@1.8.3
 - @vercel/ruby@1.2.2
 - @vercel/static-build@0.17.2
2020-06-11 16:30:31 -07:00
Nathan Rajlich
ccf6e3c432 Publish Canary
- vercel@19.0.2-canary.17
 - @vercel/client@8.0.2-canary.4
2020-06-11 15:17:05 -07:00
Steven
8d015e3138 [client] Fix .vercelignore override default ignore list (#4627)
- Fixes #3747 
- Related to #4325
- Related to [tweet](https://twitter.com/Rich_Harris/status/1270871878018699264) from @Rich-Harris
- Docs updated in https://github.com/vercel/docs/pull/1909

There was an issue that was likely introduced when we started using `@vercel/client`: the [default ignore list](https://vercel.com/docs/v2/build-step#ignored-files-and-folders) could not be overridden. This is because the default `ignores` array was always used instead of the combined `default ignore + user ignore`. The solution was to utilize [`recursive-readdir` ignore function](https://www.npmjs.com/package/recursive-readdir#usage) along with [`ig.ignores` function](https://www.npmjs.com/package/ignore#usage) so that the combined result is used for ignoring files while walking the file tree.

This ensures that the fix from PR #4325 is still effective and also fixes the longstanding bug from Issue #3747.
2020-06-11 18:15:16 -04:00
Nathan Rajlich
42f2fa1a20 [cli] Invalidate the configuration if vercel.json is deleted (#4629)
Before this, if the `vercel.json` file gets deleted while the dev server
is running, then it would still act like the file exists since it would
use the cached version.

Now it properly invalidates to an empty configuration if the
`vercel.json` file does not exist.
2020-06-11 22:06:44 +00:00
Steven
8397aac0e3 [github] Update codeowners (#4630)
* Update codeowners

* Make TooTallNate taller
2020-06-11 16:59:18 -04:00
Nathan Rajlich
7bcdc144eb [cli] Update "npm-install-error" link to "npm-install-failed-dev" (#4628)
Depends on https://github.com/vercel/docs/pull/1908.
2020-06-11 19:08:48 +00:00
29 changed files with 116 additions and 100 deletions

28
.github/CODEOWNERS vendored
View File

@@ -1,27 +1,27 @@
# Documentation
# https://help.github.com/en/articles/about-code-owners
* @tootallnate
* @TooTallNate
/.github/workflows @AndyBitz @styfle
/packages/frameworks @AndyBitz
/packages/now-cli/src/commands/dev/ @tootallnate @styfle @AndyBitz
/packages/now-cli/src/util/dev/ @tootallnate @styfle @AndyBitz
/packages/now-cli/src/commands/domains/ @javivelasco @mglagola @anatrajkovska
/packages/now-cli/src/commands/certs/ @javivelasco @mglagola @anatrajkovska
/packages/now-cli/src/commands/dev @TooTallNate @styfle @AndyBitz
/packages/now-cli/src/util/dev @TooTallNate @styfle @AndyBitz
/packages/now-cli/src/commands/domains @javivelasco @mglagola @anatrajkovska
/packages/now-cli/src/commands/certs @javivelasco @mglagola @anatrajkovska
/packages/now-cli/src/commands/env @styfle @lucleray
/packages/now-client @rdev
/packages/now-build-utils @styfle @AndyBitz
/packages/now-node @styfle @tootallnate @lucleray
/packages/now-node-bridge @styfle @tootallnate @lucleray
/packages/now-client @rdev @styfle @TooTallNate
/packages/now-build-utils @styfle @AndyBitz @TooTallNate
/packages/now-node @styfle @TooTallNate @lucleray
/packages/now-node-bridge @styfle @TooTallNate @lucleray
/packages/now-next @Timer @ijjk
/packages/now-go @styfle @sophearak
/packages/now-python @styfle @sophearak
/packages/now-ruby @styfle @coetry @nathancahill
/packages/now-go @styfle @TooTallNate
/packages/now-python @styfle @TooTallNate
/packages/now-ruby @styfle @coetry @TooTallNate
/packages/now-static-build @styfle @AndyBitz
/packages/now-routing-utils @styfle @dav-is @ijjk
/examples @mcsdevv @timothyis
/examples/create-react-app @Timer
/examples/nextjs @timneutkens
/examples/nextjs @timneutkens @Timer
/examples/hugo @mcsdevv @timothyis @styfle
/examples/jekyll @mcsdevv @timothyis @sarupbanskota
/examples/jekyll @mcsdevv @timothyis @styfle
/examples/zola @mcsdevv @timothyis @styfle

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/frameworks",
"version": "0.0.15-canary.5",
"version": "0.0.15",
"main": "frameworks.json",
"license": "UNLICENSED",
"scripts": {

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/cgi",
"version": "1.0.6-canary.0",
"version": "1.0.6",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "19.0.2-canary.16",
"version": "19.1.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Now",
@@ -62,13 +62,13 @@
"node": ">= 10"
},
"dependencies": {
"@vercel/build-utils": "2.3.2-canary.6",
"@vercel/go": "1.1.2-canary.2",
"@vercel/next": "2.6.5",
"@vercel/node": "1.6.2-canary.6",
"@vercel/python": "1.2.2-canary.2",
"@vercel/ruby": "1.2.2-canary.1",
"@vercel/static-build": "0.17.2-canary.1"
"@vercel/build-utils": "2.4.0",
"@vercel/go": "1.1.2",
"@vercel/next": "2.6.6",
"@vercel/node": "1.7.0",
"@vercel/python": "1.2.2",
"@vercel/ruby": "1.2.2",
"@vercel/static-build": "0.17.2"
},
"devDependencies": {
"@sentry/node": "5.5.0",

View File

@@ -264,7 +264,7 @@ async function npmInstall(
? '`npm` is not installed'
: 'Failed to install `vercel dev` dependencies',
code: 'NPM_INSTALL_ERROR',
link: 'https://vercel.link/npm-install-error',
link: 'https://vercel.link/npm-install-failed-dev',
});
}
} finally {

View File

@@ -533,18 +533,11 @@ export default class DevServer {
// The default empty `vercel.json` is used to serve all files as static
// when no `vercel.json` is present
let configPath = 'vercel.json';
let config: NowConfig = this.cachedNowConfig || {
let config: NowConfig = {
version: 2,
[fileNameSymbol]: configPath,
};
// We need to delete these properties for zero config to work
// with file changes
if (this.cachedNowConfig) {
delete this.cachedNowConfig.builds;
delete this.cachedNowConfig.routes;
}
try {
configPath = getNowConfigPath(this.cwd);
this.output.debug(`Reading ${configPath}`);
@@ -784,7 +777,6 @@ export default class DevServer {
this.getLocalEnv('.env.build', nowConfigBuild.env),
]);
const allEnv = { ...buildEnv, ...runEnv };
Object.assign(process.env, allEnv);
this.envConfigs = { buildEnv, runEnv, allEnv };
const opts = { output: this.output, isBuilds: true };

View File

@@ -0,0 +1,3 @@
export default (req, res) => {
res.send(process.env);
};

View File

@@ -0,0 +1 @@
{ "env": { "FOO": "bar" } }

View File

@@ -386,7 +386,40 @@ test('[vercel dev] prints `npm install` errors', async t => {
t.truthy(
result.stderr.includes('Failed to install `vercel dev` dependencies')
);
t.truthy(result.stderr.includes('https://vercel.link/npm-install-error'));
t.truthy(
result.stderr.includes('https://vercel.link/npm-install-failed-dev')
);
});
test('[vercel dev] `vercel.json` should be invalidated if deleted', async t => {
const dir = fixture('invalidate-vercel-config');
const configPath = join(dir, 'vercel.json');
const originalConfig = await fs.readJSON(configPath);
const { dev, port, readyResolver } = await testFixture(dir);
try {
await readyResolver;
{
// Env var should be set from `vercel.json`
const res = await fetch(`http://localhost:${port}/api`);
const body = await res.json();
t.is(body.FOO, 'bar');
}
{
// Env var should not be set after `vercel.json` is deleted
await fs.remove(configPath);
await sleep(1000);
const res = await fetch(`http://localhost:${port}/api`);
const body = await res.json();
t.is(body.FOO, undefined);
}
} finally {
await dev.kill('SIGTERM');
await fs.writeJSON(configPath, originalConfig);
}
});
test('[vercel dev] reflects changes to config and env without restart', async t => {

View File

@@ -3,4 +3,6 @@ lib
node_modules
*.log
!tests/fixtures/nowignore/node_modules
!tests/fixtures/nowignore/node_modules
!tests/fixtures/vercelignore-allow-nodemodules/node_modules
!tests/fixtures/vercelignore-allow-nodemodules/sub/node_modules

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "8.0.2-canary.3",
"version": "8.1.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",

View File

@@ -77,43 +77,22 @@ const maybeRead = async function<T>(path: string, default_: T) {
}
};
export async function readdirRelative(
path: string,
ignores: string[],
cwd: string
): Promise<string[]> {
const preprocessedIgnores = ignores.map(ignore => {
if (ignore.endsWith('/')) {
return ignore.slice(0, -1);
}
return ignore;
});
const dirContents = await readdir(path, preprocessedIgnores);
return dirContents.map(filePath => relative(cwd, filePath));
}
export async function buildFileTree(
path: string | string[],
isDirectory: boolean,
debug: Debug
): Promise<string[]> {
// Get .nowignore
let { ig, ignores } = await getVercelIgnore(path);
debug(`Found ${ig.ignores.length} rules in .nowignore`);
let fileList: string[];
let { ig } = await getVercelIgnore(path);
debug(`Found ${ig.ignores.length} rules in .vercelignore`);
debug('Building file tree...');
if (isDirectory && !Array.isArray(path)) {
// Directory path
const cwd = process.cwd();
const relativeFileList = await readdirRelative(path, ignores, cwd);
fileList = ig
.filter(relativeFileList)
.map((relativePath: string) => join(cwd, relativePath));
const ignores = (absPath: string) => ig.ignores(relative(cwd, absPath));
fileList = await readdir(path, [ignores]);
debug(`Read ${fileList.length} files in the specified directory`);
} else if (Array.isArray(path)) {
// Array of file paths

View File

@@ -0,0 +1 @@
EXCLUDE="this file should be ignored"

View File

@@ -0,0 +1,6 @@
# literally dont ignore the node_modules directory
# so basically include the node_modules directory recursively
!node_modules/
# ignore this file in addition to the defaults
exclude.txt

View File

@@ -0,0 +1 @@
Should be ignored

View File

@@ -0,0 +1 @@
Hello World

View File

@@ -0,0 +1 @@
Should be included

View File

@@ -1,7 +1,8 @@
import path from 'path';
import { buildFileTree, getVercelIgnore, readdirRelative } from '../src/utils';
import { join, resolve } from 'path';
import { buildFileTree } from '../src/utils';
const ignoreFixturePath = path.resolve(__dirname, 'fixtures', 'nowignore');
const fixture = (name: string) => resolve(__dirname, 'fixtures', name);
const noop = () => {};
const normalizeWindowsPaths = (files: string[]) => {
if (process.platform === 'win32') {
@@ -10,34 +11,29 @@ const normalizeWindowsPaths = (files: string[]) => {
return files;
};
describe('buildFileTree', () => {
it('will include the correct files', async () => {
const expected = [
'tests/fixtures/nowignore/.nowignore',
'tests/fixtures/nowignore/index.txt',
].map(p => path.join(process.cwd(), p));
const actual = await buildFileTree(ignoreFixturePath, true, () => {});
expect(normalizeWindowsPaths(expected).sort()).toEqual(
normalizeWindowsPaths(actual).sort()
);
});
});
const toAbsolutePaths = (cwd: string, files: string[]) =>
files.map(p => join(cwd, p));
describe('readdirRelative', () => {
it('will ignore the hardcoded default ignores', async () => {
// most importantly, this method should not walk/include node_modules
const expected = [
'tests/fixtures/nowignore/.nowignore',
'tests/fixtures/nowignore/ignore.txt',
'tests/fixtures/nowignore/index.txt',
'tests/fixtures/nowignore/folder/ignore.txt',
];
const { ignores } = await getVercelIgnore(ignoreFixturePath);
const actual = await readdirRelative(
ignoreFixturePath,
ignores,
process.cwd()
describe('buildFileTree', () => {
it('should exclude files using `.nowignore` blocklist', async () => {
const cwd = fixture('nowignore');
const expected = toAbsolutePaths(cwd, ['.nowignore', 'index.txt']);
const actual = await buildFileTree(cwd, true, noop);
expect(normalizeWindowsPaths(expected).sort()).toEqual(
normalizeWindowsPaths(actual).sort()
);
});
it('should include the node_modules using `.vercelignore` allowlist', async () => {
const cwd = fixture('vercelignore-allow-nodemodules');
const expected = toAbsolutePaths(cwd, [
'node_modules/one.txt',
'sub/node_modules/two.txt',
'sub/include.txt',
'.vercelignore',
'hello.txt',
]);
const actual = await buildFileTree(cwd, true, noop);
expect(normalizeWindowsPaths(expected).sort()).toEqual(
normalizeWindowsPaths(actual).sort()
);

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/go",
"version": "1.1.2-canary.2",
"version": "1.1.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/next",
"version": "2.6.5",
"version": "2.6.6",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node-bridge",
"version": "1.3.1-canary.2",
"version": "1.3.1",
"license": "MIT",
"main": "./index.js",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/node",
"version": "1.6.2-canary.6",
"version": "1.7.0",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/python",
"version": "1.2.2-canary.2",
"version": "1.2.2",
"main": "./dist/index.js",
"license": "MIT",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/routing-utils",
"version": "1.8.3-canary.6",
"version": "1.8.3",
"description": "Vercel routing utilities",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",

View File

@@ -1,7 +1,7 @@
{
"name": "@vercel/ruby",
"author": "Nathan Cahill <nathan@nathancahill.com>",
"version": "1.2.2-canary.1",
"version": "1.2.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/static-build",
"version": "0.17.2-canary.1",
"version": "0.17.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/static-builds",