Compare commits

...

7 Commits

Author SHA1 Message Date
Nathan Rajlich
0b60467d2f Publish Stable
- @vercel/build-utils@2.7.0
 - vercel@21.1.0
 - @vercel/client@9.0.5
 - @vercel/go@1.1.7
 - @vercel/node-bridge@1.3.2
 - @vercel/node@1.9.0
 - @vercel/python@1.2.4
 - @vercel/routing-utils@1.9.2
 - @vercel/ruby@1.2.5
2021-01-13 17:18:43 -08:00
Nathan Rajlich
4384a6104f Publish Canary
- vercel@21.0.2-canary.10
2021-01-13 11:42:54 -08:00
Nathan Rajlich
f40f95ff37 [cli] Respect the directoryListing Project setting in vc dev (#5690)
Implements the ["Directory Listing" Project setting](https://vercel.com/changelog/listing-the-content-of-directories-can-now-be-toggled) in `vercel dev`.

The Dev integration test file has been updated to allow specifying custom Project settings that will be `PATCH`'d to the project document before running `vc deploy` / `vc dev`.
2021-01-13 15:36:12 +00:00
Nathan Rajlich
90c05250b0 Publish Canary
- vercel@21.0.2-canary.9
 - @vercel/go@1.1.7-canary.1
 - @vercel/node@1.8.6-canary.5
2021-01-12 17:47:24 -08:00
Nathan Rajlich
030880fe74 [node][go] Fix order of exit code in startDevServer() error reason (#5688) 2021-01-12 17:02:55 -08:00
Nathan Rajlich
02bc88f33b [cli] Use cmd() formatting for "npm not installed" message (#5687)
* [cli] Use `cmd()` formatting for "npm not installed" message

* Fix build
2021-01-12 17:02:36 -08:00
Nathan Rajlich
38ff557cad [cli] Skip "00-list-directory" and "temporary directory listing" tests temporarily (#5689)
* [cli] Skip "now-dev-directory-listing" test temporarily

* Disable correct tests

* Fix `vc env` test
2021-01-12 17:01:56 -08:00
16 changed files with 87 additions and 56 deletions

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "vercel",
"version": "21.0.2-canary.8",
"version": "21.1.0",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Vercel",
@@ -61,11 +61,11 @@
"node": ">= 10"
},
"dependencies": {
"@vercel/build-utils": "2.6.1-canary.2",
"@vercel/go": "1.1.7-canary.0",
"@vercel/node": "1.8.6-canary.4",
"@vercel/python": "1.2.4-canary.0",
"@vercel/ruby": "1.2.5-canary.0",
"@vercel/build-utils": "2.7.0",
"@vercel/go": "1.1.7",
"@vercel/node": "1.9.0",
"@vercel/python": "1.2.4",
"@vercel/ruby": "1.2.5",
"update-notifier": "4.1.0"
},
"devDependencies": {

View File

@@ -231,6 +231,7 @@ export interface ProjectSettings {
outputDirectory?: string | null;
rootDirectory?: string | null;
autoExposeSystemEnvs?: boolean;
directoryListing?: boolean;
}
export interface Project extends ProjectSettings {

View File

@@ -9,9 +9,10 @@ import { mkdirp, readJSON, writeJSON } from 'fs-extra';
import { NowBuildError, PackageJson } from '@vercel/build-utils';
import cliPkg from '../pkg';
import { NoBuilderCacheError } from '../errors-ts';
import cmd from '../output/cmd';
import { Output } from '../output';
import { getDistTag } from '../get-dist-tag';
import { NoBuilderCacheError } from '../errors-ts';
import * as staticBuilder from './static-builder';
import { BuilderWithPackage } from './types';
@@ -264,7 +265,7 @@ async function npmInstall(
(result as any).code === 'ENOENT'
? `Command not found: ${chalk.cyan(
'npm'
)}\nPlease ensure that ${chalk.cyan('npm')} is properly installed`
)}\nPlease ensure that ${cmd('npm')} is properly installed`
: 'Failed to install `vercel dev` dependencies',
code: 'NPM_INSTALL_ERROR',
link: 'https://vercel.link/npm-install-failed-dev',

View File

@@ -651,7 +651,7 @@ export default class DevServer {
const cloudEnv = exposeSystemEnvs(
this.projectEnvs || [],
this.systemEnvValues || [],
this.projectSettings && this.projectSettings.autoExposeSystemEnvs,
this.projectSettings?.autoExposeSystemEnvs,
new URL(this.address).host
);
@@ -668,7 +668,7 @@ export default class DevServer {
// mirror how VERCEL_REGION is injected in prod/preview
// only inject in `runEnvs`, because `allEnvs` is exposed to dev command
// and should not contain VERCEL_REGION
if (this.projectSettings && this.projectSettings.autoExposeSystemEnvs) {
if (this.projectSettings?.autoExposeSystemEnvs) {
runEnv['VERCEL_REGION'] = 'dev1';
}
@@ -1904,6 +1904,12 @@ export default class DevServer {
requestPath: string,
nowRequestId: string
): boolean {
// If the "directory listing" feature is disabled in the
// Project's settings, then don't render the directory listing
if (this.projectSettings?.directoryListing === false) {
return false;
}
let prefix = requestPath;
if (prefix.length > 0 && !prefix.endsWith('/')) {
prefix += '/';

View File

@@ -232,7 +232,7 @@ async function testFixture(directory, opts = {}, args = []) {
function testFixtureStdio(
directory,
fn,
{ expectedCode = 0, skipDeploy, isExample } = {}
{ expectedCode = 0, skipDeploy, isExample, projectSettings } = {}
) {
return async t => {
const nodeMajor = Number(process.versions.node.split('.')[0]);
@@ -249,24 +249,51 @@ function testFixtureStdio(
// Deploy fixture and link project
if (!skipDeploy) {
const project = join(cwd, '.vercel', 'project.json');
if (await fs.exists(project)) {
await fs.unlink(project);
}
const projectJsonPath = join(cwd, '.vercel', 'project.json');
await fs.remove(projectJsonPath);
const gitignore = join(cwd, '.gitignore');
const gitignoreOrig = await fs.exists(gitignore);
let { stdout, stderr, exitCode } = await execa(
binaryPath,
['-t', token, '--confirm', '--public', '--no-clipboard', '--debug'],
{ cwd, reject: false }
);
console.log({ stdout, stderr, exitCode });
if (!gitignoreOrig && (await fs.exists(gitignore))) {
await fs.unlink(gitignore);
}
t.is(exitCode, expectedCode);
if (expectedCode === 0) {
deploymentUrl = new URL(stdout).host;
const hasGitignore = await fs.exists(gitignore);
try {
// Run `vc link`
const { exitCode: linkExitCode } = await execa(
binaryPath,
['-t', token, 'link', '--confirm'],
{ cwd, stdio: 'inherit', reject: false }
);
t.is(linkExitCode, 0);
// Patch the project with any non-default properties
if (projectSettings) {
const { projectId } = await fs.readJson(projectJsonPath);
const res = await fetch(
`https://api.vercel.com/v2/projects/${projectId}`,
{
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(projectSettings),
}
);
t.is(res.status, 200);
}
// Run `vc deploy`
let { exitCode, stdout } = await execa(
binaryPath,
['-t', token, 'deploy', '--public', '--no-clipboard', '--debug'],
{ cwd, stdio: ['ignore', 'pipe', 'inherit'], reject: false }
);
console.log({ exitCode, stdout });
t.is(exitCode, expectedCode);
if (expectedCode === 0) {
deploymentUrl = new URL(stdout).host;
}
} finally {
if (!hasGitignore) {
await fs.remove(gitignore);
}
}
}
@@ -622,14 +649,6 @@ test(
});
})
);
/*
test(
'[vercel dev] displays directory listing after miss',
testFixtureStdio('handle-miss-display-dir-list', async (testPath) => {
await testPath(404, '/post', /one.html/m);
})
);
*/
test(
'[vercel dev] does not display directory listing after 404',
@@ -1056,12 +1075,16 @@ test(
test(
'[vercel dev] 00-list-directory',
testFixtureStdio('00-list-directory', async testPath => {
await testPath(200, '/', /Files within/m);
await testPath(200, '/', /test[0-3]\.txt/m);
await testPath(200, '/', /\.well-known/m);
await testPath(200, '/.well-known/keybase.txt', 'proof goes here');
})
testFixtureStdio(
'00-list-directory',
async testPath => {
await testPath(200, '/', /Files within/m);
await testPath(200, '/', /test[0-3]\.txt/m);
await testPath(200, '/', /\.well-known/m);
await testPath(200, '/.well-known/keybase.txt', 'proof goes here');
},
{ projectSettings: { directoryListing: true } }
)
);
test(

View File

@@ -800,9 +800,9 @@ test('Deploy `api-env` fixture and test `vercel env` command', async t => {
t.is(homeJson['MY_STDIN_VAR'], '{"expect":"quotes"}');
t.is(homeJson['MY_DECRYPTABLE_SECRET_ENV'], 'decryptable value');
// system env vars are not automatically exposed
t.is(apiJson['VERCEL'], undefined);
t.is(homeJson['VERCEL'], undefined);
// system env vars are automatically exposed
t.is(apiJson['VERCEL'], '1');
t.is(homeJson['VERCEL'], '1');
vc.kill('SIGTERM', { forceKillAfterTimeout: 2000 });

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/client",
"version": "9.0.5-canary.2",
"version": "9.0.5",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"homepage": "https://vercel.com",
@@ -37,7 +37,7 @@
]
},
"dependencies": {
"@vercel/build-utils": "2.6.1-canary.2",
"@vercel/build-utils": "2.7.0",
"@zeit/fetch": "5.2.0",
"async-retry": "1.2.3",
"async-sema": "3.0.0",

View File

@@ -581,7 +581,7 @@ Learn more: https://vercel.com/docs/runtimes#official-runtimes/go`
} else if (Array.isArray(result)) {
// Got "exit" event from child process
const [exitCode, signal] = result;
const reason = signal ? `${signal} signal` : `${exitCode} exit code`;
const reason = signal ? `"${signal}" signal` : `exit code ${exitCode}`;
throw new Error(`\`go run ${entrypointWithExt}\` failed with ${reason}`);
} else {
throw new Error(`Unexpected result type: ${typeof result}`);

View File

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

View File

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

View File

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

View File

@@ -471,7 +471,7 @@ export async function startDevServer(
} else {
// Got "exit" event from child process
const [exitCode, signal] = result;
const reason = signal ? `${signal} signal` : `${exitCode} exit code`;
const reason = signal ? `"${signal}" signal` : `exit code ${exitCode}`;
throw new Error(`\`node ${entrypoint}\` failed with ${reason}`);
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@vercel/python",
"version": "1.2.4-canary.0",
"version": "1.2.4",
"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.9.2-canary.4",
"version": "1.9.2",
"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.5-canary.0",
"version": "1.2.5",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",