[now-cli] Add the core Runtimes as npm dependencies for now dev (#4117)

Rather than creating a `builders.tar.gz` file with the core Runtimes and
bundling that tarball with Now CLI, simply have them be regular npm
dependencies so that they are installed into Now CLI's `node_modules`
directory.

When one of the core runtimes is specified for a build, the runtime will be
required as a regular module dependency of Now CLI, and the builders cache
will never touched.

Bundled runtimes are also no longer updated, making the runtime versions
pinned to the version of Now CLI.

Logic for the builders cache directory still remains, but will now only be
used when using a Community Runtime (or development tarball URL).
This commit is contained in:
Nathan Rajlich
2020-04-24 17:19:58 -07:00
committed by GitHub
parent de3a066934
commit 55e4bffcd2
10 changed files with 230 additions and 226 deletions

View File

@@ -1,7 +1,8 @@
import test from 'ava';
import { filterPackage } from '../src/util/dev/builder-cache';
import npa from 'npm-package-arg';
import { filterPackage, isBundledBuilder } from '../src/util/dev/builder-cache';
test('[dev-builder] filter install "latest", cached canary', async t => {
test('[dev-builder] filter install "latest", cached canary', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1-canary.0',
@@ -11,7 +12,7 @@ test('[dev-builder] filter install "latest", cached canary', async t => {
t.is(result, true);
});
test('[dev-builder] filter install "canary", cached stable', async t => {
test('[dev-builder] filter install "canary", cached stable', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1',
@@ -25,7 +26,7 @@ test('[dev-builder] filter install "canary", cached stable', async t => {
t.is(result, true);
});
test('[dev-builder] filter install "latest", cached stable', async t => {
test('[dev-builder] filter install "latest", cached stable', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1',
@@ -35,7 +36,7 @@ test('[dev-builder] filter install "latest", cached stable', async t => {
t.is(result, false);
});
test('[dev-builder] filter install "canary", cached canary', async t => {
test('[dev-builder] filter install "canary", cached canary', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1-canary.0',
@@ -49,7 +50,7 @@ test('[dev-builder] filter install "canary", cached canary', async t => {
t.is(result, false);
});
test('[dev-builder] filter install URL, cached stable', async t => {
test('[dev-builder] filter install URL, cached stable', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1',
@@ -59,7 +60,7 @@ test('[dev-builder] filter install URL, cached stable', async t => {
t.is(result, true);
});
test('[dev-builder] filter install URL, cached canary', async t => {
test('[dev-builder] filter install URL, cached canary', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': '0.0.1-canary.0',
@@ -69,7 +70,7 @@ test('[dev-builder] filter install URL, cached canary', async t => {
t.is(result, true);
});
test('[dev-builder] filter install "latest", cached URL - stable', async t => {
test('[dev-builder] filter install "latest", cached URL - stable', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': 'https://tarball.now.sh',
@@ -79,7 +80,7 @@ test('[dev-builder] filter install "latest", cached URL - stable', async t => {
t.is(result, true);
});
test('[dev-builder] filter install "latest", cached URL - canary', async t => {
test('[dev-builder] filter install "latest", cached URL - canary', t => {
const buildersPkg = {
dependencies: {
'@now/build-utils': 'https://tarball.now.sh',
@@ -89,7 +90,7 @@ test('[dev-builder] filter install "latest", cached URL - canary', async t => {
t.is(result, true);
});
test('[dev-builder] filter install not bundled version, cached same version', async t => {
test('[dev-builder] filter install not bundled version, cached same version', t => {
const buildersPkg = {
dependencies: {
'not-bundled-package': '0.0.1',
@@ -99,7 +100,7 @@ test('[dev-builder] filter install not bundled version, cached same version', as
t.is(result, false);
});
test('[dev-builder] filter install not bundled version, cached different version', async t => {
test('[dev-builder] filter install not bundled version, cached different version', t => {
const buildersPkg = {
dependencies: {
'not-bundled-package': '0.0.9',
@@ -109,7 +110,7 @@ test('[dev-builder] filter install not bundled version, cached different version
t.is(result, true);
});
test('[dev-builder] filter install not bundled stable, cached version', async t => {
test('[dev-builder] filter install not bundled stable, cached version', t => {
const buildersPkg = {
dependencies: {
'not-bundled-package': '0.0.1',
@@ -119,7 +120,7 @@ test('[dev-builder] filter install not bundled stable, cached version', async t
t.is(result, true);
});
test('[dev-builder] filter install not bundled tagged, cached tagged', async t => {
test('[dev-builder] filter install not bundled tagged, cached tagged', t => {
const buildersPkg = {
dependencies: {
'not-bundled-package': '16.9.0-alpha.0',
@@ -128,3 +129,89 @@ test('[dev-builder] filter install not bundled tagged, cached tagged', async t =
const result = filterPackage('not-bundled-package@alpha', '_', buildersPkg);
t.is(result, true);
});
test('[dev-builder] isBundledBuilder() - stable', t => {
const nowCliPkg = {
dependencies: {
'@now/node': '1.5.2',
},
};
// "canary" tag
{
const parsed = npa('@now/node@canary');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, false);
}
// "latest" tag
{
const parsed = npa('@now/node');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, true);
}
// specific matching version
{
const parsed = npa('@now/node@1.5.2');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, true);
}
// specific non-matching version
{
const parsed = npa('@now/node@1.5.1');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, false);
}
// URL
{
const parsed = npa('https://example.com');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, false);
}
});
test('[dev-builder] isBundledBuilder() - canary', t => {
const nowCliPkg = {
dependencies: {
'@now/node': '1.5.2-canary.3',
},
};
// "canary" tag
{
const parsed = npa('@now/node@canary');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, true);
}
// "latest" tag
{
const parsed = npa('@now/node');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, false);
}
// specific matching version
{
const parsed = npa('@now/node@1.5.2-canary.3');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, true);
}
// specific non-matching version
{
const parsed = npa('@now/node@1.5.2-canary.2');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, false);
}
// URL
{
const parsed = npa('https://example.com');
const result = isBundledBuilder(parsed, nowCliPkg);
t.is(result, false);
}
});