centoui-cli 0.2.1 → 0.2.2
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.mjs +8 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { pathToFileURL } from "node:url";
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/constants.ts
|
|
10
10
|
/** CentoUI current package version */
|
|
11
|
-
const VERSION = "0.2.
|
|
11
|
+
const VERSION = "0.2.2";
|
|
12
12
|
/** CentoUI config file name */
|
|
13
13
|
const CONFIG_FILE_NAME = "centoui.config.ts";
|
|
14
14
|
/** CentoUI registry file name */
|
|
@@ -77,7 +77,7 @@ function validatePath(path) {
|
|
|
77
77
|
* @returns The destination path for the component file.
|
|
78
78
|
*/
|
|
79
79
|
function resolveComponentsDestinationPath(path, config, cwd) {
|
|
80
|
-
const normalizedPath = path.replace(/^
|
|
80
|
+
const normalizedPath = path.replace(/^components\//, "");
|
|
81
81
|
return join(cwd, config.componentsDir, normalizedPath);
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
@@ -188,11 +188,11 @@ function resolveComponentTree(name, registry, seen = /* @__PURE__ */ new Set())
|
|
|
188
188
|
/**
|
|
189
189
|
* Fetches the raw source code of a component or utility file from the registry.
|
|
190
190
|
*
|
|
191
|
-
* @param
|
|
191
|
+
* @param path - Path as listed in the component registry (e.g. 'components/button/button.vue')
|
|
192
192
|
* @returns The raw source code of the file
|
|
193
193
|
*/
|
|
194
|
-
async function fetchComponentFile(
|
|
195
|
-
const requestUrl = `${BASE_URL}/${
|
|
194
|
+
async function fetchComponentFile(path) {
|
|
195
|
+
const requestUrl = `${BASE_URL}/${path}`;
|
|
196
196
|
const response = await fetch(requestUrl, { headers: FETCH_HEADERS });
|
|
197
197
|
if (!response.ok) throw new Error(`${response.status}: ${response.statusText}`);
|
|
198
198
|
return response.text();
|
|
@@ -354,9 +354,9 @@ function add() {
|
|
|
354
354
|
await tasks([...componentsToInstall.map(([name, entry]) => ({
|
|
355
355
|
title: `Installing ${name}`,
|
|
356
356
|
task: async () => {
|
|
357
|
-
for (const
|
|
358
|
-
const content = await fetchComponentFile(
|
|
359
|
-
await writeFile(resolveComponentsDestinationPath(
|
|
357
|
+
for (const path of entry.files) {
|
|
358
|
+
const content = await fetchComponentFile(path);
|
|
359
|
+
await writeFile(resolveComponentsDestinationPath(path, config, cwd), content);
|
|
360
360
|
}
|
|
361
361
|
return `${name} installed (${entry.files.length} file${entry.files.length !== 1 ? "s" : ""})`;
|
|
362
362
|
}
|