regressify 1.0.6 → 1.0.8
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/README.md +4 -4
- package/cli.js +9 -0
- package/package.json +1 -1
- package/update-package.js +8 -3
package/README.md
CHANGED
|
@@ -13,15 +13,15 @@ Please check [Documentation](https://tuyen.blog/optimizely-cms/testing/get-start
|
|
|
13
13
|
1. Manual Set up all test and config files in the **visual_tests** folder and place it at the root of the project, or automatically add it using the command:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npx regressify
|
|
16
|
+
npx regressify init
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
1. Add to scripts in package.json:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
"ref": "regressify
|
|
23
|
-
"approve": "regressify
|
|
24
|
-
"test": "regressify
|
|
22
|
+
"ref": "regressify ref",
|
|
23
|
+
"approve": "regressify approve",
|
|
24
|
+
"test": "regressify test"
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
1. Use new command aliases:
|
package/cli.js
CHANGED
|
@@ -52,6 +52,7 @@ let commandBase = `tsx ${getLibraryPath()}/src/index.ts`;
|
|
|
52
52
|
if (command === 'init') {
|
|
53
53
|
const __filename = fileURLToPath(import.meta.url);
|
|
54
54
|
const __dirname = dirname(__filename);
|
|
55
|
+
|
|
55
56
|
const postInstallPath = pathToFileURL(path.join(__dirname, 'generate_tests.js'));
|
|
56
57
|
if (fs.existsSync(postInstallPath)) {
|
|
57
58
|
console.log(chalk.yellow('generate folder visual_tests ...'));
|
|
@@ -59,6 +60,14 @@ if (command === 'init') {
|
|
|
59
60
|
} else {
|
|
60
61
|
console.log(chalk.red('generate_tests.js not found!'));
|
|
61
62
|
}
|
|
63
|
+
|
|
64
|
+
const updatePackageJsonPath = pathToFileURL(path.join(__dirname, 'update-package.js'));
|
|
65
|
+
if (fs.existsSync(updatePackageJsonPath)) {
|
|
66
|
+
console.log(chalk.yellow('update package.json ...'));
|
|
67
|
+
await import(updatePackageJsonPath);
|
|
68
|
+
} else {
|
|
69
|
+
console.log(chalk.red('update-package.js not found!'));
|
|
70
|
+
}
|
|
62
71
|
} else if (command === 'ref') {
|
|
63
72
|
const command = `${commandBase} --command test --ref ${args.slice(1).join(' ')}`;
|
|
64
73
|
console.log(chalk.yellow(`Running command: ${command}`));
|
package/package.json
CHANGED
package/update-package.js
CHANGED
|
@@ -4,13 +4,18 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
|
|
5
5
|
async function updatePackageJson() {
|
|
6
6
|
const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'package.json');
|
|
7
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
8
|
+
console.log(chalk.red("package.json file doesn't exists"), err);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
const packageJsonText = fs.readFileSync(packageJsonPath, 'utf8');
|
|
8
13
|
const packageJson = JSON.parse(packageJsonText);
|
|
9
14
|
|
|
10
15
|
const scripts = packageJson.scripts || {};
|
|
11
|
-
scripts.ref = 'regressify
|
|
12
|
-
scripts.approve = 'regressify
|
|
13
|
-
scripts.test = 'regressify
|
|
16
|
+
scripts.ref = 'regressify ref';
|
|
17
|
+
scripts.approve = 'regressify approve';
|
|
18
|
+
scripts.test = 'regressify test';
|
|
14
19
|
|
|
15
20
|
packageJson.scripts = scripts;
|
|
16
21
|
|