@komaci/cli 242.2.0 → 242.2.3
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.
|
@@ -14,6 +14,13 @@ declare type BundleFile = {
|
|
|
14
14
|
* @returns An array of BundleFile
|
|
15
15
|
*/
|
|
16
16
|
export declare function readBundle(path: string): BundleFile[];
|
|
17
|
+
/**
|
|
18
|
+
* Finds all .js, .mjs, .css, and .html files within the given directory, reads their contents, and combines them into a bundle,
|
|
19
|
+
* and returning the array of BundleFile containing the file's fileName and source
|
|
20
|
+
* @param path
|
|
21
|
+
* @returns An array of BundleFile
|
|
22
|
+
*/
|
|
23
|
+
export declare function traverseDir(path: string, filesArr: BundleFile[]): BundleFile[];
|
|
17
24
|
/**
|
|
18
25
|
* Takes the directory path of an LWC module bundle and an optional set of config overrides. Returns the ParsedBundle, inlcuding
|
|
19
26
|
* the bundle's 1) LWC Metadata and 2) Komaci / Resolvable module.
|
|
@@ -10,16 +10,33 @@ import { generateKomaciModule, processGeneratorInputAndState } from '@komaci/esm
|
|
|
10
10
|
*/
|
|
11
11
|
export function readBundle(path) {
|
|
12
12
|
path = resolve(path);
|
|
13
|
+
return traverseDir(path, []);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Finds all .js, .mjs, .css, and .html files within the given directory, reads their contents, and combines them into a bundle,
|
|
17
|
+
* and returning the array of BundleFile containing the file's fileName and source
|
|
18
|
+
* @param path
|
|
19
|
+
* @returns An array of BundleFile
|
|
20
|
+
*/
|
|
21
|
+
export function traverseDir(path, filesArr) {
|
|
13
22
|
if (existsSync(path)) {
|
|
14
|
-
const contents = readdirSync(path);
|
|
23
|
+
const contents = readdirSync(path, { withFileTypes: true });
|
|
15
24
|
const LWC_EXT = ['.js', '.mjs', '.css', '.html'];
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
contents.forEach((file) => {
|
|
26
|
+
if (file.isDirectory()) {
|
|
27
|
+
filesArr.concat(traverseDir(path + '/' + file.name, filesArr));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
//check the file extension here and then add it to the files arr
|
|
31
|
+
if (LWC_EXT.includes(extname(file.name))) {
|
|
32
|
+
filesArr.push({
|
|
33
|
+
fileName: path + '/' + file.name,
|
|
34
|
+
source: readFileSync(resolve(path, file.name), 'utf-8').toString(),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
18
38
|
});
|
|
19
|
-
return
|
|
20
|
-
fileName,
|
|
21
|
-
source: readFileSync(resolve(path, fileName), 'utf-8').toString(),
|
|
22
|
-
}));
|
|
39
|
+
return filesArr;
|
|
23
40
|
}
|
|
24
41
|
else {
|
|
25
42
|
throw new Error(`path doesn't exist: ${path}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@komaci/cli",
|
|
3
|
-
"version": "242.2.
|
|
3
|
+
"version": "242.2.3",
|
|
4
4
|
"description": "CLI utility that enables developers to use komaci from the command line.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/AndrewHuffman/komaci/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@komaci/esm-generator": "242.2.
|
|
27
|
+
"@komaci/esm-generator": "242.2.3",
|
|
28
28
|
"@lwc/metadata": "2.22.0-0",
|
|
29
29
|
"@lwc/sfdc-compiler-utils": "2.22.0-0",
|
|
30
30
|
"chalk": "^5.0.1",
|