portosaurus 2.0.0 → 2.0.2
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/portosaurus.mjs +12 -1
- package/package.json +1 -1
- package/src/core/createDocuConf.mjs +45 -11
- package/src/core/packageManager.mjs +12 -0
package/bin/portosaurus.mjs
CHANGED
|
@@ -89,7 +89,7 @@ function ensureContentDirs(projectRoot) {
|
|
|
89
89
|
if (!fs.existsSync(notesIndex)) {
|
|
90
90
|
fs.writeFileSync(
|
|
91
91
|
notesIndex,
|
|
92
|
-
`---\nhide_table_of_contents: true\n---\n\nimport NoteCards from "
|
|
92
|
+
`---\nhide_table_of_contents: true\n---\n\nimport NoteCards from "portosaurus/src/components/NoteIndex/index.js";\n\n# Notes\n\n<NoteCards />\n`,
|
|
93
93
|
);
|
|
94
94
|
logger.debug("Created default notes/index.mdx");
|
|
95
95
|
}
|
|
@@ -191,6 +191,12 @@ program
|
|
|
191
191
|
dependencies: {
|
|
192
192
|
portosaurus: `^${packageJson.version}`,
|
|
193
193
|
},
|
|
194
|
+
overrides: {
|
|
195
|
+
webpack: "5.105.4",
|
|
196
|
+
},
|
|
197
|
+
resolutions: {
|
|
198
|
+
webpack: "5.105.4",
|
|
199
|
+
},
|
|
194
200
|
};
|
|
195
201
|
fs.writeFileSync(
|
|
196
202
|
path.join(projectPath, "package.json"),
|
|
@@ -206,6 +212,11 @@ program
|
|
|
206
212
|
// Git init
|
|
207
213
|
try {
|
|
208
214
|
execSync("git init", { cwd: projectPath, stdio: "ignore" });
|
|
215
|
+
execSync("git add .", { cwd: projectPath, stdio: "ignore" });
|
|
216
|
+
execSync('git commit -m "Initialize Portosaurus project"', {
|
|
217
|
+
cwd: projectPath,
|
|
218
|
+
stdio: "ignore",
|
|
219
|
+
});
|
|
209
220
|
} catch {
|
|
210
221
|
logger.warn("Failed to initialize git repository.");
|
|
211
222
|
}
|
package/package.json
CHANGED
|
@@ -115,7 +115,12 @@ function getVersion() {
|
|
|
115
115
|
function useEnabled(items) {
|
|
116
116
|
if (!Array.isArray(items)) return [];
|
|
117
117
|
return items.flatMap((item) => {
|
|
118
|
-
if (
|
|
118
|
+
if (
|
|
119
|
+
item &&
|
|
120
|
+
typeof item === "object" &&
|
|
121
|
+
"enable" in item &&
|
|
122
|
+
"value" in item
|
|
123
|
+
) {
|
|
119
124
|
return item.enable === true ? [item.value] : [];
|
|
120
125
|
}
|
|
121
126
|
return [item];
|
|
@@ -169,7 +174,9 @@ export function createDocuConf(rawUserConfig, projectRoot) {
|
|
|
169
174
|
// Meta tags
|
|
170
175
|
let metaTags = [];
|
|
171
176
|
try {
|
|
172
|
-
const meta = require(
|
|
177
|
+
const meta = require(
|
|
178
|
+
path.resolve(portosaurusRoot, "src/config/metaTags.js"),
|
|
179
|
+
);
|
|
173
180
|
metaTags = meta.metaTags || [];
|
|
174
181
|
} catch {
|
|
175
182
|
// OK — no meta tags
|
|
@@ -183,7 +190,7 @@ export function createDocuConf(rawUserConfig, projectRoot) {
|
|
|
183
190
|
const userStaticDir = path.resolve(projectRoot, "static");
|
|
184
191
|
const internalImgDir = path.resolve(portosaurusRoot, "src/assets");
|
|
185
192
|
const staticDirectories = [userStaticDir, internalImgDir].filter((d) =>
|
|
186
|
-
fs.existsSync(d)
|
|
193
|
+
fs.existsSync(d),
|
|
187
194
|
);
|
|
188
195
|
|
|
189
196
|
// Pages — served from the portosaurus package
|
|
@@ -242,7 +249,8 @@ export function createDocuConf(rawUserConfig, projectRoot) {
|
|
|
242
249
|
usrConf.about_me?.image ||
|
|
243
250
|
usrConf.hero_section?.profile_pic ||
|
|
244
251
|
"img/icon.png",
|
|
245
|
-
description:
|
|
252
|
+
description:
|
|
253
|
+
usrConf.about_me?.description || defaults.about_me.description,
|
|
246
254
|
skills: usrConf.about_me?.skills || defaults.about_me.skills,
|
|
247
255
|
resumeLink: usrConf.about_me?.resume_link || "",
|
|
248
256
|
},
|
|
@@ -285,7 +293,14 @@ export function createDocuConf(rawUserConfig, projectRoot) {
|
|
|
285
293
|
path: notesPath,
|
|
286
294
|
sidebarPath,
|
|
287
295
|
admonitions: {
|
|
288
|
-
keywords: [
|
|
296
|
+
keywords: [
|
|
297
|
+
"note",
|
|
298
|
+
"tip",
|
|
299
|
+
"info",
|
|
300
|
+
"warning",
|
|
301
|
+
"danger",
|
|
302
|
+
"question",
|
|
303
|
+
],
|
|
289
304
|
extendDefaults: true,
|
|
290
305
|
},
|
|
291
306
|
},
|
|
@@ -309,16 +324,14 @@ export function createDocuConf(rawUserConfig, projectRoot) {
|
|
|
309
324
|
],
|
|
310
325
|
],
|
|
311
326
|
|
|
312
|
-
// Register portosaurus's src/
|
|
313
|
-
// so Root.js,
|
|
314
|
-
/*
|
|
327
|
+
// Register portosaurus's src/ as a theme directory
|
|
328
|
+
// so Root.js, components, and pages are all natively transpiled by Docusaurus.
|
|
315
329
|
themes: [
|
|
316
330
|
[
|
|
317
331
|
path.resolve(portosaurusRoot, "src/core/themePlugin.mjs"),
|
|
318
|
-
{ themeDir:
|
|
332
|
+
{ themeDir: path.resolve(portosaurusRoot, "src") },
|
|
319
333
|
],
|
|
320
334
|
],
|
|
321
|
-
*/
|
|
322
335
|
|
|
323
336
|
markdown: {
|
|
324
337
|
mermaid: true,
|
|
@@ -430,8 +443,29 @@ export function createDocuConf(rawUserConfig, projectRoot) {
|
|
|
430
443
|
},
|
|
431
444
|
|
|
432
445
|
plugins: [
|
|
446
|
+
function portosaurusWebpackTranspiler() {
|
|
447
|
+
return {
|
|
448
|
+
name: "portosaurus-transpile",
|
|
449
|
+
configureWebpack(config) {
|
|
450
|
+
if (config.module && config.module.rules) {
|
|
451
|
+
console.log(
|
|
452
|
+
JSON.stringify(
|
|
453
|
+
config.module.rules,
|
|
454
|
+
(k, v) => (typeof v === "function" ? v.toString() : v),
|
|
455
|
+
2,
|
|
456
|
+
),
|
|
457
|
+
);
|
|
458
|
+
process.exit(1);
|
|
459
|
+
}
|
|
460
|
+
return config;
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
},
|
|
433
464
|
path.resolve(portosaurusRoot, "src/core/build-utils/generateFavicon.mjs"),
|
|
434
|
-
path.resolve(
|
|
465
|
+
path.resolve(
|
|
466
|
+
portosaurusRoot,
|
|
467
|
+
"src/core/build-utils/generateRobotsTxt.mjs",
|
|
468
|
+
),
|
|
435
469
|
[
|
|
436
470
|
require.resolve("@easyops-cn/docusaurus-search-local"),
|
|
437
471
|
{
|
|
@@ -18,6 +18,18 @@ export function detectPackageManager(projectRoot) {
|
|
|
18
18
|
if (fs.existsSync(path.join(projectRoot, "yarn.lock"))) return "yarn";
|
|
19
19
|
if (fs.existsSync(path.join(projectRoot, "package-lock.json"))) return "npm";
|
|
20
20
|
|
|
21
|
+
if (process.env.npm_config_user_agent) {
|
|
22
|
+
if (process.env.npm_config_user_agent.includes("bun")) return "bun";
|
|
23
|
+
if (process.env.npm_config_user_agent.includes("pnpm")) return "pnpm";
|
|
24
|
+
if (process.env.npm_config_user_agent.includes("yarn")) return "yarn";
|
|
25
|
+
}
|
|
26
|
+
if (
|
|
27
|
+
typeof process !== "undefined" &&
|
|
28
|
+
process.versions &&
|
|
29
|
+
process.versions.bun
|
|
30
|
+
)
|
|
31
|
+
return "bun";
|
|
32
|
+
|
|
21
33
|
return "npm";
|
|
22
34
|
}
|
|
23
35
|
|