@tailor-platform/sdk 2.0.0-next.1 → 2.0.0-next.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 (119) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/application-Dtqap5jM.mjs +3 -0
  3. package/dist/{client-z_oHGVNy.mjs → application-XuMWK4eq.mjs} +5861 -20
  4. package/dist/application-XuMWK4eq.mjs.map +1 -0
  5. package/dist/cli/index.mjs +179 -122
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +75 -16
  8. package/dist/cli/lib.mjs +5 -6
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/completion/zsh-worker.zsh +105 -26
  11. package/dist/configure/index.d.mts +9 -8
  12. package/dist/configure/index.mjs +56 -19
  13. package/dist/configure/index.mjs.map +1 -1
  14. package/dist/context-Bd266-ru.mjs.map +1 -1
  15. package/dist/{context-BuuIb8CC.d.mts → context-C2lEi9uw.d.mts} +7 -28
  16. package/dist/{crashreport-pr6Rhvza.mjs → crashreport-BMWcxeSE.mjs} +1 -1
  17. package/dist/{crashreport-BsjAkFWw.mjs → crashreport-DFq-vsU0.mjs} +5 -7
  18. package/dist/{crashreport-BsjAkFWw.mjs.map → crashreport-DFq-vsU0.mjs.map} +1 -1
  19. package/dist/{file-_oUZo76X.mjs → file-BbdFGdMV.mjs} +2 -10
  20. package/dist/file-BbdFGdMV.mjs.map +1 -0
  21. package/dist/{file-BB8Vs9O_.d.mts → file-Dq3NIt_F.d.mts} +3 -42
  22. package/dist/{file-utils-DcyIPFQh.mjs → file-utils-CYZnO1pX.mjs} +5 -5
  23. package/dist/file-utils-CYZnO1pX.mjs.map +1 -0
  24. package/dist/{globals-Crz8o65k.mjs → globals-Cf0sxIt8.mjs} +2 -2
  25. package/dist/{globals-Crz8o65k.mjs.map → globals-Cf0sxIt8.mjs.map} +1 -1
  26. package/dist/{http-adapter.generated-WgMnb7Sb.d.mts → http-adapter.generated-DFsXDdm5.d.mts} +11 -10
  27. package/dist/{index-BlpzXncY.d.mts → index-BI-_j9Z3.d.mts} +29 -32
  28. package/dist/{index-DjUdWlzf.d.mts → index-C4JirJH8.d.mts} +2 -2
  29. package/dist/{index-5vPyRu1y.d.mts → index-CZfWhr0a.d.mts} +2 -2
  30. package/dist/{index-CK7u9isy.d.mts → index-Cg8VKAdN.d.mts} +4 -4
  31. package/dist/{index-B7AKc18V.d.mts → index-DYRjoLXD.d.mts} +2 -2
  32. package/dist/{index-ZePLwxw7.d.mts → index-lFpcjHPU.d.mts} +8 -15
  33. package/dist/{index-CNYe5lnW.d.mts → index-nW7hE6oE.d.mts} +2 -2
  34. package/dist/{mock-BjFj5o1I.mjs → mock-FPxmnt-y.mjs} +4 -49
  35. package/dist/{mock-BjFj5o1I.mjs.map → mock-FPxmnt-y.mjs.map} +1 -1
  36. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  37. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  38. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  39. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  40. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  41. package/dist/plugin/builtin/seed/index.mjs +1 -1
  42. package/dist/plugin/index.d.mts +4 -3
  43. package/dist/plugin/index.mjs.map +1 -1
  44. package/dist/{registry-DdsYlL_P.mjs → registry-DH4m7eYo.mjs} +4 -2
  45. package/dist/registry-DH4m7eYo.mjs.map +1 -0
  46. package/dist/runtime/context.d.mts +1 -1
  47. package/dist/runtime/file.d.mts +2 -2
  48. package/dist/runtime/file.mjs +2 -2
  49. package/dist/runtime/globals.d.mts +6 -6
  50. package/dist/runtime/index.d.mts +4 -4
  51. package/dist/runtime/index.mjs +2 -2
  52. package/dist/runtime/workflow.d.mts +2 -2
  53. package/dist/runtime/workflow.mjs +1 -1
  54. package/dist/{runtime-n9NCkjee.mjs → runtime-CY4JvrDj.mjs} +777 -234
  55. package/dist/runtime-CY4JvrDj.mjs.map +1 -0
  56. package/dist/{schema-BhkpP5Hw.mjs → schema-Dtw9Orye.mjs} +16 -13
  57. package/dist/schema-Dtw9Orye.mjs.map +1 -0
  58. package/dist/{secret-file-DBqZhjFQ.mjs → secret-file-VSVGy1V0.mjs} +27 -2
  59. package/dist/{secret-file-DBqZhjFQ.mjs.map → secret-file-VSVGy1V0.mjs.map} +1 -1
  60. package/dist/{seed-jf3008-h.mjs → seed-izIEyP3z.mjs} +3 -4
  61. package/dist/seed-izIEyP3z.mjs.map +1 -0
  62. package/dist/service-DCqIWibD.mjs +3 -0
  63. package/dist/{service-DU1mVzri.mjs → service-DU1mVzri2.mjs} +1 -1
  64. package/dist/service-DU1mVzri2.mjs.map +1 -0
  65. package/dist/{service-CCL8ruDf.mjs → service-DjyqbCaJ.mjs} +7 -7
  66. package/dist/{service-CCL8ruDf.mjs.map → service-DjyqbCaJ.mjs.map} +1 -1
  67. package/dist/test-env-key-D7UkZp99.mjs +75 -0
  68. package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
  69. package/dist/{types-ClhIrW_C.mjs → types-74etvaxy.mjs} +1 -1
  70. package/dist/{types-DhO_VEZd.d.mts → types-BDRml5C3.d.mts} +12 -12
  71. package/dist/{types-B2RpYyA_.mjs → types-BQijbo4m.mjs} +9 -9
  72. package/dist/types-BQijbo4m.mjs.map +1 -0
  73. package/dist/{types-DwDgacni.d.mts → types-BX4q6Mo6.d.mts} +3 -2
  74. package/dist/types-BZ7QKVE8.d.mts +21 -0
  75. package/dist/{types-DCUhgpyI.d.mts → types-CdcQh4Z2.d.mts} +5 -76
  76. package/dist/utils/test/index.d.mts +6 -15
  77. package/dist/utils/test/index.mjs +4 -13
  78. package/dist/utils/test/index.mjs.map +1 -1
  79. package/dist/vitest/environment.mjs +1 -1
  80. package/dist/vitest/index.d.mts +2 -2
  81. package/dist/vitest/index.mjs +4 -4
  82. package/dist/vitest/setup.mjs +2 -2
  83. package/dist/{workflow-DgemCAz3.mjs → workflow-BOmaZwwG.mjs} +8 -3
  84. package/dist/workflow-BOmaZwwG.mjs.map +1 -0
  85. package/dist/{workflow-BbKvGLQg.d.mts → workflow-BVy4XWjS.d.mts} +15 -10
  86. package/dist/{workflow.generated-DtQwEo-x.d.mts → workflow.generated-ClEjBYhm.d.mts} +3 -3
  87. package/docs/cli/executor.md +53 -0
  88. package/docs/cli/setup.md +35 -33
  89. package/docs/cli/workflow.md +157 -20
  90. package/docs/cli-reference.md +26 -20
  91. package/docs/github-actions.md +29 -16
  92. package/docs/migration/v2.md +475 -0
  93. package/docs/runtime.md +1 -1
  94. package/docs/services/auth.md +12 -12
  95. package/docs/services/executor.md +3 -3
  96. package/docs/services/resolver.md +6 -6
  97. package/docs/services/tailordb.md +14 -12
  98. package/docs/services/workflow.md +4 -4
  99. package/docs/testing.md +59 -47
  100. package/package.json +7 -7
  101. package/dist/application-DB2r36Et.mjs +0 -3
  102. package/dist/application-DqS1yBg3.mjs +0 -5680
  103. package/dist/application-DqS1yBg3.mjs.map +0 -1
  104. package/dist/client-Dbohmtkv.mjs +0 -3
  105. package/dist/client-z_oHGVNy.mjs.map +0 -1
  106. package/dist/file-_oUZo76X.mjs.map +0 -1
  107. package/dist/file-utils-DcyIPFQh.mjs.map +0 -1
  108. package/dist/job-fuc3j1Ma.mjs +0 -53
  109. package/dist/job-fuc3j1Ma.mjs.map +0 -1
  110. package/dist/registry-DdsYlL_P.mjs.map +0 -1
  111. package/dist/runtime-n9NCkjee.mjs.map +0 -1
  112. package/dist/schema-BhkpP5Hw.mjs.map +0 -1
  113. package/dist/seed-jf3008-h.mjs.map +0 -1
  114. package/dist/service-D6yonf2I.mjs +0 -3
  115. package/dist/service-DU1mVzri.mjs.map +0 -1
  116. package/dist/test-env-key-D9kM6ETE.mjs +0 -49
  117. package/dist/test-env-key-D9kM6ETE.mjs.map +0 -1
  118. package/dist/types-B2RpYyA_.mjs.map +0 -1
  119. package/dist/workflow-DgemCAz3.mjs.map +0 -1
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { Et as AuthInvokerSchema, L as CustomDomainStatus, Nt as PATScope, Q as FunctionExecution_Type, _ as userAgent, a as fetchAll, c as fetchPlatformMachineUserToken, d as initOAuth2Client, f as initOperatorClient, l as fetchUserInfo, r as closeConnectionPool, s as fetchPaged } from "../client-z_oHGVNy.mjs";
2
+ import { A as loadAccessToken, At as FunctionExecution_Type, B as fetchAll, C as getDistDir, D as deleteUserTokens, E as loadConfig, F as removeLegacyUserAlias, G as initOAuth2Client, H as fetchPaged, I as resolveTokens, K as initOperatorClient, L as saveUserTokens, M as loadMachineUserName, N as loadWorkspaceId, O as fetchLatestToken, P as readPlatformConfig, R as writePlatformConfig, U as fetchPlatformMachineUserToken, W as fetchUserInfo, _ as composeFunctionTreeshakeOptions, dn as PATScope, g as platformBundleDefinePlugin, ht as CustomDomainStatus, i as resolveInlineSourcemap, in as AuthInvokerSchema, k as findConfigUserKey, l as INVOKER_EXPR, o as WorkflowJobSchema, s as ResolverSchema, t as defineApplication, v as createLogLevelTreeshakeOptions, w as hashContent$1, y as resolveBundleLogLevel, z as closeConnectionPool } from "../application-XuMWK4eq.mjs";
3
3
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
4
  import { n as logger, r as styles } from "../logger-CxF-Ex5d.mjs";
