@dofu-lab/simui-cli 0.1.2 → 0.1.3
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 +21 -0
- package/README.md +2 -1
- package/dist/index.js +29 -9
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dofu Lab
|
|
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
CHANGED
|
@@ -8,11 +8,13 @@ A small, focused CLI to fetch and inject SimUI Angular components into an existi
|
|
|
8
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).
|
|
9
9
|
|
|
10
10
|
Features
|
|
11
|
+
|
|
11
12
|
- Fetch a component by name and inject it into your project
|
|
12
13
|
- Detects `@spartan-ng/helm/*` and `@ng-icons/*` imports and offers to install them
|
|
13
14
|
- Default output path: `src/app/components` (configurable with `--path`)
|
|
14
15
|
|
|
15
16
|
Prerequisites
|
|
17
|
+
|
|
16
18
|
- Node.js >= 18
|
|
17
19
|
- An Angular project (CLI available via `ng`)
|
|
18
20
|
|
|
@@ -110,4 +112,3 @@ This project is licensed under the MIT License — see the `LICENSE` file for de
|
|
|
110
112
|
Support
|
|
111
113
|
|
|
112
114
|
If you encounter issues, open an issue on the repository with logs and reproduction steps.
|
|
113
|
-
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,9 @@ Browse available components at https://simui.dev`
|
|
|
36
36
|
throw new Error(`Invalid response from registry for "${name}"`);
|
|
37
37
|
}
|
|
38
38
|
if (typeof data !== "object" || data === null || !("content" in data) || typeof data.content !== "string") {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Unexpected registry format for "${name}" \u2014 expected { content: string }`
|
|
41
|
+
);
|
|
40
42
|
}
|
|
41
43
|
return data.content;
|
|
42
44
|
}
|
|
@@ -112,7 +114,11 @@ async function addComponent(componentName, options) {
|
|
|
112
114
|
mkdirSync(outputDir, { recursive: true });
|
|
113
115
|
writeFileSync(outputFile, content, "utf-8");
|
|
114
116
|
} catch (err) {
|
|
115
|
-
p.outro(
|
|
117
|
+
p.outro(
|
|
118
|
+
chalk.red(
|
|
119
|
+
`Could not write file: ${err instanceof Error ? err.message : err}`
|
|
120
|
+
)
|
|
121
|
+
);
|
|
116
122
|
process.exit(1);
|
|
117
123
|
}
|
|
118
124
|
const relativePath = outputFile.replace(cwd + "/", "");
|
|
@@ -125,7 +131,9 @@ async function addComponent(componentName, options) {
|
|
|
125
131
|
}
|
|
126
132
|
p.log.info(chalk.bold("Dependencies detected in this component:"));
|
|
127
133
|
for (const d of spartanHelm) {
|
|
128
|
-
p.log.message(
|
|
134
|
+
p.log.message(
|
|
135
|
+
` ${chalk.cyan("@spartan-ng/helm/")}${d} ${chalk.dim("(via Spartan CLI)")}`
|
|
136
|
+
);
|
|
129
137
|
}
|
|
130
138
|
for (const d of ngIcons) {
|
|
131
139
|
p.log.message(` ${chalk.cyan(d)}`);
|
|
@@ -135,12 +143,16 @@ async function addComponent(componentName, options) {
|
|
|
135
143
|
initialValue: true
|
|
136
144
|
});
|
|
137
145
|
if (p.isCancel(shouldInstall) || !shouldInstall) {
|
|
138
|
-
p.log.warn(
|
|
146
|
+
p.log.warn(
|
|
147
|
+
"Skipped dependency installation. Install them manually before using the component."
|
|
148
|
+
);
|
|
139
149
|
p.outro(chalk.dim("Done."));
|
|
140
150
|
return;
|
|
141
151
|
}
|
|
142
152
|
const pm = detectPackageManager(installCwd);
|
|
143
|
-
p.log.info(
|
|
153
|
+
p.log.info(
|
|
154
|
+
`Installing dependencies in ${chalk.bold(installCwd)} using ${chalk.bold(pm)}`
|
|
155
|
+
);
|
|
144
156
|
for (const helmPkg of spartanHelm) {
|
|
145
157
|
const installSpinner = p.spinner();
|
|
146
158
|
installSpinner.start(`Installing @spartan-ng/helm/${helmPkg}\u2026`);
|
|
@@ -149,12 +161,18 @@ async function addComponent(componentName, options) {
|
|
|
149
161
|
cwd: installCwd,
|
|
150
162
|
stdio: "pipe"
|
|
151
163
|
});
|
|
152
|
-
installSpinner.stop(
|
|
164
|
+
installSpinner.stop(
|
|
165
|
+
chalk.green(`@spartan-ng/helm/${helmPkg} installed via generator`)
|
|
166
|
+
);
|
|
153
167
|
} catch (err) {
|
|
154
|
-
installSpinner.stop(
|
|
168
|
+
installSpinner.stop(
|
|
169
|
+
chalk.red(`Failed to install @spartan-ng/helm/${helmPkg}`)
|
|
170
|
+
);
|
|
155
171
|
const stderr = err instanceof Error && "stderr" in err ? String(err.stderr) : "";
|
|
156
172
|
p.log.warn(chalk.dim(stderr.trim() || String(err)));
|
|
157
|
-
p.log.warn(
|
|
173
|
+
p.log.warn(
|
|
174
|
+
`If this fails, try running: ${chalk.bold(`ng generate @spartan-ng/cli:ui ${helmPkg}`)}`
|
|
175
|
+
);
|
|
158
176
|
}
|
|
159
177
|
}
|
|
160
178
|
if (ngIcons.length > 0) {
|
|
@@ -183,7 +201,9 @@ var __dirname = dirname2(__filename);
|
|
|
183
201
|
var pkg = require2(join3(__dirname, "..", "package.json"));
|
|
184
202
|
var program = new Command();
|
|
185
203
|
program.name("simui").description("Add SimUI Angular components to your project").version(pkg.version);
|
|
186
|
-
program.command("add <component>").description(
|
|
204
|
+
program.command("add <component>").description(
|
|
205
|
+
"Fetch a SimUI component from the registry and add it to your project"
|
|
206
|
+
).option(
|
|
187
207
|
"-p, --path <path>",
|
|
188
208
|
"Output directory relative to cwd (default: src/app/components)"
|
|
189
209
|
).action(async (component, opts) => {
|