shadcn-vue 2.0.0 → 2.0.1
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/index.js +750 -220
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/commands/init.ts
|
|
4
|
-
import { promises as
|
|
4
|
+
import { promises as fs9 } from "node:fs";
|
|
5
5
|
|
|
6
6
|
// src/utils/errors.ts
|
|
7
7
|
var MISSING_DIR_OR_EMPTY_PROJECT = "1";
|
|
@@ -9,6 +9,7 @@ var MISSING_CONFIG = "3";
|
|
|
9
9
|
var TAILWIND_NOT_CONFIGURED = "5";
|
|
10
10
|
var IMPORT_ALIAS_MISSING = "6";
|
|
11
11
|
var UNSUPPORTED_FRAMEWORK = "7";
|
|
12
|
+
var BUILD_MISSING_REGISTRY_FILE = "13";
|
|
12
13
|
|
|
13
14
|
// src/utils/frameworks.ts
|
|
14
15
|
var FRAMEWORKS = {
|
|
@@ -182,7 +183,6 @@ async function getRawConfig(cwd) {
|
|
|
182
183
|
}
|
|
183
184
|
return rawConfigSchema.parse(configResult.config);
|
|
184
185
|
} catch (error) {
|
|
185
|
-
console.log(error.message);
|
|
186
186
|
throw new Error(`Invalid configuration found in ${cwd}/components.json.`);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -544,41 +544,37 @@ Once configured, you can use the cli to add components.`
|
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
// src/
|
|
548
|
-
import { consola as consola2 } from "consola";
|
|
549
|
-
function handleError(error) {
|
|
550
|
-
consola2.log("this is error: ", error);
|
|
551
|
-
if (typeof error === "string") {
|
|
552
|
-
consola2.error(error);
|
|
553
|
-
process.exit(1);
|
|
554
|
-
}
|
|
555
|
-
if (error instanceof Error) {
|
|
556
|
-
consola2.error(error.message);
|
|
557
|
-
process.exit(1);
|
|
558
|
-
}
|
|
559
|
-
consola2.error("Something went wrong. Please try again.");
|
|
560
|
-
process.exit(1);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// src/utils/registry/schema.ts
|
|
547
|
+
// src/registry/schema.ts
|
|
564
548
|
import { z as z3 } from "zod";
|
|
565
549
|
var registryItemTypeSchema = z3.enum([
|
|
566
|
-
"registry:style",
|
|
567
550
|
"registry:lib",
|
|
568
|
-
"registry:example",
|
|
569
551
|
"registry:block",
|
|
570
552
|
"registry:component",
|
|
571
553
|
"registry:ui",
|
|
572
554
|
"registry:hook",
|
|
555
|
+
"registry:page",
|
|
556
|
+
"registry:file",
|
|
573
557
|
"registry:theme",
|
|
574
|
-
"registry:
|
|
558
|
+
"registry:style",
|
|
559
|
+
// Internal use only
|
|
560
|
+
"registry:example",
|
|
561
|
+
"registry:internal"
|
|
562
|
+
]);
|
|
563
|
+
var registryItemFileSchema = z3.discriminatedUnion("type", [
|
|
564
|
+
// Target is required for registry:file and registry:page
|
|
565
|
+
z3.object({
|
|
566
|
+
path: z3.string(),
|
|
567
|
+
content: z3.string().optional(),
|
|
568
|
+
type: z3.enum(["registry:file", "registry:page"]),
|
|
569
|
+
target: z3.string()
|
|
570
|
+
}),
|
|
571
|
+
z3.object({
|
|
572
|
+
path: z3.string(),
|
|
573
|
+
content: z3.string().optional(),
|
|
574
|
+
type: registryItemTypeSchema.exclude(["registry:file", "registry:page"]),
|
|
575
|
+
target: z3.string().optional()
|
|
576
|
+
})
|
|
575
577
|
]);
|
|
576
|
-
var registryItemFileSchema = z3.object({
|
|
577
|
-
path: z3.string(),
|
|
578
|
-
content: z3.string().optional(),
|
|
579
|
-
type: registryItemTypeSchema,
|
|
580
|
-
target: z3.string().optional()
|
|
581
|
-
});
|
|
582
578
|
var registryItemTailwindSchema = z3.object({
|
|
583
579
|
config: z3.object({
|
|
584
580
|
content: z3.array(z3.string()).optional(),
|
|
@@ -587,12 +583,29 @@ var registryItemTailwindSchema = z3.object({
|
|
|
587
583
|
}).optional()
|
|
588
584
|
});
|
|
589
585
|
var registryItemCssVarsSchema = z3.object({
|
|
586
|
+
theme: z3.record(z3.string(), z3.string()).optional(),
|
|
590
587
|
light: z3.record(z3.string(), z3.string()).optional(),
|
|
591
588
|
dark: z3.record(z3.string(), z3.string()).optional()
|
|
592
589
|
});
|
|
590
|
+
var registryItemCssSchema = z3.record(
|
|
591
|
+
z3.string(),
|
|
592
|
+
z3.lazy(
|
|
593
|
+
() => z3.union([
|
|
594
|
+
z3.string(),
|
|
595
|
+
z3.record(
|
|
596
|
+
z3.string(),
|
|
597
|
+
z3.union([z3.string(), z3.record(z3.string(), z3.string())])
|
|
598
|
+
)
|
|
599
|
+
])
|
|
600
|
+
)
|
|
601
|
+
);
|
|
593
602
|
var registryItemSchema = z3.object({
|
|
603
|
+
$schema: z3.string().optional(),
|
|
604
|
+
extends: z3.string().optional(),
|
|
594
605
|
name: z3.string(),
|
|
595
606
|
type: registryItemTypeSchema,
|
|
607
|
+
title: z3.string().optional(),
|
|
608
|
+
author: z3.string().min(2).optional(),
|
|
596
609
|
description: z3.string().optional(),
|
|
597
610
|
dependencies: z3.array(z3.string()).optional(),
|
|
598
611
|
devDependencies: z3.array(z3.string()).optional(),
|
|
@@ -600,14 +613,17 @@ var registryItemSchema = z3.object({
|
|
|
600
613
|
files: z3.array(registryItemFileSchema).optional(),
|
|
601
614
|
tailwind: registryItemTailwindSchema.optional(),
|
|
602
615
|
cssVars: registryItemCssVarsSchema.optional(),
|
|
616
|
+
css: registryItemCssSchema.optional(),
|
|
603
617
|
meta: z3.record(z3.string(), z3.any()).optional(),
|
|
604
|
-
docs: z3.string().optional()
|
|
618
|
+
docs: z3.string().optional(),
|
|
619
|
+
categories: z3.array(z3.string()).optional()
|
|
605
620
|
});
|
|
606
|
-
var
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
);
|
|
621
|
+
var registrySchema = z3.object({
|
|
622
|
+
name: z3.string(),
|
|
623
|
+
homepage: z3.string(),
|
|
624
|
+
items: z3.array(registryItemSchema)
|
|
625
|
+
});
|
|
626
|
+
var registryIndexSchema = z3.array(registryItemSchema);
|
|
611
627
|
var stylesSchema = z3.array(
|
|
612
628
|
z3.object({
|
|
613
629
|
name: z3.string(),
|
|
@@ -623,14 +639,8 @@ var registryBaseColorSchema = z3.object({
|
|
|
623
639
|
light: z3.record(z3.string(), z3.string()),
|
|
624
640
|
dark: z3.record(z3.string(), z3.string())
|
|
625
641
|
}),
|
|
626
|
-
cssVars:
|
|
627
|
-
|
|
628
|
-
dark: z3.record(z3.string(), z3.string())
|
|
629
|
-
}),
|
|
630
|
-
cssVarsV4: z3.object({
|
|
631
|
-
light: z3.record(z3.string(), z3.string()),
|
|
632
|
-
dark: z3.record(z3.string(), z3.string())
|
|
633
|
-
}).optional(),
|
|
642
|
+
cssVars: registryItemCssVarsSchema,
|
|
643
|
+
cssVarsV4: registryItemCssVarsSchema.optional(),
|
|
634
644
|
inlineColorsTemplate: z3.string(),
|
|
635
645
|
cssVarsTemplate: z3.string()
|
|
636
646
|
});
|
|
@@ -640,9 +650,26 @@ var registryResolvedItemsTreeSchema = registryItemSchema.pick({
|
|
|
640
650
|
files: true,
|
|
641
651
|
tailwind: true,
|
|
642
652
|
cssVars: true,
|
|
653
|
+
css: true,
|
|
643
654
|
docs: true
|
|
644
655
|
});
|
|
645
656
|
|
|
657
|
+
// src/utils/handle-error.ts
|
|
658
|
+
import { consola as consola2 } from "consola";
|
|
659
|
+
function handleError(error) {
|
|
660
|
+
consola2.log("this is error: ", error);
|
|
661
|
+
if (typeof error === "string") {
|
|
662
|
+
consola2.error(error);
|
|
663
|
+
process.exit(1);
|
|
664
|
+
}
|
|
665
|
+
if (error instanceof Error) {
|
|
666
|
+
consola2.error(error.message);
|
|
667
|
+
process.exit(1);
|
|
668
|
+
}
|
|
669
|
+
consola2.error("Something went wrong. Please try again.");
|
|
670
|
+
process.exit(1);
|
|
671
|
+
}
|
|
672
|
+
|
|
646
673
|
// src/utils/updaters/update-tailwind-config.ts
|
|
647
674
|
import { promises as fs4 } from "node:fs";
|
|
648
675
|
import { tmpdir } from "node:os";
|
|
@@ -999,7 +1026,7 @@ function buildTailwindThemeColorsFromCssVars(cssVars) {
|
|
|
999
1026
|
return result;
|
|
1000
1027
|
}
|
|
1001
1028
|
|
|
1002
|
-
// src/
|
|
1029
|
+
// src/registry/api.ts
|
|
1003
1030
|
import deepmerge2 from "deepmerge";
|
|
1004
1031
|
import { ofetch } from "ofetch";
|
|
1005
1032
|
import path6 from "pathe";
|
|
@@ -1007,6 +1034,7 @@ import { ProxyAgent } from "undici";
|
|
|
1007
1034
|
import { z as z4 } from "zod";
|
|
1008
1035
|
var REGISTRY_URL = process.env.REGISTRY_URL ?? "https://shadcn-vue.com/r";
|
|
1009
1036
|
var agent = process.env.https_proxy ? new ProxyAgent(process.env.https_proxy) : void 0;
|
|
1037
|
+
var registryCache = /* @__PURE__ */ new Map();
|
|
1010
1038
|
async function getRegistryIndex() {
|
|
1011
1039
|
try {
|
|
1012
1040
|
const [result] = await fetchRegistry(["index.json"]);
|
|
@@ -1035,6 +1063,18 @@ async function getRegistryIcons() {
|
|
|
1035
1063
|
return {};
|
|
1036
1064
|
}
|
|
1037
1065
|
}
|
|
1066
|
+
async function getRegistryItem(name, style) {
|
|
1067
|
+
try {
|
|
1068
|
+
const [result] = await fetchRegistry([
|
|
1069
|
+
isUrl(name) ? name : `styles/${style}/${name}.json`
|
|
1070
|
+
]);
|
|
1071
|
+
return registryItemSchema.parse(result);
|
|
1072
|
+
} catch (error) {
|
|
1073
|
+
logger.break();
|
|
1074
|
+
handleError(error);
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1038
1078
|
var BASE_COLORS = [
|
|
1039
1079
|
{
|
|
1040
1080
|
name: "neutral",
|
|
@@ -1096,11 +1136,15 @@ async function getItemTargetPath(config, item, override) {
|
|
|
1096
1136
|
async function fetchRegistry(paths) {
|
|
1097
1137
|
try {
|
|
1098
1138
|
const results = await Promise.all(
|
|
1099
|
-
paths.map(async (
|
|
1100
|
-
const url = getRegistryUrl(
|
|
1139
|
+
paths.map(async (path20) => {
|
|
1140
|
+
const url = getRegistryUrl(path20);
|
|
1141
|
+
if (registryCache.has(url)) {
|
|
1142
|
+
return registryCache.get(url);
|
|
1143
|
+
}
|
|
1101
1144
|
const response = await ofetch(url, { dispatcher: agent, parseResponse: JSON.parse }).catch((error) => {
|
|
1102
1145
|
throw new Error(error.data);
|
|
1103
1146
|
});
|
|
1147
|
+
registryCache.set(url, response);
|
|
1104
1148
|
return response;
|
|
1105
1149
|
})
|
|
1106
1150
|
);
|
|
@@ -1249,6 +1293,7 @@ async function registryGetTheme(name, config) {
|
|
|
1249
1293
|
}
|
|
1250
1294
|
},
|
|
1251
1295
|
cssVars: {
|
|
1296
|
+
theme: {},
|
|
1252
1297
|
light: {
|
|
1253
1298
|
radius: "0.5rem"
|
|
1254
1299
|
},
|
|
@@ -1258,9 +1303,13 @@ async function registryGetTheme(name, config) {
|
|
|
1258
1303
|
if (config.tailwind.cssVariables) {
|
|
1259
1304
|
theme.tailwind.config.theme.extend.colors = {
|
|
1260
1305
|
...theme.tailwind.config.theme.extend.colors,
|
|
1261
|
-
...buildTailwindThemeColorsFromCssVars(baseColor.cssVars.dark)
|
|
1306
|
+
...buildTailwindThemeColorsFromCssVars(baseColor.cssVars.dark ?? {})
|
|
1262
1307
|
};
|
|
1263
1308
|
theme.cssVars = {
|
|
1309
|
+
theme: {
|
|
1310
|
+
...baseColor.cssVars.theme,
|
|
1311
|
+
...theme.cssVars.theme
|
|
1312
|
+
},
|
|
1264
1313
|
light: {
|
|
1265
1314
|
...baseColor.cssVars.light,
|
|
1266
1315
|
...theme.cssVars.light
|
|
@@ -1272,6 +1321,10 @@ async function registryGetTheme(name, config) {
|
|
|
1272
1321
|
};
|
|
1273
1322
|
if (tailwindVersion === "v4" && baseColor.cssVarsV4) {
|
|
1274
1323
|
theme.cssVars = {
|
|
1324
|
+
theme: {
|
|
1325
|
+
...baseColor.cssVarsV4.theme,
|
|
1326
|
+
...theme.cssVars.theme
|
|
1327
|
+
},
|
|
1275
1328
|
light: {
|
|
1276
1329
|
...theme.cssVars.light,
|
|
1277
1330
|
...baseColor.cssVarsV4.light
|
|
@@ -1285,29 +1338,273 @@ async function registryGetTheme(name, config) {
|
|
|
1285
1338
|
}
|
|
1286
1339
|
return theme;
|
|
1287
1340
|
}
|
|
1288
|
-
function getRegistryUrl(
|
|
1289
|
-
if (isUrl(
|
|
1290
|
-
const url = new URL(
|
|
1341
|
+
function getRegistryUrl(path20) {
|
|
1342
|
+
if (isUrl(path20)) {
|
|
1343
|
+
const url = new URL(path20);
|
|
1291
1344
|
if (url.pathname.match(/\/chat\/b\//) && !url.pathname.endsWith("/json")) {
|
|
1292
1345
|
url.pathname = `${url.pathname}/json`;
|
|
1293
1346
|
}
|
|
1294
1347
|
return url.toString();
|
|
1295
1348
|
}
|
|
1296
|
-
return `${REGISTRY_URL}/${
|
|
1349
|
+
return `${REGISTRY_URL}/${path20}`;
|
|
1297
1350
|
}
|
|
1298
|
-
function isUrl(
|
|
1351
|
+
function isUrl(path20) {
|
|
1299
1352
|
try {
|
|
1300
|
-
new URL(
|
|
1353
|
+
new URL(path20);
|
|
1301
1354
|
return true;
|
|
1302
1355
|
} catch (error) {
|
|
1303
1356
|
return false;
|
|
1304
1357
|
}
|
|
1305
1358
|
}
|
|
1359
|
+
async function resolveRegistryItems(names, config) {
|
|
1360
|
+
const registryDependencies = [];
|
|
1361
|
+
for (const name of names) {
|
|
1362
|
+
const itemRegistryDependencies = await resolveRegistryDependencies(
|
|
1363
|
+
name,
|
|
1364
|
+
config
|
|
1365
|
+
);
|
|
1366
|
+
registryDependencies.push(...itemRegistryDependencies);
|
|
1367
|
+
}
|
|
1368
|
+
return Array.from(new Set(registryDependencies));
|
|
1369
|
+
}
|
|
1306
1370
|
|
|
1307
|
-
// src/utils/updaters/update-css
|
|
1371
|
+
// src/utils/updaters/update-css.ts
|
|
1308
1372
|
import { promises as fs5 } from "node:fs";
|
|
1309
|
-
import path7 from "
|
|
1373
|
+
import path7 from "pathe";
|
|
1310
1374
|
import postcss from "postcss";
|
|
1375
|
+
async function updateCss(css, config, options) {
|
|
1376
|
+
if (!config.resolvedPaths.tailwindCss || !css || Object.keys(css).length === 0) {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
options = {
|
|
1380
|
+
silent: false,
|
|
1381
|
+
...options
|
|
1382
|
+
};
|
|
1383
|
+
const cssFilepath = config.resolvedPaths.tailwindCss;
|
|
1384
|
+
const cssFilepathRelative = path7.relative(
|
|
1385
|
+
config.resolvedPaths.cwd,
|
|
1386
|
+
cssFilepath
|
|
1387
|
+
);
|
|
1388
|
+
const cssSpinner = spinner(
|
|
1389
|
+
`Updating ${highlighter.info(cssFilepathRelative)}`,
|
|
1390
|
+
{
|
|
1391
|
+
silent: options.silent
|
|
1392
|
+
}
|
|
1393
|
+
).start();
|
|
1394
|
+
const raw = await fs5.readFile(cssFilepath, "utf8");
|
|
1395
|
+
const output = await transformCss(raw, css);
|
|
1396
|
+
await fs5.writeFile(cssFilepath, output, "utf8");
|
|
1397
|
+
cssSpinner.succeed();
|
|
1398
|
+
}
|
|
1399
|
+
async function transformCss(input, css) {
|
|
1400
|
+
const plugins = [updateCssPlugin(css)];
|
|
1401
|
+
const result = await postcss(plugins).process(input, {
|
|
1402
|
+
from: void 0
|
|
1403
|
+
});
|
|
1404
|
+
let output = result.css;
|
|
1405
|
+
output = output.replace(/\/\* ---break--- \*\//g, "");
|
|
1406
|
+
output = output.replace(/(\n\s*\n)+/g, "\n\n");
|
|
1407
|
+
output = output.trimEnd();
|
|
1408
|
+
return output;
|
|
1409
|
+
}
|
|
1410
|
+
function updateCssPlugin(css) {
|
|
1411
|
+
return {
|
|
1412
|
+
postcssPlugin: "update-css",
|
|
1413
|
+
Once(root) {
|
|
1414
|
+
for (const [selector, properties] of Object.entries(css)) {
|
|
1415
|
+
if (selector.startsWith("@")) {
|
|
1416
|
+
const atRuleMatch = selector.match(/@([a-z-]+)\s*(.*)/i);
|
|
1417
|
+
if (!atRuleMatch)
|
|
1418
|
+
continue;
|
|
1419
|
+
const [, name, params] = atRuleMatch;
|
|
1420
|
+
if (name === "keyframes") {
|
|
1421
|
+
let themeInline = root.nodes?.find(
|
|
1422
|
+
(node) => node.type === "atrule" && node.name === "theme" && node.params === "inline"
|
|
1423
|
+
);
|
|
1424
|
+
if (!themeInline) {
|
|
1425
|
+
themeInline = postcss.atRule({
|
|
1426
|
+
name: "theme",
|
|
1427
|
+
params: "inline",
|
|
1428
|
+
raws: { semicolon: true, between: " ", before: "\n" }
|
|
1429
|
+
});
|
|
1430
|
+
root.append(themeInline);
|
|
1431
|
+
root.insertBefore(
|
|
1432
|
+
themeInline,
|
|
1433
|
+
postcss.comment({ text: "---break---" })
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
const keyframesRule = postcss.atRule({
|
|
1437
|
+
name: "keyframes",
|
|
1438
|
+
params,
|
|
1439
|
+
raws: { semicolon: true, between: " ", before: "\n " }
|
|
1440
|
+
});
|
|
1441
|
+
themeInline.append(keyframesRule);
|
|
1442
|
+
if (typeof properties === "object") {
|
|
1443
|
+
for (const [step, stepProps] of Object.entries(properties)) {
|
|
1444
|
+
processRule(keyframesRule, step, stepProps);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
} else if (name === "utility") {
|
|
1448
|
+
const utilityAtRule = root.nodes?.find(
|
|
1449
|
+
(node) => node.type === "atrule" && node.name === name && node.params === params
|
|
1450
|
+
);
|
|
1451
|
+
if (!utilityAtRule) {
|
|
1452
|
+
const atRule = postcss.atRule({
|
|
1453
|
+
name,
|
|
1454
|
+
params,
|
|
1455
|
+
raws: { semicolon: true, between: " ", before: "\n" }
|
|
1456
|
+
});
|
|
1457
|
+
root.append(atRule);
|
|
1458
|
+
root.insertBefore(
|
|
1459
|
+
atRule,
|
|
1460
|
+
postcss.comment({ text: "---break---" })
|
|
1461
|
+
);
|
|
1462
|
+
if (typeof properties === "object") {
|
|
1463
|
+
for (const [prop, value] of Object.entries(properties)) {
|
|
1464
|
+
if (typeof value === "string") {
|
|
1465
|
+
const decl = postcss.decl({
|
|
1466
|
+
prop,
|
|
1467
|
+
value,
|
|
1468
|
+
raws: { semicolon: true, before: "\n " }
|
|
1469
|
+
});
|
|
1470
|
+
atRule.append(decl);
|
|
1471
|
+
} else if (typeof value === "object") {
|
|
1472
|
+
processRule(atRule, prop, value);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
} else {
|
|
1477
|
+
if (typeof properties === "object") {
|
|
1478
|
+
for (const [prop, value] of Object.entries(properties)) {
|
|
1479
|
+
if (typeof value === "string") {
|
|
1480
|
+
const existingDecl = utilityAtRule.nodes?.find(
|
|
1481
|
+
(node) => node.type === "decl" && node.prop === prop
|
|
1482
|
+
);
|
|
1483
|
+
const decl = postcss.decl({
|
|
1484
|
+
prop,
|
|
1485
|
+
value,
|
|
1486
|
+
raws: { semicolon: true, before: "\n " }
|
|
1487
|
+
});
|
|
1488
|
+
existingDecl ? existingDecl.replaceWith(decl) : utilityAtRule.append(decl);
|
|
1489
|
+
} else if (typeof value === "object") {
|
|
1490
|
+
processRule(utilityAtRule, prop, value);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
} else {
|
|
1496
|
+
processAtRule(root, name, params, properties);
|
|
1497
|
+
}
|
|
1498
|
+
} else {
|
|
1499
|
+
processRule(root, selector, properties);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
function processAtRule(root, name, params, properties) {
|
|
1506
|
+
let atRule = root.nodes?.find(
|
|
1507
|
+
(node) => node.type === "atrule" && node.name === name && node.params === params
|
|
1508
|
+
);
|
|
1509
|
+
if (!atRule) {
|
|
1510
|
+
atRule = postcss.atRule({
|
|
1511
|
+
name,
|
|
1512
|
+
params,
|
|
1513
|
+
raws: { semicolon: true, between: " ", before: "\n" }
|
|
1514
|
+
});
|
|
1515
|
+
root.append(atRule);
|
|
1516
|
+
root.insertBefore(atRule, postcss.comment({ text: "---break---" }));
|
|
1517
|
+
}
|
|
1518
|
+
if (typeof properties === "object") {
|
|
1519
|
+
for (const [childSelector, childProps] of Object.entries(properties)) {
|
|
1520
|
+
if (childSelector.startsWith("@")) {
|
|
1521
|
+
const nestedMatch = childSelector.match(/@([a-z-]+)\s*(.*)/i);
|
|
1522
|
+
if (nestedMatch) {
|
|
1523
|
+
const [, nestedName, nestedParams] = nestedMatch;
|
|
1524
|
+
processAtRule(atRule, nestedName, nestedParams, childProps);
|
|
1525
|
+
}
|
|
1526
|
+
} else {
|
|
1527
|
+
processRule(atRule, childSelector, childProps);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
} else if (typeof properties === "string") {
|
|
1531
|
+
try {
|
|
1532
|
+
const parsed = postcss.parse(`.temp{${properties}}`);
|
|
1533
|
+
const tempRule = parsed.first;
|
|
1534
|
+
if (tempRule && tempRule.nodes) {
|
|
1535
|
+
const rule = postcss.rule({
|
|
1536
|
+
selector: "temp",
|
|
1537
|
+
raws: { semicolon: true, between: " ", before: "\n " }
|
|
1538
|
+
});
|
|
1539
|
+
tempRule.nodes.forEach((node) => {
|
|
1540
|
+
if (node.type === "decl") {
|
|
1541
|
+
const clone = node.clone();
|
|
1542
|
+
clone.raws.before = "\n ";
|
|
1543
|
+
rule.append(clone);
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
if (rule.nodes?.length) {
|
|
1547
|
+
atRule.append(rule);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
} catch (error) {
|
|
1551
|
+
console.error("Error parsing at-rule content:", properties, error);
|
|
1552
|
+
throw error;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
function processRule(parent, selector, properties) {
|
|
1557
|
+
let rule = parent.nodes?.find(
|
|
1558
|
+
(node) => node.type === "rule" && node.selector === selector
|
|
1559
|
+
);
|
|
1560
|
+
if (!rule) {
|
|
1561
|
+
rule = postcss.rule({
|
|
1562
|
+
selector,
|
|
1563
|
+
raws: { semicolon: true, between: " ", before: "\n " }
|
|
1564
|
+
});
|
|
1565
|
+
parent.append(rule);
|
|
1566
|
+
}
|
|
1567
|
+
if (typeof properties === "object") {
|
|
1568
|
+
for (const [prop, value] of Object.entries(properties)) {
|
|
1569
|
+
if (typeof value === "string") {
|
|
1570
|
+
const decl = postcss.decl({
|
|
1571
|
+
prop,
|
|
1572
|
+
value,
|
|
1573
|
+
raws: { semicolon: true, before: "\n " }
|
|
1574
|
+
});
|
|
1575
|
+
const existingDecl = rule.nodes?.find(
|
|
1576
|
+
(node) => node.type === "decl" && node.prop === prop
|
|
1577
|
+
);
|
|
1578
|
+
existingDecl ? existingDecl.replaceWith(decl) : rule.append(decl);
|
|
1579
|
+
} else if (typeof value === "object") {
|
|
1580
|
+
const nestedSelector = prop.startsWith("&") ? selector.replace(/^([^:]+)/, `$1${prop.substring(1)}`) : prop;
|
|
1581
|
+
processRule(parent, nestedSelector, value);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
} else if (typeof properties === "string") {
|
|
1585
|
+
try {
|
|
1586
|
+
const parsed = postcss.parse(`.temp{${properties}}`);
|
|
1587
|
+
const tempRule = parsed.first;
|
|
1588
|
+
if (tempRule && tempRule.nodes) {
|
|
1589
|
+
tempRule.nodes.forEach((node) => {
|
|
1590
|
+
if (node.type === "decl") {
|
|
1591
|
+
const clone = node.clone();
|
|
1592
|
+
clone.raws.before = "\n ";
|
|
1593
|
+
rule?.append(clone);
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
} catch (error) {
|
|
1598
|
+
console.error("Error parsing rule content:", selector, properties, error);
|
|
1599
|
+
throw error;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
// src/utils/updaters/update-css-vars.ts
|
|
1605
|
+
import { promises as fs6 } from "node:fs";
|
|
1606
|
+
import path8 from "node:path";
|
|
1607
|
+
import postcss2 from "postcss";
|
|
1311
1608
|
import AtRule from "postcss/lib/at-rule";
|
|
1312
1609
|
import { z as z5 } from "zod";
|
|
1313
1610
|
async function updateCssVars(cssVars, config, options) {
|
|
@@ -1318,37 +1615,45 @@ async function updateCssVars(cssVars, config, options) {
|
|
|
1318
1615
|
cleanupDefaultNextStyles: false,
|
|
1319
1616
|
silent: false,
|
|
1320
1617
|
tailwindVersion: "v3",
|
|
1618
|
+
overwriteCssVars: false,
|
|
1619
|
+
initIndex: true,
|
|
1321
1620
|
...options
|
|
1322
1621
|
};
|
|
1323
1622
|
const cssFilepath = config.resolvedPaths.tailwindCss;
|
|
1324
|
-
const cssFilepathRelative =
|
|
1623
|
+
const cssFilepathRelative = path8.relative(
|
|
1325
1624
|
config.resolvedPaths.cwd,
|
|
1326
1625
|
cssFilepath
|
|
1327
1626
|
);
|
|
1328
1627
|
const cssVarsSpinner = spinner(
|
|
1329
|
-
`Updating ${highlighter.info(cssFilepathRelative)}`,
|
|
1628
|
+
`Updating CSS variables in ${highlighter.info(cssFilepathRelative)}`,
|
|
1330
1629
|
{
|
|
1331
1630
|
silent: options.silent
|
|
1332
1631
|
}
|
|
1333
1632
|
).start();
|
|
1334
|
-
const raw = await
|
|
1633
|
+
const raw = await fs6.readFile(cssFilepath, "utf8");
|
|
1335
1634
|
const output = await transformCssVars(raw, cssVars ?? {}, config, {
|
|
1336
1635
|
cleanupDefaultNextStyles: options.cleanupDefaultNextStyles,
|
|
1337
1636
|
tailwindVersion: options.tailwindVersion,
|
|
1338
|
-
tailwindConfig: options.tailwindConfig
|
|
1637
|
+
tailwindConfig: options.tailwindConfig,
|
|
1638
|
+
overwriteCssVars: options.overwriteCssVars,
|
|
1639
|
+
initIndex: options.initIndex
|
|
1339
1640
|
});
|
|
1340
|
-
await
|
|
1641
|
+
await fs6.writeFile(cssFilepath, output, "utf8");
|
|
1341
1642
|
cssVarsSpinner.succeed();
|
|
1342
1643
|
}
|
|
1343
1644
|
async function transformCssVars(input, cssVars, config, options = {
|
|
1344
1645
|
cleanupDefaultNextStyles: false,
|
|
1345
1646
|
tailwindVersion: "v3",
|
|
1346
|
-
tailwindConfig: void 0
|
|
1647
|
+
tailwindConfig: void 0,
|
|
1648
|
+
overwriteCssVars: false,
|
|
1649
|
+
initIndex: true
|
|
1347
1650
|
}) {
|
|
1348
1651
|
options = {
|
|
1349
1652
|
cleanupDefaultNextStyles: false,
|
|
1350
1653
|
tailwindVersion: "v3",
|
|
1351
1654
|
tailwindConfig: void 0,
|
|
1655
|
+
overwriteCssVars: false,
|
|
1656
|
+
initIndex: true,
|
|
1352
1657
|
...options
|
|
1353
1658
|
};
|
|
1354
1659
|
let plugins = [updateCssVarsPlugin(cssVars)];
|
|
@@ -1356,11 +1661,22 @@ async function transformCssVars(input, cssVars, config, options = {
|
|
|
1356
1661
|
plugins.push(cleanupDefaultNextStylesPlugin());
|
|
1357
1662
|
}
|
|
1358
1663
|
if (options.tailwindVersion === "v4") {
|
|
1359
|
-
plugins = [
|
|
1664
|
+
plugins = [];
|
|
1665
|
+
if (config.resolvedPaths?.cwd) {
|
|
1666
|
+
const packageInfo = getPackageInfo(config.resolvedPaths.cwd);
|
|
1667
|
+
if (!packageInfo?.dependencies?.["tailwindcss-animate"] && !packageInfo?.devDependencies?.["tailwindcss-animate"] && options.initIndex) {
|
|
1668
|
+
plugins.push(addCustomImport({ params: "tw-animate-css" }));
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
plugins.push(addCustomVariant({ params: "dark (&:is(.dark *))" }));
|
|
1360
1672
|
if (options.cleanupDefaultNextStyles) {
|
|
1361
1673
|
plugins.push(cleanupDefaultNextStylesPlugin());
|
|
1362
1674
|
}
|
|
1363
|
-
plugins.push(
|
|
1675
|
+
plugins.push(
|
|
1676
|
+
updateCssVarsPluginV4(cssVars, {
|
|
1677
|
+
overwriteCssVars: options.overwriteCssVars
|
|
1678
|
+
})
|
|
1679
|
+
);
|
|
1364
1680
|
plugins.push(updateThemePlugin(cssVars));
|
|
1365
1681
|
if (options.tailwindConfig) {
|
|
1366
1682
|
plugins.push(updateTailwindConfigPlugin(options.tailwindConfig));
|
|
@@ -1368,12 +1684,12 @@ async function transformCssVars(input, cssVars, config, options = {
|
|
|
1368
1684
|
plugins.push(updateTailwindConfigKeyframesPlugin(options.tailwindConfig));
|
|
1369
1685
|
}
|
|
1370
1686
|
}
|
|
1371
|
-
if (config.tailwind.cssVariables) {
|
|
1687
|
+
if (config.tailwind.cssVariables && options.initIndex) {
|
|
1372
1688
|
plugins.push(
|
|
1373
1689
|
updateBaseLayerPlugin({ tailwindVersion: options.tailwindVersion })
|
|
1374
1690
|
);
|
|
1375
1691
|
}
|
|
1376
|
-
const result = await
|
|
1692
|
+
const result = await postcss2(plugins).process(input, {
|
|
1377
1693
|
from: void 0
|
|
1378
1694
|
});
|
|
1379
1695
|
let output = result.css;
|
|
@@ -1406,13 +1722,13 @@ function updateBaseLayerPlugin({
|
|
|
1406
1722
|
)
|
|
1407
1723
|
);
|
|
1408
1724
|
if (!baseLayer) {
|
|
1409
|
-
baseLayer =
|
|
1725
|
+
baseLayer = postcss2.atRule({
|
|
1410
1726
|
name: "layer",
|
|
1411
1727
|
params: "base",
|
|
1412
1728
|
raws: { semicolon: true, between: " ", before: "\n" }
|
|
1413
1729
|
});
|
|
1414
1730
|
root.append(baseLayer);
|
|
1415
|
-
root.insertBefore(baseLayer,
|
|
1731
|
+
root.insertBefore(baseLayer, postcss2.comment({ text: "---break---" }));
|
|
1416
1732
|
}
|
|
1417
1733
|
requiredRules.forEach(({ selector, apply }) => {
|
|
1418
1734
|
const existingRule = baseLayer?.nodes?.find(
|
|
@@ -1420,10 +1736,10 @@ function updateBaseLayerPlugin({
|
|
|
1420
1736
|
);
|
|
1421
1737
|
if (!existingRule) {
|
|
1422
1738
|
baseLayer?.append(
|
|
1423
|
-
|
|
1739
|
+
postcss2.rule({
|
|
1424
1740
|
selector,
|
|
1425
1741
|
nodes: [
|
|
1426
|
-
|
|
1742
|
+
postcss2.atRule({
|
|
1427
1743
|
name: "apply",
|
|
1428
1744
|
params: apply,
|
|
1429
1745
|
raws: { semicolon: true, before: "\n " }
|
|
@@ -1445,7 +1761,7 @@ function updateCssVarsPlugin(cssVars) {
|
|
|
1445
1761
|
(node) => node.type === "atrule" && node.name === "layer" && node.params === "base"
|
|
1446
1762
|
);
|
|
1447
1763
|
if (!(baseLayer instanceof AtRule)) {
|
|
1448
|
-
baseLayer =
|
|
1764
|
+
baseLayer = postcss2.atRule({
|
|
1449
1765
|
name: "layer",
|
|
1450
1766
|
params: "base",
|
|
1451
1767
|
nodes: [],
|
|
@@ -1456,7 +1772,7 @@ function updateCssVarsPlugin(cssVars) {
|
|
|
1456
1772
|
}
|
|
1457
1773
|
});
|
|
1458
1774
|
root.append(baseLayer);
|
|
1459
|
-
root.insertBefore(baseLayer,
|
|
1775
|
+
root.insertBefore(baseLayer, postcss2.comment({ text: "---break---" }));
|
|
1460
1776
|
}
|
|
1461
1777
|
if (baseLayer !== void 0) {
|
|
1462
1778
|
Object.entries(cssVars).forEach(([key, vars]) => {
|
|
@@ -1523,7 +1839,7 @@ function addOrUpdateVars(baseLayer, selector, vars) {
|
|
|
1523
1839
|
);
|
|
1524
1840
|
if (!ruleNode) {
|
|
1525
1841
|
if (Object.keys(vars).length > 0) {
|
|
1526
|
-
ruleNode =
|
|
1842
|
+
ruleNode = postcss2.rule({
|
|
1527
1843
|
selector,
|
|
1528
1844
|
raws: { between: " ", before: "\n " }
|
|
1529
1845
|
});
|
|
@@ -1532,7 +1848,7 @@ function addOrUpdateVars(baseLayer, selector, vars) {
|
|
|
1532
1848
|
}
|
|
1533
1849
|
Object.entries(vars).forEach(([key, value]) => {
|
|
1534
1850
|
const prop = `--${key.replace(/^--/, "")}`;
|
|
1535
|
-
const newDecl =
|
|
1851
|
+
const newDecl = postcss2.decl({
|
|
1536
1852
|
prop,
|
|
1537
1853
|
value,
|
|
1538
1854
|
raws: { semicolon: true }
|
|
@@ -1543,23 +1859,50 @@ function addOrUpdateVars(baseLayer, selector, vars) {
|
|
|
1543
1859
|
existingDecl ? existingDecl.replaceWith(newDecl) : ruleNode?.append(newDecl);
|
|
1544
1860
|
});
|
|
1545
1861
|
}
|
|
1546
|
-
function updateCssVarsPluginV4(cssVars) {
|
|
1862
|
+
function updateCssVarsPluginV4(cssVars, options) {
|
|
1547
1863
|
return {
|
|
1548
1864
|
postcssPlugin: "update-css-vars-v4",
|
|
1549
1865
|
Once(root) {
|
|
1550
1866
|
Object.entries(cssVars).forEach(([key, vars]) => {
|
|
1551
|
-
|
|
1867
|
+
let selector = key === "light" ? ":root" : `.${key}`;
|
|
1868
|
+
if (key === "theme") {
|
|
1869
|
+
selector = "@theme";
|
|
1870
|
+
const themeNode = upsertThemeNode(root);
|
|
1871
|
+
Object.entries(vars).forEach(([key2, value]) => {
|
|
1872
|
+
const prop = `--${key2.replace(/^--/, "")}`;
|
|
1873
|
+
const newDecl = postcss2.decl({
|
|
1874
|
+
prop,
|
|
1875
|
+
value,
|
|
1876
|
+
raws: { semicolon: true }
|
|
1877
|
+
});
|
|
1878
|
+
const existingDecl = themeNode?.nodes?.find(
|
|
1879
|
+
(node) => node.type === "decl" && node.prop === prop
|
|
1880
|
+
);
|
|
1881
|
+
if (options.overwriteCssVars) {
|
|
1882
|
+
if (existingDecl) {
|
|
1883
|
+
existingDecl.replaceWith(newDecl);
|
|
1884
|
+
} else {
|
|
1885
|
+
themeNode?.append(newDecl);
|
|
1886
|
+
}
|
|
1887
|
+
} else {
|
|
1888
|
+
if (!existingDecl) {
|
|
1889
|
+
themeNode?.append(newDecl);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1552
1895
|
let ruleNode = root.nodes?.find(
|
|
1553
1896
|
(node) => node.type === "rule" && node.selector === selector
|
|
1554
1897
|
);
|
|
1555
1898
|
if (!ruleNode && Object.keys(vars).length > 0) {
|
|
1556
|
-
ruleNode =
|
|
1899
|
+
ruleNode = postcss2.rule({
|
|
1557
1900
|
selector,
|
|
1558
1901
|
nodes: [],
|
|
1559
1902
|
raws: { semicolon: true, between: " ", before: "\n" }
|
|
1560
1903
|
});
|
|
1561
1904
|
root.append(ruleNode);
|
|
1562
|
-
root.insertBefore(ruleNode,
|
|
1905
|
+
root.insertBefore(ruleNode, postcss2.comment({ text: "---break---" }));
|
|
1563
1906
|
}
|
|
1564
1907
|
Object.entries(vars).forEach(([key2, value]) => {
|
|
1565
1908
|
let prop = `--${key2.replace(/^--/, "")}`;
|
|
@@ -1569,7 +1912,7 @@ function updateCssVarsPluginV4(cssVars) {
|
|
|
1569
1912
|
if (isLocalHSLValue(value)) {
|
|
1570
1913
|
value = `hsl(${value})`;
|
|
1571
1914
|
}
|
|
1572
|
-
const newDecl =
|
|
1915
|
+
const newDecl = postcss2.decl({
|
|
1573
1916
|
prop,
|
|
1574
1917
|
value,
|
|
1575
1918
|
raws: { semicolon: true }
|
|
@@ -1577,8 +1920,16 @@ function updateCssVarsPluginV4(cssVars) {
|
|
|
1577
1920
|
const existingDecl = ruleNode?.nodes.find(
|
|
1578
1921
|
(node) => node.type === "decl" && node.prop === prop
|
|
1579
1922
|
);
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1923
|
+
if (options.overwriteCssVars) {
|
|
1924
|
+
if (existingDecl) {
|
|
1925
|
+
existingDecl.replaceWith(newDecl);
|
|
1926
|
+
} else {
|
|
1927
|
+
ruleNode?.append(newDecl);
|
|
1928
|
+
}
|
|
1929
|
+
} else {
|
|
1930
|
+
if (!existingDecl) {
|
|
1931
|
+
ruleNode?.append(newDecl);
|
|
1932
|
+
}
|
|
1582
1933
|
}
|
|
1583
1934
|
});
|
|
1584
1935
|
});
|
|
@@ -1616,7 +1967,7 @@ function updateThemePlugin(cssVars) {
|
|
|
1616
1967
|
xl: "calc(var(--radius) + 4px)"
|
|
1617
1968
|
};
|
|
1618
1969
|
for (const [key, value2] of Object.entries(radiusVariables)) {
|
|
1619
|
-
const cssVarNode2 =
|
|
1970
|
+
const cssVarNode2 = postcss2.decl({
|
|
1620
1971
|
prop: `--radius-${key}`,
|
|
1621
1972
|
value: value2,
|
|
1622
1973
|
raws: { semicolon: true }
|
|
@@ -1638,7 +1989,7 @@ function updateThemePlugin(cssVars) {
|
|
|
1638
1989
|
if (prop === "--color-sidebar") {
|
|
1639
1990
|
propValue = "var(--sidebar)";
|
|
1640
1991
|
}
|
|
1641
|
-
const cssVarNode =
|
|
1992
|
+
const cssVarNode = postcss2.decl({
|
|
1642
1993
|
prop,
|
|
1643
1994
|
value: propValue,
|
|
1644
1995
|
raws: { semicolon: true }
|
|
@@ -1665,14 +2016,14 @@ function upsertThemeNode(root) {
|
|
|
1665
2016
|
(node) => node.type === "atrule" && node.name === "theme" && node.params === "inline"
|
|
1666
2017
|
);
|
|
1667
2018
|
if (!themeNode) {
|
|
1668
|
-
themeNode =
|
|
2019
|
+
themeNode = postcss2.atRule({
|
|
1669
2020
|
name: "theme",
|
|
1670
2021
|
params: "inline",
|
|
1671
2022
|
nodes: [],
|
|
1672
2023
|
raws: { semicolon: true, between: " ", before: "\n" }
|
|
1673
2024
|
});
|
|
1674
2025
|
root.append(themeNode);
|
|
1675
|
-
root.insertBefore(themeNode,
|
|
2026
|
+
root.insertBefore(themeNode, postcss2.comment({ text: "---break---" }));
|
|
1676
2027
|
}
|
|
1677
2028
|
return themeNode;
|
|
1678
2029
|
}
|
|
@@ -1684,13 +2035,57 @@ function addCustomVariant({ params }) {
|
|
|
1684
2035
|
(node) => node.type === "atrule" && node.name === "custom-variant"
|
|
1685
2036
|
);
|
|
1686
2037
|
if (!customVariant) {
|
|
1687
|
-
const
|
|
2038
|
+
const importNodes = root.nodes.filter(
|
|
2039
|
+
(node) => node.type === "atrule" && node.name === "import"
|
|
2040
|
+
);
|
|
2041
|
+
const variantNode = postcss2.atRule({
|
|
1688
2042
|
name: "custom-variant",
|
|
1689
2043
|
params,
|
|
1690
2044
|
raws: { semicolon: true, before: "\n" }
|
|
1691
2045
|
});
|
|
1692
|
-
|
|
1693
|
-
|
|
2046
|
+
if (importNodes.length > 0) {
|
|
2047
|
+
const lastImport = importNodes[importNodes.length - 1];
|
|
2048
|
+
root.insertAfter(lastImport, variantNode);
|
|
2049
|
+
} else {
|
|
2050
|
+
root.insertAfter(root.nodes[0], variantNode);
|
|
2051
|
+
}
|
|
2052
|
+
root.insertBefore(variantNode, postcss2.comment({ text: "---break---" }));
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
function addCustomImport({ params }) {
|
|
2058
|
+
return {
|
|
2059
|
+
postcssPlugin: "add-custom-import",
|
|
2060
|
+
Once(root) {
|
|
2061
|
+
const importNodes = root.nodes.filter(
|
|
2062
|
+
(node) => node.type === "atrule" && node.name === "import"
|
|
2063
|
+
);
|
|
2064
|
+
const customVariantNode = root.nodes.find(
|
|
2065
|
+
(node) => node.type === "atrule" && node.name === "custom-variant"
|
|
2066
|
+
);
|
|
2067
|
+
const hasImport = importNodes.some(
|
|
2068
|
+
(node) => node.params.replace(/["']/g, "") === params
|
|
2069
|
+
);
|
|
2070
|
+
if (!hasImport) {
|
|
2071
|
+
const importNode = postcss2.atRule({
|
|
2072
|
+
name: "import",
|
|
2073
|
+
params: `"${params}"`,
|
|
2074
|
+
raws: { semicolon: true, before: "\n" }
|
|
2075
|
+
});
|
|
2076
|
+
if (importNodes.length > 0) {
|
|
2077
|
+
const lastImport = importNodes[importNodes.length - 1];
|
|
2078
|
+
root.insertAfter(lastImport, importNode);
|
|
2079
|
+
} else if (customVariantNode) {
|
|
2080
|
+
root.insertBefore(customVariantNode, importNode);
|
|
2081
|
+
root.insertBefore(
|
|
2082
|
+
customVariantNode,
|
|
2083
|
+
postcss2.comment({ text: "---break---" })
|
|
2084
|
+
);
|
|
2085
|
+
} else {
|
|
2086
|
+
root.prepend(importNode);
|
|
2087
|
+
root.insertAfter(importNode, postcss2.comment({ text: "---break---" }));
|
|
2088
|
+
}
|
|
1694
2089
|
}
|
|
1695
2090
|
}
|
|
1696
2091
|
};
|
|
@@ -1715,13 +2110,13 @@ function updateTailwindConfigPlugin(tailwindConfig) {
|
|
|
1715
2110
|
})) {
|
|
1716
2111
|
continue;
|
|
1717
2112
|
}
|
|
1718
|
-
const pluginNode =
|
|
2113
|
+
const pluginNode = postcss2.atRule({
|
|
1719
2114
|
name: "plugin",
|
|
1720
2115
|
params: `${quote}${pluginName}${quote}`,
|
|
1721
2116
|
raws: { semicolon: true, before: "\n" }
|
|
1722
2117
|
});
|
|
1723
2118
|
root.insertAfter(lastPluginNode, pluginNode);
|
|
1724
|
-
root.insertBefore(pluginNode,
|
|
2119
|
+
root.insertBefore(pluginNode, postcss2.comment({ text: "---break---" }));
|
|
1725
2120
|
}
|
|
1726
2121
|
}
|
|
1727
2122
|
};
|
|
@@ -1756,17 +2151,17 @@ function updateTailwindConfigKeyframesPlugin(tailwindConfig) {
|
|
|
1756
2151
|
)) {
|
|
1757
2152
|
continue;
|
|
1758
2153
|
}
|
|
1759
|
-
const keyframeNode =
|
|
2154
|
+
const keyframeNode = postcss2.atRule({
|
|
1760
2155
|
name: "keyframes",
|
|
1761
2156
|
params: keyframeName,
|
|
1762
2157
|
nodes: [],
|
|
1763
2158
|
raws: { semicolon: true, between: " ", before: "\n " }
|
|
1764
2159
|
});
|
|
1765
2160
|
for (const [key, values] of Object.entries(parsedKeyframeValue.data)) {
|
|
1766
|
-
const rule =
|
|
2161
|
+
const rule = postcss2.rule({
|
|
1767
2162
|
selector: key,
|
|
1768
2163
|
nodes: Object.entries(values).map(
|
|
1769
|
-
([key2, value]) =>
|
|
2164
|
+
([key2, value]) => postcss2.decl({
|
|
1770
2165
|
prop: key2,
|
|
1771
2166
|
value,
|
|
1772
2167
|
raws: { semicolon: true, before: "\n ", between: ": " }
|
|
@@ -1779,7 +2174,7 @@ function updateTailwindConfigKeyframesPlugin(tailwindConfig) {
|
|
|
1779
2174
|
themeNode.append(keyframeNode);
|
|
1780
2175
|
themeNode.insertBefore(
|
|
1781
2176
|
keyframeNode,
|
|
1782
|
-
|
|
2177
|
+
postcss2.comment({ text: "---break---" })
|
|
1783
2178
|
);
|
|
1784
2179
|
}
|
|
1785
2180
|
}
|
|
@@ -1807,7 +2202,7 @@ function updateTailwindConfigAnimationPlugin(tailwindConfig) {
|
|
|
1807
2202
|
)) {
|
|
1808
2203
|
continue;
|
|
1809
2204
|
}
|
|
1810
|
-
const animationNode =
|
|
2205
|
+
const animationNode = postcss2.decl({
|
|
1811
2206
|
prop,
|
|
1812
2207
|
value,
|
|
1813
2208
|
raws: { semicolon: true, between: ": ", before: "\n " }
|
|
@@ -1854,7 +2249,7 @@ async function updateDependencies(dependencies, config, options) {
|
|
|
1854
2249
|
}
|
|
1855
2250
|
|
|
1856
2251
|
// src/utils/updaters/update-files.ts
|
|
1857
|
-
import { existsSync, promises as
|
|
2252
|
+
import { existsSync, promises as fs7 } from "node:fs";
|
|
1858
2253
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
1859
2254
|
|
|
1860
2255
|
// src/utils/transformers/transform-css-vars.ts
|
|
@@ -1869,12 +2264,12 @@ function transformCssVars2(opts) {
|
|
|
1869
2264
|
return transformCount;
|
|
1870
2265
|
for (const scriptAST of scriptASTs) {
|
|
1871
2266
|
traverseScriptAST(scriptAST, {
|
|
1872
|
-
visitLiteral(
|
|
1873
|
-
if (
|
|
1874
|
-
|
|
2267
|
+
visitLiteral(path20) {
|
|
2268
|
+
if (path20.parent.value.type !== "ImportDeclaration" && typeof path20.node.value === "string") {
|
|
2269
|
+
path20.node.value = applyColorMapping(path20.node.value.replace(/"/g, ""), baseColor.inlineColors);
|
|
1875
2270
|
transformCount++;
|
|
1876
2271
|
}
|
|
1877
|
-
return this.traverse(
|
|
2272
|
+
return this.traverse(path20);
|
|
1878
2273
|
}
|
|
1879
2274
|
});
|
|
1880
2275
|
}
|
|
@@ -1955,25 +2350,25 @@ function transformImport(opts) {
|
|
|
1955
2350
|
const { config } = opts;
|
|
1956
2351
|
for (const scriptAST of scriptASTs) {
|
|
1957
2352
|
traverseScriptAST(scriptAST, {
|
|
1958
|
-
visitImportDeclaration(
|
|
1959
|
-
if (typeof
|
|
1960
|
-
const sourcePath =
|
|
2353
|
+
visitImportDeclaration(path20) {
|
|
2354
|
+
if (typeof path20.node.source.value === "string") {
|
|
2355
|
+
const sourcePath = path20.node.source.value;
|
|
1961
2356
|
if (sourcePath.startsWith("@/registry/")) {
|
|
1962
2357
|
if (config.aliases.ui) {
|
|
1963
|
-
|
|
2358
|
+
path20.node.source.value = sourcePath.replace(/^@\/registry\/[^/]+\/ui/, config.aliases.ui);
|
|
1964
2359
|
} else {
|
|
1965
|
-
|
|
2360
|
+
path20.node.source.value = sourcePath.replace(/^@\/registry\/[^/]+/, config.aliases.components);
|
|
1966
2361
|
}
|
|
1967
2362
|
}
|
|
1968
2363
|
if (sourcePath === "@/lib/utils") {
|
|
1969
|
-
const namedImports =
|
|
2364
|
+
const namedImports = path20.node.specifiers?.map((node) => node.local?.name ?? "") ?? [];
|
|
1970
2365
|
const cnImport = namedImports.find((i) => i === "cn");
|
|
1971
2366
|
if (cnImport) {
|
|
1972
|
-
|
|
2367
|
+
path20.node.source.value = sourcePath.replace(/^@\/lib\/utils/, config.aliases.utils);
|
|
1973
2368
|
}
|
|
1974
2369
|
}
|
|
1975
2370
|
}
|
|
1976
|
-
return this.traverse(
|
|
2371
|
+
return this.traverse(path20);
|
|
1977
2372
|
}
|
|
1978
2373
|
});
|
|
1979
2374
|
}
|
|
@@ -2011,9 +2406,9 @@ function transformTwPrefix(opts) {
|
|
|
2011
2406
|
return transformCount;
|
|
2012
2407
|
for (const scriptAST of scriptASTs) {
|
|
2013
2408
|
traverseScriptAST(scriptAST, {
|
|
2014
|
-
visitCallExpression(
|
|
2015
|
-
if (
|
|
2016
|
-
const nodes =
|
|
2409
|
+
visitCallExpression(path20) {
|
|
2410
|
+
if (path20.node.callee.type === "Identifier" && path20.node.callee.name === "cva") {
|
|
2411
|
+
const nodes = path20.node.arguments;
|
|
2017
2412
|
nodes.forEach((node) => {
|
|
2018
2413
|
if (node.type === "Literal" && typeof node.value === "string") {
|
|
2019
2414
|
node.value = applyPrefix(node.value, config.tailwind.prefix);
|
|
@@ -2033,7 +2428,7 @@ function transformTwPrefix(opts) {
|
|
|
2033
2428
|
}
|
|
2034
2429
|
});
|
|
2035
2430
|
}
|
|
2036
|
-
return this.traverse(
|
|
2431
|
+
return this.traverse(path20);
|
|
2037
2432
|
}
|
|
2038
2433
|
});
|
|
2039
2434
|
}
|
|
@@ -2118,10 +2513,10 @@ function transformIcons(opts, registryIcons) {
|
|
|
2118
2513
|
const targetedIconsMap = /* @__PURE__ */ new Map();
|
|
2119
2514
|
for (const scriptAST of scriptASTs) {
|
|
2120
2515
|
traverseScriptAST(scriptAST, {
|
|
2121
|
-
visitImportDeclaration(
|
|
2122
|
-
if (![ICON_LIBRARIES.radix.import, ICON_LIBRARIES.lucide.import].includes(`${
|
|
2123
|
-
return this.traverse(
|
|
2124
|
-
for (const specifier of
|
|
2516
|
+
visitImportDeclaration(path20) {
|
|
2517
|
+
if (![ICON_LIBRARIES.radix.import, ICON_LIBRARIES.lucide.import].includes(`${path20.node.source.value}`))
|
|
2518
|
+
return this.traverse(path20);
|
|
2519
|
+
for (const specifier of path20.node.specifiers ?? []) {
|
|
2125
2520
|
if (specifier.type === "ImportSpecifier") {
|
|
2126
2521
|
const iconName = specifier.imported.name;
|
|
2127
2522
|
const targetedIcon = registryIcons[iconName]?.[targetLibrary];
|
|
@@ -2133,8 +2528,8 @@ function transformIcons(opts, registryIcons) {
|
|
|
2133
2528
|
}
|
|
2134
2529
|
}
|
|
2135
2530
|
if (targetedIconsMap.size > 0)
|
|
2136
|
-
|
|
2137
|
-
return this.traverse(
|
|
2531
|
+
path20.node.source.value = ICON_LIBRARIES[targetLibrary].import;
|
|
2532
|
+
return this.traverse(path20);
|
|
2138
2533
|
}
|
|
2139
2534
|
});
|
|
2140
2535
|
if (sfcAST) {
|
|
@@ -2166,13 +2561,13 @@ async function transform2(opts) {
|
|
|
2166
2561
|
}
|
|
2167
2562
|
|
|
2168
2563
|
// src/utils/updaters/update-files.ts
|
|
2169
|
-
import
|
|
2564
|
+
import path9, { basename, dirname } from "pathe";
|
|
2170
2565
|
import prompts from "prompts";
|
|
2171
2566
|
function resolveTargetDir(projectInfo, config, target) {
|
|
2172
2567
|
if (target.startsWith("~/")) {
|
|
2173
|
-
return
|
|
2568
|
+
return path9.join(config.resolvedPaths.cwd, target.replace("~/", ""));
|
|
2174
2569
|
}
|
|
2175
|
-
return
|
|
2570
|
+
return path9.join(config.resolvedPaths.cwd, target);
|
|
2176
2571
|
}
|
|
2177
2572
|
async function updateFiles(files, config, options) {
|
|
2178
2573
|
if (!files?.length) {
|
|
@@ -2201,15 +2596,15 @@ async function updateFiles(files, config, options) {
|
|
|
2201
2596
|
if (!file.content) {
|
|
2202
2597
|
continue;
|
|
2203
2598
|
}
|
|
2204
|
-
const dirName =
|
|
2205
|
-
tempRoot =
|
|
2206
|
-
const tempDir =
|
|
2207
|
-
const tempPath =
|
|
2208
|
-
await
|
|
2209
|
-
await
|
|
2599
|
+
const dirName = path9.dirname(file.path);
|
|
2600
|
+
tempRoot = path9.join(tmpdir2(), "shadcn-vue");
|
|
2601
|
+
const tempDir = path9.join(tempRoot, "registry", config.style, dirName);
|
|
2602
|
+
const tempPath = path9.join(tempRoot, "registry", config.style, file.path);
|
|
2603
|
+
await fs7.mkdir(tempDir, { recursive: true });
|
|
2604
|
+
await fs7.writeFile(tempPath, file.content, "utf-8");
|
|
2210
2605
|
}
|
|
2211
|
-
await
|
|
2212
|
-
await
|
|
2606
|
+
await fs7.cp(path9.join(process.cwd(), "node_modules"), tempRoot, { recursive: true });
|
|
2607
|
+
await fs7.writeFile(path9.join(tempRoot, "tsconfig.json"), `{
|
|
2213
2608
|
"compilerOptions": {
|
|
2214
2609
|
"baseUrl": ".",
|
|
2215
2610
|
"paths": {
|
|
@@ -2226,10 +2621,10 @@ async function updateFiles(files, config, options) {
|
|
|
2226
2621
|
}
|
|
2227
2622
|
let targetDir = getRegistryItemFileTargetPath(file, config);
|
|
2228
2623
|
const fileName = basename(file.path);
|
|
2229
|
-
let filePath =
|
|
2624
|
+
let filePath = path9.join(targetDir, fileName);
|
|
2230
2625
|
if (file.target) {
|
|
2231
2626
|
filePath = resolveTargetDir(projectInfo, config, file.target);
|
|
2232
|
-
targetDir =
|
|
2627
|
+
targetDir = path9.dirname(filePath);
|
|
2233
2628
|
}
|
|
2234
2629
|
if (!config.typescript) {
|
|
2235
2630
|
filePath = filePath.replace(/\.ts?$/, (match) => ".js");
|
|
@@ -2253,7 +2648,7 @@ async function updateFiles(files, config, options) {
|
|
|
2253
2648
|
filesCreatedSpinner?.start();
|
|
2254
2649
|
}
|
|
2255
2650
|
if (folderSkipped.get(folderName) === true) {
|
|
2256
|
-
filesSkipped.push(
|
|
2651
|
+
filesSkipped.push(path9.relative(config.resolvedPaths.cwd, filePath));
|
|
2257
2652
|
continue;
|
|
2258
2653
|
}
|
|
2259
2654
|
} else {
|
|
@@ -2268,26 +2663,26 @@ async function updateFiles(files, config, options) {
|
|
|
2268
2663
|
initial: false
|
|
2269
2664
|
});
|
|
2270
2665
|
if (!overwrite) {
|
|
2271
|
-
filesSkipped.push(
|
|
2666
|
+
filesSkipped.push(path9.relative(config.resolvedPaths.cwd, filePath));
|
|
2272
2667
|
continue;
|
|
2273
2668
|
}
|
|
2274
2669
|
filesCreatedSpinner?.start();
|
|
2275
2670
|
}
|
|
2276
2671
|
}
|
|
2277
2672
|
if (!existsSync(targetDir)) {
|
|
2278
|
-
await
|
|
2673
|
+
await fs7.mkdir(targetDir, { recursive: true });
|
|
2279
2674
|
}
|
|
2280
2675
|
const content = await transform2({
|
|
2281
|
-
filename:
|
|
2676
|
+
filename: path9.join(tempRoot, "registry", config.style, file.path),
|
|
2282
2677
|
raw: file.content,
|
|
2283
2678
|
config,
|
|
2284
2679
|
baseColor
|
|
2285
2680
|
});
|
|
2286
|
-
await
|
|
2287
|
-
existingFile ? filesUpdated.push(
|
|
2681
|
+
await fs7.writeFile(filePath, content, "utf-8");
|
|
2682
|
+
existingFile ? filesUpdated.push(path9.relative(config.resolvedPaths.cwd, filePath)) : filesCreated.push(path9.relative(config.resolvedPaths.cwd, filePath));
|
|
2288
2683
|
}
|
|
2289
2684
|
if (tempRoot) {
|
|
2290
|
-
await
|
|
2685
|
+
await fs7.rm(tempRoot, { recursive: true });
|
|
2291
2686
|
}
|
|
2292
2687
|
const hasUpdatedFiles = filesCreated.length || filesUpdated.length;
|
|
2293
2688
|
if (!hasUpdatedFiles && !filesSkipped.length) {
|
|
@@ -2337,11 +2732,13 @@ async function updateFiles(files, config, options) {
|
|
|
2337
2732
|
}
|
|
2338
2733
|
|
|
2339
2734
|
// src/utils/add-components.ts
|
|
2735
|
+
import { z as z6 } from "zod";
|
|
2340
2736
|
async function addComponents(components, config, options) {
|
|
2341
2737
|
options = {
|
|
2342
2738
|
overwrite: false,
|
|
2343
2739
|
silent: false,
|
|
2344
2740
|
isNewProject: false,
|
|
2741
|
+
style: "index",
|
|
2345
2742
|
...options
|
|
2346
2743
|
};
|
|
2347
2744
|
return await addProjectComponents(components, config, options);
|
|
@@ -2361,11 +2758,17 @@ async function addProjectComponents(components, config, options) {
|
|
|
2361
2758
|
silent: options.silent,
|
|
2362
2759
|
tailwindVersion
|
|
2363
2760
|
});
|
|
2761
|
+
const overwriteCssVars = await shouldOverwriteCssVars(components, config);
|
|
2364
2762
|
await updateCssVars(tree.cssVars, config, {
|
|
2365
2763
|
cleanupDefaultNextStyles: options.isNewProject,
|
|
2366
2764
|
silent: options.silent,
|
|
2367
2765
|
tailwindVersion,
|
|
2368
|
-
tailwindConfig: tree.tailwind?.config
|
|
2766
|
+
tailwindConfig: tree.tailwind?.config,
|
|
2767
|
+
overwriteCssVars,
|
|
2768
|
+
initIndex: options.style ? options.style === "index" : false
|
|
2769
|
+
});
|
|
2770
|
+
await updateCss(tree.css, config, {
|
|
2771
|
+
silent: options.silent
|
|
2369
2772
|
});
|
|
2370
2773
|
await updateDependencies(tree.dependencies, config, {
|
|
2371
2774
|
silent: options.silent
|
|
@@ -2378,10 +2781,18 @@ async function addProjectComponents(components, config, options) {
|
|
|
2378
2781
|
logger.info(tree.docs);
|
|
2379
2782
|
}
|
|
2380
2783
|
}
|
|
2784
|
+
async function shouldOverwriteCssVars(components, config) {
|
|
2785
|
+
const registryItems = await resolveRegistryItems(components, config);
|
|
2786
|
+
const result = await fetchRegistry(registryItems);
|
|
2787
|
+
const payload = z6.array(registryItemSchema).parse(result);
|
|
2788
|
+
return payload.some(
|
|
2789
|
+
(component) => component.type === "registry:theme" || component.type === "registry:style"
|
|
2790
|
+
);
|
|
2791
|
+
}
|
|
2381
2792
|
|
|
2382
2793
|
// src/utils/updaters/update-tailwind-content.ts
|
|
2383
|
-
import { promises as
|
|
2384
|
-
import
|
|
2794
|
+
import { promises as fs8 } from "node:fs";
|
|
2795
|
+
import path10 from "pathe";
|
|
2385
2796
|
import { SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
2386
2797
|
async function updateTailwindContent(content, config, options) {
|
|
2387
2798
|
if (!content) {
|
|
@@ -2391,7 +2802,7 @@ async function updateTailwindContent(content, config, options) {
|
|
|
2391
2802
|
silent: false,
|
|
2392
2803
|
...options
|
|
2393
2804
|
};
|
|
2394
|
-
const tailwindFileRelativePath =
|
|
2805
|
+
const tailwindFileRelativePath = path10.relative(
|
|
2395
2806
|
config.resolvedPaths.cwd,
|
|
2396
2807
|
config.resolvedPaths.tailwindConfig
|
|
2397
2808
|
);
|
|
@@ -2401,9 +2812,9 @@ async function updateTailwindContent(content, config, options) {
|
|
|
2401
2812
|
silent: options.silent
|
|
2402
2813
|
}
|
|
2403
2814
|
).start();
|
|
2404
|
-
const raw = await
|
|
2815
|
+
const raw = await fs8.readFile(config.resolvedPaths.tailwindConfig, "utf8");
|
|
2405
2816
|
const output = await transformTailwindContent(raw, content, config);
|
|
2406
|
-
await
|
|
2817
|
+
await fs8.writeFile(config.resolvedPaths.tailwindConfig, output, "utf8");
|
|
2407
2818
|
tailwindSpinner?.succeed();
|
|
2408
2819
|
}
|
|
2409
2820
|
async function transformTailwindContent(input, content, config) {
|
|
@@ -2450,20 +2861,20 @@ async function addTailwindConfigContent(configObject, content) {
|
|
|
2450
2861
|
|
|
2451
2862
|
// src/commands/init.ts
|
|
2452
2863
|
import { Command } from "commander";
|
|
2453
|
-
import
|
|
2864
|
+
import path11 from "pathe";
|
|
2454
2865
|
import prompts2 from "prompts";
|
|
2455
|
-
import { z as
|
|
2456
|
-
var initOptionsSchema =
|
|
2457
|
-
cwd:
|
|
2458
|
-
components:
|
|
2459
|
-
yes:
|
|
2460
|
-
defaults:
|
|
2461
|
-
force:
|
|
2462
|
-
silent:
|
|
2463
|
-
isNewProject:
|
|
2464
|
-
srcDir:
|
|
2465
|
-
cssVariables:
|
|
2466
|
-
baseColor:
|
|
2866
|
+
import { z as z7 } from "zod";
|
|
2867
|
+
var initOptionsSchema = z7.object({
|
|
2868
|
+
cwd: z7.string(),
|
|
2869
|
+
components: z7.array(z7.string()).optional(),
|
|
2870
|
+
yes: z7.boolean(),
|
|
2871
|
+
defaults: z7.boolean(),
|
|
2872
|
+
force: z7.boolean(),
|
|
2873
|
+
silent: z7.boolean(),
|
|
2874
|
+
isNewProject: z7.boolean(),
|
|
2875
|
+
srcDir: z7.boolean().optional(),
|
|
2876
|
+
cssVariables: z7.boolean(),
|
|
2877
|
+
baseColor: z7.string().optional().refine(
|
|
2467
2878
|
(val) => {
|
|
2468
2879
|
if (val) {
|
|
2469
2880
|
return BASE_COLORS.find((color) => color.name === val);
|
|
@@ -2475,7 +2886,8 @@ var initOptionsSchema = z6.object({
|
|
|
2475
2886
|
(color) => color.name
|
|
2476
2887
|
).join("', '")}'`
|
|
2477
2888
|
}
|
|
2478
|
-
)
|
|
2889
|
+
),
|
|
2890
|
+
style: z7.string()
|
|
2479
2891
|
});
|
|
2480
2892
|
var init = new Command().name("init").description("initialize your project and install dependencies").argument(
|
|
2481
2893
|
"[components...]",
|
|
@@ -2487,11 +2899,19 @@ var init = new Command().name("init").description("initialize your project and i
|
|
|
2487
2899
|
).option("-s, --silent", "mute output.", false).option("--css-variables", "use css variables for theming.", true).option("--no-css-variables", "do not use css variables for theming.").action(async (components, opts) => {
|
|
2488
2900
|
try {
|
|
2489
2901
|
const options = initOptionsSchema.parse({
|
|
2490
|
-
cwd:
|
|
2902
|
+
cwd: path11.resolve(opts.cwd),
|
|
2491
2903
|
isNewProject: false,
|
|
2492
2904
|
components,
|
|
2905
|
+
style: "index",
|
|
2493
2906
|
...opts
|
|
2494
2907
|
});
|
|
2908
|
+
if (components.length > 0 && isUrl(components[0])) {
|
|
2909
|
+
const item = await getRegistryItem(components[0], "");
|
|
2910
|
+
if (item?.type === "registry:style") {
|
|
2911
|
+
options.baseColor = "neutral";
|
|
2912
|
+
options.style = item.extends ?? "index";
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2495
2915
|
await runInit(options);
|
|
2496
2916
|
logger.log(
|
|
2497
2917
|
`${highlighter.success(
|
|
@@ -2532,15 +2952,19 @@ async function runInit(options) {
|
|
|
2532
2952
|
}
|
|
2533
2953
|
}
|
|
2534
2954
|
const componentSpinner = spinner(`Writing components.json.`).start();
|
|
2535
|
-
const targetPath =
|
|
2536
|
-
await
|
|
2955
|
+
const targetPath = path11.resolve(options.cwd, "components.json");
|
|
2956
|
+
await fs9.writeFile(targetPath, JSON.stringify(config, null, 2), "utf8");
|
|
2537
2957
|
componentSpinner.succeed();
|
|
2538
2958
|
const fullConfig = await resolveConfigPaths(options.cwd, config);
|
|
2539
|
-
const components = [
|
|
2959
|
+
const components = [
|
|
2960
|
+
...options.style === "none" ? [] : [options.style],
|
|
2961
|
+
...options.components ?? []
|
|
2962
|
+
];
|
|
2540
2963
|
await addComponents(components, fullConfig, {
|
|
2541
2964
|
// Init will always overwrite files.
|
|
2542
2965
|
overwrite: true,
|
|
2543
2966
|
silent: options.silent,
|
|
2967
|
+
style: options.style,
|
|
2544
2968
|
isNewProject: options.isNewProject || projectInfo?.framework.name === "nuxt"
|
|
2545
2969
|
});
|
|
2546
2970
|
if (options.isNewProject && options.srcDir) {
|
|
@@ -2710,18 +3134,18 @@ async function promptForMinimalConfig(defaultConfig, opts) {
|
|
|
2710
3134
|
}
|
|
2711
3135
|
|
|
2712
3136
|
// src/preflights/preflight-add.ts
|
|
2713
|
-
import
|
|
2714
|
-
import
|
|
3137
|
+
import fs10 from "fs-extra";
|
|
3138
|
+
import path12 from "pathe";
|
|
2715
3139
|
async function preFlightAdd(options) {
|
|
2716
3140
|
const errors = {};
|
|
2717
|
-
if (!
|
|
3141
|
+
if (!fs10.existsSync(options.cwd) || !fs10.existsSync(path12.resolve(options.cwd, "package.json"))) {
|
|
2718
3142
|
errors[MISSING_DIR_OR_EMPTY_PROJECT] = true;
|
|
2719
3143
|
return {
|
|
2720
3144
|
errors,
|
|
2721
3145
|
config: null
|
|
2722
3146
|
};
|
|
2723
3147
|
}
|
|
2724
|
-
if (!
|
|
3148
|
+
if (!fs10.existsSync(path12.resolve(options.cwd, "components.json"))) {
|
|
2725
3149
|
errors[MISSING_CONFIG] = true;
|
|
2726
3150
|
return {
|
|
2727
3151
|
errors,
|
|
@@ -2758,9 +3182,9 @@ Before you can add components, you must create a valid ${highlighter.info(
|
|
|
2758
3182
|
|
|
2759
3183
|
// src/commands/add.ts
|
|
2760
3184
|
import { Command as Command2 } from "commander";
|
|
2761
|
-
import
|
|
3185
|
+
import path13 from "pathe";
|
|
2762
3186
|
import prompts3 from "prompts";
|
|
2763
|
-
import { z as
|
|
3187
|
+
import { z as z8 } from "zod";
|
|
2764
3188
|
var DEPRECATED_COMPONENTS = [
|
|
2765
3189
|
{
|
|
2766
3190
|
name: "toast",
|
|
@@ -2773,16 +3197,16 @@ var DEPRECATED_COMPONENTS = [
|
|
|
2773
3197
|
message: "The toaster component is deprecated. Use the sonner component instead."
|
|
2774
3198
|
}
|
|
2775
3199
|
];
|
|
2776
|
-
var addOptionsSchema =
|
|
2777
|
-
components:
|
|
2778
|
-
yes:
|
|
2779
|
-
overwrite:
|
|
2780
|
-
cwd:
|
|
2781
|
-
all:
|
|
2782
|
-
path:
|
|
2783
|
-
silent:
|
|
2784
|
-
srcDir:
|
|
2785
|
-
cssVariables:
|
|
3200
|
+
var addOptionsSchema = z8.object({
|
|
3201
|
+
components: z8.array(z8.string()).optional(),
|
|
3202
|
+
yes: z8.boolean(),
|
|
3203
|
+
overwrite: z8.boolean(),
|
|
3204
|
+
cwd: z8.string(),
|
|
3205
|
+
all: z8.boolean(),
|
|
3206
|
+
path: z8.string().optional(),
|
|
3207
|
+
silent: z8.boolean(),
|
|
3208
|
+
srcDir: z8.boolean().optional(),
|
|
3209
|
+
cssVariables: z8.boolean()
|
|
2786
3210
|
});
|
|
2787
3211
|
var add = new Command2().name("add").description("add a component to your project").argument(
|
|
2788
3212
|
"[components...]",
|
|
@@ -2799,7 +3223,7 @@ var add = new Command2().name("add").description("add a component to your projec
|
|
|
2799
3223
|
try {
|
|
2800
3224
|
const options = addOptionsSchema.parse({
|
|
2801
3225
|
components,
|
|
2802
|
-
cwd:
|
|
3226
|
+
cwd: path13.resolve(opts.cwd),
|
|
2803
3227
|
...opts
|
|
2804
3228
|
});
|
|
2805
3229
|
const isTheme = options.components?.some(
|
|
@@ -2861,7 +3285,8 @@ var add = new Command2().name("add").description("add a component to your projec
|
|
|
2861
3285
|
silent: true,
|
|
2862
3286
|
isNewProject: false,
|
|
2863
3287
|
srcDir: options.srcDir,
|
|
2864
|
-
cssVariables: options.cssVariables
|
|
3288
|
+
cssVariables: options.cssVariables,
|
|
3289
|
+
style: "index"
|
|
2865
3290
|
});
|
|
2866
3291
|
}
|
|
2867
3292
|
if (!config) {
|
|
@@ -2911,7 +3336,7 @@ async function promptForRegistryComponents(options) {
|
|
|
2911
3336
|
logger.info("");
|
|
2912
3337
|
process.exit(1);
|
|
2913
3338
|
}
|
|
2914
|
-
const result =
|
|
3339
|
+
const result = z8.array(z8.string()).safeParse(components);
|
|
2915
3340
|
if (!result.success) {
|
|
2916
3341
|
logger.error("");
|
|
2917
3342
|
handleError(new Error("Something went wrong. Please try again."));
|
|
@@ -2920,19 +3345,123 @@ async function promptForRegistryComponents(options) {
|
|
|
2920
3345
|
return result.data;
|
|
2921
3346
|
}
|
|
2922
3347
|
|
|
2923
|
-
// src/commands/
|
|
2924
|
-
import
|
|
3348
|
+
// src/commands/build.ts
|
|
3349
|
+
import * as fs12 from "node:fs/promises";
|
|
3350
|
+
|
|
3351
|
+
// src/preflights/preflight-build.ts
|
|
3352
|
+
import fs11 from "fs-extra";
|
|
3353
|
+
import path14 from "pathe";
|
|
3354
|
+
async function preFlightBuild(options) {
|
|
3355
|
+
const errors = {};
|
|
3356
|
+
const resolvePaths = {
|
|
3357
|
+
cwd: options.cwd,
|
|
3358
|
+
registryFile: path14.resolve(options.cwd, options.registryFile),
|
|
3359
|
+
outputDir: path14.resolve(options.cwd, options.outputDir)
|
|
3360
|
+
};
|
|
3361
|
+
if (!fs11.existsSync(resolvePaths.registryFile)) {
|
|
3362
|
+
errors[BUILD_MISSING_REGISTRY_FILE] = true;
|
|
3363
|
+
}
|
|
3364
|
+
await fs11.mkdir(resolvePaths.outputDir, { recursive: true });
|
|
3365
|
+
if (Object.keys(errors).length > 0) {
|
|
3366
|
+
if (errors[BUILD_MISSING_REGISTRY_FILE]) {
|
|
3367
|
+
logger.break();
|
|
3368
|
+
logger.error(
|
|
3369
|
+
`The path ${highlighter.info(
|
|
3370
|
+
resolvePaths.registryFile
|
|
3371
|
+
)} does not exist.`
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3374
|
+
logger.break();
|
|
3375
|
+
process.exit(1);
|
|
3376
|
+
}
|
|
3377
|
+
return {
|
|
3378
|
+
errors,
|
|
3379
|
+
resolvePaths
|
|
3380
|
+
};
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
// src/commands/build.ts
|
|
2925
3384
|
import { Command as Command3 } from "commander";
|
|
3385
|
+
import * as path15 from "pathe";
|
|
3386
|
+
import { z as z9 } from "zod";
|
|
3387
|
+
var buildOptionsSchema = z9.object({
|
|
3388
|
+
cwd: z9.string(),
|
|
3389
|
+
registryFile: z9.string(),
|
|
3390
|
+
outputDir: z9.string()
|
|
3391
|
+
});
|
|
3392
|
+
var build = new Command3().name("build").description("build components for a shadcn registry").argument("[registry]", "path to registry.json file", "./registry.json").option(
|
|
3393
|
+
"-o, --output <path>",
|
|
3394
|
+
"destination directory for json files",
|
|
3395
|
+
"./public/r"
|
|
3396
|
+
).option(
|
|
3397
|
+
"-c, --cwd <cwd>",
|
|
3398
|
+
"the working directory. defaults to the current directory.",
|
|
3399
|
+
process.cwd()
|
|
3400
|
+
).action(async (registry, opts) => {
|
|
3401
|
+
try {
|
|
3402
|
+
const options = buildOptionsSchema.parse({
|
|
3403
|
+
cwd: path15.resolve(opts.cwd),
|
|
3404
|
+
registryFile: registry,
|
|
3405
|
+
outputDir: opts.output
|
|
3406
|
+
});
|
|
3407
|
+
const { resolvePaths } = await preFlightBuild(options);
|
|
3408
|
+
const content = await fs12.readFile(resolvePaths.registryFile, "utf-8");
|
|
3409
|
+
const result = registrySchema.safeParse(JSON.parse(content));
|
|
3410
|
+
if (!result.success) {
|
|
3411
|
+
logger.error(
|
|
3412
|
+
`Invalid registry file found at ${highlighter.info(
|
|
3413
|
+
resolvePaths.registryFile
|
|
3414
|
+
)}.`
|
|
3415
|
+
);
|
|
3416
|
+
process.exit(1);
|
|
3417
|
+
}
|
|
3418
|
+
const buildSpinner = spinner("Building registry...");
|
|
3419
|
+
for (const registryItem of result.data.items) {
|
|
3420
|
+
if (!registryItem.files) {
|
|
3421
|
+
continue;
|
|
3422
|
+
}
|
|
3423
|
+
buildSpinner.start(`Building ${registryItem.name}...`);
|
|
3424
|
+
registryItem.$schema = "https://shadcn-vue.com/schema/registry-item.json";
|
|
3425
|
+
for (const file of registryItem.files) {
|
|
3426
|
+
file.content = await fs12.readFile(
|
|
3427
|
+
path15.resolve(resolvePaths.cwd, file.path),
|
|
3428
|
+
"utf-8"
|
|
3429
|
+
);
|
|
3430
|
+
}
|
|
3431
|
+
const result2 = registryItemSchema.safeParse(registryItem);
|
|
3432
|
+
if (!result2.success) {
|
|
3433
|
+
logger.error(
|
|
3434
|
+
`Invalid registry item found for ${highlighter.info(
|
|
3435
|
+
registryItem.name
|
|
3436
|
+
)}.`
|
|
3437
|
+
);
|
|
3438
|
+
continue;
|
|
3439
|
+
}
|
|
3440
|
+
await fs12.writeFile(
|
|
3441
|
+
path15.resolve(resolvePaths.outputDir, `${result2.data.name}.json`),
|
|
3442
|
+
JSON.stringify(result2.data, null, 2)
|
|
3443
|
+
);
|
|
3444
|
+
}
|
|
3445
|
+
buildSpinner.succeed("Building registry.");
|
|
3446
|
+
} catch (error) {
|
|
3447
|
+
logger.break();
|
|
3448
|
+
handleError(error);
|
|
3449
|
+
}
|
|
3450
|
+
});
|
|
3451
|
+
|
|
3452
|
+
// src/commands/diff.ts
|
|
3453
|
+
import { existsSync as existsSync2, promises as fs13 } from "node:fs";
|
|
3454
|
+
import { Command as Command4 } from "commander";
|
|
2926
3455
|
import { diffLines } from "diff";
|
|
2927
|
-
import
|
|
2928
|
-
import { z as
|
|
2929
|
-
var updateOptionsSchema =
|
|
2930
|
-
component:
|
|
2931
|
-
yes:
|
|
2932
|
-
cwd:
|
|
2933
|
-
path:
|
|
3456
|
+
import path16 from "pathe";
|
|
3457
|
+
import { z as z10 } from "zod";
|
|
3458
|
+
var updateOptionsSchema = z10.object({
|
|
3459
|
+
component: z10.string().optional(),
|
|
3460
|
+
yes: z10.boolean(),
|
|
3461
|
+
cwd: z10.string(),
|
|
3462
|
+
path: z10.string().optional()
|
|
2934
3463
|
});
|
|
2935
|
-
var diff = new
|
|
3464
|
+
var diff = new Command4().name("diff").description("check for updates against the registry").argument("[component]", "the component name").option("-y, --yes", "skip confirmation prompt.", false).option(
|
|
2936
3465
|
"-c, --cwd <cwd>",
|
|
2937
3466
|
"the working directory. defaults to the current directory.",
|
|
2938
3467
|
process.cwd()
|
|
@@ -2942,7 +3471,7 @@ var diff = new Command3().name("diff").description("check for updates against th
|
|
|
2942
3471
|
component: name,
|
|
2943
3472
|
...opts
|
|
2944
3473
|
});
|
|
2945
|
-
const cwd =
|
|
3474
|
+
const cwd = path16.resolve(options.cwd);
|
|
2946
3475
|
if (!existsSync2(cwd)) {
|
|
2947
3476
|
logger.error(`The path ${cwd} does not exist. Please try again.`);
|
|
2948
3477
|
process.exit(1);
|
|
@@ -2965,7 +3494,7 @@ var diff = new Command3().name("diff").description("check for updates against th
|
|
|
2965
3494
|
const targetDir = config.resolvedPaths.components;
|
|
2966
3495
|
const projectComponents = registryIndex.filter((item) => {
|
|
2967
3496
|
for (const file of item.files ?? []) {
|
|
2968
|
-
const filePath =
|
|
3497
|
+
const filePath = path16.resolve(
|
|
2969
3498
|
targetDir,
|
|
2970
3499
|
typeof file === "string" ? file : file.path
|
|
2971
3500
|
);
|
|
@@ -3040,14 +3569,14 @@ async function diffComponent(component, config) {
|
|
|
3040
3569
|
continue;
|
|
3041
3570
|
}
|
|
3042
3571
|
for (const file of item.files ?? []) {
|
|
3043
|
-
const filePath =
|
|
3572
|
+
const filePath = path16.resolve(
|
|
3044
3573
|
targetDir,
|
|
3045
3574
|
typeof file === "string" ? file : file.path
|
|
3046
3575
|
);
|
|
3047
3576
|
if (!existsSync2(filePath)) {
|
|
3048
3577
|
continue;
|
|
3049
3578
|
}
|
|
3050
|
-
const fileContent = await
|
|
3579
|
+
const fileContent = await fs13.readFile(filePath, "utf8");
|
|
3051
3580
|
if (typeof file === "string" || !file.content) {
|
|
3052
3581
|
continue;
|
|
3053
3582
|
}
|
|
@@ -3083,9 +3612,9 @@ async function printDiff(diff2) {
|
|
|
3083
3612
|
}
|
|
3084
3613
|
|
|
3085
3614
|
// src/commands/info.ts
|
|
3086
|
-
import { Command as
|
|
3615
|
+
import { Command as Command5 } from "commander";
|
|
3087
3616
|
import consola3 from "consola";
|
|
3088
|
-
var info = new
|
|
3617
|
+
var info = new Command5().name("info").description("get information about your project").option(
|
|
3089
3618
|
"-c, --cwd <cwd>",
|
|
3090
3619
|
"the working directory. defaults to the current directory.",
|
|
3091
3620
|
process.cwd()
|
|
@@ -3099,9 +3628,9 @@ var info = new Command4().name("info").description("get information about your p
|
|
|
3099
3628
|
|
|
3100
3629
|
// src/migrations/migrate-icons.ts
|
|
3101
3630
|
import { randomBytes } from "node:crypto";
|
|
3102
|
-
import { promises as
|
|
3631
|
+
import { promises as fs14 } from "node:fs";
|
|
3103
3632
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
3104
|
-
import
|
|
3633
|
+
import path17 from "pathe";
|
|
3105
3634
|
import prompts4 from "prompts";
|
|
3106
3635
|
import { glob as glob2 } from "tinyglobby";
|
|
3107
3636
|
import { Project as Project2, ScriptKind as ScriptKind2, SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
@@ -3162,7 +3691,7 @@ async function migrateIcons(config) {
|
|
|
3162
3691
|
message: `We will migrate ${highlighter.info(
|
|
3163
3692
|
files.length
|
|
3164
3693
|
)} files in ${highlighter.info(
|
|
3165
|
-
`./${
|
|
3694
|
+
`./${path17.relative(config.resolvedPaths.cwd, uiPath)}`
|
|
3166
3695
|
)} from ${highlighter.info(sourceLibrary.name)} to ${highlighter.info(
|
|
3167
3696
|
targetLibrary.name
|
|
3168
3697
|
)}. Continue?`
|
|
@@ -3180,15 +3709,15 @@ async function migrateIcons(config) {
|
|
|
3180
3709
|
await Promise.all(
|
|
3181
3710
|
files.map(async (file) => {
|
|
3182
3711
|
migrationSpinner.text = `Migrating ${file}...`;
|
|
3183
|
-
const filePath =
|
|
3184
|
-
const fileContent = await
|
|
3712
|
+
const filePath = path17.join(uiPath, file);
|
|
3713
|
+
const fileContent = await fs14.readFile(filePath, "utf-8");
|
|
3185
3714
|
const content = await migrateIconsFile(
|
|
3186
3715
|
fileContent,
|
|
3187
3716
|
migrateOptions.sourceLibrary,
|
|
3188
3717
|
migrateOptions.targetLibrary,
|
|
3189
3718
|
registryIcons
|
|
3190
3719
|
);
|
|
3191
|
-
await
|
|
3720
|
+
await fs14.writeFile(filePath, content);
|
|
3192
3721
|
})
|
|
3193
3722
|
);
|
|
3194
3723
|
migrationSpinner.succeed("Migration complete.");
|
|
@@ -3196,11 +3725,11 @@ async function migrateIcons(config) {
|
|
|
3196
3725
|
async function migrateIconsFile(content, sourceLibrary, targetLibrary, iconsMapping) {
|
|
3197
3726
|
const sourceLibraryImport = ICON_LIBRARIES[sourceLibrary]?.import;
|
|
3198
3727
|
const targetLibraryImport = ICON_LIBRARIES[targetLibrary]?.import;
|
|
3199
|
-
const dir = await
|
|
3728
|
+
const dir = await fs14.mkdtemp(path17.join(tmpdir3(), "shadcn-"));
|
|
3200
3729
|
const project = new Project2({
|
|
3201
3730
|
compilerOptions: {}
|
|
3202
3731
|
});
|
|
3203
|
-
const tempFile =
|
|
3732
|
+
const tempFile = path17.join(
|
|
3204
3733
|
dir,
|
|
3205
3734
|
`shadcn-icons-${randomBytes(4).toString("hex")}.tsx`
|
|
3206
3735
|
);
|
|
@@ -3240,18 +3769,18 @@ async function migrateIconsFile(content, sourceLibrary, targetLibrary, iconsMapp
|
|
|
3240
3769
|
}
|
|
3241
3770
|
|
|
3242
3771
|
// src/preflights/preflight-migrate.ts
|
|
3243
|
-
import
|
|
3244
|
-
import
|
|
3772
|
+
import fs15 from "fs-extra";
|
|
3773
|
+
import path18 from "pathe";
|
|
3245
3774
|
async function preFlightMigrate(options) {
|
|
3246
3775
|
const errors = {};
|
|
3247
|
-
if (!
|
|
3776
|
+
if (!fs15.existsSync(options.cwd) || !fs15.existsSync(path18.resolve(options.cwd, "package.json"))) {
|
|
3248
3777
|
errors[MISSING_DIR_OR_EMPTY_PROJECT] = true;
|
|
3249
3778
|
return {
|
|
3250
3779
|
errors,
|
|
3251
3780
|
config: null
|
|
3252
3781
|
};
|
|
3253
3782
|
}
|
|
3254
|
-
if (!
|
|
3783
|
+
if (!fs15.existsSync(path18.resolve(options.cwd, "components.json"))) {
|
|
3255
3784
|
errors[MISSING_CONFIG] = true;
|
|
3256
3785
|
return {
|
|
3257
3786
|
errors,
|
|
@@ -3287,34 +3816,34 @@ Before you can run a migration, you must create a valid ${highlighter.info(
|
|
|
3287
3816
|
}
|
|
3288
3817
|
|
|
3289
3818
|
// src/commands/migrate.ts
|
|
3290
|
-
import { Command as
|
|
3819
|
+
import { Command as Command6 } from "commander";
|
|
3291
3820
|
import consola4 from "consola";
|
|
3292
|
-
import
|
|
3293
|
-
import { z as
|
|
3821
|
+
import path19 from "pathe";
|
|
3822
|
+
import { z as z11 } from "zod";
|
|
3294
3823
|
var migrations = [
|
|
3295
3824
|
{
|
|
3296
3825
|
name: "icons",
|
|
3297
3826
|
description: "migrate your ui components to a different icon library."
|
|
3298
3827
|
}
|
|
3299
3828
|
];
|
|
3300
|
-
var migrateOptionsSchema =
|
|
3301
|
-
cwd:
|
|
3302
|
-
list:
|
|
3303
|
-
migration:
|
|
3829
|
+
var migrateOptionsSchema = z11.object({
|
|
3830
|
+
cwd: z11.string(),
|
|
3831
|
+
list: z11.boolean(),
|
|
3832
|
+
migration: z11.string().refine(
|
|
3304
3833
|
(value) => value && migrations.some((migration) => migration.name === value),
|
|
3305
3834
|
{
|
|
3306
3835
|
message: "You must specify a valid migration. Run `shadcn migrate --list` to see available migrations."
|
|
3307
3836
|
}
|
|
3308
3837
|
).optional()
|
|
3309
3838
|
});
|
|
3310
|
-
var migrate = new
|
|
3839
|
+
var migrate = new Command6().name("migrate").description("run a migration.").argument("[migration]", "the migration to run.").option(
|
|
3311
3840
|
"-c, --cwd <cwd>",
|
|
3312
3841
|
"the working directory. defaults to the current directory.",
|
|
3313
3842
|
process.cwd()
|
|
3314
3843
|
).option("-l, --list", "list all migrations.", false).action(async (migration, opts) => {
|
|
3315
3844
|
try {
|
|
3316
3845
|
const options = migrateOptionsSchema.parse({
|
|
3317
|
-
cwd:
|
|
3846
|
+
cwd: path19.resolve(opts.cwd),
|
|
3318
3847
|
migration,
|
|
3319
3848
|
list: opts.list
|
|
3320
3849
|
});
|
|
@@ -3350,13 +3879,13 @@ var migrate = new Command5().name("migrate").description("run a migration.").arg
|
|
|
3350
3879
|
});
|
|
3351
3880
|
|
|
3352
3881
|
// src/index.ts
|
|
3353
|
-
import { Command as
|
|
3882
|
+
import { Command as Command7 } from "commander";
|
|
3354
3883
|
|
|
3355
3884
|
// package.json
|
|
3356
3885
|
var package_default = {
|
|
3357
3886
|
name: "shadcn-vue",
|
|
3358
3887
|
type: "module",
|
|
3359
|
-
version: "2.0.
|
|
3888
|
+
version: "2.0.1",
|
|
3360
3889
|
description: "Add components to your apps.",
|
|
3361
3890
|
publishConfig: {
|
|
3362
3891
|
access: "public"
|
|
@@ -3441,6 +3970,7 @@ var package_default = {
|
|
|
3441
3970
|
"@types/node": "^22.13.4",
|
|
3442
3971
|
"@types/prompts": "^2.4.9",
|
|
3443
3972
|
"@types/stringify-object": "^4.0.5",
|
|
3973
|
+
msw: "^2.7.3",
|
|
3444
3974
|
tsup: "^8.3.6",
|
|
3445
3975
|
"type-fest": "^4.34.1",
|
|
3446
3976
|
typescript: "catalog:"
|
|
@@ -3451,12 +3981,12 @@ var package_default = {
|
|
|
3451
3981
|
process.on("SIGINT", () => process.exit(0));
|
|
3452
3982
|
process.on("SIGTERM", () => process.exit(0));
|
|
3453
3983
|
async function main() {
|
|
3454
|
-
const program = new
|
|
3984
|
+
const program = new Command7().name("shadcn-vue").description("add components and dependencies to your project").version(
|
|
3455
3985
|
package_default.version || "1.0.0",
|
|
3456
3986
|
"-v, --version",
|
|
3457
3987
|
"display the version number"
|
|
3458
3988
|
);
|
|
3459
|
-
program.addCommand(init).addCommand(add).addCommand(diff).addCommand(migrate).addCommand(info);
|
|
3989
|
+
program.addCommand(init).addCommand(add).addCommand(diff).addCommand(migrate).addCommand(info).addCommand(build);
|
|
3460
3990
|
program.parse();
|
|
3461
3991
|
}
|
|
3462
3992
|
main();
|