@treeseed/cli 0.1.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.
Files changed (200) hide show
  1. package/README.md +27 -26
  2. package/dist/cli/handlers/auth-login.d.ts +2 -0
  3. package/dist/cli/handlers/auth-login.js +67 -0
  4. package/dist/cli/handlers/auth-logout.d.ts +2 -0
  5. package/dist/cli/handlers/auth-logout.js +20 -0
  6. package/dist/cli/handlers/auth-whoami.d.ts +2 -0
  7. package/dist/cli/handlers/auth-whoami.js +24 -0
  8. package/dist/cli/handlers/close.js +19 -53
  9. package/dist/cli/handlers/config.js +33 -53
  10. package/dist/cli/handlers/destroy.js +34 -79
  11. package/dist/{src/cli/handlers/ship.d.ts → cli/handlers/dev.d.ts} +1 -1
  12. package/dist/cli/handlers/dev.js +19 -0
  13. package/dist/cli/handlers/doctor.js +13 -6
  14. package/dist/cli/handlers/init.js +32 -8
  15. package/dist/cli/handlers/release.js +21 -53
  16. package/dist/cli/handlers/rollback.js +8 -8
  17. package/dist/cli/handlers/save.js +21 -79
  18. package/dist/cli/handlers/stage.d.ts +2 -0
  19. package/dist/cli/handlers/stage.js +28 -0
  20. package/dist/cli/handlers/status.js +35 -26
  21. package/dist/{src/cli/handlers/deploy.d.ts → cli/handlers/switch.d.ts} +1 -1
  22. package/dist/cli/handlers/switch.js +29 -0
  23. package/dist/{src/cli/handlers/next.d.ts → cli/handlers/sync.d.ts} +1 -1
  24. package/dist/cli/handlers/sync.js +26 -0
  25. package/dist/cli/handlers/tasks.d.ts +2 -0
  26. package/dist/cli/handlers/tasks.js +31 -0
  27. package/dist/cli/handlers/template.d.ts +2 -0
  28. package/dist/cli/handlers/template.js +27 -0
  29. package/dist/cli/handlers/workflow.d.ts +6 -0
  30. package/dist/cli/handlers/workflow.js +71 -0
  31. package/dist/{src/cli → cli}/help.d.ts +2 -2
  32. package/dist/cli/help.js +36 -24
  33. package/dist/cli/main.d.ts +6 -0
  34. package/dist/cli/main.js +14 -19
  35. package/dist/cli/operations-help.d.ts +1 -0
  36. package/dist/cli/operations-help.js +1 -0
  37. package/dist/cli/operations-parser.d.ts +1 -0
  38. package/dist/cli/operations-parser.js +1 -0
  39. package/dist/cli/operations-registry.d.ts +5 -0
  40. package/dist/cli/operations-registry.js +260 -0
  41. package/dist/cli/operations-types.d.ts +72 -0
  42. package/dist/cli/parser.d.ts +3 -0
  43. package/dist/cli/parser.js +1 -6
  44. package/dist/cli/registry.d.ts +25 -0
  45. package/dist/cli/registry.js +28 -416
  46. package/dist/cli/repair.js +6 -4
  47. package/dist/cli/runtime.d.ts +31 -0
  48. package/dist/cli/runtime.js +240 -111
  49. package/dist/cli/types.d.ts +1 -0
  50. package/dist/{src/cli → cli}/workflow-state.d.ts +9 -0
  51. package/dist/cli/workflow-state.js +45 -21
  52. package/package.json +13 -13
  53. package/dist/cli/handlers/continue.js +0 -23
  54. package/dist/cli/handlers/deploy.js +0 -139
  55. package/dist/cli/handlers/next.js +0 -27
  56. package/dist/cli/handlers/prepare.js +0 -8
  57. package/dist/cli/handlers/promote.js +0 -8
  58. package/dist/cli/handlers/publish.js +0 -8
  59. package/dist/cli/handlers/setup.js +0 -48
  60. package/dist/cli/handlers/ship.js +0 -49
  61. package/dist/cli/handlers/start.js +0 -97
  62. package/dist/cli/handlers/teardown.js +0 -50
  63. package/dist/cli/handlers/work.js +0 -85
  64. package/dist/scripts/aggregate-book.d.ts +0 -1
  65. package/dist/scripts/aggregate-book.js +0 -121
  66. package/dist/scripts/assert-release-tag-version.d.ts +0 -1
  67. package/dist/scripts/assert-release-tag-version.js +0 -21
  68. package/dist/scripts/build-dist.d.ts +0 -1
  69. package/dist/scripts/build-dist.js +0 -108
  70. package/dist/scripts/build-tenant-worker.d.ts +0 -1
  71. package/dist/scripts/build-tenant-worker.js +0 -36
  72. package/dist/scripts/cleanup-markdown.d.ts +0 -2
  73. package/dist/scripts/cleanup-markdown.js +0 -373
  74. package/dist/scripts/config-runtime-lib.d.ts +0 -122
  75. package/dist/scripts/config-runtime-lib.js +0 -505
  76. package/dist/scripts/config-treeseed.d.ts +0 -2
  77. package/dist/scripts/config-treeseed.js +0 -81
  78. package/dist/scripts/d1-migration-lib.d.ts +0 -6
  79. package/dist/scripts/d1-migration-lib.js +0 -90
  80. package/dist/scripts/deploy-lib.d.ts +0 -127
  81. package/dist/scripts/deploy-lib.js +0 -841
  82. package/dist/scripts/ensure-mailpit.d.ts +0 -1
  83. package/dist/scripts/ensure-mailpit.js +0 -29
  84. package/dist/scripts/git-workflow-lib.d.ts +0 -25
  85. package/dist/scripts/git-workflow-lib.js +0 -136
  86. package/dist/scripts/github-automation-lib.d.ts +0 -156
  87. package/dist/scripts/github-automation-lib.js +0 -242
  88. package/dist/scripts/local-dev-lib.d.ts +0 -9
  89. package/dist/scripts/local-dev-lib.js +0 -84
  90. package/dist/scripts/local-dev.d.ts +0 -1
  91. package/dist/scripts/local-dev.js +0 -129
  92. package/dist/scripts/logs-mailpit.d.ts +0 -1
  93. package/dist/scripts/logs-mailpit.js +0 -2
  94. package/dist/scripts/mailpit-runtime.d.ts +0 -4
  95. package/dist/scripts/mailpit-runtime.js +0 -57
  96. package/dist/scripts/package-tools.d.ts +0 -22
  97. package/dist/scripts/package-tools.js +0 -255
  98. package/dist/scripts/patch-starlight-content-path.d.ts +0 -1
  99. package/dist/scripts/patch-starlight-content-path.js +0 -172
  100. package/dist/scripts/paths.d.ts +0 -17
  101. package/dist/scripts/paths.js +0 -26
  102. package/dist/scripts/publish-package.d.ts +0 -1
  103. package/dist/scripts/publish-package.js +0 -19
  104. package/dist/scripts/release-verify.d.ts +0 -1
  105. package/dist/scripts/release-verify.js +0 -136
  106. package/dist/scripts/run-fixture-astro-command.d.ts +0 -1
  107. package/dist/scripts/run-fixture-astro-command.js +0 -18
  108. package/dist/scripts/save-deploy-preflight-lib.d.ts +0 -34
  109. package/dist/scripts/save-deploy-preflight-lib.js +0 -69
  110. package/dist/scripts/scaffold-site.d.ts +0 -2
  111. package/dist/scripts/scaffold-site.js +0 -92
  112. package/dist/scripts/stop-mailpit.d.ts +0 -1
  113. package/dist/scripts/stop-mailpit.js +0 -5
  114. package/dist/scripts/sync-dev-vars.d.ts +0 -1
  115. package/dist/scripts/sync-dev-vars.js +0 -6
  116. package/dist/scripts/template-registry-lib.d.ts +0 -47
  117. package/dist/scripts/template-registry-lib.js +0 -137
  118. package/dist/scripts/tenant-astro-command.d.ts +0 -1
  119. package/dist/scripts/tenant-astro-command.js +0 -3
  120. package/dist/scripts/tenant-build.d.ts +0 -1
  121. package/dist/scripts/tenant-build.js +0 -16
  122. package/dist/scripts/tenant-check.d.ts +0 -1
  123. package/dist/scripts/tenant-check.js +0 -7
  124. package/dist/scripts/tenant-d1-migrate-local.d.ts +0 -1
  125. package/dist/scripts/tenant-d1-migrate-local.js +0 -11
  126. package/dist/scripts/tenant-deploy.d.ts +0 -2
  127. package/dist/scripts/tenant-deploy.js +0 -180
  128. package/dist/scripts/tenant-destroy.d.ts +0 -2
  129. package/dist/scripts/tenant-destroy.js +0 -104
  130. package/dist/scripts/tenant-dev.d.ts +0 -1
  131. package/dist/scripts/tenant-dev.js +0 -171
  132. package/dist/scripts/tenant-lint.d.ts +0 -1
  133. package/dist/scripts/tenant-lint.js +0 -4
  134. package/dist/scripts/tenant-test.d.ts +0 -1
  135. package/dist/scripts/tenant-test.js +0 -4
  136. package/dist/scripts/test-cloudflare-local.d.ts +0 -1
  137. package/dist/scripts/test-cloudflare-local.js +0 -212
  138. package/dist/scripts/test-scaffold.d.ts +0 -2
  139. package/dist/scripts/test-scaffold.js +0 -297
  140. package/dist/scripts/treeseed.d.ts +0 -2
  141. package/dist/scripts/treeseed.js +0 -4
  142. package/dist/scripts/validate-templates.d.ts +0 -2
  143. package/dist/scripts/validate-templates.js +0 -4
  144. package/dist/scripts/watch-dev-lib.d.ts +0 -21
  145. package/dist/scripts/watch-dev-lib.js +0 -277
  146. package/dist/scripts/workspace-close.d.ts +0 -2
  147. package/dist/scripts/workspace-close.js +0 -24
  148. package/dist/scripts/workspace-command-e2e.d.ts +0 -2
  149. package/dist/scripts/workspace-command-e2e.js +0 -718
  150. package/dist/scripts/workspace-lint.d.ts +0 -1
  151. package/dist/scripts/workspace-lint.js +0 -9
  152. package/dist/scripts/workspace-preflight-lib.d.ts +0 -36
  153. package/dist/scripts/workspace-preflight-lib.js +0 -179
  154. package/dist/scripts/workspace-preflight.d.ts +0 -2
  155. package/dist/scripts/workspace-preflight.js +0 -22
  156. package/dist/scripts/workspace-publish-changed-packages.d.ts +0 -1
  157. package/dist/scripts/workspace-publish-changed-packages.js +0 -16
  158. package/dist/scripts/workspace-release-verify.d.ts +0 -1
  159. package/dist/scripts/workspace-release-verify.js +0 -81
  160. package/dist/scripts/workspace-release.d.ts +0 -2
  161. package/dist/scripts/workspace-release.js +0 -42
  162. package/dist/scripts/workspace-save-lib.d.ts +0 -42
  163. package/dist/scripts/workspace-save-lib.js +0 -220
  164. package/dist/scripts/workspace-save.d.ts +0 -2
  165. package/dist/scripts/workspace-save.js +0 -124
  166. package/dist/scripts/workspace-start-warning.js +0 -3
  167. package/dist/scripts/workspace-start.d.ts +0 -2
  168. package/dist/scripts/workspace-start.js +0 -71
  169. package/dist/scripts/workspace-test-unit.d.ts +0 -1
  170. package/dist/scripts/workspace-test-unit.js +0 -4
  171. package/dist/scripts/workspace-test.d.ts +0 -1
  172. package/dist/scripts/workspace-test.js +0 -11
  173. package/dist/scripts/workspace-tools.d.ts +0 -13
  174. package/dist/scripts/workspace-tools.js +0 -226
  175. package/dist/src/cli/handlers/continue.d.ts +0 -2
  176. package/dist/src/cli/handlers/prepare.d.ts +0 -2
  177. package/dist/src/cli/handlers/promote.d.ts +0 -2
  178. package/dist/src/cli/handlers/publish.d.ts +0 -2
  179. package/dist/src/cli/handlers/setup.d.ts +0 -2
  180. package/dist/src/cli/handlers/start.d.ts +0 -3
  181. package/dist/src/cli/handlers/teardown.d.ts +0 -2
  182. package/dist/src/cli/handlers/work.d.ts +0 -2
  183. package/dist/src/cli/main.d.ts +0 -6
  184. package/dist/src/cli/parser.d.ts +0 -3
  185. package/dist/src/cli/registry.d.ts +0 -27
  186. package/dist/src/cli/runtime.d.ts +0 -4
  187. package/dist/src/cli/types.d.ts +0 -71
  188. /package/dist/{src/cli → cli}/handlers/close.d.ts +0 -0
  189. /package/dist/{src/cli → cli}/handlers/config.d.ts +0 -0
  190. /package/dist/{src/cli → cli}/handlers/destroy.d.ts +0 -0
  191. /package/dist/{src/cli → cli}/handlers/doctor.d.ts +0 -0
  192. /package/dist/{src/cli → cli}/handlers/init.d.ts +0 -0
  193. /package/dist/{src/cli → cli}/handlers/release.d.ts +0 -0
  194. /package/dist/{src/cli → cli}/handlers/rollback.d.ts +0 -0
  195. /package/dist/{src/cli → cli}/handlers/save.d.ts +0 -0
  196. /package/dist/{src/cli → cli}/handlers/status.d.ts +0 -0
  197. /package/dist/{src/cli → cli}/handlers/utils.d.ts +0 -0
  198. /package/dist/{scripts/workspace-start-warning.d.ts → cli/operations-types.js} +0 -0
  199. /package/dist/{src/cli → cli}/repair.d.ts +0 -0
  200. /package/dist/{src/index.d.ts → index.d.ts} +0 -0
