@treeseed/cli 0.1.1 → 0.4.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/README.md +27 -26
- package/dist/cli/handlers/auth-login.d.ts +2 -0
- package/dist/cli/handlers/auth-login.js +67 -0
- package/dist/cli/handlers/auth-logout.d.ts +2 -0
- package/dist/cli/handlers/auth-logout.js +20 -0
- package/dist/cli/handlers/auth-whoami.d.ts +2 -0
- package/dist/cli/handlers/auth-whoami.js +24 -0
- package/dist/cli/handlers/close.js +19 -53
- package/dist/cli/handlers/config.js +33 -53
- package/dist/cli/handlers/destroy.js +34 -79
- package/dist/{src/cli/handlers/ship.d.ts → cli/handlers/dev.d.ts} +1 -1
- package/dist/cli/handlers/dev.js +19 -0
- package/dist/cli/handlers/doctor.js +13 -6
- package/dist/cli/handlers/init.js +32 -8
- package/dist/cli/handlers/release.js +21 -53
- package/dist/cli/handlers/rollback.js +8 -8
- package/dist/cli/handlers/save.js +21 -79
- package/dist/cli/handlers/stage.d.ts +2 -0
- package/dist/cli/handlers/stage.js +28 -0
- package/dist/cli/handlers/status.js +35 -26
- package/dist/{src/cli/handlers/deploy.d.ts → cli/handlers/switch.d.ts} +1 -1
- package/dist/cli/handlers/switch.js +29 -0
- package/dist/{src/cli/handlers/next.d.ts → cli/handlers/sync.d.ts} +1 -1
- package/dist/cli/handlers/sync.js +26 -0
- package/dist/cli/handlers/tasks.d.ts +2 -0
- package/dist/cli/handlers/tasks.js +31 -0
- package/dist/cli/handlers/template.d.ts +2 -0
- package/dist/cli/handlers/template.js +27 -0
- package/dist/cli/handlers/workflow.d.ts +6 -0
- package/dist/cli/handlers/workflow.js +71 -0
- package/dist/{src/cli → cli}/help.d.ts +2 -2
- package/dist/cli/help.js +36 -24
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +14 -19
- package/dist/cli/operations-help.d.ts +1 -0
- package/dist/cli/operations-help.js +1 -0
- package/dist/cli/operations-parser.d.ts +1 -0
- package/dist/cli/operations-parser.js +1 -0
- package/dist/cli/operations-registry.d.ts +5 -0
- package/dist/cli/operations-registry.js +260 -0
- package/dist/cli/operations-types.d.ts +72 -0
- package/dist/cli/parser.d.ts +3 -0
- package/dist/cli/parser.js +1 -6
- package/dist/cli/registry.d.ts +25 -0
- package/dist/cli/registry.js +28 -416
- package/dist/cli/repair.js +6 -4
- package/dist/cli/runtime.d.ts +31 -0
- package/dist/cli/runtime.js +240 -111
- package/dist/cli/types.d.ts +1 -0
- package/dist/{src/cli → cli}/workflow-state.d.ts +9 -0
- package/dist/cli/workflow-state.js +45 -21
- package/package.json +13 -13
- package/dist/cli/handlers/continue.js +0 -23
- package/dist/cli/handlers/deploy.js +0 -139
- package/dist/cli/handlers/next.js +0 -27
- package/dist/cli/handlers/prepare.js +0 -8
- package/dist/cli/handlers/promote.js +0 -8
- package/dist/cli/handlers/publish.js +0 -8
- package/dist/cli/handlers/setup.js +0 -48
- package/dist/cli/handlers/ship.js +0 -49
- package/dist/cli/handlers/start.js +0 -97
- package/dist/cli/handlers/teardown.js +0 -50
- package/dist/cli/handlers/work.js +0 -85
- package/dist/scripts/aggregate-book.d.ts +0 -1
- package/dist/scripts/aggregate-book.js +0 -121
- package/dist/scripts/assert-release-tag-version.d.ts +0 -1
- package/dist/scripts/assert-release-tag-version.js +0 -21
- package/dist/scripts/build-dist.d.ts +0 -1
- package/dist/scripts/build-dist.js +0 -108
- package/dist/scripts/build-tenant-worker.d.ts +0 -1
- package/dist/scripts/build-tenant-worker.js +0 -36
- package/dist/scripts/cleanup-markdown.d.ts +0 -2
- package/dist/scripts/cleanup-markdown.js +0 -373
- package/dist/scripts/config-runtime-lib.d.ts +0 -122
- package/dist/scripts/config-runtime-lib.js +0 -505
- package/dist/scripts/config-treeseed.d.ts +0 -2
- package/dist/scripts/config-treeseed.js +0 -81
- package/dist/scripts/d1-migration-lib.d.ts +0 -6
- package/dist/scripts/d1-migration-lib.js +0 -90
- package/dist/scripts/deploy-lib.d.ts +0 -127
- package/dist/scripts/deploy-lib.js +0 -841
- package/dist/scripts/ensure-mailpit.d.ts +0 -1
- package/dist/scripts/ensure-mailpit.js +0 -29
- package/dist/scripts/git-workflow-lib.d.ts +0 -25
- package/dist/scripts/git-workflow-lib.js +0 -136
- package/dist/scripts/github-automation-lib.d.ts +0 -156
- package/dist/scripts/github-automation-lib.js +0 -242
- package/dist/scripts/local-dev-lib.d.ts +0 -9
- package/dist/scripts/local-dev-lib.js +0 -84
- package/dist/scripts/local-dev.d.ts +0 -1
- package/dist/scripts/local-dev.js +0 -129
- package/dist/scripts/logs-mailpit.d.ts +0 -1
- package/dist/scripts/logs-mailpit.js +0 -2
- package/dist/scripts/mailpit-runtime.d.ts +0 -4
- package/dist/scripts/mailpit-runtime.js +0 -57
- package/dist/scripts/package-tools.d.ts +0 -22
- package/dist/scripts/package-tools.js +0 -255
- package/dist/scripts/patch-starlight-content-path.d.ts +0 -1
- package/dist/scripts/patch-starlight-content-path.js +0 -172
- package/dist/scripts/paths.d.ts +0 -17
- package/dist/scripts/paths.js +0 -26
- package/dist/scripts/publish-package.d.ts +0 -1
- package/dist/scripts/publish-package.js +0 -19
- package/dist/scripts/release-verify.d.ts +0 -1
- package/dist/scripts/release-verify.js +0 -136
- package/dist/scripts/run-fixture-astro-command.d.ts +0 -1
- package/dist/scripts/run-fixture-astro-command.js +0 -18
- package/dist/scripts/save-deploy-preflight-lib.d.ts +0 -34
- package/dist/scripts/save-deploy-preflight-lib.js +0 -69
- package/dist/scripts/scaffold-site.d.ts +0 -2
- package/dist/scripts/scaffold-site.js +0 -92
- package/dist/scripts/stop-mailpit.d.ts +0 -1
- package/dist/scripts/stop-mailpit.js +0 -5
- package/dist/scripts/sync-dev-vars.d.ts +0 -1
- package/dist/scripts/sync-dev-vars.js +0 -6
- package/dist/scripts/template-registry-lib.d.ts +0 -47
- package/dist/scripts/template-registry-lib.js +0 -137
- package/dist/scripts/tenant-astro-command.d.ts +0 -1
- package/dist/scripts/tenant-astro-command.js +0 -3
- package/dist/scripts/tenant-build.d.ts +0 -1
- package/dist/scripts/tenant-build.js +0 -16
- package/dist/scripts/tenant-check.d.ts +0 -1
- package/dist/scripts/tenant-check.js +0 -7
- package/dist/scripts/tenant-d1-migrate-local.d.ts +0 -1
- package/dist/scripts/tenant-d1-migrate-local.js +0 -11
- package/dist/scripts/tenant-deploy.d.ts +0 -2
- package/dist/scripts/tenant-deploy.js +0 -180
- package/dist/scripts/tenant-destroy.d.ts +0 -2
- package/dist/scripts/tenant-destroy.js +0 -104
- package/dist/scripts/tenant-dev.d.ts +0 -1
- package/dist/scripts/tenant-dev.js +0 -171
- package/dist/scripts/tenant-lint.d.ts +0 -1
- package/dist/scripts/tenant-lint.js +0 -4
- package/dist/scripts/tenant-test.d.ts +0 -1
- package/dist/scripts/tenant-test.js +0 -4
- package/dist/scripts/test-cloudflare-local.d.ts +0 -1
- package/dist/scripts/test-cloudflare-local.js +0 -212
- package/dist/scripts/test-scaffold.d.ts +0 -2
- package/dist/scripts/test-scaffold.js +0 -297
- package/dist/scripts/treeseed.d.ts +0 -2
- package/dist/scripts/treeseed.js +0 -4
- package/dist/scripts/validate-templates.d.ts +0 -2
- package/dist/scripts/validate-templates.js +0 -4
- package/dist/scripts/watch-dev-lib.d.ts +0 -21
- package/dist/scripts/watch-dev-lib.js +0 -277
- package/dist/scripts/workspace-close.d.ts +0 -2
- package/dist/scripts/workspace-close.js +0 -24
- package/dist/scripts/workspace-command-e2e.d.ts +0 -2
- package/dist/scripts/workspace-command-e2e.js +0 -718
- package/dist/scripts/workspace-lint.d.ts +0 -1
- package/dist/scripts/workspace-lint.js +0 -9
- package/dist/scripts/workspace-preflight-lib.d.ts +0 -36
- package/dist/scripts/workspace-preflight-lib.js +0 -179
- package/dist/scripts/workspace-preflight.d.ts +0 -2
- package/dist/scripts/workspace-preflight.js +0 -22
- package/dist/scripts/workspace-publish-changed-packages.d.ts +0 -1
- package/dist/scripts/workspace-publish-changed-packages.js +0 -16
- package/dist/scripts/workspace-release-verify.d.ts +0 -1
- package/dist/scripts/workspace-release-verify.js +0 -81
- package/dist/scripts/workspace-release.d.ts +0 -2
- package/dist/scripts/workspace-release.js +0 -42
- package/dist/scripts/workspace-save-lib.d.ts +0 -42
- package/dist/scripts/workspace-save-lib.js +0 -220
- package/dist/scripts/workspace-save.d.ts +0 -2
- package/dist/scripts/workspace-save.js +0 -124
- package/dist/scripts/workspace-start-warning.js +0 -3
- package/dist/scripts/workspace-start.d.ts +0 -2
- package/dist/scripts/workspace-start.js +0 -71
- package/dist/scripts/workspace-test-unit.d.ts +0 -1
- package/dist/scripts/workspace-test-unit.js +0 -4
- package/dist/scripts/workspace-test.d.ts +0 -1
- package/dist/scripts/workspace-test.js +0 -11
- package/dist/scripts/workspace-tools.d.ts +0 -13
- package/dist/scripts/workspace-tools.js +0 -226
- package/dist/src/cli/handlers/continue.d.ts +0 -2
- package/dist/src/cli/handlers/prepare.d.ts +0 -2
- package/dist/src/cli/handlers/promote.d.ts +0 -2
- package/dist/src/cli/handlers/publish.d.ts +0 -2
- package/dist/src/cli/handlers/setup.d.ts +0 -2
- package/dist/src/cli/handlers/start.d.ts +0 -3
- package/dist/src/cli/handlers/teardown.d.ts +0 -2
- package/dist/src/cli/handlers/work.d.ts +0 -2
- package/dist/src/cli/main.d.ts +0 -6
- package/dist/src/cli/parser.d.ts +0 -3
- package/dist/src/cli/registry.d.ts +0 -27
- package/dist/src/cli/runtime.d.ts +0 -4
- package/dist/src/cli/types.d.ts +0 -71
- /package/dist/{src/cli → cli}/handlers/close.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/config.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/destroy.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/doctor.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/init.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/release.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/rollback.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/save.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/status.d.ts +0 -0
- /package/dist/{src/cli → cli}/handlers/utils.d.ts +0 -0
- /package/dist/{scripts/workspace-start-warning.d.ts → cli/operations-types.js} +0 -0
- /package/dist/{src/cli → cli}/repair.d.ts +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { corePackageRoot } from './package-tools.js';
|
|
3
|
-
import { fixtureRoot } from './paths.js';
|
|
4
|
-
import { prepareCloudflareLocalRuntime, startWranglerDev } from './local-dev-lib.js';
|
|
5
|
-
import { clearStagedBuildOutput, createWatchBuildPaths, createTenantWatchEntries, startPollingWatch, stopManagedProcess, swapStagedBuildOutput, writeDevReloadStamp, workspaceSdkRoot, } from './watch-dev-lib.js';
|
|
6
|
-
const cliArgs = process.argv.slice(2);
|
|
7
|
-
const watchMode = cliArgs.includes('--watch');
|
|
8
|
-
const wranglerArgs = cliArgs.filter((arg) => arg !== '--watch');
|
|
9
|
-
let wranglerChild = null;
|
|
10
|
-
let stopWatching = null;
|
|
11
|
-
let isStoppingForRebuild = false;
|
|
12
|
-
let shuttingDown = false;
|
|
13
|
-
function runStep(command, args, { cwd = corePackageRoot, env = {}, fatal = true } = {}) {
|
|
14
|
-
const result = spawnSync(command, args, {
|
|
15
|
-
stdio: 'inherit',
|
|
16
|
-
cwd,
|
|
17
|
-
env: { ...process.env, ...env },
|
|
18
|
-
});
|
|
19
|
-
if (result.status !== 0 && fatal) {
|
|
20
|
-
process.exit(result.status ?? 1);
|
|
21
|
-
}
|
|
22
|
-
return result.status === 0;
|
|
23
|
-
}
|
|
24
|
-
function runFixtureBuildCycle({ includePackageBuild = false, includeSdkBuild = false, fatal = true, stagedOutput = false } = {}) {
|
|
25
|
-
if (includeSdkBuild) {
|
|
26
|
-
const sdkRoot = workspaceSdkRoot();
|
|
27
|
-
if (sdkRoot) {
|
|
28
|
-
const built = runStep('npm', ['run', 'build:dist'], { cwd: sdkRoot, fatal });
|
|
29
|
-
if (!built) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (includePackageBuild) {
|
|
35
|
-
const built = runStep('npm', ['run', 'build:dist'], { cwd: corePackageRoot, fatal });
|
|
36
|
-
if (!built) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (watchMode) {
|
|
41
|
-
writeDevReloadStamp(fixtureRoot);
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
const outDir = stagedOutput ? createWatchBuildPaths(fixtureRoot).stagedDistRoot : undefined;
|
|
45
|
-
if (stagedOutput) {
|
|
46
|
-
clearStagedBuildOutput(fixtureRoot);
|
|
47
|
-
}
|
|
48
|
-
prepareCloudflareLocalRuntime({
|
|
49
|
-
envOverrides: watchMode ? { TREESEED_PUBLIC_DEV_WATCH_RELOAD: 'true' } : {},
|
|
50
|
-
outDir,
|
|
51
|
-
});
|
|
52
|
-
if (stagedOutput) {
|
|
53
|
-
swapStagedBuildOutput(fixtureRoot);
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
if (fatal) {
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function startWrangler() {
|
|
66
|
-
const child = startWranglerDev(wranglerArgs, {
|
|
67
|
-
env: watchMode ? { TREESEED_PUBLIC_DEV_WATCH_RELOAD: 'true' } : {},
|
|
68
|
-
detached: process.platform !== 'win32',
|
|
69
|
-
});
|
|
70
|
-
wranglerChild = child;
|
|
71
|
-
child.on('exit', (code, signal) => {
|
|
72
|
-
if (child !== wranglerChild) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
wranglerChild = null;
|
|
76
|
-
if (isStoppingForRebuild || shuttingDown) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (stopWatching) {
|
|
80
|
-
stopWatching();
|
|
81
|
-
}
|
|
82
|
-
if (signal) {
|
|
83
|
-
process.kill(process.pid, signal);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
process.exit(code ?? 0);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
async function shutdownAndExit(code = 0) {
|
|
90
|
-
shuttingDown = true;
|
|
91
|
-
if (stopWatching) {
|
|
92
|
-
stopWatching();
|
|
93
|
-
}
|
|
94
|
-
await stopManagedProcess(wranglerChild);
|
|
95
|
-
process.exit(code);
|
|
96
|
-
}
|
|
97
|
-
process.on('SIGINT', () => {
|
|
98
|
-
void shutdownAndExit(130);
|
|
99
|
-
});
|
|
100
|
-
process.on('SIGTERM', () => {
|
|
101
|
-
void shutdownAndExit(143);
|
|
102
|
-
});
|
|
103
|
-
runFixtureBuildCycle({ includeSdkBuild: true, includePackageBuild: true, fatal: true });
|
|
104
|
-
startWrangler();
|
|
105
|
-
if (watchMode) {
|
|
106
|
-
console.log('Starting fixture watch mode. Changes will rebuild the package fixture and refresh the browser.');
|
|
107
|
-
stopWatching = startPollingWatch({
|
|
108
|
-
watchEntries: createTenantWatchEntries(fixtureRoot),
|
|
109
|
-
onChange: async ({ changedPaths, packageChanged, sdkChanged }) => {
|
|
110
|
-
console.log(`Detected ${changedPaths.length} change${changedPaths.length === 1 ? '' : 's'}; rebuilding ${sdkChanged ? 'sdk, core, and fixture' : packageChanged ? 'core and fixture' : 'fixture'} output...`);
|
|
111
|
-
isStoppingForRebuild = true;
|
|
112
|
-
await stopManagedProcess(wranglerChild);
|
|
113
|
-
isStoppingForRebuild = false;
|
|
114
|
-
const ok = runFixtureBuildCycle({
|
|
115
|
-
includeSdkBuild: sdkChanged,
|
|
116
|
-
includePackageBuild: packageChanged || sdkChanged,
|
|
117
|
-
fatal: false,
|
|
118
|
-
stagedOutput: false,
|
|
119
|
-
});
|
|
120
|
-
if (ok) {
|
|
121
|
-
startWrangler();
|
|
122
|
-
console.log('Rebuild complete. Wrangler restarted with the updated fixture output.');
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
console.error('Rebuild failed. Wrangler remains stopped until the next successful save.');
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
const EXPECTED_PORTS = ['1025->1025/tcp', '8025->8025/tcp'];
|
|
3
|
-
const KNOWN_MAILPIT_NAMES = ['treeseed_mailpit', 'karyon_docs_mailpit'];
|
|
4
|
-
function runDocker(args, options = {}) {
|
|
5
|
-
return spawnSync('docker', args, {
|
|
6
|
-
encoding: 'utf8',
|
|
7
|
-
...options,
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
function parseDockerPsOutput(stdout) {
|
|
11
|
-
return stdout
|
|
12
|
-
.split(/\r?\n/)
|
|
13
|
-
.map((line) => line.trim())
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.map((line) => {
|
|
16
|
-
const [name = '', image = '', ports = ''] = line.split('\t');
|
|
17
|
-
return { name, image, ports };
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function isCompatibleMailpitContainer(container) {
|
|
21
|
-
const nameMatch = KNOWN_MAILPIT_NAMES.includes(container.name);
|
|
22
|
-
const imageMatch = container.image.includes('mailpit');
|
|
23
|
-
const portsMatch = EXPECTED_PORTS.every((port) => container.ports.includes(port));
|
|
24
|
-
return (nameMatch || imageMatch) && portsMatch;
|
|
25
|
-
}
|
|
26
|
-
export function dockerIsAvailable() {
|
|
27
|
-
const result = runDocker(['ps', '--format', '{{.Names}}\t{{.Image}}\t{{.Ports}}']);
|
|
28
|
-
return result.status === 0;
|
|
29
|
-
}
|
|
30
|
-
export function findRunningMailpitContainer() {
|
|
31
|
-
const result = runDocker(['ps', '--format', '{{.Names}}\t{{.Image}}\t{{.Ports}}']);
|
|
32
|
-
if (result.status !== 0) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return parseDockerPsOutput(result.stdout).find(isCompatibleMailpitContainer) ?? null;
|
|
36
|
-
}
|
|
37
|
-
export function stopKnownMailpitContainers() {
|
|
38
|
-
const container = findRunningMailpitContainer();
|
|
39
|
-
if (!container) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
const stopResult = runDocker(['stop', container.name], { stdio: 'inherit' });
|
|
43
|
-
if (stopResult.status !== 0) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
const removeResult = runDocker(['rm', '-f', container.name], { stdio: 'inherit' });
|
|
47
|
-
return removeResult.status === 0;
|
|
48
|
-
}
|
|
49
|
-
export function streamKnownMailpitLogs() {
|
|
50
|
-
const container = findRunningMailpitContainer();
|
|
51
|
-
if (!container) {
|
|
52
|
-
console.error('No running Mailpit container was found on ports 1025 and 8025.');
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
const result = runDocker(['logs', '-f', container.name], { stdio: 'inherit' });
|
|
56
|
-
process.exit(result.status ?? 1);
|
|
57
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const packageRoot: string;
|
|
2
|
-
export declare const packageScriptRoot: string;
|
|
3
|
-
export declare function resolveAstroBin(): string;
|
|
4
|
-
export declare function resolveWranglerBin(): string;
|
|
5
|
-
export declare const corePackageRoot: string;
|
|
6
|
-
export declare const sdkPackageRoot: string;
|
|
7
|
-
export declare const agentPackageRoot: string;
|
|
8
|
-
export declare function loadPackageJson(root?: string): any;
|
|
9
|
-
export declare function isWorkspaceRoot(root?: string): boolean;
|
|
10
|
-
export declare function createProductionBuildEnv(extraEnv?: {}): {
|
|
11
|
-
TREESEED_LOCAL_DEV_MODE: string;
|
|
12
|
-
TREESEED_PUBLIC_FORMS_LOCAL_BYPASS_TURNSTILE: string;
|
|
13
|
-
TREESEED_FORMS_LOCAL_BYPASS_TURNSTILE: string;
|
|
14
|
-
TREESEED_FORMS_LOCAL_BYPASS_CLOUDFLARE_GUARDS: string;
|
|
15
|
-
TREESEED_PUBLIC_DEV_WATCH_RELOAD: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function packageScriptPath(scriptName: any): string;
|
|
18
|
-
export declare function withProcessCwd(cwd: any, action: any): any;
|
|
19
|
-
export declare function loadCliDeployConfig(tenantRoot: any): any;
|
|
20
|
-
export declare function runNodeBinary(binPath: any, args: any, options?: {}): void;
|
|
21
|
-
export declare function runNodeScript(scriptPath: any, args?: never[], options?: {}): void;
|
|
22
|
-
export declare function spawnNodeBinary(binPath: any, args: any, options?: {}): import("child_process").ChildProcessWithoutNullStreams;
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { readFileSync, existsSync } from 'node:fs';
|
|
2
|
-
import { dirname, extname, resolve } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
|
-
import { parse as parseYaml } from 'yaml';
|
|
7
|
-
import { loadTreeseedDeployConfig } from '@treeseed/core/deploy/config';
|
|
8
|
-
const require = createRequire(import.meta.url);
|
|
9
|
-
const scriptRoot = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const packageCandidate = resolve(scriptRoot, '..');
|
|
11
|
-
const TREESEED_DEFAULT_PLUGIN_REFERENCES = [
|
|
12
|
-
{
|
|
13
|
-
package: '@treeseed/core/plugin-default',
|
|
14
|
-
enabled: true,
|
|
15
|
-
},
|
|
16
|
-
];
|
|
17
|
-
const TREESEED_DEFAULT_PROVIDER_SELECTIONS = {
|
|
18
|
-
forms: 'store_only',
|
|
19
|
-
agents: {
|
|
20
|
-
execution: 'stub',
|
|
21
|
-
mutation: 'local_branch',
|
|
22
|
-
repository: 'stub',
|
|
23
|
-
verification: 'stub',
|
|
24
|
-
notification: 'stub',
|
|
25
|
-
research: 'stub',
|
|
26
|
-
},
|
|
27
|
-
deploy: 'cloudflare',
|
|
28
|
-
content: {
|
|
29
|
-
docs: 'default',
|
|
30
|
-
},
|
|
31
|
-
site: 'default',
|
|
32
|
-
};
|
|
33
|
-
export const packageRoot = packageCandidate.endsWith('/dist')
|
|
34
|
-
? resolve(packageCandidate, '..')
|
|
35
|
-
: packageCandidate;
|
|
36
|
-
export const packageScriptRoot = packageCandidate.endsWith('/dist')
|
|
37
|
-
? resolve(packageCandidate, 'scripts')
|
|
38
|
-
: resolve(packageRoot, 'scripts');
|
|
39
|
-
function resolvePackageBinary(packageName, binName = packageName) {
|
|
40
|
-
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
41
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
42
|
-
const binField = packageJson.bin;
|
|
43
|
-
const relativePath = typeof binField === 'string' ? binField : binField?.[binName];
|
|
44
|
-
if (!relativePath) {
|
|
45
|
-
throw new Error(`Unable to resolve binary "${binName}" from package "${packageName}".`);
|
|
46
|
-
}
|
|
47
|
-
return resolve(dirname(packageJsonPath), relativePath);
|
|
48
|
-
}
|
|
49
|
-
function resolveTreeseedPackageRoot(packageName, exportPath, fallbackDirName) {
|
|
50
|
-
if (fallbackDirName) {
|
|
51
|
-
const localRoot = resolve(packageRoot, '..', fallbackDirName);
|
|
52
|
-
if (existsSync(resolve(localRoot, 'package.json'))) {
|
|
53
|
-
return localRoot;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const resolvedEntry = require.resolve(exportPath ?? packageName);
|
|
58
|
-
return resolve(dirname(resolvedEntry), '..');
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
if (!fallbackDirName) {
|
|
62
|
-
throw new Error(`Unable to resolve package root for "${packageName}".`);
|
|
63
|
-
}
|
|
64
|
-
return resolve(packageRoot, '..', fallbackDirName);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export function resolveAstroBin() {
|
|
68
|
-
return resolvePackageBinary('astro', 'astro');
|
|
69
|
-
}
|
|
70
|
-
export function resolveWranglerBin() {
|
|
71
|
-
return resolvePackageBinary('wrangler', 'wrangler');
|
|
72
|
-
}
|
|
73
|
-
export const corePackageRoot = resolveTreeseedPackageRoot('@treeseed/core', '@treeseed/core/config', 'core');
|
|
74
|
-
export const sdkPackageRoot = resolveTreeseedPackageRoot('@treeseed/sdk', '@treeseed/sdk', 'sdk');
|
|
75
|
-
export const agentPackageRoot = resolveTreeseedPackageRoot('@treeseed/agent', '@treeseed/agent', 'agent');
|
|
76
|
-
export function loadPackageJson(root = process.cwd()) {
|
|
77
|
-
const packageJsonPath = resolve(root, 'package.json');
|
|
78
|
-
if (!existsSync(packageJsonPath)) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
return JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
82
|
-
}
|
|
83
|
-
export function isWorkspaceRoot(root = process.cwd()) {
|
|
84
|
-
const packageJson = loadPackageJson(root);
|
|
85
|
-
const workspaces = Array.isArray(packageJson?.workspaces)
|
|
86
|
-
? packageJson.workspaces
|
|
87
|
-
: Array.isArray(packageJson?.workspaces?.packages)
|
|
88
|
-
? packageJson.workspaces.packages
|
|
89
|
-
: [];
|
|
90
|
-
return workspaces.length > 0;
|
|
91
|
-
}
|
|
92
|
-
export function createProductionBuildEnv(extraEnv = {}) {
|
|
93
|
-
return {
|
|
94
|
-
TREESEED_LOCAL_DEV_MODE: 'cloudflare',
|
|
95
|
-
TREESEED_PUBLIC_FORMS_LOCAL_BYPASS_TURNSTILE: '',
|
|
96
|
-
TREESEED_FORMS_LOCAL_BYPASS_TURNSTILE: '',
|
|
97
|
-
TREESEED_FORMS_LOCAL_BYPASS_CLOUDFLARE_GUARDS: '',
|
|
98
|
-
TREESEED_PUBLIC_DEV_WATCH_RELOAD: '',
|
|
99
|
-
...extraEnv,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export function packageScriptPath(scriptName) {
|
|
103
|
-
if (extname(scriptName)) {
|
|
104
|
-
return resolve(packageScriptRoot, scriptName);
|
|
105
|
-
}
|
|
106
|
-
for (const extension of ['.js', '.ts', '.mjs']) {
|
|
107
|
-
const candidate = resolve(packageScriptRoot, `${scriptName}${extension}`);
|
|
108
|
-
if (existsSync(candidate)) {
|
|
109
|
-
return candidate;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
throw new Error(`Unable to resolve package script "${scriptName}".`);
|
|
113
|
-
}
|
|
114
|
-
export function withProcessCwd(cwd, action) {
|
|
115
|
-
const previous = process.cwd();
|
|
116
|
-
if (previous === cwd) {
|
|
117
|
-
return action();
|
|
118
|
-
}
|
|
119
|
-
process.chdir(cwd);
|
|
120
|
-
try {
|
|
121
|
-
return action();
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
process.chdir(previous);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function expectString(value, label) {
|
|
128
|
-
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
129
|
-
throw new Error(`Invalid deploy config: expected ${label} to be a non-empty string.`);
|
|
130
|
-
}
|
|
131
|
-
return value.trim();
|
|
132
|
-
}
|
|
133
|
-
function optionalString(value) {
|
|
134
|
-
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
135
|
-
}
|
|
136
|
-
function optionalBoolean(value, label) {
|
|
137
|
-
if (value === undefined) {
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
if (typeof value !== 'boolean') {
|
|
141
|
-
throw new Error(`Invalid deploy config: expected ${label} to be a boolean when provided.`);
|
|
142
|
-
}
|
|
143
|
-
return value;
|
|
144
|
-
}
|
|
145
|
-
function optionalRecord(value, label) {
|
|
146
|
-
if (value === undefined || value === null) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
150
|
-
throw new Error(`Invalid deploy config: expected ${label} to be an object when provided.`);
|
|
151
|
-
}
|
|
152
|
-
return value;
|
|
153
|
-
}
|
|
154
|
-
function parsePluginReferences(value) {
|
|
155
|
-
if (value === undefined) {
|
|
156
|
-
return [...TREESEED_DEFAULT_PLUGIN_REFERENCES];
|
|
157
|
-
}
|
|
158
|
-
if (!Array.isArray(value)) {
|
|
159
|
-
throw new Error('Invalid deploy config: expected plugins to be an array.');
|
|
160
|
-
}
|
|
161
|
-
return value.map((entry, index) => {
|
|
162
|
-
const record = optionalRecord(entry, `plugins[${index}]`) ?? {};
|
|
163
|
-
return {
|
|
164
|
-
package: expectString(record.package, `plugins[${index}].package`),
|
|
165
|
-
enabled: record.enabled === undefined ? true : optionalBoolean(record.enabled, `plugins[${index}].enabled`),
|
|
166
|
-
config: record.config === undefined ? {} : optionalRecord(record.config, `plugins[${index}].config`),
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function parseFallbackDeployConfig(configPath) {
|
|
171
|
-
const parsed = (parseYaml(readFileSync(configPath, 'utf8')) ?? {});
|
|
172
|
-
const record = optionalRecord(parsed, 'root') ?? {};
|
|
173
|
-
const cloudflare = optionalRecord(record.cloudflare, 'cloudflare') ?? {};
|
|
174
|
-
const smtp = optionalRecord(record.smtp, 'smtp') ?? {};
|
|
175
|
-
const turnstile = optionalRecord(record.turnstile, 'turnstile') ?? {};
|
|
176
|
-
const agentProviders = optionalRecord(optionalRecord(record.providers, 'providers')?.agents, 'providers.agents') ?? {};
|
|
177
|
-
const contentProviders = optionalRecord(optionalRecord(record.providers, 'providers')?.content, 'providers.content') ?? {};
|
|
178
|
-
const deployConfig = {
|
|
179
|
-
name: expectString(record.name, 'name'),
|
|
180
|
-
slug: expectString(record.slug, 'slug'),
|
|
181
|
-
siteUrl: expectString(record.siteUrl, 'siteUrl'),
|
|
182
|
-
contactEmail: expectString(record.contactEmail, 'contactEmail'),
|
|
183
|
-
cloudflare: {
|
|
184
|
-
accountId: optionalString(cloudflare.accountId)
|
|
185
|
-
?? optionalString(process.env.CLOUDFLARE_ACCOUNT_ID)
|
|
186
|
-
?? 'replace-with-cloudflare-account-id',
|
|
187
|
-
workerName: optionalString(cloudflare.workerName),
|
|
188
|
-
},
|
|
189
|
-
plugins: parsePluginReferences(record.plugins),
|
|
190
|
-
providers: {
|
|
191
|
-
forms: expectString(record.providers?.forms ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.forms, 'providers.forms'),
|
|
192
|
-
agents: {
|
|
193
|
-
execution: expectString(agentProviders.execution ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.execution, 'providers.agents.execution'),
|
|
194
|
-
mutation: expectString(agentProviders.mutation ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.mutation, 'providers.agents.mutation'),
|
|
195
|
-
repository: expectString(agentProviders.repository ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.repository, 'providers.agents.repository'),
|
|
196
|
-
verification: expectString(agentProviders.verification ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.verification, 'providers.agents.verification'),
|
|
197
|
-
notification: expectString(agentProviders.notification ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.notification, 'providers.agents.notification'),
|
|
198
|
-
research: expectString(agentProviders.research ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.research, 'providers.agents.research'),
|
|
199
|
-
},
|
|
200
|
-
deploy: expectString(record.providers?.deploy ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.deploy, 'providers.deploy'),
|
|
201
|
-
content: {
|
|
202
|
-
docs: expectString(contentProviders.docs ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.content.docs, 'providers.content.docs'),
|
|
203
|
-
},
|
|
204
|
-
site: expectString(record.providers?.site ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.site, 'providers.site'),
|
|
205
|
-
},
|
|
206
|
-
smtp: {
|
|
207
|
-
enabled: optionalBoolean(smtp.enabled, 'smtp.enabled'),
|
|
208
|
-
},
|
|
209
|
-
turnstile: {
|
|
210
|
-
enabled: optionalBoolean(turnstile.enabled, 'turnstile.enabled') ?? true,
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
Object.defineProperty(deployConfig, '__tenantRoot', {
|
|
214
|
-
value: dirname(configPath),
|
|
215
|
-
enumerable: false,
|
|
216
|
-
});
|
|
217
|
-
Object.defineProperty(deployConfig, '__configPath', {
|
|
218
|
-
value: configPath,
|
|
219
|
-
enumerable: false,
|
|
220
|
-
});
|
|
221
|
-
return deployConfig;
|
|
222
|
-
}
|
|
223
|
-
export function loadCliDeployConfig(tenantRoot) {
|
|
224
|
-
try {
|
|
225
|
-
return withProcessCwd(tenantRoot, () => loadTreeseedDeployConfig());
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
const configPath = resolve(tenantRoot, 'treeseed.site.yaml');
|
|
229
|
-
if (!existsSync(configPath)) {
|
|
230
|
-
throw error;
|
|
231
|
-
}
|
|
232
|
-
return parseFallbackDeployConfig(configPath);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
export function runNodeBinary(binPath, args, options = {}) {
|
|
236
|
-
const result = spawnSync(process.execPath, [binPath, ...args], {
|
|
237
|
-
stdio: options.stdio ?? 'inherit',
|
|
238
|
-
cwd: options.cwd ?? process.cwd(),
|
|
239
|
-
env: { ...process.env, ...(options.env ?? {}) },
|
|
240
|
-
});
|
|
241
|
-
if (result.status !== 0) {
|
|
242
|
-
process.exit(result.status ?? 1);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
export function runNodeScript(scriptPath, args = [], options = {}) {
|
|
246
|
-
return runNodeBinary(scriptPath, args, options);
|
|
247
|
-
}
|
|
248
|
-
export function spawnNodeBinary(binPath, args, options = {}) {
|
|
249
|
-
return spawn(process.execPath, [binPath, ...args], {
|
|
250
|
-
stdio: options.stdio ?? 'inherit',
|
|
251
|
-
cwd: options.cwd ?? process.cwd(),
|
|
252
|
-
env: { ...process.env, ...(options.env ?? {}) },
|
|
253
|
-
detached: options.detached ?? false,
|
|
254
|
-
});
|
|
255
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { packageRoot } from './paths.js';
|
|
5
|
-
const legacyDocsRoot = path.resolve(packageRoot, '../..');
|
|
6
|
-
const candidateStarlightRoots = [
|
|
7
|
-
path.join(process.cwd(), 'node_modules/@astrojs/starlight'),
|
|
8
|
-
path.join(packageRoot, 'node_modules/@astrojs/starlight'),
|
|
9
|
-
path.join(legacyDocsRoot, 'node_modules/@astrojs/starlight'),
|
|
10
|
-
];
|
|
11
|
-
const candidateCollectionFiles = [
|
|
12
|
-
path.join(process.cwd(), 'node_modules/@astrojs/starlight/utils/collection.ts'),
|
|
13
|
-
path.join(packageRoot, 'node_modules/@astrojs/starlight/utils/collection.ts'),
|
|
14
|
-
path.join(legacyDocsRoot, 'node_modules/@astrojs/starlight/utils/collection.ts'),
|
|
15
|
-
];
|
|
16
|
-
const originalSource = `export type StarlightCollection = 'docs' | 'i18n';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* We still rely on the content collection folder structure to be fixed for now:
|
|
20
|
-
*
|
|
21
|
-
* - At build time, if the feature is enabled, we get all the last commit dates for each file in
|
|
22
|
-
* the docs folder ahead of time. In the current approach, we cannot know at this time the
|
|
23
|
-
* user-defined content folder path in the integration context as this would only be available
|
|
24
|
-
* from the loader. A potential solution could be to do that from a custom loader re-implementing
|
|
25
|
-
* the glob loader or built on top of it. Although, we don't have access to the Starlight
|
|
26
|
-
* configuration from the loader to even know we should do that.
|
|
27
|
-
* - Remark plugins get passed down an absolute path to a content file and we need to figure out
|
|
28
|
-
* the language from that path. Without knowing the content folder path, we cannot reliably do
|
|
29
|
-
* so.
|
|
30
|
-
*
|
|
31
|
-
* Below are various functions to easily get paths to these collections and avoid having to
|
|
32
|
-
* hardcode them throughout the codebase. When user-defined content folder locations are supported,
|
|
33
|
-
* these helper functions should be updated to reflect that in one place.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
export function getCollectionUrl(collection: StarlightCollection, srcDir: URL) {
|
|
37
|
-
\treturn new URL(\`content/\${collection}/\`, srcDir);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getCollectionPathFromRoot(
|
|
41
|
-
\tcollection: StarlightCollection,
|
|
42
|
-
\t{ root, srcDir }: { root: URL | string; srcDir: URL | string }
|
|
43
|
-
) {
|
|
44
|
-
\treturn (
|
|
45
|
-
\t\t(typeof srcDir === 'string' ? srcDir : srcDir.pathname).replace(
|
|
46
|
-
\t\t\ttypeof root === 'string' ? root : root.pathname,
|
|
47
|
-
\t\t\t''
|
|
48
|
-
\t\t) +
|
|
49
|
-
\t\t'content/' +
|
|
50
|
-
\t\tcollection
|
|
51
|
-
\t);
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
const patchedSource = `export type StarlightCollection = 'docs' | 'i18n';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* We still rely on the content collection folder structure to be fixed for now:
|
|
58
|
-
*
|
|
59
|
-
* - At build time, if the feature is enabled, we get all the last commit dates for each file in
|
|
60
|
-
* the docs folder ahead of time. In the current approach, we cannot know at this time the
|
|
61
|
-
* user-defined content folder path in the integration context as this would only be available
|
|
62
|
-
* from the loader. A potential solution could be to do that from a custom loader re-implementing
|
|
63
|
-
* the glob loader or built on top of it. Although, we don't have access to the Starlight
|
|
64
|
-
* configuration from the loader to even know we should do that.
|
|
65
|
-
* - Remark plugins get passed down an absolute path to a content file and we need to figure out
|
|
66
|
-
* the language from that path. Without knowing the content folder path, we cannot reliably do
|
|
67
|
-
* so.
|
|
68
|
-
*
|
|
69
|
-
* Below are various functions to easily get paths to these collections and avoid having to
|
|
70
|
-
* hardcode them throughout the codebase. When user-defined content folder locations are supported,
|
|
71
|
-
* these helper functions should be updated to reflect that in one place.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
export function getCollectionUrl(collection: StarlightCollection, srcDir: URL) {
|
|
75
|
-
\treturn new URL(\`content/\${getCollectionDir(collection)}/\`, srcDir);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getCollectionDir(collection: StarlightCollection) {
|
|
79
|
-
\treturn collection === 'docs' ? 'knowledge' : collection;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function getCollectionPathFromRoot(
|
|
83
|
-
\tcollection: StarlightCollection,
|
|
84
|
-
\t{ root, srcDir }: { root: URL | string; srcDir: URL | string }
|
|
85
|
-
) {
|
|
86
|
-
\treturn (
|
|
87
|
-
\t\t(typeof srcDir === 'string' ? srcDir : srcDir.pathname).replace(
|
|
88
|
-
\t\t\ttypeof root === 'string' ? root : root.pathname,
|
|
89
|
-
\t\t\t''
|
|
90
|
-
\t\t) +
|
|
91
|
-
\t\t'content/' +
|
|
92
|
-
\t\tgetCollectionDir(collection)
|
|
93
|
-
\t);
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
async function patchCollectionFile(collectionFile) {
|
|
97
|
-
const source = await fs.readFile(collectionFile, 'utf8');
|
|
98
|
-
if (source === patchedSource) {
|
|
99
|
-
return 'already';
|
|
100
|
-
}
|
|
101
|
-
if (source !== originalSource) {
|
|
102
|
-
throw new Error(`Unexpected Starlight collection helper format in ${collectionFile}`);
|
|
103
|
-
}
|
|
104
|
-
await fs.writeFile(collectionFile, patchedSource);
|
|
105
|
-
return 'patched';
|
|
106
|
-
}
|
|
107
|
-
async function copyVendoredTree(sourceRoot, targetRoot) {
|
|
108
|
-
const entries = await fs.readdir(sourceRoot, { withFileTypes: true });
|
|
109
|
-
for (const entry of entries) {
|
|
110
|
-
const sourcePath = path.join(sourceRoot, entry.name);
|
|
111
|
-
const targetPath = path.join(targetRoot, entry.name);
|
|
112
|
-
if (entry.isDirectory()) {
|
|
113
|
-
await fs.mkdir(targetPath, { recursive: true });
|
|
114
|
-
await copyVendoredTree(sourcePath, targetPath);
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
await fs.copyFile(sourcePath, targetPath);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async function patchStarlightPackageRoot(starlightRoot) {
|
|
121
|
-
const packageJsonPath = path.join(starlightRoot, 'package.json');
|
|
122
|
-
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
|
123
|
-
const coreVendorRoot = path.join(path.dirname(path.dirname(starlightRoot)), '@treeseed/core/dist/vendor/starlight');
|
|
124
|
-
await copyVendoredTree(coreVendorRoot, starlightRoot);
|
|
125
|
-
packageJson.exports = {
|
|
126
|
-
...packageJson.exports,
|
|
127
|
-
'.': './index.js',
|
|
128
|
-
'./schema': './schema.js',
|
|
129
|
-
'./loaders': './loaders.js',
|
|
130
|
-
'./route-data': './route-data.js',
|
|
131
|
-
'./internal': './internal.js',
|
|
132
|
-
'./components': './components.js',
|
|
133
|
-
};
|
|
134
|
-
await fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8');
|
|
135
|
-
}
|
|
136
|
-
async function run() {
|
|
137
|
-
const existingFiles = [];
|
|
138
|
-
for (const collectionFile of candidateCollectionFiles) {
|
|
139
|
-
try {
|
|
140
|
-
await fs.access(collectionFile);
|
|
141
|
-
existingFiles.push(collectionFile);
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
// Ignore missing dependency trees.
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (existingFiles.length === 0) {
|
|
148
|
-
throw new Error('Unable to find any Starlight collection helper files to patch.');
|
|
149
|
-
}
|
|
150
|
-
let patchedAny = false;
|
|
151
|
-
for (const collectionFile of existingFiles) {
|
|
152
|
-
const result = await patchCollectionFile(collectionFile);
|
|
153
|
-
patchedAny = patchedAny || result === 'patched';
|
|
154
|
-
}
|
|
155
|
-
for (const starlightRoot of candidateStarlightRoots) {
|
|
156
|
-
try {
|
|
157
|
-
await fs.access(path.join(starlightRoot, 'package.json'));
|
|
158
|
-
await patchStarlightPackageRoot(starlightRoot);
|
|
159
|
-
patchedAny = true;
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
// Ignore missing dependency trees.
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
console.log(patchedAny
|
|
166
|
-
? 'Applied Starlight knowledge-path patch.'
|
|
167
|
-
: 'Starlight knowledge-path patch already applied.');
|
|
168
|
-
}
|
|
169
|
-
run().catch((error) => {
|
|
170
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
171
|
-
process.exitCode = 1;
|
|
172
|
-
});
|
package/dist/scripts/paths.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { corePackageRoot, packageRoot } from './package-tools.ts';
|
|
2
|
-
export declare const cliPackageRoot: string;
|
|
3
|
-
export { corePackageRoot, packageRoot };
|
|
4
|
-
export declare const workspaceRoot: string;
|
|
5
|
-
export declare const templatesRoot: string;
|
|
6
|
-
export declare const examplesRoot: string;
|
|
7
|
-
export declare const fixturesRoot: string;
|
|
8
|
-
export declare const referenceAppsRoot: string;
|
|
9
|
-
export declare const toolingRoot: string;
|
|
10
|
-
export declare const servicesRoot: string;
|
|
11
|
-
export declare const mailpitComposeFile: string;
|
|
12
|
-
export declare const fixtureRoot: string;
|
|
13
|
-
export declare const fixtureWranglerConfig: string;
|
|
14
|
-
export declare const fixtureMigrationsRoot: string;
|
|
15
|
-
export declare const fixtureSrcRoot: string;
|
|
16
|
-
export declare const cliPackageVersion: any;
|
|
17
|
-
export declare const corePackageVersion: any;
|