@idomatic/create 1.3.0 → 1.5.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/helpers/index.js CHANGED
@@ -29,6 +29,25 @@ const defaultConfigs = {
29
29
  excludeTags: ["html", "head", "script", ...SOLID_CONTROL_FLOW],
30
30
  includeExtensions: ["jsx", "tsx"],
31
31
  },
32
+ "react-native": {
33
+ ...base,
34
+ // React Native components take testID, not id.
35
+ attributeName: "testID",
36
+ excludeTags: [],
37
+ includeExtensions: ["js", "jsx", "ts", "tsx"],
38
+ excludeFiles: ["node_modules", "ios", "android", ".expo"],
39
+ },
40
+ lit: {
41
+ ...base,
42
+ excludeTags: ["html", "head", "script", "slot"],
43
+ includeExtensions: ["js", "ts"],
44
+ },
45
+ angular: {
46
+ ...base,
47
+ excludeTags: ["html", "head", "script", "ng-container", "ng-template", "ng-content"],
48
+ // External templates, plus inline `template:` in component files.
49
+ includeExtensions: ["html", "component.ts"],
50
+ },
32
51
  html: {
33
52
  ...base,
34
53
  excludeTags: ["html", "head", "script"],
@@ -44,16 +63,107 @@ const defaultConfigs = {
44
63
  excludeTags: ["html", "head", "script"],
45
64
  includeExtensions: ["astro"],
46
65
  },
66
+ blade: {
67
+ ...base,
68
+ excludeTags: ["html", "head", "script"],
69
+ includeExtensions: ["blade.php"],
70
+ excludeFiles: ["node_modules", "public", "vendor", "storage"],
71
+ },
72
+ twig: {
73
+ ...base,
74
+ excludeTags: ["html", "head", "script"],
75
+ includeExtensions: ["twig"],
76
+ excludeFiles: ["node_modules", "public", "vendor", "var"],
77
+ },
78
+ jinja: {
79
+ ...base,
80
+ excludeTags: ["html", "head", "script"],
81
+ includeExtensions: ["html", "jinja", "jinja2", "j2", "njk"],
82
+ excludeFiles: ["node_modules", "static", "venv", ".venv"],
83
+ },
84
+ erb: {
85
+ ...base,
86
+ excludeTags: ["html", "head", "script"],
87
+ includeExtensions: ["erb"],
88
+ excludeFiles: ["node_modules", "public", "vendor", "tmp"],
89
+ },
90
+ ejs: {
91
+ ...base,
92
+ excludeTags: ["html", "head", "script"],
93
+ includeExtensions: ["ejs"],
94
+ },
95
+ razor: {
96
+ ...base,
97
+ excludeTags: ["html", "head", "script"],
98
+ includeExtensions: ["cshtml", "razor"],
99
+ excludeFiles: ["node_modules", "bin", "obj", "wwwroot"],
100
+ },
101
+ mdx: {
102
+ ...base,
103
+ excludeTags: ["html", "head", "script"],
104
+ includeExtensions: ["mdx"],
105
+ },
106
+ pug: {
107
+ ...base,
108
+ excludeTags: ["html", "head", "script"],
109
+ includeExtensions: ["pug"],
110
+ },
47
111
  handlebars: {
48
112
  ...base,
49
113
  excludeTags: ["html", "head", "script"],
50
- includeExtensions: ["hbs", "handlebars"],
114
+ includeExtensions: ["hbs", "handlebars", "gjs", "gts"],
115
+ },
116
+ swiftui: {
117
+ ...base,
118
+ // Written as .accessibilityIdentifier("…"); attributeName is not used.
119
+ attributeName: "accessibilityIdentifier",
120
+ // Views to skip (e.g. "Text"), and your own views to tag as well.
121
+ excludeTags: [],
122
+ includeTags: [],
123
+ includeExtensions: ["swift"],
124
+ excludeFiles: ["node_modules", "Pods", "Carthage", ".build", "DerivedData"],
125
+ },
126
+ flutter: {
127
+ ...base,
128
+ // Written as key: const Key('…'); attributeName is not used.
129
+ attributeName: "key",
130
+ // Widgets to skip (e.g. "Text"), and your own widgets to key as well.
131
+ excludeTags: [],
132
+ includeTags: [],
133
+ includeExtensions: ["dart"],
134
+ // Tests, build output and the platform folders hold no app widgets.
135
+ excludeFiles: [
136
+ "node_modules", "build", ".dart_tool", "test", "integration_test",
137
+ "android", "ios", "macos", "linux", "windows", "web",
138
+ ],
51
139
  },
140
+ compose: {
141
+ ...base,
142
+ // Written as Modifier.testTag("…"); attributeName is not used.
143
+ attributeName: "testTag",
144
+ // Composables to skip (e.g. "Text"), and your own composables to tag as well.
145
+ excludeTags: [],
146
+ includeTags: [],
147
+ includeExtensions: ["kt"],
148
+ excludeFiles: ["node_modules", "**/build", "**/.gradle", ".idea"],
149
+ },
150
+ };
151
+
152
+ const HTML = "@idomatic/parser-html";
153
+ const JS = "@idomatic/parser-js";
154
+
155
+ const PARSERS = {
156
+ js: [JS],
157
+ solid: [JS],
158
+ lit: [JS],
159
+ "react-native": [JS],
160
+ angular: [HTML, JS],
161
+ swiftui: ["@idomatic/parser-swift"],
162
+ flutter: ["@idomatic/parser-dart"],
163
+ compose: ["@idomatic/parser-kotlin"],
52
164
  };
