@dofu-lab/simui-cli 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/README.md +62 -97
  2. package/dist/index.js +3 -2
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -1,148 +1,113 @@
1
- # @simui/cli
1
+ # @dofu-lab/simui-cli
2
2
 
3
- A CLI to add [SimUI](https://simui.dev) Angular components to your project instantly.
3
+ A small, focused CLI to fetch and inject SimUI Angular components into an existing Angular project.
4
4
 
5
- ## Usage
5
+ [![npm version](https://img.shields.io/npm/v/@dofu-lab/simui-cli.svg)](https://www.npmjs.com/package/@dofu-lab/simui-cli)
6
+ [![license](https://img.shields.io/npm/l/@dofu-lab/simui-cli.svg)](#license)
6
7
 
7
- ```bash
8
- # Using npx (no install required)
9
- npx @simui/cli add accordion-01
8
+ This tool fetches component source from the SimUI registry (https://simui.dev/registry), writes the component file into your project, and offers to install any detected dependencies (Spartan UI generators and ng-icons).
10
9
 
11
- # Or install globally
12
- npm install -g @simui/cli
13
- simui add accordion-01
14
- ```
10
+ Features
11
+ - Fetch a component by name and inject it into your project
12
+ - Detects `@spartan-ng/helm/*` and `@ng-icons/*` imports and offers to install them
13
+ - Default output path: `src/app/components` (configurable with `--path`)
15
14
 
16
- ## Commands
15
+ Prerequisites
16
+ - Node.js >= 18
17
+ - An Angular project (CLI available via `ng`)
17
18
 
18
- ### `simui add <component>`
19
+ Installation (local use)
19
20
 
20
- Fetches a component from the SimUI registry and writes it to your project.
21
+ You can run the CLI directly from the built artifact in this repository without publishing to npm:
21
22
 
22
23
  ```bash
23
- simui add select-01
24
- simui add dialog-03
25
- simui add button-07
24
+ cd packages/cli
25
+ npm install
26
+ npm run build
27
+ node dist/index.js add accordion-01
26
28
  ```
27
29
 
28
- **Options:**
29
-
30
- | Flag | Default | Description |
31
- |------|---------|-------------|
32
- | `-p, --path <dir>` | `src/app/components` | Output directory (relative to cwd) |
33
-
34
- **Examples:**
30
+ Usage
35
31
 
36
32
  ```bash
37
- # Default path: src/app/components/accordion-01.component.ts
38
- simui add accordion-01
33
+ # Fetch and add a component to the default location
34
+ node dist/index.js add accordion-01
39
35
 
40
- # Custom output directory
41
- simui add badge-05 --path src/shared/ui
36
+ # Use the published package (once available)
37
+ npx @dofu-lab/simui-cli add accordion-01
42
38
 
43
- # Short flag alias
44
- simui add input-12 -p src/features/auth
39
+ # Override output directory
40
+ node dist/index.js add badge-01 --path src/shared/ui
45
41
  ```
46
42
 
47
- ## What it does
48
-
49
- 1. **Fetches** the component TypeScript source from `https://simui.dev/registry/<name>.json`
50
- 2. **Writes** the file to the resolved output path
51
- 3. **Detects** required `@spartan-ng/helm/*` and `@ng-icons/*` imports
52
- 4. **Prompts** you to install them:
53
- - Spartan UI packages — installed via `npx @spartan-ng/cli@latest add <package>`
54
- - `@ng-icons/*` packages — installed via your detected package manager (pnpm / yarn / npm)
55
-
56
- ## Requirements
57
-
58
- - Node.js ≥ 18
59
- - An Angular project with [Spartan UI](https://spartan.ng) configured
43
+ Commands
60
44
 
61
- ## Browse components
45
+ - `add <component>` — fetches `<component>` from the registry and writes `<component>.component.ts` to the output directory.
62
46
 
63
- Visit [simui.dev](https://simui.dev) to browse all available components and their previews.
47
+ Options
64
48
 
65
- ## Publishing
49
+ - `-p, --path <dir>` — Output directory relative to the current working directory (default: `src/app/components`).
66
50
 
67
- Follow these steps to publish a new version of `@simui/cli` to the npm registry.
51
+ What the command does
68
52
 
69
- 1. Run tests and linters
53
+ 1. Fetches `https://simui.dev/registry/<name>.json` and reads the `content` field.
54
+ 2. Writes the TypeScript component file to the chosen output path.
55
+ 3. Parses the source for `@spartan-ng/helm/*` and `@ng-icons/*` imports.
56
+ 4. Prompts to install dependencies. Spartan packages are invoked via the Angular generator:
70
57
 
71
58
  ```bash
72
- # from packages/cli
73
- npm test # if you have tests
74
- npm run lint # if you have a lint script
59
+ ng generate @spartan-ng/cli:ui <package>
75
60
  ```
76
61
 
77
- 2. Bump the package version (creates a git commit and tag)
62
+ And `@ng-icons/*` packages are installed via your detected package manager (`pnpm`, `yarn`, or `npm`).
63
+
64
+ Development
78
65
 
79
66
  ```bash
80
67
  cd packages/cli
81
- npm version patch # or `minor` / `major`
82
- # push the commit and tag afterwards
68
+ npm install
69
+ npm run build
70
+ # Run the CLI locally
71
+ node dist/index.js add select-01
83
72
  ```
84
73
 
85
- 3. Update changelog (optional)
74
+ Publishing
86
75
 
87
- Edit `packages/cli/CHANGELOG.md` or add release notes for the new version.
88
-
89
- 4. Build the package
76
+ Follow these steps to publish a new version of this package under the `@dofu-lab` scope.
90
77
 
91
78
  ```bash
92
79
  cd packages/cli
93
- npm run build
94
- ```
95
-
96
- 5. Dry-run publish / pack
80
+ # bump version (creates a commit + tag)
81
+ npm version patch
97
82
 
98
- ```bash
99
- # create a tarball for inspection
100
- npm pack
83
+ # build
84
+ npm run build
101
85
 
102
- # simulate publish (shows what will be published)
86
+ # dry-run
103
87
  npm publish --dry-run
104
- ```
105
-
106
- 6. Login to npm (if needed)
107
-
108
- ```bash
109
- npm whoami || npm login
110
- ```
111
-
112
- 7. Publish to npm
113
88
 
114
- ```bash
115
- cd packages/cli
89
+ # publish (scoped public requires --access public)
116
90
  npm publish --access public
117
- ```
118
-
119
- 8. Push changes and tags to the remote repo
120
91
 
121
- ```bash
122
- # from repo root
92
+ # push commits and tags
123
93
  git push origin main
124
94
  git push --tags
125
95
  ```
126
96
 
127
- 9. Create a GitHub release (optional)
97
+ Contributing
128
98
 
129
- ```bash
130
- gh release create vX.Y.Z --title "vX.Y.Z" --notes "Short changelog"
131
- ```
99
+ Contributions are welcome. Open issues or pull requests against this repository. For code changes:
132
100
 
133
- 10. Verify installation
101
+ 1. Fork the repo
102
+ 2. Create a feature branch
103
+ 3. Run tests and build locally
104
+ 4. Submit a pull request
134
105
 
135
- ```bash
136
- # try via npx
137
- npx @simui/cli@latest add accordion-01
106
+ License
138
107
 
139
- # or install globally
140
- npm install -g @simui/cli
141
- simui add accordion-01
142
- ```
108
+ This project is licensed under the MIT License — see the `LICENSE` file for details.
109
+
110
+ Support
143
111
 
144
- Notes:
145
- - If your package is scoped (e.g. `@simui/cli`) publishing publicly requires `--access public`.
146
- - If your npm account has 2FA enabled, you'll be prompted for an OTP when publishing.
147
- - For CI-based publishing, use an `NPM_TOKEN` and run `npm publish` from the pipeline.
112
+ If you encounter issues, open an issue on the repository with logs and reproduction steps.
148
113
 
package/dist/index.js CHANGED
@@ -131,15 +131,16 @@ async function addComponent(componentName, options) {
131
131
  const installSpinner = p.spinner();
132
132
  installSpinner.start(`Installing @spartan-ng/helm/${helmPkg}\u2026`);
133
133
  try {
134
- execSync(`npx @spartan-ng/cli@latest add ${helmPkg}`, {
134
+ execSync(`npx ng generate @spartan-ng/cli:ui ${helmPkg}`, {
135
135
  cwd,
136
136
  stdio: "pipe"
137
137
  });
138
- installSpinner.stop(chalk.green(`@spartan-ng/helm/${helmPkg} installed`));
138
+ installSpinner.stop(chalk.green(`@spartan-ng/helm/${helmPkg} installed via generator`));
139
139
  } catch (err) {
140
140
  installSpinner.stop(chalk.red(`Failed to install @spartan-ng/helm/${helmPkg}`));
141
141
  const stderr = err instanceof Error && "stderr" in err ? String(err.stderr) : "";
142
142
  p.log.warn(chalk.dim(stderr.trim() || String(err)));
143
+ p.log.warn(`If this fails, try running: ${chalk.bold(`ng generate @spartan-ng/cli:ui ${helmPkg}`)}`);
143
144
  }
144
145
  }
145
146
  if (ngIcons.length > 0) {
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@dofu-lab/simui-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI to add SimUI components to your Angular project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "bin": {
8
8
  "simui": "./dist/index.js"
9
9
  },
10
- "files": ["dist"],
10
+ "files": [
11
+ "dist"
12
+ ],
11
13
  "scripts": {
12
14
  "build": "tsup",
13
15
  "dev": "tsup --watch",