@treeseed/core 0.4.1 → 0.4.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.
|
@@ -4,7 +4,6 @@ import { dirname, resolve } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
|
-
import { packageRoot } from './package-tools.js';
|
|
8
7
|
const require = createRequire(import.meta.url);
|
|
9
8
|
const requiredPackages = [
|
|
10
9
|
{ name: '@treeseed/sdk', dir: 'packages/sdk', build: true },
|
|
@@ -64,8 +63,31 @@ function run(command, args, options = {}) {
|
|
|
64
63
|
throw new Error(`Command failed: ${rendered}`);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
66
|
+
function findPackageRoot(startPath) {
|
|
67
|
+
let current = dirname(startPath);
|
|
68
|
+
while (true) {
|
|
69
|
+
const packageJsonPath = resolve(current, 'package.json');
|
|
70
|
+
if (existsSync(packageJsonPath)) {
|
|
71
|
+
return { root: current, packageJsonPath };
|
|
72
|
+
}
|
|
73
|
+
const parent = dirname(current);
|
|
74
|
+
if (parent === current) {
|
|
75
|
+
throw new Error(`Unable to resolve package root from "${startPath}".`);
|
|
76
|
+
}
|
|
77
|
+
current = parent;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function installedPackageRoot(root, packageName) {
|
|
81
|
+
const segments = packageName.startsWith('@') ? packageName.split('/') : [packageName];
|
|
82
|
+
const packageRoot = resolve(root, 'node_modules', ...segments);
|
|
83
|
+
const packageJsonPath = resolve(packageRoot, 'package.json');
|
|
84
|
+
if (!existsSync(packageJsonPath)) {
|
|
85
|
+
throw new Error(`Unable to resolve installed package "${packageName}" from "${root}".`);
|
|
86
|
+
}
|
|
87
|
+
return { root: packageRoot, packageJsonPath };
|
|
88
|
+
}
|
|
67
89
|
function resolvePackageBinary(packageName, binName = packageName, root = process.cwd()) {
|
|
68
|
-
const packageJsonPath =
|
|
90
|
+
const { packageJsonPath } = installedPackageRoot(root, packageName);
|
|
69
91
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
70
92
|
const binField = packageJson.bin;
|
|
71
93
|
const relativePath = typeof binField === 'string' ? binField : binField?.[binName];
|
|
@@ -75,13 +97,6 @@ function resolvePackageBinary(packageName, binName = packageName, root = process
|
|
|
75
97
|
return resolve(dirname(packageJsonPath), relativePath);
|
|
76
98
|
}
|
|
77
99
|
function runStarlightPatchFromRegistry(root) {
|
|
78
|
-
const corePackageJsonPath = require.resolve('@treeseed/core/package.json', { paths: [root, packageRoot] });
|
|
79
|
-
const coreRoot = dirname(corePackageJsonPath);
|
|
80
|
-
const patchScriptPath = resolve(coreRoot, 'dist', 'scripts', 'patch-starlight-content-path.js');
|
|
81
|
-
if (existsSync(patchScriptPath)) {
|
|
82
|
-
run(process.execPath, [patchScriptPath], { cwd: root });
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
100
|
const treeseedBin = resolvePackageBinary('@treeseed/cli', 'treeseed', root);
|
|
86
101
|
run(process.execPath, [treeseedBin, 'starlight:patch'], { cwd: root });
|
|
87
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Treeseed Research Hub package for Astro, Starlight, knowledge-factory content, and forms.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@treeseed/sdk": "^0.4.
|
|
61
|
+
"@treeseed/sdk": "^0.4.2",
|
|
62
62
|
"@astrojs/check": "^0.9.8",
|
|
63
63
|
"@astrojs/cloudflare": "^12.6.13",
|
|
64
64
|
"@astrojs/sitemap": "3.7.0",
|