@tailor-platform/sdk 1.45.2 → 1.47.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/CHANGELOG.md +66 -0
- package/dist/{actor-BmxQeMFP.d.mts → actor-DhXSqWTW.d.mts} +2 -2
- package/dist/application-CN9Htzup.mjs +4 -0
- package/dist/{application-B4zVVNRS.mjs → application-TasSqBTD.mjs} +22 -41
- package/dist/application-TasSqBTD.mjs.map +1 -0
- package/dist/cli/index.mjs +101 -61
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +13 -13
- package/dist/cli/lib.mjs +4 -4
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/{client-BwXkoiMq.mjs → client-COfsXV69.mjs} +31 -120
- package/dist/client-COfsXV69.mjs.map +1 -0
- package/dist/{client-DTaArWQr.mjs → client-DYSkSLRr.mjs} +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/configure/index.mjs +4 -43
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crash-report-BUHzuzDn.mjs → crashreport-B8lVOx0U.mjs} +1 -1
- package/dist/{crash-report-CtYCva4d.mjs → crashreport-CKJwnWsX.mjs} +9 -9
- package/dist/crashreport-CKJwnWsX.mjs.map +1 -0
- package/dist/{index-DV-5OIEv.d.mts → index-BRvNi5q9.d.mts} +2 -2
- package/dist/{index-BBvPd9Uv.d.mts → index-BXyS7xKC.d.mts} +2 -2
- package/dist/{index-Dxe6alSZ.d.mts → index-BbOTbZFf.d.mts} +2 -2
- package/dist/{index-DUKJPEwq.d.mts → index-BoU_52Du.d.mts} +6 -6
- package/dist/{index-B5_4Tzm2.d.mts → index-iy-hNfGp.d.mts} +2 -2
- package/dist/{interceptor-CrcDfLPq.mjs → interceptor-CBsqEWDK.mjs} +1 -1
- package/dist/{interceptor-CrcDfLPq.mjs.map → interceptor-CBsqEWDK.mjs.map} +1 -1
- package/dist/mock-BP-9O5On.mjs +796 -0
- package/dist/mock-BP-9O5On.mjs.map +1 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/index.d.mts +2 -2
- package/dist/{repl-editor-BlT2dFtm.mjs → repl-editor-CZpLlOBj.mjs} +1 -1
- package/dist/{repl-editor-BlT2dFtm.mjs.map → repl-editor-CZpLlOBj.mjs.map} +1 -1
- package/dist/{runtime-D97Ydu2S.mjs → runtime-DDYL2Zf1.mjs} +148 -70
- package/dist/runtime-DDYL2Zf1.mjs.map +1 -0
- package/dist/{service-CCgw66c6.mjs → service-obEU5gSM.mjs} +1 -1
- package/dist/{service-CCgw66c6.mjs.map → service-obEU5gSM.mjs.map} +1 -1
- package/dist/{tailor-db-field-Hx9OqPWY.d.mts → tailor-db-field-Bn8ZC5lK.d.mts} +1 -1
- package/dist/{schema-DBq6hr6h.mjs → tailordb-Bg9-TZj1.mjs} +42 -2
- package/dist/tailordb-Bg9-TZj1.mjs.map +1 -0
- package/dist/telemetry-21afNV9_.mjs +4 -0
- package/dist/{telemetry-DXitz4RH.mjs → telemetry-DcL8Fsm_.mjs} +1 -1
- package/dist/{telemetry-DXitz4RH.mjs.map → telemetry-DcL8Fsm_.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +13 -4
- package/dist/utils/test/index.mjs +12 -3
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.d.mts +12 -0
- package/dist/vitest/environment.mjs +44 -0
- package/dist/vitest/environment.mjs.map +1 -0
- package/dist/vitest/index.d.mts +345 -0
- package/dist/vitest/index.mjs +350 -0
- package/dist/vitest/index.mjs.map +1 -0
- package/dist/vitest/setup.d.mts +64 -0
- package/dist/vitest/setup.mjs +141 -0
- package/dist/vitest/setup.mjs.map +1 -0
- package/dist/{workflow.generated-DFljpJh7.d.mts → workflow.generated-i7PK4fg-.d.mts} +2 -2
- package/docs/cli/application.md +19 -17
- package/docs/cli/crashreport.md +119 -0
- package/docs/cli/executor.md +9 -9
- package/docs/cli/function.md +5 -5
- package/docs/cli/setup.md +1 -0
- package/docs/cli/tailordb.md +1 -1
- package/docs/cli/workflow.md +8 -8
- package/docs/cli-reference.md +8 -8
- package/docs/quickstart.md +2 -2
- package/docs/services/auth.md +2 -2
- package/docs/services/secret.md +4 -4
- package/docs/services/tailordb-migration.md +10 -10
- package/docs/services/tailordb.md +44 -13
- package/docs/services/workflow.md +1 -1
- package/docs/testing.md +530 -243
- package/package.json +32 -6
- package/dist/application-B4zVVNRS.mjs.map +0 -1
- package/dist/application-BIzicxMA.mjs +0 -4
- package/dist/client-BwXkoiMq.mjs.map +0 -1
- package/dist/crash-report-CtYCva4d.mjs.map +0 -1
- package/dist/runtime-D97Ydu2S.mjs.map +0 -1
- package/dist/schema-DBq6hr6h.mjs.map +0 -1
- package/dist/telemetry-BvI1EgMG.mjs +0 -4
- package/docs/cli/crash-report.md +0 -118
package/dist/cli/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { G as PATScope, R as AuthInvokerSchema, c as fetchUserInfo, d as initOperatorClient, h as userAgent, i as fetchAll, j as FunctionExecution_Type, n as closeConnectionPool, o as fetchPaged, s as fetchPlatformMachineUserToken, u as initOAuth2Client } from "../client-
|
|
3
|
+
import { G as PATScope, R as AuthInvokerSchema, c as fetchUserInfo, d as initOperatorClient, h as userAgent, i as fetchAll, j as FunctionExecution_Type, n as closeConnectionPool, o as fetchPaged, s as fetchPlatformMachineUserToken, u as initOAuth2Client } from "../client-COfsXV69.mjs";
|
|
4
4
|
import { n as logger, r as styles } from "../logger-DTNAMYGy.mjs";
|
|
5
|
-
import { $ as deleteCommand$3, At as executionsCommand, C as listCommand$13, Cn as toPageDirection, Ct as jobsCommand, E as resumeCommand, Et as startCommand, F as showCommand, Ft as getCommand$1, G as getCommand$5, H as treeCommand, I as logBetaWarning, Lt as
|
|
6
|
-
import { C as loadWorkspaceId, D as writePlatformConfig, E as saveUserTokens, S as loadAccessToken, T as resolveTokens, _ as getDistDir, a as WorkflowJobSchema, b as deleteUserTokens, c as ExecutorSchema, i as resolveInlineSourcemap, l as INVOKER_EXPR, o as ResolverSchema, w as readPlatformConfig, x as fetchLatestToken, y as loadConfig } from "../application-
|
|
5
|
+
import { $ as deleteCommand$3, At as executionsCommand, C as listCommand$13, Cn as toPageDirection, Ct as jobsCommand, E as resumeCommand, Et as startCommand, F as showCommand, Ft as getCommand$1, G as getCommand$5, H as treeCommand, I as logBetaWarning, Lt as deploy, N as generateCommand$1, Nt as functionExecutionStatusToString, O as listCommand$12, Ot as getCommand$6, Pt as formatKeyValueTable, R as removeCommand$1, Rt as executeScript, Sn as paginationArgs, T as healthCommand, U as listCommand$11, Vt as parseMigrationLabelNumber, Y as listCommand$10, Z as getCommand$4, Zt as formatMigrationNumber, _n as commonArgs, _t as webhookCommand, at as getCommand$3, b as createCommand$4, bn as isVerbose, bt as listCommand$6, c as listCommand$14, ct as tokenCommand, dn as trnPrefix, dt as generate, en as getMigrationFilePath, f as restoreCommand, ft as listCommand$7, g as getCommand$7, gn as defineAppCommand, i as updateCommand$4, in as loadDiff, j as truncateCommand, ln as getNamespacesWithMigrations, lt as listCommand$8, m as listCommand$15, mn as apiCommand, mt as getCommand$2, o as removeCommand, pn as prompt, q as updateCommand$2, r as queryCommand, rn as isValidMigrationNumber, rt as listCommand$9, t as isNativeTypeScriptRuntime, tn as getMigrationFiles, tt as createCommand$3, u as inviteCommand, un as sdkNameLabelKey, v as deleteCommand$4, vn as confirmationArgs, vt as triggerCommand, wn as workspaceArgs, xn as pagedLogArgs, yn as deploymentArgs, z as updateCommand$3 } from "../runtime-DDYL2Zf1.mjs";
|
|
6
|
+
import { C as loadWorkspaceId, D as writePlatformConfig, E as saveUserTokens, S as loadAccessToken, T as resolveTokens, _ as getDistDir, a as WorkflowJobSchema, b as deleteUserTokens, c as ExecutorSchema, i as resolveInlineSourcemap, l as INVOKER_EXPR, o as ResolverSchema, w as readPlatformConfig, x as fetchLatestToken, y as loadConfig } from "../application-TasSqBTD.mjs";
|
|
7
7
|
import { t as multiline } from "../multiline-e3IpANmS.mjs";
|
|
8
8
|
import { t as readPackageJson } from "../package-json-6Px8bDpG.mjs";
|
|
9
9
|
import { n as isCLIError } from "../errors-wNQxQQBH.mjs";
|
|
10
|
-
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../
|
|
10
|
+
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-CKJwnWsX.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
12
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
13
13
|
import { withCompletionCommand } from "politty/completion";
|
|
@@ -23,8 +23,8 @@ import * as http from "node:http";
|
|
|
23
23
|
import * as crypto from "node:crypto";
|
|
24
24
|
import { resolvePackageJSON, resolveTSConfig } from "pkg-types";
|
|
25
25
|
import { create } from "@bufbuild/protobuf";
|
|
26
|
-
import * as rolldown from "rolldown";
|
|
27
26
|
import open from "open";
|
|
27
|
+
import * as rolldown from "rolldown";
|
|
28
28
|
import { TraceMap, generatedPositionFor, originalPositionFor } from "@jridgewell/trace-mapping";
|
|
29
29
|
import { spawn, spawnSync } from "node:child_process";
|
|
30
30
|
import * as fs from "fs";
|
|
@@ -32,38 +32,6 @@ import { lookup } from "mime-types";
|
|
|
32
32
|
import pLimit from "p-limit";
|
|
33
33
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
34
34
|
|
|
35
|
-
//#region src/cli/commands/apply/index.ts
|
|
36
|
-
const applyCommand = defineAppCommand({
|
|
37
|
-
name: "apply",
|
|
38
|
-
description: "Apply Tailor configuration to deploy your application.",
|
|
39
|
-
args: z.object({
|
|
40
|
-
...deploymentArgs,
|
|
41
|
-
...confirmationArgs,
|
|
42
|
-
"dry-run": arg(z.boolean().optional(), {
|
|
43
|
-
alias: "d",
|
|
44
|
-
description: "Run the command without making any changes"
|
|
45
|
-
}),
|
|
46
|
-
"no-schema-check": arg(z.boolean().optional(), { description: "Skip schema diff check against migration snapshots" }),
|
|
47
|
-
"no-cache": arg(z.boolean().optional(), { description: "Disable bundle caching for this run" }),
|
|
48
|
-
"clean-cache": arg(z.boolean().optional(), { description: "Clean the bundle cache before building" })
|
|
49
|
-
}).strict(),
|
|
50
|
-
run: async (args) => {
|
|
51
|
-
const { initTelemetry } = await import("../telemetry-BvI1EgMG.mjs");
|
|
52
|
-
await initTelemetry();
|
|
53
|
-
await apply({
|
|
54
|
-
workspaceId: args["workspace-id"],
|
|
55
|
-
profile: args.profile,
|
|
56
|
-
configPath: args.config,
|
|
57
|
-
dryRun: args["dry-run"],
|
|
58
|
-
yes: args.yes,
|
|
59
|
-
noSchemaCheck: args["no-schema-check"],
|
|
60
|
-
noCache: args["no-cache"],
|
|
61
|
-
cleanCache: args["clean-cache"]
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
35
|
//#region src/cli/commands/authconnection/args.ts
|
|
68
36
|
/**
|
|
69
37
|
* Arguments for identifying an auth connection
|
|
@@ -296,7 +264,7 @@ const authconnectionCommand = defineCommand({
|
|
|
296
264
|
});
|
|
297
265
|
|
|
298
266
|
//#endregion
|
|
299
|
-
//#region src/cli/commands/
|
|
267
|
+
//#region src/cli/commands/crashreport/list.ts
|
|
300
268
|
function orderAndLimitCrashReports(entries, options) {
|
|
301
269
|
const sorted = entries.filter((f) => f.endsWith(CRASH_LOG_EXTENSION)).sort();
|
|
302
270
|
const ordered = options.order === "asc" ? sorted : sorted.reverse();
|
|
@@ -333,7 +301,7 @@ const listCommand$5 = defineAppCommand({
|
|
|
333
301
|
});
|
|
334
302
|
|
|
335
303
|
//#endregion
|
|
336
|
-
//#region src/cli/commands/
|
|
304
|
+
//#region src/cli/commands/crashreport/send.ts
|
|
337
305
|
const sendCommand = defineAppCommand({
|
|
338
306
|
name: "send",
|
|
339
307
|
description: "Submit a crash report to help improve the SDK.",
|
|
@@ -388,9 +356,10 @@ function parseCrashLogFile(content) {
|
|
|
388
356
|
}
|
|
389
357
|
|
|
390
358
|
//#endregion
|
|
391
|
-
//#region src/cli/commands/
|
|
359
|
+
//#region src/cli/commands/crashreport/index.ts
|
|
392
360
|
const crashReportCommand = defineCommand({
|
|
393
|
-
name: "
|
|
361
|
+
name: "crashreport",
|
|
362
|
+
aliases: ["crash-report"],
|
|
394
363
|
description: "Manage crash reports.",
|
|
395
364
|
subCommands: {
|
|
396
365
|
list: listCommand$5,
|
|
@@ -401,6 +370,39 @@ const crashReportCommand = defineCommand({
|
|
|
401
370
|
}
|
|
402
371
|
});
|
|
403
372
|
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/cli/commands/deploy/index.ts
|
|
375
|
+
const deployCommand$1 = defineAppCommand({
|
|
376
|
+
name: "deploy",
|
|
377
|
+
aliases: ["apply"],
|
|
378
|
+
description: "Deploy your application by applying the Tailor configuration.",
|
|
379
|
+
args: z.object({
|
|
380
|
+
...deploymentArgs,
|
|
381
|
+
...confirmationArgs,
|
|
382
|
+
"dry-run": arg(z.boolean().optional(), {
|
|
383
|
+
alias: "d",
|
|
384
|
+
description: "Run the command without making any changes"
|
|
385
|
+
}),
|
|
386
|
+
"no-schema-check": arg(z.boolean().optional(), { description: "Skip schema diff check against migration snapshots" }),
|
|
387
|
+
"no-cache": arg(z.boolean().optional(), { description: "Disable bundle caching for this run" }),
|
|
388
|
+
"clean-cache": arg(z.boolean().optional(), { description: "Clean the bundle cache before building" })
|
|
389
|
+
}).strict(),
|
|
390
|
+
run: async (args) => {
|
|
391
|
+
const { initTelemetry } = await import("../telemetry-21afNV9_.mjs");
|
|
392
|
+
await initTelemetry();
|
|
393
|
+
await deploy({
|
|
394
|
+
workspaceId: args["workspace-id"],
|
|
395
|
+
profile: args.profile,
|
|
396
|
+
configPath: args.config,
|
|
397
|
+
dryRun: args["dry-run"],
|
|
398
|
+
yes: args.yes,
|
|
399
|
+
noSchemaCheck: args["no-schema-check"],
|
|
400
|
+
noCache: args["no-cache"],
|
|
401
|
+
cleanCache: args["clean-cache"]
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
404
406
|
//#endregion
|
|
405
407
|
//#region src/cli/commands/executor/index.ts
|
|
406
408
|
const executorCommand = defineCommand({
|
|
@@ -870,6 +872,11 @@ function printFunctionExecutionDetail(options) {
|
|
|
870
872
|
* to a plain-text format when the script cannot be retrieved or when
|
|
871
873
|
* the current registry entry is stale relative to the execution.
|
|
872
874
|
*
|
|
875
|
+
* When `executionContentHash` is non-empty, the download is pinned to
|
|
876
|
+
* that exact bundle so mapping stays correct across redeploys. When
|
|
877
|
+
* empty (older servers), falls back to comparing `registryUpdatedAt`
|
|
878
|
+
* against `executionStartedAt`.
|
|
879
|
+
*
|
|
873
880
|
* `FunctionExecution.scriptName` does not match the function registry
|
|
874
881
|
* name directly; `scriptNameToRegistryName` translates between the two
|
|
875
882
|
* formats.
|
|
@@ -878,16 +885,30 @@ function printFunctionExecutionDetail(options) {
|
|
|
878
885
|
* @param options.workspaceId - Workspace ID
|
|
879
886
|
* @param options.scriptName - Script name (matches FunctionExecution.scriptName)
|
|
880
887
|
* @param options.executionType - Execution type used to discriminate registry name translation
|
|
881
|
-
* @param options.
|
|
888
|
+
* @param options.executionContentHash - Content hash of the bundle that ran; pins the download when non-empty
|
|
889
|
+
* @param options.executionStartedAt - Execution start timestamp used as fallback staleness signal
|
|
882
890
|
* @returns Bundled script content, or null when unavailable / stale
|
|
883
891
|
*/
|
|
884
892
|
async function downloadScriptForMapping(options) {
|
|
885
|
-
const { client, workspaceId, scriptName, executionType, executionStartedAt } = options;
|
|
893
|
+
const { client, workspaceId, scriptName, executionType, executionContentHash, executionStartedAt } = options;
|
|
886
894
|
const registryName = scriptNameToRegistryName(scriptName, executionType);
|
|
887
895
|
if (registryName == null) {
|
|
888
896
|
logger.debug(`Script "${scriptName}" is not a deployed registry script (e.g. test-run or seed); skipping sourcemap mapping.`);
|
|
889
897
|
return null;
|
|
890
898
|
}
|
|
899
|
+
if (executionContentHash !== "") {
|
|
900
|
+
const pinned = await downloadFunctionScript({
|
|
901
|
+
client,
|
|
902
|
+
workspaceId,
|
|
903
|
+
name: registryName,
|
|
904
|
+
contentHash: executionContentHash
|
|
905
|
+
});
|
|
906
|
+
if (pinned == null) {
|
|
907
|
+
logger.debug(`Could not download pinned script "${scriptName}" (registry: "${registryName}", contentHash: "${executionContentHash}") for stack trace mapping; showing raw stack trace.`);
|
|
908
|
+
return null;
|
|
909
|
+
}
|
|
910
|
+
return pinned.code;
|
|
911
|
+
}
|
|
891
912
|
const result = await downloadFunctionScript({
|
|
892
913
|
client,
|
|
893
914
|
workspaceId,
|
|
@@ -908,7 +929,7 @@ const logsCommand = defineAppCommand({
|
|
|
908
929
|
description: "List or get function execution logs.",
|
|
909
930
|
notes: `When viewing a specific execution that failed, the command displays error details with the stack trace mapped back to original source files via the inline sourcemap (clickable file links and code snippets, matching \`function test-run\` output).
|
|
910
931
|
|
|
911
|
-
|
|
932
|
+
The download is pinned to the bundle that actually ran using the execution's content hash, so stack traces stay accurate across redeploys when the server retains old bundles. The command falls back to a plain-text error display when the pinned bundle cannot be retrieved, or when the execution was recorded before content hashes started being tracked and the function was redeployed after it ran.`,
|
|
912
933
|
examples: [
|
|
913
934
|
{
|
|
914
935
|
cmd: "",
|
|
@@ -930,7 +951,7 @@ When the deployed script cannot be downloaded or the function has been redeploye
|
|
|
930
951
|
args: z.object({
|
|
931
952
|
...workspaceArgs,
|
|
932
953
|
...pagedLogArgs,
|
|
933
|
-
|
|
954
|
+
"execution-id": arg(z.string().optional(), {
|
|
934
955
|
positional: true,
|
|
935
956
|
description: "Execution ID (if provided, shows details with logs)"
|
|
936
957
|
})
|
|
@@ -959,6 +980,7 @@ When the deployed script cannot be downloaded or the function has been redeploye
|
|
|
959
980
|
workspaceId,
|
|
960
981
|
scriptName: detail.scriptName,
|
|
961
982
|
executionType: execution.type,
|
|
983
|
+
executionContentHash: execution.contentHash,
|
|
962
984
|
executionStartedAt: detail.startedAt
|
|
963
985
|
}) : null
|
|
964
986
|
});
|
|
@@ -1543,7 +1565,7 @@ const generateCommand = defineAppCommand({
|
|
|
1543
1565
|
})
|
|
1544
1566
|
}).strict(),
|
|
1545
1567
|
run: async (args) => {
|
|
1546
|
-
const { initTelemetry } = await import("../telemetry-
|
|
1568
|
+
const { initTelemetry } = await import("../telemetry-21afNV9_.mjs");
|
|
1547
1569
|
await initTelemetry();
|
|
1548
1570
|
await generate({
|
|
1549
1571
|
configPath: args.config,
|
|
@@ -2436,7 +2458,7 @@ const secretCommand = defineCommand({
|
|
|
2436
2458
|
|
|
2437
2459
|
//#endregion
|
|
2438
2460
|
//#region src/cli/commands/setup/github/deploy.workflow.yml
|
|
2439
|
-
var deploy_workflow_default = "name:
|
|
2461
|
+
var deploy_workflow_default = "name: Tailor Platform\n\non:\n pull_request:\n branches:\n - main\n push:\n branches:\n - main\n workflow_dispatch:\n\nconcurrency:\n group: tailor-__WORKSPACE_NAME__-${{ github.head_ref || github.ref }}\n cancel-in-progress: ${{ github.event_name == 'pull_request' }}\n\njobs:\n # __PLAN_JOB_START__\n plan:\n if: github.event_name == 'pull_request'\n runs-on: ubuntu-latest\n permissions:\n contents: read\n pull-requests: write\n steps:\n - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n with:\n fetch-depth: 0\n # __SETUP_STEPS__\n - uses: tailor-platform/actions/plan@e63ed98630a23fa21ee0636abf0f7fb75fcdce40 # v1.1.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n github-token: ${{ secrets.GITHUB_TOKEN }}\n # __PLAN_JOB_END__\n deploy:\n if: github.event_name != 'pull_request'\n runs-on: ubuntu-latest\n permissions:\n contents: read\n steps:\n - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n # __SETUP_STEPS__\n - uses: tailor-platform/actions/deploy@e63ed98630a23fa21ee0636abf0f7fb75fcdce40 # v1.1.0\n with:\n workspace-name: __WORKSPACE_NAME__\n workspace-region: __WORKSPACE_REGION__\n organization-id: __ORGANIZATION_ID__\n folder-id: __FOLDER_ID__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
|
|
2440
2462
|
|
|
2441
2463
|
//#endregion
|
|
2442
2464
|
//#region src/cli/commands/setup/github/setup-bun.yml
|
|
@@ -2479,19 +2501,24 @@ function detectPackageManager(dir) {
|
|
|
2479
2501
|
return "npm";
|
|
2480
2502
|
}
|
|
2481
2503
|
/**
|
|
2482
|
-
* Render the deploy
|
|
2504
|
+
* Render the deploy workflow YAML.
|
|
2483
2505
|
*
|
|
2484
|
-
* Generates a
|
|
2506
|
+
* Generates a workflow that calls the composite deploy action
|
|
2485
2507
|
* from tailor-platform/actions. The environment setup steps (Node.js,
|
|
2486
2508
|
* package manager, dependency install) are generated based on the
|
|
2487
2509
|
* detected package manager.
|
|
2510
|
+
*
|
|
2511
|
+
* If withPlan is true, also includes a plan job that runs on pull requests.
|
|
2512
|
+
* Otherwise, the plan job section delimited by __PLAN_JOB_START__ /
|
|
2513
|
+
* __PLAN_JOB_END__ markers is stripped from the template.
|
|
2488
2514
|
* @param params - Workspace and deployment configuration
|
|
2489
2515
|
* @returns Workflow YAML content
|
|
2490
2516
|
*/
|
|
2491
2517
|
function renderDeploy(params) {
|
|
2492
|
-
const { workspaceName, workspaceRegion, organizationId, folderId, workingDirectory, packageManager } = params;
|
|
2518
|
+
const { workspaceName, workspaceRegion, organizationId, folderId, workingDirectory, packageManager, withPlan } = params;
|
|
2493
2519
|
const workingDirectoryLine = workingDirectory ? ` working-directory: ${workingDirectory}\n` : "";
|
|
2494
|
-
|
|
2520
|
+
const stripPlanSection = (content) => withPlan ? content.replace(/^ *# __PLAN_JOB_(?:START|END)__\n/gm, "") : content.replace(/^ *# __PLAN_JOB_START__\n[\s\S]*?^ *# __PLAN_JOB_END__\n/m, "");
|
|
2521
|
+
return stripPlanSection(deploy_workflow_default).replaceAll("__WORKSPACE_NAME__", () => workspaceName).replaceAll("__WORKSPACE_REGION__", () => workspaceRegion).replaceAll("__ORGANIZATION_ID__", () => organizationId).replaceAll("__FOLDER_ID__", () => folderId).replace(/ *# __WORKING_DIRECTORY__\n/g, () => workingDirectoryLine).replace(/^ *# __SETUP_STEPS__$/gm, () => indentSnippet(setupSteps[packageManager], 6));
|
|
2495
2522
|
}
|
|
2496
2523
|
|
|
2497
2524
|
//#endregion
|
|
@@ -2503,15 +2530,18 @@ function renderDeploy(params) {
|
|
|
2503
2530
|
*/
|
|
2504
2531
|
function buildFiles(options) {
|
|
2505
2532
|
const githubDir = path.join(options.outputDir, ".github");
|
|
2533
|
+
const packageManager = detectPackageManager(options.outputDir);
|
|
2534
|
+
const workingDirectory = options.dir !== "." ? options.dir : void 0;
|
|
2506
2535
|
return [{
|
|
2507
|
-
path: path.join(githubDir, `workflows/
|
|
2536
|
+
path: path.join(githubDir, `workflows/tailor-${options.workspaceName}.yml`),
|
|
2508
2537
|
content: renderDeploy({
|
|
2509
2538
|
workspaceName: options.workspaceName,
|
|
2510
2539
|
workspaceRegion: options.workspaceRegion,
|
|
2511
2540
|
organizationId: options.organizationId,
|
|
2512
2541
|
folderId: options.folderId,
|
|
2513
|
-
workingDirectory
|
|
2514
|
-
packageManager
|
|
2542
|
+
workingDirectory,
|
|
2543
|
+
packageManager,
|
|
2544
|
+
withPlan: options.withPlan
|
|
2515
2545
|
})
|
|
2516
2546
|
}];
|
|
2517
2547
|
}
|
|
@@ -2556,6 +2586,11 @@ function setupGitHub(options) {
|
|
|
2556
2586
|
logger.info("Next steps - set GitHub secrets:");
|
|
2557
2587
|
logger.log(` gh secret set PLATFORM_MACHINE_USER_CLIENT_ID`);
|
|
2558
2588
|
logger.log(` gh secret set PLATFORM_MACHINE_USER_CLIENT_SECRET`);
|
|
2589
|
+
if (options.withPlan) {
|
|
2590
|
+
logger.newline();
|
|
2591
|
+
logger.info("For plan job - set GitHub variable with your workspace ID:");
|
|
2592
|
+
logger.log(` gh variable set TAILOR_PLATFORM_WORKSPACE_ID`);
|
|
2593
|
+
}
|
|
2559
2594
|
}
|
|
2560
2595
|
|
|
2561
2596
|
//#endregion
|
|
@@ -2583,6 +2618,10 @@ const githubCommand = defineAppCommand({
|
|
|
2583
2618
|
dir: arg(z.string().default("."), {
|
|
2584
2619
|
alias: "d",
|
|
2585
2620
|
description: "App directory (for monorepo setups)"
|
|
2621
|
+
}),
|
|
2622
|
+
"with-plan": arg(z.boolean().default(false), {
|
|
2623
|
+
alias: "p",
|
|
2624
|
+
description: "Include plan job for PR previews"
|
|
2586
2625
|
})
|
|
2587
2626
|
}).strict(),
|
|
2588
2627
|
run: (args) => {
|
|
@@ -2592,7 +2631,8 @@ const githubCommand = defineAppCommand({
|
|
|
2592
2631
|
organizationId: args["organization-id"],
|
|
2593
2632
|
folderId: args["folder-id"],
|
|
2594
2633
|
dir: args.dir,
|
|
2595
|
-
outputDir: process.cwd()
|
|
2634
|
+
outputDir: process.cwd(),
|
|
2635
|
+
withPlan: args["with-plan"]
|
|
2596
2636
|
});
|
|
2597
2637
|
}
|
|
2598
2638
|
});
|
|
@@ -3731,9 +3771,9 @@ const upgradeCommand = defineAppCommand({
|
|
|
3731
3771
|
})
|
|
3732
3772
|
}).strict(),
|
|
3733
3773
|
run: async (args) => {
|
|
3734
|
-
const { initTelemetry } = await import("../telemetry-
|
|
3774
|
+
const { initTelemetry } = await import("../telemetry-21afNV9_.mjs");
|
|
3735
3775
|
await initTelemetry();
|
|
3736
|
-
const { upgrade } = await import("../service-
|
|
3776
|
+
const { upgrade } = await import("../service-obEU5gSM.mjs");
|
|
3737
3777
|
await upgrade({
|
|
3738
3778
|
from: args.from,
|
|
3739
3779
|
dryRun: args["dry-run"],
|
|
@@ -4107,9 +4147,9 @@ const mainCommand = withCompletionCommand(defineCommand({
|
|
|
4107
4147
|
description: packageJson.description || "Tailor CLI for managing Tailor Platform SDK applications",
|
|
4108
4148
|
subCommands: {
|
|
4109
4149
|
api: apiCommand,
|
|
4110
|
-
apply: applyCommand,
|
|
4111
4150
|
authconnection: authconnectionCommand,
|
|
4112
|
-
|
|
4151
|
+
crashreport: crashReportCommand,
|
|
4152
|
+
deploy: deployCommand$1,
|
|
4113
4153
|
executor: executorCommand,
|
|
4114
4154
|
function: functionCommand,
|
|
4115
4155
|
generate: generateCommand,
|
|
@@ -4149,11 +4189,11 @@ runMain(mainCommand, {
|
|
|
4149
4189
|
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
4150
4190
|
} else logger.error(`Unknown error: ${error}`);
|
|
4151
4191
|
if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
|
|
4152
|
-
const { reportCrash } = await import("../
|
|
4192
|
+
const { reportCrash } = await import("../crashreport-B8lVOx0U.mjs");
|
|
4153
4193
|
await reportCrash(error, "handledError");
|
|
4154
4194
|
}
|
|
4155
4195
|
}
|
|
4156
|
-
const { shutdownTelemetry } = await import("../telemetry-
|
|
4196
|
+
const { shutdownTelemetry } = await import("../telemetry-21afNV9_.mjs");
|
|
4157
4197
|
await shutdownTelemetry();
|
|
4158
4198
|
}
|
|
4159
4199
|
});
|