5
- import { $ as listCommand$10, $t as INITIAL_SCHEMA_NUMBER, An as commonArgs, At as startCommand, B as logBetaWarning, C as listCommand$13, Cn as PluginManager, Dt as jobsCommand, E as resumeCommand, En as apiCommand, F as writeDbTypesFile, Fn as pagedLogArgs, Gt as MIGRATION_LABEL_KEY, H as removeCommand$1, Ht as executeScript, I as getConfiguredEditorCommand, In as paginationArgs, Jt as compareSnapshotWithRemote, K as treeCommand, Kt as handleOptionalToRequiredError, L as openInConfiguredEditor, Ln as toPageDirection, Lt as functionExecutionStatusToString, Mn as confirmationArgs, Mt as getCommand$6, N as generateCommand$1, Nn as deploymentArgs, O as listCommand$12, On as assertWritable, P as generateMigrationScript, Pn as isVerbose, Pt as executionsCommand, Rn as workspaceArgs, Rt as formatKeyValueTable, Sn as sdkNameLabelKey, St as triggerCommand, T as healthCommand, Tn as prompt, U as updateCommand$3, Vt as deploy, Xt as protoGqlPermission, Y as getCommand$5, Yt as generateAllTypeManifestsFromSnapshot, Z as updateCommand$2, _n as formatMigrationDiff, an as createSnapshotFromLocalTypes, at as createCommand$3, b as createCommand$4, bn as ensureConfigId, c as listCommand$14, cn as getMigrationFilePath, dn as isValidMigrationNumber, f as restoreCommand, fn as loadDiff, ft as tokenCommand, g as getCommand$7, gt as listCommand$7, hn as parseMigrationNumberArg, ht as generate, i as updateCommand$4, j as truncateCommand, jn as configArg, kn as defineAppCommand, ln as getMigrationFiles, lt as getCommand$3, m as listCommand$15, mn as formatMigrationNumber, nn as assertValidMigrationFiles, o as removeCommand, on as getLatestMigrationNumber, pn as reconstructSnapshotFromMigrations, pt as listCommand$8, q as listCommand$11, qt as parseMigrationLabelNumber, r as queryCommand, rn as compareLocalTypesWithSnapshot, rt as deleteCommand$3, st as listCommand$9, t as isNativeTypeScriptRuntime, tt as getCommand$4, u as inviteCommand, v as deleteCommand$4, vn as hasChanges, vt as getCommand$2, wn as generateUserTypes, wt as listCommand$6, xn as resourceTrn, xt as webhookCommand, yn as getNamespacesWithMigrations, z as showCommand, zt as getCommand$1 } from "../runtime-n9NCkjee.mjs";
6
- import { A as loadAccessToken, C as getDistDir, D as deleteUserTokens, E as loadConfig, F as removeLegacyUserAlias, I as resolveTokens, L as saveUserTokens, M as loadMachineUserName, N as loadWorkspaceId, O as fetchLatestToken, P as readPlatformConfig, R as writePlatformConfig, _ as composeFunctionTreeshakeOptions, g as platformBundleDefinePlugin, i as resolveInlineSourcemap, k as findConfigUserKey, l as INVOKER_EXPR, o as WorkflowJobSchema, s as ResolverSchema, t as defineApplication, v as createLogLevelTreeshakeOptions, w as hashContent$1, y as resolveBundleLogLevel } from "../application-DqS1yBg3.mjs";
7
- import { n as ExecutorSchema } from "../service-CCL8ruDf.mjs";
5
+ import { $ as updateCommand$2, $t as protoGqlPermission, A as listCommand$12, At as jobsCommand, Bn as toPageDirection, Bt as functionExecutionStatusToString, C as listCommand$13, Cn as ensureConfigId, Ct as webhookCommand, Dn as generateUserTypes, E as waitCommand, En as PluginManager, Et as listCommand$6, F as generateCommand$1, Fn as confirmationArgs, Ft as getCommand$6, G as updateCommand$3, Gt as executeScript, H as logBetaWarning, Ht as getCommand$1, I as generateMigrationScript, In as deploymentArgs, J as treeCommand, Jt as MIGRATION_LABEL_KEY, L as writeDbTypesFile, Ln as isVerbose, Lt as executionsCommand, Mn as defineAppCommand, N as truncateCommand, Nn as commonArgs, Nt as startCommand, O as resumeCommand, On as prompt, Pn as configArg, Qt as generateAllTypeManifestsFromSnapshot, R as getConfiguredEditorCommand, Rn as pagedLogArgs, Sn as getNamespacesWithMigrations, T as healthCommand, Tn as sdkNameLabelKey, V as showCommand, Vn as workspaceArgs, Vt as formatKeyValueTable, W as removeCommand$1, Wt as deploy, Xt as parseMigrationLabelNumber, Y as listCommand$11, Yt as handleOptionalToRequiredError, Z as getCommand$5, Zt as compareSnapshotWithRemote, _n as formatMigrationNumber, _t as generate, an as assertValidMigrationFiles, at as deleteCommand$3, b as createCommand$4, bn as formatMigrationDiff, bt as getCommand$2, c as listCommand$14, cn as createSnapshotFromLocalTypes, dn as getMigrationFilePath, dt as getCommand$3, f as restoreCommand, fn as getMigrationFiles, g as getCommand$7, gn as reconstructSnapshotFromMigrations, hn as loadDiff, ht as listCommand$8, i as updateCommand$4, jn as assertWritable, kn as apiCommand, ln as getLatestMigrationNumber, lt as listCommand$9, m as listCommand$15, mn as isValidMigrationNumber, mt as tokenCommand, nn as INITIAL_SCHEMA_NUMBER, o as removeCommand, on as compareLocalTypesWithSnapshot, r as queryCommand, rt as getCommand$4, st as createCommand$3, t as isNativeTypeScriptRuntime, tt as listCommand$10, u as inviteCommand, v as deleteCommand$4, vn as parseMigrationNumberArg, vt as listCommand$7, wn as resourceTrn, wt as triggerCommand, xn as hasChanges, z as openInConfiguredEditor, zn as paginationArgs } from "../runtime-CY4JvrDj.mjs";
6
+ import { n as ExecutorSchema } from "../service-DjyqbCaJ.mjs";
8
7
  import { t as multiline } from "../multiline-sfHpTZZK.mjs";
