centoui-cli 1.0.0-alpha.35 → 1.0.0-alpha.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/index.mjs +27 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,11 +24,12 @@ pnpm dlx centoui init
|
|
|
24
24
|
|
|
25
25
|
**What it does:**
|
|
26
26
|
|
|
27
|
-
1. Prompts you for a component directory (default: `src/components/centoui`) and theme CSS path (default: `src/assets/css/centoui.css`).
|
|
27
|
+
1. Prompts you for a component directory (default: `src/components/centoui`), a utils file path (default: `src/utils/centoui-utils.ts`), and theme CSS path (default: `src/assets/css/centoui.css`).
|
|
28
28
|
2. Writes `centoui.config.ts` with your chosen paths and default icon mappings.
|
|
29
29
|
3. Fetches and writes the `centoui.css` theme file with all light/dark color tokens.
|
|
30
|
-
4.
|
|
31
|
-
5.
|
|
30
|
+
4. Writes the `centoui-utils.ts` file with all utility functions.
|
|
31
|
+
5. Creates the component directory.
|
|
32
|
+
6. Installs global peer dependencies (`vue`, `reka-ui`, `tailwindcss`, etc.).
|
|
32
33
|
|
|
33
34
|
---
|
|
34
35
|
|
|
@@ -93,6 +94,7 @@ import { defineConfig } from "centoui"
|
|
|
93
94
|
export default defineConfig({
|
|
94
95
|
componentsDir: "./src/components/centoui",
|
|
95
96
|
themeFilePath: "./src/assets/css/centoui.css",
|
|
97
|
+
utilsFilePath: "./src/utils/centoui-utils.ts",
|
|
96
98
|
icons: {
|
|
97
99
|
check: "lucide:check",
|
|
98
100
|
close: "lucide:x",
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { loadConfig } from "c12";
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/constants.ts
|
|
10
10
|
/** CentoUI current package version, sourced directly from package.json. */
|
|
11
|
-
const VERSION = "1.0.0-alpha.
|
|
11
|
+
const VERSION = "1.0.0-alpha.37";
|
|
12
12
|
/** File name for the user-side CentoUI config (created by `centoui init`). */
|
|
13
13
|
const CONFIG_FILE_NAME = "centoui.config.ts";
|
|
14
14
|
/**
|
|
@@ -26,7 +26,11 @@ const REGISTRY_INDEX_URL = `${`${CORE_SRC_BASE_URL}/registry`}/index.json`;
|
|
|
26
26
|
* This file is written to the user's project during `centoui init`.
|
|
27
27
|
*/
|
|
28
28
|
const THEME_CSS_URL = `${CORE_SRC_BASE_URL}/defaults/centoui.css`;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Full URL to the utils file.
|
|
31
|
+
* This file is written to the user's project during `centoui init`.
|
|
32
|
+
*/
|
|
33
|
+
const UTILS_FILE_URL = `${CORE_SRC_BASE_URL}/defaults/utils.ts`;
|
|
30
34
|
/**
|
|
31
35
|
* Full URL to the default values file for the CentoUI config.
|
|
32
36
|
* The contents of this file are written to the user's project during `centoui init`.
|
|
@@ -379,6 +383,25 @@ async function fetchThemeCSSContent() {
|
|
|
379
383
|
if (!response.ok) throw new Error(`[fetchThemeCSSContent] Server returned ${response.status} ${response.statusText} (URL: ${THEME_CSS_URL})`);
|
|
380
384
|
return response.text();
|
|
381
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Fetches the raw content of the CentoUI utils file from GitHub.
|
|
388
|
+
*
|
|
389
|
+
* This is the file written to the user's project during `centoui init` and
|
|
390
|
+
* contains all global utils for every component.
|
|
391
|
+
*
|
|
392
|
+
* @returns Raw UTF-8 content of the utils file.
|
|
393
|
+
* @throws If the network request fails or the server returns a non-2xx status.
|
|
394
|
+
*/
|
|
395
|
+
async function fetchUtilsFileContent() {
|
|
396
|
+
let response;
|
|
397
|
+
try {
|
|
398
|
+
response = await fetch(UTILS_FILE_URL, { headers: GITHUB_RAW_FETCH_HEADERS });
|
|
399
|
+
} catch (error) {
|
|
400
|
+
throw new Error(`[fetchUtilsFileContent] Network request for utils file failed: ${error}`);
|
|
401
|
+
}
|
|
402
|
+
if (!response.ok) throw new Error(`[fetchUtilsFileContent] Server returned ${response.status} ${response.statusText} (URL: ${UTILS_FILE_URL})`);
|
|
403
|
+
return response.text();
|
|
404
|
+
}
|
|
382
405
|
//#endregion
|
|
383
406
|
//#region src/commands/init.ts
|
|
384
407
|
/**
|
|
@@ -455,7 +478,8 @@ function init() {
|
|
|
455
478
|
title: "Writing utils file",
|
|
456
479
|
task: async () => {
|
|
457
480
|
if (!shouldWriteUtils) return `Skipped — "${directories.utilsFilePath}" already exists`;
|
|
458
|
-
await
|
|
481
|
+
const utilsContent = await fetchUtilsFileContent();
|
|
482
|
+
await fsExtra.outputFile(utilsPath, utilsContent, "utf-8");
|
|
459
483
|
return `${directories.utilsFilePath} written`;
|
|
460
484
|
}
|
|
461
485
|
},
|