trix-ui 0.2.8 → 0.2.9
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/__tests__/contracts/registry.test.d.ts +1 -0
- package/dist/__tests__/contracts/registry.test.js +42 -0
- package/dist/__tests__/contracts/registry.test.js.map +1 -0
- package/dist/__tests__/e2e/cli.test.d.ts +1 -0
- package/dist/__tests__/e2e/cli.test.js +67 -0
- package/dist/__tests__/e2e/cli.test.js.map +1 -0
- package/dist/__tests__/helpers/fs.d.ts +5 -0
- package/dist/__tests__/helpers/fs.js +26 -0
- package/dist/__tests__/helpers/fs.js.map +1 -0
- package/dist/__tests__/integration/commands.integration.test.d.ts +1 -0
- package/dist/__tests__/integration/commands.integration.test.js +184 -0
- package/dist/__tests__/integration/commands.integration.test.js.map +1 -0
- package/dist/commands/__tests__/add-composite.test.d.ts +2 -0
- package/dist/commands/__tests__/add-composite.test.js +171 -0
- package/dist/commands/__tests__/add-composite.test.js.map +1 -0
- package/dist/commands/__tests__/add-entry.mocks.d.ts +23 -0
- package/dist/commands/__tests__/add-entry.mocks.js +64 -0
- package/dist/commands/__tests__/add-entry.mocks.js.map +1 -0
- package/dist/commands/__tests__/add-section.test.d.ts +2 -0
- package/dist/commands/__tests__/add-section.test.js +191 -0
- package/dist/commands/__tests__/add-section.test.js.map +1 -0
- package/dist/commands/__tests__/add-wrapper.test.d.ts +2 -0
- package/dist/commands/__tests__/add-wrapper.test.js +171 -0
- package/dist/commands/__tests__/add-wrapper.test.js.map +1 -0
- package/dist/commands/__tests__/cli-mocks.d.ts +1 -0
- package/dist/commands/__tests__/cli-mocks.js +24 -0
- package/dist/commands/__tests__/cli-mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.mocks.d.ts +6 -0
- package/dist/commands/__tests__/doctor.mocks.js +20 -0
- package/dist/commands/__tests__/doctor.mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.test.d.ts +2 -0
- package/dist/commands/__tests__/doctor.test.js +80 -0
- package/dist/commands/__tests__/doctor.test.js.map +1 -0
- package/dist/commands/__tests__/list.mocks.d.ts +8 -0
- package/dist/commands/__tests__/list.mocks.js +20 -0
- package/dist/commands/__tests__/list.mocks.js.map +1 -0
- package/dist/commands/__tests__/list.test.d.ts +2 -0
- package/dist/commands/__tests__/list.test.js +60 -0
- package/dist/commands/__tests__/list.test.js.map +1 -0
- package/dist/commands/__tests__/remove.mocks.d.ts +9 -0
- package/dist/commands/__tests__/remove.mocks.js +26 -0
- package/dist/commands/__tests__/remove.mocks.js.map +1 -0
- package/dist/commands/__tests__/remove.test.d.ts +2 -0
- package/dist/commands/__tests__/remove.test.js +116 -0
- package/dist/commands/__tests__/remove.test.js.map +1 -0
- package/dist/commands/add/__tests__/add.mocks.d.ts +19 -19
- package/dist/commands/add/__tests__/add.mocks.js +59 -59
- package/dist/commands/add/__tests__/add.test.d.ts +2 -2
- package/dist/commands/add/__tests__/add.test.js +140 -140
- 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 +202 -202
- 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 +201 -201
- package/dist/commands/add-section.d.ts +2 -2
- package/dist/commands/add-section.js +201 -201
- package/dist/commands/add-wrapper.d.ts +2 -2
- package/dist/commands/add-wrapper.js +201 -201
- 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/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +67 -67
- package/dist/commands/init/__tests__/init.mocks.d.ts +24 -0
- package/dist/commands/init/__tests__/init.mocks.js +84 -0
- package/dist/commands/init/__tests__/init.mocks.js.map +1 -0
- package/dist/commands/init/__tests__/init.test.d.ts +2 -0
- package/dist/commands/init/__tests__/init.test.js +283 -0
- package/dist/commands/init/__tests__/init.test.js.map +1 -0
- package/dist/commands/init/__tests__/tailwind.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tailwind.test.js +56 -0
- package/dist/commands/init/__tests__/tailwind.test.js.map +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.js +108 -0
- package/dist/commands/init/__tests__/tsconfig.test.js.map +1 -0
- package/dist/commands/init/__tests__/vite.test.d.ts +1 -0
- package/dist/commands/init/__tests__/vite.test.js +66 -0
- package/dist/commands/init/__tests__/vite.test.js.map +1 -0
- package/dist/commands/init/command.d.ts +2 -2
- package/dist/commands/init/command.js +114 -114
- package/dist/commands/init/config.d.ts +2 -2
- package/dist/commands/init/config.js +25 -25
- package/dist/commands/init/constants.d.ts +3 -3
- package/dist/commands/init/constants.js +105 -105
- package/dist/commands/init/dependencies.d.ts +5 -5
- package/dist/commands/init/dependencies.js +52 -52
- package/dist/commands/init/filesystem.d.ts +1 -1
- package/dist/commands/init/filesystem.js +10 -10
- 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 +6 -6
- package/dist/commands/init/package-json.js +18 -18
- package/dist/commands/init/project-files.d.ts +8 -0
- package/dist/commands/init/project-files.js +37 -0
- package/dist/commands/init/project-files.js.map +1 -0
- package/dist/commands/init/project.d.ts +3 -3
- package/dist/commands/init/project.js +97 -97
- package/dist/commands/init/style-imports.d.ts +9 -0
- package/dist/commands/init/style-imports.js +218 -0
- package/dist/commands/init/style-imports.js.map +1 -0
- package/dist/commands/init/tailwind.d.ts +3 -3
- package/dist/commands/init/tailwind.js +34 -34
- package/dist/commands/init/templates.d.ts +3 -3
- package/dist/commands/init/templates.js +15 -15
- package/dist/commands/init/tsconfig.d.ts +2 -2
- package/dist/commands/init/tsconfig.js +273 -273
- package/dist/commands/init/types.d.ts +33 -33
- package/dist/commands/init/types.js +1 -1
- package/dist/commands/init/ui.d.ts +3 -3
- package/dist/commands/init/ui.js +33 -33
- package/dist/commands/init/vite.d.ts +23 -0
- package/dist/commands/init/vite.js +347 -0
- package/dist/commands/init/vite.js.map +1 -0
- 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 +62 -62
- package/dist/commands/remove.d.ts +2 -2
- package/dist/commands/remove.js +93 -93
- 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 +2 -2
- package/dist/index.js +30 -30
- package/dist/lib/__tests__/config.test.d.ts +1 -0
- package/dist/lib/__tests__/config.test.js +49 -0
- package/dist/lib/__tests__/config.test.js.map +1 -0
- package/dist/lib/__tests__/install.test.d.ts +1 -0
- package/dist/lib/__tests__/install.test.js +149 -0
- package/dist/lib/__tests__/install.test.js.map +1 -0
- package/dist/lib/__tests__/lockfile.test.d.ts +1 -0
- package/dist/lib/__tests__/lockfile.test.js +89 -0
- package/dist/lib/__tests__/lockfile.test.js.map +1 -0
- package/dist/lib/__tests__/paths.test.d.ts +1 -0
- package/dist/lib/__tests__/paths.test.js +39 -0
- package/dist/lib/__tests__/paths.test.js.map +1 -0
- package/dist/lib/__tests__/registry.test.d.ts +1 -0
- package/dist/lib/__tests__/registry.test.js +76 -0
- package/dist/lib/__tests__/registry.test.js.map +1 -0
- package/dist/lib/config.d.ts +45 -45
- package/dist/lib/config.js +97 -97
- package/dist/lib/fs.d.ts +76 -76
- package/dist/lib/fs.js +302 -302
- 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 +55 -55
- package/dist/lib/lockfile.d.ts +63 -63
- package/dist/lib/lockfile.js +173 -173
- package/dist/lib/logger.d.ts +8 -8
- package/dist/lib/logger.js +41 -41
- package/dist/lib/paths.d.ts +14 -14
- package/dist/lib/paths.js +31 -31
- 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 +238 -238
- 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 +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
export async function directoryExists(dir) {
|
|
3
|
-
try {
|
|
4
|
-
const stat = await fs.stat(dir);
|
|
5
|
-
return stat.isDirectory();
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
export async function directoryExists(dir) {
|
|
3
|
+
try {
|
|
4
|
+
const stat = await fs.stat(dir);
|
|
5
|
+
return stat.isDirectory();
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
11
|
//# sourceMappingURL=filesystem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=lockfile.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type PackageJson = {
|
|
2
|
-
dependencies?: Record<string, string>;
|
|
3
|
-
devDependencies?: Record<string, string>;
|
|
4
|
-
};
|
|
5
|
-
export declare function readPackageJson(cwd: string): Promise<PackageJson>;
|
|
6
|
-
export declare function collectDependencies(packageJson: PackageJson): Record<string, string>;
|
|
1
|
+
export type PackageJson = {
|
|
2
|
+
dependencies?: Record<string, string>;
|
|
3
|
+
devDependencies?: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
export declare function readPackageJson(cwd: string): Promise<PackageJson>;
|
|
6
|
+
export declare function collectDependencies(packageJson: PackageJson): Record<string, string>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { readFile } from "../../lib/fs.js";
|
|
3
|
-
export async function readPackageJson(cwd) {
|
|
4
|
-
const packageJsonPath = path.join(cwd, "package.json");
|
|
5
|
-
const raw = await readFile(packageJsonPath);
|
|
6
|
-
try {
|
|
7
|
-
return JSON.parse(raw);
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
throw new Error(`Failed to parse package.json: ${error.message}`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function collectDependencies(packageJson) {
|
|
14
|
-
return {
|
|
15
|
-
...packageJson.dependencies,
|
|
16
|
-
...packageJson.devDependencies
|
|
17
|
-
};
|
|
18
|
-
}
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { readFile } from "../../lib/fs.js";
|
|
3
|
+
export async function readPackageJson(cwd) {
|
|
4
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
5
|
+
const raw = await readFile(packageJsonPath);
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(raw);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
throw new Error(`Failed to parse package.json: ${error.message}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function collectDependencies(packageJson) {
|
|
14
|
+
return {
|
|
15
|
+
...packageJson.dependencies,
|
|
16
|
+
...packageJson.devDependencies
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
19
|
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InitConfig, InitOptions, ProjectInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ensure the expected `trix-ui` project structure exists on disk.
|
|
4
|
+
*
|
|
5
|
+
* Init is responsible for creating the directories and baseline files that other
|
|
6
|
+
* commands (notably `ui doctor` and `ui add`) assume are present.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureInitProjectFiles(cwd: string, config: InitConfig, projectInfo: ProjectInfo, options: InitOptions): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { copyFileSafe, ensureDir, fileExists, writeFileSafe } from "../../lib/fs.js";
|
|
3
|
+
import { getTemplatePath } from "../../lib/paths.js";
|
|
4
|
+
/**
|
|
5
|
+
* Ensure the expected `trix-ui` project structure exists on disk.
|
|
6
|
+
*
|
|
7
|
+
* Init is responsible for creating the directories and baseline files that other
|
|
8
|
+
* commands (notably `ui doctor` and `ui add`) assume are present.
|
|
9
|
+
*/
|
|
10
|
+
export async function ensureInitProjectFiles(cwd, config, projectInfo, options) {
|
|
11
|
+
const force = Boolean(options.force);
|
|
12
|
+
const directories = [
|
|
13
|
+
path.resolve(cwd, config.paths.components),
|
|
14
|
+
path.resolve(cwd, config.paths.sections),
|
|
15
|
+
path.resolve(cwd, config.paths.wrappers),
|
|
16
|
+
path.resolve(cwd, config.paths.composites),
|
|
17
|
+
];
|
|
18
|
+
await Promise.all(directories.map((dir) => ensureDir(dir)));
|
|
19
|
+
const utilsPath = path.resolve(cwd, config.paths.utils);
|
|
20
|
+
if (force || !(await fileExists(utilsPath))) {
|
|
21
|
+
const ext = projectInfo.typescript ? "ts" : "js";
|
|
22
|
+
await copyFileSafe(getTemplatePath(`lib/utils.${ext}`), utilsPath, force);
|
|
23
|
+
}
|
|
24
|
+
if (!config.barrel) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const ext = projectInfo.typescript ? "ts" : "js";
|
|
28
|
+
const barrelPath = path.resolve(cwd, config.paths.components, `index.${ext}`);
|
|
29
|
+
if (!force && (await fileExists(barrelPath))) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const content = `// Auto-generated barrel file
|
|
33
|
+
// This file exports all components from this directory
|
|
34
|
+
`;
|
|
35
|
+
await writeFileSafe(barrelPath, content, force);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=project-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-files.js","sourceRoot":"","sources":["../../../src/commands/init/project-files.ts"],"names":[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CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,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,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QAC7C,OAAM;IACR,CAAC;IAED,MAAM,OAAO,GAAG;;CAEjB,CAAA;IACC,MAAM,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ProjectInfo, ValidationResult } from "./types.js";
|
|
2
|
-
export declare function detectProject(cwd: string): Promise<ProjectInfo>;
|
|
3
|
-
export declare function validateProject(cwd: string, projectInfo: ProjectInfo): Promise<ValidationResult>;
|
|
1
|
+
import type { ProjectInfo, ValidationResult } from "./types.js";
|
|
2
|
+
export declare function detectProject(cwd: string): Promise<ProjectInfo>;
|
|
3
|
+
export declare function validateProject(cwd: string, projectInfo: ProjectInfo): Promise<ValidationResult>;
|
|
@@ -1,98 +1,98 @@
|
|
|
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
|
-
export async function detectProject(cwd) {
|
|
7
|
-
const [hasPackageJson, nextConfigs, viteConfigs, hasTsConfig, postCssConfigs, hasSrcDir, hasAppDir, hasPagesDir, componentsDirs,] = await Promise.all([
|
|
8
|
-
fileExists(path.join(cwd, "package.json")),
|
|
9
|
-
Promise.all([
|
|
10
|
-
fileExists(path.join(cwd, "next.config.js")),
|
|
11
|
-
fileExists(path.join(cwd, "next.config.mjs")),
|
|
12
|
-
fileExists(path.join(cwd, "next.config.ts")),
|
|
13
|
-
]),
|
|
14
|
-
Promise.all([
|
|
15
|
-
fileExists(path.join(cwd, "vite.config.js")),
|
|
16
|
-
fileExists(path.join(cwd, "vite.config.ts")),
|
|
17
|
-
]),
|
|
18
|
-
fileExists(path.join(cwd, "tsconfig.json")),
|
|
19
|
-
Promise.all([
|
|
20
|
-
fileExists(path.join(cwd, "postcss.config.js")),
|
|
21
|
-
fileExists(path.join(cwd, "postcss.config.mjs")),
|
|
22
|
-
fileExists(path.join(cwd, "postcss.config.ts")),
|
|
23
|
-
]),
|
|
24
|
-
directoryExists(path.join(cwd, "src")),
|
|
25
|
-
directoryExists(path.join(cwd, "app")),
|
|
26
|
-
directoryExists(path.join(cwd, "pages")),
|
|
27
|
-
Promise.all([
|
|
28
|
-
directoryExists(path.join(cwd, "components")),
|
|
29
|
-
directoryExists(path.join(cwd, "src/components")),
|
|
30
|
-
]),
|
|
31
|
-
]);
|
|
32
|
-
if (!hasPackageJson) {
|
|
33
|
-
throw new Error("No package.json found. Please run this command in a valid project directory.");
|
|
34
|
-
}
|
|
35
|
-
const hasNextConfig = nextConfigs.some(Boolean);
|
|
36
|
-
const hasViteConfig = viteConfigs.some(Boolean);
|
|
37
|
-
// const hasPostCssConfig = postCssConfigs.some(Boolean)
|
|
38
|
-
const hasComponentsDir = componentsDirs.some(Boolean);
|
|
39
|
-
const packageJson = await readPackageJson(cwd);
|
|
40
|
-
const dependencies = collectDependencies(packageJson);
|
|
41
|
-
let framework = "unknown";
|
|
42
|
-
if (dependencies.next || hasNextConfig) {
|
|
43
|
-
framework = "next";
|
|
44
|
-
}
|
|
45
|
-
else if (dependencies.vite || hasViteConfig) {
|
|
46
|
-
framework = "vite";
|
|
47
|
-
}
|
|
48
|
-
else if (dependencies.react) {
|
|
49
|
-
framework = "react";
|
|
50
|
-
}
|
|
51
|
-
const hasTailwind = Boolean(dependencies.tailwindcss ||
|
|
52
|
-
dependencies["@tailwindcss/postcss"] ||
|
|
53
|
-
dependencies["@tailwindcss/vite"]);
|
|
54
|
-
const detectedPm = await detect({ cwd });
|
|
55
|
-
const packageManager = detectedPm ?? "npm";
|
|
56
|
-
return {
|
|
57
|
-
framework,
|
|
58
|
-
typescript: hasTsConfig,
|
|
59
|
-
tailwind: hasTailwind,
|
|
60
|
-
packageManager,
|
|
61
|
-
srcDir: hasSrcDir,
|
|
62
|
-
appDir: framework === "next" && hasAppDir && !hasPagesDir,
|
|
63
|
-
hasComponents: hasComponentsDir,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
export async function validateProject(cwd, projectInfo) {
|
|
67
|
-
const errors = [];
|
|
68
|
-
const warnings = [];
|
|
69
|
-
const packageJson = await readPackageJson(cwd);
|
|
70
|
-
const dependencies = collectDependencies(packageJson);
|
|
71
|
-
if (!dependencies.react) {
|
|
72
|
-
const supportNote = projectInfo.framework === "unknown"
|
|
73
|
-
? "trix-ui init supports React-based projects only (React, Next.js, Vite (React))."
|
|
74
|
-
: "React is required for trix-ui init.";
|
|
75
|
-
errors.push(`Project does not meet requirements: missing dependency \"react\". ${supportNote}`);
|
|
76
|
-
}
|
|
77
|
-
if (dependencies.react && !dependencies["react-dom"]) {
|
|
78
|
-
errors.push("Project does not meet requirements: missing dependency \"react-dom\".");
|
|
79
|
-
}
|
|
80
|
-
if (projectInfo.typescript && !dependencies["@types/react"]) {
|
|
81
|
-
warnings.push("@types/react is recommended for TypeScript projects.");
|
|
82
|
-
}
|
|
83
|
-
if (!projectInfo.typescript) {
|
|
84
|
-
warnings.push("TypeScript is not detected. TypeScript is recommended for better type safety.");
|
|
85
|
-
}
|
|
86
|
-
if (projectInfo.framework === "next" && !projectInfo.appDir) {
|
|
87
|
-
warnings.push("Next.js Pages Router detected. App Router is recommended for new projects.");
|
|
88
|
-
}
|
|
89
|
-
if (projectInfo.framework === "unknown") {
|
|
90
|
-
warnings.push("Could not detect framework. Manual configuration may be required.");
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
valid: errors.length === 0,
|
|
94
|
-
errors,
|
|
95
|
-
warnings,
|
|
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
|
+
export async function detectProject(cwd) {
|
|
7
|
+
const [hasPackageJson, nextConfigs, viteConfigs, hasTsConfig, postCssConfigs, hasSrcDir, hasAppDir, hasPagesDir, componentsDirs,] = await Promise.all([
|
|
8
|
+
fileExists(path.join(cwd, "package.json")),
|
|
9
|
+
Promise.all([
|
|
10
|
+
fileExists(path.join(cwd, "next.config.js")),
|
|
11
|
+
fileExists(path.join(cwd, "next.config.mjs")),
|
|
12
|
+
fileExists(path.join(cwd, "next.config.ts")),
|
|
13
|
+
]),
|
|
14
|
+
Promise.all([
|
|
15
|
+
fileExists(path.join(cwd, "vite.config.js")),
|
|
16
|
+
fileExists(path.join(cwd, "vite.config.ts")),
|
|
17
|
+
]),
|
|
18
|
+
fileExists(path.join(cwd, "tsconfig.json")),
|
|
19
|
+
Promise.all([
|
|
20
|
+
fileExists(path.join(cwd, "postcss.config.js")),
|
|
21
|
+
fileExists(path.join(cwd, "postcss.config.mjs")),
|
|
22
|
+
fileExists(path.join(cwd, "postcss.config.ts")),
|
|
23
|
+
]),
|
|
24
|
+
directoryExists(path.join(cwd, "src")),
|
|
25
|
+
directoryExists(path.join(cwd, "app")),
|
|
26
|
+
directoryExists(path.join(cwd, "pages")),
|
|
27
|
+
Promise.all([
|
|
28
|
+
directoryExists(path.join(cwd, "components")),
|
|
29
|
+
directoryExists(path.join(cwd, "src/components")),
|
|
30
|
+
]),
|
|
31
|
+
]);
|
|
32
|
+
if (!hasPackageJson) {
|
|
33
|
+
throw new Error("No package.json found. Please run this command in a valid project directory.");
|
|
34
|
+
}
|
|
35
|
+
const hasNextConfig = nextConfigs.some(Boolean);
|
|
36
|
+
const hasViteConfig = viteConfigs.some(Boolean);
|
|
37
|
+
// const hasPostCssConfig = postCssConfigs.some(Boolean)
|
|
38
|
+
const hasComponentsDir = componentsDirs.some(Boolean);
|
|
39
|
+
const packageJson = await readPackageJson(cwd);
|
|
40
|
+
const dependencies = collectDependencies(packageJson);
|
|
41
|
+
let framework = "unknown";
|
|
42
|
+
if (dependencies.next || hasNextConfig) {
|
|
43
|
+
framework = "next";
|
|
44
|
+
}
|
|
45
|
+
else if (dependencies.vite || hasViteConfig) {
|
|
46
|
+
framework = "vite";
|
|
47
|
+
}
|
|
48
|
+
else if (dependencies.react) {
|
|
49
|
+
framework = "react";
|
|
50
|
+
}
|
|
51
|
+
const hasTailwind = Boolean(dependencies.tailwindcss ||
|
|
52
|
+
dependencies["@tailwindcss/postcss"] ||
|
|
53
|
+
dependencies["@tailwindcss/vite"]);
|
|
54
|
+
const detectedPm = await detect({ cwd });
|
|
55
|
+
const packageManager = detectedPm ?? "npm";
|
|
56
|
+
return {
|
|
57
|
+
framework,
|
|
58
|
+
typescript: hasTsConfig,
|
|
59
|
+
tailwind: hasTailwind,
|
|
60
|
+
packageManager,
|
|
61
|
+
srcDir: hasSrcDir,
|
|
62
|
+
appDir: framework === "next" && hasAppDir && !hasPagesDir,
|
|
63
|
+
hasComponents: hasComponentsDir,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export async function validateProject(cwd, projectInfo) {
|
|
67
|
+
const errors = [];
|
|
68
|
+
const warnings = [];
|
|
69
|
+
const packageJson = await readPackageJson(cwd);
|
|
70
|
+
const dependencies = collectDependencies(packageJson);
|
|
71
|
+
if (!dependencies.react) {
|
|
72
|
+
const supportNote = projectInfo.framework === "unknown"
|
|
73
|
+
? "trix-ui init supports React-based projects only (React, Next.js, Vite (React))."
|
|
74
|
+
: "React is required for trix-ui init.";
|
|
75
|
+
errors.push(`Project does not meet requirements: missing dependency \"react\". ${supportNote}`);
|
|
76
|
+
}
|
|
77
|
+
if (dependencies.react && !dependencies["react-dom"]) {
|
|
78
|
+
errors.push("Project does not meet requirements: missing dependency \"react-dom\".");
|
|
79
|
+
}
|
|
80
|
+
if (projectInfo.typescript && !dependencies["@types/react"]) {
|
|
81
|
+
warnings.push("@types/react is recommended for TypeScript projects.");
|
|
82
|
+
}
|
|
83
|
+
if (!projectInfo.typescript) {
|
|
84
|
+
warnings.push("TypeScript is not detected. TypeScript is recommended for better type safety.");
|
|
85
|
+
}
|
|
86
|
+
if (projectInfo.framework === "next" && !projectInfo.appDir) {
|
|
87
|
+
warnings.push("Next.js Pages Router detected. App Router is recommended for new projects.");
|
|
88
|
+
}
|
|
89
|
+
if (projectInfo.framework === "unknown") {
|
|
90
|
+
warnings.push("Could not detect framework. Manual configuration may be required.");
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
valid: errors.length === 0,
|
|
94
|
+
errors,
|
|
95
|
+
warnings,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
98
|
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InitConfig, InitOptions, ProjectInfo } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Best-effort wiring for global styles.
|
|
4
|
+
*
|
|
5
|
+
* Depending on the framework, we try to insert an `import "<globals>"` into the
|
|
6
|
+
* most likely entry point (Next.js layout/_app, or a React entry file). Failures
|
|
7
|
+
* are logged as warnings and do not block init.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ensureGlobalStyleImport(cwd: string, projectInfo: ProjectInfo, config: InitConfig, options: InitOptions): Promise<void>;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ensureDir, fileExists, writeFile } from "../../lib/fs.js";
|
|
4
|
+
import { logger } from "../../lib/logger.js";
|
|
5
|
+
const DIRECTIVE_REGEX = /^"use (client|server)";?$|^'use (client|server)';?$/;
|
|
6
|
+
const NEXT_LAYOUT_FILES = [
|
|
7
|
+
"layout.tsx",
|
|
8
|
+
"layout.jsx",
|
|
9
|
+
"layout.ts",
|
|
10
|
+
"layout.js"
|
|
11
|
+
];
|
|
12
|
+
const NEXT_APP_FILES = [
|
|
13
|
+
"_app.tsx",
|
|
14
|
+
"_app.jsx",
|
|
15
|
+
"_app.ts",
|
|
16
|
+
"_app.js"
|
|
17
|
+
];
|
|
18
|
+
const REACT_ENTRY_FILES = [
|
|
19
|
+
"src/main.tsx",
|
|
20
|
+
"src/main.jsx",
|
|
21
|
+
"src/main.ts",
|
|
22
|
+
"src/main.js",
|
|
23
|
+
"src/index.tsx",
|
|
24
|
+
"src/index.jsx",
|
|
25
|
+
"src/index.ts",
|
|
26
|
+
"src/index.js"
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Best-effort wiring for global styles.
|
|
30
|
+
*
|
|
31
|
+
* Depending on the framework, we try to insert an `import "<globals>"` into the
|
|
32
|
+
* most likely entry point (Next.js layout/_app, or a React entry file). Failures
|
|
33
|
+
* are logged as warnings and do not block init.
|
|
34
|
+
*/
|
|
35
|
+
export async function ensureGlobalStyleImport(cwd, projectInfo, config, options) {
|
|
36
|
+
try {
|
|
37
|
+
const stylesPath = path.resolve(cwd, config.paths.styles);
|
|
38
|
+
if (projectInfo.framework === "next") {
|
|
39
|
+
if (projectInfo.appDir) {
|
|
40
|
+
await ensureNextAppLayoutImport(cwd, projectInfo, stylesPath);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (projectInfo.pagesDir) {
|
|
44
|
+
await ensureNextPagesAppImport(cwd, projectInfo, stylesPath);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
await ensureReactEntryImport(cwd, stylesPath);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (!options.silent) {
|
|
52
|
+
logger.warn({ error: error.message }, "Unable to auto-import global styles");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Ensure Next.js App Router projects import globals from their root `layout`.
|
|
58
|
+
*
|
|
59
|
+
* If no layout file is found, a minimal one is created.
|
|
60
|
+
*/
|
|
61
|
+
async function ensureNextAppLayoutImport(cwd, projectInfo, stylesPath) {
|
|
62
|
+
const appDir = await resolveNextAppDir(cwd);
|
|
63
|
+
const layoutPath = await findExistingFile(NEXT_LAYOUT_FILES.map((file) => path.join(appDir, file)));
|
|
64
|
+
if (layoutPath) {
|
|
65
|
+
await ensureImportInFile(layoutPath, stylesPath);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const extension = projectInfo.typescript ? "tsx" : "jsx";
|
|
69
|
+
const nextLayoutPath = path.join(appDir, `layout.${extension}`);
|
|
70
|
+
const importPath = toRelativeImport(nextLayoutPath, stylesPath);
|
|
71
|
+
const content = projectInfo.typescript
|
|
72
|
+
? `import type { ReactNode } from "react"\nimport "${importPath}"\n\nexport default function RootLayout({ children }: { children: ReactNode }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n )\n}\n`
|
|
73
|
+
: `import "${importPath}"\n\nexport default function RootLayout({ children }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n )\n}\n`;
|
|
74
|
+
await ensureDir(path.dirname(nextLayoutPath));
|
|
75
|
+
await writeFile(nextLayoutPath, content);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Ensure Next.js Pages Router projects import globals from `_app`.
|
|
79
|
+
*
|
|
80
|
+
* If no `_app` file is found, a minimal one is created.
|
|
81
|
+
*/
|
|
82
|
+
async function ensureNextPagesAppImport(cwd, projectInfo, stylesPath) {
|
|
83
|
+
const pagesDir = await resolveNextPagesDir(cwd);
|
|
84
|
+
const appPath = await findExistingFile(NEXT_APP_FILES.map((file) => path.join(pagesDir, file)));
|
|
85
|
+
if (appPath) {
|
|
86
|
+
await ensureImportInFile(appPath, stylesPath);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const extension = projectInfo.typescript ? "tsx" : "jsx";
|
|
90
|
+
const nextAppPath = path.join(pagesDir, `_app.${extension}`);
|
|
91
|
+
const importPath = toRelativeImport(nextAppPath, stylesPath);
|
|
92
|
+
const content = projectInfo.typescript
|
|
93
|
+
? `import type { AppProps } from "next/app"\nimport "${importPath}"\n\nexport default function App({ Component, pageProps }: AppProps) {\n return <Component {...pageProps} />\n}\n`
|
|
94
|
+
: `import "${importPath}"\n\nexport default function App({ Component, pageProps }) {\n return <Component {...pageProps} />\n}\n`;
|
|
95
|
+
await ensureDir(path.dirname(nextAppPath));
|
|
96
|
+
await writeFile(nextAppPath, content);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Ensure a React entry file imports the global stylesheet.
|
|
100
|
+
*
|
|
101
|
+
* Throws if we can't find a conventional entry file to edit.
|
|
102
|
+
*/
|
|
103
|
+
async function ensureReactEntryImport(cwd, stylesPath) {
|
|
104
|
+
const entryPath = await findExistingFile(REACT_ENTRY_FILES.map((file) => path.join(cwd, file)));
|
|
105
|
+
if (!entryPath) {
|
|
106
|
+
throw new Error("No React entry file found for global styles import.");
|
|
107
|
+
}
|
|
108
|
+
await ensureImportInFile(entryPath, stylesPath);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolve the effective Next.js App Router directory (`src/app` vs `app`).
|
|
112
|
+
*
|
|
113
|
+
* If neither exists yet, `src/app` is returned so callers have a stable target.
|
|
114
|
+
*/
|
|
115
|
+
async function resolveNextAppDir(cwd) {
|
|
116
|
+
const candidates = [path.join(cwd, "src", "app"), path.join(cwd, "app")];
|
|
117
|
+
for (const candidate of candidates) {
|
|
118
|
+
if (await fileExists(candidate)) {
|
|
119
|
+
return candidate;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return candidates[0];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Resolve the effective Next.js Pages Router directory (`src/pages` vs `pages`).
|
|
126
|
+
*
|
|
127
|
+
* If neither exists yet, `src/pages` is returned so callers have a stable target.
|
|
128
|
+
*/
|
|
129
|
+
async function resolveNextPagesDir(cwd) {
|
|
130
|
+
const candidates = [path.join(cwd, "src", "pages"), path.join(cwd, "pages")];
|
|
131
|
+
for (const candidate of candidates) {
|
|
132
|
+
if (await fileExists(candidate)) {
|
|
133
|
+
return candidate;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return candidates[0];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Return the first existing file from a list of candidates.
|
|
140
|
+
*/
|
|
141
|
+
async function findExistingFile(candidates) {
|
|
142
|
+
for (const candidate of candidates) {
|
|
143
|
+
if (await fileExists(candidate)) {
|
|
144
|
+
return candidate;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Convert an absolute target file into a relative import specifier from `fromFile`.
|
|
151
|
+
*
|
|
152
|
+
* Output always uses POSIX separators to match bundler expectations.
|
|
153
|
+
*/
|
|
154
|
+
function toRelativeImport(fromFile, targetFile) {
|
|
155
|
+
let relativePath = path.relative(path.dirname(fromFile), targetFile);
|
|
156
|
+
relativePath = relativePath.replace(/\\/g, "/");
|
|
157
|
+
if (!relativePath.startsWith(".")) {
|
|
158
|
+
relativePath = `./${relativePath}`;
|
|
159
|
+
}
|
|
160
|
+
return relativePath;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Insert a global style import into a source file if it isn't already present.
|
|
164
|
+
*/
|
|
165
|
+
async function ensureImportInFile(filePath, stylesPath) {
|
|
166
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
167
|
+
const importPath = toRelativeImport(filePath, stylesPath);
|
|
168
|
+
if (hasStyleImport(content, importPath)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const updated = insertStyleImport(content, importPath);
|
|
172
|
+
await writeFile(filePath, updated);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Check whether the file already imports the global stylesheet.
|
|
176
|
+
*
|
|
177
|
+
* We accept either an exact match (the computed relative path) or any import of
|
|
178
|
+
* a `globals.css` file to avoid duplicate globals.
|
|
179
|
+
*/
|
|
180
|
+
function hasStyleImport(content, importPath) {
|
|
181
|
+
const escaped = importPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
182
|
+
if (new RegExp(`['"]${escaped}['"]`).test(content)) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return /['"][^'"]*globals\.css['"]/.test(content);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Add `import "<path>"` near the top of a module without breaking directives.
|
|
189
|
+
*
|
|
190
|
+
* The import is placed after a shebang and `"use client/server"` directives, and
|
|
191
|
+
* after any existing import block when present.
|
|
192
|
+
*/
|
|
193
|
+
function insertStyleImport(content, importPath) {
|
|
194
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
195
|
+
const lines = content.split(/\r?\n/);
|
|
196
|
+
let index = 0;
|
|
197
|
+
if (lines[0]?.startsWith("#!")) {
|
|
198
|
+
index = 1;
|
|
199
|
+
}
|
|
200
|
+
while (index < lines.length && DIRECTIVE_REGEX.test(lines[index].trim())) {
|
|
201
|
+
index += 1;
|
|
202
|
+
}
|
|
203
|
+
let lastImportIndex = -1;
|
|
204
|
+
for (let i = index; i < lines.length; i += 1) {
|
|
205
|
+
const line = lines[i];
|
|
206
|
+
if (/^\s*import\s/.test(line)) {
|
|
207
|
+
lastImportIndex = i;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (line.trim() !== "") {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const insertAt = lastImportIndex >= 0 ? lastImportIndex + 1 : index;
|
|
215
|
+
lines.splice(insertAt, 0, `import "${importPath}"`, "");
|
|
216
|
+
return lines.join(eol);
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=style-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-imports.js","sourceRoot":"","sources":["../../../src/commands/init/style-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAG5C,MAAM,eAAe,GAAG,qDAAqD,CAAA;AAE7E,MAAM,iBAAiB,GAAG;IACxB,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,WAAW;CACZ,CAAA;AAED,MAAM,cAAc,GAAG;IACrB,UAAU;IACV,UAAU;IACV,SAAS;IACT,SAAS;CACV,CAAA;AAED,MAAM,iBAAiB,GAAG;IACxB,cAAc;IACd,cAAc;IACd,aAAa;IACb,aAAa;IACb,eAAe;IACf,eAAe;IACf,cAAc;IACd,cAAc;CACf,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,GAAW,EACX,WAAwB,EACxB,MAAkB,EAClB,OAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEzD,IAAI,WAAW,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;YACrC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;gBACvB,MAAM,yBAAyB,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,CAAC,CAAA;gBAC7D,OAAM;YACR,CAAC;YAED,IAAI,WAAW,CAAC,QAAQ,EAAE,CA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"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { InitConfig, InitOptions, ProjectInfo } from "./types.js";
|
|
2
|
-
export declare function setupTailwind(cwd: string, projectInfo: ProjectInfo, options: InitOptions): Promise<void>;
|
|
3
|
-
export declare function setupGlobalStyles(cwd: string, config: InitConfig, options: InitOptions): Promise<void>;
|
|
1
|
+
import type { InitConfig, InitOptions, ProjectInfo } from "./types.js";
|
|
2
|
+
export declare function setupTailwind(cwd: string, projectInfo: ProjectInfo, options: InitOptions): Promise<void>;
|
|
3
|
+
export declare function setupGlobalStyles(cwd: string, config: InitConfig, options: InitOptions): Promise<void>;
|