@kenjura/ursa 0.40.0 → 0.41.0
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 +5 -0
- package/package.json +1 -1
- package/src/jobs/generate.js +29 -12
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/jobs/generate.js
CHANGED
|
@@ -567,25 +567,42 @@ async function getFooter(source, _source) {
|
|
|
567
567
|
console.error(`Error reading footer.md: ${e.message}`);
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
// Try to read package.json from doc repo
|
|
570
|
+
// Try to read package.json from doc repo (check both source dir and parent)
|
|
571
571
|
let docPackage = null;
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
572
|
+
const sourceDir = resolve(_source);
|
|
573
|
+
const packagePaths = [
|
|
574
|
+
join(sourceDir, 'package.json'), // In source dir itself
|
|
575
|
+
join(sourceDir, '..', 'package.json'), // One level up (if docs is a subfolder)
|
|
576
|
+
];
|
|
577
|
+
|
|
578
|
+
for (const packagePath of packagePaths) {
|
|
579
|
+
try {
|
|
580
|
+
if (existsSync(packagePath)) {
|
|
581
|
+
const packageJson = await readFile(packagePath, 'utf8');
|
|
582
|
+
docPackage = JSON.parse(packageJson);
|
|
583
|
+
console.log(`Found doc package.json at ${packagePath}`);
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
} catch (e) {
|
|
587
|
+
// Continue to next path
|
|
577
588
|
}
|
|
578
|
-
} catch (e) {
|
|
579
|
-
console.error(`Error reading doc package.json: ${e.message}`);
|
|
580
589
|
}
|
|
581
590
|
|
|
582
591
|
// Get ursa version from ursa's own package.json
|
|
592
|
+
// Use import.meta.url to find the package.json relative to this file
|
|
583
593
|
let ursaVersion = 'unknown';
|
|
584
594
|
try {
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
const
|
|
588
|
-
|
|
595
|
+
// From src/jobs/generate.js, go up to package root
|
|
596
|
+
const currentFileUrl = new URL(import.meta.url);
|
|
597
|
+
const currentDir = dirname(currentFileUrl.pathname);
|
|
598
|
+
const ursaPackagePath = resolve(currentDir, '..', '..', 'package.json');
|
|
599
|
+
|
|
600
|
+
if (existsSync(ursaPackagePath)) {
|
|
601
|
+
const ursaPackageJson = await readFile(ursaPackagePath, 'utf8');
|
|
602
|
+
const ursaPackage = JSON.parse(ursaPackageJson);
|
|
603
|
+
ursaVersion = ursaPackage.version;
|
|
604
|
+
console.log(`Found ursa package.json at ${ursaPackagePath}, version: ${ursaVersion}`);
|
|
605
|
+
}
|
|
589
606
|
} catch (e) {
|
|
590
607
|
console.error(`Error reading ursa package.json: ${e.message}`);
|
|
591
608
|
}
|