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 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 pkg from 'ncp';
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 response = await inquirer.prompt([
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 (response.addFolder) {
21
- const sourceFolder = path.join(path.dirname(fileURLToPath(import.meta.url)), 'visual_tests');
22
- const destinationFolder = path.join(process.cwd(), 'visual_tests');
23
- if (!fs.existsSync(destinationFolder)) {
24
- ncp(sourceFolder, destinationFolder, function (err) {
25
- if (err) {
26
- console.log(chalk.red('Error copying folder:'), err);
27
- } else {
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('No folder was added.');
20
+ console.log(chalk.yellow('Folder "visual_tests" already exists.'));
36
21
  }
37
22
  }
38
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regressify",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Visual regression tests support",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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));