@tailor-platform/sdk 1.33.2 → 1.34.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 +8 -0
- package/dist/application-CLKuNo-l.mjs +4 -0
- package/dist/{application-CYPU-WIc.mjs → application-CluuzA0-.mjs} +18 -2
- package/dist/application-CluuzA0-.mjs.map +1 -0
- package/dist/cli/index.mjs +291 -40
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +6 -6
- package/dist/cli/lib.mjs +3 -3
- package/dist/{client-ea1w8SmG.mjs → client-BmQP4kKS.mjs} +1 -1
- package/dist/{client-CYGsf3Zl.mjs → client-CA2NM_4R.mjs} +10 -2
- package/dist/{client-CYGsf3Zl.mjs.map → client-CA2NM_4R.mjs.map} +1 -1
- package/dist/configure/index.d.mts +4 -5
- package/dist/configure/index.mjs +3 -0
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crash-report-CbueUPaP.mjs → crash-report-Bd2T8BhU.mjs} +1 -1
- package/dist/{crash-report-OXafT1iS.mjs → crash-report-CPkI2-cp.mjs} +2 -2
- package/dist/{crash-report-OXafT1iS.mjs.map → crash-report-CPkI2-cp.mjs.map} +1 -1
- package/dist/{index-DlivLpTN.d.mts → index--9iVDOXn.d.mts} +7 -8
- package/dist/{index-mAV9kYJA.d.mts → index-D4pBPp65.d.mts} +2 -2
- package/dist/{index-0H-YH8Ya.d.mts → index-DTJkkO-t.d.mts} +2 -2
- package/dist/{index-BM2SqNfO.d.mts → index-niQ9Qblw.d.mts} +2 -2
- package/dist/{index-BU6fmwJC.d.mts → index-qVqjEYnr.d.mts} +2 -2
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/index.d.mts +1 -2
- package/dist/{plugin-DQqzlulP.d.mts → plugin-D8hKE6rZ.d.mts} +59 -3
- package/dist/{runtime-CxDrzUC0.mjs → runtime-8G74KN_M.mjs} +286 -52
- package/dist/runtime-8G74KN_M.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/{workflow.generated-u9MgzqbM.d.mts → workflow.generated-DMt8PNVd.d.mts} +2 -2
- package/docs/cli/auth.md +162 -1
- package/docs/cli-reference.md +9 -6
- package/docs/services/auth.md +115 -0
- package/package.json +1 -1
- package/dist/application-CYPU-WIc.mjs.map +0 -1
- package/dist/application-dnB8CQiT.mjs +0 -4
- package/dist/env-BvIWsJxg.d.mts +0 -30
- package/dist/runtime-CxDrzUC0.mjs.map +0 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { D as FunctionExecution_Type, P as AuthInvokerSchema, V as PATScope, i as fetchAll, l as initOAuth2Client, m as userAgent, n as closeConnectionPool, o as fetchPlatformMachineUserToken, s as fetchUserInfo, u as initOperatorClient } from "../client-CA2NM_4R.mjs";
|
|
4
4
|
import { n as logger, r as styles } from "../logger-qz-Y4sBV.mjs";
|
|
5
|
-
import { At as functionExecutionStatusToString, B as updateCommand$3, Ct as startCommand, D as resumeCommand, Dt as executionsCommand, E as healthCommand, Ft as executeScript, I as showCommand, J as updateCommand$2, Jt as formatMigrationNumber, K as getCommand$4, L as logBetaWarning, M as truncateCommand, Mt as getCommand$1, P as generateCommand$1, Pt as apply, Q as getCommand$3, Qt as getMigrationFiles, Rt as parseMigrationLabelNumber, Tt as getCommand$5, U as treeCommand, W as listCommand$10, X as listCommand$9, Zt as getMigrationFilePath, _ as getCommand$6, _n as isVerbose, _t as listCommand$6, a as updateCommand$4, bt as jobsCommand, cn as sdkNameLabelKey, d as inviteCommand, en as isValidMigrationNumber, et as deleteCommand$3, fn as apiCommand, ft as generate, gn as deploymentArgs, h as listCommand$14, hn as confirmationArgs, ht as triggerCommand, i as isCLIError, it as listCommand$8, jt as formatKeyValueTable, k as listCommand$11, l as listCommand$13, ln as trnPrefix, lt as tokenCommand, mn as commonArgs, mt as webhookCommand, nt as createCommand$3, on as getNamespacesWithMigrations, ot as getCommand$2, p as restoreCommand, pn as defineAppCommand, r as queryCommand, s as removeCommand, sn as prompt, t as isNativeTypeScriptRuntime, tn as loadDiff, ut as listCommand$7, vn as workspaceArgs, w as listCommand$12, x as createCommand$4, y as deleteCommand$4, z as removeCommand$1 } from "../runtime-
|
|
5
|
+
import { At as functionExecutionStatusToString, B as updateCommand$3, Ct as startCommand, D as resumeCommand, Dt as executionsCommand, E as healthCommand, Ft as executeScript, I as showCommand, J as updateCommand$2, Jt as formatMigrationNumber, K as getCommand$4, L as logBetaWarning, M as truncateCommand, Mt as getCommand$1, P as generateCommand$1, Pt as apply, Q as getCommand$3, Qt as getMigrationFiles, Rt as parseMigrationLabelNumber, Tt as getCommand$5, U as treeCommand, W as listCommand$10, X as listCommand$9, Zt as getMigrationFilePath, _ as getCommand$6, _n as isVerbose, _t as listCommand$6, a as updateCommand$4, bt as jobsCommand, cn as sdkNameLabelKey, d as inviteCommand, en as isValidMigrationNumber, et as deleteCommand$3, fn as apiCommand, ft as generate, gn as deploymentArgs, h as listCommand$14, hn as confirmationArgs, ht as triggerCommand, i as isCLIError, it as listCommand$8, jt as formatKeyValueTable, k as listCommand$11, l as listCommand$13, ln as trnPrefix, lt as tokenCommand, mn as commonArgs, mt as webhookCommand, nt as createCommand$3, on as getNamespacesWithMigrations, ot as getCommand$2, p as restoreCommand, pn as defineAppCommand, r as queryCommand, s as removeCommand, sn as prompt, t as isNativeTypeScriptRuntime, tn as loadDiff, ut as listCommand$7, vn as workspaceArgs, w as listCommand$12, x as createCommand$4, y as deleteCommand$4, z as removeCommand$1 } from "../runtime-8G74KN_M.mjs";
|
|
6
6
|
import { t as readPackageJson } from "../package-json-CfUqjJaQ.mjs";
|
|
7
|
-
import { C as resolveTokens, S as readPlatformConfig, T as writePlatformConfig, a as loadConfig, b as loadAccessToken, g as getDistDir, i as resolveInlineSourcemap, l as ExecutorSchema, o as WorkflowJobSchema, s as ResolverSchema, v as deleteUserTokens, w as saveUserTokens, x as loadWorkspaceId, y as fetchLatestToken } from "../application-
|
|
8
|
-
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crash-report-
|
|
7
|
+
import { C as resolveTokens, S as readPlatformConfig, T as writePlatformConfig, a as loadConfig, b as loadAccessToken, g as getDistDir, i as resolveInlineSourcemap, l as ExecutorSchema, o as WorkflowJobSchema, s as ResolverSchema, v as deleteUserTokens, w as saveUserTokens, x as loadWorkspaceId, y as fetchLatestToken } from "../application-CluuzA0-.mjs";
|
|
8
|
+
import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crash-report-CPkI2-cp.mjs";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
11
11
|
import { withCompletionCommand } from "politty/completion";
|
|
@@ -22,8 +22,8 @@ import { resolveTSConfig } from "pkg-types";
|
|
|
22
22
|
import ml from "multiline-ts";
|
|
23
23
|
import * as rolldown from "rolldown";
|
|
24
24
|
import { create } from "@bufbuild/protobuf";
|
|
25
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
26
25
|
import open from "open";
|
|
26
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
27
27
|
import * as fs from "fs";
|
|
28
28
|
import { lookup } from "mime-types";
|
|
29
29
|
import pLimit from "p-limit";
|
|
@@ -60,6 +60,233 @@ const applyCommand = defineAppCommand({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/cli/commands/authconnection/args.ts
|
|
65
|
+
/**
|
|
66
|
+
* Arguments for identifying an auth connection
|
|
67
|
+
*/
|
|
68
|
+
const connectionNameArgs = { name: arg(z.string(), {
|
|
69
|
+
alias: "n",
|
|
70
|
+
description: "Auth connection name"
|
|
71
|
+
}) };
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/cli/commands/authconnection/authorize.ts
|
|
75
|
+
const defaultPort = 8080;
|
|
76
|
+
const defaultScopes = "openid,profile,email";
|
|
77
|
+
/**
|
|
78
|
+
* Fetch the OpenID Connect discovery document from a provider URL.
|
|
79
|
+
* @param providerUrl - OAuth2 provider base URL
|
|
80
|
+
* @returns Discovery document with authorization_endpoint
|
|
81
|
+
*/
|
|
82
|
+
async function fetchOIDCDiscovery(providerUrl) {
|
|
83
|
+
const url = providerUrl.replace(/\/$/, "") + "/.well-known/openid-configuration";
|
|
84
|
+
const response = await fetch(url);
|
|
85
|
+
if (!response.ok) throw new Error(`Failed to fetch OIDC discovery from ${url}: ${response.status}`);
|
|
86
|
+
return response.json();
|
|
87
|
+
}
|
|
88
|
+
function randomState$1() {
|
|
89
|
+
return crypto.randomBytes(32).toString("base64url");
|
|
90
|
+
}
|
|
91
|
+
const authorizeAuthConnectionCommand = defineAppCommand({
|
|
92
|
+
name: "authorize",
|
|
93
|
+
description: "Authorize an auth connection via OAuth2 flow.",
|
|
94
|
+
args: z.object({
|
|
95
|
+
...workspaceArgs,
|
|
96
|
+
...connectionNameArgs,
|
|
97
|
+
scopes: z.string().optional().default(defaultScopes).describe("OAuth2 scopes to request (comma-separated)"),
|
|
98
|
+
port: z.coerce.number().optional().default(defaultPort).describe("Local callback server port"),
|
|
99
|
+
"no-browser": z.boolean().optional().default(false).describe("Don't open browser automatically")
|
|
100
|
+
}).strict(),
|
|
101
|
+
run: async (args) => {
|
|
102
|
+
const client = await initOperatorClient(await loadAccessToken({
|
|
103
|
+
useProfile: true,
|
|
104
|
+
profile: args.profile
|
|
105
|
+
}));
|
|
106
|
+
const workspaceId = await loadWorkspaceId({
|
|
107
|
+
workspaceId: args["workspace-id"],
|
|
108
|
+
profile: args.profile
|
|
109
|
+
});
|
|
110
|
+
const connection = (await fetchAll(async (pageToken, maxPageSize) => {
|
|
111
|
+
const { connections, nextPageToken } = await client.listAuthConnections({
|
|
112
|
+
workspaceId,
|
|
113
|
+
pageToken,
|
|
114
|
+
pageSize: maxPageSize
|
|
115
|
+
});
|
|
116
|
+
return [connections, nextPageToken];
|
|
117
|
+
})).find((c) => c.name === args.name);
|
|
118
|
+
if (!connection) throw new Error(`Auth connection "${args.name}" not found.`);
|
|
119
|
+
if (connection.config.case !== "oauth2") throw new Error(`Auth connection "${args.name}" is not an OAuth2 connection.`);
|
|
120
|
+
const oauth2Config = connection.config.value;
|
|
121
|
+
const redirectUri = `http://localhost:${args.port}/callback`;
|
|
122
|
+
const state = randomState$1();
|
|
123
|
+
let authorizationEndpoint;
|
|
124
|
+
if (oauth2Config.authUrl) authorizationEndpoint = oauth2Config.authUrl;
|
|
125
|
+
else authorizationEndpoint = (await fetchOIDCDiscovery(oauth2Config.providerUrl)).authorization_endpoint;
|
|
126
|
+
const authUrl = new URL(authorizationEndpoint);
|
|
127
|
+
authUrl.searchParams.set("client_id", oauth2Config.clientId);
|
|
128
|
+
authUrl.searchParams.set("redirect_uri", redirectUri);
|
|
129
|
+
authUrl.searchParams.set("response_type", "code");
|
|
130
|
+
authUrl.searchParams.set("scope", args.scopes.replace(/,/g, " "));
|
|
131
|
+
authUrl.searchParams.set("state", state);
|
|
132
|
+
authUrl.searchParams.set("access_type", "offline");
|
|
133
|
+
await new Promise((resolve, reject) => {
|
|
134
|
+
const server = http.createServer(async (req, res) => {
|
|
135
|
+
if (!req.url?.startsWith("/callback")) {
|
|
136
|
+
res.writeHead(404);
|
|
137
|
+
res.end("Not found");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
const url = new URL(req.url, `http://localhost:${args.port}`);
|
|
142
|
+
const code = url.searchParams.get("code");
|
|
143
|
+
const returnedState = url.searchParams.get("state");
|
|
144
|
+
const error = url.searchParams.get("error");
|
|
145
|
+
if (error) throw new Error(`Authorization failed: ${error}`);
|
|
146
|
+
if (returnedState !== state) throw new Error("State mismatch — possible CSRF attack.");
|
|
147
|
+
if (!code) throw new Error("No authorization code received.");
|
|
148
|
+
await client.exchangeAuthConnectionAuthorizationCode({
|
|
149
|
+
workspaceId,
|
|
150
|
+
connectionName: args.name,
|
|
151
|
+
authorizationCode: code,
|
|
152
|
+
redirectUri
|
|
153
|
+
});
|
|
154
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
155
|
+
res.end("<html><body><h1>Authorization successful</h1><p>You can close this window.</p></body></html>");
|
|
156
|
+
server.close();
|
|
157
|
+
resolve();
|
|
158
|
+
} catch (err) {
|
|
159
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
160
|
+
res.end(`Authorization failed: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
161
|
+
server.close();
|
|
162
|
+
reject(err);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const timeout = setTimeout(() => {
|
|
166
|
+
server.close();
|
|
167
|
+
reject(/* @__PURE__ */ new Error("Authorization timeout exceeded (5 minutes)."));
|
|
168
|
+
}, 300 * 1e3);
|
|
169
|
+
server.on("close", () => {
|
|
170
|
+
clearTimeout(timeout);
|
|
171
|
+
});
|
|
172
|
+
server.on("error", (err) => {
|
|
173
|
+
reject(err);
|
|
174
|
+
});
|
|
175
|
+
server.listen(args.port, async () => {
|
|
176
|
+
const authorizeUrl = authUrl.toString();
|
|
177
|
+
logger.info(`Opening browser for authorization:\n\n${authorizeUrl}\n`);
|
|
178
|
+
if (!args["no-browser"]) try {
|
|
179
|
+
await open(authorizeUrl);
|
|
180
|
+
} catch {
|
|
181
|
+
logger.warn("Failed to open browser automatically. Please open the URL above manually.");
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
logger.success(`Auth connection "${args.name}" authorized successfully.`);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/cli/commands/authconnection/list.ts
|
|
191
|
+
function connectionInfo(connection) {
|
|
192
|
+
const oauth2 = connection.config.case === "oauth2" ? connection.config.value : void 0;
|
|
193
|
+
return {
|
|
194
|
+
name: connection.name,
|
|
195
|
+
type: connection.config.case ?? "unknown",
|
|
196
|
+
providerUrl: oauth2?.providerUrl ?? "",
|
|
197
|
+
issuerUrl: oauth2?.issuerUrl ?? "",
|
|
198
|
+
clientId: oauth2?.clientId ?? "",
|
|
199
|
+
authUrl: oauth2?.authUrl ?? "",
|
|
200
|
+
tokenUrl: oauth2?.tokenUrl ?? "",
|
|
201
|
+
createdAt: connection.createdAt ? timestampDate(connection.createdAt) : null
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const listAuthConnectionCommand = defineAppCommand({
|
|
205
|
+
name: "list",
|
|
206
|
+
description: "List all auth connections.",
|
|
207
|
+
args: z.object({ ...workspaceArgs }).strict(),
|
|
208
|
+
run: async (args) => {
|
|
209
|
+
const client = await initOperatorClient(await loadAccessToken({
|
|
210
|
+
useProfile: true,
|
|
211
|
+
profile: args.profile
|
|
212
|
+
}));
|
|
213
|
+
const workspaceId = await loadWorkspaceId({
|
|
214
|
+
workspaceId: args["workspace-id"],
|
|
215
|
+
profile: args.profile
|
|
216
|
+
});
|
|
217
|
+
try {
|
|
218
|
+
const connections = await fetchAll(async (pageToken, maxPageSize) => {
|
|
219
|
+
const { connections, nextPageToken } = await client.listAuthConnections({
|
|
220
|
+
workspaceId,
|
|
221
|
+
pageToken,
|
|
222
|
+
pageSize: maxPageSize
|
|
223
|
+
});
|
|
224
|
+
return [connections, nextPageToken];
|
|
225
|
+
});
|
|
226
|
+
logger.out(connections.map(connectionInfo));
|
|
227
|
+
} catch (error) {
|
|
228
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) {
|
|
229
|
+
logger.out([]);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/cli/commands/authconnection/revoke.ts
|
|
239
|
+
const revokeAuthConnectionCommand = defineAppCommand({
|
|
240
|
+
name: "revoke",
|
|
241
|
+
description: "Revoke an auth connection.",
|
|
242
|
+
args: z.object({
|
|
243
|
+
...workspaceArgs,
|
|
244
|
+
...connectionNameArgs,
|
|
245
|
+
...confirmationArgs
|
|
246
|
+
}).strict(),
|
|
247
|
+
run: async (args) => {
|
|
248
|
+
const client = await initOperatorClient(await loadAccessToken({
|
|
249
|
+
useProfile: true,
|
|
250
|
+
profile: args.profile
|
|
251
|
+
}));
|
|
252
|
+
const workspaceId = await loadWorkspaceId({
|
|
253
|
+
workspaceId: args["workspace-id"],
|
|
254
|
+
profile: args.profile
|
|
255
|
+
});
|
|
256
|
+
if (!args.yes) {
|
|
257
|
+
if (await prompt.text({ message: `Enter the connection name to confirm revocation ("${args.name}"):` }) !== args.name) {
|
|
258
|
+
logger.info("Auth connection revocation cancelled.");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
await client.revokeAuthConnection({
|
|
264
|
+
workspaceId,
|
|
265
|
+
connectionName: args.name
|
|
266
|
+
});
|
|
267
|
+
} catch (error) {
|
|
268
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Auth connection "${args.name}" not found.`, { cause: error });
|
|
269
|
+
throw error;
|
|
270
|
+
}
|
|
271
|
+
logger.success(`Auth connection "${args.name}" revoked.`);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/cli/commands/authconnection/index.ts
|
|
277
|
+
const authconnectionCommand = defineCommand({
|
|
278
|
+
name: "authconnection",
|
|
279
|
+
description: "Manage auth connections.",
|
|
280
|
+
subCommands: {
|
|
281
|
+
authorize: authorizeAuthConnectionCommand,
|
|
282
|
+
list: listAuthConnectionCommand,
|
|
283
|
+
revoke: revokeAuthConnectionCommand
|
|
284
|
+
},
|
|
285
|
+
async run() {
|
|
286
|
+
await runCommand(listAuthConnectionCommand, []);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
63
290
|
//#endregion
|
|
64
291
|
//#region src/cli/commands/crash-report/list.ts
|
|
65
292
|
const listCommand$5 = defineAppCommand({
|
|
@@ -808,7 +1035,7 @@ const generateCommand = defineAppCommand({
|
|
|
808
1035
|
|
|
809
1036
|
//#endregion
|
|
810
1037
|
//#region src/cli/commands/init.ts
|
|
811
|
-
const detectPackageManager = () => {
|
|
1038
|
+
const detectPackageManager$1 = () => {
|
|
812
1039
|
const availablePMs = [
|
|
813
1040
|
"npm",
|
|
814
1041
|
"yarn",
|
|
@@ -837,7 +1064,7 @@ const initCommand = defineAppCommand({
|
|
|
837
1064
|
run: async (args) => {
|
|
838
1065
|
const packageJson = await readPackageJson();
|
|
839
1066
|
const version = packageJson.version && packageJson.version !== "0.0.0" ? packageJson.version : "latest";
|
|
840
|
-
let packageManager = detectPackageManager();
|
|
1067
|
+
let packageManager = detectPackageManager$1();
|
|
841
1068
|
if (!packageManager) {
|
|
842
1069
|
logger.warn("Could not detect package manager, defaulting to npm");
|
|
843
1070
|
packageManager = "npm";
|
|
@@ -1676,31 +1903,63 @@ const secretCommand = defineCommand({
|
|
|
1676
1903
|
});
|
|
1677
1904
|
|
|
1678
1905
|
//#endregion
|
|
1679
|
-
//#region src/cli/commands/setup/github/
|
|
1680
|
-
var
|
|
1906
|
+
//#region src/cli/commands/setup/github/deploy.workflow.yml
|
|
1907
|
+
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\njobs:\n deploy:\n runs-on: ubuntu-latest\n permissions:\n contents: read\n steps:\n - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n # __SETUP_STEPS__\n - uses: tailor-platform/actions/deploy@980aeba08963f4322b2b48ca7a920f4e14876842 # v1.0.0\n with:\n workspace-name: __WORKSPACE_NAME__\n workspace-region: __WORKSPACE_REGION__\n organization-id: __ORGANIZATION_ID__\n folder-id: __FOLDER_ID__\n # __WORKING_DIRECTORY__\n platform-client-id: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_ID }}\n platform-client-secret: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n";
|
|
1681
1908
|
|
|
1682
1909
|
//#endregion
|
|
1683
|
-
//#region src/cli/commands/setup/github/
|
|
1684
|
-
var
|
|
1910
|
+
//#region src/cli/commands/setup/github/setup-bun.yml
|
|
1911
|
+
var setup_bun_default = "- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0\n- run: bun install --frozen-lockfile\n";
|
|
1685
1912
|
|
|
1686
1913
|
//#endregion
|
|
1687
|
-
//#region src/cli/commands/setup/github/
|
|
1688
|
-
var
|
|
1914
|
+
//#region src/cli/commands/setup/github/setup-npm.yml
|
|
1915
|
+
var setup_npm_default = "- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0\n with:\n node-version-file: package.json\n cache: npm\n- run: npm ci\n";
|
|
1916
|
+
|
|
1917
|
+
//#endregion
|
|
1918
|
+
//#region src/cli/commands/setup/github/setup-pnpm.yml
|
|
1919
|
+
var setup_pnpm_default = "- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0\n- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0\n with:\n node-version-file: package.json\n cache: pnpm\n- run: pnpm install --frozen-lockfile\n";
|
|
1920
|
+
|
|
1921
|
+
//#endregion
|
|
1922
|
+
//#region src/cli/commands/setup/github/setup-yarn.yml
|
|
1923
|
+
var setup_yarn_default = "- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0\n with:\n node-version-file: package.json\n cache: yarn\n- run: yarn install --frozen-lockfile\n";
|
|
1689
1924
|
|
|
1690
1925
|
//#endregion
|
|
1691
1926
|
//#region src/cli/commands/setup/github/template-deploy.ts
|
|
1927
|
+
const setupSteps = {
|
|
1928
|
+
pnpm: setup_pnpm_default,
|
|
1929
|
+
yarn: setup_yarn_default,
|
|
1930
|
+
npm: setup_npm_default,
|
|
1931
|
+
bun: setup_bun_default
|
|
1932
|
+
};
|
|
1933
|
+
function indentSnippet(snippet, spaces) {
|
|
1934
|
+
const indent = " ".repeat(spaces);
|
|
1935
|
+
return snippet.trimEnd().split("\n").map((line) => line ? indent + line : line).join("\n");
|
|
1936
|
+
}
|
|
1692
1937
|
/**
|
|
1693
|
-
*
|
|
1938
|
+
* Detect the package manager used in a project directory by checking for lockfiles.
|
|
1939
|
+
* @param dir - Project directory to inspect
|
|
1940
|
+
* @returns Detected package manager, defaults to npm
|
|
1941
|
+
*/
|
|
1942
|
+
function detectPackageManager(dir) {
|
|
1943
|
+
if (fs$1.existsSync(path.join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
1944
|
+
if (fs$1.existsSync(path.join(dir, "yarn.lock"))) return "yarn";
|
|
1945
|
+
if (fs$1.existsSync(path.join(dir, "bun.lockb")) || fs$1.existsSync(path.join(dir, "bun.lock"))) return "bun";
|
|
1946
|
+
if (fs$1.existsSync(path.join(dir, "package-lock.json"))) return "npm";
|
|
1947
|
+
return "npm";
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Render the deploy caller workflow YAML.
|
|
1694
1951
|
*
|
|
1695
|
-
*
|
|
1696
|
-
*
|
|
1952
|
+
* Generates a thin workflow that calls the composite deploy action
|
|
1953
|
+
* from tailor-platform/actions. The environment setup steps (Node.js,
|
|
1954
|
+
* package manager, dependency install) are generated based on the
|
|
1955
|
+
* detected package manager.
|
|
1697
1956
|
* @param params - Workspace and deployment configuration
|
|
1698
1957
|
* @returns Workflow YAML content
|
|
1699
1958
|
*/
|
|
1700
1959
|
function renderDeploy(params) {
|
|
1701
|
-
const { workspaceName, workspaceRegion, organizationId, folderId, workingDirectory } = params;
|
|
1702
|
-
const
|
|
1703
|
-
return deploy_workflow_default.replaceAll("__WORKSPACE_NAME__", () => workspaceName).
|
|
1960
|
+
const { workspaceName, workspaceRegion, organizationId, folderId, workingDirectory, packageManager } = params;
|
|
1961
|
+
const workingDirectoryLine = workingDirectory ? ` working-directory: ${workingDirectory}\n` : "";
|
|
1962
|
+
return deploy_workflow_default.replaceAll("__WORKSPACE_NAME__", () => workspaceName).replaceAll("__WORKSPACE_REGION__", () => workspaceRegion).replaceAll("__ORGANIZATION_ID__", () => organizationId).replaceAll("__FOLDER_ID__", () => folderId).replace(/ *# __WORKING_DIRECTORY__\n/, () => workingDirectoryLine).replace(/^ *# __SETUP_STEPS__$/m, () => indentSnippet(setupSteps[packageManager], 6));
|
|
1704
1963
|
}
|
|
1705
1964
|
|
|
1706
1965
|
//#endregion
|
|
@@ -1712,26 +1971,17 @@ function renderDeploy(params) {
|
|
|
1712
1971
|
*/
|
|
1713
1972
|
function buildFiles(options) {
|
|
1714
1973
|
const githubDir = path.join(options.outputDir, ".github");
|
|
1715
|
-
return [
|
|
1716
|
-
{
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
content: renderDeploy({
|
|
1727
|
-
workspaceName: options.workspaceName,
|
|
1728
|
-
workspaceRegion: options.workspaceRegion,
|
|
1729
|
-
organizationId: options.organizationId,
|
|
1730
|
-
folderId: options.folderId,
|
|
1731
|
-
workingDirectory: options.dir !== "." ? options.dir : void 0
|
|
1732
|
-
})
|
|
1733
|
-
}
|
|
1734
|
-
];
|
|
1974
|
+
return [{
|
|
1975
|
+
path: path.join(githubDir, `workflows/deploy-${options.workspaceName}.yml`),
|
|
1976
|
+
content: renderDeploy({
|
|
1977
|
+
workspaceName: options.workspaceName,
|
|
1978
|
+
workspaceRegion: options.workspaceRegion,
|
|
1979
|
+
organizationId: options.organizationId,
|
|
1980
|
+
folderId: options.folderId,
|
|
1981
|
+
workingDirectory: options.dir !== "." ? options.dir : void 0,
|
|
1982
|
+
packageManager: detectPackageManager(options.outputDir)
|
|
1983
|
+
})
|
|
1984
|
+
}];
|
|
1735
1985
|
}
|
|
1736
1986
|
/**
|
|
1737
1987
|
* Write files to disk, skipping any that already exist.
|
|
@@ -3199,6 +3449,7 @@ const mainCommand = withCompletionCommand(defineCommand({
|
|
|
3199
3449
|
subCommands: {
|
|
3200
3450
|
api: apiCommand,
|
|
3201
3451
|
apply: applyCommand,
|
|
3452
|
+
authconnection: authconnectionCommand,
|
|
3202
3453
|
"crash-report": crashReportCommand,
|
|
3203
3454
|
executor: executorCommand,
|
|
3204
3455
|
function: functionCommand,
|
|
@@ -3237,7 +3488,7 @@ runMain(mainCommand, {
|
|
|
3237
3488
|
if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
3238
3489
|
} else logger.error(`Unknown error: ${error}`);
|
|
3239
3490
|
if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
|
|
3240
|
-
const { reportCrash } = await import("../crash-report-
|
|
3491
|
+
const { reportCrash } = await import("../crash-report-Bd2T8BhU.mjs");
|
|
3241
3492
|
await reportCrash(error, "handledError");
|
|
3242
3493
|
}
|
|
3243
3494
|
}
|