@treeseed/sdk 0.5.0 → 0.5.1

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.
@@ -500,9 +500,9 @@ function parseDeployConfig(raw) {
500
500
  buildOutputDir: optionalString(cloudflarePages.buildOutputDir)
501
501
  },
502
502
  r2: cloudflare.r2 === void 0 ? void 0 : {
503
- binding: optionalString(process.env.TREESEED_CONTENT_BUCKET_BINDING),
504
- bucketName: optionalString(process.env.TREESEED_CONTENT_BUCKET_NAME),
505
- publicBaseUrl: optionalString(process.env.TREESEED_CONTENT_PUBLIC_BASE_URL),
503
+ binding: optionalString(process.env.TREESEED_CONTENT_BUCKET_BINDING) ?? optionalString(cloudflareR2.binding),
504
+ bucketName: optionalString(process.env.TREESEED_CONTENT_BUCKET_NAME) ?? optionalString(cloudflareR2.bucketName),
505
+ publicBaseUrl: optionalString(process.env.TREESEED_CONTENT_PUBLIC_BASE_URL) ?? optionalString(cloudflareR2.publicBaseUrl),
506
506
  manifestKeyTemplate: optionalString(cloudflareR2.manifestKeyTemplate) ?? "teams/{teamId}/published/common.json",
507
507
  previewRootTemplate: optionalString(cloudflareR2.previewRootTemplate) ?? "teams/{teamId}/previews",
508
508
  previewTtlHours: optionalPositiveNumber(cloudflareR2.previewTtlHours, "cloudflare.r2.previewTtlHours") ?? 168
@@ -1,6 +1,7 @@
1
- import { existsSync, readdirSync, readFileSync } from "node:fs";
1
+ import { existsSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import * as childProcess from "node:child_process";
3
- import { basename, resolve } from "node:path";
3
+ import { basename, relative, resolve } from "node:path";
4
+ import { tmpdir } from "node:os";
4
5
  import { fileURLToPath } from "node:url";
5
6
  function defaultWrite(message, stream = "stdout") {
6
7
  if (!message) return;
@@ -38,6 +39,84 @@ function readPackageManifest(packageJsonPath) {
38
39
  return null;
39
40
  }
40
41
  }
42
+ function createWorkspaceActWorkflow(options) {
43
+ const relativePackageRoot = relative(options.workspaceRoot, options.packageRoot).replace(/\\/g, "/");
44
+ const siblingPreparationCommands = options.localTreeseedSiblingDependencies.map((packageName) => {
45
+ const packageDir = `packages/${packageName.split("/")[1]}`;
46
+ const manifest = readPackageManifest(resolve(options.workspaceRoot, packageDir, "package.json"));
47
+ if (!manifest) {
48
+ return null;
49
+ }
50
+ const commands = [
51
+ `if test -f ${packageDir}/package-lock.json; then`,
52
+ ` npm --prefix ${packageDir} ci`,
53
+ "else",
54
+ ` npm --prefix ${packageDir} install --no-audit --no-fund`,
55
+ "fi"
56
+ ];
57
+ if (manifest.scripts?.["build:dist"]) {
58
+ commands.push(`npm --prefix ${packageDir} run build:dist`);
59
+ }
60
+ return commands.join("\n");
61
+ }).filter((command) => Boolean(command)).join("\n");
62
+ const workflowRoot = mkdtempSync(resolve(tmpdir(), "treeseed-verify-act-"));
63
+ const workflowPath = resolve(workflowRoot, "verify.yml");
64
+ writeFileSync(
65
+ workflowPath,
66
+ `name: Treeseed Local Verify
67
+
68
+ on:
69
+ workflow_dispatch:
70
+
71
+ jobs:
72
+ verify:
73
+ runs-on: ubuntu-latest
74
+ defaults:
75
+ run:
76
+ working-directory: ${relativePackageRoot}
77
+ env:
78
+ CI: "true"
79
+ TREESEED_GITHUB_AUTOMATION_MODE: stub
80
+ TREESEED_STAGE_WAIT_MODE: skip
81
+ TREESEED_AGENT_DISABLE_GIT: "true"
82
+ TREESEED_FIXTURE_ID: treeseed-working-site
83
+ steps:
84
+ - name: Checkout
85
+ uses: actions/checkout@v4
86
+ with:
87
+ submodules: recursive
88
+
89
+ - name: Setup Node
90
+ uses: actions/setup-node@v4
91
+ with:
92
+ node-version: 24.12.0
93
+
94
+ - name: Assert node:sqlite availability
95
+ run: node -e "import('node:sqlite').then(() => console.log('node:sqlite available')).catch((error) => { console.error(error); process.exit(1); })"
96
+
97
+ ${siblingPreparationCommands ? ` - name: Prepare sibling packages
98
+ working-directory: .
99
+ run: |
100
+ ${siblingPreparationCommands.split("\n").map((line) => ` ${line}`).join("\n")}
101
+
102
+ ` : ""} - name: Install dependencies
103
+ run: |
104
+ if test -f package-lock.json; then
105
+ npm ci
106
+ else
107
+ npm install --no-audit --no-fund
108
+ fi
109
+
110
+ - name: Verify package
111
+ run: npm run verify:direct
112
+ `,
113
+ "utf8"
114
+ );
115
+ return {
116
+ cwd: options.workspaceRoot,
117
+ args: ["act", options.eventName, "-W", workflowPath, "-j", "verify"]
118
+ };
119
+ }
41
120
  function findWorkspaceRoot(packageRoot) {
42
121
  let current = packageRoot;
43
122
  while (true) {
@@ -150,6 +229,15 @@ function runTreeseedVerifyDriver(options = {}) {
150
229
  write(detail || "Treeseed verify requires a running Docker daemon when TREESEED_VERIFY_DRIVER=act.", "stderr");
151
230
  return 1;
152
231
  }
232
+ if (status.workspaceRoot && status.localTreeseedSiblingDependencies.length > 0) {
233
+ const workspaceAct = createWorkspaceActWorkflow({
234
+ workspaceRoot: status.workspaceRoot,
235
+ packageRoot: status.packageRoot,
236
+ eventName: status.eventName,
237
+ localTreeseedSiblingDependencies: status.localTreeseedSiblingDependencies
238
+ });
239
+ return runCommand("gh", workspaceAct.args, workspaceAct.cwd);
240
+ }
153
241
  return runCommand("gh", ["act", status.eventName, "-W", ".github/workflows/verify.yml", "-j", "verify"], status.packageRoot);
154
242
  }
155
243
  if (status.prefersDirectForLocalWorkspace) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {