starwind 1.15.4 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +318 -55
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command, Option } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "starwind",
|
|
9
|
-
version: "1.
|
|
9
|
+
version: "1.16.0",
|
|
10
10
|
description: "Add beautifully designed components to your Astro applications",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
author: {
|
|
@@ -20,15 +20,16 @@ var package_default = {
|
|
|
20
20
|
},
|
|
21
21
|
keywords: [
|
|
22
22
|
"starwind",
|
|
23
|
-
"starwind
|
|
24
|
-
"starwind
|
|
23
|
+
"starwind-ui",
|
|
24
|
+
"starwind-cli",
|
|
25
25
|
"astro",
|
|
26
|
-
"astro
|
|
27
|
-
"astro
|
|
28
|
-
"
|
|
26
|
+
"astro-component",
|
|
27
|
+
"astro-ui",
|
|
28
|
+
"withastro",
|
|
29
|
+
"ui",
|
|
30
|
+
"accessibility",
|
|
29
31
|
"tailwind",
|
|
30
|
-
"components"
|
|
31
|
-
"add component"
|
|
32
|
+
"components"
|
|
32
33
|
],
|
|
33
34
|
type: "module",
|
|
34
35
|
bin: {
|
|
@@ -58,7 +59,7 @@ var package_default = {
|
|
|
58
59
|
},
|
|
59
60
|
dependencies: {
|
|
60
61
|
"@clack/prompts": "^0.11.0",
|
|
61
|
-
"@starwind-ui/core": "1.
|
|
62
|
+
"@starwind-ui/core": "1.16.0",
|
|
62
63
|
chalk: "^5.6.2",
|
|
63
64
|
commander: "^14.0.2",
|
|
64
65
|
execa: "^9.6.0",
|
|
@@ -87,12 +88,16 @@ var MIN_ASTRO_VERSION = "5.0.0";
|
|
|
87
88
|
var PATHS = {
|
|
88
89
|
STARWIND_CORE: "@starwind-ui/core",
|
|
89
90
|
STARWIND_CORE_COMPONENTS: "src/components",
|
|
91
|
+
STARWIND_CORE_UTILS: "src/lib/utils",
|
|
90
92
|
STARWIND_REMOTE_COMPONENT_REGISTRY: "https://starwind.dev/registry.json",
|
|
91
93
|
STARWIND_PRO_REGISTRY: "https://pro.starwind.dev/r/{name}",
|
|
92
94
|
LOCAL_CSS_FILE: "src/styles/starwind.css",
|
|
93
95
|
LOCAL_CONFIG_FILE: "starwind.config.json",
|
|
94
96
|
LOCAL_STYLES_DIR: "src/styles",
|
|
95
|
-
LOCAL_COMPONENTS_DIR: "src/components"
|
|
97
|
+
LOCAL_COMPONENTS_DIR: "src/components",
|
|
98
|
+
LOCAL_UTILS_DIR: "src/lib/utils",
|
|
99
|
+
VSCODE_DIR: ".vscode",
|
|
100
|
+
VSCODE_SNIPPETS_FILE: ".vscode/starwind.code-snippets"
|
|
96
101
|
};
|
|
97
102
|
var ASTRO_PACKAGES = {
|
|
98
103
|
core: "astro@latest"
|
|
@@ -140,6 +145,7 @@ var defaultConfig = {
|
|
|
140
145
|
// components: "@/components",
|
|
141
146
|
// },
|
|
142
147
|
componentDir: "src/components/starwind",
|
|
148
|
+
utilsDir: PATHS.LOCAL_UTILS_DIR,
|
|
143
149
|
components: []
|
|
144
150
|
};
|
|
145
151
|
async function getConfig() {
|
|
@@ -182,6 +188,7 @@ async function updateConfig(updates, options = { appendComponents: true }) {
|
|
|
182
188
|
...updates.tailwind || {}
|
|
183
189
|
},
|
|
184
190
|
componentDir: updates.componentDir ? updates.componentDir : currentConfig.componentDir,
|
|
191
|
+
utilsDir: updates.utilsDir ? updates.utilsDir : currentConfig.utilsDir ?? defaultConfig.utilsDir,
|
|
185
192
|
components: finalComponents
|
|
186
193
|
};
|
|
187
194
|
try {
|
|
@@ -226,6 +233,7 @@ var componentSchema = z.object({
|
|
|
226
233
|
name: z.string(),
|
|
227
234
|
version: z.string(),
|
|
228
235
|
dependencies: z.array(z.string()).default([]),
|
|
236
|
+
fileDependencies: z.array(z.string()).optional(),
|
|
229
237
|
type: z.enum(["component"])
|
|
230
238
|
});
|
|
231
239
|
var registryRootSchema = z.object({
|
|
@@ -274,25 +282,74 @@ async function getAllComponents(forceRefresh = false) {
|
|
|
274
282
|
}
|
|
275
283
|
|
|
276
284
|
// src/utils/component.ts
|
|
277
|
-
|
|
285
|
+
function resolveConfigPath(directory) {
|
|
286
|
+
if (directory.startsWith("@/")) {
|
|
287
|
+
return path.join("src", directory.slice(2));
|
|
288
|
+
}
|
|
289
|
+
return directory;
|
|
290
|
+
}
|
|
291
|
+
function normalizeFileDependencyPath(fileDependency) {
|
|
292
|
+
const normalized = fileDependency.replace(/\\/g, "/");
|
|
293
|
+
if (path.posix.isAbsolute(normalized)) {
|
|
294
|
+
throw new Error(`File dependency "${fileDependency}" must be a relative path`);
|
|
295
|
+
}
|
|
296
|
+
const trimmed = normalized.startsWith("starwind/") ? normalized.slice("starwind/".length) : normalized;
|
|
297
|
+
const safePath = path.posix.normalize(trimmed);
|
|
298
|
+
if (safePath.startsWith("..") || safePath === "." || safePath.length === 0) {
|
|
299
|
+
throw new Error(`File dependency "${fileDependency}" contains an invalid path`);
|
|
300
|
+
}
|
|
301
|
+
return safePath;
|
|
302
|
+
}
|
|
303
|
+
async function copyFileDependencies(options) {
|
|
304
|
+
const { coreDir, fileDependencies, utilsDir } = options;
|
|
305
|
+
if (fileDependencies.length === 0) return;
|
|
306
|
+
const targetUtilsRoot = path.join(resolveConfigPath(utilsDir), "starwind");
|
|
307
|
+
const sourceUtilsRoot = path.join(coreDir, PATHS.STARWIND_CORE_UTILS, "starwind");
|
|
308
|
+
await fs2.ensureDir(targetUtilsRoot);
|
|
309
|
+
for (const fileDependency of fileDependencies) {
|
|
310
|
+
const relativePath = normalizeFileDependencyPath(fileDependency);
|
|
311
|
+
const sourcePath = path.join(sourceUtilsRoot, relativePath);
|
|
312
|
+
const destinationPath = path.join(targetUtilsRoot, relativePath);
|
|
313
|
+
if (!await fs2.pathExists(sourcePath)) {
|
|
314
|
+
throw new Error(
|
|
315
|
+
`File dependency "${fileDependency}" for component is missing from ${PATHS.STARWIND_CORE_UTILS}/starwind`
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
await fs2.ensureDir(path.dirname(destinationPath));
|
|
319
|
+
await fs2.copy(sourcePath, destinationPath, { overwrite: true });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async function copyComponent(name, overwrite = false, options) {
|
|
278
323
|
const config = await getConfig();
|
|
279
324
|
const currentComponents = Array.isArray(config.components) ? config.components : [];
|
|
280
|
-
if (!overwrite && currentComponents.some((component) => component.name === name)) {
|
|
281
|
-
const existingComponent = currentComponents.find((c) => c.name === name);
|
|
282
|
-
return {
|
|
283
|
-
status: "skipped",
|
|
284
|
-
name,
|
|
285
|
-
version: existingComponent?.version ?? "unknown"
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
const componentDir = path.join(config.componentDir, "starwind", name);
|
|
289
325
|
try {
|
|
290
|
-
await
|
|
291
|
-
const
|
|
326
|
+
const registry = await getRegistry();
|
|
327
|
+
const componentInfo = registry.find((component) => component.name === name);
|
|
328
|
+
if (!componentInfo) {
|
|
329
|
+
throw new Error(`Component ${name} not found in registry`);
|
|
330
|
+
}
|
|
331
|
+
const fileDependencies = componentInfo.fileDependencies ?? [];
|
|
332
|
+
const resolvePackageUrl = options?.resolvePackageUrl ?? ((specifier) => import.meta.resolve?.(specifier));
|
|
333
|
+
const pkgUrl = resolvePackageUrl(PATHS.STARWIND_CORE);
|
|
292
334
|
if (!pkgUrl) {
|
|
293
335
|
throw new Error(`Could not resolve ${PATHS.STARWIND_CORE} package, is it installed?`);
|
|
294
336
|
}
|
|
295
337
|
const coreDir = path.dirname(fileURLToPath(pkgUrl));
|
|
338
|
+
if (!overwrite && currentComponents.some((component) => component.name === name)) {
|
|
339
|
+
await copyFileDependencies({
|
|
340
|
+
coreDir,
|
|
341
|
+
fileDependencies,
|
|
342
|
+
utilsDir: config.utilsDir || PATHS.LOCAL_UTILS_DIR
|
|
343
|
+
});
|
|
344
|
+
const existingComponent = currentComponents.find((c) => c.name === name);
|
|
345
|
+
return {
|
|
346
|
+
status: "skipped",
|
|
347
|
+
name,
|
|
348
|
+
version: existingComponent?.version ?? "unknown"
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const componentDir = path.join(config.componentDir, "starwind", name);
|
|
352
|
+
await fs2.ensureDir(componentDir);
|
|
296
353
|
const sourceDir = path.join(coreDir, PATHS.STARWIND_CORE_COMPONENTS, name);
|
|
297
354
|
const files = await fs2.readdir(sourceDir);
|
|
298
355
|
for (const file of files) {
|
|
@@ -300,11 +357,11 @@ async function copyComponent(name, overwrite = false) {
|
|
|
300
357
|
const destPath = path.join(componentDir, file);
|
|
301
358
|
await fs2.copy(sourcePath, destPath, { overwrite: true });
|
|
302
359
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
360
|
+
await copyFileDependencies({
|
|
361
|
+
coreDir,
|
|
362
|
+
fileDependencies,
|
|
363
|
+
utilsDir: config.utilsDir || PATHS.LOCAL_UTILS_DIR
|
|
364
|
+
});
|
|
308
365
|
return {
|
|
309
366
|
status: "installed",
|
|
310
367
|
name,
|
|
@@ -1100,9 +1157,9 @@ var tailwindConfig = `@import "tailwindcss";
|
|
|
1100
1157
|
--primary: var(--color-blue-700);
|
|
1101
1158
|
--primary-foreground: var(--color-neutral-50);
|
|
1102
1159
|
--primary-accent: var(--color-blue-700);
|
|
1103
|
-
--secondary: var(--color-
|
|
1104
|
-
--secondary-foreground: var(--color-neutral-
|
|
1105
|
-
--secondary-accent: var(--color-
|
|
1160
|
+
--secondary: var(--color-neutral-200);
|
|
1161
|
+
--secondary-foreground: var(--color-neutral-950);
|
|
1162
|
+
--secondary-accent: var(--color-neutral-950);
|
|
1106
1163
|
--muted: var(--color-neutral-100);
|
|
1107
1164
|
--muted-foreground: var(--color-neutral-600);
|
|
1108
1165
|
--accent: var(--color-neutral-100);
|
|
@@ -1141,9 +1198,9 @@ var tailwindConfig = `@import "tailwindcss";
|
|
|
1141
1198
|
--primary: var(--color-blue-700);
|
|
1142
1199
|
--primary-foreground: var(--color-neutral-50);
|
|
1143
1200
|
--primary-accent: var(--color-blue-400);
|
|
1144
|
-
--secondary: var(--color-
|
|
1201
|
+
--secondary: var(--color-neutral-800);
|
|
1145
1202
|
--secondary-foreground: var(--color-neutral-50);
|
|
1146
|
-
--secondary-accent: var(--color-
|
|
1203
|
+
--secondary-accent: var(--color-neutral-50);
|
|
1147
1204
|
--muted: var(--color-neutral-800);
|
|
1148
1205
|
--muted-foreground: var(--color-neutral-400);
|
|
1149
1206
|
--accent: var(--color-neutral-700);
|
|
@@ -1371,6 +1428,28 @@ async function setupStarwindProEnv() {
|
|
|
1371
1428
|
const gitignoreResult = await setupGitignore();
|
|
1372
1429
|
return envResult && gitignoreResult;
|
|
1373
1430
|
}
|
|
1431
|
+
async function checkStarwindProEnv() {
|
|
1432
|
+
const envExists = await fileExists(ENV_LOCAL_PATH);
|
|
1433
|
+
if (!envExists) return false;
|
|
1434
|
+
try {
|
|
1435
|
+
const envContent = await fs4.readFile(ENV_LOCAL_PATH, "utf-8");
|
|
1436
|
+
if (!hasStarwindLicenseKey(envContent)) return false;
|
|
1437
|
+
} catch {
|
|
1438
|
+
return false;
|
|
1439
|
+
}
|
|
1440
|
+
const gitignoreExists = await fileExists(GITIGNORE_PATH);
|
|
1441
|
+
if (gitignoreExists) {
|
|
1442
|
+
try {
|
|
1443
|
+
const gitignoreContent = await fs4.readFile(GITIGNORE_PATH, "utf-8");
|
|
1444
|
+
if (!hasEnvLocalInGitignore(gitignoreContent)) return false;
|
|
1445
|
+
} catch {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
} else {
|
|
1449
|
+
return false;
|
|
1450
|
+
}
|
|
1451
|
+
return true;
|
|
1452
|
+
}
|
|
1374
1453
|
|
|
1375
1454
|
// src/utils/layout.ts
|
|
1376
1455
|
import * as p6 from "@clack/prompts";
|
|
@@ -1446,6 +1525,63 @@ async function setupLayoutCssImport(cssPath) {
|
|
|
1446
1525
|
}
|
|
1447
1526
|
}
|
|
1448
1527
|
|
|
1528
|
+
// src/utils/snippets.ts
|
|
1529
|
+
var THEME_TOGGLE_SNIPPET = {
|
|
1530
|
+
"Starwind UI Theme Toggle": {
|
|
1531
|
+
prefix: "starwind-theme-toggle",
|
|
1532
|
+
description: "Starwind UI theme initialization script for the document head",
|
|
1533
|
+
scope: "astro,typescript",
|
|
1534
|
+
body: [
|
|
1535
|
+
"<script is:inline>",
|
|
1536
|
+
" function initTheme() {",
|
|
1537
|
+
' const colorTheme = localStorage.getItem("colorTheme");',
|
|
1538
|
+
" if (!colorTheme) {",
|
|
1539
|
+
' if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {',
|
|
1540
|
+
' document.documentElement.classList.add("dark");',
|
|
1541
|
+
' localStorage.setItem("colorTheme", "dark");',
|
|
1542
|
+
" } else {",
|
|
1543
|
+
' document.documentElement.classList.remove("dark");',
|
|
1544
|
+
' localStorage.setItem("colorTheme", "light");',
|
|
1545
|
+
" }",
|
|
1546
|
+
" } else {",
|
|
1547
|
+
' if (colorTheme === "dark") {',
|
|
1548
|
+
' document.documentElement.classList.add("dark");',
|
|
1549
|
+
' } else if (colorTheme === "light") {',
|
|
1550
|
+
' document.documentElement.classList.remove("dark");',
|
|
1551
|
+
' } else if (colorTheme === "system") {',
|
|
1552
|
+
' const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;',
|
|
1553
|
+
' document.documentElement.classList.toggle("dark", prefersDark);',
|
|
1554
|
+
" }",
|
|
1555
|
+
" }",
|
|
1556
|
+
" }",
|
|
1557
|
+
"",
|
|
1558
|
+
" initTheme();",
|
|
1559
|
+
' document.addEventListener("astro:after-swap", initTheme);',
|
|
1560
|
+
"</script>"
|
|
1561
|
+
]
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
async function setupSnippets() {
|
|
1565
|
+
await ensureDirectory(PATHS.VSCODE_DIR);
|
|
1566
|
+
const targetPath = PATHS.VSCODE_SNIPPETS_FILE;
|
|
1567
|
+
let existingSnippets = {};
|
|
1568
|
+
if (await fileExists(targetPath)) {
|
|
1569
|
+
try {
|
|
1570
|
+
existingSnippets = await readJsonFile(targetPath);
|
|
1571
|
+
} catch (error) {
|
|
1572
|
+
existingSnippets = {};
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
const updatedSnippets = {
|
|
1576
|
+
...existingSnippets,
|
|
1577
|
+
"Starwind UI Theme Toggle": {
|
|
1578
|
+
...THEME_TOGGLE_SNIPPET["Starwind UI Theme Toggle"]
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
await writeJsonFile(targetPath, updatedSnippets);
|
|
1582
|
+
return true;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1449
1585
|
// src/utils/tsconfig.ts
|
|
1450
1586
|
import * as p7 from "@clack/prompts";
|
|
1451
1587
|
var REQUIRED_TSCONFIG = {
|
|
@@ -1617,6 +1753,7 @@ async function init(withinAdd = false, options) {
|
|
|
1617
1753
|
}
|
|
1618
1754
|
);
|
|
1619
1755
|
}
|
|
1756
|
+
const utilsDir = PATHS.LOCAL_UTILS_DIR;
|
|
1620
1757
|
const cssFileDir = path2.dirname(configChoices.cssFile);
|
|
1621
1758
|
const componentInstallDir = path2.join(configChoices.installLocation, "starwind");
|
|
1622
1759
|
configTasks.push({
|
|
@@ -1628,6 +1765,14 @@ async function init(withinAdd = false, options) {
|
|
|
1628
1765
|
return "Created project structure";
|
|
1629
1766
|
}
|
|
1630
1767
|
});
|
|
1768
|
+
configTasks.push({
|
|
1769
|
+
title: "Setting up VS Code snippets",
|
|
1770
|
+
task: async () => {
|
|
1771
|
+
await setupSnippets();
|
|
1772
|
+
await sleep(250);
|
|
1773
|
+
return "VS Code snippets configured";
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1631
1776
|
configTasks.push({
|
|
1632
1777
|
title: "Setup Astro config file",
|
|
1633
1778
|
task: async () => {
|
|
@@ -1712,6 +1857,7 @@ async function init(withinAdd = false, options) {
|
|
|
1712
1857
|
// components: "@/components",
|
|
1713
1858
|
// },
|
|
1714
1859
|
componentDir: configChoices.installLocation,
|
|
1860
|
+
utilsDir,
|
|
1715
1861
|
components: []
|
|
1716
1862
|
});
|
|
1717
1863
|
await sleep(250);
|
|
@@ -1745,7 +1891,9 @@ async function init(withinAdd = false, options) {
|
|
|
1745
1891
|
});
|
|
1746
1892
|
} else {
|
|
1747
1893
|
if (!withinAdd) {
|
|
1748
|
-
p8.log.
|
|
1894
|
+
p8.log.warn(
|
|
1895
|
+
`${highlighter.warn("Starwind Pro registry already configured.")} Use the ${highlighter.info("setup")} command to update your Pro configuration.`
|
|
1896
|
+
);
|
|
1749
1897
|
}
|
|
1750
1898
|
}
|
|
1751
1899
|
}
|
|
@@ -1829,7 +1977,7 @@ async function init(withinAdd = false, options) {
|
|
|
1829
1977
|
Starwind Pro is now configured! You can install pro components using:
|
|
1830
1978
|
${highlighter.info("npx starwind@latest add @starwind-pro/component-name")}
|
|
1831
1979
|
|
|
1832
|
-
Make sure to set your ${highlighter.infoBright("STARWIND_LICENSE_KEY")} environment variable in ${highlighter.infoBright(".env.local")}
|
|
1980
|
+
Make sure to set your ${highlighter.infoBright("STARWIND_LICENSE_KEY")} environment variable in ${highlighter.infoBright(".env.local")}`;
|
|
1833
1981
|
}
|
|
1834
1982
|
p8.note(nextStepsMessage, "Next steps");
|
|
1835
1983
|
if (!withinAdd) {
|
|
@@ -2181,32 +2329,140 @@ ${results.removed.map((r) => ` ${r.name}`).join("\n")}`
|
|
|
2181
2329
|
}
|
|
2182
2330
|
}
|
|
2183
2331
|
|
|
2184
|
-
// src/commands/
|
|
2332
|
+
// src/commands/setup.ts
|
|
2185
2333
|
import * as p11 from "@clack/prompts";
|
|
2334
|
+
async function setup(options) {
|
|
2335
|
+
p11.intro(highlighter.title(" Using Starwind Setup "));
|
|
2336
|
+
try {
|
|
2337
|
+
const configExists = await fileExists(PATHS.LOCAL_CONFIG_FILE);
|
|
2338
|
+
if (!configExists) {
|
|
2339
|
+
const shouldInit = options?.yes ? true : await p11.confirm({
|
|
2340
|
+
message: `Starwind configuration not found. Would you like to run ${highlighter.info("starwind init")} now?`,
|
|
2341
|
+
initialValue: true
|
|
2342
|
+
});
|
|
2343
|
+
if (p11.isCancel(shouldInit)) {
|
|
2344
|
+
p11.cancel("Operation cancelled");
|
|
2345
|
+
process.exit(0);
|
|
2346
|
+
}
|
|
2347
|
+
if (shouldInit) {
|
|
2348
|
+
await init(true, { defaults: options?.yes, packageManager: options?.packageManager });
|
|
2349
|
+
} else {
|
|
2350
|
+
p11.log.error(
|
|
2351
|
+
`Please initialize starwind with ${highlighter.info("starwind init")} before running setup`
|
|
2352
|
+
);
|
|
2353
|
+
process.exit(1);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
const tasks4 = [
|
|
2357
|
+
{
|
|
2358
|
+
name: "Starwind Pro",
|
|
2359
|
+
value: "pro",
|
|
2360
|
+
flag: "pro",
|
|
2361
|
+
description: "Setup Starwind Pro registry and environment",
|
|
2362
|
+
run: runProSetup
|
|
2363
|
+
}
|
|
2364
|
+
// Future tasks (e.g., Prettier, ESLint) can be added here
|
|
2365
|
+
];
|
|
2366
|
+
const selectedTasks = [];
|
|
2367
|
+
if (options?.pro) {
|
|
2368
|
+
const proTask = tasks4.find((t) => t.value === "pro");
|
|
2369
|
+
if (proTask) selectedTasks.push(proTask);
|
|
2370
|
+
} else {
|
|
2371
|
+
const proTask = tasks4.find((t) => t.value === "pro");
|
|
2372
|
+
if (proTask) selectedTasks.push(proTask);
|
|
2373
|
+
}
|
|
2374
|
+
if (selectedTasks.length === 0) {
|
|
2375
|
+
p11.log.warn("No setup tasks selected.");
|
|
2376
|
+
process.exit(0);
|
|
2377
|
+
}
|
|
2378
|
+
for (const task of selectedTasks) {
|
|
2379
|
+
await task.run();
|
|
2380
|
+
}
|
|
2381
|
+
} catch (error) {
|
|
2382
|
+
p11.log.error(error instanceof Error ? error.message : "Failed to run setup");
|
|
2383
|
+
p11.cancel("Operation cancelled");
|
|
2384
|
+
process.exit(1);
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
async function runProSetup() {
|
|
2388
|
+
p11.log.info(highlighter.info("Setting up Starwind Pro..."));
|
|
2389
|
+
const configTasks = [];
|
|
2390
|
+
const hasRegistry = await hasStarwindProRegistry();
|
|
2391
|
+
const hasEnv = await checkStarwindProEnv();
|
|
2392
|
+
if (hasRegistry && hasEnv) {
|
|
2393
|
+
p11.log.info(highlighter.info("Starwind Pro registry and environment already configured"));
|
|
2394
|
+
} else {
|
|
2395
|
+
let cssFile = PATHS.LOCAL_CSS_FILE;
|
|
2396
|
+
let baseColor = "neutral";
|
|
2397
|
+
try {
|
|
2398
|
+
const config = await getConfig();
|
|
2399
|
+
if (config.tailwind?.css) cssFile = config.tailwind.css;
|
|
2400
|
+
if (config.tailwind?.baseColor) baseColor = config.tailwind.baseColor;
|
|
2401
|
+
} catch {
|
|
2402
|
+
}
|
|
2403
|
+
if (!hasRegistry) {
|
|
2404
|
+
configTasks.push({
|
|
2405
|
+
title: "Setting up Starwind Pro registry",
|
|
2406
|
+
task: async () => {
|
|
2407
|
+
await setupShadcnProConfig(cssFile, baseColor);
|
|
2408
|
+
await sleep(250);
|
|
2409
|
+
return "Configured Starwind Pro registry in components.json";
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
if (!hasEnv) {
|
|
2414
|
+
configTasks.push({
|
|
2415
|
+
title: "Setting up Starwind Pro environment",
|
|
2416
|
+
task: async () => {
|
|
2417
|
+
const success = await setupStarwindProEnv();
|
|
2418
|
+
if (!success) {
|
|
2419
|
+
throw new Error("Failed to setup Starwind Pro environment");
|
|
2420
|
+
}
|
|
2421
|
+
await sleep(250);
|
|
2422
|
+
return "Created .env.local and updated .gitignore";
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
if (configTasks.length > 0) {
|
|
2427
|
+
await p11.tasks(configTasks);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
await sleep(250);
|
|
2431
|
+
const nextStepsMessage = `Starwind Pro is now configured! You can install pro components using:
|
|
2432
|
+
${highlighter.info("npx starwind@latest add @starwind-pro/component-name")}
|
|
2433
|
+
|
|
2434
|
+
Make sure to set your ${highlighter.infoBright("STARWIND_LICENSE_KEY")} environment variable in ${highlighter.infoBright(".env.local")}`;
|
|
2435
|
+
p11.note(nextStepsMessage, "Next steps");
|
|
2436
|
+
await sleep(1e3);
|
|
2437
|
+
p11.outro("Enjoy using Starwind UI with Pro components! \u{1F680}");
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
// src/commands/update.ts
|
|
2441
|
+
import * as p12 from "@clack/prompts";
|
|
2186
2442
|
async function update(components, options) {
|
|
2187
2443
|
try {
|
|
2188
|
-
|
|
2444
|
+
p12.intro(highlighter.title(" Welcome to the Starwind CLI "));
|
|
2189
2445
|
const configExists = await fileExists(PATHS.LOCAL_CONFIG_FILE);
|
|
2190
2446
|
if (!configExists) {
|
|
2191
|
-
|
|
2447
|
+
p12.log.error("No Starwind configuration found. Please run starwind init first.");
|
|
2192
2448
|
process.exit(1);
|
|
2193
2449
|
}
|
|
2194
2450
|
const config = await getConfig();
|
|
2195
2451
|
const installedComponents = config.components;
|
|
2196
2452
|
if (installedComponents.length === 0) {
|
|
2197
|
-
|
|
2453
|
+
p12.log.warn("No components are currently installed.");
|
|
2198
2454
|
process.exit(0);
|
|
2199
2455
|
}
|
|
2200
2456
|
let componentsToUpdate = [];
|
|
2201
2457
|
if (options?.all) {
|
|
2202
2458
|
componentsToUpdate = installedComponents.map((comp) => comp.name);
|
|
2203
|
-
|
|
2459
|
+
p12.log.info(`Checking updates for all ${componentsToUpdate.length} installed components...`);
|
|
2204
2460
|
} else if (components && components.length > 0) {
|
|
2205
2461
|
const invalid = components.filter(
|
|
2206
2462
|
(comp) => !installedComponents.some((ic) => ic.name === comp)
|
|
2207
2463
|
);
|
|
2208
2464
|
if (invalid.length > 0) {
|
|
2209
|
-
|
|
2465
|
+
p12.log.warn(
|
|
2210
2466
|
`${highlighter.warn("Components not found in project:")}
|
|
2211
2467
|
${invalid.map((name) => ` ${name}`).join("\n")}`
|
|
2212
2468
|
);
|
|
@@ -2215,7 +2471,7 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
|
|
|
2215
2471
|
(comp) => installedComponents.some((ic) => ic.name === comp)
|
|
2216
2472
|
);
|
|
2217
2473
|
if (componentsToUpdate.length === 0) {
|
|
2218
|
-
|
|
2474
|
+
p12.log.warn("No valid components to update");
|
|
2219
2475
|
process.exit(0);
|
|
2220
2476
|
}
|
|
2221
2477
|
} else {
|
|
@@ -2223,18 +2479,18 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
|
|
|
2223
2479
|
value: comp.name,
|
|
2224
2480
|
label: comp.name
|
|
2225
2481
|
}));
|
|
2226
|
-
const selected = await
|
|
2482
|
+
const selected = await p12.multiselect({
|
|
2227
2483
|
message: "Select components to update",
|
|
2228
2484
|
options: choices
|
|
2229
2485
|
});
|
|
2230
|
-
if (
|
|
2231
|
-
|
|
2486
|
+
if (p12.isCancel(selected)) {
|
|
2487
|
+
p12.cancel("Operation cancelled");
|
|
2232
2488
|
process.exit(0);
|
|
2233
2489
|
}
|
|
2234
2490
|
componentsToUpdate = selected;
|
|
2235
2491
|
}
|
|
2236
2492
|
if (componentsToUpdate.length === 0) {
|
|
2237
|
-
|
|
2493
|
+
p12.log.warn("No components selected for update");
|
|
2238
2494
|
process.exit(0);
|
|
2239
2495
|
}
|
|
2240
2496
|
const results = {
|
|
@@ -2285,45 +2541,45 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
|
|
|
2285
2541
|
{ appendComponents: false }
|
|
2286
2542
|
);
|
|
2287
2543
|
} catch (error) {
|
|
2288
|
-
|
|
2544
|
+
p12.log.error(
|
|
2289
2545
|
`Failed to update config: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
2290
2546
|
);
|
|
2291
2547
|
process.exit(1);
|
|
2292
2548
|
}
|
|
2293
2549
|
}
|
|
2294
|
-
|
|
2550
|
+
p12.log.message(`
|
|
2295
2551
|
|
|
2296
2552
|
${highlighter.underline("Update Summary")}`);
|
|
2297
2553
|
if (results.failed.length > 0) {
|
|
2298
|
-
|
|
2554
|
+
p12.log.error(
|
|
2299
2555
|
`${highlighter.error("Failed to update components:")}
|
|
2300
2556
|
${results.failed.map((r) => ` ${r.name} - ${r.error}`).join("\n")}`
|
|
2301
2557
|
);
|
|
2302
2558
|
}
|
|
2303
2559
|
if (results.skipped.length > 0) {
|
|
2304
|
-
|
|
2560
|
+
p12.log.info(
|
|
2305
2561
|
`${highlighter.info("Components already up to date or skipped:")}
|
|
2306
2562
|
${results.skipped.map((r) => ` ${r.name} (${r.oldVersion})`).join("\n")}`
|
|
2307
2563
|
);
|
|
2308
2564
|
}
|
|
2309
2565
|
if (results.updated.length > 0) {
|
|
2310
|
-
|
|
2566
|
+
p12.log.success(
|
|
2311
2567
|
`${highlighter.success("Successfully updated components:")}
|
|
2312
2568
|
${results.updated.map((r) => ` ${r.name} (${r.oldVersion} \u2192 ${r.newVersion})`).join("\n")}`
|
|
2313
2569
|
);
|
|
2314
2570
|
}
|
|
2315
2571
|
await sleep(1e3);
|
|
2316
2572
|
if (results.updated.length > 0) {
|
|
2317
|
-
|
|
2573
|
+
p12.outro("Components updated successfully \u{1F680}");
|
|
2318
2574
|
} else if (results.skipped.length > 0 && results.failed.length === 0) {
|
|
2319
|
-
|
|
2575
|
+
p12.outro("Components already up to date or skipped \u2728");
|
|
2320
2576
|
} else {
|
|
2321
|
-
|
|
2577
|
+
p12.cancel("No components were updated");
|
|
2322
2578
|
process.exit(1);
|
|
2323
2579
|
}
|
|
2324
2580
|
} catch (error) {
|
|
2325
|
-
|
|
2326
|
-
|
|
2581
|
+
p12.log.error(error instanceof Error ? error.message : "Failed to update components");
|
|
2582
|
+
p12.cancel("Operation cancelled");
|
|
2327
2583
|
process.exit(1);
|
|
2328
2584
|
}
|
|
2329
2585
|
}
|
|
@@ -2346,5 +2602,12 @@ program.command("update").description("Update Starwind components to their lates
|
|
|
2346
2602
|
])
|
|
2347
2603
|
).action(update);
|
|
2348
2604
|
program.command("remove").description("Remove Starwind components from your project").argument("[components...]", "The components to remove (space separated)").allowExcessArguments().option("-a, --all", "Remove all installed components").action(remove);
|
|
2605
|
+
program.command("setup").description("Setup Starwind Pro in your project").option("-y, --yes", "Skip confirmation prompts").addOption(
|
|
2606
|
+
new Option("-m, --package-manager <pm>", "Package manager to use").choices([
|
|
2607
|
+
"npm",
|
|
2608
|
+
"pnpm",
|
|
2609
|
+
"yarn"
|
|
2610
|
+
])
|
|
2611
|
+
).option("-p, --pro", "Setup Starwind Pro (default)").action(setup);
|
|
2349
2612
|
program.parse(process.argv);
|
|
2350
2613
|
//# sourceMappingURL=index.js.map
|