@mayrlabs/setup-project 0.1.8 → 0.1.9
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/CHANGELOG.md +6 -0
- package/README.md +10 -10
- package/dist/index.js +433 -145
- package/dist/index.mjs +499 -142
- package/package.json +27 -22
package/dist/index.js
CHANGED
|
@@ -32,14 +32,223 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
+
// src/utils/prompts/clack.ts
|
|
36
|
+
var import_prompts = require("@clack/prompts");
|
|
37
|
+
var ClackProvider = class {
|
|
38
|
+
intro(message) {
|
|
39
|
+
(0, import_prompts.intro)(message);
|
|
40
|
+
}
|
|
41
|
+
outro(message) {
|
|
42
|
+
(0, import_prompts.outro)(message);
|
|
43
|
+
}
|
|
44
|
+
async text(opts) {
|
|
45
|
+
return (0, import_prompts.text)(opts);
|
|
46
|
+
}
|
|
47
|
+
async confirm(opts) {
|
|
48
|
+
return (0, import_prompts.confirm)(opts);
|
|
49
|
+
}
|
|
50
|
+
async select(opts) {
|
|
51
|
+
return (0, import_prompts.select)({
|
|
52
|
+
message: opts.message,
|
|
53
|
+
options: opts.options.map((o) => ({
|
|
54
|
+
label: o.label,
|
|
55
|
+
value: o.value,
|
|
56
|
+
hint: o.hint
|
|
57
|
+
}))
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async multiselect(opts) {
|
|
61
|
+
return (0, import_prompts.multiselect)({
|
|
62
|
+
message: opts.message,
|
|
63
|
+
options: opts.options.map((o) => ({
|
|
64
|
+
label: o.label,
|
|
65
|
+
value: o.value,
|
|
66
|
+
hint: o.hint
|
|
67
|
+
}))
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
note(message, title) {
|
|
71
|
+
(0, import_prompts.note)(message, title);
|
|
72
|
+
}
|
|
73
|
+
isCancel(value) {
|
|
74
|
+
return (0, import_prompts.isCancel)(value);
|
|
75
|
+
}
|
|
76
|
+
cancel(message) {
|
|
77
|
+
(0, import_prompts.cancel)(message);
|
|
78
|
+
}
|
|
79
|
+
log = {
|
|
80
|
+
message: (msg) => import_prompts.log.message(msg),
|
|
81
|
+
info: (msg) => import_prompts.log.info(msg),
|
|
82
|
+
success: (msg) => import_prompts.log.success(msg),
|
|
83
|
+
warn: (msg) => import_prompts.log.warn(msg),
|
|
84
|
+
error: (msg) => import_prompts.log.error(msg)
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/utils/prompts/top.ts
|
|
89
|
+
var import_prompts2 = require("@topcli/prompts");
|
|
90
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
91
|
+
var CANCEL_SYMBOL = /* @__PURE__ */ Symbol("cancel");
|
|
92
|
+
var TopCliProvider = class {
|
|
93
|
+
intro(message) {
|
|
94
|
+
console.log(import_picocolors.default.bgCyan(import_picocolors.default.black(` ${message} `)));
|
|
95
|
+
}
|
|
96
|
+
outro(message) {
|
|
97
|
+
console.log(import_picocolors.default.bgCyan(import_picocolors.default.black(` ${message} `)));
|
|
98
|
+
}
|
|
99
|
+
async text(opts) {
|
|
100
|
+
try {
|
|
101
|
+
return await (0, import_prompts2.question)(opts.message, {
|
|
102
|
+
defaultValue: opts.initialValue || opts.defaultValue,
|
|
103
|
+
validators: [
|
|
104
|
+
{
|
|
105
|
+
validate: (value) => opts.validate?.(value) || ""
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
} catch {
|
|
110
|
+
return CANCEL_SYMBOL;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async confirm(opts) {
|
|
114
|
+
try {
|
|
115
|
+
return await (0, import_prompts2.confirm)(opts.message, {
|
|
116
|
+
initial: opts.initialValue
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
return CANCEL_SYMBOL;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async select(opts) {
|
|
123
|
+
try {
|
|
124
|
+
const optionMap = /* @__PURE__ */ new Map();
|
|
125
|
+
const choices = opts.options.map((o) => {
|
|
126
|
+
const key = String(o.value);
|
|
127
|
+
optionMap.set(key, o.value);
|
|
128
|
+
const isSelected = opts.initialValue === o.value;
|
|
129
|
+
return {
|
|
130
|
+
label: o.label,
|
|
131
|
+
value: key,
|
|
132
|
+
description: o.hint,
|
|
133
|
+
selected: isSelected
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
const resultKey = await (0, import_prompts2.select)(opts.message, {
|
|
137
|
+
choices,
|
|
138
|
+
autocomplete: true,
|
|
139
|
+
maxVisible: 10
|
|
140
|
+
});
|
|
141
|
+
return optionMap.get(resultKey);
|
|
142
|
+
} catch {
|
|
143
|
+
return CANCEL_SYMBOL;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async multiselect(opts) {
|
|
147
|
+
try {
|
|
148
|
+
const optionMap = /* @__PURE__ */ new Map();
|
|
149
|
+
const choices = opts.options.map((o) => {
|
|
150
|
+
const key = String(o.value);
|
|
151
|
+
optionMap.set(key, o.value);
|
|
152
|
+
const isSelected = opts.initialValue?.some((iv) => iv === o.value);
|
|
153
|
+
return {
|
|
154
|
+
label: o.label,
|
|
155
|
+
value: key,
|
|
156
|
+
description: o.hint,
|
|
157
|
+
selected: isSelected
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
const resultKeys = await (0, import_prompts2.multiselect)(opts.message, {
|
|
161
|
+
choices,
|
|
162
|
+
autocomplete: true,
|
|
163
|
+
maxVisible: 10,
|
|
164
|
+
showHint: true
|
|
165
|
+
});
|
|
166
|
+
return resultKeys.map((k) => optionMap.get(k));
|
|
167
|
+
} catch {
|
|
168
|
+
return CANCEL_SYMBOL;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
note(message, title) {
|
|
172
|
+
if (title) {
|
|
173
|
+
console.log(import_picocolors.default.blue(import_picocolors.default.bold(`${title}`)));
|
|
174
|
+
}
|
|
175
|
+
console.log(import_picocolors.default.dim(message));
|
|
176
|
+
}
|
|
177
|
+
isCancel(value) {
|
|
178
|
+
return value === CANCEL_SYMBOL;
|
|
179
|
+
}
|
|
180
|
+
cancel(message) {
|
|
181
|
+
if (message) console.log(import_picocolors.default.red(import_picocolors.default.bold("\xD7")) + " " + message);
|
|
182
|
+
else console.log(import_picocolors.default.red(import_picocolors.default.bold("\xD7")) + " Operation cancelled.");
|
|
183
|
+
}
|
|
184
|
+
log = {
|
|
185
|
+
message: (msg) => console.log(msg),
|
|
186
|
+
info: (msg) => console.log(import_picocolors.default.blue(import_picocolors.default.bold("INFO")) + " " + msg),
|
|
187
|
+
success: (msg) => console.log(import_picocolors.default.green(import_picocolors.default.bold("SUCCESS")) + " " + msg),
|
|
188
|
+
warn: (msg) => console.log(import_picocolors.default.yellow(import_picocolors.default.bold("WARN")) + " " + msg),
|
|
189
|
+
error: (msg) => console.log(import_picocolors.default.red(import_picocolors.default.bold("ERROR")) + " " + msg)
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/utils/prompts/index.ts
|
|
194
|
+
var Prompts = class _Prompts {
|
|
195
|
+
provider;
|
|
196
|
+
static instance;
|
|
197
|
+
constructor() {
|
|
198
|
+
this.provider = new TopCliProvider();
|
|
199
|
+
}
|
|
200
|
+
static getInstance() {
|
|
201
|
+
if (!_Prompts.instance) {
|
|
202
|
+
_Prompts.instance = new _Prompts();
|
|
203
|
+
}
|
|
204
|
+
return _Prompts.instance;
|
|
205
|
+
}
|
|
206
|
+
setProvider(provider) {
|
|
207
|
+
this.provider = provider;
|
|
208
|
+
}
|
|
209
|
+
useClack() {
|
|
210
|
+
this.provider = new ClackProvider();
|
|
211
|
+
}
|
|
212
|
+
useTopCli() {
|
|
213
|
+
this.provider = new TopCliProvider();
|
|
214
|
+
}
|
|
215
|
+
intro(message) {
|
|
216
|
+
this.provider.intro(message);
|
|
217
|
+
}
|
|
218
|
+
outro(message) {
|
|
219
|
+
this.provider.outro(message);
|
|
220
|
+
}
|
|
221
|
+
text(opts) {
|
|
222
|
+
return this.provider.text(opts);
|
|
223
|
+
}
|
|
224
|
+
confirm(opts) {
|
|
225
|
+
return this.provider.confirm(opts);
|
|
226
|
+
}
|
|
227
|
+
select(opts) {
|
|
228
|
+
return this.provider.select(opts);
|
|
229
|
+
}
|
|
230
|
+
multiselect(opts) {
|
|
231
|
+
return this.provider.multiselect(opts);
|
|
232
|
+
}
|
|
233
|
+
note(message, title) {
|
|
234
|
+
this.provider.note(message, title);
|
|
235
|
+
}
|
|
236
|
+
isCancel(value) {
|
|
237
|
+
return this.provider.isCancel(value);
|
|
238
|
+
}
|
|
239
|
+
cancel(message) {
|
|
240
|
+
this.provider.cancel(message);
|
|
241
|
+
}
|
|
242
|
+
get log() {
|
|
243
|
+
return this.provider.log;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var prompts = Prompts.getInstance();
|
|
247
|
+
|
|
35
248
|
// src/cli/index.ts
|
|
36
|
-
var
|
|
37
|
-
var import_picocolors14 = __toESM(require("picocolors"));
|
|
249
|
+
var import_picocolors16 = __toESM(require("picocolors"));
|
|
38
250
|
var import_commander = require("commander");
|
|
39
251
|
|
|
40
|
-
// src/features/husky.ts
|
|
41
|
-
var import_prompts2 = require("@clack/prompts");
|
|
42
|
-
|
|
43
252
|
// src/utils/pm.ts
|
|
44
253
|
var import_execa = require("execa");
|
|
45
254
|
async function getPackageManager() {
|
|
@@ -73,7 +282,7 @@ async function installPackages(packages, dev = false) {
|
|
|
73
282
|
// src/features/husky.ts
|
|
74
283
|
var import_execa2 = require("execa");
|
|
75
284
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
76
|
-
var
|
|
285
|
+
var import_picocolors2 = __toESM(require("picocolors"));
|
|
77
286
|
|
|
78
287
|
// src/constants/options.ts
|
|
79
288
|
var TOOL_OPTIONS = [
|
|
@@ -158,16 +367,15 @@ var LICENSE_TYPE_OPTIONS = [
|
|
|
158
367
|
];
|
|
159
368
|
|
|
160
369
|
// src/utils/handle-cancel.ts
|
|
161
|
-
var import_prompts = require("@clack/prompts");
|
|
162
370
|
async function withCancelHandling(promptFn, cancelMessage = "Operation cancelled.") {
|
|
163
371
|
while (true) {
|
|
164
372
|
const response = await promptFn();
|
|
165
|
-
if (
|
|
166
|
-
const shouldCancel = await
|
|
373
|
+
if (prompts.isCancel(response)) {
|
|
374
|
+
const shouldCancel = await prompts.confirm({
|
|
167
375
|
message: "Do you really want to cancel options selection?"
|
|
168
376
|
});
|
|
169
|
-
if (
|
|
170
|
-
|
|
377
|
+
if (prompts.isCancel(shouldCancel) || shouldCancel) {
|
|
378
|
+
prompts.cancel(cancelMessage);
|
|
171
379
|
process.exit(0);
|
|
172
380
|
}
|
|
173
381
|
continue;
|
|
@@ -179,9 +387,9 @@ async function withCancelHandling(promptFn, cancelMessage = "Operation cancelled
|
|
|
179
387
|
|
|
180
388
|
// src/features/husky.ts
|
|
181
389
|
async function promptHusky(config2) {
|
|
182
|
-
|
|
390
|
+
prompts.log.message(import_picocolors2.default.bgMagenta(import_picocolors2.default.black(" Husky Configuration ")));
|
|
183
391
|
const hookType = await withCancelHandling(
|
|
184
|
-
async () =>
|
|
392
|
+
async () => prompts.select({
|
|
185
393
|
message: "What pre-commit hook would you like to use?",
|
|
186
394
|
options: HUSKY_HOOK_OPTIONS
|
|
187
395
|
})
|
|
@@ -192,7 +400,7 @@ async function promptHusky(config2) {
|
|
|
192
400
|
config2.enableTool("lintStaged");
|
|
193
401
|
} else if (hookType === "custom") {
|
|
194
402
|
const script = await withCancelHandling(
|
|
195
|
-
async () =>
|
|
403
|
+
async () => prompts.text({
|
|
196
404
|
message: "Enter your custom pre-commit script:",
|
|
197
405
|
placeholder: huskyConfig.options.customScript,
|
|
198
406
|
validate(value) {
|
|
@@ -207,7 +415,7 @@ async function installHusky(config2) {
|
|
|
207
415
|
await installPackages(["husky"], true);
|
|
208
416
|
try {
|
|
209
417
|
await (0, import_execa2.execa)("npx", ["husky", "init"]);
|
|
210
|
-
} catch
|
|
418
|
+
} catch {
|
|
211
419
|
await (0, import_execa2.execa)("npm", ["pkg", "set", "scripts.prepare=husky"]);
|
|
212
420
|
await (0, import_execa2.execa)("npm", ["run", "prepare"]);
|
|
213
421
|
}
|
|
@@ -227,22 +435,20 @@ async function installHusky(config2) {
|
|
|
227
435
|
}
|
|
228
436
|
|
|
229
437
|
// src/features/formatter.ts
|
|
230
|
-
var
|
|
231
|
-
var import_picocolors3 = __toESM(require("picocolors"));
|
|
438
|
+
var import_picocolors4 = __toESM(require("picocolors"));
|
|
232
439
|
|
|
233
440
|
// src/features/formatter/prettier.ts
|
|
234
441
|
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
235
442
|
|
|
236
443
|
// src/utils/config-file.ts
|
|
237
444
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
238
|
-
var import_prompts3 = require("@clack/prompts");
|
|
239
445
|
var import_node_path = __toESM(require("path"));
|
|
240
446
|
async function resolveConfigFile(toolName, candidates) {
|
|
241
447
|
for (const file of candidates) {
|
|
242
448
|
if (await import_fs_extra2.default.pathExists(file)) return file;
|
|
243
449
|
}
|
|
244
450
|
const response = await withCancelHandling(
|
|
245
|
-
async () =>
|
|
451
|
+
async () => prompts.select({
|
|
246
452
|
message: `Where do you want to store the ${toolName} config?`,
|
|
247
453
|
options: candidates.map((c) => ({ value: c, label: c })),
|
|
248
454
|
initialValue: candidates[0]
|
|
@@ -313,7 +519,7 @@ async function configurePrettierPlugins(plugins) {
|
|
|
313
519
|
return;
|
|
314
520
|
}
|
|
315
521
|
currentConfig = await import_fs_extra3.default.readJson(configFile);
|
|
316
|
-
} catch
|
|
522
|
+
} catch {
|
|
317
523
|
}
|
|
318
524
|
}
|
|
319
525
|
const existingPlugins = currentConfig.plugins || [];
|
|
@@ -1513,50 +1719,50 @@ async function configureEslintPlugins(plugins) {
|
|
|
1513
1719
|
}
|
|
1514
1720
|
|
|
1515
1721
|
// src/steps/install-plugin.ts
|
|
1516
|
-
var
|
|
1517
|
-
var import_picocolors2 = __toESM(require("picocolors"));
|
|
1722
|
+
var import_picocolors3 = __toESM(require("picocolors"));
|
|
1518
1723
|
async function installPlugins(tool) {
|
|
1519
1724
|
const pluginsList = PLUGINS[tool];
|
|
1520
1725
|
const selectedPlugins = await withCancelHandling(
|
|
1521
|
-
async () =>
|
|
1726
|
+
async () => prompts.multiselect({
|
|
1522
1727
|
message: `Select ${tool} plugins to install:`,
|
|
1523
1728
|
options: pluginsList,
|
|
1524
|
-
required: true
|
|
1729
|
+
required: true,
|
|
1730
|
+
initialValue: []
|
|
1525
1731
|
})
|
|
1526
1732
|
);
|
|
1527
1733
|
if (selectedPlugins.length === 0) {
|
|
1528
|
-
|
|
1734
|
+
prompts.outro(import_picocolors3.default.yellow("No plugins selected."));
|
|
1529
1735
|
return;
|
|
1530
1736
|
}
|
|
1531
1737
|
const packagesToInstall = selectedPlugins.map((val) => {
|
|
1532
1738
|
const p = pluginsList.find((opt) => opt.value === val);
|
|
1533
1739
|
return p ? p.package : val;
|
|
1534
1740
|
});
|
|
1535
|
-
|
|
1536
|
-
|
|
1741
|
+
prompts.outro(
|
|
1742
|
+
import_picocolors3.default.blue(`Installing ${packagesToInstall.length} plugins for ${tool}...`)
|
|
1537
1743
|
);
|
|
1538
1744
|
await installPackages(packagesToInstall, true);
|
|
1539
1745
|
await configurePlugins(tool, selectedPlugins);
|
|
1540
1746
|
}
|
|
1541
1747
|
async function configurePlugins(tool, plugins) {
|
|
1542
1748
|
const shouldConfigure = await withCancelHandling(
|
|
1543
|
-
async () =>
|
|
1749
|
+
async () => prompts.confirm({
|
|
1544
1750
|
message: `Do you want to configure the selected plugins in your ${tool} config file?`,
|
|
1545
1751
|
initialValue: true
|
|
1546
1752
|
})
|
|
1547
1753
|
);
|
|
1548
1754
|
if (!shouldConfigure) {
|
|
1549
|
-
|
|
1755
|
+
prompts.outro(import_picocolors3.default.yellow("Skipping configuration."));
|
|
1550
1756
|
return;
|
|
1551
1757
|
}
|
|
1552
1758
|
switch (tool) {
|
|
1553
1759
|
case "prettier":
|
|
1554
1760
|
await configurePrettierPlugins(plugins);
|
|
1555
|
-
|
|
1761
|
+
prompts.outro(import_picocolors3.default.green("Prettier plugins configured in .prettierrc"));
|
|
1556
1762
|
break;
|
|
1557
1763
|
case "eslint":
|
|
1558
1764
|
await configureEslintPlugins(plugins);
|
|
1559
|
-
|
|
1765
|
+
prompts.outro(import_picocolors3.default.green("ESLint plugins configured in .eslintrc.json"));
|
|
1560
1766
|
break;
|
|
1561
1767
|
}
|
|
1562
1768
|
}
|
|
@@ -1564,9 +1770,9 @@ async function configurePlugins(tool, plugins) {
|
|
|
1564
1770
|
// src/features/formatter.ts
|
|
1565
1771
|
async function promptFormatter(config2) {
|
|
1566
1772
|
const formatterConfig = config2.get("formatter");
|
|
1567
|
-
|
|
1773
|
+
prompts.log.message(import_picocolors4.default.bgBlue(import_picocolors4.default.white(" Formatter Configuration ")));
|
|
1568
1774
|
const formatter = await withCancelHandling(
|
|
1569
|
-
async () =>
|
|
1775
|
+
async () => prompts.select({
|
|
1570
1776
|
message: "Select a formatter:",
|
|
1571
1777
|
options: FORMATTER_OPTIONS,
|
|
1572
1778
|
initialValue: formatterConfig.options.choice
|
|
@@ -1577,12 +1783,12 @@ async function promptFormatter(config2) {
|
|
|
1577
1783
|
async function installFormatter(config2) {
|
|
1578
1784
|
const formatter = config2.get("formatter").options.choice;
|
|
1579
1785
|
if (!formatter) return;
|
|
1580
|
-
|
|
1786
|
+
prompts.log.message(import_picocolors4.default.white(import_picocolors4.default.bgBlack(` Installing ${formatter}... `)));
|
|
1581
1787
|
if (formatter === "prettier") await installPrettier();
|
|
1582
1788
|
else if (formatter === "oxfmt") await installOxfmt();
|
|
1583
1789
|
if (!PLUGINABLE_TOOLS.includes(formatter)) return;
|
|
1584
1790
|
const shouldConfigure = await withCancelHandling(
|
|
1585
|
-
async () =>
|
|
1791
|
+
async () => prompts.confirm({
|
|
1586
1792
|
message: `Do you want to install plugins for ${formatter}?`,
|
|
1587
1793
|
initialValue: true
|
|
1588
1794
|
})
|
|
@@ -1592,8 +1798,7 @@ async function installFormatter(config2) {
|
|
|
1592
1798
|
}
|
|
1593
1799
|
|
|
1594
1800
|
// src/features/linter.ts
|
|
1595
|
-
var
|
|
1596
|
-
var import_picocolors4 = __toESM(require("picocolors"));
|
|
1801
|
+
var import_picocolors5 = __toESM(require("picocolors"));
|
|
1597
1802
|
|
|
1598
1803
|
// src/features/linter/oxlint.ts
|
|
1599
1804
|
async function installOxlint() {
|
|
@@ -1603,9 +1808,9 @@ async function installOxlint() {
|
|
|
1603
1808
|
// src/features/linter.ts
|
|
1604
1809
|
async function promptLinter(config2) {
|
|
1605
1810
|
const linterConfig = config2.get("linter");
|
|
1606
|
-
|
|
1811
|
+
prompts.log.message(import_picocolors5.default.bgYellow(import_picocolors5.default.black(" Linter Configuration ")));
|
|
1607
1812
|
const linter = await withCancelHandling(
|
|
1608
|
-
async () =>
|
|
1813
|
+
async () => prompts.select({
|
|
1609
1814
|
message: "Select a linter:",
|
|
1610
1815
|
options: LINTER_OPTIONS,
|
|
1611
1816
|
initialValue: linterConfig.options.choice
|
|
@@ -1616,12 +1821,12 @@ async function promptLinter(config2) {
|
|
|
1616
1821
|
async function installLinter(config2) {
|
|
1617
1822
|
const linter = config2.get("linter").options.choice;
|
|
1618
1823
|
if (!linter) return;
|
|
1619
|
-
|
|
1824
|
+
prompts.log.message(import_picocolors5.default.white(import_picocolors5.default.bgBlack(` Installing ${linter}... `)));
|
|
1620
1825
|
if (linter === "eslint") await installEslint();
|
|
1621
1826
|
else if (linter === "oxlint") await installOxlint();
|
|
1622
1827
|
if (!PLUGINABLE_TOOLS.includes(linter)) return;
|
|
1623
1828
|
const shouldConfigure = await withCancelHandling(
|
|
1624
|
-
async () =>
|
|
1829
|
+
async () => prompts.confirm({
|
|
1625
1830
|
message: `Do you want to install plugins for ${linter}?`,
|
|
1626
1831
|
initialValue: true
|
|
1627
1832
|
})
|
|
@@ -1631,19 +1836,18 @@ async function installLinter(config2) {
|
|
|
1631
1836
|
}
|
|
1632
1837
|
|
|
1633
1838
|
// src/features/lint-staged.ts
|
|
1634
|
-
var
|
|
1635
|
-
var import_picocolors5 = __toESM(require("picocolors"));
|
|
1839
|
+
var import_picocolors6 = __toESM(require("picocolors"));
|
|
1636
1840
|
async function promptLintStaged(config2) {
|
|
1637
|
-
|
|
1841
|
+
prompts.log.message(import_picocolors6.default.bgGreen(import_picocolors6.default.black(" Lint-staged Configuration ")));
|
|
1638
1842
|
const lintExtensions = await withCancelHandling(
|
|
1639
|
-
async () =>
|
|
1843
|
+
async () => prompts.multiselect({
|
|
1640
1844
|
message: "Select extensions to lint:",
|
|
1641
1845
|
options: LINT_STAGED_EXTENSIONS,
|
|
1642
1846
|
required: false
|
|
1643
1847
|
})
|
|
1644
1848
|
);
|
|
1645
1849
|
const formatExtensions = await withCancelHandling(
|
|
1646
|
-
async () =>
|
|
1850
|
+
async () => prompts.multiselect({
|
|
1647
1851
|
message: "Select extensions to format:",
|
|
1648
1852
|
options: LINT_STAGED_EXTENSIONS,
|
|
1649
1853
|
required: false
|
|
@@ -1697,33 +1901,32 @@ async function installLintStaged(config2) {
|
|
|
1697
1901
|
}
|
|
1698
1902
|
|
|
1699
1903
|
// src/features/env.ts
|
|
1700
|
-
var import_prompts8 = require("@clack/prompts");
|
|
1701
1904
|
var import_fs_extra5 = __toESM(require("fs-extra"));
|
|
1702
1905
|
var import_path = __toESM(require("path"));
|
|
1703
|
-
var
|
|
1906
|
+
var import_picocolors7 = __toESM(require("picocolors"));
|
|
1704
1907
|
async function promptEnv(config2) {
|
|
1705
|
-
|
|
1908
|
+
prompts.log.message(import_picocolors7.default.bgCyan(import_picocolors7.default.black(" Env Validation Configuration ")));
|
|
1706
1909
|
const variant = await withCancelHandling(
|
|
1707
|
-
async () =>
|
|
1910
|
+
async () => prompts.select({
|
|
1708
1911
|
message: "Which @t3-oss/env variant?",
|
|
1709
1912
|
options: ENV_VARIANT_OPTIONS
|
|
1710
1913
|
})
|
|
1711
1914
|
);
|
|
1712
1915
|
const validator = await withCancelHandling(
|
|
1713
|
-
async () =>
|
|
1916
|
+
async () => prompts.select({
|
|
1714
1917
|
message: "Which validator?",
|
|
1715
1918
|
options: ENV_VALIDATOR_OPTIONS
|
|
1716
1919
|
})
|
|
1717
1920
|
);
|
|
1718
1921
|
const installPresets = await withCancelHandling(
|
|
1719
|
-
async () =>
|
|
1922
|
+
async () => prompts.confirm({
|
|
1720
1923
|
message: "Install presets?"
|
|
1721
1924
|
})
|
|
1722
1925
|
);
|
|
1723
1926
|
let presets;
|
|
1724
1927
|
if (installPresets) {
|
|
1725
1928
|
presets = await withCancelHandling(
|
|
1726
|
-
async () =>
|
|
1929
|
+
async () => prompts.multiselect({
|
|
1727
1930
|
message: "Select preset to extend:",
|
|
1728
1931
|
options: ENV_PRESET_OPTIONS,
|
|
1729
1932
|
required: false
|
|
@@ -1731,13 +1934,13 @@ async function promptEnv(config2) {
|
|
|
1731
1934
|
);
|
|
1732
1935
|
}
|
|
1733
1936
|
const split = await withCancelHandling(
|
|
1734
|
-
async () =>
|
|
1937
|
+
async () => prompts.select({
|
|
1735
1938
|
message: "Split or Joined env files?",
|
|
1736
1939
|
options: ENV_SPLIT_OPTIONS
|
|
1737
1940
|
})
|
|
1738
1941
|
);
|
|
1739
1942
|
const location = await withCancelHandling(
|
|
1740
|
-
async () =>
|
|
1943
|
+
async () => prompts.text({
|
|
1741
1944
|
message: "Where should the environment files be created?",
|
|
1742
1945
|
initialValue: config2.get("env").options.location || "src/lib",
|
|
1743
1946
|
placeholder: "src/lib"
|
|
@@ -1809,13 +2012,12 @@ export const env = createEnv({
|
|
|
1809
2012
|
}
|
|
1810
2013
|
|
|
1811
2014
|
// src/features/test.ts
|
|
1812
|
-
var import_prompts9 = require("@clack/prompts");
|
|
1813
2015
|
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
1814
|
-
var
|
|
2016
|
+
var import_picocolors8 = __toESM(require("picocolors"));
|
|
1815
2017
|
async function promptTest(config2) {
|
|
1816
|
-
|
|
2018
|
+
prompts.log.message(import_picocolors8.default.bgRed(import_picocolors8.default.white(" Test Runner Configuration ")));
|
|
1817
2019
|
const runner = await withCancelHandling(
|
|
1818
|
-
async () =>
|
|
2020
|
+
async () => prompts.select({
|
|
1819
2021
|
message: "Select a test runner:",
|
|
1820
2022
|
options: TEST_RUNNER_OPTIONS
|
|
1821
2023
|
})
|
|
@@ -1858,14 +2060,13 @@ module.exports = {
|
|
|
1858
2060
|
}
|
|
1859
2061
|
|
|
1860
2062
|
// src/features/editor-config.ts
|
|
1861
|
-
var import_prompts10 = require("@clack/prompts");
|
|
1862
2063
|
var import_fs_extra7 = __toESM(require("fs-extra"));
|
|
1863
|
-
var
|
|
2064
|
+
var import_picocolors9 = __toESM(require("picocolors"));
|
|
1864
2065
|
async function promptEditorConfig(config2) {
|
|
1865
|
-
|
|
2066
|
+
prompts.log.message(import_picocolors9.default.bgWhite(import_picocolors9.default.black(" EditorConfig Configuration ")));
|
|
1866
2067
|
const currentPreset = config2.get("editorConfig").options.preset;
|
|
1867
2068
|
const preset = await withCancelHandling(
|
|
1868
|
-
async () =>
|
|
2069
|
+
async () => prompts.select({
|
|
1869
2070
|
message: "Select EditorConfig preset:",
|
|
1870
2071
|
options: EDITOR_CONFIG_OPTIONS,
|
|
1871
2072
|
initialValue: currentPreset
|
|
@@ -1887,36 +2088,35 @@ async function installEditorConfig(config2) {
|
|
|
1887
2088
|
}
|
|
1888
2089
|
|
|
1889
2090
|
// src/features/license.ts
|
|
1890
|
-
var import_prompts11 = require("@clack/prompts");
|
|
1891
2091
|
var import_fs_extra8 = __toESM(require("fs-extra"));
|
|
1892
2092
|
var import_path2 = __toESM(require("path"));
|
|
1893
|
-
var
|
|
2093
|
+
var import_picocolors10 = __toESM(require("picocolors"));
|
|
1894
2094
|
async function promptLicense(config2) {
|
|
1895
|
-
|
|
2095
|
+
prompts.log.message(import_picocolors10.default.bgGreen(import_picocolors10.default.black(" License Configuration ")));
|
|
1896
2096
|
const licenseOptions = config2.get("license").options;
|
|
1897
2097
|
licenseOptions.name = await withCancelHandling(
|
|
1898
|
-
async () =>
|
|
2098
|
+
async () => prompts.text({
|
|
1899
2099
|
message: "License Holder Name:",
|
|
1900
2100
|
placeholder: "John Doe",
|
|
1901
2101
|
initialValue: licenseOptions.name
|
|
1902
2102
|
})
|
|
1903
2103
|
);
|
|
1904
2104
|
licenseOptions.email = await withCancelHandling(
|
|
1905
|
-
async () =>
|
|
2105
|
+
async () => prompts.text({
|
|
1906
2106
|
message: "License Holder Email:",
|
|
1907
2107
|
placeholder: "john@example.com",
|
|
1908
2108
|
initialValue: licenseOptions.email
|
|
1909
2109
|
})
|
|
1910
2110
|
);
|
|
1911
2111
|
licenseOptions.website = await withCancelHandling(
|
|
1912
|
-
async () =>
|
|
2112
|
+
async () => prompts.text({
|
|
1913
2113
|
message: "License Holder Website:",
|
|
1914
2114
|
placeholder: "https://example.com",
|
|
1915
2115
|
initialValue: licenseOptions.website
|
|
1916
2116
|
})
|
|
1917
2117
|
);
|
|
1918
2118
|
licenseOptions.type = await withCancelHandling(
|
|
1919
|
-
async () =>
|
|
2119
|
+
async () => prompts.select({
|
|
1920
2120
|
message: "Select License Type:",
|
|
1921
2121
|
options: LICENSE_TYPE_OPTIONS
|
|
1922
2122
|
})
|
|
@@ -1952,7 +2152,7 @@ Licensed under ${type}`;
|
|
|
1952
2152
|
}
|
|
1953
2153
|
|
|
1954
2154
|
// src/core/config.ts
|
|
1955
|
-
var
|
|
2155
|
+
var import_picocolors11 = __toESM(require("picocolors"));
|
|
1956
2156
|
var Config = class {
|
|
1957
2157
|
data;
|
|
1958
2158
|
constructor() {
|
|
@@ -1998,6 +2198,49 @@ var Config = class {
|
|
|
1998
2198
|
}
|
|
1999
2199
|
};
|
|
2000
2200
|
}
|
|
2201
|
+
clear() {
|
|
2202
|
+
this.data = {
|
|
2203
|
+
husky: {
|
|
2204
|
+
selected: false,
|
|
2205
|
+
options: { hookType: "none", customScript: "npm run test" }
|
|
2206
|
+
},
|
|
2207
|
+
formatter: {
|
|
2208
|
+
selected: false,
|
|
2209
|
+
options: { choice: "prettier" }
|
|
2210
|
+
},
|
|
2211
|
+
linter: {
|
|
2212
|
+
selected: false,
|
|
2213
|
+
options: { choice: "eslint" }
|
|
2214
|
+
},
|
|
2215
|
+
lintStaged: {
|
|
2216
|
+
selected: false,
|
|
2217
|
+
options: { lintExtensions: [], formatExtensions: [] }
|
|
2218
|
+
},
|
|
2219
|
+
env: {
|
|
2220
|
+
selected: false,
|
|
2221
|
+
options: {
|
|
2222
|
+
variant: "@t3-oss/env-nextjs",
|
|
2223
|
+
validator: "zod",
|
|
2224
|
+
installPresets: false,
|
|
2225
|
+
presets: [],
|
|
2226
|
+
split: "split",
|
|
2227
|
+
location: "src/lib"
|
|
2228
|
+
}
|
|
2229
|
+
},
|
|
2230
|
+
test: {
|
|
2231
|
+
selected: false,
|
|
2232
|
+
options: { runner: "vitest" }
|
|
2233
|
+
},
|
|
2234
|
+
editorConfig: {
|
|
2235
|
+
selected: false,
|
|
2236
|
+
options: { preset: "default" }
|
|
2237
|
+
},
|
|
2238
|
+
license: {
|
|
2239
|
+
selected: false,
|
|
2240
|
+
options: { name: "", email: "", website: "", type: "MIT" }
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2001
2244
|
get(tool) {
|
|
2002
2245
|
return this.data[tool];
|
|
2003
2246
|
}
|
|
@@ -2006,57 +2249,98 @@ var Config = class {
|
|
|
2006
2249
|
}
|
|
2007
2250
|
get summary() {
|
|
2008
2251
|
const lines = [];
|
|
2009
|
-
lines.push(
|
|
2252
|
+
lines.push(import_picocolors11.default.bold("The following actions will be performed:"));
|
|
2010
2253
|
lines.push("");
|
|
2011
2254
|
if (this.data.husky.selected) {
|
|
2012
|
-
lines.push(
|
|
2255
|
+
lines.push(import_picocolors11.default.magenta(`\u2022 Install and configure Husky`));
|
|
2013
2256
|
if (this.data.husky.options.hookType === "custom") {
|
|
2014
|
-
lines.push(
|
|
2257
|
+
lines.push(import_picocolors11.default.dim(` - Custom hook script`));
|
|
2015
2258
|
}
|
|
2016
2259
|
}
|
|
2017
2260
|
if (this.data.formatter.selected) {
|
|
2018
2261
|
const choice = this.data.formatter.options.choice;
|
|
2019
|
-
lines.push(
|
|
2262
|
+
lines.push(import_picocolors11.default.blue(`\u2022 Install and configure ${choice || "Formatter"}`));
|
|
2020
2263
|
}
|
|
2021
2264
|
if (this.data.linter.selected) {
|
|
2022
2265
|
const choice = this.data.linter.options.choice;
|
|
2023
|
-
lines.push(
|
|
2266
|
+
lines.push(import_picocolors11.default.yellow(`\u2022 Install and configure ${choice || "Linter"}`));
|
|
2024
2267
|
}
|
|
2025
2268
|
if (this.data.lintStaged.selected) {
|
|
2026
|
-
lines.push(
|
|
2269
|
+
lines.push(import_picocolors11.default.green(`\u2022 Install and configure Lint-staged`));
|
|
2027
2270
|
const lintExts = this.data.lintStaged.options.lintExtensions.join(", ");
|
|
2028
2271
|
const formatExts = this.data.lintStaged.options.formatExtensions.join(", ");
|
|
2029
|
-
if (lintExts) lines.push(
|
|
2030
|
-
if (formatExts) lines.push(
|
|
2272
|
+
if (lintExts) lines.push(import_picocolors11.default.dim(` - Lint: ${lintExts}`));
|
|
2273
|
+
if (formatExts) lines.push(import_picocolors11.default.dim(` - Format: ${formatExts}`));
|
|
2031
2274
|
}
|
|
2032
2275
|
if (this.data.env.selected) {
|
|
2033
|
-
lines.push(
|
|
2034
|
-
lines.push(
|
|
2035
|
-
lines.push(
|
|
2276
|
+
lines.push(import_picocolors11.default.cyan(`\u2022 Install and configure Env Validation`));
|
|
2277
|
+
lines.push(import_picocolors11.default.dim(` - Variant: ${this.data.env.options.variant}`));
|
|
2278
|
+
lines.push(import_picocolors11.default.dim(` - Validator: ${this.data.env.options.validator}`));
|
|
2036
2279
|
}
|
|
2037
2280
|
if (this.data.test.selected) {
|
|
2038
2281
|
const runner = this.data.test.options.runner;
|
|
2039
|
-
lines.push(
|
|
2282
|
+
lines.push(import_picocolors11.default.red(`\u2022 Install and configure Test Runner (${runner})`));
|
|
2040
2283
|
}
|
|
2041
2284
|
if (this.data.editorConfig.selected) {
|
|
2042
2285
|
const preset = this.data.editorConfig.options.preset;
|
|
2043
|
-
lines.push(
|
|
2286
|
+
lines.push(import_picocolors11.default.white(`\u2022 Create .editorconfig (${preset})`));
|
|
2044
2287
|
}
|
|
2045
2288
|
if (this.data.license.selected) {
|
|
2046
2289
|
const type = this.data.license.options.type;
|
|
2047
2290
|
const name = this.data.license.options.name;
|
|
2048
|
-
lines.push(
|
|
2049
|
-
lines.push(
|
|
2291
|
+
lines.push(import_picocolors11.default.green(`\u2022 Create LICENSE (${type})`));
|
|
2292
|
+
lines.push(import_picocolors11.default.dim(` - Holder: ${name}`));
|
|
2050
2293
|
}
|
|
2051
2294
|
return lines.join("\n");
|
|
2052
2295
|
}
|
|
2053
2296
|
};
|
|
2054
2297
|
var config = new Config();
|
|
2055
2298
|
|
|
2299
|
+
// src/utils/spinner.ts
|
|
2300
|
+
var import_cli_spinners = __toESM(require("cli-spinners"));
|
|
2301
|
+
var import_picocolors12 = __toESM(require("picocolors"));
|
|
2302
|
+
var Spinner = class {
|
|
2303
|
+
timer = null;
|
|
2304
|
+
frameIndex = 0;
|
|
2305
|
+
spinner = import_cli_spinners.default.dots;
|
|
2306
|
+
text = "";
|
|
2307
|
+
start(text2) {
|
|
2308
|
+
this.text = text2;
|
|
2309
|
+
this.frameIndex = 0;
|
|
2310
|
+
if (this.timer) clearInterval(this.timer);
|
|
2311
|
+
this.timer = setInterval(() => {
|
|
2312
|
+
const frame = this.spinner.frames[this.frameIndex];
|
|
2313
|
+
process.stdout.write(`\r${import_picocolors12.default.magenta(frame)} ${this.text}`);
|
|
2314
|
+
this.frameIndex = (this.frameIndex + 1) % this.spinner.frames.length;
|
|
2315
|
+
}, this.spinner.interval);
|
|
2316
|
+
}
|
|
2317
|
+
stop(text2) {
|
|
2318
|
+
if (this.timer) {
|
|
2319
|
+
clearInterval(this.timer);
|
|
2320
|
+
this.timer = null;
|
|
2321
|
+
process.stdout.write("\r\x1B[K");
|
|
2322
|
+
if (text2) {
|
|
2323
|
+
console.log(text2);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
success(text2) {
|
|
2328
|
+
this.stop();
|
|
2329
|
+
console.log(`${import_picocolors12.default.green("\u2714")} ${text2 || this.text}`);
|
|
2330
|
+
}
|
|
2331
|
+
fail(text2) {
|
|
2332
|
+
this.stop();
|
|
2333
|
+
console.log(`${import_picocolors12.default.red("\u2716")} ${text2 || this.text}`);
|
|
2334
|
+
}
|
|
2335
|
+
message(text2) {
|
|
2336
|
+
this.text = text2;
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
var spinner = () => new Spinner();
|
|
2340
|
+
|
|
2056
2341
|
// src/steps/execution.ts
|
|
2057
|
-
var import_prompts12 = require("@clack/prompts");
|
|
2058
2342
|
async function execution(config2) {
|
|
2059
|
-
const s =
|
|
2343
|
+
const s = spinner();
|
|
2060
2344
|
if (config2.get("husky").selected) {
|
|
2061
2345
|
s.start("Setting up Husky...");
|
|
2062
2346
|
await installHusky(config2);
|
|
@@ -2154,15 +2438,14 @@ async function commitChanges(message) {
|
|
|
2154
2438
|
}
|
|
2155
2439
|
|
|
2156
2440
|
// src/steps/git-check.ts
|
|
2157
|
-
var import_prompts13 = require("@clack/prompts");
|
|
2158
2441
|
async function gitCheck() {
|
|
2159
2442
|
if (await isGitRepository()) {
|
|
2160
2443
|
if (await isGitDirty()) {
|
|
2161
|
-
const shouldCommit = await
|
|
2444
|
+
const shouldCommit = await prompts.confirm({
|
|
2162
2445
|
message: "Your working directory is dirty. Would you like to commit changes before proceeding?"
|
|
2163
2446
|
});
|
|
2164
2447
|
if (shouldCommit) {
|
|
2165
|
-
const message = await
|
|
2448
|
+
const message = await prompts.text({
|
|
2166
2449
|
message: "Enter commit message:",
|
|
2167
2450
|
placeholder: "wip: pre-setup commit",
|
|
2168
2451
|
validate(value) {
|
|
@@ -2170,7 +2453,7 @@ async function gitCheck() {
|
|
|
2170
2453
|
}
|
|
2171
2454
|
});
|
|
2172
2455
|
if (typeof message === "string") {
|
|
2173
|
-
const s =
|
|
2456
|
+
const s = spinner();
|
|
2174
2457
|
s.start("Committing changes...");
|
|
2175
2458
|
await commitChanges(message);
|
|
2176
2459
|
s.stop("Changes committed.");
|
|
@@ -2181,60 +2464,63 @@ async function gitCheck() {
|
|
|
2181
2464
|
}
|
|
2182
2465
|
|
|
2183
2466
|
// src/utils/display.ts
|
|
2184
|
-
var
|
|
2467
|
+
var import_picocolors13 = __toESM(require("picocolors"));
|
|
2185
2468
|
var import_figlet = __toESM(require("figlet"));
|
|
2186
2469
|
|
|
2187
2470
|
// package.json
|
|
2188
2471
|
var package_default = {
|
|
2189
2472
|
name: "@mayrlabs/setup-project",
|
|
2190
|
-
version: "0.1.
|
|
2191
|
-
description: "Interactive CLI to setup project tools",
|
|
2473
|
+
version: "0.1.9",
|
|
2192
2474
|
private: false,
|
|
2193
|
-
|
|
2194
|
-
access: "public"
|
|
2195
|
-
},
|
|
2475
|
+
description: "Interactive CLI to setup project tools",
|
|
2196
2476
|
keywords: [
|
|
2197
|
-
"setup",
|
|
2198
2477
|
"cli",
|
|
2199
|
-
"
|
|
2478
|
+
"eslint",
|
|
2200
2479
|
"husky",
|
|
2201
2480
|
"prettier",
|
|
2202
|
-
"
|
|
2203
|
-
|
|
2204
|
-
bin: {
|
|
2205
|
-
"setup-project": "dist/index.js"
|
|
2206
|
-
},
|
|
2207
|
-
files: [
|
|
2208
|
-
"dist",
|
|
2209
|
-
"README.md",
|
|
2210
|
-
"CHANGELOG.md",
|
|
2211
|
-
"package.json"
|
|
2481
|
+
"scaffold",
|
|
2482
|
+
"setup"
|
|
2212
2483
|
],
|
|
2213
2484
|
homepage: "https://github.com/MayR-Labs/mayrlabs-js/tree/main/packages/setup-project#readme",
|
|
2214
2485
|
bugs: {
|
|
2215
2486
|
url: "https://github.com/MayR-Labs/mayrlabs-js/issues"
|
|
2216
2487
|
},
|
|
2217
|
-
repository: {
|
|
2218
|
-
type: "git",
|
|
2219
|
-
url: "git+https://github.com/MayR-Labs/mayrlabs-js.git",
|
|
2220
|
-
directory: "packages/setup-project"
|
|
2221
|
-
},
|
|
2222
2488
|
license: "MIT",
|
|
2223
2489
|
author: {
|
|
2224
2490
|
name: "Aghogho Meyoron",
|
|
2225
2491
|
email: "youngmayor.dev@gmail.com",
|
|
2226
2492
|
url: "https://mayrlabs.com"
|
|
2227
2493
|
},
|
|
2494
|
+
repository: {
|
|
2495
|
+
type: "git",
|
|
2496
|
+
url: "git+https://github.com/MayR-Labs/mayrlabs-js.git",
|
|
2497
|
+
directory: "packages/setup-project"
|
|
2498
|
+
},
|
|
2499
|
+
bin: {
|
|
2500
|
+
"setup-project": "dist/index.js"
|
|
2501
|
+
},
|
|
2502
|
+
files: [
|
|
2503
|
+
"dist",
|
|
2504
|
+
"README.md",
|
|
2505
|
+
"CHANGELOG.md",
|
|
2506
|
+
"package.json"
|
|
2507
|
+
],
|
|
2228
2508
|
type: "commonjs",
|
|
2229
2509
|
main: "dist/index.js",
|
|
2510
|
+
publishConfig: {
|
|
2511
|
+
access: "public"
|
|
2512
|
+
},
|
|
2230
2513
|
scripts: {
|
|
2231
2514
|
build: "tsup",
|
|
2515
|
+
lint: "eslint . --max-warnings 0",
|
|
2232
2516
|
demo: "tsx src/cli/index.ts",
|
|
2233
2517
|
test: "vitest",
|
|
2234
2518
|
prepublishOnly: "npm run build"
|
|
2235
2519
|
},
|
|
2236
2520
|
dependencies: {
|
|
2237
2521
|
"@clack/prompts": "^0.7.0",
|
|
2522
|
+
"@topcli/prompts": "^2.4.1",
|
|
2523
|
+
"cli-spinners": "^3.4.0",
|
|
2238
2524
|
commander: "^11.1.0",
|
|
2239
2525
|
execa: "^8.0.1",
|
|
2240
2526
|
figlet: "^1.10.0",
|
|
@@ -2243,10 +2529,12 @@ var package_default = {
|
|
|
2243
2529
|
zod: "^3.22.4"
|
|
2244
2530
|
},
|
|
2245
2531
|
devDependencies: {
|
|
2532
|
+
"@repo/eslint-config": "^0.0.0",
|
|
2246
2533
|
"@types/figlet": "^1.7.0",
|
|
2247
2534
|
"@types/fs-extra": "^11.0.4",
|
|
2248
2535
|
"@types/node": "^20.11.16",
|
|
2249
2536
|
"@vitest/coverage-v8": "^4.0.18",
|
|
2537
|
+
eslint: "^9.39.2",
|
|
2250
2538
|
tsup: "^8.5.1",
|
|
2251
2539
|
tsx: "^4.21.0",
|
|
2252
2540
|
typescript: "^5.3.3",
|
|
@@ -2258,7 +2546,7 @@ var package_default = {
|
|
|
2258
2546
|
function introScreen() {
|
|
2259
2547
|
console.log();
|
|
2260
2548
|
console.log(
|
|
2261
|
-
|
|
2549
|
+
import_picocolors13.default.cyan(
|
|
2262
2550
|
import_figlet.default.textSync("MayR\nLabs", {
|
|
2263
2551
|
font: "Graceful",
|
|
2264
2552
|
horizontalLayout: "default",
|
|
@@ -2268,33 +2556,33 @@ function introScreen() {
|
|
|
2268
2556
|
})
|
|
2269
2557
|
)
|
|
2270
2558
|
);
|
|
2271
|
-
console.log(
|
|
2559
|
+
console.log(import_picocolors13.default.cyan(`${package_default.name} - v${package_default.version}`));
|
|
2272
2560
|
console.log();
|
|
2273
2561
|
}
|
|
2274
2562
|
function showAbout() {
|
|
2275
2563
|
introScreen();
|
|
2276
|
-
console.log(
|
|
2564
|
+
console.log(import_picocolors13.default.bold("About:"));
|
|
2277
2565
|
console.log(
|
|
2278
2566
|
" Interactive CLI to setup project tools like Husky, Prettier, ESLint, etc."
|
|
2279
2567
|
);
|
|
2280
2568
|
console.log("");
|
|
2281
|
-
console.log(
|
|
2569
|
+
console.log(import_picocolors13.default.bold("How to use:"));
|
|
2282
2570
|
console.log(
|
|
2283
2571
|
" Run 'npx @mayrlabs/setup-project' and follow the interactive prompts."
|
|
2284
2572
|
);
|
|
2285
2573
|
console.log("");
|
|
2286
2574
|
}
|
|
2287
2575
|
function showVisit() {
|
|
2288
|
-
console.log(
|
|
2289
|
-
console.log(
|
|
2576
|
+
console.log(import_picocolors13.default.bold("Project Homepage:"));
|
|
2577
|
+
console.log(import_picocolors13.default.underline(import_picocolors13.default.cyan(package_default.homepage)));
|
|
2290
2578
|
console.log("");
|
|
2291
2579
|
}
|
|
2292
2580
|
function showManual() {
|
|
2293
2581
|
introScreen();
|
|
2294
|
-
console.log(
|
|
2582
|
+
console.log(import_picocolors13.default.bold("Usage:"));
|
|
2295
2583
|
console.log(" npx @mayrlabs/setup-project [command] [options]");
|
|
2296
2584
|
console.log("");
|
|
2297
|
-
console.log(
|
|
2585
|
+
console.log(import_picocolors13.default.bold("Commands:"));
|
|
2298
2586
|
console.log(" about Show project details");
|
|
2299
2587
|
console.log(" version Show version information");
|
|
2300
2588
|
console.log(" visit Visit project homepage");
|
|
@@ -2302,7 +2590,7 @@ function showManual() {
|
|
|
2302
2590
|
console.log(" configure [tool] Configure a specific tool");
|
|
2303
2591
|
console.log(" plugin [tool] Manage plugins for tools");
|
|
2304
2592
|
console.log("");
|
|
2305
|
-
console.log(
|
|
2593
|
+
console.log(import_picocolors13.default.bold("Options:"));
|
|
2306
2594
|
console.log(" -a, --about Show project details");
|
|
2307
2595
|
console.log(" -v, --version Show version information");
|
|
2308
2596
|
console.log(" -V, --visit Visit project homepage");
|
|
@@ -2311,11 +2599,10 @@ function showManual() {
|
|
|
2311
2599
|
}
|
|
2312
2600
|
|
|
2313
2601
|
// src/cli/commands/configure.ts
|
|
2314
|
-
var
|
|
2315
|
-
var import_picocolors12 = __toESM(require("picocolors"));
|
|
2602
|
+
var import_picocolors14 = __toESM(require("picocolors"));
|
|
2316
2603
|
async function configure(toolName) {
|
|
2317
2604
|
introScreen();
|
|
2318
|
-
|
|
2605
|
+
prompts.intro(import_picocolors14.default.inverse(import_picocolors14.default.bold(import_picocolors14.default.blue(" Configuration Mode "))));
|
|
2319
2606
|
await gitCheck();
|
|
2320
2607
|
let selectedTool;
|
|
2321
2608
|
if (toolName) {
|
|
@@ -2324,13 +2611,13 @@ async function configure(toolName) {
|
|
|
2324
2611
|
selectedTool = tool.value;
|
|
2325
2612
|
} else {
|
|
2326
2613
|
console.log(
|
|
2327
|
-
|
|
2614
|
+
import_picocolors14.default.yellow(`Tool '${toolName}' not found or not configurable.`)
|
|
2328
2615
|
);
|
|
2329
2616
|
}
|
|
2330
2617
|
}
|
|
2331
2618
|
if (!selectedTool) {
|
|
2332
2619
|
const selection = await withCancelHandling(
|
|
2333
|
-
async () =>
|
|
2620
|
+
async () => prompts.select({
|
|
2334
2621
|
message: "Select a tool to configure:",
|
|
2335
2622
|
options: TOOL_OPTIONS
|
|
2336
2623
|
})
|
|
@@ -2373,24 +2660,23 @@ async function configure(toolName) {
|
|
|
2373
2660
|
await installLicense(config);
|
|
2374
2661
|
break;
|
|
2375
2662
|
}
|
|
2376
|
-
|
|
2663
|
+
prompts.outro(import_picocolors14.default.green(`${selectedTool} configured successfully!`));
|
|
2377
2664
|
} catch (error) {
|
|
2378
|
-
|
|
2665
|
+
prompts.outro(import_picocolors14.default.red(`Failed to configure ${selectedTool}.`));
|
|
2379
2666
|
console.error(error);
|
|
2380
2667
|
process.exit(1);
|
|
2381
2668
|
}
|
|
2382
2669
|
}
|
|
2383
2670
|
|
|
2384
2671
|
// src/cli/commands/plugin.ts
|
|
2385
|
-
var
|
|
2386
|
-
var import_picocolors13 = __toESM(require("picocolors"));
|
|
2672
|
+
var import_picocolors15 = __toESM(require("picocolors"));
|
|
2387
2673
|
async function plugin(toolName) {
|
|
2388
2674
|
introScreen();
|
|
2389
|
-
|
|
2675
|
+
prompts.intro(import_picocolors15.default.inverse(import_picocolors15.default.bold(import_picocolors15.default.magenta(" Plugin Manager "))));
|
|
2390
2676
|
await gitCheck();
|
|
2391
2677
|
if (!toolName) {
|
|
2392
2678
|
toolName = await withCancelHandling(
|
|
2393
|
-
async () =>
|
|
2679
|
+
async () => prompts.select({
|
|
2394
2680
|
message: "Select a tool to add plugins to:",
|
|
2395
2681
|
options: [
|
|
2396
2682
|
{ value: "eslint", label: "ESLint" },
|
|
@@ -2400,19 +2686,19 @@ async function plugin(toolName) {
|
|
|
2400
2686
|
);
|
|
2401
2687
|
}
|
|
2402
2688
|
await installPlugins(toolName);
|
|
2403
|
-
|
|
2689
|
+
prompts.outro(import_picocolors15.default.green("Plugins installed successfully!"));
|
|
2404
2690
|
}
|
|
2405
2691
|
|
|
2406
2692
|
// src/cli/index.ts
|
|
2407
2693
|
async function main() {
|
|
2408
2694
|
try {
|
|
2409
2695
|
introScreen();
|
|
2410
|
-
|
|
2411
|
-
|
|
2696
|
+
prompts.intro(
|
|
2697
|
+
import_picocolors16.default.inverse(import_picocolors16.default.bold(import_picocolors16.default.cyan(" Welcome to the Project Setup Wizard ")))
|
|
2412
2698
|
);
|
|
2413
2699
|
await gitCheck();
|
|
2414
2700
|
const tools = await withCancelHandling(
|
|
2415
|
-
async () =>
|
|
2701
|
+
async () => prompts.multiselect({
|
|
2416
2702
|
message: "Select tools to configure:",
|
|
2417
2703
|
options: TOOL_OPTIONS,
|
|
2418
2704
|
required: false
|
|
@@ -2427,23 +2713,25 @@ async function main() {
|
|
|
2427
2713
|
if (config.get("test").selected) await promptTest(config);
|
|
2428
2714
|
if (config.get("editorConfig").selected) await promptEditorConfig(config);
|
|
2429
2715
|
if (config.get("license").selected) await promptLicense(config);
|
|
2430
|
-
|
|
2716
|
+
prompts.note(config.summary, "Configuration Summary");
|
|
2431
2717
|
const proceed = await withCancelHandling(
|
|
2432
|
-
async () =>
|
|
2718
|
+
async () => prompts.confirm({
|
|
2433
2719
|
message: "Do you want to proceed with the installation?"
|
|
2434
2720
|
})
|
|
2435
2721
|
);
|
|
2436
2722
|
if (!proceed) {
|
|
2437
|
-
|
|
2723
|
+
prompts.outro(import_picocolors16.default.yellow("Installation cancelled."));
|
|
2438
2724
|
process.exit(0);
|
|
2439
2725
|
}
|
|
2440
2726
|
await execution(config);
|
|
2441
|
-
|
|
2727
|
+
prompts.outro(import_picocolors16.default.green("Setup complete!"));
|
|
2442
2728
|
} catch (error) {
|
|
2443
2729
|
const logPath = await logError(error);
|
|
2444
|
-
|
|
2730
|
+
prompts.outro(
|
|
2731
|
+
import_picocolors16.default.red(`
|
|
2445
2732
|
Something went wrong!
|
|
2446
|
-
Error log saved to: ${logPath}`)
|
|
2733
|
+
Error log saved to: ${logPath}`)
|
|
2734
|
+
);
|
|
2447
2735
|
process.exit(1);
|
|
2448
2736
|
}
|
|
2449
2737
|
}
|