lucy-cli 1.0.2 → 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.
- package/dist/gulp/checks.js +80 -16
- package/package.json +2 -1
- package/src/gulp/checks.ts +85 -17
package/dist/gulp/checks.js
CHANGED
@@ -1,10 +1,43 @@
|
|
1
1
|
import * as fs from 'fs';
|
2
|
-
import
|
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
|
-
|
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
|
+
// }
|
8
41
|
/**
|
9
42
|
* Extracts a match from a file
|
10
43
|
* @param {string} filePath File path
|
@@ -24,21 +57,52 @@ function extractMatchFromFile(filePath, pattern) {
|
|
24
57
|
});
|
25
58
|
});
|
26
59
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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;
|
35
72
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
+
});
|
42
106
|
}
|
43
107
|
export async function checkPages(fail, force) {
|
44
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.
|
4
|
+
"version": "1.0.4",
|
5
5
|
"description": "Lucy Framework for WIX Studio Editor",
|
6
6
|
"main": ".dist/index.js",
|
7
7
|
"scripts": {
|
@@ -38,6 +38,7 @@
|
|
38
38
|
"chalk": "^5.3.0",
|
39
39
|
"cypress": "13.15.2",
|
40
40
|
"cypress-cloud": "^1.9.3",
|
41
|
+
"glob": "^7.2.3",
|
41
42
|
"gulp": "4.0.2",
|
42
43
|
"gulp-clean": "^0.4.0",
|
43
44
|
"gulp-cli": "3.0.0",
|
package/src/gulp/checks.ts
CHANGED
@@ -1,12 +1,50 @@
|
|
1
1
|
import * as fs from 'fs';
|
2
|
-
import
|
2
|
+
import glob from 'glob';
|
3
3
|
|
4
4
|
import * as path from 'path';
|
5
5
|
import gulp from 'gulp';
|
6
6
|
import ts from 'gulp-typescript';
|
7
7
|
import { blue, green, magenta, orange, red, yellow } from '../index.js';
|
8
8
|
import { TaskOptions } from '../Gulpfile.js';
|
9
|
-
|
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
|
+
// }
|
10
48
|
|
11
49
|
/**
|
12
50
|
* Extracts a match from a file
|
@@ -29,22 +67,52 @@ function extractMatchFromFile(filePath: string, pattern: string) {
|
|
29
67
|
});
|
30
68
|
}
|
31
69
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
filenameList.push(path.basename(file));
|
44
|
-
}
|
45
|
-
}
|
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);
|
46
81
|
|
47
|
-
|
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
|
+
});
|
48
116
|
}
|
49
117
|
export async function checkPages(fail: boolean, force: boolean) {
|
50
118
|
console.log("🐕" + green.underline.bold(' => Checking pages...'));
|