@weme-ui/weme-ui 0.1.1-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 weme-ui.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ <p align="center">
2
+ <img align="center" src="https://raw.githubusercontent.com/moujinet/assets/main/weme-ui/png/circle-128.png" height="128" />
3
+ <h1 align="center">
4
+ Weme UI <sup style="color: #4CBBA5">CLI</sup>
5
+ </h1>
6
+ </p>
7
+
8
+ [![npm version][npm-version-src]][npm-version-href]
9
+ [![License][license-src]][license-href]
10
+
11
+ <p align="center">
12
+ Re-usable UI components with Reka UI and UnoCSS.
13
+ </p>
14
+
15
+ ---
16
+
17
+ ## 鸣谢
18
+
19
+ - [UnoCSS][unocss-href]
20
+ - [Reka UI][reka-href]
21
+ - [Radix UI][radix-href]
22
+ - [shadcn/ui][shadcn-href]
23
+
24
+ ## 许可证
25
+
26
+ [MIT][license-href] License © 2025 [weme-ui][github-href]
27
+
28
+ [npm-version-src]: https://img.shields.io/npm/v/@weme-ui/weme-ui?style=flat&colorA=1d2129&colorB=4CBBA5
29
+ [npm-version-href]: https://npmjs.com/package/@weme-ui/weme-ui
30
+ [license-src]: https://img.shields.io/github/license/weme-ui/weme-ui.svg?style=flat&colorA=1d2129&colorB=4CBBA5
31
+ [license-href]: https://github.com/weme-ui/weme-ui/blob/main/LICENSE
32
+ [github-href]: https://github.com/weme-ui/weme-ui
33
+ [unocss-href]: https://unocss.dev
34
+ [reka-href]: https://reka-ui.com
35
+ [radix-href]: https://www.radix-ui.com
36
+ [shadcn-href]: https://ui.shadcn.com
@@ -0,0 +1,23 @@
1
+ import { defineCommand } from "citty";
2
+ import { cwd } from "node:process";
3
+
4
+ //#region src/commands/build/index.ts
5
+ var build_default = defineCommand({
6
+ meta: {
7
+ name: "build",
8
+ description: "Build your repository."
9
+ },
10
+ args: { cwd: {
11
+ type: "string",
12
+ description: "Change working directory.",
13
+ valueHint: "PATH",
14
+ default: cwd()
15
+ } },
16
+ async setup({ args }) {
17
+ await import("./manifest-BtSx8-dp.mjs").then((r) => r.default(args));
18
+ }
19
+ });
20
+
21
+ //#endregion
22
+ export { build_default as default };
23
+ //# sourceMappingURL=build-DPZMEzzf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-DPZMEzzf.mjs","names":[],"sources":["../src/commands/build/index.ts"],"sourcesContent":["import { cwd } from 'node:process'\nimport { defineCommand } from 'citty'\n\nexport default defineCommand({\n meta: {\n name: 'build',\n description: 'Build your repository.',\n },\n\n args: {\n cwd: {\n type: 'string',\n description: 'Change working directory.',\n valueHint: 'PATH',\n default: cwd(),\n },\n },\n\n async setup({ args }) {\n await import('./manifest').then(r => r.default(args))\n },\n})\n"],"mappings":";;;;AAGA,oBAAe,cAAc;CAC3B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CAED,MAAM,EACJ,KAAK;EACH,MAAM;EACN,aAAa;EACb,WAAW;EACX,SAAS,KAAK;EACf,EACF;CAED,MAAM,MAAM,EAAE,QAAQ;AACpB,QAAM,OAAO,2BAAc,MAAK,MAAK,EAAE,QAAQ,KAAK,CAAC;;CAExD,CAAC"}
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { defineCommand, runMain } from "citty";
3
+
4
+ //#region package.json
5
+ var version = "0.1.1-beta.2";
6
+ var description = "Re-usable UI components with Reka UI and UnoCSS.";
7
+
8
+ //#endregion
9
+ //#region src/cli.ts
10
+ const cli = defineCommand({
11
+ meta: {
12
+ name: "weme-ui",
13
+ version,
14
+ description
15
+ },
16
+ subCommands: {
17
+ init: () => import("./init-BHl8Lwuu.mjs").then((r) => r.default),
18
+ info: () => import("./info-Bz7qrvGn.mjs").then((r) => r.default),
19
+ build: () => import("./build-DPZMEzzf.mjs").then((r) => r.default)
20
+ }
21
+ });
22
+
23
+ //#endregion
24
+ //#region src/index.ts
25
+ runMain(cli);
26
+
27
+ //#endregion
28
+ export { };
29
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../package.json","../src/cli.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@weme-ui/weme-ui\",\n \"type\": \"module\",\n \"version\": \"0.1.1-beta.2\",\n \"packageManager\": \"pnpm@10.20.0\",\n \"description\": \"Re-usable UI components with Reka UI and UnoCSS.\",\n \"author\": \"Allen Luo <luoyi@mouji.net>\",\n \"license\": \"MIT\",\n \"homepage\": \"https://github.com/weme-ui/weme-ui\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/weme-ui/weme-ui.git\",\n \"directory\": \"packages/cli\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/weme-ui/weme-ui/issues\"\n },\n \"keywords\": [\n \"weme-ui\",\n \"reusable\",\n \"ui-components\",\n \"reka-ui\",\n \"unocss\"\n ],\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.mts\",\n \"import\": \"./dist/index.mjs\"\n }\n },\n \"main\": \"./dist/index.mjs\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"./dist/*\",\n \"./dist/index.d.mts\"\n ]\n }\n },\n \"bin\": \"./dist/index.mjs\",\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"scripts\": {\n \"build\": \"tsdown\",\n \"dev\": \"tsdown --watch\",\n \"dev:prepare\": \"pnpm run build\",\n \"prepublishOnly\": \"pnpm run build\",\n \"test\": \"vitest\",\n \"typecheck\": \"tsgo --noEmit\"\n },\n \"dependencies\": {\n \"@clack/prompts\": \"catalog:utils\",\n \"@weme-ui/schema\": \"catalog:dev\",\n \"chalk\": \"catalog:utils\",\n \"citty\": \"catalog:utils\",\n \"columnify\": \"catalog:utils\",\n \"debug\": \"catalog:utils\",\n \"handlebars\": \"catalog:utils\",\n \"make-fetch-happen\": \"catalog:utils\",\n \"mkdirp\": \"catalog:utils\",\n \"nypm\": \"catalog:utils\",\n \"ora\": \"catalog:utils\",\n \"pathe\": \"catalog:utils\",\n \"pkg-types\": \"catalog:utils\",\n \"scule\": \"catalog:utils\",\n \"tinyexec\": \"catalog:utils\",\n \"tinyglobby\": \"catalog:utils\",\n \"zod\": \"catalog:utils\"\n },\n \"devDependencies\": {\n \"@types/columnify\": \"catalog:utils\",\n \"@types/make-fetch-happen\": \"catalog:utils\",\n \"@types/node\": \"catalog:build\",\n \"bumpp\": \"catalog:build\",\n \"tsdown\": \"catalog:build\",\n \"typescript\": \"catalog:build\",\n \"vitest\": \"catalog:testing\"\n }\n}\n","import { defineCommand } from 'citty'\nimport { description, version } from '../package.json'\n\nexport const cli = defineCommand({\n meta: {\n name: 'weme-ui',\n version,\n description,\n },\n\n subCommands: {\n // add: () => import('./commands/add').then(r => r.default),\n init: () => import('./commands/init').then(r => r.default),\n info: () => import('./commands/info').then(r => r.default),\n build: () => import('./commands/build').then(r => r.default),\n },\n})\n","#!/usr/bin/env node\nimport { runMain } from 'citty'\nimport { cli } from './cli'\n\nrunMain(cli)\n"],"mappings":";;;;cAGa;kBAEI;;;;ACFjB,MAAa,MAAM,cAAc;CAC/B,MAAM;EACJ,MAAM;EACN;EACA;EACD;CAED,aAAa;EAEX,YAAY,OAAO,uBAAmB,MAAK,MAAK,EAAE,QAAQ;EAC1D,YAAY,OAAO,uBAAmB,MAAK,MAAK,EAAE,QAAQ;EAC1D,aAAa,OAAO,wBAAoB,MAAK,MAAK,EAAE,QAAQ;EAC7D;CACF,CAAC;;;;ACZF,QAAQ,IAAI"}
@@ -0,0 +1,41 @@
1
+ import { defineCommand } from "citty";
2
+ import { cwd } from "node:process";
3
+
4
+ //#region src/commands/info/index.ts
5
+ /**
6
+ * Usage
7
+ *
8
+ * - **Get information about current project**:
9
+ * - ```weme-ui info```
10
+ *
11
+ * - **Get information about added registry**:
12
+ * - ```weme-ui info weme-ui/std```
13
+ */
14
+ var info_default = defineCommand({
15
+ meta: {
16
+ name: "info",
17
+ description: "Get information about your project or added registry."
18
+ },
19
+ args: {
20
+ name: {
21
+ type: "positional",
22
+ required: false,
23
+ description: "Name of the registry.",
24
+ valueHint: "STRING"
25
+ },
26
+ cwd: {
27
+ type: "string",
28
+ description: "Change working directory.",
29
+ valueHint: "PATH",
30
+ default: cwd()
31
+ }
32
+ },
33
+ async setup({ args }) {
34
+ if (args.name) await import("./registry-CqjT93gC.mjs").then((r) => r.default(args));
35
+ else await import("./project-2Uhjf6-l.mjs").then((r) => r.default(args));
36
+ }
37
+ });
38
+
39
+ //#endregion
40
+ export { info_default as default };
41
+ //# sourceMappingURL=info-Bz7qrvGn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info-Bz7qrvGn.mjs","names":[],"sources":["../src/commands/info/index.ts"],"sourcesContent":["import { cwd } from 'node:process'\nimport { defineCommand } from 'citty'\n\n/**\n * Usage\n *\n * - **Get information about current project**:\n * - ```weme-ui info```\n *\n * - **Get information about added registry**:\n * - ```weme-ui info weme-ui/std```\n */\nexport default defineCommand({\n meta: {\n name: 'info',\n description: 'Get information about your project or added registry.',\n },\n\n args: {\n name: {\n type: 'positional',\n required: false,\n description: 'Name of the registry.',\n valueHint: 'STRING',\n },\n cwd: {\n type: 'string',\n description: 'Change working directory.',\n valueHint: 'PATH',\n default: cwd(),\n },\n },\n\n async setup({ args }) {\n if (args.name) {\n await import('./registry').then(r => r.default(args))\n }\n else {\n await import('./project').then(r => r.default(args))\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAYA,mBAAe,cAAc;CAC3B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CAED,MAAM;EACJ,MAAM;GACJ,MAAM;GACN,UAAU;GACV,aAAa;GACb,WAAW;GACZ;EACD,KAAK;GACH,MAAM;GACN,aAAa;GACb,WAAW;GACX,SAAS,KAAK;GACf;EACF;CAED,MAAM,MAAM,EAAE,QAAQ;AACpB,MAAI,KAAK,KACP,OAAM,OAAO,2BAAc,MAAK,MAAK,EAAE,QAAQ,KAAK,CAAC;MAGrD,OAAM,OAAO,0BAAa,MAAK,MAAK,EAAE,QAAQ,KAAK,CAAC;;CAGzD,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { defineCommand } from "citty";
2
+ import { cwd } from "node:process";
3
+
4
+ //#region src/commands/init/index.ts
5
+ /**
6
+ * Usage
7
+ *
8
+ * - **Initialize a new project**:
9
+ * - ```weme-ui init```
10
+ *
11
+ * - **Initialize a new project with default registry**:
12
+ * - ```weme-ui init weme-ui/plus --repo https://github.com/weme-ui/weme-ui```
13
+ *
14
+ * - **Initialize a new registry**:
15
+ * - ```weme-ui init weme-ui/plus --registry```
16
+ *
17
+ * - **Generate component skeleton**:
18
+ * - ```weme-ui init button --component```
19
+ */
20
+ var init_default = defineCommand({
21
+ meta: {
22
+ name: "init",
23
+ description: "Initialize a registry or project with Weme UI."
24
+ },
25
+ args: {
26
+ name: {
27
+ type: "positional",
28
+ required: false,
29
+ description: "Name of the scoped registry. (i.e. `weme-ui/std`)"
30
+ },
31
+ repo: {
32
+ type: "string",
33
+ description: "Change repository of the registry.",
34
+ valueHint: "STRING"
35
+ },
36
+ cwd: {
37
+ type: "string",
38
+ description: "Change working directory.",
39
+ valueHint: "PATH",
40
+ default: cwd()
41
+ },
42
+ registry: {
43
+ type: "boolean",
44
+ description: "Initialize a registry.",
45
+ alias: "r",
46
+ default: false
47
+ },
48
+ component: {
49
+ type: "boolean",
50
+ description: "Generate a component skeleton in your registry.",
51
+ alias: "c",
52
+ default: false
53
+ }
54
+ },
55
+ async setup({ args }) {
56
+ args.cwd = args.cwd || cwd();
57
+ if (args.registry) await import("./registry-Cm_OqNvK.mjs").then((r) => r.default(args));
58
+ else await import("./project-DH8JkbwF.mjs").then((r) => r.default(args));
59
+ }
60
+ });
61
+
62
+ //#endregion
63
+ export { init_default as default };
64
+ //# sourceMappingURL=init-BHl8Lwuu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-BHl8Lwuu.mjs","names":[],"sources":["../src/commands/init/index.ts"],"sourcesContent":["import { cwd } from 'node:process'\nimport { defineCommand } from 'citty'\n\n/**\n * Usage\n *\n * - **Initialize a new project**:\n * - ```weme-ui init```\n *\n * - **Initialize a new project with default registry**:\n * - ```weme-ui init weme-ui/plus --repo https://github.com/weme-ui/weme-ui```\n *\n * - **Initialize a new registry**:\n * - ```weme-ui init weme-ui/plus --registry```\n *\n * - **Generate component skeleton**:\n * - ```weme-ui init button --component```\n */\nexport default defineCommand({\n meta: {\n name: 'init',\n description: 'Initialize a registry or project with Weme UI.',\n },\n\n args: {\n name: {\n type: 'positional',\n required: false,\n description: 'Name of the scoped registry. (i.e. `weme-ui/std`)',\n },\n repo: {\n type: 'string',\n description: 'Change repository of the registry.',\n valueHint: 'STRING',\n },\n cwd: {\n type: 'string',\n description: 'Change working directory.',\n valueHint: 'PATH',\n default: cwd(),\n },\n registry: {\n type: 'boolean',\n description: 'Initialize a registry.',\n alias: 'r',\n default: false,\n },\n component: {\n type: 'boolean',\n description: 'Generate a component skeleton in your registry.',\n alias: 'c',\n default: false,\n },\n },\n\n async setup({ args }) {\n args.cwd = args.cwd || cwd()\n\n if (args.registry) {\n await import('./registry').then(r => r.default(args))\n }\n else {\n await import('./project').then(r => r.default(args))\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,mBAAe,cAAc;CAC3B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CAED,MAAM;EACJ,MAAM;GACJ,MAAM;GACN,UAAU;GACV,aAAa;GACd;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,WAAW;GACZ;EACD,KAAK;GACH,MAAM;GACN,aAAa;GACb,WAAW;GACX,SAAS,KAAK;GACf;EACD,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,WAAW;GACT,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;CAED,MAAM,MAAM,EAAE,QAAQ;AACpB,OAAK,MAAM,KAAK,OAAO,KAAK;AAE5B,MAAI,KAAK,SACP,OAAM,OAAO,2BAAc,MAAK,MAAK,EAAE,QAAQ,KAAK,CAAC;MAGrD,OAAM,OAAO,0BAAa,MAAK,MAAK,EAAE,QAAQ,KAAK,CAAC;;CAGzD,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { i as loadRegistryConfig, t as REGISTRY_DIRNAME } from "./registry-BChtLWfr.mjs";
2
+ import fs from "node:fs";
3
+ import * as p from "@clack/prompts";
4
+ import { DEFAULT_REGISTRY_PREFIX, MANIFEST_FILE_NAME, REGISTRY_FILE_NAME, manifestSchema } from "@weme-ui/schema";
5
+ import chalk from "chalk";
6
+ import path from "pathe";
7
+ import { glob } from "tinyglobby";
8
+
9
+ //#region src/commands/build/manifest.ts
10
+ async function manifest_default(args) {
11
+ p.intro(chalk.bold.blue("✨ Building Weme UI Repository"));
12
+ const registries = await loadRegistries(args.cwd);
13
+ await updateManifest(args.cwd, registries);
14
+ p.outro("🥤 All done!");
15
+ }
16
+ async function loadRegistries(cwd) {
17
+ const spinner = p.spinner();
18
+ spinner.start("Loading registries...");
19
+ const registries = (await glob([`**/${REGISTRY_FILE_NAME}`], {
20
+ cwd: path.resolve(cwd, REGISTRY_DIRNAME),
21
+ absolute: false,
22
+ onlyFiles: true,
23
+ ignore: ["**/node_modules/**"]
24
+ })).reduce((acc, file) => {
25
+ const directory = path.dirname(file);
26
+ const config = loadRegistryConfig(path.resolve(cwd, REGISTRY_DIRNAME, directory));
27
+ if (config.isOk()) {
28
+ const result = manifestSchema.safeParse({
29
+ name: config.unwrap().name,
30
+ description: config.unwrap().description,
31
+ version: config.unwrap().version || "0.0.0",
32
+ directory: path.join(REGISTRY_DIRNAME, directory),
33
+ prefix: config.unwrap().prefix || DEFAULT_REGISTRY_PREFIX,
34
+ access: config.unwrap().access || "public",
35
+ items: {
36
+ components: config.unwrap().items.filter((item) => item.type === "component").length,
37
+ layouts: config.unwrap().items.filter((item) => item.type === "layout").length,
38
+ themes: config.unwrap().items.filter((item) => item.type === "theme").length,
39
+ blocks: config.unwrap().items.filter((item) => item.type === "block").length,
40
+ pages: config.unwrap().items.filter((item) => item.type === "page").length
41
+ },
42
+ updated: (/* @__PURE__ */ new Date()).toISOString()
43
+ });
44
+ if (result.success) {
45
+ spinner.message(`Building ${result.data.name}...`);
46
+ acc.push(result.data);
47
+ }
48
+ }
49
+ return acc;
50
+ }, []);
51
+ spinner.stop("Registries loaded!");
52
+ return registries;
53
+ }
54
+ async function updateManifest(cwd, registries) {
55
+ const spinner = p.spinner();
56
+ spinner.start("Updating manifest...");
57
+ fs.writeFileSync(path.resolve(cwd, REGISTRY_DIRNAME, MANIFEST_FILE_NAME), `${JSON.stringify(registries, null, 2)}\n`);
58
+ spinner.stop("Manifest updated!");
59
+ }
60
+
61
+ //#endregion
62
+ export { manifest_default as default };
63
+ //# sourceMappingURL=manifest-BtSx8-dp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-BtSx8-dp.mjs","names":[],"sources":["../src/commands/build/manifest.ts"],"sourcesContent":["import type { ManifestSchema } from '@weme-ui/schema'\nimport fs from 'node:fs'\nimport * as p from '@clack/prompts'\nimport { DEFAULT_REGISTRY_PREFIX, MANIFEST_FILE_NAME, manifestSchema, REGISTRY_FILE_NAME } from '@weme-ui/schema'\nimport chalk from 'chalk'\nimport path from 'pathe'\nimport { glob } from 'tinyglobby'\nimport { loadRegistryConfig, REGISTRY_DIRNAME } from '../../utils/schema/registry'\n\nexport default async function (args: Record<string, any>) {\n p.intro(chalk.bold.blue('✨ Building Weme UI Repository'))\n\n const registries = await loadRegistries(args.cwd)\n await updateManifest(args.cwd, registries)\n\n p.outro('🥤 All done!')\n}\n\nasync function loadRegistries(cwd: string): Promise<ManifestSchema[]> {\n const spinner = p.spinner()\n\n spinner.start('Loading registries...')\n\n const files = await glob([`**/${REGISTRY_FILE_NAME}`], {\n cwd: path.resolve(cwd, REGISTRY_DIRNAME),\n absolute: false,\n onlyFiles: true,\n ignore: ['**/node_modules/**'],\n })\n\n const registries = files.reduce(\n (acc, file) => {\n const directory = path.dirname(file)\n const config = loadRegistryConfig(path.resolve(cwd, REGISTRY_DIRNAME, directory))\n\n if (config.isOk()) {\n const result = manifestSchema.safeParse({\n name: config.unwrap().name,\n description: config.unwrap().description,\n version: config.unwrap().version || '0.0.0',\n directory: path.join(REGISTRY_DIRNAME, directory),\n prefix: config.unwrap().prefix || DEFAULT_REGISTRY_PREFIX,\n access: config.unwrap().access || 'public',\n items: {\n components: config.unwrap().items.filter(item => item.type === 'component').length,\n layouts: config.unwrap().items.filter(item => item.type === 'layout').length,\n themes: config.unwrap().items.filter(item => item.type === 'theme').length,\n blocks: config.unwrap().items.filter(item => item.type === 'block').length,\n pages: config.unwrap().items.filter(item => item.type === 'page').length,\n },\n updated: new Date().toISOString(),\n })\n\n if (result.success) {\n spinner.message(`Building ${result.data.name}...`)\n acc.push(result.data)\n }\n }\n\n return acc\n },\n [] as ManifestSchema[],\n )\n\n spinner.stop('Registries loaded!')\n\n return registries\n}\n\nasync function updateManifest(cwd: string, registries: ManifestSchema[]) {\n const spinner = p.spinner()\n\n spinner.start('Updating manifest...')\n\n fs.writeFileSync(\n path.resolve(cwd, REGISTRY_DIRNAME, MANIFEST_FILE_NAME),\n `${JSON.stringify(registries, null, 2)}\\n`,\n )\n\n spinner.stop('Manifest updated!')\n}\n"],"mappings":";;;;;;;;;AASA,gCAA+B,MAA2B;AACxD,GAAE,MAAM,MAAM,KAAK,KAAK,gCAAgC,CAAC;CAEzD,MAAM,aAAa,MAAM,eAAe,KAAK,IAAI;AACjD,OAAM,eAAe,KAAK,KAAK,WAAW;AAE1C,GAAE,MAAM,eAAe;;AAGzB,eAAe,eAAe,KAAwC;CACpE,MAAM,UAAU,EAAE,SAAS;AAE3B,SAAQ,MAAM,wBAAwB;CAStC,MAAM,cAPQ,MAAM,KAAK,CAAC,MAAM,qBAAqB,EAAE;EACrD,KAAK,KAAK,QAAQ,KAAK,iBAAiB;EACxC,UAAU;EACV,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC/B,CAAC,EAEuB,QACtB,KAAK,SAAS;EACb,MAAM,YAAY,KAAK,QAAQ,KAAK;EACpC,MAAM,SAAS,mBAAmB,KAAK,QAAQ,KAAK,kBAAkB,UAAU,CAAC;AAEjF,MAAI,OAAO,MAAM,EAAE;GACjB,MAAM,SAAS,eAAe,UAAU;IACtC,MAAM,OAAO,QAAQ,CAAC;IACtB,aAAa,OAAO,QAAQ,CAAC;IAC7B,SAAS,OAAO,QAAQ,CAAC,WAAW;IACpC,WAAW,KAAK,KAAK,kBAAkB,UAAU;IACjD,QAAQ,OAAO,QAAQ,CAAC,UAAU;IAClC,QAAQ,OAAO,QAAQ,CAAC,UAAU;IAClC,OAAO;KACL,YAAY,OAAO,QAAQ,CAAC,MAAM,QAAO,SAAQ,KAAK,SAAS,YAAY,CAAC;KAC5E,SAAS,OAAO,QAAQ,CAAC,MAAM,QAAO,SAAQ,KAAK,SAAS,SAAS,CAAC;KACtE,QAAQ,OAAO,QAAQ,CAAC,MAAM,QAAO,SAAQ,KAAK,SAAS,QAAQ,CAAC;KACpE,QAAQ,OAAO,QAAQ,CAAC,MAAM,QAAO,SAAQ,KAAK,SAAS,QAAQ,CAAC;KACpE,OAAO,OAAO,QAAQ,CAAC,MAAM,QAAO,SAAQ,KAAK,SAAS,OAAO,CAAC;KACnE;IACD,0BAAS,IAAI,MAAM,EAAC,aAAa;IAClC,CAAC;AAEF,OAAI,OAAO,SAAS;AAClB,YAAQ,QAAQ,YAAY,OAAO,KAAK,KAAK,KAAK;AAClD,QAAI,KAAK,OAAO,KAAK;;;AAIzB,SAAO;IAET,EAAE,CACH;AAED,SAAQ,KAAK,qBAAqB;AAElC,QAAO;;AAGT,eAAe,eAAe,KAAa,YAA8B;CACvE,MAAM,UAAU,EAAE,SAAS;AAE3B,SAAQ,MAAM,uBAAuB;AAErC,IAAG,cACD,KAAK,QAAQ,KAAK,kBAAkB,mBAAmB,EACvD,GAAG,KAAK,UAAU,YAAY,MAAM,EAAE,CAAC,IACxC;AAED,SAAQ,KAAK,oBAAoB"}
@@ -0,0 +1,85 @@
1
+ import { c as runStep, l as Err, s as merge, u as Ok } from "./registry-BChtLWfr.mjs";
2
+ import fs from "node:fs";
3
+ import chalk from "chalk";
4
+ import path from "pathe";
5
+ import { addDependency, runScript } from "nypm";
6
+
7
+ //#region src/utils/schema/package.ts
8
+ /**
9
+ * Load `package.json` from current working directory.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const pkg = loadPackageJson(process.cwd())
14
+ *
15
+ * if (pkg.isErr()) {
16
+ * console.error(pkg.unwrapErr())
17
+ * return
18
+ * }
19
+ *
20
+ * console.log(pkg.unwrap().name)
21
+ * ```
22
+ *
23
+ * @param cwd - Current working directory
24
+ * @return {Result<PackageJson, string>}
25
+ */
26
+ function loadPackageJson(cwd) {
27
+ if (!fs.existsSync(path.join(cwd, "package.json"))) return Err("Could not find `package.json`!");
28
+ try {
29
+ const content = fs.readFileSync(path.join(cwd, "package.json"), "utf8");
30
+ if (!content) return Err("`package.json` is empty!");
31
+ return Ok(JSON.parse(content));
32
+ } catch (e) {
33
+ return Err(e.message);
34
+ }
35
+ }
36
+ /**
37
+ * Install dependencies to current working directory.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * await installDependencies(['@vueuse/core', 'nuxt'], { cwd: process.cwd() })
42
+ * ```
43
+ *
44
+ * @param packages - Packages to install
45
+ * @param options - Options for `nypm`
46
+ */
47
+ async function installDependencies(packages, options = {}) {
48
+ await runStep("Installing dependencies...", async (spinner) => {
49
+ const dependencies = Array.isArray(packages) ? packages : packages?.dependencies || [];
50
+ const devDependencies = Array.isArray(packages) ? [] : packages?.devDependencies || [];
51
+ await addDependency(merge(...dependencies), {
52
+ ...options,
53
+ silent: true
54
+ });
55
+ await addDependency(merge(...devDependencies), {
56
+ ...options,
57
+ dev: true,
58
+ silent: true
59
+ });
60
+ spinner.stop("Dependencies installed.");
61
+ });
62
+ }
63
+ /**
64
+ * Run `dev:prepare` script in current working directory.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * await runDevPrepare(process.cwd())
69
+ * ```
70
+ *
71
+ * @param cwd - Current working directory
72
+ */
73
+ async function runDevPrepare(cwd) {
74
+ await runStep(`Running ${chalk.cyan("dev:prepare")}...`, async (spinner) => {
75
+ await runScript("dev:prepare", {
76
+ cwd,
77
+ silent: true
78
+ });
79
+ spinner.stop(`${chalk.cyan("dev:prepare")} done.`);
80
+ });
81
+ }
82
+
83
+ //#endregion
84
+ export { loadPackageJson as n, runDevPrepare as r, installDependencies as t };
85
+ //# sourceMappingURL=package-e8qxd1tJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-e8qxd1tJ.mjs","names":["e: any"],"sources":["../src/utils/schema/package.ts"],"sourcesContent":["import type { OperationOptions } from 'nypm'\nimport type { PackageJson } from 'pkg-types'\nimport type { Result } from '../result'\nimport fs from 'node:fs'\nimport chalk from 'chalk'\nimport { addDependency, runScript } from 'nypm'\nimport path from 'pathe'\nimport { Err, Ok } from '../result'\nimport { merge, runStep } from '../utilities'\n\n/**\n * Load `package.json` from current working directory.\n *\n * @example\n * ```ts\n * const pkg = loadPackageJson(process.cwd())\n *\n * if (pkg.isErr()) {\n * console.error(pkg.unwrapErr())\n * return\n * }\n *\n * console.log(pkg.unwrap().name)\n * ```\n *\n * @param cwd - Current working directory\n * @return {Result<PackageJson, string>}\n */\nexport function loadPackageJson(cwd: string): Result<PackageJson, string> {\n if (!fs.existsSync(path.join(cwd, 'package.json')))\n return Err('Could not find `package.json`!')\n\n try {\n const content = fs.readFileSync(path.join(cwd, 'package.json'), 'utf8')\n\n if (!content)\n return Err('`package.json` is empty!')\n\n return Ok<PackageJson>(JSON.parse(content))\n }\n catch (e: any) {\n return Err(e.message)\n }\n}\n\n/**\n * Install dependencies to current working directory.\n *\n * @example\n * ```ts\n * await installDependencies(['@vueuse/core', 'nuxt'], { cwd: process.cwd() })\n * ```\n *\n * @param packages - Packages to install\n * @param options - Options for `nypm`\n */\nexport async function installDependencies(\n packages?: string[] | {\n dependencies?: string[]\n devDependencies?: string[]\n },\n options: OperationOptions = {},\n) {\n await runStep('Installing dependencies...', async (spinner) => {\n const dependencies = Array.isArray(packages)\n ? packages\n : packages?.dependencies || []\n\n const devDependencies = Array.isArray(packages)\n ? []\n : packages?.devDependencies || []\n\n await addDependency(merge(...dependencies), { ...options, silent: true })\n await addDependency(merge(...devDependencies), { ...options, dev: true, silent: true })\n\n spinner.stop('Dependencies installed.')\n })\n}\n\n/**\n * Run `dev:prepare` script in current working directory.\n *\n * @example\n * ```ts\n * await runDevPrepare(process.cwd())\n * ```\n *\n * @param cwd - Current working directory\n */\nexport async function runDevPrepare(cwd: string) {\n await runStep(`Running ${chalk.cyan('dev:prepare')}...`, async (spinner) => {\n await runScript('dev:prepare', {\n cwd,\n silent: true,\n })\n\n spinner.stop(`${chalk.cyan('dev:prepare')} done.`)\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,gBAAgB,KAA0C;AACxE,KAAI,CAAC,GAAG,WAAW,KAAK,KAAK,KAAK,eAAe,CAAC,CAChD,QAAO,IAAI,iCAAiC;AAE9C,KAAI;EACF,MAAM,UAAU,GAAG,aAAa,KAAK,KAAK,KAAK,eAAe,EAAE,OAAO;AAEvE,MAAI,CAAC,QACH,QAAO,IAAI,2BAA2B;AAExC,SAAO,GAAgB,KAAK,MAAM,QAAQ,CAAC;UAEtCA,GAAQ;AACb,SAAO,IAAI,EAAE,QAAQ;;;;;;;;;;;;;;AAezB,eAAsB,oBACpB,UAIA,UAA4B,EAAE,EAC9B;AACA,OAAM,QAAQ,8BAA8B,OAAO,YAAY;EAC7D,MAAM,eAAe,MAAM,QAAQ,SAAS,GACxC,WACA,UAAU,gBAAgB,EAAE;EAEhC,MAAM,kBAAkB,MAAM,QAAQ,SAAS,GAC3C,EAAE,GACF,UAAU,mBAAmB,EAAE;AAEnC,QAAM,cAAc,MAAM,GAAG,aAAa,EAAE;GAAE,GAAG;GAAS,QAAQ;GAAM,CAAC;AACzE,QAAM,cAAc,MAAM,GAAG,gBAAgB,EAAE;GAAE,GAAG;GAAS,KAAK;GAAM,QAAQ;GAAM,CAAC;AAEvF,UAAQ,KAAK,0BAA0B;GACvC;;;;;;;;;;;;AAaJ,eAAsB,cAAc,KAAa;AAC/C,OAAM,QAAQ,WAAW,MAAM,KAAK,cAAc,CAAC,MAAM,OAAO,YAAY;AAC1E,QAAM,UAAU,eAAe;GAC7B;GACA,QAAQ;GACT,CAAC;AAEF,UAAQ,KAAK,GAAG,MAAM,KAAK,cAAc,CAAC,QAAQ;GAClD"}
@@ -0,0 +1,58 @@
1
+ import { p as getGithubRepoName } from "./registry-BChtLWfr.mjs";
2
+ import { n as loadProjectInfo } from "./project-BV4nSHdV.mjs";
3
+ import "./package-e8qxd1tJ.mjs";
4
+ import { exit } from "node:process";
5
+ import chalk from "chalk";
6
+ import path from "pathe";
7
+ import columnify from "columnify";
8
+
9
+ //#region src/commands/info/project.ts
10
+ async function project_default(args) {
11
+ args.cwd = path.resolve(args.cwd);
12
+ const result = await loadProjectInfo(args.cwd);
13
+ if (result.isErr()) {
14
+ console.error(result.unwrapErr());
15
+ exit(1);
16
+ }
17
+ const info = result.unwrap();
18
+ const name = info.description || info.name || "";
19
+ const version = info.version || "0.0.0";
20
+ console.log(`${chalk.whiteBright.bold(name)} ${chalk.gray(`version ${version}`)}`);
21
+ console.log("");
22
+ info.repos.forEach((repo) => {
23
+ const registries = info.registries.filter((r) => r.repo === repo);
24
+ if (registries.length) {
25
+ console.log(`${chalk.bold.cyan(`@${getGithubRepoName(repo)}`)} ${chalk.dim(`(${registries.length})`)}`);
26
+ console.log("");
27
+ console.log(columnify(registries.map((r) => ({
28
+ default: r.default,
29
+ name: [`${r.name}@${r.version} ${chalk.dim(`(${r.prefix})`)}`, chalk.dim(r.description)].join("\n"),
30
+ access: r.access
31
+ })), {
32
+ showHeaders: false,
33
+ preserveNewLines: true,
34
+ config: {
35
+ default: {
36
+ align: "right",
37
+ minWidth: 3,
38
+ dataTransform: (data) => data === "true" ? chalk.greenBright("✓") : ""
39
+ },
40
+ name: { dataTransform: (data) => ` ${chalk.whiteBright(data)}` },
41
+ access: {
42
+ minWidth: 4,
43
+ dataTransform: (data) => data === "private" ? "🔒" : ""
44
+ }
45
+ }
46
+ }));
47
+ console.log("");
48
+ console.log(chalk.gray([` ${chalk.yellow(registries.reduce((acc, r) => acc + r.available, 0))} available`, `${chalk.yellow(registries.reduce((acc, r) => acc + r.installed, 0))} installed`].join(", ")));
49
+ }
50
+ });
51
+ console.log("");
52
+ console.log(`Run ${chalk.cyan("pnpm dlx @weme-ui/weme-ui info <registry-name>")} to get more information about a specific registry.`);
53
+ console.log(`Run ${chalk.cyan("pnpm dlx @weme-ui/weme-ui update")} to update all installed items.`);
54
+ }
55
+
56
+ //#endregion
57
+ export { project_default as default };
58
+ //# sourceMappingURL=project-2Uhjf6-l.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-2Uhjf6-l.mjs","names":[],"sources":["../src/commands/info/project.ts"],"sourcesContent":["import { exit } from 'node:process'\nimport chalk from 'chalk'\nimport columnify from 'columnify'\nimport path from 'pathe'\nimport { getGithubRepoName } from '../../utils/fetch'\nimport { loadProjectInfo } from '../../utils/schema/project'\n\nexport default async function (args: Record<string, any>) {\n args.cwd = path.resolve(args.cwd)\n\n const result = await loadProjectInfo(args.cwd)\n\n if (result.isErr()) {\n console.error(result.unwrapErr())\n exit(1)\n }\n\n const info = result.unwrap()\n\n const name = info.description || info.name || ''\n const version = info.version || '0.0.0'\n\n console.log(`${chalk.whiteBright.bold(name)} ${chalk.gray(`version ${version}`)}`)\n console.log('')\n\n info.repos.forEach((repo) => {\n const registries = info.registries.filter(r => r.repo === repo)\n\n if (registries.length) {\n console.log(`${chalk.bold.cyan(`@${getGithubRepoName(repo)}`)} ${chalk.dim(`(${registries.length})`)}`)\n console.log('')\n\n console.log(\n columnify(\n // Data\n registries.map(r => ({\n default: r.default,\n name: [\n `${r.name}@${r.version} ${chalk.dim(`(${r.prefix})`)}`,\n chalk.dim(r.description),\n ].join('\\n'),\n access: r.access,\n })),\n\n // Options\n {\n showHeaders: false,\n preserveNewLines: true,\n config: {\n default: {\n align: 'right',\n minWidth: 3,\n dataTransform: data => data === 'true' ? chalk.greenBright('✓') : '',\n },\n name: {\n dataTransform: data => ` ${chalk.whiteBright(data)}`,\n },\n access: {\n minWidth: 4,\n dataTransform: data => data === 'private' ? '🔒' : '',\n },\n },\n },\n ),\n )\n\n console.log('')\n console.log(chalk.gray(\n [\n ` ${chalk.yellow(registries.reduce((acc, r) => acc + r.available, 0))} available`,\n `${chalk.yellow(registries.reduce((acc, r) => acc + r.installed, 0))} installed`,\n ].join(', '),\n ))\n }\n })\n\n console.log('')\n console.log(`Run ${chalk.cyan('pnpm dlx @weme-ui/weme-ui info <registry-name>')} to get more information about a specific registry.`)\n console.log(`Run ${chalk.cyan('pnpm dlx @weme-ui/weme-ui update')} to update all installed items.`)\n}\n"],"mappings":";;;;;;;;;AAOA,+BAA+B,MAA2B;AACxD,MAAK,MAAM,KAAK,QAAQ,KAAK,IAAI;CAEjC,MAAM,SAAS,MAAM,gBAAgB,KAAK,IAAI;AAE9C,KAAI,OAAO,OAAO,EAAE;AAClB,UAAQ,MAAM,OAAO,WAAW,CAAC;AACjC,OAAK,EAAE;;CAGT,MAAM,OAAO,OAAO,QAAQ;CAE5B,MAAM,OAAO,KAAK,eAAe,KAAK,QAAQ;CAC9C,MAAM,UAAU,KAAK,WAAW;AAEhC,SAAQ,IAAI,GAAG,MAAM,YAAY,KAAK,KAAK,CAAC,GAAG,MAAM,KAAK,WAAW,UAAU,GAAG;AAClF,SAAQ,IAAI,GAAG;AAEf,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,aAAa,KAAK,WAAW,QAAO,MAAK,EAAE,SAAS,KAAK;AAE/D,MAAI,WAAW,QAAQ;AACrB,WAAQ,IAAI,GAAG,MAAM,KAAK,KAAK,IAAI,kBAAkB,KAAK,GAAG,CAAC,GAAG,MAAM,IAAI,IAAI,WAAW,OAAO,GAAG,GAAG;AACvG,WAAQ,IAAI,GAAG;AAEf,WAAQ,IACN,UAEE,WAAW,KAAI,OAAM;IACnB,SAAS,EAAE;IACX,MAAM,CACJ,GAAG,EAAE,KAAK,GAAG,EAAE,QAAQ,GAAG,MAAM,IAAI,IAAI,EAAE,OAAO,GAAG,IACpD,MAAM,IAAI,EAAE,YAAY,CACzB,CAAC,KAAK,KAAK;IACZ,QAAQ,EAAE;IACX,EAAE,EAGH;IACE,aAAa;IACb,kBAAkB;IAClB,QAAQ;KACN,SAAS;MACP,OAAO;MACP,UAAU;MACV,gBAAe,SAAQ,SAAS,SAAS,MAAM,YAAY,IAAI,GAAG;MACnE;KACD,MAAM,EACJ,gBAAe,SAAQ,KAAK,MAAM,YAAY,KAAK,IACpD;KACD,QAAQ;MACN,UAAU;MACV,gBAAe,SAAQ,SAAS,YAAY,OAAO;MACpD;KACF;IACF,CACF,CACF;AAED,WAAQ,IAAI,GAAG;AACf,WAAQ,IAAI,MAAM,KAChB,CACE,KAAK,MAAM,OAAO,WAAW,QAAQ,KAAK,MAAM,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,aACvE,GAAG,MAAM,OAAO,WAAW,QAAQ,KAAK,MAAM,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,YACtE,CAAC,KAAK,KAAK,CACb,CAAC;;GAEJ;AAEF,SAAQ,IAAI,GAAG;AACf,SAAQ,IAAI,OAAO,MAAM,KAAK,iDAAiD,CAAC,qDAAqD;AACrI,SAAQ,IAAI,OAAO,MAAM,KAAK,mCAAmC,CAAC,iCAAiC"}