9
8
  import { t as readPackageJson } from "../package-json-8b0O9TlX.mjs";
9
+ import { i as userAgent } from "../secret-file-VSVGy1V0.mjs";
10
10
  import { n as isCLIError } from "../errors-Dtf2WPaW.mjs";
11
- import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-BsjAkFWw.mjs";
11
+ import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-DFq-vsU0.mjs";
12
12
  import { t as isPluginGeneratedType } from "../type-source-DH_LH20p.mjs";
13
13
  import { arg, defineCommand, runCommand, runMain } from "politty";
14
14
  import { withCompletionCommand } from "politty/completion";
@@ -21,6 +21,7 @@ import { dirname, resolve } from "pathe";
21
21
  import { fileURLToPath, pathToFileURL } from "node:url";
22
22
  import { generateCodeVerifier } from "@badgateway/oauth2-client";
23
23
  import { Code, ConnectError } from "@connectrpc/connect";
24
+ import pLimit from "p-limit";
24
25
  import { resolvePackageJSON, resolveTSConfig } from "pkg-types";
25
26
  import * as crypto from "node:crypto";
26
27
  import { createHash } from "node:crypto";
@@ -29,13 +30,12 @@ import open from "open";
29
30
  import * as rolldown from "rolldown";
30
31
  import * as fsPromises from "node:fs/promises";
31
32
  import { glob } from "node:fs/promises";
32
- import pLimit from "p-limit";
33
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
33
34
  import { TraceMap, generatedPositionFor, originalPositionFor } from "@jridgewell/trace-mapping";
34
35
  import { spawn, spawnSync } from "node:child_process";
35
36
  import { watch } from "chokidar";
36
37
  import * as fs from "fs";
37
38
  import { lookup } from "mime-types";
38
- import { setTimeout as setTimeout$1 } from "node:timers/promises";
39
39
 
40
40
  //#region src/cli/commands/authconnection/args.ts
41
41
  /**
@@ -1143,21 +1143,21 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1143
1143
  export { _fn as main };
1144
1144
  `;
1145
1145
  case "resolver": {
1146
- const userExpr = buildMachineUserExpr(machineUser, workspaceId);
1146
+ const principalExpr = buildMachinePrincipalExpr(machineUser, workspaceId);
1147
1147
  return multiline`
1148
1148
  import _internalResolver from "${absoluteSourcePath}";
1149
1149
  import { t } from "@tailor-platform/sdk";
1150
1150
 
1151
1151
  const _env = ${JSON.stringify(env)};
1152
- const _user = ${userExpr};
1152
+ const _caller = ${principalExpr};
1153
1153
 
1154
1154
  const $tailor_resolver_body = async (context) => {
1155
- const _invoker = ${INVOKER_EXPR};
1155
+ const _invoker = ${INVOKER_EXPR} ?? _caller;
1156
1156
  if (_internalResolver.input) {
1157
1157
  const result = t.object(_internalResolver.input).parse({
1158
1158
  value: context,
1159
1159
  data: context,
1160
- user: _user,
1160
+ invoker: _invoker,
1161
1161
  });
1162
1162
 
1163
1163
  if (result.issues) {
@@ -1168,7 +1168,7 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1168
1168
  }
1169
1169
  }
1170
1170
 
1171
- const enrichedContext = { input: context, env: _env, user: _user, invoker: _invoker };
1171
+ const enrichedContext = { input: context, env: _env, caller: _caller, invoker: _invoker };
1172
1172
  return _internalResolver.body(enrichedContext);
1173
1173
  };
1174
1174
 
@@ -1176,15 +1176,15 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1176
1176
  `;
1177
1177
  }
1178
1178
  case "executor": {
1179
- const actorExpr = buildMachineActorExpr(machineUser, workspaceId);
1179
+ const principalExpr = buildMachinePrincipalExpr(machineUser, workspaceId);
1180
1180
  return multiline`
1181
1181
  import _internalExecutor from "${absoluteSourcePath}";
1182
1182
 
1183
1183
  const _env = ${JSON.stringify(env)};
1184
- const _actor = ${actorExpr};
1184
+ const _actor = ${principalExpr};
1185
1185
 
1186
1186
  const __executor_function = async (args) => {
1187
- const _invoker = ${INVOKER_EXPR};
1187
+ const _invoker = ${INVOKER_EXPR} ?? _actor;
1188
1188
  return _internalExecutor.operation.body({ ...args, env: _env, actor: _actor, invoker: _invoker });
1189
1189
  };
1190
1190
 
@@ -1193,13 +1193,15 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1193
1193
  }
1194
1194
  case "workflow-job": {
1195
1195
  const exportName = assertDefined(detected.exportName, "workflow job export name missing");
1196
+ const principalExpr = buildMachinePrincipalExpr(machineUser, workspaceId);
1196
1197
  return multiline`
1197
1198
  import { ${exportName} } from "${absoluteSourcePath}";
1198
1199
 
1199
1200
  const env = ${JSON.stringify(env)};
1201
+ const fallbackInvoker = ${principalExpr};
1200
1202
 
1201
1203
  export async function main(input) {
1202
- const invoker = ${INVOKER_EXPR};
1204
+ const invoker = ${INVOKER_EXPR} ?? fallbackInvoker;
1203
1205
  return await ${exportName}.body(input, { env, invoker });
1204
1206
  }
1205
1207
  `;
@@ -1207,35 +1209,20 @@ function generateEntry(detected, sourceFile, env, machineUser, workspaceId) {
1207
1209
  }
1208
1210
  }
1209
1211
  /**
1210
- * Build a JSON expression for a machine user TailorUser object.
1212
+ * Build a JSON expression for a machine user TailorPrincipal object.
1211
1213
  * @param machineUser - Resolved machine user info
1212
1214
  * @param workspaceId - Workspace ID
1213
1215
  * @returns JSON string for the user expression
1214
1216
  */
