@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.
- package/README.md +62 -97
- package/dist/index.js +3 -2
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,148 +1,113 @@
|
|
|
1
|
-
# @simui
|
|
1
|
+
# @dofu-lab/simui-cli
|
|
2
2
|
|
|
3
|
-
A CLI to
|
|
3
|
+
A small, focused CLI to fetch and inject SimUI Angular components into an existing Angular project.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@dofu-lab/simui-cli)
|
|
6
|
+
[](#license)
|
|
6
7
|
|
|
7
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
15
|
+
Prerequisites
|
|
16
|
+
- Node.js >= 18
|
|
17
|
+
- An Angular project (CLI available via `ng`)
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Installation (local use)
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
You can run the CLI directly from the built artifact in this repository without publishing to npm:
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
cd packages/cli
|
|
25
|
+
npm install
|
|
26
|
+
npm run build
|
|
27
|
+
node dist/index.js add accordion-01
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
|
|
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
|
-
#
|
|
38
|
-
|
|
33
|
+
# Fetch and add a component to the default location
|
|
34
|
+
node dist/index.js add accordion-01
|
|
39
35
|
|
|
40
|
-
#
|
|
41
|
-
simui add
|
|
36
|
+
# Use the published package (once available)
|
|
37
|
+
npx @dofu-lab/simui-cli add accordion-01
|
|
42
38
|
|
|
43
|
-
#
|
|
44
|
-
|
|
39
|
+
# Override output directory
|
|
40
|
+
node dist/index.js add badge-01 --path src/shared/ui
|
|
45
41
|
```
|
|
46
42
|
|
|
47
|
-
|
|
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
|
-
|
|
45
|
+
- `add <component>` — fetches `<component>` from the registry and writes `<component>.component.ts` to the output directory.
|
|
62
46
|
|
|
63
|
-
|
|
47
|
+
Options
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
- `-p, --path <dir>` — Output directory relative to the current working directory (default: `src/app/components`).
|
|
66
50
|
|
|
67
|
-
|
|
51
|
+
What the command does
|
|
68
52
|
|
|
69
|
-
1.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
82
|
-
|
|
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
|
-
|
|
74
|
+
Publishing
|
|
86
75
|
|
|
87
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
5. Dry-run publish / pack
|
|
80
|
+
# bump version (creates a commit + tag)
|
|
81
|
+
npm version patch
|
|
97
82
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
npm pack
|
|
83
|
+
# build
|
|
84
|
+
npm run build
|
|
101
85
|
|
|
102
|
-
#
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
+
Contributing
|
|
128
98
|
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
136
|
-
# try via npx
|
|
137
|
-
npx @simui/cli@latest add accordion-01
|
|
106
|
+
License
|
|
138
107
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
```
|
|
108
|
+
This project is licensed under the MIT License — see the `LICENSE` file for details.
|
|
109
|
+
|
|
110
|
+
Support
|
|
143
111
|
|
|
144
|
-
|
|
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
|
|
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.
|
|
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": [
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
11
13
|
"scripts": {
|
|
12
14
|
"build": "tsup",
|
|
13
15
|
"dev": "tsup --watch",
|