sigma-ui 1.1.1 → 1.2.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/README.md +1 -1
- package/__generated/registry-schemes/colors/blue.json +1 -1
- package/__generated/registry-schemes/colors/frosted-glass.json +1 -1
- package/__generated/registry-schemes/colors/grayscale.json +1 -1
- package/__generated/registry-schemes/colors/green.json +1 -1
- package/__generated/registry-schemes/colors/orange.json +1 -1
- package/__generated/registry-schemes/colors/red.json +1 -1
- package/__generated/registry-schemes/colors/rose.json +1 -1
- package/__generated/registry-schemes/colors/yellow.json +1 -1
- package/__generated/registry-schemes/style-system/css/accordion.json +1 -1
- package/__generated/registry-schemes/style-system/css/alert-dialog.json +1 -1
- package/__generated/registry-schemes/style-system/css/button.json +1 -1
- package/__generated/registry-schemes/style-system/css/collapsible.json +1 -1
- package/__generated/registry-schemes/style-system/css/combobox.json +1 -1
- package/__generated/registry-schemes/style-system/css/context-menu.json +2 -2
- package/__generated/registry-schemes/style-system/css/dialog.json +2 -2
- package/__generated/registry-schemes/style-system/css/dropdown-menu.json +2 -2
- package/__generated/registry-schemes/style-system/css/hover-card.json +1 -1
- package/__generated/registry-schemes/style-system/css/image.json +1 -1
- package/__generated/registry-schemes/style-system/css/menubar.json +2 -2
- package/__generated/registry-schemes/style-system/css/navigation-menu.json +3 -3
- package/__generated/registry-schemes/style-system/css/popover.json +1 -1
- package/__generated/registry-schemes/style-system/css/radio-group.json +1 -1
- package/__generated/registry-schemes/style-system/css/select.json +1 -1
- package/__generated/registry-schemes/style-system/css/sheet.json +1 -1
- package/__generated/registry-schemes/style-system/css/skeleton.json +1 -1
- package/__generated/registry-schemes/style-system/css/switch.json +1 -1
- package/__generated/registry-schemes/style-system/css/tooltip.json +1 -1
- package/__generated/registry-schemes/style-system/tailwind/button.json +1 -1
- package/__generated/registry-schemes/style-system/tailwind/navigation-menu.json +1 -1
- package/dist/index.js +530 -306
- package/dist/index.js.map +1 -1
- package/package.json +19 -20
- package/LICENSE +0 -21
package/dist/index.js
CHANGED
|
@@ -8,22 +8,80 @@ import process6 from "node:process";
|
|
|
8
8
|
import { Command as Command4 } from "commander";
|
|
9
9
|
|
|
10
10
|
// src/commands/add.ts
|
|
11
|
-
import {
|
|
12
|
-
import { existsSync as existsSync2, promises as fs3 } from "node:fs";
|
|
11
|
+
import { existsSync as existsSync3, promises as fs3 } from "node:fs";
|
|
13
12
|
import process3 from "node:process";
|
|
14
|
-
import
|
|
13
|
+
import path5 from "pathe";
|
|
15
14
|
import { consola as consola3 } from "consola";
|
|
16
15
|
import { colors as colors2 } from "consola/utils";
|
|
17
16
|
import { Command } from "commander";
|
|
18
17
|
import ora from "ora";
|
|
19
18
|
import prompts from "prompts";
|
|
20
19
|
import { z as z2 } from "zod";
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
// src/utils/package-manager.ts
|
|
22
|
+
import { execSync } from "node:child_process";
|
|
23
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
24
|
+
import path from "pathe";
|
|
25
|
+
async function detectPackageManager(cwd) {
|
|
26
|
+
const lockFiles = [
|
|
27
|
+
{ name: "pnpm", files: ["pnpm-lock.yaml", "pnpm-workspace.yaml"] },
|
|
28
|
+
{ name: "yarn", files: ["yarn.lock"] },
|
|
29
|
+
{ name: "bun", files: ["bun.lockb"] },
|
|
30
|
+
{ name: "npm", files: ["package-lock.json"] }
|
|
31
|
+
];
|
|
32
|
+
for (const pm of lockFiles) {
|
|
33
|
+
for (const file of pm.files) {
|
|
34
|
+
if (existsSync(path.join(cwd, file))) {
|
|
35
|
+
return { name: pm.name };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
41
|
+
if (existsSync(packageJsonPath)) {
|
|
42
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
43
|
+
if (packageJson.packageManager) {
|
|
44
|
+
const [name, version] = packageJson.packageManager.split("@");
|
|
45
|
+
return { name, version };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
return { name: "pnpm" };
|
|
51
|
+
}
|
|
52
|
+
async function addDependency(dependencies, options8 = { cwd: process.cwd() }) {
|
|
53
|
+
await installPackages(dependencies, "dependencies", options8);
|
|
54
|
+
}
|
|
55
|
+
async function addDevDependency(dependencies, options8 = { cwd: process.cwd() }) {
|
|
56
|
+
await installPackages(dependencies, "devDependencies", options8);
|
|
57
|
+
}
|
|
58
|
+
async function installPackages(dependencies, type2, options8 = { cwd: process.cwd() }) {
|
|
59
|
+
const pm = await detectPackageManager(options8.cwd);
|
|
60
|
+
const devFlag = type2 === "devDependencies" ? "-D " : "";
|
|
61
|
+
let command = "";
|
|
62
|
+
switch (pm?.name) {
|
|
63
|
+
case "npm":
|
|
64
|
+
command = `npm install ${devFlag}${dependencies.join(" ")}`;
|
|
65
|
+
break;
|
|
66
|
+
case "yarn":
|
|
67
|
+
command = `yarn add ${devFlag}${dependencies.join(" ")}`;
|
|
68
|
+
break;
|
|
69
|
+
case "bun":
|
|
70
|
+
command = `bun add ${devFlag}${dependencies.join(" ")}`;
|
|
71
|
+
break;
|
|
72
|
+
case "pnpm":
|
|
73
|
+
default:
|
|
74
|
+
command = `pnpm add ${devFlag}${dependencies.join(" ")}`;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
const stdio = options8.silent ? "pipe" : "inherit";
|
|
78
|
+
execSync(command, { cwd: options8.cwd, stdio });
|
|
79
|
+
}
|
|
22
80
|
|
|
23
81
|
// src/utils/transformers/index.ts
|
|
24
82
|
import { promises as fs } from "node:fs";
|
|
25
83
|
import { tmpdir } from "node:os";
|
|
26
|
-
import
|
|
84
|
+
import path2 from "pathe";
|
|
27
85
|
import { Project, ScriptKind } from "ts-morph";
|
|
28
86
|
|
|
29
87
|
// src/utils/transformers/transform-import.ts
|
|
@@ -67,8 +125,8 @@ var project = new Project({
|
|
|
67
125
|
compilerOptions: {}
|
|
68
126
|
});
|
|
69
127
|
async function createTempSourceFile(filename) {
|
|
70
|
-
const dir = await fs.mkdtemp(
|
|
71
|
-
return
|
|
128
|
+
const dir = await fs.mkdtemp(path2.join(tmpdir(), "sigma-ui-"));
|
|
129
|
+
return path2.join(dir, filename);
|
|
72
130
|
}
|
|
73
131
|
async function transform(opts) {
|
|
74
132
|
const tempFile = await createTempSourceFile(opts.filename);
|
|
@@ -81,10 +139,47 @@ async function transform(opts) {
|
|
|
81
139
|
return sourceFile?.getFullText();
|
|
82
140
|
}
|
|
83
141
|
|
|
142
|
+
// src/utils/transformers/transform-component-naming.ts
|
|
143
|
+
function pascalToKebab(pascalCase) {
|
|
144
|
+
return pascalCase.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
145
|
+
}
|
|
146
|
+
function kebabToPascal(kebabCase) {
|
|
147
|
+
return kebabCase.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
148
|
+
}
|
|
149
|
+
function transformDirectoryName(dirName, naming) {
|
|
150
|
+
if (naming === "kebab-case") {
|
|
151
|
+
return dirName;
|
|
152
|
+
}
|
|
153
|
+
return kebabToPascal(dirName);
|
|
154
|
+
}
|
|
155
|
+
function transformFileName(fileName, naming) {
|
|
156
|
+
if (naming === "pascal-case") {
|
|
157
|
+
return fileName;
|
|
158
|
+
}
|
|
159
|
+
if (fileName === "index.ts") {
|
|
160
|
+
return fileName;
|
|
161
|
+
}
|
|
162
|
+
const extension = fileName.includes(".") ? fileName.slice(fileName.lastIndexOf(".")) : "";
|
|
163
|
+
const baseName = fileName.includes(".") ? fileName.slice(0, fileName.lastIndexOf(".")) : fileName;
|
|
164
|
+
return pascalToKebab(baseName) + extension;
|
|
165
|
+
}
|
|
166
|
+
function transformLocalVueImports(content, naming) {
|
|
167
|
+
if (naming === "pascal-case") {
|
|
168
|
+
return content;
|
|
169
|
+
}
|
|
170
|
+
return content.replace(
|
|
171
|
+
/from\s+['"]\.\/([\w-]+)\.vue['"]/g,
|
|
172
|
+
(match, componentName) => {
|
|
173
|
+
const kebabName = pascalToKebab(componentName);
|
|
174
|
+
return `from './${kebabName}.vue'`;
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
84
179
|
// src/utils/get-config.ts
|
|
85
|
-
import { existsSync } from "node:fs";
|
|
180
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
86
181
|
import process2 from "node:process";
|
|
87
|
-
import
|
|
182
|
+
import path3 from "pathe";
|
|
88
183
|
import { loadConfig as c12LoadConfig } from "c12";
|
|
89
184
|
import { loadConfig } from "tsconfig-paths";
|
|
90
185
|
import consola from "consola";
|
|
@@ -159,6 +254,7 @@ var registryBaseColorSchema = z.object({
|
|
|
159
254
|
})
|
|
160
255
|
})
|
|
161
256
|
});
|
|
257
|
+
var componentNamingSchema = z.enum(["pascal-case", "kebab-case"]).default("pascal-case");
|
|
162
258
|
var rawConfigSchema = z.object({
|
|
163
259
|
$schema: z.string().optional(),
|
|
164
260
|
styleSystem: commonFields.styleSystem,
|
|
@@ -175,7 +271,8 @@ var rawConfigSchema = z.object({
|
|
|
175
271
|
utils: z.string().default(""),
|
|
176
272
|
components: z.string()
|
|
177
273
|
}),
|
|
178
|
-
generatePreflight: z.boolean().optional().default(true)
|
|
274
|
+
generatePreflight: z.boolean().optional().default(true),
|
|
275
|
+
componentNaming: componentNamingSchema
|
|
179
276
|
});
|
|
180
277
|
var configSchema = rawConfigSchema.extend({
|
|
181
278
|
resolvedPaths: z.object({
|
|
@@ -187,7 +284,8 @@ var configSchema = rawConfigSchema.extend({
|
|
|
187
284
|
});
|
|
188
285
|
var initOptionsSchema = z.object({
|
|
189
286
|
cwd: commonFields.cwd,
|
|
190
|
-
yes: commonFields.yes
|
|
287
|
+
yes: commonFields.yes,
|
|
288
|
+
defaults: z.boolean().default(false)
|
|
191
289
|
});
|
|
192
290
|
var addOptionsSchema = z.object({
|
|
193
291
|
components: commonFields.components,
|
|
@@ -238,14 +336,14 @@ async function handleConfigIsMissing() {
|
|
|
238
336
|
}
|
|
239
337
|
async function resolveConfigPaths(cwd, config) {
|
|
240
338
|
let tsConfig;
|
|
241
|
-
let tsConfigPath =
|
|
339
|
+
let tsConfigPath = path3.resolve(
|
|
242
340
|
cwd,
|
|
243
341
|
config.tsConfigPath
|
|
244
342
|
);
|
|
245
343
|
tsConfig = loadConfig(tsConfigPath);
|
|
246
344
|
if ("paths" in tsConfig && Object.keys(tsConfig.paths).length === 0) {
|
|
247
|
-
tsConfigPath =
|
|
248
|
-
if (
|
|
345
|
+
tsConfigPath = path3.resolve(cwd, "./tsconfig.app.json");
|
|
346
|
+
if (existsSync2(tsConfigPath)) {
|
|
249
347
|
tsConfig = loadConfig(tsConfigPath);
|
|
250
348
|
}
|
|
251
349
|
}
|
|
@@ -257,8 +355,8 @@ async function resolveConfigPaths(cwd, config) {
|
|
|
257
355
|
return configSchema.parse({
|
|
258
356
|
...config,
|
|
259
357
|
resolvedPaths: {
|
|
260
|
-
tailwindConfig:
|
|
261
|
-
tailwindCss:
|
|
358
|
+
tailwindConfig: path3.resolve(cwd, config.tailwind.config),
|
|
359
|
+
tailwindCss: path3.resolve(cwd, config.cssPath),
|
|
262
360
|
utils: resolveImport(config.aliases.utils, tsConfig),
|
|
263
361
|
components: resolveImport(config.aliases.components, tsConfig)
|
|
264
362
|
}
|
|
@@ -297,7 +395,7 @@ function handleError(error) {
|
|
|
297
395
|
|
|
298
396
|
// src/utils/registry/index.ts
|
|
299
397
|
import fs2 from "node:fs";
|
|
300
|
-
import
|
|
398
|
+
import path4 from "pathe";
|
|
301
399
|
|
|
302
400
|
// ../../apps/docs/src/lib/registry/themes.ts
|
|
303
401
|
var themes = [
|
|
@@ -756,7 +854,7 @@ function getItemTargetPath(config, item, override) {
|
|
|
756
854
|
if (!(parent in config.resolvedPaths)) {
|
|
757
855
|
return null;
|
|
758
856
|
}
|
|
759
|
-
return
|
|
857
|
+
return path4.join(
|
|
760
858
|
config.resolvedPaths[parent] ?? "",
|
|
761
859
|
type2
|
|
762
860
|
);
|
|
@@ -818,8 +916,8 @@ function parseOptions(components, opts) {
|
|
|
818
916
|
});
|
|
819
917
|
}
|
|
820
918
|
function validateAndResolveCwd(cwd) {
|
|
821
|
-
const resolvedCwd =
|
|
822
|
-
if (!
|
|
919
|
+
const resolvedCwd = path5.resolve(cwd);
|
|
920
|
+
if (!existsSync3(resolvedCwd)) {
|
|
823
921
|
consola3.error(`The path ${resolvedCwd} does not exist. Try again.`);
|
|
824
922
|
process3.exit(1);
|
|
825
923
|
}
|
|
@@ -880,7 +978,7 @@ async function processPayload(payload, options8, config, baseColor, cwd, selecte
|
|
|
880
978
|
const targetDir = getItemTargetPath(
|
|
881
979
|
config,
|
|
882
980
|
item,
|
|
883
|
-
options8.path ?
|
|
981
|
+
options8.path ? path5.resolve(cwd, options8.path) : void 0
|
|
884
982
|
);
|
|
885
983
|
if (!targetDir) {
|
|
886
984
|
continue;
|
|
@@ -891,12 +989,14 @@ async function processPayload(payload, options8, config, baseColor, cwd, selecte
|
|
|
891
989
|
}
|
|
892
990
|
async function processItem(item, targetDir, options8, config, baseColor, cwd, selectedComponents, spinner) {
|
|
893
991
|
try {
|
|
894
|
-
if (!
|
|
992
|
+
if (!existsSync3(targetDir)) {
|
|
895
993
|
await fs3.mkdir(targetDir, { recursive: true });
|
|
896
994
|
}
|
|
897
|
-
const
|
|
995
|
+
const componentNaming = config.componentNaming ?? "pascal-case";
|
|
996
|
+
const transformedDirName = transformDirectoryName(item.name, componentNaming);
|
|
997
|
+
const componentPath = path5.resolve(targetDir, transformedDirName);
|
|
898
998
|
const existingComponent = item.files.filter(
|
|
899
|
-
(file) =>
|
|
999
|
+
(file) => existsSync3(path5.resolve(componentPath, file.name))
|
|
900
1000
|
);
|
|
901
1001
|
if (existingComponent.length && !options8.overwrite) {
|
|
902
1002
|
if (selectedComponents.includes(item.name)) {
|
|
@@ -936,79 +1036,45 @@ async function installDependencies(item, cwd) {
|
|
|
936
1036
|
].filter(Boolean);
|
|
937
1037
|
for (const task of installTasks) {
|
|
938
1038
|
try {
|
|
939
|
-
consola3.info(`
|
|
1039
|
+
consola3.info(`Installing ${task.type}: ${task.deps.join(", ")}`);
|
|
940
1040
|
await task.installer(task.deps, { cwd });
|
|
941
|
-
consola3.success(`Successfully installed ${task.type}
|
|
1041
|
+
consola3.success(`Successfully installed ${task.type}.`);
|
|
942
1042
|
} catch (error) {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
let command = "";
|
|
949
|
-
const depsString = task.deps.join(" ");
|
|
950
|
-
const devFlag = task.type === "devDependencies" ? "-D " : "";
|
|
951
|
-
switch (pm?.name) {
|
|
952
|
-
case "npm":
|
|
953
|
-
command = `npm install ${devFlag}${depsString}`;
|
|
954
|
-
break;
|
|
955
|
-
case "yarn":
|
|
956
|
-
command = `yarn add ${devFlag}${depsString}`;
|
|
957
|
-
break;
|
|
958
|
-
case "bun":
|
|
959
|
-
command = `bun add ${devFlag}${depsString}`;
|
|
960
|
-
break;
|
|
961
|
-
case "pnpm":
|
|
962
|
-
default:
|
|
963
|
-
command = `pnpm add ${devFlag}${depsString}`;
|
|
964
|
-
break;
|
|
965
|
-
}
|
|
966
|
-
try {
|
|
967
|
-
consola3.info(`Running: ${command}`);
|
|
968
|
-
execSync(command, { cwd, stdio: "inherit" });
|
|
969
|
-
consola3.success(`Successfully installed ${task.type} using direct pnpm execution.`);
|
|
970
|
-
} catch (fallbackError) {
|
|
971
|
-
const errorMessage = fallbackError instanceof Error ? fallbackError.message : "Unknown error";
|
|
972
|
-
consola3.error(`Fallback pnpm execution failed for ${task.type}:`, errorMessage);
|
|
973
|
-
throw new ComponentInstallError(
|
|
974
|
-
`Failed to install ${task.type} (nypm and fallback failed): ${errorMessage}`,
|
|
975
|
-
item.name
|
|
976
|
-
);
|
|
977
|
-
}
|
|
978
|
-
} else {
|
|
979
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
980
|
-
throw new ComponentInstallError(
|
|
981
|
-
`Failed to install ${task.type} using nypm: ${errorMessage}`,
|
|
982
|
-
item.name
|
|
983
|
-
);
|
|
984
|
-
}
|
|
1043
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1044
|
+
throw new ComponentInstallError(
|
|
1045
|
+
`Failed to install ${task.type}: ${errorMessage}`,
|
|
1046
|
+
item.name
|
|
1047
|
+
);
|
|
985
1048
|
}
|
|
986
1049
|
}
|
|
987
1050
|
}
|
|
988
1051
|
async function writeComponentFiles(item, componentDir, config, baseColor) {
|
|
989
|
-
if (!
|
|
1052
|
+
if (!existsSync3(componentDir)) {
|
|
990
1053
|
await fs3.mkdir(componentDir, { recursive: true });
|
|
991
1054
|
}
|
|
1055
|
+
const componentNaming = config.componentNaming ?? "pascal-case";
|
|
992
1056
|
const files = item.files.map((file) => ({
|
|
993
1057
|
...file,
|
|
994
|
-
|
|
1058
|
+
originalName: file.name,
|
|
1059
|
+
name: transformFileName(file.name, componentNaming),
|
|
1060
|
+
path: path5.resolve(componentDir, transformFileName(file.name, componentNaming))
|
|
995
1061
|
}));
|
|
996
1062
|
for (const file of files) {
|
|
1063
|
+
const fileContent = transformLocalVueImports(file.content, componentNaming);
|
|
997
1064
|
const content = await transform({
|
|
998
1065
|
filename: file.path,
|
|
999
|
-
raw:
|
|
1066
|
+
raw: fileContent,
|
|
1000
1067
|
config,
|
|
1001
1068
|
baseColor
|
|
1002
1069
|
});
|
|
1003
|
-
|
|
1004
|
-
await fs3.writeFile(filePath, content);
|
|
1070
|
+
await fs3.writeFile(file.path, content);
|
|
1005
1071
|
}
|
|
1006
1072
|
}
|
|
1007
1073
|
|
|
1008
1074
|
// src/commands/diff.ts
|
|
1009
|
-
import { existsSync as
|
|
1075
|
+
import { existsSync as existsSync4, promises as fs4 } from "node:fs";
|
|
1010
1076
|
import process4 from "node:process";
|
|
1011
|
-
import
|
|
1077
|
+
import path6 from "pathe";
|
|
1012
1078
|
import { consola as consola4 } from "consola";
|
|
1013
1079
|
import { colors as colors3 } from "consola/utils";
|
|
1014
1080
|
import { Command as Command2 } from "commander";
|
|
@@ -1039,8 +1105,8 @@ function parseOptions2(name, opts) {
|
|
|
1039
1105
|
});
|
|
1040
1106
|
}
|
|
1041
1107
|
function validateAndResolveCwd2(cwd) {
|
|
1042
|
-
const resolvedCwd =
|
|
1043
|
-
if (!
|
|
1108
|
+
const resolvedCwd = path6.resolve(cwd);
|
|
1109
|
+
if (!existsSync4(resolvedCwd)) {
|
|
1044
1110
|
consola4.error(`The path ${resolvedCwd} does not exist. Try again.`);
|
|
1045
1111
|
process4.exit(1);
|
|
1046
1112
|
}
|
|
@@ -1068,8 +1134,8 @@ async function handleAllComponentsDiff(config, registryIndex) {
|
|
|
1068
1134
|
function findProjectComponents(registryIndex, targetDir) {
|
|
1069
1135
|
return registryIndex.filter((item) => {
|
|
1070
1136
|
return item.files.some((file) => {
|
|
1071
|
-
const fullPath =
|
|
1072
|
-
return
|
|
1137
|
+
const fullPath = path6.resolve(targetDir, item.name, file);
|
|
1138
|
+
return existsSync4(fullPath);
|
|
1073
1139
|
});
|
|
1074
1140
|
});
|
|
1075
1141
|
}
|
|
@@ -1132,8 +1198,8 @@ async function diffComponent(component, config) {
|
|
|
1132
1198
|
}
|
|
1133
1199
|
async function processItemFiles(item, targetDir, config, baseColor, changes) {
|
|
1134
1200
|
for (const file of item.files) {
|
|
1135
|
-
const filePath =
|
|
1136
|
-
if (!
|
|
1201
|
+
const filePath = path6.resolve(targetDir, item.name, file.name);
|
|
1202
|
+
if (!existsSync4(filePath)) {
|
|
1137
1203
|
continue;
|
|
1138
1204
|
}
|
|
1139
1205
|
const fileContent = await fs4.readFile(filePath, "utf8");
|
|
@@ -1170,17 +1236,15 @@ function printDiff(diff3) {
|
|
|
1170
1236
|
}
|
|
1171
1237
|
|
|
1172
1238
|
// src/commands/init.ts
|
|
1173
|
-
import { existsSync as
|
|
1239
|
+
import { existsSync as existsSync6, promises as fs8 } from "node:fs";
|
|
1174
1240
|
import process5 from "node:process";
|
|
1175
1241
|
import path14 from "pathe";
|
|
1176
1242
|
import { Command as Command3 } from "commander";
|
|
1177
1243
|
import { template } from "lodash-es";
|
|
1178
1244
|
import ora2 from "ora";
|
|
1179
1245
|
import prompts2 from "prompts";
|
|
1180
|
-
import { addDependency as addDependency2, addDevDependency as addDevDependency2, detectPackageManager as detectPackageManager2 } from "nypm";
|
|
1181
1246
|
import { consola as consola5 } from "consola";
|
|
1182
1247
|
import { colors as colors4 } from "consola/utils";
|
|
1183
|
-
import { execSync as execSync2 } from "node:child_process";
|
|
1184
1248
|
|
|
1185
1249
|
// ../../node_modules/.pnpm/prettier@3.5.0/node_modules/prettier/index.mjs
|
|
1186
1250
|
import { createRequire as __prettierCreateRequire } from "module";
|
|
@@ -1195,13 +1259,13 @@ import path42 from "path";
|
|
|
1195
1259
|
import * as path32 from "path";
|
|
1196
1260
|
import fs5 from "fs/promises";
|
|
1197
1261
|
import path22 from "path";
|
|
1198
|
-
import * as
|
|
1262
|
+
import * as path7 from "path";
|
|
1199
1263
|
import path8 from "path";
|
|
1200
1264
|
import fs22 from "fs/promises";
|
|
1201
1265
|
import fs32 from "fs/promises";
|
|
1202
1266
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
1203
1267
|
import fs42 from "fs/promises";
|
|
1204
|
-
import
|
|
1268
|
+
import path72 from "path";
|
|
1205
1269
|
import { pathToFileURL as pathToFileURL4 } from "url";
|
|
1206
1270
|
import assert3 from "assert";
|
|
1207
1271
|
import { statSync, realpathSync } from "fs";
|
|
@@ -13700,15 +13764,15 @@ async function isDirectory(directory, options8) {
|
|
|
13700
13764
|
return stats.isDirectory();
|
|
13701
13765
|
}
|
|
13702
13766
|
var is_directory_default = isDirectory;
|
|
13703
|
-
var toAbsolutePath = (value) =>
|
|
13767
|
+
var toAbsolutePath = (value) => path7.resolve(toPath(value));
|
|
13704
13768
|
function* iterateDirectoryUp(from, to) {
|
|
13705
13769
|
from = toAbsolutePath(from);
|
|
13706
|
-
const { root: root2 } =
|
|
13770
|
+
const { root: root2 } = path7.parse(from);
|
|
13707
13771
|
to = to ? toAbsolutePath(to) : root2;
|
|
13708
13772
|
if (from !== to && !from.startsWith(to)) {
|
|
13709
13773
|
return;
|
|
13710
13774
|
}
|
|
13711
|
-
for (let directory = from; directory !== to; directory =
|
|
13775
|
+
for (let directory = from; directory !== to; directory = path7.dirname(directory)) {
|
|
13712
13776
|
yield directory;
|
|
13713
13777
|
}
|
|
13714
13778
|
yield to;
|
|
@@ -19062,7 +19126,7 @@ async function loadExternalConfig(externalConfig, configFile) {
|
|
|
19062
19126
|
}
|
|
19063
19127
|
var load_external_config_default = loadExternalConfig;
|
|
19064
19128
|
async function loadConfig2(configFile) {
|
|
19065
|
-
const { base: fileName, ext: extension } =
|
|
19129
|
+
const { base: fileName, ext: extension } = path72.parse(configFile);
|
|
19066
19130
|
const load2 = fileName === "package.json" ? loadConfigFromPackageJson : fileName === "package.yaml" ? loadConfigFromPackageYaml : loaders_default[extension];
|
|
19067
19131
|
if (!load2) {
|
|
19068
19132
|
throw new Error(
|
|
@@ -24085,59 +24149,86 @@ var src_default = index_exports;
|
|
|
24085
24149
|
import { Project as Project2, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
24086
24150
|
|
|
24087
24151
|
// src/utils/get-project-info.ts
|
|
24088
|
-
import { existsSync as
|
|
24152
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
24089
24153
|
import path13 from "pathe";
|
|
24090
24154
|
import fs7 from "fs-extra";
|
|
24091
24155
|
import { readPackageJSON } from "pkg-types";
|
|
24092
|
-
async function getProjectInfo() {
|
|
24093
|
-
const
|
|
24094
|
-
|
|
24095
|
-
|
|
24096
|
-
|
|
24097
|
-
|
|
24098
|
-
|
|
24099
|
-
|
|
24100
|
-
|
|
24156
|
+
async function getProjectInfo(cwd = process.cwd()) {
|
|
24157
|
+
const framework = detectFramework(cwd);
|
|
24158
|
+
const tsConfigPath = detectTsConfigPath(cwd, framework);
|
|
24159
|
+
const hasTailwind = await detectTailwind(cwd);
|
|
24160
|
+
const { configType: tailwindConfigType, configPath: tailwindConfigPath } = detectTailwindConfigType(cwd);
|
|
24161
|
+
const sigmaUiNuxtModuleInfo = framework === "nuxt" ? await getSigmaUiNuxtInfo() : void 0;
|
|
24162
|
+
return {
|
|
24163
|
+
framework,
|
|
24164
|
+
tsConfigPath,
|
|
24165
|
+
srcDir: existsSync5(path13.resolve(cwd, "src")),
|
|
24166
|
+
srcComponentsUiDir: existsSync5(path13.resolve(cwd, "src/components/ui")),
|
|
24167
|
+
componentsUiDir: existsSync5(path13.resolve(cwd, "components/ui")),
|
|
24168
|
+
hasTailwind,
|
|
24169
|
+
tailwindConfigType,
|
|
24170
|
+
tailwindConfigPath,
|
|
24171
|
+
sigmaUiNuxtModuleInfo
|
|
24101
24172
|
};
|
|
24102
|
-
|
|
24103
|
-
|
|
24104
|
-
|
|
24105
|
-
|
|
24106
|
-
|
|
24107
|
-
|
|
24108
|
-
|
|
24109
|
-
|
|
24110
|
-
|
|
24111
|
-
|
|
24112
|
-
|
|
24113
|
-
|
|
24114
|
-
};
|
|
24115
|
-
} catch (error) {
|
|
24116
|
-
console.log(error);
|
|
24117
|
-
return info;
|
|
24173
|
+
}
|
|
24174
|
+
function detectTailwindConfigType(cwd) {
|
|
24175
|
+
const jsConfigPaths = [
|
|
24176
|
+
"tailwind.config.js",
|
|
24177
|
+
"tailwind.config.ts",
|
|
24178
|
+
"tailwind.config.mjs",
|
|
24179
|
+
"tailwind.config.cjs"
|
|
24180
|
+
];
|
|
24181
|
+
for (const configPath of jsConfigPaths) {
|
|
24182
|
+
if (existsSync5(path13.resolve(cwd, configPath))) {
|
|
24183
|
+
return { configType: "js", configPath };
|
|
24184
|
+
}
|
|
24118
24185
|
}
|
|
24186
|
+
return { configType: "css", configPath: null };
|
|
24119
24187
|
}
|
|
24120
|
-
|
|
24121
|
-
|
|
24188
|
+
function detectFramework(cwd) {
|
|
24189
|
+
if (existsSync5(path13.resolve(cwd, "nuxt.config.js")) || existsSync5(path13.resolve(cwd, "nuxt.config.ts"))) {
|
|
24190
|
+
return "nuxt";
|
|
24191
|
+
}
|
|
24192
|
+
if (existsSync5(path13.resolve(cwd, "astro.config.mjs")) || existsSync5(path13.resolve(cwd, "astro.config.ts"))) {
|
|
24193
|
+
return "astro";
|
|
24194
|
+
}
|
|
24195
|
+
if (existsSync5(path13.resolve(cwd, "artisan"))) {
|
|
24196
|
+
return "laravel";
|
|
24197
|
+
}
|
|
24198
|
+
return "vite";
|
|
24199
|
+
}
|
|
24200
|
+
function detectTsConfigPath(cwd, framework) {
|
|
24201
|
+
if (framework === "nuxt") {
|
|
24202
|
+
return ".nuxt/tsconfig.json";
|
|
24203
|
+
}
|
|
24204
|
+
const possiblePaths = [
|
|
24205
|
+
"tsconfig.json",
|
|
24206
|
+
"tsconfig.app.json"
|
|
24207
|
+
];
|
|
24208
|
+
for (const tsPath of possiblePaths) {
|
|
24209
|
+
if (existsSync5(path13.resolve(cwd, tsPath))) {
|
|
24210
|
+
return tsPath;
|
|
24211
|
+
}
|
|
24212
|
+
}
|
|
24213
|
+
return "tsconfig.json";
|
|
24214
|
+
}
|
|
24215
|
+
async function detectTailwind(cwd) {
|
|
24122
24216
|
try {
|
|
24123
|
-
|
|
24124
|
-
|
|
24125
|
-
|
|
24126
|
-
|
|
24217
|
+
const packageJson = await readPackageJSON(cwd);
|
|
24218
|
+
const allDeps = {
|
|
24219
|
+
...packageJson.dependencies,
|
|
24220
|
+
...packageJson.devDependencies
|
|
24221
|
+
};
|
|
24222
|
+
return "tailwindcss" in allDeps;
|
|
24223
|
+
} catch {
|
|
24224
|
+
return false;
|
|
24127
24225
|
}
|
|
24128
|
-
return nuxtModule;
|
|
24129
24226
|
}
|
|
24130
|
-
async function
|
|
24227
|
+
async function getSigmaUiNuxtInfo() {
|
|
24131
24228
|
try {
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24135
|
-
throw new Error("tsconfig.json is missing");
|
|
24136
|
-
}
|
|
24137
|
-
return tsconfig;
|
|
24138
|
-
} catch (error) {
|
|
24139
|
-
console.log(error);
|
|
24140
|
-
return null;
|
|
24229
|
+
return await readPackageJSON("sigma-ui-nuxt");
|
|
24230
|
+
} catch {
|
|
24231
|
+
return void 0;
|
|
24141
24232
|
}
|
|
24142
24233
|
}
|
|
24143
24234
|
|
|
@@ -24197,43 +24288,162 @@ function applyPrefixesCss(css, prefix) {
|
|
|
24197
24288
|
}
|
|
24198
24289
|
|
|
24199
24290
|
// ../shared/templates/tailwind-config.ts
|
|
24200
|
-
var
|
|
24201
|
-
|
|
24291
|
+
var UTILS_TEMPLATE = `import { type ClassValue, clsx } from 'clsx'
|
|
24292
|
+
import { twMerge } from 'tailwind-merge'
|
|
24293
|
+
|
|
24294
|
+
export function cn(...inputs: ClassValue[]) {
|
|
24295
|
+
return twMerge(clsx(inputs))
|
|
24296
|
+
}
|
|
24297
|
+
`;
|
|
24298
|
+
var TAILWIND_V4_CSS_TEMPLATE = `@import "tailwindcss";
|
|
24299
|
+
|
|
24300
|
+
@plugin "tailwindcss-animate";
|
|
24301
|
+
|
|
24302
|
+
@custom-variant dark (&:is(.dark *));
|
|
24303
|
+
|
|
24304
|
+
@theme inline {
|
|
24305
|
+
--color-background: hsl(var(--background));
|
|
24306
|
+
--color-foreground: hsl(var(--foreground));
|
|
24307
|
+
--color-muted: hsl(var(--muted));
|
|
24308
|
+
--color-muted-foreground: hsl(var(--muted-foreground));
|
|
24309
|
+
--color-popover: hsl(var(--popover));
|
|
24310
|
+
--color-popover-foreground: hsl(var(--popover-foreground));
|
|
24311
|
+
--color-card: hsl(var(--card));
|
|
24312
|
+
--color-card-foreground: hsl(var(--card-foreground));
|
|
24313
|
+
--color-border: hsl(var(--border));
|
|
24314
|
+
--color-input: hsl(var(--input));
|
|
24315
|
+
--color-primary: hsl(var(--primary));
|
|
24316
|
+
--color-primary-foreground: hsl(var(--primary-foreground));
|
|
24317
|
+
--color-secondary: hsl(var(--secondary));
|
|
24318
|
+
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
|
24319
|
+
--color-destructive: hsl(var(--destructive));
|
|
24320
|
+
--color-destructive-foreground: hsl(var(--destructive-foreground));
|
|
24321
|
+
--color-ring: hsl(var(--ring));
|
|
24322
|
+
|
|
24323
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
24324
|
+
--radius-lg: var(--radius);
|
|
24325
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
24326
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
24327
|
+
--radius-xs: min(calc(var(--radius) / 2.5), 6px);
|
|
24328
|
+
|
|
24329
|
+
--animate-accordion-down: accordion-down 0.2s ease-out;
|
|
24330
|
+
--animate-accordion-up: accordion-up 0.2s ease-out;
|
|
24331
|
+
--animate-collapsible-down: collapsible-down 0.2s ease-in-out;
|
|
24332
|
+
--animate-collapsible-up: collapsible-up 0.2s ease-in-out;
|
|
24333
|
+
|
|
24334
|
+
@keyframes accordion-down {
|
|
24335
|
+
from {
|
|
24336
|
+
height: 0;
|
|
24337
|
+
}
|
|
24338
|
+
to {
|
|
24339
|
+
height: var(--reka-accordion-content-height);
|
|
24340
|
+
}
|
|
24341
|
+
}
|
|
24342
|
+
|
|
24343
|
+
@keyframes accordion-up {
|
|
24344
|
+
from {
|
|
24345
|
+
height: var(--reka-accordion-content-height);
|
|
24346
|
+
}
|
|
24347
|
+
to {
|
|
24348
|
+
height: 0;
|
|
24349
|
+
}
|
|
24350
|
+
}
|
|
24351
|
+
|
|
24352
|
+
@keyframes collapsible-down {
|
|
24353
|
+
from {
|
|
24354
|
+
height: 0;
|
|
24355
|
+
}
|
|
24356
|
+
to {
|
|
24357
|
+
height: var(--reka-collapsible-content-height);
|
|
24358
|
+
}
|
|
24359
|
+
}
|
|
24360
|
+
|
|
24361
|
+
@keyframes collapsible-up {
|
|
24362
|
+
from {
|
|
24363
|
+
height: var(--reka-collapsible-content-height);
|
|
24364
|
+
}
|
|
24365
|
+
to {
|
|
24366
|
+
height: 0;
|
|
24367
|
+
}
|
|
24368
|
+
}
|
|
24369
|
+
}
|
|
24370
|
+
|
|
24371
|
+
@layer base {
|
|
24372
|
+
:root {
|
|
24373
|
+
--backdrop-filter-blur: 32px;
|
|
24374
|
+
--radius: 0.5rem;
|
|
24375
|
+
|
|
24376
|
+
<%- cssVarsLight %>
|
|
24377
|
+
}
|
|
24378
|
+
|
|
24379
|
+
.dark {
|
|
24380
|
+
<%- cssVarsDark %>
|
|
24381
|
+
}
|
|
24382
|
+
|
|
24383
|
+
* {
|
|
24384
|
+
@apply border-border;
|
|
24385
|
+
}
|
|
24386
|
+
|
|
24387
|
+
body {
|
|
24388
|
+
@apply bg-background text-foreground;
|
|
24389
|
+
}
|
|
24390
|
+
}
|
|
24391
|
+
`;
|
|
24392
|
+
var TAILWIND_KEYFRAMES_JS = `
|
|
24393
|
+
"sigma-ui-fade-in": {
|
|
24202
24394
|
from: { opacity: 0 },
|
|
24203
24395
|
to: { opacity: 1 },
|
|
24204
24396
|
},
|
|
24205
|
-
"accordion-down": {
|
|
24397
|
+
"sigma-ui-accordion-down": {
|
|
24206
24398
|
from: { height: 0 },
|
|
24207
24399
|
to: { height: "var(--reka-accordion-content-height)" },
|
|
24208
24400
|
},
|
|
24209
|
-
"accordion-up": {
|
|
24401
|
+
"sigma-ui-accordion-up": {
|
|
24210
24402
|
from: { height: "var(--reka-accordion-content-height)" },
|
|
24211
24403
|
to: { height: 0 },
|
|
24212
24404
|
},
|
|
24213
|
-
"collapsible-down": {
|
|
24405
|
+
"sigma-ui-collapsible-down": {
|
|
24214
24406
|
from: { height: 0 },
|
|
24215
|
-
to: { height:
|
|
24407
|
+
to: { height: "var(--reka-collapsible-content-height)" },
|
|
24216
24408
|
},
|
|
24217
|
-
"collapsible-up": {
|
|
24218
|
-
from: { height:
|
|
24409
|
+
"sigma-ui-collapsible-up": {
|
|
24410
|
+
from: { height: "var(--reka-collapsible-content-height)" },
|
|
24219
24411
|
to: { height: 0 },
|
|
24220
24412
|
},
|
|
24413
|
+
"sigma-ui-popover-slide-blur-from-top": {
|
|
24414
|
+
from: { opacity: 0, transform: "translateY(-1rem) scaleY(0.98)", filter: "blur(4px)" },
|
|
24415
|
+
to: { opacity: 1, transform: "translateY(0) scaleY(1)", filter: "blur(0px)" },
|
|
24416
|
+
},
|
|
24417
|
+
"sigma-ui-popover-slide-blur-from-bottom": {
|
|
24418
|
+
from: { opacity: 0, transform: "translateY(1rem) scaleY(0.98)", filter: "blur(4px)" },
|
|
24419
|
+
to: { opacity: 1, transform: "translateY(0) scaleY(1)", filter: "blur(0px)" },
|
|
24420
|
+
},
|
|
24421
|
+
"sigma-ui-popover-slide-blur-from-left": {
|
|
24422
|
+
from: { opacity: 0, transform: "translateX(-1rem) scaleY(0.98)", filter: "blur(4px)" },
|
|
24423
|
+
to: { opacity: 1, transform: "translateX(0) scaleY(1)", filter: "blur(0px)" },
|
|
24424
|
+
},
|
|
24425
|
+
"sigma-ui-popover-slide-blur-from-right": {
|
|
24426
|
+
from: { opacity: 0, transform: "translateX(1rem) scaleY(0.98)", filter: "blur(4px)" },
|
|
24427
|
+
to: { opacity: 1, transform: "translateX(0) scaleY(1)", filter: "blur(0px)" },
|
|
24428
|
+
},
|
|
24429
|
+
"sigma-ui-popover-fade-scale-blur-out": {
|
|
24430
|
+
from: { opacity: 1, transform: "scaleY(1)", filter: "blur(0px)" },
|
|
24431
|
+
to: { opacity: 0, transform: "scaleY(0.98)", filter: "blur(4px)" },
|
|
24432
|
+
},
|
|
24221
24433
|
`;
|
|
24222
|
-
var
|
|
24223
|
-
"fade-in": "fade-in 0.5s ease-in-out",
|
|
24224
|
-
"accordion-down": "accordion-down 0.2s ease-out",
|
|
24225
|
-
"accordion-up": "accordion-up 0.2s ease-out",
|
|
24226
|
-
"collapsible-down": "collapsible-down 0.2s ease-in-out",
|
|
24227
|
-
"collapsible-up": "collapsible-up 0.2s ease-in-out",
|
|
24228
|
-
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24232
|
-
|
|
24233
|
-
return twMerge(clsx(inputs))
|
|
24234
|
-
}
|
|
24434
|
+
var TAILWIND_ANIMATION_JS = `
|
|
24435
|
+
"fade-in": "sigma-ui-fade-in 0.5s ease-in-out",
|
|
24436
|
+
"accordion-down": "sigma-ui-accordion-down 0.2s ease-out",
|
|
24437
|
+
"accordion-up": "sigma-ui-accordion-up 0.2s ease-out",
|
|
24438
|
+
"collapsible-down": "sigma-ui-collapsible-down 0.2s ease-in-out",
|
|
24439
|
+
"collapsible-up": "sigma-ui-collapsible-up 0.2s ease-in-out",
|
|
24440
|
+
"popover-slide-blur-from-top": "sigma-ui-popover-slide-blur-from-top 150ms ease-out",
|
|
24441
|
+
"popover-slide-blur-from-bottom": "sigma-ui-popover-slide-blur-from-bottom 150ms ease-out",
|
|
24442
|
+
"popover-slide-blur-from-left": "sigma-ui-popover-slide-blur-from-left 150ms ease-out",
|
|
24443
|
+
"popover-slide-blur-from-right": "sigma-ui-popover-slide-blur-from-right 150ms ease-out",
|
|
24444
|
+
"popover-fade-scale-blur-out": "sigma-ui-popover-fade-scale-blur-out 150ms ease-in",
|
|
24235
24445
|
`;
|
|
24236
|
-
var
|
|
24446
|
+
var TAILWIND_CONFIG_JS_TEMPLATE = `const animate = require("tailwindcss-animate")
|
|
24237
24447
|
|
|
24238
24448
|
/** @type {import('tailwindcss').Config} */
|
|
24239
24449
|
module.exports = {
|
|
@@ -24307,15 +24517,39 @@ module.exports = {
|
|
|
24307
24517
|
xs: 'min(calc(var(--radius) / 2.5), 6px)',
|
|
24308
24518
|
},
|
|
24309
24519
|
keyframes: {
|
|
24310
|
-
${
|
|
24520
|
+
${TAILWIND_KEYFRAMES_JS}
|
|
24311
24521
|
},
|
|
24312
24522
|
animation: {
|
|
24313
|
-
${
|
|
24523
|
+
${TAILWIND_ANIMATION_JS}
|
|
24314
24524
|
},
|
|
24315
24525
|
},
|
|
24316
24526
|
},
|
|
24317
24527
|
plugins: [animate],
|
|
24318
24528
|
}`;
|
|
24529
|
+
var TAILWIND_CSS_WITH_JS_CONFIG_TEMPLATE = `@import "tailwindcss";
|
|
24530
|
+
@config "<%- configPath %>";
|
|
24531
|
+
|
|
24532
|
+
@layer base {
|
|
24533
|
+
:root {
|
|
24534
|
+
--backdrop-filter-blur: 32px;
|
|
24535
|
+
--radius: 0.5rem;
|
|
24536
|
+
|
|
24537
|
+
<%- cssVarsLight %>
|
|
24538
|
+
}
|
|
24539
|
+
|
|
24540
|
+
.dark {
|
|
24541
|
+
<%- cssVarsDark %>
|
|
24542
|
+
}
|
|
24543
|
+
|
|
24544
|
+
* {
|
|
24545
|
+
@apply border-border;
|
|
24546
|
+
}
|
|
24547
|
+
|
|
24548
|
+
body {
|
|
24549
|
+
@apply bg-background text-foreground;
|
|
24550
|
+
}
|
|
24551
|
+
}
|
|
24552
|
+
`;
|
|
24319
24553
|
|
|
24320
24554
|
// ../shared/templates/preflight.ts
|
|
24321
24555
|
var PREFLIGHT_CSS_TEMPLATE = `
|
|
@@ -24734,22 +24968,19 @@ var PROJECT_DEV_DEPENDENCIES = {
|
|
|
24734
24968
|
]
|
|
24735
24969
|
}
|
|
24736
24970
|
};
|
|
24737
|
-
var init = new Command3().name("init").description("initialize your project and install dependencies").option("-y, --yes", "skip confirmation prompt.", false).option(
|
|
24971
|
+
var init = new Command3().name("init").description("initialize your project and install dependencies").option("-y, --yes", "skip confirmation prompt.", false).option("-d, --defaults", "use default configuration without prompts.", false).option(
|
|
24738
24972
|
"-c, --cwd <cwd>",
|
|
24739
24973
|
"the working directory. defaults to the current directory.",
|
|
24740
24974
|
process5.cwd()
|
|
24741
24975
|
).action(async (opts) => {
|
|
24742
24976
|
try {
|
|
24743
|
-
const spinner = ora2("Fetching data...").start();
|
|
24744
24977
|
const options8 = initOptionsSchema.parse(opts);
|
|
24745
24978
|
const cwd = path14.resolve(options8.cwd);
|
|
24746
|
-
if (!
|
|
24979
|
+
if (!existsSync6(cwd)) {
|
|
24747
24980
|
consola5.error(`The path ${cwd} does not exist. Please try again.`);
|
|
24748
24981
|
process5.exit(1);
|
|
24749
24982
|
}
|
|
24750
|
-
const
|
|
24751
|
-
spinner.stop();
|
|
24752
|
-
const config = await promptForConfig(cwd, existingConfig, options8.yes);
|
|
24983
|
+
const config = await promptForConfig(cwd, options8.yes, options8.defaults);
|
|
24753
24984
|
await runInit(cwd, config);
|
|
24754
24985
|
consola5.log("");
|
|
24755
24986
|
consola5.info(
|
|
@@ -24760,115 +24991,111 @@ var init = new Command3().name("init").description("initialize your project and
|
|
|
24760
24991
|
handleError(error);
|
|
24761
24992
|
}
|
|
24762
24993
|
});
|
|
24763
|
-
|
|
24994
|
+
function getDetectedConfig(projectInfo) {
|
|
24995
|
+
const { framework, tsConfigPath, hasTailwind, tailwindConfigType, tailwindConfigPath } = projectInfo;
|
|
24996
|
+
return {
|
|
24997
|
+
framework,
|
|
24998
|
+
tsConfigPath,
|
|
24999
|
+
cssPath: TAILWIND_CSS_PATH[framework],
|
|
25000
|
+
tailwindConfigPath: tailwindConfigPath ?? (framework === "astro" ? "tailwind.config.mjs" : DEFAULT_TAILWIND_CONFIG),
|
|
25001
|
+
tailwindConfigType,
|
|
25002
|
+
setupTailwind: !hasTailwind
|
|
25003
|
+
};
|
|
25004
|
+
}
|
|
25005
|
+
async function promptForConfig(cwd, skipConfirmation = false, useDefaults = false) {
|
|
24764
25006
|
const highlight = (text) => colors4.cyan(text);
|
|
25007
|
+
const spinner = ora2("Detecting project settings...").start();
|
|
25008
|
+
const projectInfo = await getProjectInfo(cwd);
|
|
25009
|
+
const detectedConfig = getDetectedConfig(projectInfo);
|
|
24765
25010
|
const styles3 = await getRegistryStyles();
|
|
24766
25011
|
const baseColors2 = await getRegistryBaseColors();
|
|
25012
|
+
spinner.stop();
|
|
25013
|
+
consola5.info(`Detected ${highlight(detectedConfig.framework)} project`);
|
|
25014
|
+
if (useDefaults) {
|
|
25015
|
+
const config2 = createConfig({
|
|
25016
|
+
framework: detectedConfig.framework,
|
|
25017
|
+
styleSystem: "tailwind",
|
|
25018
|
+
tailwindBaseColor: "grayscale",
|
|
25019
|
+
componentNaming: "pascal-case",
|
|
25020
|
+
tsConfigPath: detectedConfig.tsConfigPath,
|
|
25021
|
+
cssPath: detectedConfig.cssPath,
|
|
25022
|
+
tailwindConfigPath: detectedConfig.tailwindConfigPath,
|
|
25023
|
+
tailwindConfigType: detectedConfig.tailwindConfigType,
|
|
25024
|
+
setupTailwind: detectedConfig.setupTailwind,
|
|
25025
|
+
components: DEFAULT_COMPONENTS,
|
|
25026
|
+
utils: DEFAULT_UTILS,
|
|
25027
|
+
generatePreflight: true
|
|
25028
|
+
});
|
|
25029
|
+
await writeConfigFile(cwd, config2);
|
|
25030
|
+
return await resolveConfigPaths(cwd, config2);
|
|
25031
|
+
}
|
|
24767
25032
|
const options8 = await prompts2([
|
|
24768
|
-
{
|
|
24769
|
-
type: "select",
|
|
24770
|
-
name: "framework",
|
|
24771
|
-
message: `Which ${highlight("framework")} are you using?`,
|
|
24772
|
-
choices: [
|
|
24773
|
-
{ title: "Vite", value: "vite" },
|
|
24774
|
-
{ title: "Nuxt", value: "nuxt" },
|
|
24775
|
-
{ title: "Laravel", value: "laravel" },
|
|
24776
|
-
{ title: "Astro", value: "astro" }
|
|
24777
|
-
]
|
|
24778
|
-
},
|
|
24779
25033
|
{
|
|
24780
25034
|
type: "select",
|
|
24781
25035
|
name: "styleSystem",
|
|
24782
|
-
message: `Which ${highlight("style system")}
|
|
25036
|
+
message: `Which ${highlight("style system")} would you like to use?`,
|
|
24783
25037
|
choices: styles3.map((style) => ({
|
|
24784
25038
|
title: style.label,
|
|
24785
25039
|
value: style.name
|
|
24786
25040
|
}))
|
|
24787
25041
|
},
|
|
24788
|
-
{
|
|
24789
|
-
type: (_, answers) => answers.styleSystem === "tailwind" ? "toggle" : null,
|
|
24790
|
-
name: "setupTailwind",
|
|
24791
|
-
message: `Setup ${highlight("Tailwind")} in this project for you?`,
|
|
24792
|
-
initial: !defaultConfig?.tailwind.config,
|
|
24793
|
-
active: "yes",
|
|
24794
|
-
inactive: "no"
|
|
24795
|
-
},
|
|
24796
25042
|
{
|
|
24797
25043
|
type: "select",
|
|
24798
25044
|
name: "tailwindBaseColor",
|
|
24799
|
-
message: `Choose
|
|
25045
|
+
message: `Choose a ${highlight("base color")} for your theme:`,
|
|
24800
25046
|
choices: baseColors2.map((color) => ({
|
|
24801
25047
|
title: color.label,
|
|
24802
25048
|
value: color.name
|
|
24803
25049
|
}))
|
|
24804
25050
|
},
|
|
24805
25051
|
{
|
|
24806
|
-
type:
|
|
24807
|
-
name: "
|
|
24808
|
-
message: `
|
|
24809
|
-
|
|
24810
|
-
|
|
24811
|
-
|
|
24812
|
-
|
|
24813
|
-
|
|
24814
|
-
return "tailwind.config.mjs";
|
|
24815
|
-
} else {
|
|
24816
|
-
return DEFAULT_TAILWIND_CONFIG;
|
|
24817
|
-
}
|
|
24818
|
-
}
|
|
24819
|
-
},
|
|
24820
|
-
{
|
|
24821
|
-
type: "text",
|
|
24822
|
-
name: "tsConfigPath",
|
|
24823
|
-
message: `Specify the path to ${highlight("tsconfig")} file`,
|
|
24824
|
-
initial: (_, values) => {
|
|
24825
|
-
const prefix = values.framework === "nuxt" ? ".nuxt/" : "./";
|
|
24826
|
-
return `${prefix}tsconfig.json`;
|
|
24827
|
-
}
|
|
24828
|
-
},
|
|
24829
|
-
{
|
|
24830
|
-
type: "text",
|
|
24831
|
-
name: "cssPath",
|
|
24832
|
-
message: `Specify the path to ${highlight("global CSS")} file ${colors4.gray("(it will be overwritten / created)")}`,
|
|
24833
|
-
initial: (_, values) => defaultConfig?.cssPath ?? TAILWIND_CSS_PATH[values.framework]
|
|
24834
|
-
},
|
|
24835
|
-
{
|
|
24836
|
-
type: "text",
|
|
24837
|
-
name: "components",
|
|
24838
|
-
message: `Configure the import alias for ${highlight("components")}:`,
|
|
24839
|
-
initial: defaultConfig?.aliases.components ?? DEFAULT_COMPONENTS
|
|
24840
|
-
},
|
|
24841
|
-
{
|
|
24842
|
-
type: (_, answers) => answers.styleSystem === "tailwind" ? "text" : null,
|
|
24843
|
-
name: "utils",
|
|
24844
|
-
message: `Configure the import alias for ${highlight("utils")}:`,
|
|
24845
|
-
initial: defaultConfig?.aliases.utils ?? DEFAULT_UTILS
|
|
24846
|
-
},
|
|
24847
|
-
{
|
|
24848
|
-
type: (_, answers) => answers.styleSystem === "css" ? "toggle" : null,
|
|
24849
|
-
name: "generatePreflight",
|
|
24850
|
-
message: `Generate ${highlight("preflight.css")} with modern CSS reset? ${colors4.gray("(recommended)")}`,
|
|
24851
|
-
initial: true,
|
|
24852
|
-
active: "yes",
|
|
24853
|
-
inactive: "no"
|
|
25052
|
+
type: "select",
|
|
25053
|
+
name: "componentNaming",
|
|
25054
|
+
message: `Choose ${highlight("component naming")} convention:`,
|
|
25055
|
+
choices: [
|
|
25056
|
+
{ title: "PascalCase (Button.vue)", value: "pascal-case" },
|
|
25057
|
+
{ title: "kebab-case (button.vue)", value: "kebab-case" }
|
|
25058
|
+
],
|
|
25059
|
+
initial: 0
|
|
24854
25060
|
}
|
|
24855
25061
|
]);
|
|
24856
|
-
if (!
|
|
25062
|
+
if (!skipConfirmation) {
|
|
25063
|
+
consola5.log("");
|
|
25064
|
+
consola5.box(
|
|
25065
|
+
`Framework: ${highlight(detectedConfig.framework)}
|
|
25066
|
+
Style: ${highlight(options8.styleSystem)}
|
|
25067
|
+
Theme: ${highlight(options8.tailwindBaseColor)}
|
|
25068
|
+
Naming: ${highlight(options8.componentNaming)}
|
|
25069
|
+
CSS: ${highlight(detectedConfig.cssPath)}
|
|
25070
|
+
Components: ${highlight(DEFAULT_COMPONENTS)}`
|
|
25071
|
+
);
|
|
24857
25072
|
const { proceed } = await prompts2({
|
|
24858
25073
|
type: "confirm",
|
|
24859
25074
|
name: "proceed",
|
|
24860
|
-
message:
|
|
25075
|
+
message: "Proceed with installation?",
|
|
24861
25076
|
initial: true
|
|
24862
25077
|
});
|
|
24863
25078
|
if (!proceed) {
|
|
24864
25079
|
process5.exit(0);
|
|
24865
25080
|
}
|
|
24866
25081
|
}
|
|
24867
|
-
const config = createConfig(
|
|
25082
|
+
const config = createConfig({
|
|
25083
|
+
...options8,
|
|
25084
|
+
framework: detectedConfig.framework,
|
|
25085
|
+
tsConfigPath: detectedConfig.tsConfigPath,
|
|
25086
|
+
cssPath: detectedConfig.cssPath,
|
|
25087
|
+
tailwindConfigPath: options8.styleSystem === "tailwind" ? detectedConfig.tailwindConfigPath : "",
|
|
25088
|
+
tailwindConfigType: detectedConfig.tailwindConfigType,
|
|
25089
|
+
setupTailwind: options8.styleSystem === "tailwind" ? detectedConfig.setupTailwind : false,
|
|
25090
|
+
components: DEFAULT_COMPONENTS,
|
|
25091
|
+
utils: DEFAULT_UTILS,
|
|
25092
|
+
generatePreflight: options8.styleSystem === "css"
|
|
25093
|
+
});
|
|
24868
25094
|
await writeConfigFile(cwd, config);
|
|
24869
25095
|
return await resolveConfigPaths(cwd, config);
|
|
24870
25096
|
}
|
|
24871
25097
|
function createConfig(options8) {
|
|
25098
|
+
const usesJsConfig = options8.tailwindConfigType === "js";
|
|
24872
25099
|
const config = rawConfigSchema.parse({
|
|
24873
25100
|
$schema: "https://sigma-ui.dev/schema.json",
|
|
24874
25101
|
styleSystem: options8.styleSystem,
|
|
@@ -24878,13 +25105,14 @@ function createConfig(options8) {
|
|
|
24878
25105
|
cssPath: options8.cssPath,
|
|
24879
25106
|
baseColor: options8.tailwindBaseColor,
|
|
24880
25107
|
tailwind: {
|
|
24881
|
-
config: options8.
|
|
25108
|
+
config: usesJsConfig ? options8.tailwindConfigPath : ""
|
|
24882
25109
|
},
|
|
24883
25110
|
aliases: {
|
|
24884
25111
|
utils: options8.utils || "",
|
|
24885
25112
|
components: options8.components
|
|
24886
25113
|
},
|
|
24887
|
-
generatePreflight: options8.generatePreflight
|
|
25114
|
+
generatePreflight: options8.generatePreflight,
|
|
25115
|
+
componentNaming: options8.componentNaming || "pascal-case"
|
|
24888
25116
|
});
|
|
24889
25117
|
return config;
|
|
24890
25118
|
}
|
|
@@ -24895,34 +25123,39 @@ async function writeConfigFile(cwd, config) {
|
|
|
24895
25123
|
await fs8.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
|
|
24896
25124
|
spinner.succeed();
|
|
24897
25125
|
}
|
|
24898
|
-
async function handleNuxtProject() {
|
|
24899
|
-
const
|
|
24900
|
-
if (
|
|
25126
|
+
async function handleNuxtProject(cwd) {
|
|
25127
|
+
const projectInfo = await getProjectInfo(cwd);
|
|
25128
|
+
if (projectInfo.framework === "nuxt") {
|
|
24901
25129
|
consola5.log("");
|
|
24902
|
-
|
|
25130
|
+
if (projectInfo.sigmaUiNuxtModuleInfo) {
|
|
25131
|
+
consola5.info(`Detected a Nuxt project with 'sigma-ui-nuxt' v${projectInfo.sigmaUiNuxtModuleInfo.version}`);
|
|
25132
|
+
} else {
|
|
25133
|
+
consola5.warn(`Detected a Nuxt project without 'sigma-ui-nuxt' module. It's recommended to install it.`);
|
|
25134
|
+
}
|
|
24903
25135
|
}
|
|
24904
25136
|
}
|
|
24905
25137
|
async function runInit(cwd, config) {
|
|
24906
|
-
await writeFiles(config);
|
|
25138
|
+
await writeFiles(config, cwd);
|
|
24907
25139
|
await installDependencies2(config, cwd);
|
|
24908
25140
|
}
|
|
24909
|
-
async function writeFiles(config) {
|
|
25141
|
+
async function writeFiles(config, cwd) {
|
|
24910
25142
|
const writeFilesSpinner = ora2("Initializing project")?.start();
|
|
24911
|
-
await handleNuxtProject();
|
|
25143
|
+
await handleNuxtProject(cwd);
|
|
24912
25144
|
await ensureDirectoriesExist(config);
|
|
24913
|
-
|
|
24914
|
-
|
|
24915
|
-
|
|
24916
|
-
|
|
24917
|
-
|
|
25145
|
+
const hasJsConfig = Boolean(config.tailwind.config && config.tailwind.config.length > 0);
|
|
25146
|
+
if (hasJsConfig) {
|
|
25147
|
+
await writeTailwindJsConfig(config);
|
|
25148
|
+
}
|
|
25149
|
+
if (config.framework === "vite" && config.setupTailwind) {
|
|
25150
|
+
await updateViteConfig();
|
|
24918
25151
|
}
|
|
24919
|
-
writeCssFile(config);
|
|
25152
|
+
await writeCssFile(config, hasJsConfig);
|
|
24920
25153
|
writeCnFile(config);
|
|
24921
25154
|
await writePreflightCss(config);
|
|
24922
25155
|
writeFilesSpinner?.succeed();
|
|
24923
25156
|
}
|
|
24924
|
-
async function
|
|
24925
|
-
const unformattedConfig = template(
|
|
25157
|
+
async function writeTailwindJsConfig(config) {
|
|
25158
|
+
const unformattedConfig = template(TAILWIND_CONFIG_JS_TEMPLATE)({
|
|
24926
25159
|
framework: config.framework,
|
|
24927
25160
|
prefix: config.tailwind.prefix,
|
|
24928
25161
|
extension: "ts"
|
|
@@ -24943,23 +25176,47 @@ async function writeTailwindConfig(config) {
|
|
|
24943
25176
|
"utf8"
|
|
24944
25177
|
);
|
|
24945
25178
|
}
|
|
24946
|
-
async function writeCssFile(config) {
|
|
25179
|
+
async function writeCssFile(config, hasJsConfig) {
|
|
24947
25180
|
const baseColorData = await getRegistryBaseColor(config.baseColor);
|
|
24948
|
-
if (baseColorData) {
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
|
|
24955
|
-
|
|
24956
|
-
|
|
25181
|
+
if (!baseColorData) {
|
|
25182
|
+
return;
|
|
25183
|
+
}
|
|
25184
|
+
const file = config.resolvedPaths.tailwindCss;
|
|
25185
|
+
let data = "";
|
|
25186
|
+
if (config.styleSystem === "tailwind") {
|
|
25187
|
+
const cssVarsLight = generateCssVars(baseColorData.cssVars.light);
|
|
25188
|
+
const cssVarsDark = generateCssVars(baseColorData.cssVars.dark);
|
|
25189
|
+
if (hasJsConfig) {
|
|
25190
|
+
data = template(TAILWIND_CSS_WITH_JS_CONFIG_TEMPLATE)({
|
|
25191
|
+
configPath: config.tailwind.config,
|
|
25192
|
+
cssVarsLight,
|
|
25193
|
+
cssVarsDark
|
|
25194
|
+
});
|
|
25195
|
+
} else {
|
|
25196
|
+
data = template(TAILWIND_V4_CSS_TEMPLATE)({
|
|
25197
|
+
cssVarsLight,
|
|
25198
|
+
cssVarsDark
|
|
25199
|
+
});
|
|
25200
|
+
}
|
|
25201
|
+
if (config.tailwind.prefix) {
|
|
25202
|
+
data = applyPrefixesCss(data, config.tailwind.prefix);
|
|
25203
|
+
}
|
|
25204
|
+
} else if (config.styleSystem === "css") {
|
|
25205
|
+
data = baseColorData.templates.css.withVariables;
|
|
25206
|
+
if (config.generatePreflight) {
|
|
25207
|
+
data = `@import "./preflight.css";
|
|
24957
25208
|
|
|
24958
25209
|
${data}`;
|
|
24959
|
-
}
|
|
24960
25210
|
}
|
|
24961
|
-
await fs8.writeFile(file, data, "utf8");
|
|
24962
25211
|
}
|
|
25212
|
+
const formattedCss = await src_default.format(data, {
|
|
25213
|
+
parser: "css",
|
|
25214
|
+
singleQuote: true
|
|
25215
|
+
});
|
|
25216
|
+
await fs8.writeFile(file, formattedCss, "utf8");
|
|
25217
|
+
}
|
|
25218
|
+
function generateCssVars(vars) {
|
|
25219
|
+
return Object.entries(vars).map(([key2, value]) => `--${key2}: ${value};`).join("\n ");
|
|
24963
25220
|
}
|
|
24964
25221
|
async function writeCnFile(config) {
|
|
24965
25222
|
if (config.resolvedPaths.utils) {
|
|
@@ -24981,11 +25238,11 @@ async function writePreflightCss(config) {
|
|
|
24981
25238
|
}
|
|
24982
25239
|
}
|
|
24983
25240
|
async function installDependencies2(config, cwd) {
|
|
24984
|
-
const
|
|
25241
|
+
const projectInfo = await getProjectInfo(cwd);
|
|
24985
25242
|
const dependenciesSpinner = ora2("Installing dependencies")?.start();
|
|
24986
25243
|
let baseDeps = [];
|
|
24987
25244
|
let baseDevDeps = [];
|
|
24988
|
-
if (sigmaUiNuxtModuleInfo?.version) {
|
|
25245
|
+
if (projectInfo.sigmaUiNuxtModuleInfo?.version) {
|
|
24989
25246
|
baseDeps = [];
|
|
24990
25247
|
} else {
|
|
24991
25248
|
if (config.styleSystem === "css") {
|
|
@@ -25000,50 +25257,17 @@ async function installDependencies2(config, cwd) {
|
|
|
25000
25257
|
const deps = [...baseDeps, ...PROJECT_DEPENDENCIES.sharedBase].filter(Boolean);
|
|
25001
25258
|
const devDeps = baseDevDeps.filter(Boolean);
|
|
25002
25259
|
const installTasks = [
|
|
25003
|
-
config.framework === "nuxt" && PROJECT_DEPENDENCIES.nuxt.length && { type: "devDependencies", deps: PROJECT_DEPENDENCIES.nuxt, installer:
|
|
25004
|
-
deps.length && { type: "dependencies", deps, installer:
|
|
25005
|
-
devDeps.length && { type: "devDependencies", deps: devDeps, installer:
|
|
25260
|
+
config.framework === "nuxt" && PROJECT_DEPENDENCIES.nuxt.length && { type: "devDependencies", deps: PROJECT_DEPENDENCIES.nuxt, installer: addDevDependency },
|
|
25261
|
+
deps.length && { type: "dependencies", deps, installer: addDependency },
|
|
25262
|
+
devDeps.length && { type: "devDependencies", deps: devDeps, installer: addDevDependency }
|
|
25006
25263
|
].filter(Boolean);
|
|
25007
25264
|
for (const task of installTasks) {
|
|
25008
25265
|
try {
|
|
25009
25266
|
dependenciesSpinner.text = `Installing ${task.type}...`;
|
|
25010
25267
|
await task.installer(task.deps, { cwd, silent: true });
|
|
25011
25268
|
} catch (error) {
|
|
25012
|
-
|
|
25013
|
-
|
|
25014
|
-
if (isCorepackError) {
|
|
25015
|
-
consola5.info(`Falling back to direct package manager execution for ${task.type}...`);
|
|
25016
|
-
const pm = await detectPackageManager2(cwd);
|
|
25017
|
-
let command = "";
|
|
25018
|
-
const depsString = task.deps.join(" ");
|
|
25019
|
-
const devFlag = task.type === "devDependencies" ? "-D " : "";
|
|
25020
|
-
switch (pm?.name) {
|
|
25021
|
-
case "npm":
|
|
25022
|
-
command = `npm install ${devFlag}${depsString}`;
|
|
25023
|
-
break;
|
|
25024
|
-
case "yarn":
|
|
25025
|
-
command = `yarn add ${devFlag}${depsString}`;
|
|
25026
|
-
break;
|
|
25027
|
-
case "bun":
|
|
25028
|
-
command = `bun add ${devFlag}${depsString}`;
|
|
25029
|
-
break;
|
|
25030
|
-
case "pnpm":
|
|
25031
|
-
default:
|
|
25032
|
-
command = `pnpm add ${devFlag}${depsString}`;
|
|
25033
|
-
break;
|
|
25034
|
-
}
|
|
25035
|
-
try {
|
|
25036
|
-
consola5.info(`Running: ${command}`);
|
|
25037
|
-
execSync2(command, { cwd, stdio: "inherit" });
|
|
25038
|
-
consola5.success(`Successfully installed ${task.type} using direct package manager execution.`);
|
|
25039
|
-
} catch (fallbackError) {
|
|
25040
|
-
const errorMessage = fallbackError instanceof Error ? fallbackError.message : "Unknown error";
|
|
25041
|
-
consola5.error(`Fallback package manager execution failed for ${task.type}:`, errorMessage);
|
|
25042
|
-
}
|
|
25043
|
-
} else {
|
|
25044
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
25045
|
-
consola5.error(`Failed to install ${task.type} using nypm: ${errorMessage}`);
|
|
25046
|
-
}
|
|
25269
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
25270
|
+
consola5.error(`Failed to install ${task.type}: ${errorMessage}`);
|
|
25047
25271
|
}
|
|
25048
25272
|
}
|
|
25049
25273
|
dependenciesSpinner?.succeed();
|
|
@@ -25075,7 +25299,7 @@ async function getDirectoryPath(key2, resolvedPath) {
|
|
|
25075
25299
|
}
|
|
25076
25300
|
async function updateViteConfig() {
|
|
25077
25301
|
const viteConfigPath = path14.join(process5.cwd(), "vite.config.ts");
|
|
25078
|
-
if (!
|
|
25302
|
+
if (!existsSync6(viteConfigPath)) {
|
|
25079
25303
|
consola5.warn(`Vite config file not found at ${viteConfigPath}`);
|
|
25080
25304
|
return;
|
|
25081
25305
|
}
|