@idomatic/core 1.1.67 → 1.1.68
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/lib/core.js +6 -6
- package/lib/scan.js +6 -13
- package/package.json +1 -1
package/lib/core.js
CHANGED
|
@@ -12,26 +12,26 @@ const parserMap = {
|
|
|
12
12
|
".ng.html": "@idomatic/parser-html",
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export async function processFile(filePath, config) {
|
|
15
|
+
export async function processFile(filePath, config, dry = false) {
|
|
16
16
|
const ext = path.extname(filePath).toLowerCase();
|
|
17
17
|
const parserPackage = parserMap[ext];
|
|
18
18
|
|
|
19
19
|
if (!parserPackage) {
|
|
20
20
|
console.warn(`⛔ Skipping unsupported file: ${filePath}`);
|
|
21
|
-
return;
|
|
21
|
+
return false;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
25
|
const resolvedPath = resolveFrom(process.cwd(), parserPackage);
|
|
26
26
|
const resolvedURL = pathToFileURL(resolvedPath).href;
|
|
27
27
|
const parser = await import(resolvedURL);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
28
|
+
|
|
29
|
+
const result = await parser.default(filePath, config, dry);
|
|
30
|
+
return result;
|
|
32
31
|
} catch (err) {
|
|
33
32
|
console.error(
|
|
34
33
|
`❌ Failed to load parser "${parserPackage}" for ${filePath}`
|
|
35
34
|
);
|
|
35
|
+
return false;
|
|
36
36
|
}
|
|
37
37
|
}
|
package/lib/scan.js
CHANGED
|
@@ -2,7 +2,7 @@ import { globby } from "globby";
|
|
|
2
2
|
import { processFile } from "./core.js";
|
|
3
3
|
import getUserConfig from "./readConfig.js";
|
|
4
4
|
|
|
5
|
-
async function runInitScan(isDry = false) {
|
|
5
|
+
export default async function runInitScan(isDry = false) {
|
|
6
6
|
const config = getUserConfig();
|
|
7
7
|
|
|
8
8
|
const patterns = config.includeExtensions.map((ext) => `**/*.${ext}`);
|
|
@@ -19,16 +19,11 @@ async function runInitScan(isDry = false) {
|
|
|
19
19
|
|
|
20
20
|
for (const file of files) {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} else {
|
|
28
|
-
const updated = await processFile(file, config);
|
|
29
|
-
if (updated) {
|
|
30
|
-
console.log(`✅ Updated: ${file}`);
|
|
31
|
-
}
|
|
22
|
+
const updated = await processFile(file, config, isDry);
|
|
23
|
+
if (updated) {
|
|
24
|
+
console.log(
|
|
25
|
+
`${isDry ? "[Dry Run] Would update" : "✅ Updated"}: ${file}`
|
|
26
|
+
);
|
|
32
27
|
}
|
|
33
28
|
} catch (e) {
|
|
34
29
|
console.warn(`❌ Error in: ${file}`, e);
|
|
@@ -37,5 +32,3 @@ async function runInitScan(isDry = false) {
|
|
|
37
32
|
|
|
38
33
|
console.log("🎉 Init scan complete!");
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
export default runInitScan;
|