@treeseed/sdk 0.1.1 → 0.3.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 +97 -494
- package/dist/{src/cli-tools.d.ts → cli-tools.d.ts} +1 -1
- package/dist/cli-tools.js +5 -3
- package/dist/{src/content-store.d.ts → content-store.d.ts} +3 -2
- package/dist/content-store.js +52 -20
- package/dist/{src/d1-store.d.ts → d1-store.d.ts} +62 -1
- package/dist/d1-store.js +625 -65
- package/dist/field-aliases.d.ts +11 -0
- package/dist/field-aliases.js +41 -0
- package/dist/graph/build.d.ts +19 -0
- package/dist/graph/build.js +949 -0
- package/dist/graph/dsl.d.ts +2 -0
- package/dist/graph/dsl.js +243 -0
- package/dist/graph/query.d.ts +47 -0
- package/dist/graph/query.js +447 -0
- package/dist/graph/ranking.d.ts +3 -0
- package/dist/graph/ranking.js +483 -0
- package/dist/graph/schema.d.ts +142 -0
- package/dist/graph/schema.js +133 -0
- package/dist/graph.d.ts +52 -0
- package/dist/graph.js +133 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +90 -2
- package/dist/model-registry.d.ts +8 -0
- package/dist/model-registry.js +351 -25
- package/dist/operations/providers/default.d.ts +10 -0
- package/dist/operations/providers/default.js +514 -0
- package/dist/operations/runtime.d.ts +7 -0
- package/dist/operations/runtime.js +60 -0
- package/dist/operations/services/config-runtime.d.ts +269 -0
- package/dist/operations/services/config-runtime.js +1397 -0
- package/dist/operations/services/d1-migration.d.ts +6 -0
- package/dist/operations/services/d1-migration.js +89 -0
- package/dist/operations/services/deploy.d.ts +371 -0
- package/dist/operations/services/deploy.js +981 -0
- package/dist/operations/services/git-workflow.d.ts +49 -0
- package/dist/operations/services/git-workflow.js +218 -0
- package/dist/operations/services/github-automation.d.ts +156 -0
- package/dist/operations/services/github-automation.js +256 -0
- package/dist/operations/services/local-dev.d.ts +9 -0
- package/dist/operations/services/local-dev.js +106 -0
- package/dist/operations/services/mailpit-runtime.d.ts +4 -0
- package/dist/operations/services/mailpit-runtime.js +59 -0
- package/dist/operations/services/railway-deploy.d.ts +53 -0
- package/dist/operations/services/railway-deploy.js +123 -0
- package/dist/operations/services/runtime-paths.d.ts +19 -0
- package/dist/operations/services/runtime-paths.js +54 -0
- package/dist/operations/services/runtime-tools.d.ts +117 -0
- package/dist/operations/services/runtime-tools.js +358 -0
- package/dist/operations/services/save-deploy-preflight.d.ts +34 -0
- package/dist/operations/services/save-deploy-preflight.js +76 -0
- package/dist/operations/services/template-registry.d.ts +88 -0
- package/dist/operations/services/template-registry.js +407 -0
- package/dist/operations/services/watch-dev.d.ts +21 -0
- package/dist/operations/services/watch-dev.js +284 -0
- package/dist/operations/services/workspace-preflight.d.ts +40 -0
- package/dist/operations/services/workspace-preflight.js +165 -0
- package/dist/operations/services/workspace-save.d.ts +42 -0
- package/dist/operations/services/workspace-save.js +235 -0
- package/dist/operations/services/workspace-tools.d.ts +16 -0
- package/dist/operations/services/workspace-tools.js +270 -0
- package/dist/operations-registry.d.ts +5 -0
- package/dist/operations-registry.js +68 -0
- package/dist/operations-types.d.ts +71 -0
- package/dist/operations-types.js +17 -0
- package/dist/operations.d.ts +6 -0
- package/dist/operations.js +16 -0
- package/dist/platform/books-data.d.ts +1 -0
- package/dist/platform/books-data.js +1 -0
- package/dist/platform/contracts.d.ts +158 -0
- package/dist/platform/contracts.js +0 -0
- package/dist/platform/deploy/config.d.ts +4 -0
- package/dist/platform/deploy/config.js +222 -0
- package/dist/platform/deploy-config.d.ts +1 -0
- package/dist/platform/deploy-config.js +1 -0
- package/dist/platform/env.yaml +394 -0
- package/dist/platform/environment.d.ts +130 -0
- package/dist/platform/environment.js +331 -0
- package/dist/platform/plugin.d.ts +2 -0
- package/dist/platform/plugin.js +4 -0
- package/dist/platform/plugins/constants.d.ts +22 -0
- package/dist/platform/plugins/constants.js +29 -0
- package/dist/platform/plugins/plugin.d.ts +51 -0
- package/dist/platform/plugins/plugin.js +6 -0
- package/dist/platform/plugins/runtime.d.ts +35 -0
- package/dist/platform/plugins/runtime.js +142 -0
- package/dist/platform/plugins.d.ts +5 -0
- package/dist/platform/plugins.js +16 -0
- package/dist/platform/site-config-schema.js +1 -0
- package/dist/platform/tenant/config.d.ts +9 -0
- package/dist/platform/tenant/config.js +154 -0
- package/dist/platform/tenant/runtime-config.d.ts +4 -0
- package/dist/platform/tenant/runtime-config.js +20 -0
- package/dist/platform/tenant-config.d.ts +1 -0
- package/dist/platform/tenant-config.js +1 -0
- package/dist/platform/utils/books-data.d.ts +29 -0
- package/dist/platform/utils/books-data.js +82 -0
- package/dist/platform/utils/site-config-schema.js +321 -0
- package/dist/remote.d.ts +175 -0
- package/dist/remote.js +202 -0
- package/dist/runtime.js +50 -3
- package/dist/scripts/aggregate-book.js +121 -0
- package/dist/scripts/build-dist.js +57 -13
- package/dist/scripts/build-tenant-worker.js +36 -0
- package/dist/scripts/cleanup-markdown.js +373 -0
- package/dist/scripts/cli-test-fixtures.js +48 -0
- package/dist/scripts/config-treeseed.js +95 -0
- package/dist/scripts/ensure-mailpit.js +29 -0
- package/dist/scripts/local-dev.js +129 -0
- package/dist/scripts/logs-mailpit.js +2 -0
- package/dist/scripts/patch-starlight-content-path.js +172 -0
- package/dist/scripts/release-verify.js +34 -5
- package/dist/scripts/run-fixture-astro-command.js +18 -0
- package/dist/scripts/scaffold-site.js +65 -0
- package/dist/scripts/stop-mailpit.js +5 -0
- package/dist/scripts/sync-dev-vars.js +6 -0
- package/dist/scripts/sync-template.js +20 -0
- package/dist/scripts/template-catalog.test.js +100 -0
- package/dist/scripts/template-command.js +31 -0
- package/dist/scripts/tenant-astro-command.js +3 -0
- package/dist/scripts/tenant-build.js +16 -0
- package/dist/scripts/tenant-check.js +7 -0
- package/dist/scripts/tenant-d1-migrate-local.js +11 -0
- package/dist/scripts/tenant-deploy.js +180 -0
- package/dist/scripts/tenant-destroy.js +104 -0
- package/dist/scripts/tenant-dev.js +171 -0
- package/dist/scripts/tenant-lint.js +4 -0
- package/dist/scripts/tenant-test.js +4 -0
- package/dist/scripts/test-cloudflare-local.js +212 -0
- package/dist/scripts/test-scaffold.js +314 -0
- package/dist/scripts/test-smoke.js +71 -13
- package/dist/scripts/treeseed-assert-release-tag-version.js +21 -0
- package/dist/scripts/treeseed-build-dist.js +134 -0
- package/dist/scripts/treeseed-publish-package.js +19 -0
- package/dist/scripts/treeseed-release-verify.js +131 -0
- package/dist/scripts/treeseed-run-ts.js +45 -0
- package/dist/scripts/validate-templates.js +6 -0
- package/dist/scripts/verify-driver.js +29 -0
- package/dist/scripts/workflow-commands.test.js +39 -0
- package/dist/scripts/workspace-close.js +24 -0
- package/dist/scripts/workspace-command-e2e.js +718 -0
- package/dist/scripts/workspace-lint.js +9 -0
- package/dist/scripts/workspace-preflight.js +22 -0
- package/dist/scripts/workspace-publish-changed-packages.js +16 -0
- package/dist/scripts/workspace-release-verify.js +81 -0
- package/dist/scripts/workspace-release.js +42 -0
- package/dist/scripts/workspace-save.js +124 -0
- package/dist/scripts/workspace-start-warning.js +3 -0
- package/dist/scripts/workspace-start.js +71 -0
- package/dist/scripts/workspace-test-unit.js +4 -0
- package/dist/scripts/workspace-test.js +11 -0
- package/dist/sdk-fields.d.ts +11 -0
- package/dist/sdk-fields.js +169 -0
- package/dist/sdk-filters.d.ts +4 -0
- package/dist/sdk-filters.js +12 -15
- package/dist/sdk-types.d.ts +796 -0
- package/dist/sdk-types.js +7 -1
- package/dist/sdk-version.d.ts +2 -0
- package/dist/sdk-version.js +42 -0
- package/dist/sdk.d.ts +215 -0
- package/dist/sdk.js +235 -11
- package/dist/stores/cursor-store.js +9 -3
- package/dist/stores/lease-store.js +8 -2
- package/dist/{src/stores → stores}/message-store.d.ts +1 -1
- package/dist/stores/message-store.js +27 -3
- package/dist/stores/operational-store.d.ts +24 -0
- package/dist/stores/operational-store.js +279 -0
- package/dist/stores/run-store.js +8 -1
- package/dist/stores/subscription-store.js +7 -5
- package/dist/template-catalog.d.ts +13 -0
- package/dist/template-catalog.js +141 -0
- package/dist/treeseed/services/compose.yml +7 -0
- package/dist/treeseed/template-catalog/catalog.fixture.json +55 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/astro.config.d.ts +2 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/astro.config.ts +3 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +32 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/config.yaml +40 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content/empty/.gitkeep +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content/knowledge/handbook/index.mdx +11 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content/pages/welcome.mdx +11 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content.config.d.ts +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content.config.ts +3 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/env.yaml +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/manifest.yaml +19 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +26 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/tsconfig.json +9 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +90 -0
- package/dist/verification.d.ts +20 -0
- package/dist/verification.js +98 -0
- package/dist/workflow/operations.d.ts +396 -0
- package/dist/workflow/operations.js +841 -0
- package/dist/workflow-state.d.ts +56 -0
- package/dist/workflow-state.js +195 -0
- package/dist/workflow-support.d.ts +9 -0
- package/dist/workflow-support.js +176 -0
- package/dist/workflow.d.ts +111 -0
- package/dist/workflow.js +97 -0
- package/package.json +97 -5
- package/scripts/verify-driver.mjs +29 -0
- package/dist/scripts/.ts-run-1775616845195-odh4xzphk3l.js +0 -22
- package/dist/scripts/.ts-run-1775616848931-9386s6kwrl.js +0 -126
- package/dist/scripts/assert-release-tag-version.d.ts +0 -1
- package/dist/scripts/build-dist.d.ts +0 -1
- package/dist/scripts/package-tools.d.ts +0 -15
- package/dist/scripts/publish-package.d.ts +0 -1
- package/dist/scripts/release-verify.d.ts +0 -1
- package/dist/scripts/test-smoke.d.ts +0 -1
- package/dist/src/index.d.ts +0 -6
- package/dist/src/model-registry.d.ts +0 -4
- package/dist/src/sdk-filters.d.ts +0 -4
- package/dist/src/sdk-types.d.ts +0 -285
- package/dist/src/sdk.d.ts +0 -109
- package/dist/test/test-fixture.d.ts +0 -1
- package/dist/test/utils/envelopes.test.d.ts +0 -1
- package/dist/test/utils/sdk.test.d.ts +0 -1
- package/dist/vitest.config.d.ts +0 -2
- /package/dist/{src/frontmatter.d.ts → frontmatter.d.ts} +0 -0
- /package/dist/{src/git-runtime.d.ts → git-runtime.d.ts} +0 -0
- /package/dist/{src/runtime.d.ts → runtime.d.ts} +0 -0
- /package/dist/{src/stores → stores}/cursor-store.d.ts +0 -0
- /package/dist/{src/stores → stores}/envelopes.d.ts +0 -0
- /package/dist/{src/stores → stores}/helpers.d.ts +0 -0
- /package/dist/{src/stores → stores}/lease-store.d.ts +0 -0
- /package/dist/{src/stores → stores}/run-store.d.ts +0 -0
- /package/dist/{src/stores → stores}/subscription-store.d.ts +0 -0
- /package/dist/{src/types → types}/agents.d.ts +0 -0
- /package/dist/{src/types → types}/cloudflare.d.ts +0 -0
- /package/dist/{src/wrangler-d1.d.ts → wrangler-d1.d.ts} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { runLocalD1Migrations as applyLocalD1Migrations } from "./d1-migration.js";
|
|
4
|
+
import {
|
|
5
|
+
fixtureMigrationsRoot,
|
|
6
|
+
fixtureRoot,
|
|
7
|
+
fixtureWranglerConfig,
|
|
8
|
+
corePackageRoot
|
|
9
|
+
} from "./runtime-paths.js";
|
|
10
|
+
function mergeEnv(extraEnv = {}) {
|
|
11
|
+
return { ...process.env, ...extraEnv };
|
|
12
|
+
}
|
|
13
|
+
function runStep(command, args, options = {}) {
|
|
14
|
+
const result = spawnSync(command, args, {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
shell: process.platform === "win32",
|
|
17
|
+
env: mergeEnv(options.env),
|
|
18
|
+
cwd: options.cwd ?? process.cwd()
|
|
19
|
+
});
|
|
20
|
+
if (result.status !== 0) {
|
|
21
|
+
process.exit(result.status ?? 1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function runNodeScript(scriptRelativePath, args = [], options = {}) {
|
|
25
|
+
return runStep(process.execPath, [resolve(corePackageRoot, scriptRelativePath), ...args], {
|
|
26
|
+
...options,
|
|
27
|
+
cwd: options.cwd ?? corePackageRoot
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function spawnProcess(command, args, options = {}) {
|
|
31
|
+
return spawn(command, args, {
|
|
32
|
+
stdio: options.stdio ?? "inherit",
|
|
33
|
+
shell: process.platform === "win32",
|
|
34
|
+
env: mergeEnv(options.env),
|
|
35
|
+
cwd: options.cwd ?? process.cwd(),
|
|
36
|
+
detached: options.detached ?? false
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function syncDevVars(overrides = {}) {
|
|
40
|
+
const overrideEntries = Object.entries(overrides);
|
|
41
|
+
runNodeScript(
|
|
42
|
+
"./scripts/sync-dev-vars.js",
|
|
43
|
+
overrideEntries.map(([key, value]) => `${key}=${value}`),
|
|
44
|
+
{ cwd: fixtureRoot }
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function runLocalD1Migration(persistTo) {
|
|
48
|
+
applyLocalD1Migrations({
|
|
49
|
+
cwd: fixtureRoot,
|
|
50
|
+
wranglerConfig: fixtureWranglerConfig,
|
|
51
|
+
migrationsRoot: fixtureMigrationsRoot,
|
|
52
|
+
persistTo
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function prepareCloudflareLocalRuntime({ envOverrides = {}, persistTo, outDir } = {}) {
|
|
56
|
+
const mergedEnvOverrides = {
|
|
57
|
+
TREESEED_MAILPIT_SMTP_HOST: "127.0.0.1",
|
|
58
|
+
TREESEED_MAILPIT_SMTP_PORT: "1025",
|
|
59
|
+
...envOverrides
|
|
60
|
+
};
|
|
61
|
+
runNodeScript("./scripts/patch-starlight-content-path.js");
|
|
62
|
+
runNodeScript("./scripts/aggregate-book.js");
|
|
63
|
+
runNodeScript("./scripts/ensure-mailpit.js");
|
|
64
|
+
syncDevVars({
|
|
65
|
+
TREESEED_LOCAL_DEV_MODE: "cloudflare",
|
|
66
|
+
...mergedEnvOverrides
|
|
67
|
+
});
|
|
68
|
+
runLocalD1Migration(persistTo);
|
|
69
|
+
const astroArgs = ["astro", "build", "--root", fixtureRoot];
|
|
70
|
+
if (outDir) {
|
|
71
|
+
astroArgs.push("--outDir", outDir);
|
|
72
|
+
}
|
|
73
|
+
runStep("npx", astroArgs, {
|
|
74
|
+
env: {
|
|
75
|
+
TREESEED_LOCAL_DEV_MODE: "cloudflare",
|
|
76
|
+
...mergedEnvOverrides
|
|
77
|
+
},
|
|
78
|
+
cwd: corePackageRoot
|
|
79
|
+
});
|
|
80
|
+
runNodeScript("./scripts/build-tenant-worker.js", [], {
|
|
81
|
+
cwd: fixtureRoot,
|
|
82
|
+
env: {
|
|
83
|
+
TREESEED_LOCAL_DEV_MODE: "cloudflare",
|
|
84
|
+
...mergedEnvOverrides
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function startWranglerDev(args = [], options = {}) {
|
|
89
|
+
return spawnProcess(
|
|
90
|
+
"wrangler",
|
|
91
|
+
["dev", "--local", "--config", fixtureWranglerConfig, ...args],
|
|
92
|
+
{
|
|
93
|
+
...options,
|
|
94
|
+
cwd: options.cwd ?? fixtureRoot
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
prepareCloudflareLocalRuntime,
|
|
100
|
+
runLocalD1Migration,
|
|
101
|
+
runNodeScript,
|
|
102
|
+
runStep,
|
|
103
|
+
spawnProcess,
|
|
104
|
+
startWranglerDev,
|
|
105
|
+
syncDevVars
|
|
106
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
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.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((line) => {
|
|
12
|
+
const [name = "", image = "", ports = ""] = line.split(" ");
|
|
13
|
+
return { name, image, ports };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function isCompatibleMailpitContainer(container) {
|
|
17
|
+
const nameMatch = KNOWN_MAILPIT_NAMES.includes(container.name);
|
|
18
|
+
const imageMatch = container.image.includes("mailpit");
|
|
19
|
+
const portsMatch = EXPECTED_PORTS.every((port) => container.ports.includes(port));
|
|
20
|
+
return (nameMatch || imageMatch) && portsMatch;
|
|
21
|
+
}
|
|
22
|
+
function dockerIsAvailable() {
|
|
23
|
+
const result = runDocker(["ps", "--format", "{{.Names}} {{.Image}} {{.Ports}}"]);
|
|
24
|
+
return result.status === 0;
|
|
25
|
+
}
|
|
26
|
+
function findRunningMailpitContainer() {
|
|
27
|
+
const result = runDocker(["ps", "--format", "{{.Names}} {{.Image}} {{.Ports}}"]);
|
|
28
|
+
if (result.status !== 0) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return parseDockerPsOutput(result.stdout).find(isCompatibleMailpitContainer) ?? null;
|
|
32
|
+
}
|
|
33
|
+
function stopKnownMailpitContainers() {
|
|
34
|
+
const container = findRunningMailpitContainer();
|
|
35
|
+
if (!container) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const stopResult = runDocker(["stop", container.name], { stdio: "inherit" });
|
|
39
|
+
if (stopResult.status !== 0) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const removeResult = runDocker(["rm", "-f", container.name], { stdio: "inherit" });
|
|
43
|
+
return removeResult.status === 0;
|
|
44
|
+
}
|
|
45
|
+
function streamKnownMailpitLogs() {
|
|
46
|
+
const container = findRunningMailpitContainer();
|
|
47
|
+
if (!container) {
|
|
48
|
+
console.error("No running Mailpit container was found on ports 1025 and 8025.");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const result = runDocker(["logs", "-f", container.name], { stdio: "inherit" });
|
|
52
|
+
process.exit(result.status ?? 1);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
dockerIsAvailable,
|
|
56
|
+
findRunningMailpitContainer,
|
|
57
|
+
stopKnownMailpitContainers,
|
|
58
|
+
streamKnownMailpitLogs
|
|
59
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare function configuredRailwayServices(tenantRoot: any, scope: any): ({
|
|
2
|
+
key: string;
|
|
3
|
+
scope: string;
|
|
4
|
+
projectId: string | null;
|
|
5
|
+
projectName: string | null;
|
|
6
|
+
serviceId: string | null;
|
|
7
|
+
serviceName: string | null;
|
|
8
|
+
rootDir: string;
|
|
9
|
+
publicBaseUrl: string | null;
|
|
10
|
+
railwayEnvironment: string;
|
|
11
|
+
buildCommand: string | null;
|
|
12
|
+
startCommand: string | null;
|
|
13
|
+
} | null)[];
|
|
14
|
+
export declare function validateRailwayServiceConfiguration(tenantRoot: any, scope: any): ({
|
|
15
|
+
key: string;
|
|
16
|
+
scope: string;
|
|
17
|
+
projectId: string | null;
|
|
18
|
+
projectName: string | null;
|
|
19
|
+
serviceId: string | null;
|
|
20
|
+
serviceName: string | null;
|
|
21
|
+
rootDir: string;
|
|
22
|
+
publicBaseUrl: string | null;
|
|
23
|
+
railwayEnvironment: string;
|
|
24
|
+
buildCommand: string | null;
|
|
25
|
+
startCommand: string | null;
|
|
26
|
+
} | null)[];
|
|
27
|
+
export declare function validateRailwayDeployPrerequisites(tenantRoot: any, scope: any): ({
|
|
28
|
+
key: string;
|
|
29
|
+
scope: string;
|
|
30
|
+
projectId: string | null;
|
|
31
|
+
projectName: string | null;
|
|
32
|
+
serviceId: string | null;
|
|
33
|
+
serviceName: string | null;
|
|
34
|
+
rootDir: string;
|
|
35
|
+
publicBaseUrl: string | null;
|
|
36
|
+
railwayEnvironment: string;
|
|
37
|
+
buildCommand: string | null;
|
|
38
|
+
startCommand: string | null;
|
|
39
|
+
} | null)[];
|
|
40
|
+
export declare function planRailwayServiceDeploy(service: any): {
|
|
41
|
+
command: string;
|
|
42
|
+
args: any[];
|
|
43
|
+
cwd: any;
|
|
44
|
+
};
|
|
45
|
+
export declare function deployRailwayService(tenantRoot: any, service: any, { dryRun }?: {
|
|
46
|
+
dryRun?: boolean | undefined;
|
|
47
|
+
}): {
|
|
48
|
+
service: any;
|
|
49
|
+
status: string;
|
|
50
|
+
command: string;
|
|
51
|
+
cwd: any;
|
|
52
|
+
publicBaseUrl: any;
|
|
53
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { loadCliDeployConfig } from "./runtime-tools.js";
|
|
5
|
+
function normalizeScope(scope) {
|
|
6
|
+
return scope === "prod" ? "prod" : scope === "staging" ? "staging" : "local";
|
|
7
|
+
}
|
|
8
|
+
const RAILWAY_SERVICE_KEYS = ["api", "agents", "manager", "worker", "workdayStart", "workdayReport"];
|
|
9
|
+
function runRailway(args, { cwd, capture = false, allowFailure = false } = {}) {
|
|
10
|
+
const result = spawnSync("railway", args, {
|
|
11
|
+
cwd,
|
|
12
|
+
stdio: capture ? "pipe" : "inherit",
|
|
13
|
+
encoding: "utf8",
|
|
14
|
+
env: { ...process.env }
|
|
15
|
+
});
|
|
16
|
+
if (result.status !== 0 && !allowFailure) {
|
|
17
|
+
throw new Error(result.stderr?.trim() || result.stdout?.trim() || `railway ${args.join(" ")} failed`);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function configuredRailwayServices(tenantRoot, scope) {
|
|
22
|
+
const deployConfig = loadCliDeployConfig(tenantRoot);
|
|
23
|
+
const normalizedScope = normalizeScope(scope);
|
|
24
|
+
return RAILWAY_SERVICE_KEYS.map((serviceKey) => {
|
|
25
|
+
const service = deployConfig.services?.[serviceKey];
|
|
26
|
+
if (!service || service.enabled === false || (service.provider ?? "railway") !== "railway") {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const defaultRootDir = serviceKey === "api" ? "packages/api" : "packages/agent";
|
|
30
|
+
const serviceRoot = resolve(tenantRoot, service.railway?.rootDir ?? service.rootDir ?? defaultRootDir);
|
|
31
|
+
const railwayEnvironment = service.environments?.[normalizedScope]?.railwayEnvironment ?? normalizedScope;
|
|
32
|
+
const publicBaseUrl = service.environments?.[normalizedScope]?.baseUrl ?? service.publicBaseUrl ?? null;
|
|
33
|
+
return {
|
|
34
|
+
key: serviceKey,
|
|
35
|
+
scope: normalizedScope,
|
|
36
|
+
projectId: service.railway?.projectId ?? null,
|
|
37
|
+
projectName: service.railway?.projectName ?? null,
|
|
38
|
+
serviceId: service.railway?.serviceId ?? null,
|
|
39
|
+
serviceName: service.railway?.serviceName ?? null,
|
|
40
|
+
rootDir: serviceRoot,
|
|
41
|
+
publicBaseUrl,
|
|
42
|
+
railwayEnvironment,
|
|
43
|
+
buildCommand: service.railway?.buildCommand ?? null,
|
|
44
|
+
startCommand: service.railway?.startCommand ?? null
|
|
45
|
+
};
|
|
46
|
+
}).filter(Boolean);
|
|
47
|
+
}
|
|
48
|
+
function validateRailwayServiceConfiguration(tenantRoot, scope) {
|
|
49
|
+
const services = configuredRailwayServices(tenantRoot, scope);
|
|
50
|
+
const issues = [];
|
|
51
|
+
for (const service of services) {
|
|
52
|
+
if (!service.serviceName && !service.serviceId) {
|
|
53
|
+
issues.push(`${service.key}: set railway.serviceName or railway.serviceId in treeseed.site.yaml.`);
|
|
54
|
+
}
|
|
55
|
+
if (!service.projectName && !service.projectId) {
|
|
56
|
+
issues.push(`${service.key}: set railway.projectName or railway.projectId in treeseed.site.yaml.`);
|
|
57
|
+
}
|
|
58
|
+
if (!existsSync(service.rootDir)) {
|
|
59
|
+
issues.push(`${service.key}: service root ${service.rootDir} does not exist.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (issues.length > 0) {
|
|
63
|
+
throw new Error(`Railway service configuration is incomplete:
|
|
64
|
+
- ${issues.join("\n- ")}`);
|
|
65
|
+
}
|
|
66
|
+
return services;
|
|
67
|
+
}
|
|
68
|
+
function validateRailwayDeployPrerequisites(tenantRoot, scope) {
|
|
69
|
+
const services = validateRailwayServiceConfiguration(tenantRoot, scope);
|
|
70
|
+
const token = process.env.RAILWAY_API_TOKEN;
|
|
71
|
+
if (typeof token !== "string" || token.trim().length === 0) {
|
|
72
|
+
throw new Error("Configure RAILWAY_API_TOKEN before deploying Railway-managed services.");
|
|
73
|
+
}
|
|
74
|
+
return services;
|
|
75
|
+
}
|
|
76
|
+
function planRailwayServiceDeploy(service) {
|
|
77
|
+
const args = ["up", "--service", service.serviceName ?? service.serviceId, "--ci"];
|
|
78
|
+
if (service.railwayEnvironment) {
|
|
79
|
+
args.push("--environment", service.railwayEnvironment);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
command: "railway",
|
|
83
|
+
args,
|
|
84
|
+
cwd: service.rootDir
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function deployRailwayService(tenantRoot, service, { dryRun = false } = {}) {
|
|
88
|
+
const plan = planRailwayServiceDeploy(service);
|
|
89
|
+
if (dryRun) {
|
|
90
|
+
return {
|
|
91
|
+
service: service.key,
|
|
92
|
+
status: "planned",
|
|
93
|
+
command: [plan.command, ...plan.args].join(" "),
|
|
94
|
+
cwd: plan.cwd,
|
|
95
|
+
publicBaseUrl: service.publicBaseUrl
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (service.buildCommand) {
|
|
99
|
+
const buildResult = spawnSync("bash", ["-lc", service.buildCommand], {
|
|
100
|
+
cwd: service.rootDir,
|
|
101
|
+
stdio: "inherit",
|
|
102
|
+
env: { ...process.env }
|
|
103
|
+
});
|
|
104
|
+
if (buildResult.status !== 0) {
|
|
105
|
+
throw new Error(`Railway ${service.key} build command failed.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
runRailway(plan.args, { cwd: service.rootDir });
|
|
109
|
+
return {
|
|
110
|
+
service: service.key,
|
|
111
|
+
status: "deployed",
|
|
112
|
+
command: [plan.command, ...plan.args].join(" "),
|
|
113
|
+
cwd: plan.cwd,
|
|
114
|
+
publicBaseUrl: service.publicBaseUrl
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
configuredRailwayServices,
|
|
119
|
+
deployRailwayService,
|
|
120
|
+
planRailwayServiceDeploy,
|
|
121
|
+
validateRailwayDeployPrerequisites,
|
|
122
|
+
validateRailwayServiceConfiguration
|
|
123
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { corePackageRoot, packageRoot } from './runtime-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 templateCatalogRoot: string;
|
|
17
|
+
export declare const localTemplateArtifactsRoot: string;
|
|
18
|
+
export declare const cliPackageVersion: any;
|
|
19
|
+
export declare const corePackageVersion: any;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { corePackageRoot, packageRoot, runtimeRoot } from "./runtime-tools.js";
|
|
5
|
+
const pathsRuntimeRoot = resolve(fileURLToPath(new URL("..", import.meta.url)));
|
|
6
|
+
const cliPackageRoot = packageRoot;
|
|
7
|
+
const cliRuntimeRoot = runtimeRoot ?? pathsRuntimeRoot;
|
|
8
|
+
const workspaceRoot = resolve(cliPackageRoot, "..");
|
|
9
|
+
function resolveProjectRoot(localPath, workspacePath) {
|
|
10
|
+
return existsSync(localPath) ? localPath : workspacePath;
|
|
11
|
+
}
|
|
12
|
+
function readPackageVersion(packageDir, fallback = "0.0.0") {
|
|
13
|
+
const packageJsonPath = resolve(packageDir, "package.json");
|
|
14
|
+
if (!existsSync(packageJsonPath)) {
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
return JSON.parse(readFileSync(packageJsonPath, "utf8")).version ?? fallback;
|
|
18
|
+
}
|
|
19
|
+
const templatesRoot = resolveProjectRoot(resolve(cliPackageRoot, "templates"), resolve(workspaceRoot, "templates"));
|
|
20
|
+
const examplesRoot = resolveProjectRoot(resolve(cliPackageRoot, "examples"), resolve(workspaceRoot, "examples"));
|
|
21
|
+
const fixturesRoot = resolveProjectRoot(resolve(cliPackageRoot, ".fixtures", "treeseed-fixtures"), resolve(workspaceRoot, "fixtures"));
|
|
22
|
+
const referenceAppsRoot = resolveProjectRoot(resolve(cliPackageRoot, "reference-apps"), resolve(workspaceRoot, "reference-apps"));
|
|
23
|
+
const toolingRoot = resolveProjectRoot(resolve(cliPackageRoot, "tooling"), resolve(workspaceRoot, "tooling"));
|
|
24
|
+
const servicesRoot = resolve(cliRuntimeRoot, "services");
|
|
25
|
+
const mailpitComposeFile = resolve(servicesRoot, "compose.yml");
|
|
26
|
+
const fixtureRoot = resolve(corePackageRoot, "fixture");
|
|
27
|
+
const fixtureWranglerConfig = resolve(fixtureRoot, "wrangler.toml");
|
|
28
|
+
const fixtureMigrationsRoot = resolve(fixtureRoot, "migrations");
|
|
29
|
+
const fixtureSrcRoot = resolve(fixtureRoot, "src");
|
|
30
|
+
const templateCatalogRoot = resolve(cliRuntimeRoot, "template-catalog");
|
|
31
|
+
const localTemplateArtifactsRoot = resolve(templateCatalogRoot, "templates");
|
|
32
|
+
const cliPackageVersion = readPackageVersion(cliPackageRoot);
|
|
33
|
+
const corePackageVersion = readPackageVersion(corePackageRoot);
|
|
34
|
+
export {
|
|
35
|
+
cliPackageRoot,
|
|
36
|
+
cliPackageVersion,
|
|
37
|
+
corePackageRoot,
|
|
38
|
+
corePackageVersion,
|
|
39
|
+
examplesRoot,
|
|
40
|
+
fixtureMigrationsRoot,
|
|
41
|
+
fixtureRoot,
|
|
42
|
+
fixtureSrcRoot,
|
|
43
|
+
fixtureWranglerConfig,
|
|
44
|
+
fixturesRoot,
|
|
45
|
+
localTemplateArtifactsRoot,
|
|
46
|
+
mailpitComposeFile,
|
|
47
|
+
packageRoot,
|
|
48
|
+
referenceAppsRoot,
|
|
49
|
+
servicesRoot,
|
|
50
|
+
templateCatalogRoot,
|
|
51
|
+
templatesRoot,
|
|
52
|
+
toolingRoot,
|
|
53
|
+
workspaceRoot
|
|
54
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export declare const packageRoot: string;
|
|
2
|
+
export declare const packageScriptRoot: string;
|
|
3
|
+
export declare const runtimeRoot: string;
|
|
4
|
+
export declare function treeseedWorkspacePackageCheckoutState(root?: string): {
|
|
5
|
+
mode: string;
|
|
6
|
+
packages: {
|
|
7
|
+
dirName: string;
|
|
8
|
+
dir: string;
|
|
9
|
+
present: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
missing: {
|
|
12
|
+
dirName: string;
|
|
13
|
+
dir: string;
|
|
14
|
+
present: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
export declare function resolveAstroBin(): string;
|
|
18
|
+
export declare function resolveWranglerBin(): string;
|
|
19
|
+
export declare const corePackageRoot: string;
|
|
20
|
+
export declare const sdkPackageRoot: string;
|
|
21
|
+
export declare const agentPackageRoot: string;
|
|
22
|
+
export declare function loadPackageJson(root?: string): any;
|
|
23
|
+
export declare function isWorkspaceRoot(root?: string): boolean;
|
|
24
|
+
export declare function createProductionBuildEnv(extraEnv?: {}): {
|
|
25
|
+
TREESEED_LOCAL_DEV_MODE: string;
|
|
26
|
+
TREESEED_PUBLIC_FORMS_LOCAL_BYPASS_TURNSTILE: string;
|
|
27
|
+
TREESEED_FORMS_LOCAL_BYPASS_TURNSTILE: string;
|
|
28
|
+
TREESEED_FORMS_LOCAL_BYPASS_CLOUDFLARE_GUARDS: string;
|
|
29
|
+
TREESEED_PUBLIC_DEV_WATCH_RELOAD: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function packageScriptPath(scriptName: any): string;
|
|
32
|
+
export declare function withProcessCwd(cwd: any, action: any): any;
|
|
33
|
+
export declare function loadCliDeployConfig(tenantRoot: any): {
|
|
34
|
+
name: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
siteUrl: string;
|
|
37
|
+
contactEmail: string;
|
|
38
|
+
cloudflare: {
|
|
39
|
+
accountId: string;
|
|
40
|
+
workerName: string | undefined;
|
|
41
|
+
gatewayWorkerName: string | undefined;
|
|
42
|
+
queueName: string | undefined;
|
|
43
|
+
dlqName: string | undefined;
|
|
44
|
+
d1Binding: string | undefined;
|
|
45
|
+
queueBinding: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
plugins: {
|
|
48
|
+
package: string;
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
}[] | {
|
|
51
|
+
package: string;
|
|
52
|
+
enabled: boolean | undefined;
|
|
53
|
+
config: any;
|
|
54
|
+
}[];
|
|
55
|
+
providers: {
|
|
56
|
+
forms: string;
|
|
57
|
+
agents: {
|
|
58
|
+
execution: string;
|
|
59
|
+
mutation: string;
|
|
60
|
+
repository: string;
|
|
61
|
+
verification: string;
|
|
62
|
+
notification: string;
|
|
63
|
+
research: string;
|
|
64
|
+
};
|
|
65
|
+
deploy: string;
|
|
66
|
+
content: {
|
|
67
|
+
docs: string;
|
|
68
|
+
};
|
|
69
|
+
site: string;
|
|
70
|
+
};
|
|
71
|
+
services: {
|
|
72
|
+
[k: string]: {
|
|
73
|
+
enabled: boolean | undefined;
|
|
74
|
+
provider: string | undefined;
|
|
75
|
+
rootDir: string | undefined;
|
|
76
|
+
publicBaseUrl: string | undefined;
|
|
77
|
+
cloudflare: {
|
|
78
|
+
workerName: string | undefined;
|
|
79
|
+
};
|
|
80
|
+
railway: {
|
|
81
|
+
projectId: string | undefined;
|
|
82
|
+
projectName: string | undefined;
|
|
83
|
+
serviceId: string | undefined;
|
|
84
|
+
serviceName: string | undefined;
|
|
85
|
+
rootDir: string | undefined;
|
|
86
|
+
buildCommand: string | undefined;
|
|
87
|
+
startCommand: string | undefined;
|
|
88
|
+
};
|
|
89
|
+
environments: {
|
|
90
|
+
local: {
|
|
91
|
+
baseUrl: string | undefined;
|
|
92
|
+
domain: string | undefined;
|
|
93
|
+
railwayEnvironment: string | undefined;
|
|
94
|
+
};
|
|
95
|
+
staging: {
|
|
96
|
+
baseUrl: string | undefined;
|
|
97
|
+
domain: string | undefined;
|
|
98
|
+
railwayEnvironment: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
prod: {
|
|
101
|
+
baseUrl: string | undefined;
|
|
102
|
+
domain: string | undefined;
|
|
103
|
+
railwayEnvironment: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
} | undefined;
|
|
107
|
+
} | undefined;
|
|
108
|
+
smtp: {
|
|
109
|
+
enabled: boolean | undefined;
|
|
110
|
+
};
|
|
111
|
+
turnstile: {
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export declare function runNodeBinary(binPath: any, args: any, options?: {}): void;
|
|
116
|
+
export declare function runNodeScript(scriptPath: any, args?: never[], options?: {}): void;
|
|
117
|
+
export declare function spawnNodeBinary(binPath: any, args: any, options?: {}): import("child_process").ChildProcessWithoutNullStreams;
|