Compare commits

..

4 Commits

Author SHA1 Message Date
Steven
21fe0a2006 Publish Stable
- @now/build-utils@1.1.0
 - now@16.6.0
 - now-client@5.2.4
 - @now/next@2.1.0
 - @now/node@1.2.0
 - @now/static-build@0.13.0
2019-11-21 13:14:17 -05:00
Steven
23acd3cec6 Publish Canary
- @now/build-utils@1.0.1-canary.4
 - now@16.5.3-canary.6
 - @now/routing-utils@1.3.4-canary.2
2019-11-21 11:45:19 -05:00
Steven
7892f88a42 [now-build-utils] Ignore engines for yarn run (#3341)
Fixes a confusing error message.

<details>
<summary>Click to view error message</summary>
<pre>> Ready! Available at http://localhost:3000
> Building @now/node:index.js
Installing dependencies...
Running "yarn run now-build"
yarn run v1.17.3
error @: The engine "node" is incompatible with this module. Expected version "10.x". Got "12.13.1"
error Commands cannot run with an incompatible environment.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Exited with 1
    at ChildProcess.<anonymous> (/Users/styfle/Library/Caches/co.zeit.now/dev/builders/node_modules/@now/node/dist/index.js:78518:24)
    at ChildProcess.emit (events.js:210:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  message: 'Exited with 1'
}</pre>
</details>



The `--ignore-engines` flag was added to `yarn install` many months ago but not `yarn run`.

This PR adds the flag to `yarn run`.

This is useful in `now dev` when the user might have a different Node version installed than what is specified by `engines` in `package.json`.
2019-11-21 16:41:55 +00:00
Steven
aae0e3bec7 Revert [now-cli][now-routing-utils] Add support for v4 builders #3311 (#3333)
Reverts #3311

Previously, we thought we were going to use version 4 to support builder rewrites/redirects => routes. But that is no longer necessary. So instead version 4 will be builders that accept multiple file entrypoints.

Until v4 can be implemented, this reverts v4 changes.

Additionally, I added a helpful error message when the CLI does not support the builder version. In a future PR, we will add better version locking to avoid this type of version mismatch.
2019-11-21 15:49:33 +00:00
13 changed files with 24 additions and 72 deletions

View File

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

View File

@@ -247,7 +247,11 @@ export async function runPackageJsonScript(
await spawnAsync('npm', ['run', scriptName], opts);
} else {
console.log(`Running "yarn run ${scriptName}"`);
await spawnAsync('yarn', ['--cwd', destPath, 'run', scriptName], opts);
await spawnAsync(
'yarn',
['--ignore-engines', '--cwd', destPath, 'run', scriptName],
opts
);
}
return true;

View File

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

View File

@@ -29,11 +29,10 @@ import {
BuilderInputs,
BuilderOutput,
BuildResultV3,
BuildResultV4,
BuilderOutputs,
RouteConfig,
} from './types';
import { normalizeRoutes, getTransformedRoutes } from '@now/routing-utils';
import { normalizeRoutes } from '@now/routing-utils';
import getUpdateCommand from '../get-update-command';
interface BuildMessage {
type: string;
@@ -176,11 +175,7 @@ export async function executeBuild(
},
};
let buildResultOrOutputs:
| BuilderOutputs
| BuildResult
| BuildResultV3
| BuildResultV4;
let buildResultOrOutputs: BuilderOutputs | BuildResult | BuildResultV3;
if (buildProcess) {
buildProcess.send({
type: 'build',
@@ -233,10 +228,8 @@ export async function executeBuild(
};
} else if (builder.version === 2) {
result = buildResultOrOutputs as BuildResult;
} else if (builder.version === 3 || builder.version === 4) {
const { output, ...rest } = buildResultOrOutputs as (
| BuildResultV3
| BuildResultV4);
} else if (builder.version === 3) {
const { output, ...rest } = buildResultOrOutputs as BuildResultV3;
if (!output || (output as BuilderOutput).type !== 'Lambda') {
throw new Error('The result of "builder.build()" must be a `Lambda`');
@@ -268,27 +261,18 @@ export async function executeBuild(
}
}
let routes: RouteConfig[] = [];
if (builder.version === 4) {
const { error, routes: buildRoutes } = getTransformedRoutes({
nowConfig: rest,
builderVersion: builder.version,
});
if (error) {
throw new Error(error.message);
}
routes = buildRoutes || [];
}
result = {
...rest,
routes,
output: {
[entrypoint]: output,
},
} as BuildResult;
} else {
result = buildResultOrOutputs as BuildResult;
throw new Error(
`Now CLI does not support builder version ${
builder.version
}.\nPlease run \`${await getUpdateCommand()}\` to update Now CLI.`
);
}
// Normalize Builder Routes

View File

@@ -130,14 +130,10 @@ export interface BuildResultV3 {
}
export interface BuildResultV4 {
output: Lambda;
output: { [filePath: string]: Lambda };
routes: RouteConfig[];
watch: string[];
distPath?: string;
cleanUrls?: boolean;
rewrites?: NowRewrite[];
redirects?: NowRedirect[];
headers?: NowHeader[];
trailingSlash?: boolean;
}
export interface ShouldServeParams {

View File

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

View File

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

View File

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

View File

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

View File

@@ -127,25 +127,11 @@ function notEmpty<T>(value: T | null | undefined): value is T {
export function getTransformedRoutes({
nowConfig,
builderVersion,
}: GetRoutesProps): NormalizedRoutes {
const { cleanUrls, rewrites, redirects, headers, trailingSlash } = nowConfig;
let { routes = null } = nowConfig;
const errors: NowErrorNested[] = [];
if (routes) {
if (typeof builderVersion === 'number' && builderVersion >= 4) {
const error = createNowError(
'invalid_builder_result',
'Invalid builder result',
[
{
message:
'Cannot define `routes` when builder.version is 4 or newer',
},
]
);
return { routes, error };
}
if (typeof cleanUrls !== 'undefined') {
errors.push({
message: 'Cannot define both `routes` and `cleanUrls`',

View File

@@ -33,7 +33,6 @@ export type NormalizedRoutes = {
export interface GetRoutesProps {
nowConfig: NowConfig;
builderVersion?: number;
}
export interface NowConfig {

View File

@@ -548,21 +548,4 @@ describe('getTransformedRoutes', () => {
const actual = getTransformedRoutes({ nowConfig });
assert.equal(actual.routes, null);
});
test('should error when builder version 4 uses routes', () => {
const nowConfig = { routes: [{ src: '/page', dest: '/another' }] };
const actual = getTransformedRoutes({ nowConfig, builderVersion: 4 });
assert.notEqual(actual.error, null);
assert.equal(actual.error.code, 'invalid_builder_result');
});
test('should not error when builder version 4 uses rewrites', () => {
const nowConfig = {
rewrites: [{ source: '/page', destination: '/another' }],
};
const actual = getTransformedRoutes({ nowConfig, builderVersion: 4 });
assert.equal(actual.error, null);
assert.notEqual(actual.routes, null);
assertValid(actual.routes);
});
});

View File

@@ -1,6 +1,6 @@
{
"name": "@now/static-build",
"version": "0.12.3-canary.2",
"version": "0.13.0",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/runtimes#official-runtimes/static-builds",