lucy-cli 1.0.3 β†’ 1.0.4

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.
@@ -1,9 +1,43 @@
1
1
  import * as fs from 'fs';
2
- import { glob } from 'glob';
2
+ import glob from 'glob';
3
3
  import * as path from 'path';
4
4
  import gulp from 'gulp';
5
5
  import ts from 'gulp-typescript';
6
6
  import { blue, green, magenta, orange, red, yellow } from '../index.js';
7
+ // /**
8
+ // * Extracts a match from a file
9
+ // * @param {string} filePath File path
10
+ // * @param {string} pattern Pattern to match
11
+ // */
12
+ // function extractMatchFromFile(filePath: string, pattern: string) {
13
+ // return new Promise((resolve, reject) => {
14
+ // fs.readFile(filePath, 'utf8', (err, data) => {
15
+ // if (err){
16
+ // reject(err);
17
+ // return;
18
+ // }
19
+ // const regex = new RegExp(pattern);
20
+ // const match = regex.exec(data);
21
+ // const capturedGroup = match ? match.groups?.page : null;
22
+ // resolve(capturedGroup);
23
+ // });
24
+ // });
25
+ // }
26
+ // async function readFilesInFolder(folderPath: string, pattern: string | null, globPattern: string): Promise<Object[]> {
27
+ // const files = await glob(path.join(folderPath, globPattern));
28
+ // const filenameList: Object[] = [];
29
+ // for (const file of files) {
30
+ // if (pattern) {
31
+ // const capturedGroup = await extractMatchFromFile(file, pattern);
32
+ // if (capturedGroup) {
33
+ // filenameList.push(capturedGroup);
34
+ // }
35
+ // } else {
36
+ // filenameList.push(path.basename(file));
37
+ // }
38
+ // }
39
+ // return filenameList;
40
+ // }
7
41
  /**
8
42
  * Extracts a match from a file
9
43
  * @param {string} filePath File path
@@ -23,21 +57,52 @@ function extractMatchFromFile(filePath, pattern) {
23
57
  });
24
58
  });
25
59
  }
26
- async function readFilesInFolder(folderPath, pattern, globPattern) {
27
- const files = await glob(path.join(folderPath, globPattern));
28
- const filenameList = [];
29
- for (const file of files) {
30
- if (pattern) {
31
- const capturedGroup = await extractMatchFromFile(file, pattern);
32
- if (capturedGroup) {
33
- filenameList.push(capturedGroup);
60
+ /**
61
+ * Reads files in a folder
62
+ * @param {string} folderPath Folder path
63
+ * @param {string} pattern Pattern to match
64
+ * @param {string} globPattern Glob pattern
65
+ */
66
+ function readFilesInFolder(folderPath, pattern, globPattern) {
67
+ return new Promise((resolve, reject) => {
68
+ glob(path.join(folderPath, globPattern), (err, files) => {
69
+ if (err) {
70
+ reject(err);
71
+ return;
34
72
  }
35
- }
36
- else {
37
- filenameList.push(path.basename(file));
38
- }
39
- }
40
- return filenameList;
73
+ const filenameList = [];
74
+ /**
75
+ * Traverse files
76
+ * @param {number} index Index
77
+ */
78
+ function traverseFiles(index) {
79
+ if (index === files.length) {
80
+ resolve(filenameList);
81
+ return;
82
+ }
83
+ const file = files[index];
84
+ if (pattern) {
85
+ if (!file)
86
+ return;
87
+ extractMatchFromFile(file, pattern)
88
+ .then((capturedGroup) => {
89
+ if (capturedGroup) {
90
+ filenameList.push(capturedGroup);
91
+ }
92
+ traverseFiles(index + 1);
93
+ })
94
+ .catch(reject);
95
+ }
96
+ if (!pattern) {
97
+ if (!file)
98
+ return;
99
+ filenameList.push(path.basename(file));
100
+ traverseFiles(index + 1);
101
+ }
102
+ }
103
+ traverseFiles(0);
104
+ });
105
+ });
41
106
  }
