regressify 1.0.4 → 1.0.5
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/generate_tests.js +12 -27
- package/package.json +1 -1
- package/update-package.js +20 -0
package/generate_tests.js
CHANGED
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
3
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import
|
|
4
|
+
import { ncp } from 'ncp';
|
|
6
5
|
import chalk from 'chalk';
|
|
7
6
|
|
|
8
|
-
const { ncp } = pkg;
|
|
9
|
-
|
|
10
7
|
async function askUser() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
type: 'confirm',
|
|
14
|
-
name: 'addFolder',
|
|
15
|
-
message: 'Do you want to add the "visual_tests" folder to the root of your project?',
|
|
16
|
-
default: true,
|
|
17
|
-
},
|
|
18
|
-
]);
|
|
8
|
+
const sourceFolder = path.join(path.dirname(fileURLToPath(import.meta.url)), 'visual_tests');
|
|
9
|
+
const destinationFolder = path.join(process.cwd(), 'visual_tests');
|
|
19
10
|
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
console.log(chalk.green('Folder "visual_tests" has been copied to your project!'));
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
console.log(chalk.yellow('Folder "visual_tests" already exists.'));
|
|
33
|
-
}
|
|
11
|
+
if (!fs.existsSync(destinationFolder)) {
|
|
12
|
+
ncp(sourceFolder, destinationFolder, function (err) {
|
|
13
|
+
if (err) {
|
|
14
|
+
console.log(chalk.red('Error copying folder:'), err);
|
|
15
|
+
} else {
|
|
16
|
+
console.log(chalk.green('Folder "visual_tests" has been copied to your project!'));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
34
19
|
} else {
|
|
35
|
-
console.log('
|
|
20
|
+
console.log(chalk.yellow('Folder "visual_tests" already exists.'));
|
|
36
21
|
}
|
|
37
22
|
}
|
|
38
23
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
async function updatePackageJson() {
|
|
6
|
+
const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'package.json');
|
|
7
|
+
const packageJsonText = fs.readFileSync(packageJsonPath, 'utf8');
|
|
8
|
+
const packageJson = JSON.parse(packageJsonText);
|
|
9
|
+
|
|
10
|
+
const scripts = packageJson.scripts || {};
|
|
11
|
+
scripts.ref = 'regressify-cli ref';
|
|
12
|
+
scripts.approve = 'regressify-cli approve';
|
|
13
|
+
scripts.test = 'regressify-cli test';
|
|
14
|
+
|
|
15
|
+
packageJson.scripts = scripts;
|
|
16
|
+
|
|
17
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
updatePackageJson().catch((err) => console.error('Error:', err));
|