[redwoood] Add runtime @vercel/redwood (#4676)

### Changes
- Add new Runtime: `@vercel/redwood`
- Update `run.js` script to sort packages properly

### Related
- Related to #4539 
- Related to #4535
- Depends on https://github.com/apollographql/apollo-server/pull/4311
This commit is contained in:
Steven
2020-07-23 16:22:48 -04:00
committed by GitHub
parent e519d49d7b
commit b118e461b1
49 changed files with 15652 additions and 64 deletions

71
utils/run.js vendored
View File

@@ -1,21 +1,30 @@
const { execSync, spawn } = require('child_process');
const { join, relative, sep } = require('path');
const { readdirSync } = require('fs');
if (
process.env.GITHUB_REPOSITORY &&
process.env.GITHUB_REPOSITORY !== 'vercel/vercel'
) {
console.log('Detected fork, skipping tests');
return;
}
// The order matters because we must build dependencies first
const allPackages = [
'frameworks',
'now-routing-utils',
'now-build-utils',
'now-cgi',
'now-client',
'now-node-bridge',
'now-next',
'now-node',
'redwood',
'now-static-build',
'now-go',
'now-python',
'now-ruby',
'now-cli',
];
process.chdir(join(__dirname, '..'));
async function main() {
const script = process.argv[2];
const all = process.argv[3];
let matches = [];
let modifiedPackages = new Set(allPackages);
if (!script) {
console.error('Please provide at least one argument');
@@ -23,7 +32,6 @@ async function main() {
}
if (all === 'all') {
matches = readdirSync(join(__dirname, '..', 'packages'));
console.log(`Running script "${script}" for all packages`);
} else {
const branch =
@@ -41,50 +49,23 @@ async function main() {
.map(item => relative('packages', item).split(sep)[0])
.concat('now-cli'); // Always run tests for Now CLI
matches = Array.from(new Set(changed));
if (matches.length === 0) {
matches.push('now-node');
console.log('No packages changed. Using default packages.');
}
modifiedPackages = new Set(changed);
console.log(
`Running "${script}" on branch "${branch}" with the following packages:\n`
);
}
// Sort the matches such that `utils` modules are compiled first,
// because other packages (such as builders) depend on them.
// We also need to ensure that `now-cli` is built last.
matches.sort((a, b) => {
if (a === 'now-routing-utils' && b !== 'now-routing-utils') {
return -1;
for (const pkgName of allPackages) {
if (modifiedPackages.has(pkgName)) {
console.log(` - ${pkgName}`);
}
if (b === 'now-routing-utils' && a !== 'now-routing-utils') {
return 1;
}
if (a === 'now-build-utils' && b !== 'now-build-utils') {
return -1;
}
if (b === 'now-build-utils' && a !== 'now-build-utils') {
return 1;
}
if (a === 'now-cli' && b !== 'now-cli') {
return 1;
}
if (b === 'now-cli' && a !== 'now-cli') {
return -1;
}
return b - a;
});
for (const m of matches) {
console.log(` - ${m}`);
}
for (const pkgName of matches) {
await runScript(pkgName, script);
for (const pkgName of allPackages) {
if (modifiedPackages.has(pkgName)) {
await runScript(pkgName, script);
}
}
}