53
165
 
54
- export const parserFor = (framework) =>
55
- framework === "js" || framework === "solid"
56
- ? "@idomatic/parser-js"
57
- : "@idomatic/parser-html";
166
+ /** The parser package(s) a framework needs. */
167
+ export const parsersFor = (framework) => PARSERS[framework] ?? [HTML];
58
168
 
59
169
  export default defaultConfigs;
package/index.js CHANGED
@@ -3,7 +3,7 @@ import prompts from "prompts";
3
3
  import { execSync } from "child_process";
4
4
  import { detectPackageManagerFallback } from "./utils/index.js";
5
5
  import initConfig from "./lib/initConfig.js";
6
- import { parserFor } from "./helpers/index.js";
6
+ import { parsersFor } from "./helpers/index.js";
7
7
 
8
8
  console.log("✨ Welcome to idomatic setup!");
9
9
 
@@ -26,14 +26,15 @@ const pkg = detectPackageManagerFallback();
26
26
 
27
27
  // Install parser if opted-in
28
28
  if (res.installParsers) {
29
- const parser = parserFor(framework);
29
+ const parsers = parsersFor(framework).join(" ");
30
30
  const installParserCmd = {
31
- npm: `npm install ${parser} --save-dev`,
32
- yarn: `yarn add ${parser} --dev`,
33
- bun: `bun add -d ${parser}`,
31
+ npm: `npm install ${parsers} --save-dev`,
32
+ yarn: `yarn add ${parsers} --dev`,
33
+ pnpm: `pnpm add -D ${parsers}`,
34
+ bun: `bun add -d ${parsers}`,
34
35
  }[pkg];
35
36
 
36
- console.log(`📦 Installing ${parser} with ${pkg}...`);
37
+ console.log(`📦 Installing ${parsers} with ${pkg}...`);
37
38
  execSync(installParserCmd, { stdio: "inherit" });
38
39
  }
39
40
 
@@ -41,10 +42,15 @@ if (res.installParsers) {
41
42
  const installCoreCmd = {
42
43
  npm: `npm install @idomatic/core --save-dev`,
43
44
  yarn: `yarn add @idomatic/core --dev`,
45
+ pnpm: `pnpm add -D @idomatic/core`,
44
46
  bun: `bun add -d @idomatic/core`,
45
47
  }[pkg];
46
48
 
47
49
  console.log(`📦 Installing @idomatic/core with ${pkg}...`);
48
50
  execSync(installCoreCmd, { stdio: "inherit" });
49
51
 
52
+ if (["swiftui", "flutter", "compose"].includes(framework)) {
53
+ console.log("ℹ️ idomatic runs on Node. Add node_modules/ to your .gitignore.");
54
+ }
55
+
50
56
  console.log("🎉 You're ready to run: npx idomatic scan --dry");
package/lib/initConfig.js CHANGED
@@ -11,11 +11,25 @@ async function initConfig() {
11
11
  message: "Which framework are you using?",
12
12
  choices: [
13
13
  { title: "React (JS/TSX)", value: "js" },
14
+ { title: "React Native", value: "react-native" },
14
15
  { title: "SolidJS", value: "solid" },
15
- { title: "HTML / Vue / Angular", value: "html" },
16
+ { title: "SwiftUI (iOS / macOS)", value: "swiftui" },
17
+ { title: "Flutter", value: "flutter" },
18
+ { title: "Jetpack Compose (Android / Multiplatform)", value: "compose" },
19
+ { title: "Lit / Web Components", value: "lit" },
20
+ { title: "Angular", value: "angular" },
21
+ { title: "HTML / Vue", value: "html" },
16
22
  { title: "Svelte", value: "svelte" },
17
23
  { title: "Astro", value: "astro" },
18
24
  { title: "Handlebars / Ember", value: "handlebars" },
25
+ { title: "Laravel Blade", value: "blade" },
26
+ { title: "Twig (Symfony)", value: "twig" },
27
+ { title: "Django / Jinja / Nunjucks", value: "jinja" },
28
+ { title: "Ruby on Rails (ERB)", value: "erb" },
29
+ { title: "EJS", value: "ejs" },
30
+ { title: "ASP.NET Razor / Blazor", value: "razor" },
31
+ { title: "MDX", value: "mdx" },
32
+ { title: "Pug", value: "pug" },
19
33
  ],
20
34
  },
21
35
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idomatic/create",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Interactive setup CLI for idomatic — run `npm init @idomatic` to scaffold config in an existing project.",
5
5
  "type": "module",
6
6
  "repository": {
package/utils/index.js CHANGED
@@ -4,7 +4,7 @@ import { join } from "path";
4
4
  export function detectPackageManagerFallback() {
5
5
  const root = process.cwd();
6
6
 
7
- if (existsSync(join(root, "bun.lockb"))) return "bun";
7
+ if (existsSync(join(root, "bun.lockb")) || existsSync(join(root, "bun.lock"))) return "bun";
8
8
  if (existsSync(join(root, "yarn.lock"))) return "yarn";
9
9
  if (existsSync(join(root, "pnpm-lock.yaml"))) return "pnpm";
10
10
  if (existsSync(join(root, "package-lock.json"))) return "npm";