Compare commits

..

7 Commits

Author SHA1 Message Date
Steven
3fa7b80bde Publish
- @now/build-utils@0.9.6
 - @now/next@0.5.8
 - @now/node@0.12.2
2019-07-31 08:30:21 -04:00
Steven
d012e73166 [now-node] Bump node-file-trace to 0.2.5 (#852) 2019-07-31 08:29:09 -04:00
Andy
d6c46da37f [now-build-utils] Remove @now/nuxt from default builders (#850) 2019-07-31 08:29:04 -04:00
Andy
1508932ad6 [now-static-build] Allow setting the tag for zero-config builders (#842)
* [now-static-build] Allow to set the `tag` for zero-config builders

This reverts commit 32b6f1d6a9047920d6cc40385de711022f77c4d4.

* Remove unsupported builders

* Fix setting the tag
2019-07-31 08:28:58 -04:00
Steven
873b099f53 [now-node] Bump node-file-trace to 0.2.4 (#849) 2019-07-31 08:28:52 -04:00
Steven
6546d3b67d [now-build-utils] Fix require file path for legacy builders (#846)
* [now-build-utils] Fix require file path

* Add more tests
2019-07-31 08:28:46 -04:00
Steven
34ad4ac33a [now-next] Fix dev-server bundle output (#847)
* [now-next] Fix dev-server bundle

* [now-next] Fix bundle output dev-server
2019-07-31 08:28:39 -04:00
14 changed files with 104 additions and 21 deletions

View File

@@ -1 +1 @@
module.exports = require('../dist/fs/download').default;
module.exports = require('../dist/index').download;

View File

@@ -1 +1 @@
module.exports = require('../dist/fs/get-writable-directory').default;
module.exports = require('../dist/index').getWriteableDirectory;

View File

@@ -1 +1 @@
module.exports = require('../dist/fs/glob').default;
module.exports = require('../dist/index').glob;

View File

@@ -1 +1 @@
module.exports = require('../dist/fs/rename').default;
module.exports = require('../dist/index').rename;

View File

@@ -1 +1 @@
module.exports = require('../dist/fs/run-user-scripts');
module.exports = require('../dist/index');

View File

@@ -1 +1 @@
module.exports = require('../dist/fs/stream-to-buffer').default;
module.exports = require('../dist/index').streamToBuffer;

View File

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

View File

@@ -6,24 +6,24 @@ interface ErrorResponse {
message: string;
}
interface Options {
tag?: 'canary' | 'latest';
}
const src: string = 'package.json';
const config: Config = { zeroConfig: true };
// Static builders are special cased in `@now/static-build`
const BUILDERS = new Map<string, Builder>([
['next', { src, use: '@now/next', config }],
['nuxt', { src, use: '@now/nuxt', config }],
]);
const API_BUILDERS: Builder[] = [
{ src: 'api/**/*.js', use: '@now/node', config },
{ src: 'api/**/*.ts', use: '@now/node', config },
{ src: 'api/**/*.rs', use: '@now/rust', config },
{ src: 'api/**/*.go', use: '@now/go', config },
{ src: 'api/**/*.php', use: '@now/php', config },
{ src: 'api/**/*.py', use: '@now/python', config },
{ src: 'api/**/*.rb', use: '@now/ruby', config },
{ src: 'api/**/*.sh', use: '@now/bash', config },
];
const MISSING_BUILD_SCRIPT_ERROR: ErrorResponse = {
@@ -101,7 +101,8 @@ async function detectApiBuilders(files: string[]): Promise<Builder[]> {
// to determine what builders to use
export async function detectBuilders(
files: string[],
pkg?: PackageJson | undefined | null
pkg?: PackageJson | undefined | null,
options?: Options
): Promise<{
builders: Builder[] | null;
errors: ErrorResponse[] | null;
@@ -109,7 +110,7 @@ export async function detectBuilders(
const errors: ErrorResponse[] = [];
// Detect all builders for the `api` directory before anything else
const builders = await detectApiBuilders(files);
let builders = await detectApiBuilders(files);
if (pkg && hasBuildScript(pkg)) {
builders.push(await detectBuilder(pkg));
@@ -145,6 +146,22 @@ export async function detectBuilders(
}
}
// Change the tag for the builders
if (builders && builders.length) {
const tag = options && options.tag;
if (tag) {
builders = builders.map((builder: Builder) => {
// @now/static has no canary builder
if (builder.use !== '@now/static') {
builder.use = `${builder.use}@${tag}`;
}
return builder;
});
}
}
return {
builders: builders.length ? builders : null,
errors: errors.length ? errors : null,

View File

@@ -116,6 +116,36 @@ it('should match all semver ranges', () => {
);
});
it('should support require by path for legacy builders', () => {
const index = require('@now/build-utils');
const download2 = require('@now/build-utils/fs/download.js');
const getWriteableDirectory2 = require('@now/build-utils/fs/get-writable-directory.js');
const glob2 = require('@now/build-utils/fs/glob.js');
const rename2 = require('@now/build-utils/fs/rename.js');
const {
runNpmInstall: runNpmInstall2,
} = require('@now/build-utils/fs/run-user-scripts.js');
const streamToBuffer2 = require('@now/build-utils/fs/stream-to-buffer.js');
const FileBlob2 = require('@now/build-utils/file-blob.js');
const FileFsRef2 = require('@now/build-utils/file-fs-ref.js');
const FileRef2 = require('@now/build-utils/file-ref.js');
const { Lambda: Lambda2 } = require('@now/build-utils/lambda.js');
expect(download2).toBe(index.download);
expect(getWriteableDirectory2).toBe(index.getWriteableDirectory);
expect(glob2).toBe(index.glob);
expect(rename2).toBe(index.rename);
expect(runNpmInstall2).toBe(index.runNpmInstall);
expect(streamToBuffer2).toBe(index.streamToBuffer);
expect(FileBlob2).toBe(index.FileBlob);
expect(FileFsRef2).toBe(index.FileFsRef);
expect(FileRef2).toBe(index.FileRef);
expect(Lambda2).toBe(index.Lambda);
});
// own fixtures
const fixturesPath = path.resolve(__dirname, 'fixtures');
@@ -355,7 +385,7 @@ it('Test `detectBuilders`', async () => {
const files = ['package.json', 'pages/index.js'];
const { builders } = await detectBuilders(files, pkg);
expect(builders[0].use).toBe('@now/nuxt');
expect(builders[0].use).toBe('@now/static-build');
expect(builders[0].src).toBe('package.json');
expect(builders.length).toBe(1);
}
@@ -397,6 +427,25 @@ it('Test `detectBuilders`', async () => {
expect(builders).toBe(null);
expect(errors).toBe(null);
}
{
// package.json + api + canary
const pkg = {
scripts: { build: 'next build' },
dependencies: { next: '9.0.0' },
};
const files = [
'pages/index.js',
'api/[endpoint].js',
'api/[endpoint]/[id].js',
];
const { builders } = await detectBuilders(files, pkg, { tag: 'canary' });
expect(builders[0].use).toBe('@now/node@canary');
expect(builders[1].use).toBe('@now/node@canary');
expect(builders[2].use).toBe('@now/next@canary');
expect(builders.length).toBe(3);
}
});
it('Test `detectRoutes`', async () => {

View File

@@ -7,6 +7,10 @@ cp -v "$bridge_defs" src/now__bridge.ts
tsc
ncc build src/dev-server.ts -o dist/dev
mv dist/dev/index.js dist/dev-server.js
rm -rf dist/dev
ncc build src/index.ts -o dist/main
mv dist/main/index.js dist/index.js
rm -rf dist/main

View File

@@ -1,6 +1,6 @@
{
"name": "@now/next",
"version": "0.5.7",
"version": "0.5.8",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/next-js-now-next",

View File

@@ -0,0 +1,13 @@
describe('export', () => {
it('should require by path main', async () => {
const main = require('@now/next');
expect(main).toBeDefined();
});
it('should require by path dev-server relative to index', async () => {
const index = require('@now/next/dist/index.js');
const server = require('@now/next/dist/dev-server.js');
expect(index).toBeDefined();
expect(server).toBeDefined();
});
});

View File

@@ -1,6 +1,6 @@
{
"name": "@now/node",
"version": "0.12.1",
"version": "0.12.2",
"license": "MIT",
"main": "./dist/index",
"homepage": "https://zeit.co/docs/v2/deployments/official-builders/node-js-now-node",
@@ -28,7 +28,7 @@
"@types/etag": "1.8.0",
"@types/test-listen": "1.1.0",
"@zeit/ncc": "0.20.4",
"@zeit/node-file-trace": "0.2.3",
"@zeit/node-file-trace": "0.2.5",
"content-type": "1.0.4",
"cookie": "0.4.0",
"etag": "1.8.1",

View File

@@ -1499,10 +1499,10 @@
resolved "https://registry.yarnpkg.com/@zeit/ncc/-/ncc-0.20.4.tgz#00f0a25a88cac3712af4ba66561d9e281c6f05c9"
integrity sha512-fmq+F/QxPec+k/zvT7HiVpk7oiGFseS6brfT/AYqmCUp6QFRK7vZf2Ref46MImsg/g2W3g5X6SRvGRmOAvEfdA==
"@zeit/node-file-trace@0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@zeit/node-file-trace/-/node-file-trace-0.2.3.tgz#58acc5fef28bfcf3b27481a95e2a0497358ec59e"
integrity sha512-uC0fCbwUGvqxl9kTm2rmAYJ/4EOYNzSDba1NSgyROWRF8ELUxt4th28n8xEMGNrAHwy1BUUscsKyyA8M74g0dA==
"@zeit/node-file-trace@0.2.5":
version "0.2.5"
resolved "https://registry.yarnpkg.com/@zeit/node-file-trace/-/node-file-trace-0.2.5.tgz#be69738b89fa084dfc51454ec4e0089d25888ef6"
integrity sha512-K7BNYZg19PQFzA3CpaPvjCc/sE0vgUMsVn4f1LurDk/e9aizjmrZCKPQpsGhEhGGR/jtPPMqBLhWVQM3k/trKQ==
dependencies:
acorn "^6.1.1"
acorn-stage3 "^2.0.0"