Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migrate-local subcommand #144

Merged
merged 6 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bin/d2l-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import commandLineArgs from 'command-line-args';
import process from 'node:process';
import { runner } from '../src/server/cli/test-runner.js';
import { execSync } from 'node:child_process';

Check failure on line 5 in bin/d2l-test-runner.js

View workflow job for this annotation

GitHub Actions / Test

Imports should be sorted alphabetically

const { argv, stdout } = process;
const cli = commandLineArgs({ name: 'subcommand', defaultOption: true }, { stopAtFirstUnknown: true, argv });
Expand All @@ -21,8 +22,15 @@
} else if (vdiff.subcommand === 'migrate') {
const { migrate } = await import('../src/server/cli/vdiff/migrate.js');
await migrate.start(vdiff._unknown);
} else if (vdiff.subcommand === 'migrate-local') {

execSync('npm install @brightspace-ui/visual-diff@14 --no-save');
execSync('npx mocha \'./**/*.visual-diff.js\' -t 10000 --golden');
svanherk marked this conversation as resolved.
Show resolved Hide resolved

const { migrate } = await import('../src/server/cli/vdiff/migrate.js');
await migrate.start(vdiff._unknown, true);
} else {
stdout.write(`\nfatal: unknown subcomamnd: ${vdiff.subcommand}\n`);
stdout.write(`\nfatal: unknown subcommand: ${vdiff.subcommand}\n`);
}
} else {
runTests();
Expand Down
8 changes: 5 additions & 3 deletions src/server/cli/vdiff/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { glob } from 'glob';
import { PATHS } from '../../visual-diff-plugin.js';
import { stdout } from 'node:process';

async function start(argv = []) {
async function start(argv = [], local = false) {
const { pattern = './**' } = commandLineArgs({ name: 'pattern', type: String, defaultOption: true }, { partial: true, argv });
const oldSuffix = 'screenshots/ci/golden';
const oldSuffix = local ? 'screenshots/golden' : 'screenshots/ci/golden';
const dirs = await glob(`${pattern}/${oldSuffix}`, { ignore: 'node_modules/**', posix: true });
let fileCount = 0;

Expand All @@ -30,7 +30,9 @@ async function start(argv = []) {
.replace(/^d2l-/, '')
.replace(new RegExp(`^${dirName}-`), '');

const newDir = dir.replace(`${oldSuffix}/${dirName}`, `${PATHS.GOLDEN}/${dirName}/chromium`);
const newDir = local ?
`${PATHS.VDIFF_ROOT}/${dir.replace(`${oldSuffix}/${dirName}`, `${dirName}/${PATHS.GOLDEN}/chromium`)}` :
dir.replace(`${oldSuffix}/${dirName}`, `${PATHS.GOLDEN}/${dirName}/chromium`);

await mkdir(newDir, { recursive: true });
return rename(file, join(newDir, newName));
svanherk marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading