trix-ui 0.2.14 → 0.3.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/dist/commands/add/analysis.d.ts +4 -4
- package/dist/commands/add/analysis.js +56 -56
- package/dist/commands/add/command.d.ts +2 -2
- package/dist/commands/add/command.js +205 -202
- package/dist/commands/add/command.js.map +1 -1
- package/dist/commands/add/config.d.ts +2 -2
- package/dist/commands/add/config.js +11 -11
- package/dist/commands/add/install.d.ts +27 -27
- package/dist/commands/add/install.js +80 -80
- package/dist/commands/add/package-manager.d.ts +1 -1
- package/dist/commands/add/package-manager.js +4 -4
- package/dist/commands/add/project-files.d.ts +2 -2
- package/dist/commands/add/project-files.js +17 -17
- package/dist/commands/add/prompts.d.ts +3 -3
- package/dist/commands/add/prompts.js +28 -28
- package/dist/commands/add/registry.d.ts +4 -4
- package/dist/commands/add/registry.js +6 -6
- package/dist/commands/add/types.d.ts +33 -33
- package/dist/commands/add/types.js +1 -1
- package/dist/commands/add/ui.d.ts +4 -4
- package/dist/commands/add/ui.js +55 -55
- package/dist/commands/add/validation.d.ts +3 -3
- package/dist/commands/add/validation.js +30 -30
- package/dist/commands/add-collection.d.ts +1 -1
- package/dist/commands/add-collection.js +1 -1
- package/dist/commands/add-composite.d.ts +2 -2
- package/dist/commands/add-composite.js +205 -201
- package/dist/commands/add-composite.js.map +1 -1
- package/dist/commands/add-section.d.ts +2 -2
- package/dist/commands/add-section.js +205 -201
- package/dist/commands/add-section.js.map +1 -1
- package/dist/commands/add-wrapper.d.ts +2 -2
- package/dist/commands/add-wrapper.js +205 -201
- package/dist/commands/add-wrapper.js.map +1 -1
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/build.d.ts +2 -2
- package/dist/commands/build.js +104 -104
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +67 -67
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init/command.d.ts +8 -2
- package/dist/commands/init/command.js +186 -114
- package/dist/commands/init/command.js.map +1 -1
- package/dist/commands/init/config.d.ts +9 -2
- package/dist/commands/init/config.js +45 -25
- package/dist/commands/init/config.js.map +1 -1
- package/dist/commands/init/constants.d.ts +3 -3
- package/dist/commands/init/constants.js +105 -105
- package/dist/commands/init/dependencies.d.ts +22 -5
- package/dist/commands/init/dependencies.js +86 -52
- package/dist/commands/init/dependencies.js.map +1 -1
- package/dist/commands/init/filesystem.d.ts +7 -1
- package/dist/commands/init/filesystem.js +16 -10
- package/dist/commands/init/filesystem.js.map +1 -1
- package/dist/commands/init/lockfile.d.ts +1 -1
- package/dist/commands/init/lockfile.js +1 -1
- package/dist/commands/init/package-json.d.ts +17 -6
- package/dist/commands/init/package-json.js +28 -18
- package/dist/commands/init/package-json.js.map +1 -1
- package/dist/commands/init/project.d.ts +15 -3
- package/dist/commands/init/project.js +120 -97
- package/dist/commands/init/project.js.map +1 -1
- package/dist/commands/init/tailwind.d.ts +14 -3
- package/dist/commands/init/tailwind.js +141 -33
- package/dist/commands/init/tailwind.js.map +1 -1
- package/dist/commands/init/templates.d.ts +15 -3
- package/dist/commands/init/templates.js +27 -15
- package/dist/commands/init/templates.js.map +1 -1
- package/dist/commands/init/tsconfig.d.ts +14 -2
- package/dist/commands/init/tsconfig.js +561 -273
- package/dist/commands/init/tsconfig.js.map +1 -1
- package/dist/commands/init/types.d.ts +34 -33
- package/dist/commands/init/types.js +1 -1
- package/dist/commands/init/ui.d.ts +12 -3
- package/dist/commands/init/ui.js +45 -33
- package/dist/commands/init/ui.js.map +1 -1
- package/dist/commands/init/vite.d.ts +1 -1
- package/dist/commands/init/vite.js +17 -27
- package/dist/commands/init/vite.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/list.d.ts +2 -2
- package/dist/commands/list.js +69 -62
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/remove.d.ts +2 -2
- package/dist/commands/remove.js +95 -93
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/shared/add-collection.d.ts +50 -50
- package/dist/commands/shared/add-collection.js +206 -206
- package/dist/commands/shared/list-entries.d.ts +6 -6
- package/dist/commands/shared/list-entries.js +12 -12
- package/dist/commands/shared/name-utils.d.ts +1 -1
- package/dist/commands/shared/name-utils.js +13 -13
- package/dist/commands/shared/remove-entries.d.ts +16 -16
- package/dist/commands/shared/remove-entries.js +41 -41
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/libraries.d.ts +37 -37
- package/dist/icons/libraries.js +34 -34
- package/dist/index.d.ts +1 -2
- package/dist/index.js +29 -30
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +45 -45
- package/dist/lib/config.js +97 -97
- package/dist/lib/fs.d.ts +82 -76
- package/dist/lib/fs.js +299 -302
- package/dist/lib/fs.js.map +1 -1
- package/dist/lib/highlighter.d.ts +6 -6
- package/dist/lib/highlighter.js +7 -7
- package/dist/lib/install.d.ts +19 -19
- package/dist/lib/install.js +101 -55
- package/dist/lib/install.js.map +1 -1
- package/dist/lib/lockfile.d.ts +63 -63
- package/dist/lib/lockfile.js +179 -173
- package/dist/lib/lockfile.js.map +1 -1
- package/dist/lib/logger.d.ts +8 -8
- package/dist/lib/logger.js +41 -41
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/paths.d.ts +14 -14
- package/dist/lib/paths.js +41 -31
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/registry.d.ts +35 -35
- package/dist/lib/registry.js +180 -180
- package/dist/schema/index.d.ts +1128 -1128
- package/dist/schema/index.js +237 -238
- package/dist/schema/index.js.map +1 -1
- package/dist/styles/create-style-map.d.ts +4 -4
- package/dist/styles/create-style-map.js +68 -68
- package/dist/styles/transform-style-map.d.ts +3 -3
- package/dist/styles/transform-style-map.js +428 -428
- package/dist/styles/transform.d.ts +10 -10
- package/dist/styles/transform.js +15 -15
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.js +5 -5
- package/dist/utils/transformers/transform-icons.d.ts +2 -2
- package/dist/utils/transformers/transform-icons.js +164 -164
- package/dist/utils/transformers/transform-menu.d.ts +2 -2
- package/dist/utils/transformers/transform-menu.js +39 -39
- package/dist/utils/transformers/transform-render.d.ts +2 -2
- package/dist/utils/transformers/transform-render.js +97 -97
- package/dist/utils/transformers/types.d.ts +14 -14
- package/dist/utils/transformers/types.js +1 -1
- package/package.json +69 -69
- package/dist/__tests__/contracts/registry.test.d.ts +0 -1
- package/dist/__tests__/contracts/registry.test.js +0 -42
- package/dist/__tests__/contracts/registry.test.js.map +0 -1
- package/dist/__tests__/e2e/cli.test.d.ts +0 -1
- package/dist/__tests__/e2e/cli.test.js +0 -67
- package/dist/__tests__/e2e/cli.test.js.map +0 -1
- package/dist/__tests__/helpers/fs.d.ts +0 -5
- package/dist/__tests__/helpers/fs.js +0 -26
- package/dist/__tests__/helpers/fs.js.map +0 -1
- package/dist/__tests__/integration/commands.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/commands.integration.test.js +0 -184
- package/dist/__tests__/integration/commands.integration.test.js.map +0 -1
- package/dist/commands/__tests__/add-composite.test.d.ts +0 -2
- package/dist/commands/__tests__/add-composite.test.js +0 -171
- package/dist/commands/__tests__/add-composite.test.js.map +0 -1
- package/dist/commands/__tests__/add-entry.mocks.d.ts +0 -23
- package/dist/commands/__tests__/add-entry.mocks.js +0 -64
- package/dist/commands/__tests__/add-entry.mocks.js.map +0 -1
- package/dist/commands/__tests__/add-section.test.d.ts +0 -2
- package/dist/commands/__tests__/add-section.test.js +0 -191
- package/dist/commands/__tests__/add-section.test.js.map +0 -1
- package/dist/commands/__tests__/add-wrapper.test.d.ts +0 -2
- package/dist/commands/__tests__/add-wrapper.test.js +0 -171
- package/dist/commands/__tests__/add-wrapper.test.js.map +0 -1
- package/dist/commands/__tests__/cli-mocks.d.ts +0 -1
- package/dist/commands/__tests__/cli-mocks.js +0 -24
- package/dist/commands/__tests__/cli-mocks.js.map +0 -1
- package/dist/commands/__tests__/doctor.mocks.d.ts +0 -6
- package/dist/commands/__tests__/doctor.mocks.js +0 -20
- package/dist/commands/__tests__/doctor.mocks.js.map +0 -1
- package/dist/commands/__tests__/doctor.test.d.ts +0 -2
- package/dist/commands/__tests__/doctor.test.js +0 -80
- package/dist/commands/__tests__/doctor.test.js.map +0 -1
- package/dist/commands/__tests__/list.mocks.d.ts +0 -8
- package/dist/commands/__tests__/list.mocks.js +0 -20
- package/dist/commands/__tests__/list.mocks.js.map +0 -1
- package/dist/commands/__tests__/list.test.d.ts +0 -2
- package/dist/commands/__tests__/list.test.js +0 -60
- package/dist/commands/__tests__/list.test.js.map +0 -1
- package/dist/commands/__tests__/remove.mocks.d.ts +0 -9
- package/dist/commands/__tests__/remove.mocks.js +0 -26
- package/dist/commands/__tests__/remove.mocks.js.map +0 -1
- package/dist/commands/__tests__/remove.test.d.ts +0 -2
- package/dist/commands/__tests__/remove.test.js +0 -116
- package/dist/commands/__tests__/remove.test.js.map +0 -1
- package/dist/commands/add/__tests__/__mocks__/cli-mocks.d.ts +0 -1
- package/dist/commands/add/__tests__/__mocks__/cli-mocks.js +0 -21
- package/dist/commands/add/__tests__/__mocks__/cli-mocks.js.map +0 -1
- package/dist/commands/add/__tests__/add.mocks.d.ts +0 -19
- package/dist/commands/add/__tests__/add.mocks.js +0 -60
- package/dist/commands/add/__tests__/add.mocks.js.map +0 -1
- package/dist/commands/add/__tests__/add.test.d.ts +0 -2
- package/dist/commands/add/__tests__/add.test.js +0 -141
- package/dist/commands/add/__tests__/add.test.js.map +0 -1
- package/dist/commands/init/__tests__/init.mocks.d.ts +0 -24
- package/dist/commands/init/__tests__/init.mocks.js +0 -84
- package/dist/commands/init/__tests__/init.mocks.js.map +0 -1
- package/dist/commands/init/__tests__/init.test.d.ts +0 -2
- package/dist/commands/init/__tests__/init.test.js +0 -283
- package/dist/commands/init/__tests__/init.test.js.map +0 -1
- package/dist/commands/init/__tests__/tailwind.test.d.ts +0 -1
- package/dist/commands/init/__tests__/tailwind.test.js +0 -56
- package/dist/commands/init/__tests__/tailwind.test.js.map +0 -1
- package/dist/commands/init/__tests__/tsconfig.test.d.ts +0 -1
- package/dist/commands/init/__tests__/tsconfig.test.js +0 -108
- package/dist/commands/init/__tests__/tsconfig.test.js.map +0 -1
- package/dist/commands/init/__tests__/vite.test.d.ts +0 -1
- package/dist/commands/init/__tests__/vite.test.js +0 -66
- package/dist/commands/init/__tests__/vite.test.js.map +0 -1
- package/dist/commands/list-sections.d.ts +0 -2
- package/dist/commands/list-sections.js +0 -20
- package/dist/commands/list-sections.js.map +0 -1
- package/dist/commands/list-wrappers.d.ts +0 -2
- package/dist/commands/list-wrappers.js +0 -20
- package/dist/commands/list-wrappers.js.map +0 -1
- package/dist/commands/remove-section.d.ts +0 -2
- package/dist/commands/remove-section.js +0 -37
- package/dist/commands/remove-section.js.map +0 -1
- package/dist/commands/remove-wrapper.d.ts +0 -2
- package/dist/commands/remove-wrapper.js +0 -37
- package/dist/commands/remove-wrapper.js.map +0 -1
- package/dist/lib/__tests__/config.test.d.ts +0 -1
- package/dist/lib/__tests__/config.test.js +0 -49
- package/dist/lib/__tests__/config.test.js.map +0 -1
- package/dist/lib/__tests__/install.test.d.ts +0 -1
- package/dist/lib/__tests__/install.test.js +0 -149
- package/dist/lib/__tests__/install.test.js.map +0 -1
- package/dist/lib/__tests__/lockfile.test.d.ts +0 -1
- package/dist/lib/__tests__/lockfile.test.js +0 -89
- package/dist/lib/__tests__/lockfile.test.js.map +0 -1
- package/dist/lib/__tests__/paths.test.d.ts +0 -1
- package/dist/lib/__tests__/paths.test.js +0 -39
- package/dist/lib/__tests__/paths.test.js.map +0 -1
- package/dist/lib/__tests__/registry.test.d.ts +0 -1
- package/dist/lib/__tests__/registry.test.js +0 -76
- package/dist/lib/__tests__/registry.test.js.map +0 -1
|
@@ -1,98 +1,121 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { detect } from "@antfu/ni";
|
|
3
|
-
import { fileExists } from "../../lib/fs.js";
|
|
4
|
-
import { directoryExists } from "./filesystem.js";
|
|
5
|
-
import { collectDependencies, readPackageJson } from "./package-json.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
fileExists(path.join(cwd, "
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fileExists(path.join(cwd, "
|
|
22
|
-
fileExists(path.join(cwd, "
|
|
23
|
-
]),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { detect } from "@antfu/ni";
|
|
3
|
+
import { fileExists } from "../../lib/fs.js";
|
|
4
|
+
import { directoryExists } from "./filesystem.js";
|
|
5
|
+
import { collectDependencies, readPackageJson } from "./package-json.js";
|
|
6
|
+
/**
|
|
7
|
+
* Infer the project's shape (framework, TS, Tailwind, common directories) from `cwd`.
|
|
8
|
+
*
|
|
9
|
+
* The result drives init decisions like which config templates to write and where
|
|
10
|
+
* to place `globals.css`.
|
|
11
|
+
*/
|
|
12
|
+
export async function detectProject(cwd) {
|
|
13
|
+
const [hasPackageJson, nextConfigs, viteConfigs, hasTsConfig, postCssConfigs, hasSrcDir, hasAppDir, hasPagesDir, hasSrcAppDir, hasSrcPagesDir, componentsDirs,] = await Promise.all([
|
|
14
|
+
fileExists(path.join(cwd, "package.json")),
|
|
15
|
+
Promise.all([
|
|
16
|
+
fileExists(path.join(cwd, "next.config.js")),
|
|
17
|
+
fileExists(path.join(cwd, "next.config.mjs")),
|
|
18
|
+
fileExists(path.join(cwd, "next.config.ts")),
|
|
19
|
+
]),
|
|
20
|
+
Promise.all([
|
|
21
|
+
fileExists(path.join(cwd, "vite.config.js")),
|
|
22
|
+
fileExists(path.join(cwd, "vite.config.ts")),
|
|
23
|
+
]),
|
|
24
|
+
fileExists(path.join(cwd, "tsconfig.json")),
|
|
25
|
+
Promise.all([
|
|
26
|
+
fileExists(path.join(cwd, "postcss.config.js")),
|
|
27
|
+
fileExists(path.join(cwd, "postcss.config.mjs")),
|
|
28
|
+
fileExists(path.join(cwd, "postcss.config.ts")),
|
|
29
|
+
]),
|
|
30
|
+
directoryExists(path.join(cwd, "src")),
|
|
31
|
+
directoryExists(path.join(cwd, "app")),
|
|
32
|
+
directoryExists(path.join(cwd, "pages")),
|
|
33
|
+
directoryExists(path.join(cwd, "src", "app")),
|
|
34
|
+
directoryExists(path.join(cwd, "src", "pages")),
|
|
35
|
+
Promise.all([
|
|
36
|
+
directoryExists(path.join(cwd, "components")),
|
|
37
|
+
directoryExists(path.join(cwd, "src/components")),
|
|
38
|
+
]),
|
|
39
|
+
]);
|
|
40
|
+
if (!hasPackageJson) {
|
|
41
|
+
throw new Error("No package.json found. Please run this command in a valid project directory.");
|
|
42
|
+
}
|
|
43
|
+
const hasNextConfig = nextConfigs.some(Boolean);
|
|
44
|
+
const hasViteConfig = viteConfigs.some(Boolean);
|
|
45
|
+
// const hasPostCssConfig = postCssConfigs.some(Boolean)
|
|
46
|
+
const [hasRootComponentsDir, hasSrcComponentsDir] = componentsDirs;
|
|
47
|
+
const hasComponentsDir = hasRootComponentsDir || hasSrcComponentsDir;
|
|
48
|
+
const packageJson = await readPackageJson(cwd);
|
|
49
|
+
const dependencies = collectDependencies(packageJson);
|
|
50
|
+
let framework = "unknown";
|
|
51
|
+
if (dependencies.next || hasNextConfig) {
|
|
52
|
+
framework = "next";
|
|
53
|
+
}
|
|
54
|
+
else if (dependencies.vite || hasViteConfig) {
|
|
55
|
+
framework = "vite";
|
|
56
|
+
}
|
|
57
|
+
else if (dependencies.react) {
|
|
58
|
+
framework = "react";
|
|
59
|
+
}
|
|
60
|
+
const hasTailwind = Boolean(dependencies["@tailwindcss/postcss"] || dependencies["@tailwindcss/vite"]);
|
|
61
|
+
const usesSrcDir = framework === "next" ? hasSrcAppDir || hasSrcPagesDir : hasSrcDir;
|
|
62
|
+
const detectedPm = await detect({ cwd });
|
|
63
|
+
const packageManager = detectedPm ?? "npm";
|
|
64
|
+
return {
|
|
65
|
+
framework,
|
|
66
|
+
typescript: hasTsConfig,
|
|
67
|
+
tailwind: hasTailwind,
|
|
68
|
+
packageManager,
|
|
69
|
+
srcDir: usesSrcDir,
|
|
70
|
+
appDir: framework === "next" && (hasAppDir || hasSrcAppDir),
|
|
71
|
+
pagesDir: framework === "next" && (hasPagesDir || hasSrcPagesDir),
|
|
72
|
+
hasComponents: hasComponentsDir,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validate that the project is compatible with `trix-ui init`.
|
|
77
|
+
*
|
|
78
|
+
* Returns hard errors for missing requirements (React/ReactDOM) and softer
|
|
79
|
+
* warnings for common footguns (missing TS types, mixed Next.js routers).
|
|
80
|
+
*/
|
|
81
|
+
export async function validateProject(cwd, projectInfo) {
|
|
82
|
+
const errors = [];
|
|
83
|
+
const warnings = [];
|
|
84
|
+
const packageJson = await readPackageJson(cwd);
|
|
85
|
+
const dependencies = collectDependencies(packageJson);
|
|
86
|
+
if (!dependencies.react) {
|
|
87
|
+
const supportNote = projectInfo.framework === "unknown"
|
|
88
|
+
? "trix-ui init supports React-based projects only (React, Next.js, Vite (React))."
|
|
89
|
+
: "React is required for trix-ui init.";
|
|
90
|
+
errors.push(`Project does not meet requirements: missing dependency \"react\". ${supportNote}`);
|
|
91
|
+
}
|
|
92
|
+
if (dependencies.react && !dependencies["react-dom"]) {
|
|
93
|
+
errors.push("Project does not meet requirements: missing dependency \"react-dom\".");
|
|
94
|
+
}
|
|
95
|
+
if (projectInfo.typescript && !dependencies["@types/react"]) {
|
|
96
|
+
warnings.push("@types/react is recommended for TypeScript projects.");
|
|
97
|
+
}
|
|
98
|
+
if (!projectInfo.typescript) {
|
|
99
|
+
warnings.push("TypeScript is not detected. TypeScript is recommended for better type safety.");
|
|
100
|
+
}
|
|
101
|
+
if (projectInfo.framework === "next") {
|
|
102
|
+
if (projectInfo.pagesDir && !projectInfo.appDir) {
|
|
103
|
+
warnings.push("Next.js Pages Router detected. App Router is recommended for new projects.");
|
|
104
|
+
}
|
|
105
|
+
else if (projectInfo.appDir && projectInfo.pagesDir) {
|
|
106
|
+
warnings.push("Next.js App + Pages routers detected. Ensure globals and routing are aligned for both.");
|
|
107
|
+
}
|
|
108
|
+
else if (!projectInfo.appDir && !projectInfo.pagesDir) {
|
|
109
|
+
warnings.push("Next.js detected without app/ or pages/ directory. Initialization may be incomplete.");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (projectInfo.framework === "unknown") {
|
|
113
|
+
warnings.push("Could not detect framework. Manual configuration may be required.");
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
valid: errors.length === 0,
|
|
117
|
+
errors,
|
|
118
|
+
warnings,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
98
121
|
//# sourceMappingURL=project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/commands/init/project.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGxE,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW;IAC7C,MAAM,CACJ,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,cAAc,EACd,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACf,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAE1C,OAAO,CAAC,GAAG,CAAC;YACV,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;YAC5C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;YAC7C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;SAC7C,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC;YACV,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,G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vE,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QAC5B,QAAQ,CAAC,IAAI,CACX,+EAA+E,CAChF,CAAA;IACH,CAAC;IAED,IAAI,WAAW,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QACrC,IAAI,WAAW,CAAC,QAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CACX,4EAA4E,CAC7E,CAAA;QACH,CAAC;aAAM,IAAI,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;YACtD,QAAQ,CAAC,IAAI,CACX,wFAAwF,CACzF,CAAA;QACH,CAAC;aAAM,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YACxD,QAAQ,CAAC,IAAI,CACX,sFAAsF,CACvF,CAAA;QACH,CAAC;IACH,CAAC;IAED,IAAI,WAAW,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACxC,QAAQ,CAAC,IAAI,CACX,mEAAmE,CACpE,CAAA;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;QACN,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import type { InitConfig, InitOptions, ProjectInfo } from "./types.js";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { InitConfig, InitOptions, ProjectInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ensure Tailwind + PostCSS config files exist for the target project.
|
|
4
|
+
*
|
|
5
|
+
* Existing configs are respected unless `--force` is used.
|
|
6
|
+
*/
|
|
7
|
+
export declare function setupTailwind(cwd: string, projectInfo: ProjectInfo, options: InitOptions): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Write the global CSS variables file referenced by the init config.
|
|
10
|
+
*
|
|
11
|
+
* If the file already contains common variable names and `--force` isn't set,
|
|
12
|
+
* we leave it untouched.
|
|
13
|
+
*/
|
|
14
|
+
export declare function setupGlobalStyles(cwd: string, config: InitConfig, options: InitOptions): Promise<void>;
|
|
@@ -1,35 +1,143 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { ensureDir, fileExists, readFile, writeFileSafe } from "../../lib/fs.js";
|
|
3
|
-
import { BASE_CSS_VARS } from "./constants.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { ensureDir, fileExists, readFile, writeFile, writeFileSafe } from "../../lib/fs.js";
|
|
3
|
+
import { BASE_CSS_VARS, TAILWIND_CONTENT_PATHS } from "./constants.js";
|
|
4
|
+
import { readPackageJson } from "./package-json.js";
|
|
5
|
+
const TAILWIND_CONFIG_FILES = [
|
|
6
|
+
"tailwind.config.ts",
|
|
7
|
+
"tailwind.config.js",
|
|
8
|
+
"tailwind.config.cjs",
|
|
9
|
+
"tailwind.config.mjs"
|
|
10
|
+
];
|
|
11
|
+
const POSTCSS_CONFIG_FILES = [
|
|
12
|
+
"postcss.config.js",
|
|
13
|
+
"postcss.config.cjs",
|
|
14
|
+
"postcss.config.mjs",
|
|
15
|
+
"postcss.config.ts"
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Ensure Tailwind + PostCSS config files exist for the target project.
|
|
19
|
+
*
|
|
20
|
+
* Existing configs are respected unless `--force` is used.
|
|
21
|
+
*/
|
|
22
|
+
export async function setupTailwind(cwd, projectInfo, options) {
|
|
23
|
+
const moduleFormat = await resolveModuleFormat(cwd);
|
|
24
|
+
await ensureTailwindConfig(cwd, projectInfo, moduleFormat, options);
|
|
25
|
+
await ensurePostcssConfig(cwd, moduleFormat, options);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Write the global CSS variables file referenced by the init config.
|
|
29
|
+
*
|
|
30
|
+
* If the file already contains common variable names and `--force` isn't set,
|
|
31
|
+
* we leave it untouched.
|
|
32
|
+
*/
|
|
33
|
+
export async function setupGlobalStyles(cwd, config, options) {
|
|
34
|
+
const stylesPath = path.resolve(cwd, config.paths.styles);
|
|
35
|
+
const existingStyles = (await fileExists(stylesPath))
|
|
36
|
+
? await readFile(stylesPath)
|
|
37
|
+
: "";
|
|
38
|
+
const hasVars = existingStyles.includes("--background") ||
|
|
39
|
+
existingStyles.includes("--foreground");
|
|
40
|
+
let finalStyles = BASE_CSS_VARS;
|
|
41
|
+
if (existingStyles && !hasVars) {
|
|
42
|
+
finalStyles = `${BASE_CSS_VARS}\n\n/* Existing styles */\n${existingStyles}`;
|
|
43
|
+
}
|
|
44
|
+
else if (hasVars && !options.force) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
await ensureDir(path.dirname(stylesPath));
|
|
48
|
+
await writeFile(stylesPath, finalStyles);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Decide whether config files should be written as ESM (`export default`) or CJS.
|
|
52
|
+
*
|
|
53
|
+
* The check is based on `package.json#type` and falls back to CommonJS.
|
|
54
|
+
*/
|
|
55
|
+
async function resolveModuleFormat(cwd) {
|
|
56
|
+
try {
|
|
57
|
+
const pkg = await readPackageJson(cwd);
|
|
58
|
+
return pkg.type === "module" ? "module" : "commonjs";
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return "commonjs";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Return the first Tailwind/PostCSS config file that already exists in `cwd`.
|
|
66
|
+
*/
|
|
67
|
+
async function findExistingConfig(cwd, candidates) {
|
|
68
|
+
for (const file of candidates) {
|
|
69
|
+
const fullPath = path.join(cwd, file);
|
|
70
|
+
if (await fileExists(fullPath)) {
|
|
71
|
+
return fullPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create or overwrite `tailwind.config.*` as needed for the current project.
|
|
78
|
+
*/
|
|
79
|
+
async function ensureTailwindConfig(cwd, projectInfo, moduleFormat, options) {
|
|
80
|
+
const existingPath = await findExistingConfig(cwd, TAILWIND_CONFIG_FILES);
|
|
81
|
+
if (existingPath && !options.force) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const configPath = existingPath ??
|
|
85
|
+
path.join(cwd, projectInfo.typescript
|
|
86
|
+
? "tailwind.config.ts"
|
|
87
|
+
: moduleFormat === "module"
|
|
88
|
+
? "tailwind.config.mjs"
|
|
89
|
+
: "tailwind.config.js");
|
|
90
|
+
const content = buildTailwindConfig(projectInfo, moduleFormat);
|
|
91
|
+
await writeFileSafe(configPath, content, Boolean(options.force));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create or overwrite `postcss.config.*` as needed for the current project.
|
|
95
|
+
*/
|
|
96
|
+
async function ensurePostcssConfig(cwd, moduleFormat, options) {
|
|
97
|
+
const existingPath = await findExistingConfig(cwd, POSTCSS_CONFIG_FILES);
|
|
98
|
+
if (existingPath && !options.force) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const configPath = existingPath ??
|
|
102
|
+
path.join(cwd, moduleFormat === "module" ? "postcss.config.mjs" : "postcss.config.js");
|
|
103
|
+
const content = buildPostcssConfig(moduleFormat);
|
|
104
|
+
await writeFileSafe(configPath, content, Boolean(options.force));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Generate the Tailwind config file content.
|
|
108
|
+
*
|
|
109
|
+
* Uses the project's framework to choose sensible `content` globs.
|
|
110
|
+
*/
|
|
111
|
+
function buildTailwindConfig(projectInfo, moduleFormat) {
|
|
112
|
+
const contentPaths = TAILWIND_CONTENT_PATHS[projectInfo.framework];
|
|
113
|
+
const contentLiteral = JSON.stringify(contentPaths, null, 2);
|
|
114
|
+
if (projectInfo.typescript) {
|
|
115
|
+
return `import type { Config } from "tailwindcss"\n\nconst config: Config = {\n content: ${contentLiteral},\n theme: {\n extend: {}\n },\n plugins: []\n}\n\nexport default config\n`;
|
|
116
|
+
}
|
|
117
|
+
const configObject = `{
|
|
118
|
+
content: ${contentLiteral},
|
|
119
|
+
theme: {
|
|
120
|
+
extend: {}
|
|
11
121
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
await writeFileSafe(stylesPath, finalStyles, Boolean(options.force));
|
|
34
|
-
}
|
|
122
|
+
plugins: []
|
|
123
|
+
}`;
|
|
124
|
+
if (moduleFormat === "module") {
|
|
125
|
+
return `const config = ${configObject}\n\nexport default config\n`;
|
|
126
|
+
}
|
|
127
|
+
return `module.exports = ${configObject}\n`;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Generate the PostCSS config file content for Tailwind.
|
|
131
|
+
*/
|
|
132
|
+
function buildPostcssConfig(moduleFormat) {
|
|
133
|
+
const configObject = `{
|
|
134
|
+
plugins: {
|
|
135
|
+
"@tailwindcss/postcss": {},
|
|
136
|
+
},
|
|
137
|
+
}`;
|
|
138
|
+
if (moduleFormat === "module") {
|
|
139
|
+
return `const config = ${configObject}\n\nexport default config\n`;
|
|
140
|
+
}
|
|
141
|
+
return `module.exports = ${configObject}\n`;
|
|
142
|
+
}
|
|
35
143
|
//# sourceMappingURL=tailwind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../../src/commands/init/tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO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AAI,EAAE,CAAC,CAAC,CAAA;IAE5D,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;QAC3B,OAAO,qFAAqF,cAAc,kFAAkF,CAAA;IAC9L,CAAC;IAED,MAAM,YAAY,GAAG;aACV,cAAc;;;;;EAKzB,CAAA;IAEA,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,kBAAkB,YAAY,6BAA6B,CAAA;IACpE,CAAC;IAED,OAAO,oBAAoB,YAAY,IAAI,CAAA;AAC7C,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,YAA0B;IACpD,MAAM,YAAY,GAAG;;;;EAIrB,CAAA;IAEA,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,kBAAkB,YAAY,6BAA6B,CAAA;IACpE,CAAC;IAED,OAAO,oBAAoB,YAAY,IAAI,CAAA;AAC7C,CAAC"}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import type { InitConfig, ProjectInfo } from "./types.js";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { InitConfig, ProjectInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Copy init templates into the target project.
|
|
4
|
+
*
|
|
5
|
+
* Today this is intentionally narrow (a small utilities file), but it keeps the
|
|
6
|
+
* path/extension logic in one place as the template set grows.
|
|
7
|
+
*/
|
|
8
|
+
export declare function copyTemplateFiles(cwd: string, config: InitConfig, projectInfo: ProjectInfo, force: boolean): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Create (or overwrite) a simple `components/ui` barrel file.
|
|
11
|
+
*
|
|
12
|
+
* The barrel is optional and controlled by init options; this helper just writes
|
|
13
|
+
* the file once the decision has been made.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createBarrelFile(cwd: string, config: InitConfig, projectInfo: ProjectInfo): Promise<void>;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { copyFileSafe, writeFileSafe } from "../../lib/fs.js";
|
|
3
|
-
import { getTemplatePath } from "../../lib/paths.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { copyFileSafe, writeFileSafe } from "../../lib/fs.js";
|
|
3
|
+
import { getTemplatePath } from "../../lib/paths.js";
|
|
4
|
+
/**
|
|
5
|
+
* Copy init templates into the target project.
|
|
6
|
+
*
|
|
7
|
+
* Today this is intentionally narrow (a small utilities file), but it keeps the
|
|
8
|
+
* path/extension logic in one place as the template set grows.
|
|
9
|
+
*/
|
|
10
|
+
export async function copyTemplateFiles(cwd, config, projectInfo, force) {
|
|
11
|
+
const ext = projectInfo.typescript ? "ts" : "js";
|
|
12
|
+
await copyFileSafe(getTemplatePath(`lib/utils.${ext}`), path.resolve(cwd, config.paths.utils), force);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create (or overwrite) a simple `components/ui` barrel file.
|
|
16
|
+
*
|
|
17
|
+
* The barrel is optional and controlled by init options; this helper just writes
|
|
18
|
+
* the file once the decision has been made.
|
|
19
|
+
*/
|
|
20
|
+
export async function createBarrelFile(cwd, config, projectInfo) {
|
|
21
|
+
const ext = projectInfo.typescript ? "ts" : "js";
|
|
22
|
+
const barrelPath = path.resolve(cwd, config.paths.components, `index.${ext}`);
|
|
23
|
+
const content = `// Auto-generated barrel file
|
|
24
|
+
// This file exports all components from this directory
|
|
25
|
+
`;
|
|
26
|
+
await writeFileSafe(barrelPath, content, true);
|
|
27
|
+
}
|
|
16
28
|
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/commands/init/templates.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AA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AM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAEhD,MAAM,YAAY,CAChB,eAAe,CAAC,aAAa,GAAG,EAAE,CAAC,EACnC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EACrC,KAAK,CACN,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAW,EACX,MAAkB,EAClB,WAAwB;IAExB,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,EAAE,CAAC,CAAA;IAC7E,MAAM,OAAO,GAAG;;CAEjB,CAAA;IACC,MAAM,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
import type { ProjectInfo } from "./types.js";
|
|
2
|
-
|
|
1
|
+
import type { ProjectInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validate TypeScript path aliases across the project's relevant tsconfig files.
|
|
4
|
+
*
|
|
5
|
+
* For Vite projects, we validate `tsconfig.json` plus `tsconfig.app.json` (when present),
|
|
6
|
+
* matching the common Vite/shadcn split-config setup.
|
|
7
|
+
*
|
|
8
|
+
* For other projects using TS references, we validate each referenced app config.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setupTypeScriptPaths(cwd: string, projectInfo: ProjectInfo): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate `jsconfig.json` path aliases for non-TypeScript projects.
|
|
13
|
+
*/
|
|
14
|
+
export declare function setupJavaScriptPaths(cwd: string, projectInfo: ProjectInfo): Promise<void>;
|