kmod-cli 1.4.11 → 1.4.13
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/bin/index.js +54 -1
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -142,12 +142,65 @@ 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")
|
|
148
183
|
.description("CLI to copy component/templates into project")
|
|
149
184
|
.version("1.0.0");
|
|
150
185
|
|
|
151
|
-
program.command("add").description("Select components to add").action(addComponents);
|
|
186
|
+
// program.command("add").description("Select components to add").action(addComponents);
|
|
187
|
+
program
|
|
188
|
+
.command("add [components...]")
|
|
189
|
+
.description("Add components")
|
|
190
|
+
.option("--all", "Add all components")
|
|
191
|
+
.action(async (components = [], options) => {
|
|
192
|
+
if (options.all) {
|
|
193
|
+
await addComponents(); //handle --all
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (components.length > 0) {
|
|
198
|
+
await addComponentsByName(components);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
await addComponents(); // interactive
|
|
203
|
+
});
|
|
204
|
+
|
|
152
205
|
|
|
153
206
|
program.parse(process.argv);
|