1215
- function buildMachineUserExpr(machineUser, workspaceId) {
1217
+ function buildMachinePrincipalExpr(machineUser, workspaceId) {
1216
1218
  return JSON.stringify({
1217
1219
  id: machineUser.id,
1218
1220
  type: "machine_user",
1219
1221
  workspaceId,
1220
- attributes: machineUser.attributes,
1222
+ attributes: machineUser.attributes ?? {},
1221
1223
  attributeList: machineUser.attributeList
1222
1224
  });
1223
1225
  }
1224
- /**
1225
- * Build a JSON expression for a machine user TailorActor object.
1226
- * @param machineUser - Resolved machine user info
1227
- * @param workspaceId - Workspace ID
1228
- * @returns JSON string for the actor expression
1229
- */
1230
- function buildMachineActorExpr(machineUser, workspaceId) {
1231
- return JSON.stringify({
1232
- workspaceId,
1233
- userId: machineUser.id,
1234
- attributes: machineUser.attributes,
1235
- attributeList: machineUser.attributeList,
1236
- userType: "USER_TYPE_MACHINE_USER"
1237
- });
1238
- }
1239
1226
 
1240
1227
  //#endregion
1241
1228
  //#region src/cli/commands/function/detect.ts
@@ -1258,7 +1245,7 @@ async function detectFunctionType(options) {
1258
1245
  const rawInput = module.default.input;
1259
1246
  let inputSchema;
1260
1247
  if (rawInput) {
1261
- const { t } = await import("../types-ClhIrW_C.mjs");
1248
+ const { t } = await import("../types-74etvaxy.mjs");
1262
1249
  inputSchema = t.object(rawInput);
1263
1250
  }
1264
1251
  return {
@@ -1444,11 +1431,9 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
1444
1431
  functionType = detected.type;
1445
1432
  functionName = detected.name;
1446
1433
  logger.info(`Detected: ${styles.bold(detected.type)} ${styles.info(`"${detected.name}"`)}`);
1447
- if (detected.type === "resolver" && args.arg) {
1448
- if (!detected.hasInput) {
1449
- logger.warn("--arg is ignored because this resolver has no input schema. Define \"input\" in your resolver to use --arg.");
1450
- args.arg = void 0;
1451
- } else if (detected.inputSchema) JSON.parse(args.arg);
1434
+ if (detected.type === "resolver" && args.arg && !detected.hasInput) {
1435
+ logger.warn("--arg is ignored because this resolver has no input schema. Define \"input\" in your resolver to use --arg.");
1436
+ args.arg = void 0;
1452
1437
  }
1453
1438
  logger.info("Bundling...");
1454
1439
  ({bundledCode, scriptName} = await bundleForTestRun({
@@ -1462,18 +1447,24 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
1462
1447
  }));
1463
1448
  logger.info(`Bundled as ${styles.bold(scriptName)}`);
1464
1449
  }
1465
- const authInvoker = create(AuthInvokerSchema, {
1450
+ const invoker = create(AuthInvokerSchema, {
1466
1451
  namespace: authNamespace,
1467
1452
  machineUserName: machineUser.name
1468
1453
  });
1469
1454
  logger.info(`Executing on workspace ${styles.dim(workspaceId)}...`);
1455
+ let parsedArg;
1456
+ if (args.arg !== void 0) try {
1457
+ parsedArg = JSON.parse(args.arg);
1458
+ } catch (error) {
1459
+ throw new Error(`Invalid --arg JSON: ${error instanceof Error ? error.message : error}`, { cause: error });
1460
+ }
1470
1461
  const result = await executeScript({
1471
1462
  client,
1472
1463
  workspaceId,
1473
1464
  name: scriptName,
1474
1465
  code: bundledCode,
1475
- arg: args.arg,
1476
- invoker: authInvoker
1466
+ arg: parsedArg,
1467
+ invoker
1477
1468
  });
1478
1469
  if (jsonOutput) logger.out({
1479
1470
  success: result.success,
@@ -2551,7 +2542,7 @@ const secretCommand = defineCommand({
2551
2542
  });
2552
2543
 
2553
2544
  //#endregion
2554
- //#region src/cli/commands/setup/github/git.ts
2545
+ //#region src/cli/commands/setup/git.ts
2555
2546
  const defaultGitRunner = (args, cwd) => {
2556
2547
  const result = spawnSync("git", args, {
2557
2548
  cwd,
@@ -2582,7 +2573,7 @@ function detectDefaultBranch(cwd, run = defaultGitRunner) {
2582
2573
  }
2583
2574
 
2584
2575
  //#endregion
2585
- //#region src/cli/commands/setup/github/lock.ts
2576
+ //#region src/cli/commands/setup/lock.ts
2586
2577
  /** Current lock schema version. Bumped only on breaking lock-format changes. */
2587
2578
  const LOCK_VERSION = 1;
2588
2579
  /** Lock file path, relative to the repository root. */
@@ -2648,66 +2639,24 @@ function findTarget(lock, kind, workspaceName) {
2648
2639
  }
2649
2640
 
2650
2641
  //#endregion
2651
- //#region src/cli/commands/setup/github/branch.workflow.yml
2652
- var branch_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n # __PULL_REQUEST_START__\n pull_request:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n # __PULL_REQUEST_END__\n push:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n workflow_dispatch:\n # __DISPATCH_INPUTS_START__\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n # __DISPATCH_INPUTS_END__\n\npermissions:\n contents: read\n\njobs:\n # __PLAN_JOB_START__\n tailor-plan:\n if: >-\n github.event_name == 'pull_request' ||\n (github.event_name == 'workflow_dispatch' && inputs['dry-run'])\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n pull-requests: write\n concurrency:\n group: tailor-plan-__WORKSPACE_NAME__-${{ github.event.pull_request.number || github.run_id }}\n cancel-in-progress: true\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n - id: tailor-merge-base\n if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork\n env:\n BASE_REF: ${{ github.base_ref }}\n run: |\n git config user.name \"github-actions[bot]\"\n git config user.email \"41898282+github-actions[bot]@users.noreply.github.com\"\n git fetch origin \"$BASE_REF:refs/remotes/origin/$BASE_REF\"\n git merge --no-edit \"origin/$BASE_REF\"\n # __SETUP_STEPS__\n - id: tailor-generate\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk generate\n - id: tailor-generate-check\n run: |\n git add -A\n if ! git diff --cached --quiet; then\n git --no-pager diff --cached --stat\n echo \"::error::Generated files are out of date. Run 'tailor-sdk generate' locally and commit the result.\"\n exit 1\n fi\n - id: tailor-mask-credentials\n # Fork PRs cannot read secrets; the checks above still run for them.\n if: >-\n (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) &&\n vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n run: |\n echo \"::add-mask::$CLIENT_ID\"\n echo \"::add-mask::$CLIENT_SECRET\"\n env:\n CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-login\n if: >-\n (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) &&\n vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk login --machine-user\n env:\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-plan\n if: >-\n (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) &&\n vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n # __WORKING_DIRECTORY__\n run: |\n if [ -z \"$TAILOR_PLATFORM_WORKSPACE_ID\" ]; then\n echo \"exit-code=\" >> \"$GITHUB_OUTPUT\"\n exit 0\n fi\n\n set +e\n OUTPUT=$(__PM_EXEC__ tailor-sdk deploy --dry-run --yes 2>&1)\n EXIT_CODE=$?\n set -e\n\n MAX_OUTPUT=60000\n if [ \"${#OUTPUT}\" -gt \"$MAX_OUTPUT\" ]; then\n LOG_STOP_TOKEN=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)\n echo \"::group::Full Tailor Platform plan output\"\n echo \"::stop-commands::$LOG_STOP_TOKEN\"\n printf '%s\\n' \"$OUTPUT\"\n echo \"::$LOG_STOP_TOKEN::\"\n echo \"::endgroup::\"\n OUTPUT_TAIL=\"${OUTPUT: -$MAX_OUTPUT}\"\n OUTPUT=$(printf '%s\\n\\n%s' \"[output truncated to the last $MAX_OUTPUT characters - see the workflow logs for the full plan]\" \"$OUTPUT_TAIL\")\n fi\n\n EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)\n {\n echo \"exit-code=$EXIT_CODE\"\n echo \"output<<$EOF\"\n echo \"$OUTPUT\"\n echo \"$EOF\"\n } >> \"$GITHUB_OUTPUT\"\n env:\n TAILOR_PLATFORM_WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n - id: tailor-plan-summary\n if: github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork\n run: |\n if [ -n \"$LABEL\" ]; then\n KEY=\"$LABEL\"\n elif [ -n \"$WORKSPACE_ID\" ]; then\n KEY=\"$WORKSPACE_ID\"\n else\n KEY=\"workspace\"\n fi\n\n if [ -z \"$WORKSPACE_ID\" ]; then\n {\n echo \"## Tailor Platform Plan ($KEY)\"\n echo \"\"\n echo \"Workspace is not provisioned yet. Set TAILOR_PLATFORM_WORKSPACE_ID after provisioning the workspace.\"\n } >> \"$GITHUB_STEP_SUMMARY\"\n exit 0\n fi\n\n if [ \"$DRY_RUN_EXIT_CODE\" = \"0\" ]; then\n STATUS=\"PASS\"\n else\n STATUS=\"FAIL\"\n fi\n\n {\n echo \"## $STATUS Tailor Platform Plan ($KEY)\"\n echo \"\"\n echo \"<details>\"\n echo \"<summary>Plan output (exit code: $DRY_RUN_EXIT_CODE)</summary>\"\n echo \"\"\n echo '```'\n echo \"$DRY_RUN_OUTPUT\"\n echo '```'\n echo \"\"\n echo \"</details>\"\n } >> \"$GITHUB_STEP_SUMMARY\"\n env:\n WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n LABEL: __WORKSPACE_NAME__\n DRY_RUN_OUTPUT: ${{ steps.tailor-plan.outputs.output }}\n DRY_RUN_EXIT_CODE: ${{ steps.tailor-plan.outputs.exit-code }}\n - id: tailor-plan-comment\n if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork\n uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9\n env:\n WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n LABEL: __WORKSPACE_NAME__\n DRY_RUN_OUTPUT: ${{ steps.tailor-plan.outputs.output }}\n DRY_RUN_EXIT_CODE: ${{ steps.tailor-plan.outputs.exit-code }}\n with:\n github-token: ${{ secrets.GITHUB_TOKEN }}\n script: |\n const workspaceId = process.env.WORKSPACE_ID;\n const label = process.env.LABEL;\n const key = label || workspaceId || 'workspace';\n const marker = `<!-- tailor-plan: ${key} -->`;\n\n let body;\n if (!workspaceId) {\n body = [\n marker,\n `## Tailor Platform Plan (${key})`,\n '',\n 'Workspace is not provisioned yet. Set TAILOR_PLATFORM_WORKSPACE_ID after provisioning the workspace.',\n '',\n ].join('\\n');\n } else {\n const exitCode = process.env.DRY_RUN_EXIT_CODE;\n let output = process.env.DRY_RUN_OUTPUT;\n const MAX_OUTPUT = 60000;\n if (output.length > MAX_OUTPUT) {\n const note = `[output truncated to the last ${MAX_OUTPUT} characters - see the job's step summary for the full plan]\\n\\n`;\n output = note + output.slice(output.length - MAX_OUTPUT);\n }\n const status = exitCode === '0' ? 'PASS' : 'FAIL';\n body = [\n marker,\n `## ${status} Tailor Platform Plan (${key})`,\n '',\n '<details>',\n `<summary>Plan output (exit code: ${exitCode})</summary>`,\n '',\n '```',\n output,\n '```',\n '',\n '</details>',\n '',\n ].join('\\n');\n }\n\n const comments = await github.paginate(github.rest.issues.listComments, {\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n per_page: 100,\n });\n const existingComment = comments.find(comment =>\n comment.body?.includes(marker) &&\n comment.user?.type === 'Bot' &&\n comment.user?.login === 'github-actions[bot]'\n );\n if (existingComment) {\n await github.rest.issues.updateComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n comment_id: existingComment.id,\n body,\n });\n } else {\n await github.rest.issues.createComment({\n owner: context.repo.owner,\n repo: context.repo.repo,\n issue_number: context.issue.number,\n body,\n });\n }\n - id: tailor-plan-fail\n if: >-\n (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) &&\n vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n run: |\n if [ \"$DRY_RUN_EXIT_CODE\" != \"0\" ]; then\n echo \"::error::Plan dry-run failed with exit code $DRY_RUN_EXIT_CODE\"\n exit \"$DRY_RUN_EXIT_CODE\"\n fi\n env:\n DRY_RUN_EXIT_CODE: ${{ steps.tailor-plan.outputs.exit-code }}\n # __PLAN_JOB_END__\n tailor-deploy:\n # __DEPLOY_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n environment: __ENVIRONMENT__\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-validate-workspace\n env:\n WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n run: |\n if [ -z \"$WORKSPACE_ID\" ]; then\n echo \"::error::Workspace is not provisioned: TAILOR_PLATFORM_WORKSPACE_ID is empty. Provision the workspace and set the variable.\"\n exit 1\n fi\n - id: tailor-mask-credentials\n run: |\n echo \"::add-mask::$CLIENT_ID\"\n echo \"::add-mask::$CLIENT_SECRET\"\n env:\n CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-login\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk login --machine-user\n env:\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-generate\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk generate\n env:\n TAILOR_PLATFORM_WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n - id: tailor-deploy\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk deploy --yes\n env:\n TAILOR_PLATFORM_WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n";
2653
-
2654
- //#endregion
2655
- //#region src/cli/commands/setup/github/setup-bun.yml
2656
- var setup_bun_default = "- id: tailor-setup-bun\n uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0\n- id: tailor-install\n run: bun install --frozen-lockfile\n";
2657
-
2658
- //#endregion
2659
- //#region src/cli/commands/setup/github/setup-npm.yml
2660
- var setup_npm_default = "- id: tailor-setup-node\n uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version-file: package.json\n cache: npm\n- id: tailor-install\n run: npm ci\n";
2642
+ //#region src/cli/commands/setup/branch.workflow.yml
2643
+ var branch_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n # __PULL_REQUEST_START__\n pull_request:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n # __PULL_REQUEST_END__\n push:\n branches: [\"__BRANCH__\"]\n # __PATHS__\n workflow_dispatch:\n # __DISPATCH_INPUTS_START__\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n # __DISPATCH_INPUTS_END__\n\npermissions:\n contents: read\n\njobs:\n # __PLAN_JOB_START__\n tailor-plan:\n if: >-\n github.event_name == 'pull_request' ||\n (github.event_name == 'workflow_dispatch' && inputs['dry-run'])\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n pull-requests: write\n concurrency:\n group: tailor-plan-__WORKSPACE_NAME__-${{ github.event.pull_request.number || github.run_id }}\n cancel-in-progress: true\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-generate-check\n uses: tailor-platform/actions/generate-check@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n - id: tailor-plan\n # Fork PRs cannot read secrets; the checks above still run for them.\n if: github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork\n uses: tailor-platform/actions/plan@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n label: __WORKSPACE_NAME__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n github-token: ${{ secrets.GITHUB_TOKEN }}\n # __PLAN_JOB_END__\n tailor-deploy:\n # __DEPLOY_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n environment: __ENVIRONMENT__\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-apply\n uses: tailor-platform/actions/deploy@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
2661
2644
 
2662
2645
  //#endregion
2663
- //#region src/cli/commands/setup/github/setup-pnpm.yml
2664
- var setup_pnpm_default = "- id: tailor-setup-pnpm\n uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9\n- id: tailor-setup-node\n uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version-file: package.json\n cache: pnpm\n- id: tailor-install\n run: pnpm install --frozen-lockfile\n";
2646
+ //#region src/cli/commands/setup/tag.workflow.yml
2647
+ var tag_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n push:\n tags: [\"__TAG_PATTERN__\"]\n workflow_dispatch:\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n\npermissions:\n contents: read\n\njobs:\n # __TAG_GUARD_JOB_START__\n tailor-tag-guard:\n runs-on: ubuntu-latest\n timeout-minutes: 10\n permissions:\n contents: read\n outputs:\n on-branch: ${{ steps.tailor-tag-guard.outputs.on-branch }}\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n - id: tailor-tag-guard\n uses: tailor-platform/actions/tag-guard@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n target-branch: \"__BRANCH__\"\n # __TAG_GUARD_JOB_END__\n tailor-plan:\n # __PLAN_NEEDS__\n # __PLAN_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-generate-check\n uses: tailor-platform/actions/generate-check@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n - id: tailor-plan\n uses: tailor-platform/actions/plan@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n label: __WORKSPACE_NAME__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n\n tailor-deploy:\n needs: tailor-plan\n if: ${{ !(github.event_name == 'workflow_dispatch' && inputs['dry-run']) }}\n environment: __ENVIRONMENT__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n - id: tailor-setup\n uses: tailor-platform/actions/setup@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n package-manager: __PACKAGE_MANAGER__\n - id: tailor-apply\n uses: tailor-platform/actions/deploy@7817f37adf2891fbb2ebbe0a3b222a5fa2ed0c1f # v1.3.0\n with:\n workspace-id: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n package-manager: __PACKAGE_MANAGER__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
2665
2648
 
2666
2649
  //#endregion
2667
- //#region src/cli/commands/setup/github/setup-yarn.yml
2668
- var setup_yarn_default = "- id: tailor-setup-node\n uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0\n with:\n node-version-file: package.json\n cache: yarn\n- id: tailor-install\n run: yarn install --frozen-lockfile\n";
2669
-
2670
- //#endregion
2671
- //#region src/cli/commands/setup/github/tag.workflow.yml
2672
- var tag_workflow_default = "# __HEADER__\nname: Tailor (__WORKSPACE_NAME__)\n\non:\n push:\n tags: [\"__TAG_PATTERN__\"]\n workflow_dispatch:\n inputs:\n dry-run:\n description: Preview changes without deploying\n type: boolean\n default: false\n\npermissions:\n contents: read\n\njobs:\n # __TAG_GUARD_JOB_START__\n tailor-tag-guard:\n runs-on: ubuntu-latest\n timeout-minutes: 10\n permissions:\n contents: read\n outputs:\n on-branch: ${{ steps.tailor-tag-guard.outputs.on-branch }}\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n with:\n fetch-depth: 0\n - id: tailor-tag-guard\n env:\n TARGET_BRANCH: \"__BRANCH__\"\n run: |\n git fetch origin \"$TARGET_BRANCH\"\n if git merge-base --is-ancestor \"$GITHUB_SHA\" \"origin/$TARGET_BRANCH\"; then\n echo \"on-branch=true\" >> \"$GITHUB_OUTPUT\"\n else\n # A tag outside the target branch is not an error — just skip.\n echo \"on-branch=false\" >> \"$GITHUB_OUTPUT\"\n echo \"::notice::Tag $GITHUB_REF_NAME is not reachable from $TARGET_BRANCH; skipping deploy.\"\n fi\n # __TAG_GUARD_JOB_END__\n tailor-plan:\n # __PLAN_NEEDS__\n # __PLAN_IF__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n environment: __ENVIRONMENT__\n permissions:\n contents: read\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-generate\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk generate\n - id: tailor-generate-check\n run: |\n git add -A\n if ! git diff --cached --quiet; then\n git --no-pager diff --cached --stat\n echo \"::error::Generated files are out of date. Run 'tailor-sdk generate' locally and commit the result.\"\n exit 1\n fi\n - id: tailor-mask-credentials\n if: vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n run: |\n echo \"::add-mask::$CLIENT_ID\"\n echo \"::add-mask::$CLIENT_SECRET\"\n env:\n CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-login\n if: vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk login --machine-user\n env:\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-plan\n if: vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n # __WORKING_DIRECTORY__\n run: |\n if [ -z \"$TAILOR_PLATFORM_WORKSPACE_ID\" ]; then\n echo \"exit-code=\" >> \"$GITHUB_OUTPUT\"\n exit 0\n fi\n\n set +e\n OUTPUT=$(__PM_EXEC__ tailor-sdk deploy --dry-run --yes 2>&1)\n EXIT_CODE=$?\n set -e\n\n MAX_OUTPUT=60000\n if [ \"${#OUTPUT}\" -gt \"$MAX_OUTPUT\" ]; then\n LOG_STOP_TOKEN=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)\n echo \"::group::Full Tailor Platform plan output\"\n echo \"::stop-commands::$LOG_STOP_TOKEN\"\n printf '%s\\n' \"$OUTPUT\"\n echo \"::$LOG_STOP_TOKEN::\"\n echo \"::endgroup::\"\n OUTPUT_TAIL=\"${OUTPUT: -$MAX_OUTPUT}\"\n OUTPUT=$(printf '%s\\n\\n%s' \"[output truncated to the last $MAX_OUTPUT characters - see the workflow logs for the full plan]\" \"$OUTPUT_TAIL\")\n fi\n\n EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)\n {\n echo \"exit-code=$EXIT_CODE\"\n echo \"output<<$EOF\"\n echo \"$OUTPUT\"\n echo \"$EOF\"\n } >> \"$GITHUB_OUTPUT\"\n env:\n TAILOR_PLATFORM_WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n - id: tailor-plan-summary\n run: |\n if [ -n \"$LABEL\" ]; then\n KEY=\"$LABEL\"\n elif [ -n \"$WORKSPACE_ID\" ]; then\n KEY=\"$WORKSPACE_ID\"\n else\n KEY=\"workspace\"\n fi\n\n if [ -z \"$WORKSPACE_ID\" ]; then\n {\n echo \"## Tailor Platform Plan ($KEY)\"\n echo \"\"\n echo \"Workspace is not provisioned yet. Set TAILOR_PLATFORM_WORKSPACE_ID after provisioning the workspace.\"\n } >> \"$GITHUB_STEP_SUMMARY\"\n exit 0\n fi\n\n if [ \"$DRY_RUN_EXIT_CODE\" = \"0\" ]; then\n STATUS=\"PASS\"\n else\n STATUS=\"FAIL\"\n fi\n\n {\n echo \"## $STATUS Tailor Platform Plan ($KEY)\"\n echo \"\"\n echo \"<details>\"\n echo \"<summary>Plan output (exit code: $DRY_RUN_EXIT_CODE)</summary>\"\n echo \"\"\n echo '```'\n echo \"$DRY_RUN_OUTPUT\"\n echo '```'\n echo \"\"\n echo \"</details>\"\n } >> \"$GITHUB_STEP_SUMMARY\"\n env:\n WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n LABEL: __WORKSPACE_NAME__\n DRY_RUN_OUTPUT: ${{ steps.tailor-plan.outputs.output }}\n DRY_RUN_EXIT_CODE: ${{ steps.tailor-plan.outputs.exit-code }}\n - id: tailor-plan-fail\n if: vars.TAILOR_PLATFORM_WORKSPACE_ID != ''\n run: |\n if [ \"$DRY_RUN_EXIT_CODE\" != \"0\" ]; then\n echo \"::error::Plan dry-run failed with exit code $DRY_RUN_EXIT_CODE\"\n exit \"$DRY_RUN_EXIT_CODE\"\n fi\n env:\n DRY_RUN_EXIT_CODE: ${{ steps.tailor-plan.outputs.exit-code }}\n\n tailor-deploy:\n needs: tailor-plan\n if: ${{ !(github.event_name == 'workflow_dispatch' && inputs['dry-run']) }}\n environment: __ENVIRONMENT__\n runs-on: ubuntu-latest\n timeout-minutes: 30\n permissions:\n contents: read\n concurrency:\n group: tailor-deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n steps:\n - id: tailor-checkout\n uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3\n # __SETUP_STEPS__\n - id: tailor-validate-workspace\n env:\n WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n run: |\n if [ -z \"$WORKSPACE_ID\" ]; then\n echo \"::error::Workspace is not provisioned: TAILOR_PLATFORM_WORKSPACE_ID is empty. Provision the workspace and set the variable.\"\n exit 1\n fi\n - id: tailor-mask-credentials\n run: |\n echo \"::add-mask::$CLIENT_ID\"\n echo \"::add-mask::$CLIENT_SECRET\"\n env:\n CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-login\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk login --machine-user\n env:\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID }}\n TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET: ${{ secrets.TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n - id: tailor-generate\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk generate\n env:\n TAILOR_PLATFORM_WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n - id: tailor-deploy\n # __WORKING_DIRECTORY__\n run: __PM_EXEC__ tailor-sdk deploy --yes\n env:\n TAILOR_PLATFORM_WORKSPACE_ID: ${{ vars.TAILOR_PLATFORM_WORKSPACE_ID }}\n";
2673
-
2674
- //#endregion
2675
- //#region src/cli/commands/setup/github/templates.ts
2676
- const setupStepIds = {
2677
- pnpm: [
2678
- "tailor-setup-pnpm",
2679
- "tailor-setup-node",
2680
- "tailor-install"
2681
- ],
2682
- yarn: ["tailor-setup-node", "tailor-install"],
2683
- npm: ["tailor-setup-node", "tailor-install"],
2684
- bun: ["tailor-setup-bun", "tailor-install"]
2685
- };
2686
- const setupSteps = {
2687
- pnpm: setup_pnpm_default,
2688
- yarn: setup_yarn_default,
2689
- npm: setup_npm_default,
2690
- bun: setup_bun_default
2691
- };
2692
- const execPrefix = {
2693
- npm: "npx",
2694
- pnpm: "pnpm exec",
2695
- yarn: "yarn",
2696
- bun: "bunx"
2697
- };
2698
- const HEADER = `# Generated by \`tailor-sdk setup github\` — managed by the Tailor SDK.
2650
+ //#region src/cli/commands/setup/templates.ts
2651
+ const HEADER = `# Generated by \`tailor-sdk setup\` managed by the Tailor SDK.
2699
2652
  #
2700
2653
  # - Jobs and steps whose id starts with \`tailor-\` are managed by the SDK.
2701
2654
  # Do not edit or rename them.
2702
2655
  # - State is tracked in .github/tailor-sdk.lock (machine-owned: commit it, never edit it).
2703
- # - Re-running \`tailor-sdk setup github\` regenerates this file. If you have
2656
+ # - Re-running \`tailor-sdk setup\` regenerates this file. If you have
2704
2657
  # edited it by hand, regeneration stops and asks for --force (which discards
2705
2658
  # your edits), so prefer keeping customizations in your own jobs/steps and
2706
2659
  # re-running setup after SDK updates.`;
2707
- function indentSnippet(snippet, spaces) {
2708
- const indent = " ".repeat(spaces);
2709
- return snippet.trimEnd().split("\n").map((line) => line ? indent + line : line).join("\n");
2710
- }
2711
2660
  /**
2712
2661
  * Detect the package manager used in a project directory by checking for lockfiles.
2713
2662
  * @param dir - Project directory to inspect
@@ -2735,11 +2684,7 @@ function applyCommon(content, params) {
2735
2684
  const { workingDirectory, environment, packageManager } = params;
2736
2685
  let out = line(content, "HEADER", HEADER);
2737
2686
  out = line(out, "WORKING_DIRECTORY", workingDirectory ? `working-directory: ${workingDirectory}` : void 0);
2738
- out = out.replace(/^ *# __SETUP_STEPS__$/gm, () => indentSnippet(setupSteps[packageManager], 6));
2739
- return out.replaceAll("__WORKSPACE_NAME__", () => params.workspaceName).replaceAll("__ENVIRONMENT__", () => environment).replaceAll("__PM_EXEC__", () => execPrefix[packageManager]);
2740
- }
2741
- function setupIds(job, packageManager) {
2742
- return setupStepIds[packageManager].map((id) => `${job}/${id}`);
2687
+ return out.replaceAll("__WORKSPACE_NAME__", () => params.workspaceName).replaceAll("__ENVIRONMENT__", () => environment).replaceAll("__PACKAGE_MANAGER__", () => packageManager);
2743
2688
  }
2744
2689
  /**
2745
2690
  * Render the branch-target deploy workflow.
@@ -2751,7 +2696,7 @@ function setupIds(job, packageManager) {
2751
2696
  * @returns Rendered YAML and the list of managed job/step ids
2752
2697
  */
2753
2698
  function renderBranchWorkflow(params) {
2754
- const { branch, plan, packageManager } = params;
2699
+ const { branch, plan } = params;
2755
2700
  let out = branch_workflow_default;
2756
2701
  out = block(out, "PLAN_JOB", plan);
2757
2702
  out = block(out, "PULL_REQUEST", plan);
@@ -2760,8 +2705,8 @@ function renderBranchWorkflow(params) {
2760
2705
  out = line(out, "PATHS", params.workingDirectory ? `paths: ["${params.workingDirectory}/**"]` : void 0);
2761
2706
  out = applyCommon(out, params).replaceAll("__BRANCH__", () => branch);
2762
2707
  const generatedIds = [];
2763
- if (plan) generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", "tailor-plan/tailor-merge-base", ...setupIds("tailor-plan", packageManager), "tailor-plan/tailor-generate", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-mask-credentials", "tailor-plan/tailor-login", "tailor-plan/tailor-plan", "tailor-plan/tailor-plan-summary", "tailor-plan/tailor-plan-comment", "tailor-plan/tailor-plan-fail");
2764
- generatedIds.push("tailor-deploy", "tailor-deploy/tailor-checkout", ...setupIds("tailor-deploy", packageManager), "tailor-deploy/tailor-validate-workspace", "tailor-deploy/tailor-mask-credentials", "tailor-deploy/tailor-login", "tailor-deploy/tailor-generate", "tailor-deploy/tailor-deploy");
2708
+ if (plan) generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", "tailor-plan/tailor-setup", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-plan");
2709
+ generatedIds.push("tailor-deploy", "tailor-deploy/tailor-checkout", "tailor-deploy/tailor-setup", "tailor-deploy/tailor-apply");
2765
2710
  return {
2766
2711
  content: out,
2767
2712
  generatedIds
@@ -2776,7 +2721,7 @@ function renderBranchWorkflow(params) {
2776
2721
  * @returns Rendered YAML and the list of managed job/step ids
2777
2722
  */
2778
2723
  function renderTagWorkflow(params) {
2779
- const { tagPattern, branch, packageManager } = params;
2724
+ const { tagPattern, branch } = params;
2780
2725
  const hasGuard = branch !== void 0;
2781
2726
  let out = tag_workflow_default;
2782
2727
  out = block(out, "TAG_GUARD_JOB", hasGuard);
@@ -2786,7 +2731,7 @@ function renderTagWorkflow(params) {
2786
2731
  if (hasGuard) out = out.replaceAll("__BRANCH__", () => branch);
2787
2732
  const generatedIds = [];
2788
2733
  if (hasGuard) generatedIds.push("tailor-tag-guard", "tailor-tag-guard/tailor-checkout", "tailor-tag-guard/tailor-tag-guard");
2789
- generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", ...setupIds("tailor-plan", packageManager), "tailor-plan/tailor-generate", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-mask-credentials", "tailor-plan/tailor-login", "tailor-plan/tailor-plan", "tailor-plan/tailor-plan-summary", "tailor-plan/tailor-plan-fail", "tailor-deploy", "tailor-deploy/tailor-checkout", ...setupIds("tailor-deploy", packageManager), "tailor-deploy/tailor-validate-workspace", "tailor-deploy/tailor-mask-credentials", "tailor-deploy/tailor-login", "tailor-deploy/tailor-generate", "tailor-deploy/tailor-deploy");
2734
+ generatedIds.push("tailor-plan", "tailor-plan/tailor-checkout", "tailor-plan/tailor-setup", "tailor-plan/tailor-generate-check", "tailor-plan/tailor-plan", "tailor-deploy", "tailor-deploy/tailor-checkout", "tailor-deploy/tailor-setup", "tailor-deploy/tailor-apply");
2790
2735
  return {
2791
2736
  content: out,
2792
2737
  generatedIds
@@ -2794,7 +2739,110 @@ function renderTagWorkflow(params) {
2794
2739
  }
2795
2740
 
2796
2741
  //#endregion
2797
- //#region src/cli/commands/setup/github/github.ts
2742
+ //#region src/cli/commands/setup/check.ts
2743
+ /**
2744
+ * Compute drift findings for one target by comparing its recorded lock state
2745
+ * against the current repository/config state.
2746
+ * @param target - The lock target being audited
2747
+ * @param state - Current repository/config state for this target
2748
+ * @returns Drift findings (empty when the target is in sync)
2749
+ */
2750
+ function findTargetDrift(target, state) {
2751
+ const id = `${target.kind} ${target.workspaceName}`;
2752
+ const findings = [];
2753
+ if (!state.fileExists) findings.push({
2754
+ target: id,
2755
+ rule: "missing-file",
2756
+ message: `${target.file} is missing or unreadable. Re-run setup to restore it.`
2757
+ });
2758
+ else if (state.currentHash !== null && state.currentHash !== target.contentHash) findings.push({
2759
+ target: id,
2760
+ rule: "hand-edit",
2761
+ message: `${target.file} was edited by hand since it was generated. Re-run setup with --force to regenerate, or keep customizations in your own jobs/steps.`
2762
+ });
2763
+ if (target.templateVersion < state.templateVersion) findings.push({
2764
+ target: id,
2765
+ rule: "template-version",
2766
+ message: `A newer workflow template is available (generated with v${String(target.templateVersion)}, current v${String(state.templateVersion)}). Re-run setup to update.`
2767
+ });
2768
+ if (!state.configExists) findings.push({
2769
+ target: id,
2770
+ rule: "config-dir",
2771
+ message: `tailor.config.ts not found under "${target.inputs.dir}". The app directory may have moved; re-run setup with the correct --dir.`
2772
+ });
2773
+ if (target.kind === "branch" && target.inputs.branchAutoDetected !== false && state.defaultBranch !== null && target.inputs.branch !== null && target.inputs.branch !== state.defaultBranch) findings.push({
2774
+ target: id,
2775
+ rule: "default-branch",
2776
+ message: `The workflow triggers on "${target.inputs.branch}" but the repository default branch is now "${state.defaultBranch}". If this is intentional, ignore this; otherwise re-run setup so the trigger matches the default branch.`
2777
+ });
2778
+ return findings;
2779
+ }
2780
+ function detectDefaultBranchSafe(cwd, run) {
2781
+ try {
2782
+ return detectDefaultBranch(cwd, run);
2783
+ } catch {
2784
+ return null;
2785
+ }
2786
+ }
2787
+ function escapesRoot$1(rel) {
2788
+ return path.isAbsolute(rel) || rel === ".." || rel.startsWith(`..${path.sep}`) || rel.startsWith("../");
2789
+ }
2790
+ function resolveWithinRoot(outputDir, relPath) {
2791
+ if (path.isAbsolute(relPath)) return null;
2792
+ const abs = path.join(outputDir, relPath);
2793
+ if (escapesRoot$1(path.relative(outputDir, abs))) return null;
2794
+ try {
2795
+ if (escapesRoot$1(path.relative(fs$1.realpathSync(outputDir), fs$1.realpathSync(abs)))) return null;
2796
+ } catch {}
2797
+ return abs;
2798
+ }
2799
+ function readHash(absFile) {
2800
+ try {
2801
+ return hashContent(fs$1.readFileSync(absFile, "utf-8"));
2802
+ } catch {
2803
+ return null;
2804
+ }
2805
+ }
2806
+ /**
2807
+ * Audit the generated workflows for drift against the current config/repo
2808
+ * state. Read-only: never writes files, the lock, or the config.
2809
+ *
2810
+ * Throws when drift is found (so it composes like the other `:check`
2811
+ * commands). The workflow drift-check step layers advisory behaviour on top
2812
+ * (per-rule ignore / continue-on-error); the CLI itself reports via exit code.
2813
+ * @param options - Check options
2814
+ */
2815
+ function checkGitHub(options) {
2816
+ logBetaWarning("setup");
2817
+ const { outputDir } = options;
2818
+ const lock = readLock(outputDir);
2819
+ if (!lock || lock.targets.length === 0) throw new Error("No managed workflows found (.github/tailor-sdk.lock is missing or empty). Run `tailor-sdk setup` first.");
2820
+ const exists = options.configExistsAt ?? ((p) => fs$1.existsSync(p));
2821
+ const defaultBranch = detectDefaultBranchSafe(outputDir, options.gitRunner);
2822
+ const findings = [];
2823
+ for (const target of lock.targets) {
2824
+ const absFile = resolveWithinRoot(outputDir, target.file);
2825
+ const currentHash = absFile === null ? null : readHash(absFile);
2826
+ const configAbs = resolveWithinRoot(outputDir, path.join(target.inputs.dir, "tailor.config.ts"));
2827
+ findings.push(...findTargetDrift(target, {
2828
+ fileExists: currentHash !== null,
2829
+ currentHash,
2830
+ configExists: configAbs !== null && exists(configAbs),
2831
+ defaultBranch,
2832
+ templateVersion: 2
2833
+ }));
2834
+ }
2835
+ const count = lock.targets.length;
2836
+ if (findings.length === 0) {
2837
+ logger.success(`No drift detected across ${String(count)} target(s).`);
2838
+ return;
2839
+ }
2840
+ for (const finding of findings) logger.warn(`[${finding.target}] ${finding.message} (ignore key: ${finding.rule})`);
2841
+ throw new Error(`Detected ${String(findings.length)} drift finding(s) across ${String(count)} target(s). Re-run \`tailor-sdk setup\` to regenerate, or address each finding above.`);
2842
+ }
2843
+
2844
+ //#endregion
2845
+ //#region src/cli/commands/setup/generate.ts
2798
2846
  async function defaultLoadConfigName(configPath) {
2799
2847
  const { config } = await loadConfig(configPath);
2800
2848
  return config.name;
@@ -2866,8 +2914,10 @@ async function resolve$1(options) {
2866
2914
  validateEnvironment(environment);
2867
2915
  if (kind === "tag") validateTagPattern(options.tagPattern);
2868
2916
  let branch = null;
2917
+ let branchAutoDetected = false;
2869
2918
  let render;
2870
2919
  if (kind === "branch") {
2920
+ branchAutoDetected = options.branch === void 0;
2871
2921
  branch = options.branch ?? detectDefaultBranch(options.outputDir, options.gitRunner);
2872
2922
  validateBranch(branch);
2873
2923
  render = renderBranchWorkflow({
@@ -2893,6 +2943,7 @@ async function resolve$1(options) {
2893
2943
  const file = `.github/workflows/tailor-${workspaceName}.yml`;
2894
2944
  const inputs = {
2895
2945
  branch,
2946
+ branchAutoDetected: kind === "branch" ? branchAutoDetected : void 0,
2896
2947
  tagPattern: kind === "tag" ? options.tagPattern : null,
2897
2948
  environment,
2898
2949
  dir,
@@ -2981,7 +3032,7 @@ function printNextSteps(obj) {
2981
3032
  * @param options - Setup options
2982
3033
  */
2983
3034
  async function setupGitHub(options) {
2984
- logBetaWarning("setup github");
3035
+ logBetaWarning("setup");
2985
3036
  const resolved = await resolve$1(options);
2986
3037
  const lock = readLock(options.outputDir);
2987
3038
  const absFile = path.join(options.outputDir, resolved.file);
@@ -3033,11 +3084,23 @@ async function setupGitHub(options) {
3033
3084
  }
3034
3085
 
3035
3086
  //#endregion
3036
- //#region src/cli/commands/setup/github/index.ts
3037
- const githubCommand = defineAppCommand({
3038
- name: "github",
3039
- description: "Generate a GitHub Actions deploy workflow. (beta)",
3087
+ //#region src/cli/commands/setup/index.ts
3088
+ const checkCommand = defineAppCommand({
3089
+ name: "check",
3090
+ description: "Audit generated workflows for drift against the current config/repo (read-only).",
3091
+ args: z.object({}).strict(),
3092
+ run: () => {
3093
+ checkGitHub({ outputDir: process.cwd() });
3094
+ }
3095
+ });
3096
+ const setupCommand = defineAppCommand({
3097
+ name: "setup",
3098
+ description: "Generate a CI deploy workflow for your project. (beta)",
3040
3099
  args: z.object({
3100
+ provider: arg(z.enum(["github"], { message: "Only the 'github' provider is supported." }).default("github"), {
3101
+ alias: "p",
3102
+ description: "CI provider to generate for (only 'github' is supported)"
3103
+ }),
3041
3104
  "workspace-name": arg(z.string().min(1).optional(), {
3042
3105
  alias: "n",
3043
3106
  description: "Workspace name (defaults to the config 'name')"
@@ -3053,6 +3116,7 @@ const githubCommand = defineAppCommand({
3053
3116
  }),
3054
3117
  force: arg(z.boolean().default(false), { description: "Discard hand edits / take over unmanaged files and regenerate" })
3055
3118
  }).strict(),
3119
+ subCommands: { check: checkCommand },
3056
3120
  run: async (args) => {
3057
3121
  if (args["tag-pattern"] !== void 0 && !args.tag) throw new Error("--tag-pattern requires --tag.");
3058
3122
  if (args["no-plan"] && args.tag) throw new Error("--no-plan cannot be combined with --tag.");
@@ -3070,14 +3134,6 @@ const githubCommand = defineAppCommand({
3070
3134
  }
3071
3135
  });
3072
3136
 
3073
- //#endregion
3074
- //#region src/cli/commands/setup/index.ts
3075
- const setupCommand = defineCommand({
3076
- name: "setup",
3077
- description: "Set up project infrastructure.",
3078
- subCommands: { github: githubCommand }
3079
- });
3080
-
3081
3137
  //#endregion
3082
3138
  //#region src/cli/shared/skills-installer.ts
3083
3139
  const SKILL_NAME = "tailor-sdk";
@@ -4749,7 +4805,7 @@ async function fetchRemoteTypes(client, workspaceId, namespace) {
4749
4805
  async function assertMigrationsReproduceLocalTypes(loaded, target) {
4750
4806
  const { config, plugins } = loaded;
4751
4807
  const pluginManager = plugins.length > 0 ? new PluginManager(plugins) : void 0;
4752
- const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-DB2r36Et.mjs");
4808
+ const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-Dtqap5jM.mjs");
4753
4809
  const application = defineApplication({
4754
4810
  config,
4755
4811
  pluginManager
@@ -4761,7 +4817,7 @@ async function assertMigrationsReproduceLocalTypes(loaded, target) {
4761
4817
  await service.processNamespacePlugins();
4762
4818
  }
4763
4819
  const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, application.tailorDBServices, config.path);
4764
- const executorService = application.executorService ?? (pluginExecutorFiles.length > 0 ? (await import("../service-D6yonf2I.mjs")).createExecutorService({ config: { files: [] } }) : void 0);
4820
+ const executorService = application.executorService ?? (pluginExecutorFiles.length > 0 ? (await import("../service-DCqIWibD.mjs")).createExecutorService({ config: { files: [] } }) : void 0);
4765
4821
  await executorService?.loadExecutors();
4766
4822
  if (pluginExecutorFiles.length > 0) await executorService?.loadPluginExecutorFiles([...pluginExecutorFiles]);
4767
4823
  const executorUsedTypes = /* @__PURE__ */ new Set();
@@ -5038,7 +5094,7 @@ const upgradeCommand = defineAppCommand({
5038
5094
  run: async (args) => {
5039
5095
  const { initTelemetry } = await import("../telemetry-ClwW5ohF.mjs");
5040
5096
  await initTelemetry();
5041
- const { upgrade } = await import("../service-DU1mVzri.mjs");
5097
+ const { upgrade } = await import("../service-DU1mVzri2.mjs");
5042
5098
  await upgrade({
5043
5099
  from: args.from,
5044
5100
  dryRun: args["dry-run"],
@@ -5356,6 +5412,7 @@ const workflowCommand = defineCommand({
5356
5412
  list: listCommand$12,
5357
5413
  get: getCommand$6,
5358
5414
  start: startCommand,
5415
+ wait: waitCommand,
5359
5416
  executions: executionsCommand,
5360
5417
  resume: resumeCommand
5361
5418
  },
@@ -5469,7 +5526,7 @@ runMain(mainCommand, {
5469
5526
  if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
5470
5527
  } else logger.error(`Unknown error: ${error}`);
5471
5528
  if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
5472
- const { reportCrash } = await import("../crashreport-pr6Rhvza.mjs");
5529
+ const { reportCrash } = await import("../crashreport-BMWcxeSE.mjs");
5473
5530
  await reportCrash(error, "handledError");
5474
5531
  }
5475
5532
  }