@treeseed/sdk 0.6.12 → 0.6.14
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/dist/operations/services/d1-migration.js +24 -1
- package/dist/operations/services/git-workflow.js +1 -1
- package/dist/operations/services/save-deploy-preflight.d.ts +3 -0
- package/dist/operations/services/save-deploy-preflight.js +6 -0
- package/dist/scripts/workspace-release-test.js +15 -0
- package/dist/workflow/operations.js +2 -2
- package/dist/workflow-support.d.ts +1 -1
- package/dist/workflow-support.js +2 -0
- package/package.json +4 -1
|
@@ -55,10 +55,33 @@ function loadAppliedMigrations({ cwd, wranglerConfig, persistTo }) {
|
|
|
55
55
|
capture: true,
|
|
56
56
|
command: "SELECT name FROM treeseed_schema_migrations ORDER BY name ASC;"
|
|
57
57
|
});
|
|
58
|
-
const parsed =
|
|
58
|
+
const parsed = parseWranglerJsonOutput(result.stdout);
|
|
59
59
|
const rows = (Array.isArray(parsed) ? parsed : [parsed]).flatMap((entry) => entry.results ?? []);
|
|
60
60
|
return new Set(rows.map((row) => row.name).filter(Boolean));
|
|
61
61
|
}
|
|
62
|
+
function parseWranglerJsonOutput(stdout) {
|
|
63
|
+
const trimmed = String(stdout ?? "").trim();
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(trimmed);
|
|
66
|
+
} catch {
|
|
67
|
+
const firstArray = trimmed.indexOf("[");
|
|
68
|
+
const firstObject = trimmed.indexOf("{");
|
|
69
|
+
const candidates = [firstArray, firstObject].filter((index) => index >= 0).sort((left, right) => left - right);
|
|
70
|
+
for (const start of candidates) {
|
|
71
|
+
const opener = trimmed[start];
|
|
72
|
+
const closer = opener === "[" ? "]" : "}";
|
|
73
|
+
const end = trimmed.lastIndexOf(closer);
|
|
74
|
+
if (end <= start) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(trimmed.slice(start, end + 1));
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
throw new Error("Unable to parse JSON output from Wrangler D1.");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
62
85
|
function markMigrationApplied({ cwd, wranglerConfig, persistTo, migration }) {
|
|
63
86
|
executeSqlCommand({
|
|
64
87
|
cwd,
|
|
@@ -287,7 +287,7 @@ function listTaskBranches(repoDir) {
|
|
|
287
287
|
gitLines(repoDir, ["for-each-ref", "--format=%(refname:short)", "refs/heads"]).filter(isTaskBranch)
|
|
288
288
|
);
|
|
289
289
|
const remote = new Set(
|
|
290
|
-
gitLines(repoDir, ["for-each-ref", "--format=%(refname:short)", "refs/remotes/origin"]).map((branchName) => branchName.replace(/^origin\//, "")).filter(isTaskBranch)
|
|
290
|
+
gitLines(repoDir, ["for-each-ref", "--format=%(refname:short)", "refs/remotes/origin"]).filter((branchName) => branchName.startsWith("origin/") && branchName !== "origin/HEAD").map((branchName) => branchName.replace(/^origin\//, "")).filter(isTaskBranch)
|
|
291
291
|
);
|
|
292
292
|
const current = currentBranch(repoDir);
|
|
293
293
|
const branches = [.../* @__PURE__ */ new Set([...local, ...remote])].sort((left, right) => left.localeCompare(right));
|
|
@@ -28,6 +28,9 @@ export declare function validateSaveAutomationPrerequisites({ cwd }: {
|
|
|
28
28
|
export declare function runWorkspaceSavePreflight({ cwd }: {
|
|
29
29
|
cwd: any;
|
|
30
30
|
}): void;
|
|
31
|
+
export declare function runWorkspaceReleasePreflight({ cwd }: {
|
|
32
|
+
cwd: any;
|
|
33
|
+
}): void;
|
|
31
34
|
export declare function runTenantDeployPreflight({ cwd, scope }: {
|
|
32
35
|
cwd: any;
|
|
33
36
|
scope?: string | undefined;
|
|
@@ -62,6 +62,11 @@ function runWorkspaceSavePreflight({ cwd }) {
|
|
|
62
62
|
runStep("test", "workspace-test", { cwd });
|
|
63
63
|
runStep("build", "tenant-build", { cwd });
|
|
64
64
|
}
|
|
65
|
+
function runWorkspaceReleasePreflight({ cwd }) {
|
|
66
|
+
runStep("lint", "workspace-lint", { cwd });
|
|
67
|
+
runStep("test", "workspace-release-test", { cwd });
|
|
68
|
+
runStep("build", "tenant-build", { cwd });
|
|
69
|
+
}
|
|
65
70
|
function runTenantDeployPreflight({ cwd, scope = "prod" }) {
|
|
66
71
|
applyTreeseedEnvironmentToProcess({ tenantRoot: cwd, scope, override: true });
|
|
67
72
|
assertTreeseedCommandEnvironment({ tenantRoot: cwd, scope, purpose: "deploy" });
|
|
@@ -71,6 +76,7 @@ function runTenantDeployPreflight({ cwd, scope = "prod" }) {
|
|
|
71
76
|
}
|
|
72
77
|
export {
|
|
73
78
|
runTenantDeployPreflight,
|
|
79
|
+
runWorkspaceReleasePreflight,
|
|
74
80
|
runWorkspaceSavePreflight,
|
|
75
81
|
validateSaveAutomationPrerequisites
|
|
76
82
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sortWorkspacePackages, workspacePackages, run } from '../operations/services/workspace-tools.js';
|
|
2
|
+
const packages = sortWorkspacePackages(workspacePackages());
|
|
3
|
+
for (const pkg of packages) {
|
|
4
|
+
const scripts = pkg.packageJson.scripts ?? {};
|
|
5
|
+
const scriptName = typeof scripts['test:release'] === 'string'
|
|
6
|
+
? 'test:release'
|
|
7
|
+
: typeof scripts['test:unit'] === 'string'
|
|
8
|
+
? 'test:unit'
|
|
9
|
+
: typeof scripts.test === 'string'
|
|
10
|
+
? 'test'
|
|
11
|
+
: null;
|
|
12
|
+
if (scriptName) {
|
|
13
|
+
run('npm', ['run', scriptName], { cwd: pkg.dir });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
} from "../operations/services/git-workflow.js";
|
|
69
69
|
import { getGitHubAutomationMode, resolveGitHubRepositorySlug, waitForGitHubWorkflowCompletion } from "../operations/services/github-automation.js";
|
|
70
70
|
import { loadCliDeployConfig, packageScriptPath, resolveWranglerBin } from "../operations/services/runtime-tools.js";
|
|
71
|
-
import { runTenantDeployPreflight, runWorkspaceSavePreflight } from "../operations/services/save-deploy-preflight.js";
|
|
71
|
+
import { runTenantDeployPreflight, runWorkspaceReleasePreflight, runWorkspaceSavePreflight } from "../operations/services/save-deploy-preflight.js";
|
|
72
72
|
import { collectCliPreflight } from "../operations/services/workspace-preflight.js";
|
|
73
73
|
import {
|
|
74
74
|
collectMergeConflictReport,
|
|
@@ -3176,7 +3176,7 @@ async function workflowRelease(helpers, input) {
|
|
|
3176
3176
|
}
|
|
3177
3177
|
prepareReleaseBranches(root);
|
|
3178
3178
|
ensureWorkflowWorkspaceLinks(root, helpers, effectiveInput.workspaceLinks ?? "auto");
|
|
3179
|
-
|
|
3179
|
+
runWorkspaceReleasePreflight({ cwd: root });
|
|
3180
3180
|
await executeJournalStep(root, workflowRun.runId, "workspace-unlink", () => unlinkWorkflowWorkspaceLinks(root, helpers, effectiveInput.workspaceLinks ?? "auto"), { rerunCompleted: true });
|
|
3181
3181
|
if (mode === "root-only") {
|
|
3182
3182
|
const rootRelease2 = await executeJournalStep(root, workflowRun.runId, "release-root", () => {
|
|
@@ -5,7 +5,7 @@ export { assertCleanWorktree, assertFeatureBranch, branchExists, checkoutBranch,
|
|
|
5
5
|
export { loadCliDeployConfig, packageScriptPath, resolveWranglerBin, } from './operations/services/runtime-tools.ts';
|
|
6
6
|
export { configuredRailwayServices, deployRailwayService, validateRailwayDeployPrerequisites, } from './operations/services/railway-deploy.ts';
|
|
7
7
|
export { ensureRailwayEnvironment, ensureRailwayProject, ensureRailwayService, getRailwayAuthProfile, listRailwayEnvironments, listRailwayProjects, listRailwayServices, listRailwayVariables, railwayGraphqlRequest, resolveRailwayApiToken, resolveRailwayApiUrl, resolveRailwayWorkspace, resolveRailwayWorkspaceContext, upsertRailwayVariables, } from './operations/services/railway-api.ts';
|
|
8
|
-
export { runTenantDeployPreflight, runWorkspaceSavePreflight, } from './operations/services/save-deploy-preflight.ts';
|
|
8
|
+
export { runTenantDeployPreflight, runWorkspaceReleasePreflight, runWorkspaceSavePreflight, } from './operations/services/save-deploy-preflight.ts';
|
|
9
9
|
export { collectCliPreflight } from './operations/services/workspace-preflight.ts';
|
|
10
10
|
export { collectTreeseedDependencyStatus, collectTreeseedToolStatus, createTreeseedManagedToolEnv, formatTreeseedDependencyFailureDetails, formatTreeseedDependencyReport, installTreeseedDependencies, resolveTreeseedToolBinary, resolveTreeseedToolCommand, type TreeseedToolStatusResult, } from './managed-dependencies.ts';
|
|
11
11
|
export { runTreeseedCopilotTask, type TreeseedCopilotTaskInput, type TreeseedCopilotTaskResult, } from './copilot.ts';
|
package/dist/workflow-support.js
CHANGED
|
@@ -108,6 +108,7 @@ import {
|
|
|
108
108
|
} from "./operations/services/railway-api.js";
|
|
109
109
|
import {
|
|
110
110
|
runTenantDeployPreflight,
|
|
111
|
+
runWorkspaceReleasePreflight,
|
|
111
112
|
runWorkspaceSavePreflight
|
|
112
113
|
} from "./operations/services/save-deploy-preflight.js";
|
|
113
114
|
import { collectCliPreflight } from "./operations/services/workspace-preflight.js";
|
|
@@ -279,6 +280,7 @@ export {
|
|
|
279
280
|
runRemoteD1Migrations,
|
|
280
281
|
runTenantDeployPreflight,
|
|
281
282
|
runTreeseedCopilotTask,
|
|
283
|
+
runWorkspaceReleasePreflight,
|
|
282
284
|
runWorkspaceSavePreflight,
|
|
283
285
|
setTreeseedRemoteSession,
|
|
284
286
|
syncBranchWithOrigin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.14",
|
|
4
4
|
"description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"prepack": "npm run build:dist",
|
|
39
39
|
"test": "npm run test:unit",
|
|
40
40
|
"test:unit": "vitest run --config ./vitest.config.ts",
|
|
41
|
+
"test:unit:fast": "vitest run --config ./vitest.fast.config.ts",
|
|
42
|
+
"test:workflow:lifecycle": "vitest run --config ./vitest.config.ts test/utils/workflow-lifecycle.test.ts",
|
|
43
|
+
"test:release": "npm run test:unit:fast",
|
|
41
44
|
"test:smoke": "node ./scripts/run-ts.mjs ./scripts/test-smoke.ts",
|
|
42
45
|
"fixtures:resolve": "node ./scripts/run-ts.mjs ./scripts/fixture-tools.ts resolve",
|
|
43
46
|
"fixtures:check": "node ./scripts/run-ts.mjs ./scripts/fixture-tools.ts check",
|