@portosaur/cli 0.5.1 → 0.6.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/package.json +4 -4
- package/src/utils/runner.mjs +29 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portosaur/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "CLI for Portosaur - The static Personal portfolio site generator.",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": "soymadip",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"types": "./src/index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@portosaur/core": "^0.
|
|
30
|
-
"@portosaur/logger": "^0.
|
|
31
|
-
"@portosaur/wizard": "^0.
|
|
29
|
+
"@portosaur/core": "^0.6.3",
|
|
30
|
+
"@portosaur/logger": "^0.6.3",
|
|
31
|
+
"@portosaur/wizard": "^0.6.3",
|
|
32
32
|
"commander": "^13.1.0",
|
|
33
33
|
"js-yaml": "^4.1.1"
|
|
34
34
|
}
|
package/src/utils/runner.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
|
+
import { hasCommand } from "@portosaur/core";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Generates a static Docusaurus config file by evaluating the Portosaur config
|
|
@@ -134,6 +135,7 @@ export function warnIfRepoNameMismatch(
|
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
137
|
* Executes a Docusaurus command.
|
|
138
|
+
*
|
|
137
139
|
* @param {string} command - Docusaurus command to run (e.g., 'start', 'build').
|
|
138
140
|
* @param {string} UserRoot - The project directory.
|
|
139
141
|
* @param {string} configPath - Path to the docusaurus.config.js shim.
|
|
@@ -146,57 +148,50 @@ export async function runDocusaurus(
|
|
|
146
148
|
configPath,
|
|
147
149
|
extraArgs = [],
|
|
148
150
|
) {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
docusaurusBin = require.resolve("docusaurus/bin/docusaurus.mjs", {
|
|
166
|
-
paths: [UserRoot],
|
|
167
|
-
});
|
|
168
|
-
} catch (e) {
|
|
169
|
-
docusaurusBin = path.join(
|
|
170
|
-
UserRoot,
|
|
171
|
-
"node_modules",
|
|
172
|
-
"docusaurus",
|
|
173
|
-
"bin",
|
|
174
|
-
"docusaurus.mjs",
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
args = [docusaurusBin, command, UserRoot];
|
|
151
|
+
const require = createRequire(import.meta.url);
|
|
152
|
+
let docusaurusBin;
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
docusaurusBin = require.resolve("@docusaurus/core/bin/docusaurus.mjs", {
|
|
156
|
+
paths: [UserRoot],
|
|
157
|
+
});
|
|
158
|
+
} catch {
|
|
159
|
+
docusaurusBin = path.join(
|
|
160
|
+
UserRoot,
|
|
161
|
+
"node_modules",
|
|
162
|
+
"@docusaurus",
|
|
163
|
+
"core",
|
|
164
|
+
"bin",
|
|
165
|
+
"docusaurus.mjs",
|
|
166
|
+
);
|
|
178
167
|
}
|
|
179
168
|
|
|
169
|
+
const args = [docusaurusBin, command, UserRoot];
|
|
170
|
+
|
|
180
171
|
if (configPath) {
|
|
181
172
|
args.push("--config", configPath);
|
|
182
173
|
}
|
|
183
174
|
|
|
184
175
|
args.push(...extraArgs);
|
|
185
176
|
|
|
177
|
+
// Use bun when available for faster builds, fall back to node.
|
|
178
|
+
// If node isn't installed, fallback to bun gracefully.
|
|
179
|
+
let runtime = "node";
|
|
180
|
+
if (typeof Bun !== "undefined" || !hasCommand("node")) {
|
|
181
|
+
runtime = "bun";
|
|
182
|
+
}
|
|
183
|
+
|
|
186
184
|
// Skip actual execution in test mode
|
|
187
185
|
if (process.env.PORTO_TEST_MODE === "true") {
|
|
188
186
|
console.log(
|
|
189
|
-
`[TEST_MODE] Would run docusaurus ${command} in ${UserRoot} using ${
|
|
187
|
+
`[TEST_MODE] Would run docusaurus ${command} in ${UserRoot} using ${runtime}`,
|
|
190
188
|
);
|
|
191
189
|
return Promise.resolve();
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
const childEnv = { ...process.env, FORCE_COLOR: "true" };
|
|
195
|
-
if (command === "build") {
|
|
196
|
-
childEnv.CI = "true";
|
|
197
|
-
}
|
|
198
193
|
|
|
199
|
-
const child = spawn(
|
|
194
|
+
const child = spawn(runtime, args, {
|
|
200
195
|
stdio: "inherit",
|
|
201
196
|
cwd: UserRoot,
|
|
202
197
|
env: childEnv,
|