@idomatic/core 1.2.0 → 1.4.0

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/bin/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import runInitScan from "../lib/scan.js";
3
3
 
4
- const args = process.argv.slice(2);
5
- const isDry = args[0] === "scan" && args[1] === "--dry";
4
+ const [command, flag] = process.argv.slice(2);
6
5
 
7
- if (args[0] === "scan") {
8
- await runInitScan(isDry);
6
+ if (command === "scan" && (flag === "--dry" || flag === "--write")) {
7
+ await runInitScan(flag === "--dry");
9
8
  } else {
10
- console.log("āŒ Unsupported command.\nšŸ‘‰ Use: 'scan' or 'scan --dry'");
9
+ console.log(
10
+ "šŸ‘‰ Use: 'idomatic scan --dry' to preview, or 'idomatic scan --write' to apply."
11
+ );
11
12
  }
@@ -0,0 +1,13 @@
1
+ import excludeFiles from "./ignoredFiles.js";
2
+
3
+ const defaultConfig = {
4
+ attributeName: "id",
5
+ // "semantic" -> readable ids (button-submit); "random" -> ${prefix}${uuid}
6
+ idStrategy: "semantic",
7
+ prefix: "",
8
+ excludeTags: [], //html,head,script...
9
+ includeExtensions: ["js", "jsx", "ts", "tsx"],
10
+ excludeFiles: excludeFiles,
11
+ };
12
+
13
+ export default defaultConfig;
@@ -0,0 +1,14 @@
1
+ const excludeFiles = [
2
+ "node_modules",
3
+ "bun_modules",
4
+ ".next",
5
+ "dist",
6
+ "out",
7
+ "build",
8
+ ".git",
9
+ ".vercel",
10
+ ".turbo",
11
+ "public",
12
+ ];
13
+
14
+ export default excludeFiles;
package/lib/core.js CHANGED
@@ -9,7 +9,10 @@ const parserMap = {
9
9
  ".tsx": "@idomatic/parser-js",
10
10
  ".html": "@idomatic/parser-html",
11
11
  ".vue": "@idomatic/parser-html",
12
- ".ng.html": "@idomatic/parser-html",
12
+ ".svelte": "@idomatic/parser-html",
13
+ ".astro": "@idomatic/parser-html",
14
+ ".hbs": "@idomatic/parser-html",
15
+ ".handlebars": "@idomatic/parser-html",
13
16
  };
14
17
 
15
18
  export async function processFile(filePath, config, dry = false) {
@@ -29,10 +32,16 @@ export async function processFile(filePath, config, dry = false) {
29
32
  const result = await parser.default(filePath, config, dry);
30
33
  return result;
31
34
  } catch (err) {
32
- console.log(err);
33
- console.error(
34
- `āŒ Failed to load parser "${parserPackage}" for ${filePath}`
35
- );
35
+ if (err.code === "MODULE_NOT_FOUND") {
36
+ console.error(
37
+ `āŒ Missing parser for ${filePath} — install it with: npm i -D ${parserPackage}`
38
+ );
39
+ } else {
40
+ console.error(
41
+ `āŒ Failed to load parser "${parserPackage}" for ${filePath}`,
42
+ err
43
+ );
44
+ }
36
45
  return false;
37
46
  }
38
47
  }
package/lib/readConfig.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import defaultConfig from "../const/defaultConfig.js";
3
4
 
4
5
  export default function getUserConfig() {
5
6
  const configFilePath = path.join(process.cwd(), ".idomatic.config.json");
@@ -8,13 +9,15 @@ export default function getUserConfig() {
8
9
  try {
9
10
  const configContent = fs.readFileSync(configFilePath, "utf-8");
10
11
  const userConfig = JSON.parse(configContent);
11
- return userConfig;
12
+ return { ...defaultConfig, ...userConfig };
12
13
  } catch (err) {
13
14
  console.error(
14
15
  "Error reading the .idomatic.config.json file. Using default config."
15
16
  );
17
+ return defaultConfig;
16
18
  }
17
- } else {
18
- console.warn("No .idomatic.config.json file found. Using default config.");
19
19
  }
20
+
21
+ console.warn("No .idomatic.config.json file found. Using default config.");
22
+ return defaultConfig;
20
23
  }
package/package.json CHANGED
@@ -1,13 +1,24 @@
1
1
  {
2
2
  "name": "@idomatic/core",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
+ "description": "CLI that injects stable, human-readable id attributes into React, Solid, HTML, Vue, Angular, Svelte, Astro and Handlebars elements so Playwright, Cypress and Testing Library tests stop breaking.",
4
5
  "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/AmarSmajlovic/idomatic.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "homepage": "https://www.idomatic.dev",
12
+ "bugs": {
13
+ "url": "https://github.com/AmarSmajlovic/idomatic/issues"
14
+ },
5
15
  "bin": {
6
16
  "idomatic": "./bin/index.js"
7
17
  },
8
18
  "files": [
9
19
  "bin",
10
- "lib"
20
+ "lib",
21
+ "const"
11
22
  ],
12
23
  "dependencies": {
13
24
  "globby": "^14.1.0",
@@ -29,6 +40,10 @@
29
40
  "react",
30
41
  "html",
31
42
  "vue",
43
+ "svelte",
44
+ "astro",
45
+ "solid",
46
+ "handlebars",
32
47
  "ids",
33
48
  "precommit",
34
49
  "parser"