@treeseed/sdk 0.4.9 → 0.4.11
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/control-plane-client.d.ts +45 -0
- package/dist/control-plane-client.js +229 -0
- package/dist/control-plane.d.ts +94 -0
- package/dist/control-plane.js +125 -0
- package/dist/d1-store.d.ts +56 -1
- package/dist/d1-store.js +132 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +69 -1
- package/dist/operations/services/config-runtime.d.ts +10 -0
- package/dist/operations/services/config-runtime.js +60 -2
- package/dist/operations/services/deploy.d.ts +95 -0
- package/dist/operations/services/deploy.js +350 -9
- package/dist/operations/services/github-automation.d.ts +37 -1
- package/dist/operations/services/github-automation.js +71 -14
- package/dist/operations/services/project-platform.d.ts +835 -0
- package/dist/operations/services/project-platform.js +782 -0
- package/dist/operations/services/railway-deploy.d.ts +113 -18
- package/dist/operations/services/railway-deploy.js +355 -6
- package/dist/operations/services/runtime-tools.d.ts +25 -0
- package/dist/operations/services/runtime-tools.js +65 -3
- package/dist/operations/services/template-registry.d.ts +1 -1
- package/dist/operations/services/template-registry.js +17 -3
- package/dist/operations/services/workspace-save-script.d.ts +26 -0
- package/dist/operations/services/workspace-save-script.js +50 -0
- package/dist/platform/books-data.d.ts +3 -4
- package/dist/platform/books-data.js +30 -4
- package/dist/platform/contracts.d.ts +55 -2
- package/dist/platform/deploy-config.js +109 -4
- package/dist/platform/deploy-runtime.d.ts +2 -0
- package/dist/platform/deploy-runtime.js +9 -1
- package/dist/platform/env.yaml +677 -0
- package/dist/platform/environment.js +57 -2
- package/dist/platform/plugin.d.ts +8 -0
- package/dist/platform/plugins/constants.d.ts +2 -0
- package/dist/platform/plugins/constants.js +2 -0
- package/dist/platform/plugins/runtime.d.ts +2 -0
- package/dist/platform/plugins/runtime.js +9 -1
- package/dist/platform/plugins.d.ts +1 -1
- package/dist/platform/plugins.js +4 -0
- package/dist/platform/published-content-pipeline.d.ts +84 -0
- package/dist/platform/published-content-pipeline.js +543 -0
- package/dist/platform/published-content.d.ts +223 -0
- package/dist/platform/published-content.js +588 -0
- package/dist/platform/tenant/runtime-config.d.ts +1 -1
- package/dist/platform/tenant/runtime-config.js +34 -1
- package/dist/platform/tenant-config.d.ts +2 -1
- package/dist/platform/tenant-config.js +17 -1
- package/dist/platform/utils/site-config-schema.js +104 -0
- package/dist/plugin-default.d.ts +2 -0
- package/dist/plugin-default.js +2 -0
- package/dist/scripts/check-build-warnings.js +50 -0
- package/dist/scripts/config-treeseed.js +7 -0
- package/dist/scripts/tenant-workflow-action.js +71 -0
- package/dist/scripts/workspace-command-e2e.js +0 -2
- package/dist/scripts/workspace-save.js +47 -107
- package/dist/sdk-types.d.ts +442 -3
- package/dist/sdk-types.js +37 -1
- package/dist/sdk.d.ts +11 -1
- package/dist/sdk.js +40 -0
- package/dist/stores/operational-store.d.ts +22 -2
- package/dist/stores/operational-store.js +235 -0
- package/dist/template-catalog.js +8 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +20 -0
- package/dist/types/cloudflare.d.ts +23 -0
- package/dist/workflow/operations.d.ts +12 -3
- package/dist/workflow/policy.d.ts +1 -1
- package/package.json +7 -2
- package/templates/github/deploy.workflow.yml +442 -0
- package/templates/github/hosted-project.workflow.yml +77 -0
|
@@ -166,6 +166,108 @@ function parseTheme(value, path) {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
function parseAccessRoles(value, path) {
|
|
170
|
+
const record = optionalRecord(value, path);
|
|
171
|
+
if (!record) {
|
|
172
|
+
return {};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return Object.fromEntries(
|
|
176
|
+
Object.entries(record).map(([roleId, rawRole]) => {
|
|
177
|
+
const parsedRole = expectRecord(rawRole, `${path}.${roleId}`);
|
|
178
|
+
return [
|
|
179
|
+
roleId,
|
|
180
|
+
{
|
|
181
|
+
grants: stringArray(parsedRole.grants, `${path}.${roleId}.grants`),
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function parseAccessPolicies(value, path) {
|
|
189
|
+
const record = optionalRecord(value, path);
|
|
190
|
+
if (!record) {
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return Object.fromEntries(
|
|
195
|
+
Object.entries(record).map(([policyId, rawPolicy]) => {
|
|
196
|
+
const parsedPolicy = expectRecord(rawPolicy, `${path}.${policyId}`);
|
|
197
|
+
return [
|
|
198
|
+
policyId,
|
|
199
|
+
{
|
|
200
|
+
audience: optionalString(parsedPolicy.audience, `${path}.${policyId}.audience`),
|
|
201
|
+
entitlement: optionalString(parsedPolicy.entitlement, `${path}.${policyId}.entitlement`),
|
|
202
|
+
offer: optionalString(parsedPolicy.offer, `${path}.${policyId}.offer`),
|
|
203
|
+
visibility: optionalString(parsedPolicy.visibility, `${path}.${policyId}.visibility`),
|
|
204
|
+
},
|
|
205
|
+
];
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function parseAccessDefaults(value, path) {
|
|
211
|
+
const record = optionalRecord(value, path);
|
|
212
|
+
if (!record) {
|
|
213
|
+
return { models: {} };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const models = optionalRecord(record.models, `${path}.models`) ?? {};
|
|
217
|
+
return {
|
|
218
|
+
models: Object.fromEntries(
|
|
219
|
+
Object.entries(models).map(([modelId, rawSurfaces]) => {
|
|
220
|
+
const parsedSurfaces = expectRecord(rawSurfaces, `${path}.models.${modelId}`);
|
|
221
|
+
return [
|
|
222
|
+
modelId,
|
|
223
|
+
Object.fromEntries(
|
|
224
|
+
Object.entries(parsedSurfaces).map(([surfaceId, rawPolicy]) => [
|
|
225
|
+
surfaceId,
|
|
226
|
+
expectString(rawPolicy, `${path}.models.${modelId}.${surfaceId}`),
|
|
227
|
+
]),
|
|
228
|
+
),
|
|
229
|
+
];
|
|
230
|
+
}),
|
|
231
|
+
),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function parseAccessBootstrap(value, path) {
|
|
236
|
+
const record = optionalRecord(value, path);
|
|
237
|
+
if (!record) {
|
|
238
|
+
return {};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const owners = optionalRecord(record.owners, `${path}.owners`);
|
|
242
|
+
return {
|
|
243
|
+
owners: owners
|
|
244
|
+
? {
|
|
245
|
+
emails: stringArray(owners.emails, `${path}.owners.emails`),
|
|
246
|
+
roles: stringArray(owners.roles, `${path}.owners.roles`),
|
|
247
|
+
}
|
|
248
|
+
: undefined,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function parseAccess(value, path) {
|
|
253
|
+
const record = optionalRecord(value, path);
|
|
254
|
+
if (!record) {
|
|
255
|
+
return {
|
|
256
|
+
roles: {},
|
|
257
|
+
policies: {},
|
|
258
|
+
defaults: { models: {} },
|
|
259
|
+
bootstrap: {},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
roles: parseAccessRoles(record.roles, `${path}.roles`),
|
|
265
|
+
policies: parseAccessPolicies(record.policies, `${path}.policies`),
|
|
266
|
+
defaults: parseAccessDefaults(record.defaults, `${path}.defaults`),
|
|
267
|
+
bootstrap: parseAccessBootstrap(record.bootstrap, `${path}.bootstrap`),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
169
271
|
/** @type {TreeseedFieldAliasRegistry} */
|
|
170
272
|
const siteFieldAliases = {
|
|
171
273
|
siteUrl: { key: 'siteUrl', aliases: ['site_url'] },
|
|
@@ -228,6 +330,7 @@ export function parseSiteConfig(source) {
|
|
|
228
330
|
emailNotificationFieldAliases,
|
|
229
331
|
expectRecord(site.emailNotifications, 'site.emailNotifications'),
|
|
230
332
|
);
|
|
333
|
+
const access = parseAccess(parsed.access, 'access');
|
|
231
334
|
|
|
232
335
|
return {
|
|
233
336
|
site: {
|
|
@@ -317,5 +420,6 @@ export function parseSiteConfig(source) {
|
|
|
317
420
|
},
|
|
318
421
|
},
|
|
319
422
|
},
|
|
423
|
+
access,
|
|
320
424
|
};
|
|
321
425
|
}
|
package/dist/plugin-default.d.ts
CHANGED
package/dist/plugin-default.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const allowlisted = [];
|
|
8
|
+
const files = [];
|
|
9
|
+
|
|
10
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
11
|
+
const arg = args[index];
|
|
12
|
+
if (arg === '--allow') {
|
|
13
|
+
const pattern = args[index + 1];
|
|
14
|
+
if (!pattern) {
|
|
15
|
+
throw new Error('Missing value for --allow.');
|
|
16
|
+
}
|
|
17
|
+
allowlisted.push(new RegExp(pattern));
|
|
18
|
+
index += 1;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
files.push(arg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (files.length === 0) {
|
|
25
|
+
throw new Error('Usage: node check-build-warnings.mjs <log-file> [<log-file> ...] [--allow <regex>]');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const warningLines = [];
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
const contents = readFileSync(resolve(process.cwd(), file), 'utf8');
|
|
31
|
+
for (const line of contents.split(/\r?\n/u)) {
|
|
32
|
+
if (!line.includes('[WARN]')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (allowlisted.some((pattern) => pattern.test(line))) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
warningLines.push(line);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (warningLines.length > 0) {
|
|
43
|
+
console.error('Unexpected build warnings detected:');
|
|
44
|
+
for (const line of warningLines) {
|
|
45
|
+
console.error(`- ${line}`);
|
|
46
|
+
}
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log('No unexpected build warnings detected.');
|
|
@@ -74,6 +74,13 @@ try {
|
|
|
74
74
|
console.log(`Machine key: ${keyPath}`);
|
|
75
75
|
console.log(`Updated values: ${applyResult.updated.length}`);
|
|
76
76
|
console.log(`Initialized environments: ${result.initialized.length}`);
|
|
77
|
+
for (const scope of scopes) {
|
|
78
|
+
const readiness = result.readinessByScope?.[scope];
|
|
79
|
+
if (!readiness)
|
|
80
|
+
continue;
|
|
81
|
+
const status = readiness.deployable ? 'deployable' : readiness.provisioned ? 'provisioned' : readiness.configured ? 'configured' : 'pending';
|
|
82
|
+
console.log(`Readiness (${scope}): ${status}`);
|
|
83
|
+
}
|
|
77
84
|
if (result.synced.github) {
|
|
78
85
|
console.log(`GitHub sync: ${result.synced.github.secrets.length} secrets, ${result.synced.github.variables.length} variables (${result.synced.github.repository})`);
|
|
79
86
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolveScope, runProjectPlatformAction, } from '../operations/services/project-platform.js';
|
|
3
|
+
const tenantRoot = process.cwd();
|
|
4
|
+
function parseArgs(argv) {
|
|
5
|
+
const parsed = {
|
|
6
|
+
action: 'deploy_code',
|
|
7
|
+
environment: null,
|
|
8
|
+
projectId: null,
|
|
9
|
+
previewId: null,
|
|
10
|
+
dryRun: false,
|
|
11
|
+
};
|
|
12
|
+
const rest = [...argv];
|
|
13
|
+
while (rest.length) {
|
|
14
|
+
const current = rest.shift();
|
|
15
|
+
if (!current)
|
|
16
|
+
continue;
|
|
17
|
+
if (current === '--action') {
|
|
18
|
+
parsed.action = (rest.shift() ?? parsed.action);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (current.startsWith('--action=')) {
|
|
22
|
+
parsed.action = (current.split('=', 2)[1] ?? parsed.action);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (current === '--environment') {
|
|
26
|
+
parsed.environment = rest.shift() ?? null;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (current.startsWith('--environment=')) {
|
|
30
|
+
parsed.environment = current.split('=', 2)[1] ?? null;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (current === '--project-id') {
|
|
34
|
+
parsed.projectId = rest.shift() ?? null;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (current.startsWith('--project-id=')) {
|
|
38
|
+
parsed.projectId = current.split('=', 2)[1] ?? null;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (current === '--preview-id') {
|
|
42
|
+
parsed.previewId = rest.shift() ?? null;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (current.startsWith('--preview-id=')) {
|
|
46
|
+
parsed.previewId = current.split('=', 2)[1] ?? null;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (current === '--dry-run') {
|
|
50
|
+
parsed.dryRun = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Unknown workflow action argument: ${current}`);
|
|
54
|
+
}
|
|
55
|
+
return parsed;
|
|
56
|
+
}
|
|
57
|
+
async function main() {
|
|
58
|
+
const options = parseArgs(process.argv.slice(2));
|
|
59
|
+
const scope = resolveScope(options.environment);
|
|
60
|
+
const result = await runProjectPlatformAction(options.action, {
|
|
61
|
+
tenantRoot,
|
|
62
|
+
scope,
|
|
63
|
+
projectId: options.projectId ?? process.env.TREESEED_PROJECT_ID ?? null,
|
|
64
|
+
previewId: options.previewId,
|
|
65
|
+
dryRun: options.dryRun,
|
|
66
|
+
});
|
|
67
|
+
if (result !== undefined) {
|
|
68
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
await main();
|
|
@@ -549,7 +549,6 @@ async function runLocalSuite() {
|
|
|
549
549
|
try {
|
|
550
550
|
return runCommand('save-no-changes', process.execPath, [packageScriptPath('treeseed'), 'save', 'test: no-op save'], {
|
|
551
551
|
cwd: clonedWorkspace.workingRoot,
|
|
552
|
-
allowedExitCodes: [1],
|
|
553
552
|
env: cacheEnv(),
|
|
554
553
|
});
|
|
555
554
|
}
|
|
@@ -643,7 +642,6 @@ async function runStagingSuite() {
|
|
|
643
642
|
return runCommand('staging-save-no-op', 'npm', ['run', 'save', '--', 'test: staging no-op save'], {
|
|
644
643
|
cwd: staging.workingRoot,
|
|
645
644
|
env: cacheEnv(createWranglerCommandEnv()),
|
|
646
|
-
allowedExitCodes: [1],
|
|
647
645
|
timeoutMs: 180000,
|
|
648
646
|
});
|
|
649
647
|
});
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { remoteBranchExists, STAGING_BRANCH, PRODUCTION_BRANCH } from '../operations/services/git-workflow.js';
|
|
7
|
-
import { run, workspaceRoot } from '../operations/services/workspace-tools.js';
|
|
8
|
-
import { runWorkspaceSavePreflight } from '../operations/services/save-deploy-preflight.js';
|
|
4
|
+
import { TreeseedWorkflowError, TreeseedWorkflowSdk } from '../workflow.js';
|
|
5
|
+
import { formatWorkspaceSaveFailureReport, formatWorkspaceSaveSuccessReport, parseWorkspaceSaveScriptArgs, } from '../operations/services/workspace-save-script.js';
|
|
9
6
|
function writeSaveReport(payload) {
|
|
10
7
|
const target = process.env.TREESEED_SAVE_REPORT_PATH;
|
|
11
8
|
if (!target) {
|
|
@@ -15,110 +12,53 @@ function writeSaveReport(payload) {
|
|
|
15
12
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
16
13
|
writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`, 'utf8');
|
|
17
14
|
}
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
parsed.hotfix = true;
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
parsed.messageParts.push(current);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
hotfix: parsed.hotfix,
|
|
32
|
-
message: parsed.messageParts.join(' ').trim(),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const options = parseArgs(process.argv.slice(2));
|
|
36
|
-
const message = options.message;
|
|
37
|
-
const root = workspaceRoot();
|
|
38
|
-
const gitRoot = repoRoot(root);
|
|
39
|
-
const branch = currentBranch(gitRoot);
|
|
40
|
-
const scope = branch === STAGING_BRANCH ? 'staging' : branch === PRODUCTION_BRANCH ? 'prod' : 'local';
|
|
41
|
-
applyTreeseedEnvironmentToProcess({ tenantRoot: root, scope, override: true });
|
|
42
|
-
if (!message) {
|
|
43
|
-
writeSaveReport({ ok: false, kind: 'usage', message: 'Treeseed save requires a commit message.' });
|
|
44
|
-
console.error('Treeseed save requires a commit message. Usage: treeseed save <message>');
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
if (!branch) {
|
|
48
|
-
writeSaveReport({ ok: false, kind: 'missing_branch', message: 'Treeseed save requires an active git branch.' });
|
|
49
|
-
console.error('Treeseed save requires an active git branch.');
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
if (branch === PRODUCTION_BRANCH && !options.hotfix) {
|
|
53
|
-
writeSaveReport({
|
|
54
|
-
ok: false,
|
|
55
|
-
kind: 'protected_branch',
|
|
56
|
-
branch,
|
|
57
|
-
message: 'Treeseed save is blocked on main. Use `treeseed release` for normal production promotion or `treeseed save --hotfix` for an explicit hotfix.',
|
|
58
|
-
});
|
|
59
|
-
console.error('Treeseed save is blocked on main. Use `treeseed release` for normal production promotion or `treeseed save --hotfix` for an explicit hotfix.');
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
originRemoteUrl(gitRoot);
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
writeSaveReport({ ok: false, kind: 'missing_origin', message: 'Treeseed save requires an origin remote.' });
|
|
67
|
-
console.error('Treeseed save requires an origin remote.');
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
runWorkspaceSavePreflight({ cwd: root });
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
const kind = error?.kind ?? 'preflight_failed';
|
|
75
|
-
writeSaveReport({
|
|
76
|
-
ok: false,
|
|
77
|
-
kind,
|
|
78
|
-
message: error instanceof Error ? error.message : String(error),
|
|
79
|
-
});
|
|
80
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
81
|
-
process.exit(error?.exitCode ?? 1);
|
|
82
|
-
}
|
|
83
|
-
if (!hasMeaningfulChanges(gitRoot)) {
|
|
84
|
-
writeSaveReport({ ok: false, kind: 'no_changes', message: 'Treeseed save found no meaningful repository changes to commit.' });
|
|
85
|
-
console.error('Treeseed save found no meaningful repository changes to commit.');
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
run('git', ['add', '-A'], { cwd: gitRoot });
|
|
89
|
-
run('git', ['commit', '-m', message], { cwd: gitRoot });
|
|
90
|
-
try {
|
|
91
|
-
if (remoteBranchExists(gitRoot, branch)) {
|
|
92
|
-
run('git', ['pull', '--rebase', 'origin', branch], { cwd: gitRoot });
|
|
93
|
-
run('git', ['push', 'origin', branch], { cwd: gitRoot });
|
|
15
|
+
function printSaveSummary(payload) {
|
|
16
|
+
const commitSha = typeof payload.commitSha === 'string' ? payload.commitSha : '';
|
|
17
|
+
const previewStatus = typeof payload.previewAction?.status === 'string'
|
|
18
|
+
? String(payload.previewAction.status)
|
|
19
|
+
: 'skipped';
|
|
20
|
+
if (payload.noChanges === true) {
|
|
21
|
+
console.log('Treeseed save found no new changes and confirmed branch sync.');
|
|
94
22
|
}
|
|
95
23
|
else {
|
|
96
|
-
|
|
24
|
+
console.log('Treeseed save completed successfully.');
|
|
25
|
+
}
|
|
26
|
+
if (typeof payload.branch === 'string') {
|
|
27
|
+
console.log(`Branch: ${payload.branch}`);
|
|
28
|
+
}
|
|
29
|
+
if (typeof payload.scope === 'string') {
|
|
30
|
+
console.log(`Environment scope: ${payload.scope}`);
|
|
97
31
|
}
|
|
32
|
+
if (commitSha) {
|
|
33
|
+
console.log(`Commit: ${commitSha.slice(0, 12)}`);
|
|
34
|
+
}
|
|
35
|
+
console.log(`Preview action: ${previewStatus}`);
|
|
98
36
|
}
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
branch,
|
|
105
|
-
report,
|
|
106
|
-
formatted: formatMergeConflictReport(report, gitRoot, branch),
|
|
37
|
+
async function main() {
|
|
38
|
+
const options = parseWorkspaceSaveScriptArgs(process.argv.slice(2));
|
|
39
|
+
const workflow = new TreeseedWorkflowSdk({
|
|
40
|
+
cwd: process.cwd(),
|
|
41
|
+
env: process.env,
|
|
107
42
|
});
|
|
108
|
-
|
|
109
|
-
|
|
43
|
+
try {
|
|
44
|
+
const result = await workflow.save({
|
|
45
|
+
message: options.message,
|
|
46
|
+
hotfix: options.hotfix,
|
|
47
|
+
});
|
|
48
|
+
const payload = result.payload;
|
|
49
|
+
writeSaveReport(formatWorkspaceSaveSuccessReport(result));
|
|
50
|
+
printSaveSummary(payload);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error instanceof TreeseedWorkflowError) {
|
|
54
|
+
writeSaveReport(formatWorkspaceSaveFailureReport(error));
|
|
55
|
+
console.error(error.message);
|
|
56
|
+
process.exit(error.exitCode ?? 1);
|
|
57
|
+
}
|
|
58
|
+
const report = formatWorkspaceSaveFailureReport(error);
|
|
59
|
+
console.error(report.message);
|
|
60
|
+
writeSaveReport(report);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
110
63
|
}
|
|
111
|
-
|
|
112
|
-
ok: true,
|
|
113
|
-
kind: 'success',
|
|
114
|
-
message,
|
|
115
|
-
branch,
|
|
116
|
-
scope,
|
|
117
|
-
hotfix: options.hotfix,
|
|
118
|
-
root,
|
|
119
|
-
repositoryRoot: gitRoot,
|
|
120
|
-
};
|
|
121
|
-
writeSaveReport(summary);
|
|
122
|
-
console.log('Treeseed save completed successfully.');
|
|
123
|
-
console.log(`Branch: ${branch}`);
|
|
124
|
-
console.log(`Environment scope: ${scope}`);
|
|
64
|
+
await main();
|