42
107
  export async function checkPages(fail, force) {
43
108
  console.log("πŸ•" + green.underline.bold(' => Checking pages...'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "lucy-cli",
4
- "version": "1.0.3",
4
+ "version": "1.0.4",
5
5
  "description": "Lucy Framework for WIX Studio Editor",
6
6
  "main": ".dist/index.js",
7
7
  "scripts": {
@@ -23,7 +23,6 @@
23
23
  ],
24
24
  "author": "Gradlon von KΓ€nel",
25
25
  "license": "MIT",
26
- "node": ">=20.0.0",
27
26
  "bugs": {
28
27
  "url": "https://github.com/Integral-Systems/wix-lucy-cli/issues"
29
28
  },
@@ -39,6 +38,7 @@
39
38
  "chalk": "^5.3.0",
40
39
  "cypress": "13.15.2",
41
40
  "cypress-cloud": "^1.9.3",
41
+ "glob": "^7.2.3",
42
42
  "gulp": "4.0.2",
43
43
  "gulp-clean": "^0.4.0",
44
44
  "gulp-cli": "3.0.0",
@@ -95,6 +95,7 @@
95
95
  "eslint-plugin-jsdoc": "50.5.0",
96
96
  "eslint-plugin-named-import-spacing": "^1.0.3",
97
97
  "eslint-plugin-simple-import-sort": "12.1.1",
98
+ "i": "^0.3.7",
98
99
  "npm": "^11.0.0",
99
100
  "ts-node": "^10.9.1"
100
101
  }
@@ -1,11 +1,51 @@
1
1
  import * as fs from 'fs';
2
- import { glob } from 'glob';
2
+ import glob from 'glob';
3
+
3
4
  import * as path from 'path';
4
5
  import gulp from 'gulp';
5
6
  import ts from 'gulp-typescript';
6
7
  import { blue, green, magenta, orange, red, yellow } from '../index.js';
7
8
  import { TaskOptions } from '../Gulpfile.js';
8
9
 
10
+ // /**
11
+ // * Extracts a match from a file
12
+ // * @param {string} filePath File path
13
+ // * @param {string} pattern Pattern to match
14
+ // */
15
+ // function extractMatchFromFile(filePath: string, pattern: string) {
16
+ // return new Promise((resolve, reject) => {
17
+ // fs.readFile(filePath, 'utf8', (err, data) => {
18
+ // if (err){
19
+ // reject(err);
20
+
21
+ // return;
22
+ // }
23
+ // const regex = new RegExp(pattern);
24
+ // const match = regex.exec(data);
25
+ // const capturedGroup = match ? match.groups?.page : null;
26
+ // resolve(capturedGroup);
27
+ // });
28
+ // });
29
+ // }
30
+
31
+ // async function readFilesInFolder(folderPath: string, pattern: string | null, globPattern: string): Promise<Object[]> {
32
+ // const files = await glob(path.join(folderPath, globPattern));
33
+ // const filenameList: Object[] = [];
34
+
35
+ // for (const file of files) {
36
+ // if (pattern) {
37
+ // const capturedGroup = await extractMatchFromFile(file, pattern);
38
+ // if (capturedGroup) {
39
+ // filenameList.push(capturedGroup);
40
+ // }
41
+ // } else {
42
+ // filenameList.push(path.basename(file));
43
+ // }
44
+ // }
45
+
46
+ // return filenameList;
47
+ // }
48
+
9
49
  /**
10
50
  * Extracts a match from a file
11
51
  * @param {string} filePath File path
@@ -27,22 +67,52 @@ function extractMatchFromFile(filePath: string, pattern: string) {
27
67
  });
28
68
  }
29
69
 
30
- async function readFilesInFolder(folderPath: string, pattern: string | null, globPattern: string): Promise<Object[]> {
31
- const files = await glob(path.join(folderPath, globPattern));
32
- const filenameList: Object[] = [];
33
-
34
- for (const file of files) {
35
- if (pattern) {
36
- const capturedGroup = await extractMatchFromFile(file, pattern);
37
- if (capturedGroup) {
38
- filenameList.push(capturedGroup);
39
- }
40
- } else {
41
- filenameList.push(path.basename(file));
42
- }
43
- }
70
+ /**
71
+ * Reads files in a folder
72
+ * @param {string} folderPath Folder path
73
+ * @param {string} pattern Pattern to match
74
+ * @param {string} globPattern Glob pattern
75
+ */
76
+ function readFilesInFolder(folderPath: string, pattern: string | null, globPattern: string,) {
77
+ return new Promise((resolve, reject) => {
78
+ glob(path.join(folderPath, globPattern), (err: unknown, files: string[]) => {
79
+ if (err){
80
+ reject(err);
44
81
 
45
- return filenameList;
82
+ return;
83
+ }
84
+ const filenameList: Object[] = [];
85
+ /**
86
+ * Traverse files
87
+ * @param {number} index Index
88
+ */
89
+ function traverseFiles(index: number) {
90
+ if (index === files.length){
91
+ resolve(filenameList);
92
+
93
+ return;
94
+ }
95
+ const file = files[index];
96
+ if(pattern){
97
+ if(!file) return
98
+ extractMatchFromFile(file, pattern)
99
+ .then((capturedGroup) => {
100
+ if (capturedGroup){
101
+ filenameList.push(capturedGroup);
102
+ }
103
+ traverseFiles(index + 1);
104
+ })
105
+ .catch(reject);
106
+ }
107
+ if(!pattern){
108
+ if(!file) return
109
+ filenameList.push(path.basename(file));
110
+ traverseFiles(index + 1);
111
+ }
112
+ }
113
+ traverseFiles(0);
114
+ });
115
+ });
46
116
  }
47
117
  export async function checkPages(fail: boolean, force: boolean) {
48
118
  console.log("πŸ•" + green.underline.bold(' => Checking pages...'));