regressify 1.0.27 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy.yml +3 -4
- package/cli/generate-tests.js +5 -4
- package/cli/helpers.js +8 -0
- package/cli.js +5 -10
- package/package.json +1 -1
- package/src/config.ts +2 -3
- package/src/replacements.ts +4 -4
|
@@ -5,11 +5,7 @@ on:
|
|
|
5
5
|
branches:
|
|
6
6
|
- release
|
|
7
7
|
paths:
|
|
8
|
-
- .engine_scripts/**
|
|
9
|
-
- cli/**
|
|
10
|
-
- src/**
|
|
11
8
|
- package.json
|
|
12
|
-
- cli.js
|
|
13
9
|
|
|
14
10
|
workflow_dispatch:
|
|
15
11
|
|
|
@@ -34,6 +30,9 @@ jobs:
|
|
|
34
30
|
- name: Install dependencies
|
|
35
31
|
run: npm ci
|
|
36
32
|
|
|
33
|
+
- name: Build
|
|
34
|
+
run: npm run build
|
|
35
|
+
|
|
37
36
|
- name: Publish to NPM
|
|
38
37
|
run: npm publish --access public
|
|
39
38
|
env:
|
package/cli/generate-tests.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
3
|
import pkg from 'ncp';
|
|
5
4
|
import chalk from 'chalk';
|
|
5
|
+
import { getLibraryPath } from './helpers';
|
|
6
|
+
import slash from 'slash';
|
|
6
7
|
|
|
7
8
|
const { ncp } = pkg;
|
|
8
9
|
|
|
9
|
-
async function
|
|
10
|
-
const sourceFolder = path.join(
|
|
10
|
+
async function initVisualTestsFolder() {
|
|
11
|
+
const sourceFolder = slash(path.join(getLibraryPath(), 'visual_tests'));
|
|
11
12
|
const destinationFolder = path.join(process.cwd(), 'visual_tests');
|
|
12
13
|
|
|
13
14
|
if (!fs.existsSync(destinationFolder)) {
|
|
@@ -23,4 +24,4 @@ async function askUser() {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
initVisualTestsFolder().catch((err) => console.error('Error:', err));
|
package/cli/helpers.js
ADDED
package/cli.js
CHANGED
|
@@ -4,12 +4,10 @@ import path, { dirname } from 'path';
|
|
|
4
4
|
import { exec } from 'child_process';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
|
+
import { getLibraryPath } from './cli/helpers';
|
|
7
8
|
import slash from 'slash';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
const fileName = fileURLToPath(import.meta.url);
|
|
11
|
-
return slash(dirname(fileName));
|
|
12
|
-
}
|
|
10
|
+
const libraryPath = getLibraryPath();
|
|
13
11
|
|
|
14
12
|
function runCommand(command) {
|
|
15
13
|
const childProcess = exec(command, { env: { ...process.env, FORCE_COLOR: '1' } });
|
|
@@ -36,13 +34,10 @@ function runCommand(command) {
|
|
|
36
34
|
const args = process.argv.slice(2);
|
|
37
35
|
const command = args[0].toLowerCase();
|
|
38
36
|
|
|
39
|
-
let commandBase = `node ${
|
|
37
|
+
let commandBase = `node ${libraryPath}/dist/index.js`;
|
|
40
38
|
|
|
41
39
|
if (command === 'init') {
|
|
42
|
-
const
|
|
43
|
-
const __dirname = dirname(__filename);
|
|
44
|
-
|
|
45
|
-
const postInstallPath = pathToFileURL(path.join(__dirname, 'cli', 'generate-tests.js'));
|
|
40
|
+
const postInstallPath = slash(pathToFileURL(path.join(libraryPath, 'cli', 'generate-tests.js')));
|
|
46
41
|
if (fs.existsSync(postInstallPath)) {
|
|
47
42
|
console.log(chalk.yellow('Generate folder visual_tests ...'));
|
|
48
43
|
await import(postInstallPath);
|
|
@@ -50,7 +45,7 @@ if (command === 'init') {
|
|
|
50
45
|
console.log(chalk.red('generate-tests.js not found!'));
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
const updatePackageJsonPath = pathToFileURL(path.join(
|
|
48
|
+
const updatePackageJsonPath = slash(pathToFileURL(path.join(libraryPath, 'cli', 'update-package.js')));
|
|
54
49
|
if (fs.existsSync(updatePackageJsonPath)) {
|
|
55
50
|
console.log(chalk.yellow('Update package.json ...'));
|
|
56
51
|
await import(updatePackageJsonPath);
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -3,16 +3,15 @@ import { Config, Scenario, ViewportNext } from 'backstopjs';
|
|
|
3
3
|
import { createScenario } from './scenarios.js';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { getFlagArg, getStringArg, parseDataFromFile, getLibraryPath } from './helpers.js';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
6
|
import { TestSuiteModel, ScenarioModel } from './types.js';
|
|
8
7
|
import chalk from 'chalk';
|
|
9
8
|
import { exit } from 'process';
|
|
10
9
|
import YAML from 'js-yaml';
|
|
11
10
|
import { getTestUrl } from './replacements.js';
|
|
12
11
|
|
|
12
|
+
const libraryPath = getLibraryPath();
|
|
13
13
|
const engine: 'puppeteer' | 'playwright' = 'playwright';
|
|
14
14
|
|
|
15
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
15
|
const testSuite = getStringArg('--test-suite');
|
|
17
16
|
const isRef = getFlagArg('--ref');
|
|
18
17
|
const globalRequiredLogin = getFlagArg('--requiredLogin');
|
|
@@ -23,7 +22,7 @@ if (globalRequiredLogin) {
|
|
|
23
22
|
const scenarios: Scenario[] = [];
|
|
24
23
|
|
|
25
24
|
const getScriptPath = (scriptPath: string, engine: 'puppeteer' | 'playwright') => {
|
|
26
|
-
return path.join(
|
|
25
|
+
return path.join(libraryPath, '.engine_scripts', (engine == 'puppeteer' ? 'puppet' : 'playwright') + scriptPath);
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
if (!testSuite) {
|
package/src/replacements.ts
CHANGED
|
@@ -2,15 +2,15 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { ReplacementModel, ReplacementsModel } from './types';
|
|
4
4
|
import YAML from 'js-yaml';
|
|
5
|
-
import { getStringArg } from './helpers.js';
|
|
6
|
-
import
|
|
5
|
+
import { getLibraryPath, getStringArg } from './helpers.js';
|
|
6
|
+
import slash from 'slash';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const libraryPath = getLibraryPath();
|
|
9
9
|
|
|
10
10
|
const getReplacementProfile = (): ReplacementModel[] | undefined => {
|
|
11
11
|
const replacementProfileName = getStringArg('replacement-profile') ?? process.env.REPLACEMENT_PROFILE;
|
|
12
12
|
if (!!replacementProfileName) {
|
|
13
|
-
const replacementProfilePath = path.
|
|
13
|
+
const replacementProfilePath = slash(path.join(libraryPath, 'visual_tests', '_replacement-profiles.yaml'));
|
|
14
14
|
if (!fs.existsSync(replacementProfilePath)) {
|
|
15
15
|
throw "Replacement profile doesn't exist: " + replacementProfilePath;
|
|
16
16
|
}
|