chore: use yalc to run e2e tsts

This commit is contained in:
Alexandre Bodin 2023-12-01 11:30:16 +01:00
parent b373446907
commit efd534b8a8
4 changed files with 68 additions and 6 deletions

22
scripts/yalc-link.js Executable file
View File

@ -0,0 +1,22 @@
'use strict';
const { join } = require('path');
const { promisify } = require('util');
const execa = require('execa');
const fs = require('fs-extra');
const glob = promisify(require('glob').glob);
async function run() {
const proc = await execa('yarn', ['workspaces', 'list', '--json', '--no-private'], {
cwd: join(__dirname, '..'),
});
const packages = proc.stdout
.trim()
.split('\n')
.map((info) => JSON.parse(info).name);
await execa('npx', ['yalc', 'link', ...packages], { stdio: 'inherit' });
}
run().catch((err) => console.error(err));

28
scripts/yalc-publish.js Executable file
View File

@ -0,0 +1,28 @@
'use strict';
const { join } = require('path');
const { promisify } = require('util');
const execa = require('execa');
const fs = require('fs-extra');
const glob = promisify(require('glob').glob);
async function run() {
const proc = await execa('yarn', ['workspaces', 'list', '--json', '--no-private'], {
cwd: join(__dirname, '..'),
});
const packagesDirs = proc.stdout
.trim()
.split('\n')
.map((info) => JSON.parse(info).location);
await Promise.all(
packagesDirs.map(async (dir) => {
await execa('npx', ['yalc', 'publish', '--no-scripts', dir], {
stdio: 'inherit',
});
})
);
}
run().catch((err) => console.error(err));

View File

@ -61,15 +61,20 @@ const generateTestApp = async ({ appPath, database, template, link = false }) =>
await generateNew(scope);
if (link) {
await linkPackages(appPath);
await linkPackages(scope);
}
};
const linkPackages = async (appPath) => {
const rootPath = path.resolve(__dirname, '../..');
fs.writeFileSync(path.join(appPath, 'yarn.lock'), '');
await execa('yarn', ['link', '-A', rootPath], {
cwd: appPath,
const linkPackages = async (scope) => {
fs.writeFileSync(path.join(scope.rootPath, 'yarn.lock'), '');
await execa('node', [path.join(__dirname, '../..', 'scripts', 'yalc-link.js')], {
cwd: scope.rootPath,
stdio: 'inherit',
});
await execa('yarn', ['install'], {
cwd: scope.rootPath,
stdio: 'inherit',
});
};

View File

@ -53,6 +53,13 @@ yargs
try {
const { concurrency, domains, setup } = argv;
/**
* Publshing all pacakges to the yalc store
*/
await execa('node', [path.join(__dirname, '../..', 'scripts', 'yalc-publish.js')], {
stdio: 'inherit',
});
/**
* We don't need to spawn more apps than we have domains,
* but equally if someone sets the concurrency to 1