@@ -1,139 +0,0 @@
1
- import { applyTreeseedEnvironmentToProcess } from "../../scripts/config-runtime-lib.js";
2
- import {
3
- assertDeploymentInitialized,
4
- createBranchPreviewDeployTarget,
5
- createPersistentDeployTarget,
6
- deployTargetLabel,
7
- ensureGeneratedWranglerConfig,
8
- finalizeDeploymentState,
9
- runRemoteD1Migrations
10
- } from "../../scripts/deploy-lib.js";
11
- import { currentManagedBranch, PRODUCTION_BRANCH, STAGING_BRANCH } from "../../scripts/git-workflow-lib.js";
12
- import { packageScriptPath, resolveWranglerBin } from "../../scripts/package-tools.js";
13
- import { runTenantDeployPreflight } from "../../scripts/save-deploy-preflight-lib.js";
14
- import { guidedResult } from "./utils.js";
15
- function inferEnvironmentFromBranch(tenantRoot) {
16
- const branch = currentManagedBranch(tenantRoot);
17
- if (branch === STAGING_BRANCH) return "staging";
18
- if (branch === PRODUCTION_BRANCH) return "prod";
19
- return null;
20
- }
21
- const handleDeploy = (invocation, context) => {
22
- const commandName = invocation.commandName || "deploy";
23
- const tenantRoot = context.cwd;
24
- const environment = typeof invocation.args.environment === "string" ? invocation.args.environment : void 0;
25
- const targetBranch = typeof invocation.args.targetBranch === "string" ? invocation.args.targetBranch : void 0;
26
- const dryRun = invocation.args.dryRun === true;
27
- const only = typeof invocation.args.only === "string" ? invocation.args.only : null;
28
- const name = typeof invocation.args.name === "string" ? invocation.args.name : null;
29
- const target = targetBranch ? createBranchPreviewDeployTarget(targetBranch) : createPersistentDeployTarget(environment ?? (context.env.CI ? inferEnvironmentFromBranch(tenantRoot) : null));
30
- const scope = targetBranch ? "staging" : String(environment ?? (context.env.CI ? inferEnvironmentFromBranch(tenantRoot) : ""));
31
- const executedSteps = [];
32
- const nextSteps = [];
33
- let deployUrl = null;
34
- let migratedDatabase = null;
35
- applyTreeseedEnvironmentToProcess({ tenantRoot, scope });
36
- const allowedSteps = /* @__PURE__ */ new Set(["migrate", "build", "publish"]);
37
- if (only && !allowedSteps.has(only)) {
38
- throw new Error(`Unsupported deploy step "${only}". Expected one of ${[...allowedSteps].join(", ")}.`);
39
- }
40
- const shouldRun = (step) => !only || only === step;
41
- if (scope === "local") {
42
- runTenantDeployPreflight({ cwd: tenantRoot, scope: "local" });
43
- const buildOnly = context.spawn(process.execPath, [packageScriptPath("tenant-build")], {
44
- cwd: tenantRoot,
45
- env: { ...context.env },
46
- stdio: "inherit"
47
- });
48
- return guidedResult({
49
- command: commandName,
50
- summary: buildOnly.status === 0 ? "Treeseed local deploy completed as a build-only publish target." : "Treeseed local deploy failed.",
51
- exitCode: buildOnly.status ?? 1,
52
- facts: [
53
- { label: "Target", value: "local" },
54
- { label: "Dry run", value: dryRun ? "yes" : "no" }
55
- ],
56
- nextSteps: buildOnly.status === 0 ? ["treeseed preview", 'treeseed save "describe your change"'] : ["treeseed doctor"],
57
- report: {
58
- target: "local",
59
- dryRun,
60
- only,
61
- name,
62
- executedSteps: ["build"]
63
- }
64
- });
65
- }
66
- assertDeploymentInitialized(tenantRoot, { target });
67
- runTenantDeployPreflight({ cwd: tenantRoot, scope });
68
- const { wranglerPath } = ensureGeneratedWranglerConfig(tenantRoot, { target });
69
- if (shouldRun("migrate")) {
70
- const result = runRemoteD1Migrations(tenantRoot, { dryRun, target });
71
- executedSteps.push("migrate");
72
- migratedDatabase = result.databaseName;
73
- }
74
- if (shouldRun("build")) {
75
- if (dryRun) {
76
- executedSteps.push("build");
77
- } else {
78
- const buildResult = context.spawn(process.execPath, [packageScriptPath("tenant-build")], {
79
- cwd: tenantRoot,
80
- env: { ...context.env },
81
- stdio: "inherit"
82
- });
83
- if ((buildResult.status ?? 1) !== 0) {
84
- return { exitCode: buildResult.status ?? 1 };
85
- }
86
- executedSteps.push("build");
87
- }
88
- }
89
- if (shouldRun("publish")) {
90
- if (dryRun) {
91
- executedSteps.push("publish");
92
- } else {
93
- const publishResult = context.spawn(process.execPath, [resolveWranglerBin(), "deploy", "--config", wranglerPath], {
94
- cwd: tenantRoot,
95
- env: { ...context.env },
96
- stdio: "inherit"
97
- });
98
- if ((publishResult.status ?? 1) !== 0) {
99
- return { exitCode: publishResult.status ?? 1 };
100
- }
101
- const finalizedState = finalizeDeploymentState(tenantRoot, { target });
102
- deployUrl = finalizedState.lastDeployedUrl ?? null;
103
- executedSteps.push("publish");
104
- }
105
- }
106
- if (scope === "staging") {
107
- nextSteps.push("treeseed release --patch");
108
- }
109
- if (scope !== "local") {
110
- nextSteps.push(`treeseed status`);
111
- }
112
- return guidedResult({
113
- command: commandName,
114
- summary: dryRun ? `Treeseed ${commandName} dry run completed for ${deployTargetLabel(target)}.` : `Treeseed ${commandName} completed for ${deployTargetLabel(target)}.`,
115
- facts: [
116
- { label: "Target", value: deployTargetLabel(target) },
117
- { label: "Target label", value: name ?? "(none)" },
118
- { label: "Dry run", value: dryRun ? "yes" : "no" },
119
- { label: "Executed steps", value: executedSteps.join(", ") || "(none)" },
120
- { label: "Migrated database", value: migratedDatabase ?? "(none)" },
121
- { label: "Preview URL", value: deployUrl ?? (dryRun ? "(dry run)" : "(not reported)") }
122
- ],
123
- nextSteps,
124
- report: {
125
- target: deployTargetLabel(target),
126
- scope,
127
- dryRun,
128
- only,
129
- name,
130
- wranglerPath,
131
- executedSteps,
132
- migratedDatabase,
133
- deployUrl
134
- }
135
- });
136
- };
137
- export {
138
- handleDeploy
139
- };
@@ -1,27 +0,0 @@
1
- import { guidedResult } from "./utils.js";
2
- import { resolveTreeseedWorkflowState } from "../workflow-state.js";
3
- const handleNext = (_invocation, context) => {
4
- const state = resolveTreeseedWorkflowState(context.cwd);
5
- return guidedResult({
6
- command: "next",
7
- summary: "Treeseed next-step recommendations",
8
- facts: [
9
- { label: "Branch", value: state.branchName ?? "(none)" },
10
- { label: "Branch role", value: state.branchRole },
11
- { label: "Dirty worktree", value: state.dirtyWorktree ? "yes" : "no" }
12
- ],
13
- nextSteps: state.recommendations.map((item) => `${item.command} # ${item.reason}`),
14
- report: {
15
- state: {
16
- branchName: state.branchName,
17
- branchRole: state.branchRole,
18
- dirtyWorktree: state.dirtyWorktree,
19
- environment: state.environment
20
- },
21
- recommendations: state.recommendations
22
- }
23
- });
24
- };
25
- export {
26
- handleNext
27
- };
@@ -1,8 +0,0 @@
1
- import { handleConfig } from "./config.js";
2
- const handlePrepare = (invocation, context) => handleConfig({
3
- ...invocation,
4
- commandName: invocation.commandName || "prepare"
5
- }, context);
6
- export {
7
- handlePrepare
8
- };
@@ -1,8 +0,0 @@
1
- import { handleRelease } from "./release.js";
2
- const handlePromote = (invocation, context) => handleRelease({
3
- ...invocation,
4
- commandName: invocation.commandName || "promote"
5
- }, context);
6
- export {
7
- handlePromote
8
- };
@@ -1,8 +0,0 @@
1
- import { handleDeploy } from "./deploy.js";
2
- const handlePublish = (invocation, context) => handleDeploy({
3
- ...invocation,
4
- commandName: invocation.commandName || "publish"
5
- }, context);
6
- export {
7
- handlePublish
8
- };
@@ -1,48 +0,0 @@
1
- import { handleConfig } from "./config.js";
2
- import { handleDoctor } from "./doctor.js";
3
- import { guidedResult } from "./utils.js";
4
- import { applyTreeseedSafeRepairs } from "../repair.js";
5
- import { resolveTreeseedWorkflowState } from "../workflow-state.js";
6
- const handleSetup = async (invocation, context) => {
7
- const tenantRoot = context.cwd;
8
- const scopes = Array.isArray(invocation.args.environment) ? invocation.args.environment : invocation.args.environment ? [invocation.args.environment] : ["local"];
9
- const repairs = resolveTreeseedWorkflowState(tenantRoot).deployConfigPresent ? applyTreeseedSafeRepairs(tenantRoot) : [];
10
- const configResult = await handleConfig({
11
- ...invocation,
12
- commandName: "config",
13
- args: {
14
- ...invocation.args,
15
- environment: scopes,
16
- sync: invocation.args.sync ?? "none"
17
- },
18
- positionals: [],
19
- rawArgs: [
20
- ...scopes.flatMap((scope) => ["--environment", scope]),
21
- ...invocation.args.json === true ? ["--json"] : []
22
- ]
23
- }, context);
24
- if ((configResult.exitCode ?? 0) !== 0) {
25
- return configResult;
26
- }
27
- const doctorResult = handleDoctor({ ...invocation, args: { ...invocation.args } }, context);
28
- const doctorPayload = doctorResult.report ?? {};
29
- return guidedResult({
30
- command: "setup",
31
- summary: "Treeseed setup completed.",
32
- facts: [
33
- { label: "Initialized environments", value: scopes.join(", ") },
34
- { label: "Safe repairs", value: repairs.length },
35
- { label: "Blocking issues remaining", value: Array.isArray(doctorPayload.mustFixNow) ? doctorPayload.mustFixNow?.length ?? 0 : 0 }
36
- ],
37
- nextSteps: ["treeseed dev", "treeseed work feature/my-change"],
38
- report: {
39
- repairs,
40
- scopes,
41
- config: configResult.report,
42
- doctor: doctorPayload
43
- }
44
- });
45
- };
46
- export {
47
- handleSetup
48
- };
@@ -1,49 +0,0 @@
1
- import { guidedResult } from "./utils.js";
2
- import { handleSave } from "./save.js";
3
- import { handleDeploy } from "./deploy.js";
4
- import { resolveTreeseedWorkflowState } from "../workflow-state.js";
5
- const handleShip = async (invocation, context) => {
6
- const beforeState = resolveTreeseedWorkflowState(context.cwd);
7
- const saveResult = await handleSave({
8
- ...invocation,
9
- commandName: "save"
10
- }, context);
11
- if ((saveResult.exitCode ?? 0) !== 0) {
12
- return saveResult;
13
- }
14
- let previewRefresh = null;
15
- if (beforeState.branchRole === "feature" && beforeState.preview.enabled && beforeState.branchName) {
16
- const publishResult = await handleDeploy({
17
- commandName: "deploy",
18
- args: {
19
- targetBranch: beforeState.branchName,
20
- json: invocation.args.json
21
- },
22
- positionals: [],
23
- rawArgs: ["--target-branch", beforeState.branchName, ...invocation.args.json === true ? ["--json"] : []]
24
- }, context);
25
- if ((publishResult.exitCode ?? 0) !== 0) {
26
- return publishResult;
27
- }
28
- previewRefresh = publishResult.report ?? null;
29
- }
30
- const afterState = resolveTreeseedWorkflowState(context.cwd);
31
- return guidedResult({
32
- command: "ship",
33
- summary: "Treeseed ship completed successfully.",
34
- facts: [
35
- { label: "Branch", value: afterState.branchName ?? beforeState.branchName ?? "(none)" },
36
- { label: "Branch role", value: afterState.branchRole },
37
- { label: "Preview refreshed", value: previewRefresh ? "yes" : "no" }
38
- ],
39
- nextSteps: afterState.recommendations.map((item) => `${item.command} # ${item.reason}`),
40
- report: {
41
- state: afterState,
42
- save: saveResult.report,
43
- previewRefresh
44
- }
45
- });
46
- };
47
- export {
48
- handleShip
49
- };
@@ -1,97 +0,0 @@
1
- import {
2
- applyTreeseedEnvironmentToProcess,
3
- assertTreeseedCommandEnvironment
4
- } from "../../scripts/config-runtime-lib.js";
5
- import {
6
- createBranchPreviewDeployTarget,
7
- deployTargetLabel,
8
- ensureGeneratedWranglerConfig,
9
- finalizeDeploymentState,
10
- printDeploySummary,
11
- provisionCloudflareResources,
12
- runRemoteD1Migrations,
13
- syncCloudflareSecrets,
14
- validateDeployPrerequisites
15
- } from "../../scripts/deploy-lib.js";
16
- import { createFeatureBranchFromStaging, pushBranch } from "../../scripts/git-workflow-lib.js";
17
- import { packageScriptPath, resolveWranglerBin } from "../../scripts/package-tools.js";
18
- import { guidedResult } from "./utils.js";
19
- function provisionBranchPreview(branchName, context, commandName = "start") {
20
- const tenantRoot = context.cwd;
21
- applyTreeseedEnvironmentToProcess({ tenantRoot, scope: "staging" });
22
- assertTreeseedCommandEnvironment({ tenantRoot, scope: "staging", purpose: "deploy" });
23
- validateDeployPrerequisites(tenantRoot, { requireRemote: true });
24
- const target = createBranchPreviewDeployTarget(branchName);
25
- const summary = provisionCloudflareResources(tenantRoot, { target });
26
- printDeploySummary(summary);
27
- const { wranglerPath } = ensureGeneratedWranglerConfig(tenantRoot, { target });
28
- syncCloudflareSecrets(tenantRoot, { target });
29
- runRemoteD1Migrations(tenantRoot, { target });
30
- const buildResult = context.spawn(process.execPath, [packageScriptPath("tenant-build")], {
31
- cwd: tenantRoot,
32
- env: { ...context.env },
33
- stdio: "inherit"
34
- });
35
- if ((buildResult.status ?? 1) !== 0) {
36
- return { exitCode: buildResult.status ?? 1 };
37
- }
38
- const deployResult = context.spawn(process.execPath, [resolveWranglerBin(), "deploy", "--config", wranglerPath], {
39
- cwd: tenantRoot,
40
- env: { ...context.env },
41
- stdio: "inherit"
42
- });
43
- if ((deployResult.status ?? 1) !== 0) {
44
- return { exitCode: deployResult.status ?? 1 };
45
- }
46
- const state = finalizeDeploymentState(tenantRoot, { target });
47
- return guidedResult({
48
- command: commandName,
49
- summary: `Treeseed ${commandName} preview completed for ${branchName}.`,
50
- facts: [
51
- { label: "Target", value: deployTargetLabel(target) },
52
- { label: "Preview URL", value: state.lastDeployedUrl }
53
- ],
54
- nextSteps: [
55
- 'treeseed save "describe your change"',
56
- `treeseed deploy --target-branch ${branchName}`
57
- ],
58
- report: {
59
- branchName,
60
- preview: true,
61
- target: deployTargetLabel(target),
62
- previewUrl: state.lastDeployedUrl
63
- }
64
- });
65
- }
66
- const handleStart = (invocation, context) => {
67
- const commandName = invocation.commandName || "start";
68
- const branchName = invocation.positionals[0];
69
- const preview = invocation.args.preview === true;
70
- const tenantRoot = context.cwd;
71
- const result = createFeatureBranchFromStaging(tenantRoot, branchName);
72
- pushBranch(result.repoDir, branchName, { setUpstream: true });
73
- if (!preview) {
74
- return guidedResult({
75
- command: commandName,
76
- summary: `Created feature branch ${branchName} from staging.`,
77
- facts: [
78
- { label: "Branch", value: branchName },
79
- { label: "Preview", value: "disabled" }
80
- ],
81
- nextSteps: [
82
- "treeseed dev",
83
- 'treeseed save "describe your change"'
84
- ],
85
- report: {
86
- branchName,
87
- preview: false,
88
- baseBranch: result.baseBranch
89
- }
90
- });
91
- }
92
- return provisionBranchPreview(branchName, context, commandName);
93
- };
94
- export {
95
- handleStart,
96
- provisionBranchPreview
97
- };
@@ -1,50 +0,0 @@
1
- import { currentManagedBranch, PRODUCTION_BRANCH, STAGING_BRANCH } from "../../scripts/git-workflow-lib.js";
2
- import { guidedResult } from "./utils.js";
3
- import { handleClose } from "./close.js";
4
- import { handleDestroy } from "./destroy.js";
5
- const handleTeardown = async (invocation, context) => {
6
- const commandName = invocation.commandName || "teardown";
7
- const environment = typeof invocation.args.environment === "string" ? invocation.args.environment : null;
8
- if (environment) {
9
- return handleDestroy({
10
- ...invocation,
11
- commandName
12
- }, context);
13
- }
14
- const branch = currentManagedBranch(context.cwd);
15
- if (!branch || branch === STAGING_BRANCH || branch === PRODUCTION_BRANCH) {
16
- return guidedResult({
17
- command: commandName,
18
- summary: "Treeseed teardown needs an explicit persistent environment on staging or main.",
19
- facts: [{ label: "Current branch", value: branch ?? "(none)" }],
20
- nextSteps: [
21
- "treeseed teardown --environment staging",
22
- "treeseed teardown --environment prod"
23
- ],
24
- report: {
25
- branch
26
- },
27
- exitCode: 1
28
- });
29
- }
30
- if (invocation.args.dryRun === true) {
31
- return guidedResult({
32
- command: commandName,
33
- summary: `Dry run: Treeseed would merge ${branch} into staging and remove any branch preview artifacts.`,
34
- facts: [{ label: "Branch", value: branch }],
35
- nextSteps: ["treeseed teardown"],
36
- report: {
37
- branch,
38
- dryRun: true,
39
- mode: "feature-close"
40
- }
41
- });
42
- }
43
- return handleClose({
44
- ...invocation,
45
- commandName
46
- }, context);
47
- };
48
- export {
49
- handleTeardown
50
- };
@@ -1,85 +0,0 @@
1
- import {
2
- assertCleanWorktree,
3
- branchExists,
4
- checkoutBranch,
5
- currentManagedBranch,
6
- ensureLocalBranchTracking,
7
- gitWorkflowRoot,
8
- remoteBranchExists,
9
- syncBranchWithOrigin
10
- } from "../../scripts/git-workflow-lib.js";
11
- import { guidedResult } from "./utils.js";
12
- import { provisionBranchPreview } from "./start.js";
13
- import { handleStart } from "./start.js";
14
- import { resolveTreeseedWorkflowState } from "../workflow-state.js";
15
- const handleWork = async (invocation, context) => {
16
- const commandName = invocation.commandName || "work";
17
- const branchName = invocation.positionals[0];
18
- const preview = invocation.args.preview === true;
19
- const repoDir = gitWorkflowRoot(context.cwd);
20
- const currentBranch = currentManagedBranch(context.cwd);
21
- if (currentBranch === branchName) {
22
- const state2 = resolveTreeseedWorkflowState(context.cwd);
23
- if (preview && !state2.preview.enabled) {
24
- return provisionBranchPreview(branchName, context, commandName);
25
- }
26
- return guidedResult({
27
- command: commandName,
28
- summary: `Already working on ${branchName}.`,
29
- facts: [
30
- { label: "Branch", value: branchName },
31
- { label: "Preview", value: state2.preview.enabled ? "enabled" : "disabled" },
32
- { label: "Preview URL", value: state2.preview.url ?? "(none)" }
33
- ],
34
- nextSteps: [
35
- preview && !state2.preview.enabled ? `treeseed work ${branchName} --preview` : "treeseed dev",
36
- 'treeseed ship "describe your change"'
37
- ],
38
- report: {
39
- branchName,
40
- resumed: true,
41
- preview: state2.preview.enabled,
42
- previewUrl: state2.preview.url
43
- }
44
- });
45
- }
46
- if (!branchExists(repoDir, branchName) && !remoteBranchExists(repoDir, branchName)) {
47
- return handleStart({
48
- ...invocation,
49
- commandName
50
- }, context);
51
- }
52
- assertCleanWorktree(context.cwd);
53
- ensureLocalBranchTracking(repoDir, branchName);
54
- checkoutBranch(repoDir, branchName);
55
- syncBranchWithOrigin(repoDir, branchName);
56
- if (preview) {
57
- const state2 = resolveTreeseedWorkflowState(context.cwd);
58
- if (!state2.preview.enabled) {
59
- return provisionBranchPreview(branchName, context, commandName);
60
- }
61
- }
62
- const state = resolveTreeseedWorkflowState(context.cwd);
63
- return guidedResult({
64
- command: commandName,
65
- summary: `Resumed feature branch ${branchName}.`,
66
- facts: [
67
- { label: "Branch", value: branchName },
68
- { label: "Preview", value: state.preview.enabled ? "enabled" : "disabled" },
69
- { label: "Preview URL", value: state.preview.url ?? "(none)" }
70
- ],
71
- nextSteps: [
72
- state.preview.enabled ? `treeseed publish --target-branch ${branchName}` : "treeseed dev",
73
- 'treeseed ship "describe your change"'
74
- ],
75
- report: {
76
- branchName,
77
- resumed: true,
78
- preview: state.preview.enabled,
79
- previewUrl: state.preview.url
80
- }
81
- });
82
- };
83
- export {
84
- handleWork
85
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,121 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { buildTenantBookRuntime } from '@treeseed/core/utils/books-data';
4
- import { loadTreeseedManifest } from '@treeseed/core/tenant-config';
5
- const PROJECT_TENANT = loadTreeseedManifest();
6
- const { BOOKS, TREESEED_LIBRARY_DOWNLOAD } = buildTenantBookRuntime(PROJECT_TENANT, {
7
- projectRoot: PROJECT_TENANT.__tenantRoot ?? process.cwd(),
8
- docsLibraryDownload: {
9
- downloadFileName: 'karyon-knowledge.md',
10
- downloadHref: '/books/karyon-knowledge.md',
11
- downloadTitle: 'Karyon Knowledge Library',
12
- },
13
- });
14
- const projectRoot = PROJECT_TENANT.__tenantRoot ?? process.cwd();
15
- const outputDir = path.join(projectRoot, 'public', 'books');
16
- const legacyOutputFile = path.join(projectRoot, 'public', 'book.md');
17
- function sortPaths(paths) {
18
- return [...paths].sort((left, right) => left.localeCompare(right, undefined, { numeric: true, sensitivity: 'base' }));
19
- }
20
- function getSidebarOrder(filePath) {
21
- const rawContent = fs.readFileSync(filePath, 'utf8');
22
- const frontmatterMatch = rawContent.match(/^---\r?\n([\s\S]*?)\r?\n---/);
23
- if (!frontmatterMatch)
24
- return Number.POSITIVE_INFINITY;
25
- const orderMatch = frontmatterMatch[1].match(/^\s{2}order:\s*(\d+)\s*$/m);
26
- return orderMatch ? Number.parseInt(orderMatch[1], 10) : Number.POSITIVE_INFINITY;
27
- }
28
- function collectMarkdownFiles(rootPath) {
29
- if (!fs.existsSync(rootPath)) {
30
- throw new Error(`Book export root not found: ${rootPath}`);
31
- }
32
- const stats = fs.statSync(rootPath);
33
- if (stats.isFile()) {
34
- return [rootPath];
35
- }
36
- const entries = fs.readdirSync(rootPath, { withFileTypes: true });
37
- return sortPaths(entries.flatMap((entry) => {
38
- const fullPath = path.join(rootPath, entry.name);
39
- if (entry.isDirectory()) {
40
- return collectMarkdownFiles(fullPath);
41
- }
42
- if (entry.isFile() && (entry.name.endsWith('.md') || entry.name.endsWith('.mdx'))) {
43
- return [fullPath];
44
- }
45
- return [];
46
- }));
47
- }
48
- function stripFrontmatter(content) {
49
- return content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '').trim();
50
- }
51
- function stripMdxOnlySyntax(content) {
52
- return content
53
- .replace(/^import\s.+$/gm, '')
54
- .replace(/^\s*<\/?[A-Z][^>]*>\s*$/gm, '')
55
- .replace(/\n{3,}/g, '\n\n')
56
- .trim();
57
- }
58
- function inferExportRootFromBasePath(book) {
59
- const normalizedBasePath = String(book.basePath || '').trim();
60
- const knowledgePrefix = '/knowledge/';
61
- if (!normalizedBasePath.startsWith(knowledgePrefix)) {
62
- throw new Error(`Book basePath must start with "${knowledgePrefix}" to infer exports: ${book.basePath}`);
63
- }
64
- const relativeKnowledgePath = normalizedBasePath
65
- .slice(knowledgePrefix.length)
66
- .replace(/^\/+|\/+$/g, '');
67
- if (!relativeKnowledgePath) {
68
- throw new Error(`Book basePath must identify a knowledge directory: ${book.basePath}`);
69
- }
70
- return path.join(PROJECT_TENANT.content.docs, relativeKnowledgePath);
71
- }
72
- function resolveExportRoots(book) {
73
- if (Array.isArray(book.exportRoots) && book.exportRoots.length > 0) {
74
- return book.exportRoots;
75
- }
76
- return [inferExportRootFromBasePath(book)];
77
- }
78
- function resolveBookFiles(book) {
79
- const files = resolveExportRoots(book).flatMap((root) => collectMarkdownFiles(path.resolve(projectRoot, root)).sort((left, right) => {
80
- const orderDelta = getSidebarOrder(left) - getSidebarOrder(right);
81
- if (orderDelta !== 0)
82
- return orderDelta;
83
- return left.localeCompare(right, undefined, { numeric: true, sensitivity: 'base' });
84
- }));
85
- return Array.from(new Set(files));
86
- }
87
- function buildBookMarkdown(book) {
88
- const sections = resolveBookFiles(book).map((filePath) => {
89
- const rawContent = fs.readFileSync(filePath, 'utf8');
90
- return stripMdxOnlySyntax(stripFrontmatter(rawContent));
91
- });
92
- return `# ${book.downloadTitle}\n\n> This document is auto-generated from the Karyon knowledge source.\n\n${sections.join('\n\n---\n\n')}\n`;
93
- }
94
- function ensureOutputDir() {
95
- fs.mkdirSync(outputDir, { recursive: true });
96
- }
97
- function writeBookOutput(fileName, content) {
98
- const outputPath = path.join(outputDir, fileName);
99
- fs.writeFileSync(outputPath, content);
100
- return outputPath;
101
- }
102
- function main() {
103
- console.log('Generating contextual Karyon knowledge exports...');
104
- ensureOutputDir();
105
- const bookOutputs = BOOKS.map((book) => {
106
- const content = buildBookMarkdown(book);
107
- const outputPath = writeBookOutput(book.downloadFileName, content);
108
- console.log(`Generated ${path.relative(projectRoot, outputPath)}`);
109
- return { book, content };
110
- });
111
- const compositeContent = `# ${TREESEED_LIBRARY_DOWNLOAD.downloadTitle}\n\n> This document is auto-generated from the Karyon knowledge source.\n\n${bookOutputs
112
- .map(({ content }) => content.trim())
113
- .join('\n\n---\n\n')}\n`;
114
- const compositeOutputPath = writeBookOutput(TREESEED_LIBRARY_DOWNLOAD.downloadFileName, compositeContent);
115
- console.log(`Generated ${path.relative(projectRoot, compositeOutputPath)}`);
116
- if (fs.existsSync(legacyOutputFile)) {
117
- fs.rmSync(legacyOutputFile);
118
- console.log(`Removed legacy export ${path.relative(projectRoot, legacyOutputFile)}`);
119
- }
120
- }
121
- main();
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- const packageRoot = resolve(fileURLToPath(new URL('..', import.meta.url)));
5
- const packageJson = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'));
6
- const packageVersion = packageJson.version;
7
- const tagName = process.argv[2] || process.env.GITHUB_REF_NAME;
8
- if (!tagName) {
9
- console.error('Release tag validation requires a tag name argument or GITHUB_REF_NAME.');
10
- process.exit(1);
11
- }
12
- if (!/^\d+\.\d+\.\d+$/.test(tagName)) {
13
- console.error(`Release tag "${tagName}" must use plain semver format "x.y.z".`);
14
- process.exit(1);
15
- }
16
- const taggedVersion = tagName;
17
- if (taggedVersion !== packageVersion) {
18
- console.error(`Release tag version "${taggedVersion}" does not match @treeseed/cli version "${packageVersion}".`);
19
- process.exit(1);
20
- }
21
- console.log(`Release tag "${tagName}" matches @treeseed/cli version "${packageVersion}".`);
@@ -1 +0,0 @@
1
- export {};