kmod-cli 1.4.11 → 1.4.12

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 (2) hide show
  1. package/bin/index.js +46 -0
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -142,6 +142,41 @@ async function addComponents() {
142
142
  }
143
143
  }
144
144
 
145
+ async function addComponentsByName(names) {
146
+ const collectedDeps = { deps: [], devDeps: [] };
147
+
148
+ for (const name of names) {
149
+ await copyComponent(name, collectedDeps);
150
+ }
151
+
152
+ collectedDeps.deps = [...new Set(collectedDeps.deps)];
153
+ collectedDeps.devDeps = [...new Set(collectedDeps.devDeps)];
154
+
155
+ if (collectedDeps.deps.length || collectedDeps.devDeps.length) {
156
+ console.log(`⚠️ Missing packages detected:`);
157
+
158
+ if (collectedDeps.deps.length)
159
+ console.log(" - deps:", collectedDeps.deps.join(", "));
160
+ if (collectedDeps.devDeps.length)
161
+ console.log(" - devDeps:", collectedDeps.devDeps.join(", "));
162
+
163
+ const { confirm } = await inquirer.prompt([
164
+ {
165
+ type: "confirm",
166
+ name: "confirm",
167
+ message: "Install all missing packages now?",
168
+ default: true,
169
+ },
170
+ ]);
171
+
172
+ if (confirm) {
173
+ if (collectedDeps.deps.length) installDeps(collectedDeps.deps, false);
174
+ if (collectedDeps.devDeps.length) installDeps(collectedDeps.devDeps, true);
175
+ }
176
+ }
177
+ }
178
+
179
+
145
180
  // ====================== CLI Commands ======================
146
181
  program
147
182
  .name("kumod")
@@ -149,5 +184,16 @@ program
149
184
  .version("1.0.0");
150
185
 
151
186
  program.command("add").description("Select components to add").action(addComponents);
187
+ program
188
+ .command("add [components...]")
189
+ .description("Add components by name or select interactively")
190
+ .action(async (components) => {
191
+ if (components.length > 0) {
192
+ await addComponentsByName(components);
193
+ } else {
194
+ await addComponents();
195
+ }
196
+ });
197
+
152
198
 
153
199
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kmod-cli",
3
- "version": "1.4.11",
3
+ "version": "1.4.12",
4
4
  "description": "Stack components utilities fast setup in projects",
5
5
  "author": "kumo_d",
6
6
  "license": "MIT",