@idomatic/create 1.2.1 → 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
@@ -1,20 +1,169 @@
1
+ const base = {
2
+ attributeName: "id",
3
+ idStrategy: "semantic",
4
+ prefix: "",
5
+ excludeFiles: ["node_modules", "public"],
6
+ };
7
+
8
+ // Solid control-flow components render no DOM node of their own.
9
+ const SOLID_CONTROL_FLOW = [
10
+ "For",
11
+ "Index",
12
+ "Show",
13
+ "Switch",
14
+ "Match",
15
+ "Suspense",
16
+ "ErrorBoundary",
17
+ "Portal",
18
+ "Dynamic",
19
+ ];
20
+
1
21
  const defaultConfigs = {
2
22
  js: {
3
- attributeName: "id",
4
- idStrategy: "semantic",
5
- prefix: "",
23
+ ...base,
6
24
  excludeTags: ["html", "head", "script"],
7
25
  includeExtensions: ["js", "jsx", "ts", "tsx"],
8
- excludeFiles: ["node_modules", "public"],
26
+ },
27
+ solid: {
28
+ ...base,
29
+ excludeTags: ["html", "head", "script", ...SOLID_CONTROL_FLOW],
30
+ includeExtensions: ["jsx", "tsx"],
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"],
9
50
  },
10
51
  html: {
11
- attributeName: "id",
12
- idStrategy: "semantic",
13
- prefix: "",
52
+ ...base,
14
53
  excludeTags: ["html", "head", "script"],
15
54
  includeExtensions: ["html", "vue"],
16
- excludeFiles: ["node_modules", "public"],
55
+ },
56
+ svelte: {
57
+ ...base,
58
+ excludeTags: ["html", "head", "script"],
59
+ includeExtensions: ["svelte"],
60
+ },
61
+ astro: {
62
+ ...base,
63
+ excludeTags: ["html", "head", "script"],
64
+ includeExtensions: ["astro"],
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
+ },
111
+ handlebars: {
112
+ ...base,
113
+ excludeTags: ["html", "head", "script"],
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
+ ],
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"],
17
149
  },
18
150
  };
19
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"],
164
+ };
165
+
166
+ /** The parser package(s) a framework needs. */
167
+ export const parsersFor = (framework) => PARSERS[framework] ?? [HTML];
168
+
20
169
  export default defaultConfigs;
package/index.js CHANGED
@@ -3,6 +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 { parsersFor } from "./helpers/index.js";
6
7
 
7
8
  console.log("✨ Welcome to idomatic setup!");
8
9
 
@@ -25,15 +26,15 @@ const pkg = detectPackageManagerFallback();
25
26
 
26
27
  // Install parser if opted-in
27
28
  if (res.installParsers) {
28
- const parser =
29
- framework === "js" ? "@idomatic/parser-js" : "@idomatic/parser-html";
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,7 +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: "HTML / Vue / Angular", value: "html" },
14
+ { title: "React Native", value: "react-native" },
15
+ { title: "SolidJS", value: "solid" },
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" },
22
+ { title: "Svelte", value: "svelte" },
23
+ { title: "Astro", value: "astro" },
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" },
15
33
  ],
16
34
  },
17
35
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idomatic/create",
3
- "version": "1.2.1",
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";