@tailor-platform/sdk 1.25.4 → 1.27.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 +28 -0
- package/dist/application-CBJFUKrU.mjs +4701 -0
- package/dist/application-CBJFUKrU.mjs.map +1 -0
- package/dist/application-WyZetOky.mjs +11 -0
- package/dist/cli/index.mjs +290 -32
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +350 -8
- package/dist/cli/lib.mjs +10 -8
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/client-C2_wgujH.mjs +6 -0
- package/dist/{application-91Th6tm6.mjs → client-bTbnbQbB.mjs} +24 -4795
- package/dist/client-bTbnbQbB.mjs.map +1 -0
- package/dist/configure/index.d.mts +5 -5
- package/dist/configure/index.mjs.map +1 -1
- package/dist/crash-report-Cot_9Esm.mjs +6 -0
- package/dist/crash-report-Ju8cQF-l.mjs +414 -0
- package/dist/crash-report-Ju8cQF-l.mjs.map +1 -0
- package/dist/{enum-constants-6uK0VI_s.mjs → enum-constants-D1nfn0qD.mjs} +1 -1
- package/dist/{enum-constants-6uK0VI_s.mjs.map → enum-constants-D1nfn0qD.mjs.map} +1 -1
- package/dist/{env-uBeVwE9B.d.mts → env-BuMbIknz.d.mts} +2 -2
- package/dist/{file-utils-2T9w20FP.mjs → file-utils-Bctuzn3x.mjs} +1 -1
- package/dist/{file-utils-2T9w20FP.mjs.map → file-utils-Bctuzn3x.mjs.map} +1 -1
- package/dist/{index-BD-K97-C.d.mts → index-B0Lrzywd.d.mts} +2 -2
- package/dist/{index-cZilKprY.d.mts → index-CbnLNm14.d.mts} +2 -2
- package/dist/{index-D1J5SfyK.d.mts → index-CyapgSFI.d.mts} +2 -2
- package/dist/{index-CT53egux.d.mts → index-D1AM_02Y.d.mts} +2 -2
- package/dist/{index-Bu12qy3m.d.mts → index-cD9sQLTh.d.mts} +15 -15
- package/dist/{interceptor-BPiIBTk_.mjs → interceptor-B0d_GrI5.mjs} +1 -1
- package/dist/{interceptor-BPiIBTk_.mjs.map → interceptor-B0d_GrI5.mjs.map} +1 -1
- package/dist/{kysely-type-cMNbsQ6k.mjs → kysely-type-B_IecdK9.mjs} +1 -1
- package/dist/{kysely-type-cMNbsQ6k.mjs.map → kysely-type-B_IecdK9.mjs.map} +1 -1
- package/dist/logger-CqezTedh.mjs +181 -0
- package/dist/logger-CqezTedh.mjs.map +1 -0
- package/dist/{package-json-CVUv8Y9T.mjs → package-json-D3x2nBPB.mjs} +1 -1
- package/dist/{package-json-CVUv8Y9T.mjs.map → package-json-D3x2nBPB.mjs.map} +1 -1
- package/dist/package-json-DHfTiUCS.mjs +4 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -2
- package/dist/{plugin-zY5wvV82.d.mts → plugin-D3a0-qe0.d.mts} +20 -4
- package/dist/{query-kb_4EQp4.mjs → query-CgGbAmUg.mjs} +460 -361
- package/dist/query-CgGbAmUg.mjs.map +1 -0
- package/dist/{seed-CCVRLibh.mjs → seed-CWkIDWMb.mjs} +1 -1
- package/dist/{seed-CCVRLibh.mjs.map → seed-CWkIDWMb.mjs.map} +1 -1
- package/dist/{telemetry-DDQZRqHK.mjs → telemetry-BevrwWwF.mjs} +1 -1
- package/dist/{telemetry-0w8OupuQ.mjs → telemetry-VvNfsyEE.mjs} +2 -2
- package/dist/{telemetry-0w8OupuQ.mjs.map → telemetry-VvNfsyEE.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/{workflow.generated-v1LXRuB6.d.mts → workflow.generated-BsgIlrH-.d.mts} +2 -2
- package/docs/cli/crash-report.md +107 -0
- package/docs/cli/setup.md +82 -0
- package/docs/cli-reference.md +19 -0
- package/docs/services/auth.md +33 -0
- package/docs/services/resolver.md +32 -0
- package/package.json +4 -4
- package/dist/application-91Th6tm6.mjs.map +0 -1
- package/dist/application-DegTCDd8.mjs +0 -9
- package/dist/package-json-Bj76LPsV.mjs +0 -4
- package/dist/query-kb_4EQp4.mjs.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./chunk-Cz-A8uMR.mjs";
|
|
2
|
+
import "./brand-GZnI4eYb.mjs";
|
|
3
|
+
import "./logger-CqezTedh.mjs";
|
|
4
|
+
import "./client-bTbnbQbB.mjs";
|
|
5
|
+
import "./package-json-D3x2nBPB.mjs";
|
|
6
|
+
import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-CBJFUKrU.mjs";
|
|
7
|
+
import "./seed-CWkIDWMb.mjs";
|
|
8
|
+
import "./file-utils-Bctuzn3x.mjs";
|
|
9
|
+
import "./kysely-type-B_IecdK9.mjs";
|
|
10
|
+
|
|
11
|
+
export { defineApplication };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
import "../chunk-Cz-A8uMR.mjs";
|
|
3
3
|
import "../schema-BePzTFBV.mjs";
|
|
4
4
|
import "../brand-GZnI4eYb.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { C as listCommand$
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import "../
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
5
|
+
import { n as logger, r as styles } from "../logger-CqezTedh.mjs";
|
|
6
|
+
import { C as listCommand$10, E as resumeCommand, F as showCommand, Ft as isValidMigrationNumber, G as listCommand$7, Ht as prompt, I as logBetaWarning, It as loadDiff, Jt as commonArgs, Kt as apiCommand, Mt as getMigrationFilePath, N as generateCommand$1, Nt as getMigrationFiles, O as listCommand$9, Q as listCommand$6, Qt as workspaceArgs, R as removeCommand$1, T as healthCommand, Ut as trnPrefix, V as getCommand$2, Vt as getNamespacesWithMigrations, W as tokenCommand, X as triggerCommand, Xt as deploymentArgs, Y as webhookCommand, Yt as confirmationArgs, Zt as isVerbose, b as createCommand$3, c as listCommand$11, ct as executionsCommand, dt as functionExecutionStatusToString, f as restoreCommand, ft as formatKeyValueTable, g as getCommand$4, gt as executeScript, ht as apply, i as updateCommand$2, it as startCommand, j as truncateCommand, kt as formatMigrationNumber, m as listCommand$12, n as queryCommand, o as removeCommand, ot as getCommand$3, pt as getCommand$1, q as generate, qt as defineAppCommand, r as isCLIError, tt as jobsCommand, u as inviteCommand, v as deleteCommand$3, yt as parseMigrationLabelNumber, z as listCommand$8 } from "../query-CgGbAmUg.mjs";
|
|
7
|
+
import { A as AuthInvokerSchema, L as PATScope, d as userAgent, i as fetchUserInfo, n as fetchAll, o as initOAuth2Client, s as initOperatorClient, w as FunctionExecution_Type } from "../client-bTbnbQbB.mjs";
|
|
8
|
+
import { t as readPackageJson } from "../package-json-D3x2nBPB.mjs";
|
|
9
|
+
import { S as writePlatformConfig, a as loadConfig, b as loadWorkspaceId, c as ExecutorSchema, g as getDistDir, i as resolveInlineSourcemap, o as WorkflowJobSchema, u as ResolverSchema, v as fetchLatestToken, x as readPlatformConfig, y as loadAccessToken } from "../application-CBJFUKrU.mjs";
|
|
10
|
+
import "../seed-CWkIDWMb.mjs";
|
|
11
|
+
import "../file-utils-Bctuzn3x.mjs";
|
|
12
|
+
import "../kysely-type-B_IecdK9.mjs";
|
|
13
|
+
import "../telemetry-VvNfsyEE.mjs";
|
|
14
|
+
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crash-report-Ju8cQF-l.mjs";
|
|
12
15
|
import { createRequire, register } from "node:module";
|
|
13
16
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
14
17
|
import { withCompletionCommand } from "politty/completion";
|
|
@@ -21,8 +24,8 @@ import { Code, ConnectError } from "@connectrpc/connect";
|
|
|
21
24
|
import { resolveTSConfig } from "pkg-types";
|
|
22
25
|
import ml from "multiline-ts";
|
|
23
26
|
import * as crypto from "node:crypto";
|
|
24
|
-
import { pathToFileURL } from "node:url";
|
|
25
27
|
import * as rolldown from "rolldown";
|
|
28
|
+
import { pathToFileURL } from "node:url";
|
|
26
29
|
import { create } from "@bufbuild/protobuf";
|
|
27
30
|
import { spawn, spawnSync } from "node:child_process";
|
|
28
31
|
import * as http from "node:http";
|
|
@@ -48,7 +51,7 @@ const applyCommand = defineAppCommand({
|
|
|
48
51
|
"clean-cache": arg(z.boolean().optional(), { description: "Clean the bundle cache before building" })
|
|
49
52
|
}).strict(),
|
|
50
53
|
run: async (args) => {
|
|
51
|
-
const { initTelemetry } = await import("../telemetry-
|
|
54
|
+
const { initTelemetry } = await import("../telemetry-BevrwWwF.mjs");
|
|
52
55
|
await initTelemetry();
|
|
53
56
|
await apply({
|
|
54
57
|
workspaceId: args["workspace-id"],
|
|
@@ -63,20 +66,118 @@ const applyCommand = defineAppCommand({
|
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/cli/commands/crash-report/list.ts
|
|
71
|
+
const listCommand$5 = defineAppCommand({
|
|
72
|
+
name: "list",
|
|
73
|
+
description: "List local crash report files.",
|
|
74
|
+
args: z.object({}).strict(),
|
|
75
|
+
run: async () => {
|
|
76
|
+
const config = parseCrashReportConfig();
|
|
77
|
+
if (!config.localDir) {
|
|
78
|
+
logger.info("Crash report directory not available.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let entries;
|
|
82
|
+
try {
|
|
83
|
+
entries = fs$1.readdirSync(config.localDir);
|
|
84
|
+
} catch {
|
|
85
|
+
logger.info("No crash reports found.");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const files = entries.filter((f) => f.endsWith(CRASH_LOG_EXTENSION)).sort().reverse();
|
|
89
|
+
if (files.length === 0) {
|
|
90
|
+
logger.info("No crash reports found.");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
logger.info(`${files.length} crash report(s) in ${config.localDir}:`);
|
|
94
|
+
for (const file of files) logger.log(` ${file}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/cli/commands/crash-report/send.ts
|
|
100
|
+
const sendCommand = defineAppCommand({
|
|
101
|
+
name: "send",
|
|
102
|
+
description: "Submit a crash report to help improve the SDK.",
|
|
103
|
+
args: z.object({ file: arg(z.string(), {
|
|
104
|
+
description: "Path to the crash report file",
|
|
105
|
+
required: true,
|
|
106
|
+
completion: {
|
|
107
|
+
type: "file",
|
|
108
|
+
extensions: ["log"]
|
|
109
|
+
}
|
|
110
|
+
}) }).strict(),
|
|
111
|
+
run: async (args) => {
|
|
112
|
+
let content;
|
|
113
|
+
try {
|
|
114
|
+
content = fs$1.readFileSync(args.file, "utf-8");
|
|
115
|
+
} catch {
|
|
116
|
+
logger.error(`Crash report file not found: ${args.file}`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
const report = parseCrashLogFile(content);
|
|
120
|
+
if (!report) {
|
|
121
|
+
logger.error("Failed to parse crash report file. The file may be corrupted.");
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
const ua = await userAgent();
|
|
125
|
+
logger.info("Sending crash report...");
|
|
126
|
+
if (await sendCrashReport(report, ua)) logger.success("Crash report submitted successfully. Thank you!");
|
|
127
|
+
else {
|
|
128
|
+
logger.error("Failed to submit crash report. The server may be unavailable.");
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Parse a crash log file back into a CrashReport object.
|
|
135
|
+
* Reads the embedded JSON footer appended by formatCrashReport.
|
|
136
|
+
* @param content - File content
|
|
137
|
+
* @returns Parsed report or undefined if parsing fails
|
|
138
|
+
*/
|
|
139
|
+
function parseCrashLogFile(content) {
|
|
140
|
+
try {
|
|
141
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
142
|
+
const marker = `\n${JSON_FOOTER_MARKER}\n`;
|
|
143
|
+
const lastIdx = normalized.lastIndexOf(marker);
|
|
144
|
+
if (lastIdx === -1) return void 0;
|
|
145
|
+
const jsonLine = normalized.slice(lastIdx + marker.length).split("\n")[0];
|
|
146
|
+
if (!jsonLine) return void 0;
|
|
147
|
+
return JSON.parse(jsonLine);
|
|
148
|
+
} catch {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/cli/commands/crash-report/index.ts
|
|
155
|
+
const crashReportCommand = defineCommand({
|
|
156
|
+
name: "crash-report",
|
|
157
|
+
description: "Manage crash reports.",
|
|
158
|
+
subCommands: {
|
|
159
|
+
send: sendCommand,
|
|
160
|
+
list: listCommand$5
|
|
161
|
+
},
|
|
162
|
+
async run() {
|
|
163
|
+
await runCommand(listCommand$5, []);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
66
167
|
//#endregion
|
|
67
168
|
//#region src/cli/commands/executor/index.ts
|
|
68
169
|
const executorCommand = defineCommand({
|
|
69
170
|
name: "executor",
|
|
70
171
|
description: "Manage executors",
|
|
71
172
|
subCommands: {
|
|
72
|
-
list: listCommand$
|
|
173
|
+
list: listCommand$6,
|
|
73
174
|
get: getCommand$1,
|
|
74
175
|
jobs: jobsCommand,
|
|
75
176
|
trigger: triggerCommand,
|
|
76
177
|
webhook: webhookCommand
|
|
77
178
|
},
|
|
78
179
|
async run() {
|
|
79
|
-
await runCommand(listCommand$
|
|
180
|
+
await runCommand(listCommand$6, []);
|
|
80
181
|
}
|
|
81
182
|
});
|
|
82
183
|
|
|
@@ -707,7 +808,7 @@ const generateCommand = defineAppCommand({
|
|
|
707
808
|
})
|
|
708
809
|
}).strict(),
|
|
709
810
|
run: async (args) => {
|
|
710
|
-
const { initTelemetry } = await import("../telemetry-
|
|
811
|
+
const { initTelemetry } = await import("../telemetry-BevrwWwF.mjs");
|
|
711
812
|
await initTelemetry();
|
|
712
813
|
await generate({
|
|
713
814
|
configPath: args.config,
|
|
@@ -875,11 +976,11 @@ const machineuserCommand = defineCommand({
|
|
|
875
976
|
name: "machineuser",
|
|
876
977
|
description: "Manage machine users in your Tailor Platform application.",
|
|
877
978
|
subCommands: {
|
|
878
|
-
list: listCommand$
|
|
979
|
+
list: listCommand$7,
|
|
879
980
|
token: tokenCommand
|
|
880
981
|
},
|
|
881
982
|
async run() {
|
|
882
|
-
await runCommand(listCommand$
|
|
983
|
+
await runCommand(listCommand$7, []);
|
|
883
984
|
}
|
|
884
985
|
});
|
|
885
986
|
|
|
@@ -890,10 +991,10 @@ const oauth2clientCommand = defineCommand({
|
|
|
890
991
|
description: "Manage OAuth2 clients in your Tailor Platform application.",
|
|
891
992
|
subCommands: {
|
|
892
993
|
get: getCommand$2,
|
|
893
|
-
list: listCommand$
|
|
994
|
+
list: listCommand$8
|
|
894
995
|
},
|
|
895
996
|
async run() {
|
|
896
|
-
await runCommand(listCommand$
|
|
997
|
+
await runCommand(listCommand$8, []);
|
|
897
998
|
}
|
|
898
999
|
});
|
|
899
1000
|
|
|
@@ -1424,6 +1525,154 @@ const secretCommand = defineCommand({
|
|
|
1424
1525
|
}
|
|
1425
1526
|
});
|
|
1426
1527
|
|
|
1528
|
+
//#endregion
|
|
1529
|
+
//#region src/cli/commands/setup/github/fetch-tailor-token.action.yml
|
|
1530
|
+
var fetch_tailor_token_action_default = "name: Fetch Tailor Platform Token\ndescription: Fetch an OAuth2 access token via client credentials grant and export as TAILOR_PLATFORM_TOKEN\n\ninputs:\n client_id:\n description: OAuth2 client ID\n required: true\n client_secret:\n description: OAuth2 client secret\n required: true\n platform_oauth2_url:\n description: OAuth2 token endpoint URL\n required: false\n default: https://api.tailor.tech/oauth2/platform/token\n\nruns:\n using: composite\n steps:\n - name: Fetch access token\n shell: bash\n run: |\n RESPONSE=$(curl -s -X POST \"${{ inputs.platform_oauth2_url }}\" \\\n -H \"Content-Type: application/x-www-form-urlencoded\" \\\n -d \"grant_type=client_credentials\" \\\n --data-urlencode \"client_id=${{ inputs.client_id }}\" \\\n --data-urlencode \"client_secret=${{ inputs.client_secret }}\")\n\n TOKEN=$(echo \"$RESPONSE\" | jq -r '.access_token')\n\n if [ \"$TOKEN\" = \"null\" ] || [ -z \"$TOKEN\" ]; then\n echo \"::error::Failed to fetch access token\"\n echo \"$RESPONSE\" | jq .\n exit 1\n fi\n\n echo \"::add-mask::$TOKEN\"\n echo \"TAILOR_PLATFORM_TOKEN=$TOKEN\" >> \"$GITHUB_ENV\"\n";
|
|
1531
|
+
|
|
1532
|
+
//#endregion
|
|
1533
|
+
//#region src/cli/commands/setup/github/install-node.action.yml
|
|
1534
|
+
var install_node_action_default = "name: Install Node.js\ndescription: Install pnpm, Node.js, and project dependencies\n\nruns:\n using: composite\n steps:\n - name: Install pnpm\n uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0\n with:\n version: 10\n\n - name: Setup Node.js\n uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0\n with:\n node-version: 22\n cache: pnpm\n\n - name: Install dependencies\n run: pnpm install --frozen-lockfile\n shell: bash\n";
|
|
1535
|
+
|
|
1536
|
+
//#endregion
|
|
1537
|
+
//#region src/cli/commands/setup/github/deploy.workflow.yml
|
|
1538
|
+
var deploy_workflow_default = "name: Deploy\n\non:\n push:\n branches:\n - main\n workflow_dispatch:\n\nconcurrency:\n group: deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n\nenv:\n WORKSPACE_NAME: __WORKSPACE_NAME__\n WORKSPACE_REGION: __WORKSPACE_REGION__\n TAILOR_PLATFORM_ORGANIZATION_ID: __ORGANIZATION_ID__\n TAILOR_PLATFORM_FOLDER_ID: __FOLDER_ID__\n# __DEFAULTS_BLOCK__\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n with:\n persist-credentials: false\n\n - name: Install Node.js\n uses: ./.github/actions/install-node\n\n - name: Fetch Tailor Platform token\n uses: ./.github/actions/fetch-tailor-token\n with:\n client_id: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_ID }}\n client_secret: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n\n - name: Ensure workspace exists\n run: |\n WORKSPACE_ID=$(pnpm tailor-sdk workspace list -j | jq -r --arg name \"$WORKSPACE_NAME\" --arg region \"$WORKSPACE_REGION\" '.[] | select(.name == $name and .region == $region) | .id')\n\n if [ -z \"$WORKSPACE_ID\" ]; then\n echo \"Workspace '$WORKSPACE_NAME' not found, creating...\"\n WORKSPACE_ID=$(pnpm tailor-sdk workspace create -j --name \"$WORKSPACE_NAME\" --region \"$WORKSPACE_REGION\" --organization-id \"$TAILOR_PLATFORM_ORGANIZATION_ID\" --folder-id \"$TAILOR_PLATFORM_FOLDER_ID\" | jq -r '.id')\n echo \"Created workspace: $WORKSPACE_ID\"\n else\n echo \"Found existing workspace: $WORKSPACE_ID\"\n fi\n\n echo \"TAILOR_PLATFORM_WORKSPACE_ID=$WORKSPACE_ID\" >> \"$GITHUB_ENV\"\n\n - name: Generate types\n run: pnpm generate\n\n - name: Deploy\n # Runs the \"deploy\" script from package.json (tailor-sdk apply --yes)\n run: pnpm run deploy -- --yes\n\n - name: Show application info\n run: pnpm tailor-sdk show -j -w \"$TAILOR_PLATFORM_WORKSPACE_ID\"\n";
|
|
1539
|
+
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region src/cli/commands/setup/github/template-deploy.ts
|
|
1542
|
+
/**
|
|
1543
|
+
* Render the deploy workflow YAML.
|
|
1544
|
+
*
|
|
1545
|
+
* Targets single-application scaffolds (those with `generate` and `deploy` scripts).
|
|
1546
|
+
* Multi-application projects (e.g. chained `deploy:*` scripts) need manual workflow customization.
|
|
1547
|
+
* @param params - Workspace and deployment configuration
|
|
1548
|
+
* @returns Workflow YAML content
|
|
1549
|
+
*/
|
|
1550
|
+
function renderDeploy(params) {
|
|
1551
|
+
const { workspaceName, workspaceRegion, organizationId, folderId, workingDirectory } = params;
|
|
1552
|
+
const defaultsBlock = workingDirectory ? `\ndefaults:\n run:\n working-directory: ${workingDirectory}\n` : "";
|
|
1553
|
+
return deploy_workflow_default.replaceAll("__WORKSPACE_NAME__", () => workspaceName).replace("__WORKSPACE_REGION__", () => workspaceRegion).replace("__ORGANIZATION_ID__", () => organizationId).replace("__FOLDER_ID__", () => folderId).replace("# __DEFAULTS_BLOCK__\n", () => defaultsBlock);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
//#endregion
|
|
1557
|
+
//#region src/cli/commands/setup/github/github.ts
|
|
1558
|
+
/**
|
|
1559
|
+
* Build the list of GitHub Actions files to generate.
|
|
1560
|
+
* @param options - Setup options including workspace config and output directory
|
|
1561
|
+
* @returns Array of files with paths and rendered content
|
|
1562
|
+
*/
|
|
1563
|
+
function buildFiles(options) {
|
|
1564
|
+
const githubDir = path.join(options.outputDir, ".github");
|
|
1565
|
+
return [
|
|
1566
|
+
{
|
|
1567
|
+
path: path.join(githubDir, "actions/fetch-tailor-token/action.yml"),
|
|
1568
|
+
content: fetch_tailor_token_action_default
|
|
1569
|
+
},
|
|
1570
|
+
{
|
|
1571
|
+
path: path.join(githubDir, "actions/install-node/action.yml"),
|
|
1572
|
+
content: install_node_action_default
|
|
1573
|
+
},
|
|
1574
|
+
{
|
|
1575
|
+
path: path.join(githubDir, `workflows/deploy-${options.workspaceName}.yml`),
|
|
1576
|
+
content: renderDeploy({
|
|
1577
|
+
workspaceName: options.workspaceName,
|
|
1578
|
+
workspaceRegion: options.workspaceRegion,
|
|
1579
|
+
organizationId: options.organizationId,
|
|
1580
|
+
folderId: options.folderId,
|
|
1581
|
+
workingDirectory: options.dir !== "." ? options.dir : void 0
|
|
1582
|
+
})
|
|
1583
|
+
}
|
|
1584
|
+
];
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Write files to disk, skipping any that already exist.
|
|
1588
|
+
* @param files - Files to write
|
|
1589
|
+
* @returns Result with lists of written and skipped file paths
|
|
1590
|
+
*/
|
|
1591
|
+
function writeFiles(files) {
|
|
1592
|
+
const written = [];
|
|
1593
|
+
const skipped = [];
|
|
1594
|
+
for (const file of files) {
|
|
1595
|
+
if (fs$1.existsSync(file.path)) {
|
|
1596
|
+
skipped.push(file.path);
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
fs$1.mkdirSync(path.dirname(file.path), { recursive: true });
|
|
1600
|
+
fs$1.writeFileSync(file.path, file.content);
|
|
1601
|
+
written.push(file.path);
|
|
1602
|
+
}
|
|
1603
|
+
return {
|
|
1604
|
+
written,
|
|
1605
|
+
skipped
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* Generate GitHub Actions workflow files and print next steps.
|
|
1610
|
+
* @param options - Setup options including workspace config and output directory
|
|
1611
|
+
*/
|
|
1612
|
+
function setupGitHub(options) {
|
|
1613
|
+
logBetaWarning("setup github");
|
|
1614
|
+
const result = writeFiles(buildFiles(options));
|
|
1615
|
+
for (const filePath of result.written) {
|
|
1616
|
+
const relativePath = path.relative(options.outputDir, filePath);
|
|
1617
|
+
logger.success(`Generated ${styles.path(relativePath)}`);
|
|
1618
|
+
}
|
|
1619
|
+
for (const filePath of result.skipped) {
|
|
1620
|
+
const relativePath = path.relative(options.outputDir, filePath);
|
|
1621
|
+
logger.warn(`Skipped ${styles.path(relativePath)} (already exists)`);
|
|
1622
|
+
}
|
|
1623
|
+
logger.newline();
|
|
1624
|
+
logger.info("Next steps - set GitHub secrets:");
|
|
1625
|
+
logger.log(` gh secret set PLATFORM_MACHINE_USER_CLIENT_ID`);
|
|
1626
|
+
logger.log(` gh secret set PLATFORM_MACHINE_USER_CLIENT_SECRET`);
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region src/cli/commands/setup/github/index.ts
|
|
1631
|
+
const githubCommand = defineAppCommand({
|
|
1632
|
+
name: "github",
|
|
1633
|
+
description: "Generate GitHub Actions workflow for deployment. (beta)",
|
|
1634
|
+
args: z.object({
|
|
1635
|
+
"workspace-name": arg(z.string(), {
|
|
1636
|
+
alias: "n",
|
|
1637
|
+
description: "Workspace name"
|
|
1638
|
+
}),
|
|
1639
|
+
"workspace-region": arg(z.string(), {
|
|
1640
|
+
alias: "r",
|
|
1641
|
+
description: "Workspace region"
|
|
1642
|
+
}),
|
|
1643
|
+
"organization-id": arg(z.string(), {
|
|
1644
|
+
alias: "o",
|
|
1645
|
+
description: "Organization ID"
|
|
1646
|
+
}),
|
|
1647
|
+
"folder-id": arg(z.string(), {
|
|
1648
|
+
alias: "f",
|
|
1649
|
+
description: "Folder ID"
|
|
1650
|
+
}),
|
|
1651
|
+
dir: arg(z.string().default("."), {
|
|
1652
|
+
alias: "d",
|
|
1653
|
+
description: "App directory (for monorepo setups)"
|
|
1654
|
+
})
|
|
1655
|
+
}).strict(),
|
|
1656
|
+
run: (args) => {
|
|
1657
|
+
setupGitHub({
|
|
1658
|
+
workspaceName: args["workspace-name"],
|
|
1659
|
+
workspaceRegion: args["workspace-region"],
|
|
1660
|
+
organizationId: args["organization-id"],
|
|
1661
|
+
folderId: args["folder-id"],
|
|
1662
|
+
dir: args.dir,
|
|
1663
|
+
outputDir: process.cwd()
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
|
|
1668
|
+
//#endregion
|
|
1669
|
+
//#region src/cli/commands/setup/index.ts
|
|
1670
|
+
const setupCommand = defineCommand({
|
|
1671
|
+
name: "setup",
|
|
1672
|
+
description: "Set up project infrastructure.",
|
|
1673
|
+
subCommands: { github: githubCommand }
|
|
1674
|
+
});
|
|
1675
|
+
|
|
1427
1676
|
//#endregion
|
|
1428
1677
|
//#region src/cli/shared/progress.ts
|
|
1429
1678
|
/**
|
|
@@ -2725,14 +2974,14 @@ const workflowCommand = defineCommand({
|
|
|
2725
2974
|
name: "workflow",
|
|
2726
2975
|
description: "Manage workflows and workflow executions.",
|
|
2727
2976
|
subCommands: {
|
|
2728
|
-
list: listCommand$
|
|
2977
|
+
list: listCommand$9,
|
|
2729
2978
|
get: getCommand$3,
|
|
2730
2979
|
start: startCommand,
|
|
2731
2980
|
executions: executionsCommand,
|
|
2732
2981
|
resume: resumeCommand
|
|
2733
2982
|
},
|
|
2734
2983
|
async run() {
|
|
2735
|
-
await runCommand(listCommand$
|
|
2984
|
+
await runCommand(listCommand$9, []);
|
|
2736
2985
|
}
|
|
2737
2986
|
});
|
|
2738
2987
|
|
|
@@ -2743,10 +2992,10 @@ const appCommand = defineCommand({
|
|
|
2743
2992
|
description: "Manage workspace applications",
|
|
2744
2993
|
subCommands: {
|
|
2745
2994
|
health: healthCommand,
|
|
2746
|
-
list: listCommand$
|
|
2995
|
+
list: listCommand$10
|
|
2747
2996
|
},
|
|
2748
2997
|
async run() {
|
|
2749
|
-
await runCommand(listCommand$
|
|
2998
|
+
await runCommand(listCommand$10, []);
|
|
2750
2999
|
}
|
|
2751
3000
|
});
|
|
2752
3001
|
|
|
@@ -2757,12 +3006,12 @@ const userCommand = defineCommand({
|
|
|
2757
3006
|
description: "Manage workspace users",
|
|
2758
3007
|
subCommands: {
|
|
2759
3008
|
invite: inviteCommand,
|
|
2760
|
-
list: listCommand$
|
|
3009
|
+
list: listCommand$11,
|
|
2761
3010
|
remove: removeCommand,
|
|
2762
3011
|
update: updateCommand$2
|
|
2763
3012
|
},
|
|
2764
3013
|
async run() {
|
|
2765
|
-
await runCommand(listCommand$
|
|
3014
|
+
await runCommand(listCommand$11, []);
|
|
2766
3015
|
}
|
|
2767
3016
|
});
|
|
2768
3017
|
|
|
@@ -2776,18 +3025,19 @@ const workspaceCommand = defineCommand({
|
|
|
2776
3025
|
create: createCommand$3,
|
|
2777
3026
|
delete: deleteCommand$3,
|
|
2778
3027
|
get: getCommand$4,
|
|
2779
|
-
list: listCommand$
|
|
3028
|
+
list: listCommand$12,
|
|
2780
3029
|
restore: restoreCommand,
|
|
2781
3030
|
user: userCommand
|
|
2782
3031
|
},
|
|
2783
3032
|
async run() {
|
|
2784
|
-
await runCommand(listCommand$
|
|
3033
|
+
await runCommand(listCommand$12, []);
|
|
2785
3034
|
}
|
|
2786
3035
|
});
|
|
2787
3036
|
|
|
2788
3037
|
//#endregion
|
|
2789
3038
|
//#region src/cli/index.ts
|
|
2790
3039
|
register("tsx", import.meta.url, { data: {} });
|
|
3040
|
+
initCrashReporting();
|
|
2791
3041
|
const packageJson = await readPackageJson();
|
|
2792
3042
|
const cliName = Object.keys(packageJson.bin ?? {})[0] || "tailor-sdk";
|
|
2793
3043
|
const mainCommand = withCompletionCommand(defineCommand({
|
|
@@ -2796,6 +3046,7 @@ const mainCommand = withCompletionCommand(defineCommand({
|
|
|
2796
3046
|
subCommands: {
|
|
2797
3047
|
api: apiCommand,
|
|
2798
3048
|
apply: applyCommand,
|
|
3049
|
+
"crash-report": crashReportCommand,
|
|
2799
3050
|
executor: executorCommand,
|
|
2800
3051
|
function: functionCommand,
|
|
2801
3052
|
generate: generateCommand,
|
|
@@ -2809,6 +3060,7 @@ const mainCommand = withCompletionCommand(defineCommand({
|
|
|
2809
3060
|
query: queryCommand,
|
|
2810
3061
|
remove: removeCommand$1,
|
|
2811
3062
|
secret: secretCommand,
|
|
3063
|
+
setup: setupCommand,
|
|
2812
3064
|
show: showCommand,
|
|
2813
3065
|
staticwebsite: staticwebsiteCommand,
|
|
2814
3066
|
tailordb: tailordbCommand,
|
|
@@ -2821,14 +3073,20 @@ runMain(mainCommand, {
|
|
|
2821
3073
|
version: packageJson.version,
|
|
2822
3074
|
globalArgs: z.object(commonArgs),
|
|
2823
3075
|
cleanup: async ({ error }) => {
|
|
2824
|
-
if (error)
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
3076
|
+
if (error) {
|
|
3077
|
+
if (isCLIError(error)) {
|
|
3078
|
+
logger.log(error.format());
|
|
3079
|
+
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
3080
|
+
} else if (error instanceof Error) {
|
|
3081
|
+
logger.error(error.message);
|
|
3082
|
+
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
3083
|
+
} else logger.error(`Unknown error: ${error}`);
|
|
3084
|
+
if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
|
|
3085
|
+
const { reportCrash } = await import("../crash-report-Cot_9Esm.mjs");
|
|
3086
|
+
await reportCrash(error, "handledError");
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
const { shutdownTelemetry } = await import("../telemetry-BevrwWwF.mjs");
|
|
2832
3090
|
await shutdownTelemetry();
|
|
2833
3091
|
}
|
|
2834
3092
|
});
|