centoui-cli 1.14.0 → 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.d.mts CHANGED
@@ -23,8 +23,6 @@ interface CentoUIConfig {
23
23
  componentsDir: string;
24
24
  /** Relative path to the CSS file. */
25
25
  themeFilePath: string;
26
- /** Maps internal icon slot names to Iconify IDs. */
27
- icons: Record<string, string>;
28
26
  }
29
27
  /** Partial package.json structure needed by the CLI. */
30
28
  interface PackageJson {
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { addDependency, removeDependency } from "nypm";
7
7
  //#endregion
8
8
  //#region src/constants.ts
9
9
  /** CentoUI current package version, sourced directly from package.json. */
10
- const VERSION = "1.14.0";
10
+ const VERSION = "1.16.0";
11
11
  /** File name for the user-side CentoUI config (created by `centoui init`). */
12
12
  const CONFIG_FILE_NAME = "centoui.config.ts";
13
13
  /**
@@ -27,43 +27,6 @@ const GITHUB_RAW_FETCH_HEADERS = {
27
27
  "X-GitHub-Api-Version": "2026-03-10"
28
28
  };
29
29
  //#endregion
30
- //#region src/utils/network.ts
31
- /**
32
- * Sends a network request to the CentoUI core package on GitHub.
33
- * @param path The relative path to the file from the base URL (i.e. core/src).
34
- * @param responseFormat The format of the response.
35
- * @param init The request options.
36
- * @returns The response from the server.
37
- * @throws If the network request fails or the server returns a non-2xx status.
38
- */
39
- async function sendNetworkRequest(path, responseFormat = "text", init) {
40
- const url = `${BASE_URL}${path}`;
41
- const resolvedInit = {
42
- ...init,
43
- headers: {
44
- ...GITHUB_RAW_FETCH_HEADERS,
45
- ...init?.headers
46
- }
47
- };
48
- let response;
49
- try {
50
- response = await fetch(url, resolvedInit);
51
- } catch (error) {
52
- throw new Error("Network request failed", { cause: error });
53
- }
54
- if (!response.ok) throw new Error(`Server responded with ${response.status} ${response.statusText} (URL: ${url})`);
55
- let resolvedResponse;
56
- switch (responseFormat) {
57
- case "json":
58
- resolvedResponse = await response.json();
59
- break;
60
- case "text":
61
- resolvedResponse = await response.text();
62
- break;
63
- }
64
- return resolvedResponse;
65
- }
66
- //#endregion
67
30
  //#region src/utils/config.ts
68
31
  /**
69
32
  * Loads the user's CentoUI configuration from `centoui.config.ts`.
@@ -83,24 +46,14 @@ async function loadConfig$1(cwd) {
83
46
  * Builds the user's CentoUI configuration file content.
84
47
  * @param choices The user's configuration choices.
85
48
  * @returns The file content.
86
- * @throws If building fails.
87
49
  */
88
- async function buildUserConfig(choices) {
89
- try {
90
- let cleanedContent = (await sendNetworkRequest("/config.ts")).replaceAll(/^import\s+.*$/gm, "").replace(/^\s*export\s+default\s+/, "").replace(/\s+satisfies\s+[^}]*$/, "").trim();
91
- const firstBrace = cleanedContent.indexOf("{");
92
- const lastBrace = cleanedContent.lastIndexOf("}");
93
- cleanedContent = cleanedContent.slice(firstBrace + 1, lastBrace).replace(/^\n/, "").replace(/\n\s*$/, "");
94
- return `import { defineConfig } from 'centoui'
50
+ function buildUserConfig(choices) {
51
+ return `import { defineConfig } from 'centoui'
95
52
 
96
53
  export default defineConfig({
97
54
  componentsDir: '${choices.componentsDir}',
98
55
  themeFilePath: '${choices.themeFilePath}',
99
- ${cleanedContent}
100
56
  })`;
101
- } catch (error) {
102
- throw new Error("Failed to build user config", { cause: error });
103
- }
104
57
  }
105
58
  //#endregion
106
59
  //#region src/utils/file-system.ts
@@ -147,6 +100,43 @@ async function confirmOverwrite(path) {
147
100
  return answer;
148
101
  }
149
102
  //#endregion
103
+ //#region src/utils/network.ts
104
+ /**
105
+ * Sends a network request to the CentoUI core package on GitHub.
106
+ * @param path The relative path to the file from the base URL (i.e. core/src).
107
+ * @param responseFormat The format of the response.
108
+ * @param init The request options.
109
+ * @returns The response from the server.
110
+ * @throws If the network request fails or the server returns a non-2xx status.
111
+ */
112
+ async function sendNetworkRequest(path, responseFormat = "text", init) {
113
+ const url = `${BASE_URL}${path}`;
114
+ const resolvedInit = {
115
+ ...init,
116
+ headers: {
117
+ ...GITHUB_RAW_FETCH_HEADERS,
118
+ ...init?.headers
119
+ }
120
+ };
121
+ let response;
122
+ try {
123
+ response = await fetch(url, resolvedInit);
124
+ } catch (error) {
125
+ throw new Error("Network request failed", { cause: error });
126
+ }
127
+ if (!response.ok) throw new Error(`Server responded with ${response.status} ${response.statusText} (URL: ${url})`);
128
+ let resolvedResponse;
129
+ switch (responseFormat) {
130
+ case "json":
131
+ resolvedResponse = await response.json();
132
+ break;
133
+ case "text":
134
+ resolvedResponse = await response.text();
135
+ break;
136
+ }
137
+ return resolvedResponse;
138
+ }
139
+ //#endregion
150
140
  //#region src/utils/package.ts
151
141
  /**
152
142
  * Installs a dependency using nypm.
@@ -340,7 +330,7 @@ function init() {
340
330
  enabled: shouldWriteTheme,
341
331
  task: async (message) => {
342
332
  message("Fetching theme from registry.");
343
- const themeFileContent = await sendNetworkRequest("/theme.css");
333
+ const themeFileContent = await sendNetworkRequest("/css/theme.css");
344
334
  message("Writing to disk.");
345
335
  await writeToFile(themePath, themeFileContent);
346
336
  return "Theme created!";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "centoui-cli",
3
3
  "type": "module",
4
- "version": "1.14.0",
4
+ "version": "1.16.0",
5
5
  "private": false,
6
6
  "description": "Official CLI for CentoUI.",
7
7
  "author": "Favour Emeka <favorodera@gmail.com>",