@farming-labs/docs 0.0.25 → 0.0.27
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/dist/cli/index.mjs +41 -6
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -20,11 +20,12 @@ function detectFramework(cwd) {
|
|
|
20
20
|
if (allDeps["nuxt"]) return "nuxt";
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function detectPackageManagerFromLockfile(cwd) {
|
|
24
24
|
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
25
25
|
if (fs.existsSync(path.join(cwd, "bun.lockb")) || fs.existsSync(path.join(cwd, "bun.lock"))) return "bun";
|
|
26
26
|
if (fs.existsSync(path.join(cwd, "yarn.lock"))) return "yarn";
|
|
27
|
-
return "npm";
|
|
27
|
+
if (fs.existsSync(path.join(cwd, "package-lock.json"))) return "npm";
|
|
28
|
+
return null;
|
|
28
29
|
}
|
|
29
30
|
function installCommand(pm) {
|
|
30
31
|
return pm === "yarn" ? "yarn add" : `${pm} add`;
|
|
@@ -2094,10 +2095,10 @@ async function init(options = {}) {
|
|
|
2094
2095
|
s.stop("Files scaffolded");
|
|
2095
2096
|
if (written.length > 0) p.log.success(`Created ${written.length} file${written.length > 1 ? "s" : ""}:\n` + written.map((f) => ` ${pc.green("+")} ${f}`).join("\n"));
|
|
2096
2097
|
if (skipped.length > 0) p.log.info(`Skipped ${skipped.length} existing file${skipped.length > 1 ? "s" : ""}:\n` + skipped.map((f) => ` ${pc.dim("-")} ${f}`).join("\n"));
|
|
2097
|
-
let pm =
|
|
2098
|
-
p.log.info(`Detected ${pc.cyan(pm)}
|
|
2098
|
+
let pm = detectPackageManagerFromLockfile(cwd);
|
|
2099
|
+
if (pm) p.log.info(`Detected ${pc.cyan(pm)} from lockfile`);
|
|
2099
2100
|
const pmAnswerExisting = await p.select({
|
|
2100
|
-
initialValue: pm,
|
|
2101
|
+
...pm ? { initialValue: pm } : {},
|
|
2101
2102
|
message: "Which package manager do you want to use in this project?",
|
|
2102
2103
|
options: [
|
|
2103
2104
|
{
|
|
@@ -2445,7 +2446,41 @@ async function upgrade(options = {}) {
|
|
|
2445
2446
|
}
|
|
2446
2447
|
preset = presetFromFramework(framework);
|
|
2447
2448
|
}
|
|
2448
|
-
|
|
2449
|
+
let pm = detectPackageManagerFromLockfile(cwd);
|
|
2450
|
+
if (pm) p.log.info(`Detected ${pc.cyan(pm)} from lockfile`);
|
|
2451
|
+
else {
|
|
2452
|
+
const pmAnswer = await p.select({
|
|
2453
|
+
message: "Which package manager do you want to use for this upgrade?",
|
|
2454
|
+
options: [
|
|
2455
|
+
{
|
|
2456
|
+
value: "pnpm",
|
|
2457
|
+
label: "pnpm",
|
|
2458
|
+
hint: "Use pnpm add"
|
|
2459
|
+
},
|
|
2460
|
+
{
|
|
2461
|
+
value: "npm",
|
|
2462
|
+
label: "npm",
|
|
2463
|
+
hint: "Use npm add"
|
|
2464
|
+
},
|
|
2465
|
+
{
|
|
2466
|
+
value: "yarn",
|
|
2467
|
+
label: "yarn",
|
|
2468
|
+
hint: "Use yarn add"
|
|
2469
|
+
},
|
|
2470
|
+
{
|
|
2471
|
+
value: "bun",
|
|
2472
|
+
label: "bun",
|
|
2473
|
+
hint: "Use bun add"
|
|
2474
|
+
}
|
|
2475
|
+
]
|
|
2476
|
+
});
|
|
2477
|
+
if (p.isCancel(pmAnswer)) {
|
|
2478
|
+
p.outro(pc.red("Upgrade cancelled."));
|
|
2479
|
+
process.exit(0);
|
|
2480
|
+
}
|
|
2481
|
+
pm = pmAnswer;
|
|
2482
|
+
p.log.info(`Using ${pc.cyan(pm)} as package manager`);
|
|
2483
|
+
}
|
|
2449
2484
|
const cmd = buildUpgradeCommand(framework, tag, pm);
|
|
2450
2485
|
const packages = getPackagesForFramework(framework);
|
|
2451
2486
|
p.log.step(`Upgrading ${preset} docs packages to ${tag}...`);
|