centoui-cli 1.0.0-alpha.34 → 1.0.0-alpha.36
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.d.mts +2 -1
- package/dist/index.mjs +45 -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.d.mts
CHANGED
|
@@ -49,7 +49,8 @@ type Registry = {
|
|
|
49
49
|
*/
|
|
50
50
|
type CentoUIConfig = {
|
|
51
51
|
/** Relative path (from project root) to the directory where components are installed. */componentsDir: string; /** Relative path (from project root) to the CSS file that receives theme and component styles. */
|
|
52
|
-
themeFilePath: string;
|
|
52
|
+
themeFilePath: string; /** Relative path (from project root) to the utils file. */
|
|
53
|
+
utilsFilePath: string;
|
|
53
54
|
/**
|
|
54
55
|
* Maps internal CentoUI icon slot names to Iconify icon IDs.
|
|
55
56
|
* Components reference icon slots by their internal name so you can swap icon libraries freely.
|
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.36";
|
|
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
|
/**
|
|
@@ -27,6 +27,11 @@ const REGISTRY_INDEX_URL = `${`${CORE_SRC_BASE_URL}/registry`}/index.json`;
|
|
|
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`;
|
|
34
|
+
/**
|
|
30
35
|
* Full URL to the default values file for the CentoUI config.
|
|
31
36
|
* The contents of this file are written to the user's project during `centoui init`.
|
|
32
37
|
*/
|
|
@@ -271,14 +276,16 @@ function extractInnerConfigContent(fileContent) {
|
|
|
271
276
|
*
|
|
272
277
|
* @param themeFilePath - Relative path (from project root) where the CSS theme file lives.
|
|
273
278
|
* @param componentsDir - Relative path (from project root) where components will be installed.
|
|
279
|
+
* @param utilsFilePath - Relative path (from project root) where the utils file lives.
|
|
274
280
|
* @returns A string containing the complete TypeScript source for the config file.
|
|
275
281
|
*/
|
|
276
|
-
async function buildUserDefaultConfigFileContent(themeFilePath, componentsDir) {
|
|
282
|
+
async function buildUserDefaultConfigFileContent(themeFilePath, componentsDir, utilsFilePath) {
|
|
277
283
|
return `import { defineConfig } from 'centoui'
|
|
278
284
|
|
|
279
285
|
export default defineConfig({
|
|
280
286
|
componentsDir: '${componentsDir}',
|
|
281
287
|
themeFilePath: '${themeFilePath}',
|
|
288
|
+
utilsFilePath: '${utilsFilePath}',
|
|
282
289
|
${extractInnerConfigContent(await fetchDefaultConfig())}
|
|
283
290
|
})
|
|
284
291
|
`;
|
|
@@ -376,6 +383,25 @@ async function fetchThemeCSSContent() {
|
|
|
376
383
|
if (!response.ok) throw new Error(`[fetchThemeCSSContent] Server returned ${response.status} ${response.statusText} (URL: ${THEME_CSS_URL})`);
|
|
377
384
|
return response.text();
|
|
378
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
|
+
}
|
|
379
405
|
//#endregion
|
|
380
406
|
//#region src/commands/init.ts
|
|
381
407
|
/**
|
|
@@ -410,6 +436,11 @@ function init() {
|
|
|
410
436
|
message: "Path for the theme CSS file",
|
|
411
437
|
initialValue: "src/assets/css/centoui.css",
|
|
412
438
|
validate: validateNonEmptyPath
|
|
439
|
+
}),
|
|
440
|
+
utilsFilePath: () => text({
|
|
441
|
+
message: "Path for the utils file",
|
|
442
|
+
initialValue: "src/utils/centoui-utils.ts",
|
|
443
|
+
validate: validateNonEmptyPath
|
|
413
444
|
})
|
|
414
445
|
}, { onCancel: () => {
|
|
415
446
|
cancel("Initialization cancelled.");
|
|
@@ -418,16 +449,18 @@ function init() {
|
|
|
418
449
|
const configPath = join(cwd, CONFIG_FILE_NAME);
|
|
419
450
|
const themePath = join(cwd, directories.themeFilePath);
|
|
420
451
|
const componentsPath = join(cwd, directories.componentDir);
|
|
452
|
+
const utilsPath = join(cwd, directories.utilsFilePath);
|
|
421
453
|
const shouldWriteConfig = await confirmOverwriteIfExists(CONFIG_FILE_NAME, configPath);
|
|
422
454
|
const shouldWriteTheme = await confirmOverwriteIfExists(directories.themeFilePath, themePath);
|
|
423
455
|
const shouldWriteComponentsDir = await confirmOverwriteIfExists(directories.componentDir, componentsPath);
|
|
456
|
+
const shouldWriteUtils = await confirmOverwriteIfExists(directories.utilsFilePath, utilsPath);
|
|
424
457
|
let registry;
|
|
425
458
|
await tasks([
|
|
426
459
|
{
|
|
427
460
|
title: "Fetching config defaults",
|
|
428
461
|
task: async () => {
|
|
429
462
|
if (!shouldWriteConfig) return `Skipped — "${CONFIG_FILE_NAME}" already exists`;
|
|
430
|
-
const userConfigContent = await buildUserDefaultConfigFileContent(directories.themeFilePath, directories.componentDir);
|
|
463
|
+
const userConfigContent = await buildUserDefaultConfigFileContent(directories.themeFilePath, directories.componentDir, directories.utilsFilePath);
|
|
431
464
|
await fsExtra.outputFile(configPath, userConfigContent, "utf-8");
|
|
432
465
|
return `${CONFIG_FILE_NAME} written`;
|
|
433
466
|
}
|
|
@@ -441,6 +474,15 @@ function init() {
|
|
|
441
474
|
return `${directories.themeFilePath} written`;
|
|
442
475
|
}
|
|
443
476
|
},
|
|
477
|
+
{
|
|
478
|
+
title: "Writing utils file",
|
|
479
|
+
task: async () => {
|
|
480
|
+
if (!shouldWriteUtils) return `Skipped — "${directories.utilsFilePath}" already exists`;
|
|
481
|
+
const utilsContent = await fetchUtilsFileContent();
|
|
482
|
+
await fsExtra.outputFile(utilsPath, utilsContent, "utf-8");
|
|
483
|
+
return `${directories.utilsFilePath} written`;
|
|
484
|
+
}
|
|
485
|
+
},
|
|
444
486
|
{
|
|
445
487
|
title: "Preparing components directory",
|
|
446
488
|
task: async () => {
|