@supacloud/cli 0.35.1 → 0.37.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/dist/index.js +221 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6503,7 +6503,7 @@ var ACTION_POLICY = {
|
|
|
6503
6503
|
},
|
|
6504
6504
|
edge_functions: {
|
|
6505
6505
|
read: ["list", "get_config", "source"],
|
|
6506
|
-
local: ["check"],
|
|
6506
|
+
local: ["check", "scaffold"],
|
|
6507
6507
|
write: ["deploy", "deploy_bundle", "config", "activate", "delete"]
|
|
6508
6508
|
},
|
|
6509
6509
|
scheduled_functions: { read: ["list", "get"], write: ["create", "update", "delete"] },
|
|
@@ -10069,6 +10069,7 @@ import {
|
|
|
10069
10069
|
existsSync as existsSync3,
|
|
10070
10070
|
fstatSync,
|
|
10071
10071
|
lstatSync,
|
|
10072
|
+
mkdirSync,
|
|
10072
10073
|
mkdtempSync,
|
|
10073
10074
|
openSync,
|
|
10074
10075
|
readFileSync as readFileSync3,
|
|
@@ -10087,13 +10088,15 @@ var CANONICAL_VERSION_PATTERN = /^(?:0|[1-9][0-9]*)$/;
|
|
|
10087
10088
|
var SAFE_SLUG_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
|
|
10088
10089
|
var ACTIVATION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
10089
10090
|
var LEGACY_ACTIVATION_ID = "legacy";
|
|
10091
|
+
var FUNCTION_FRAMEWORKS = ["fetch", "elysia", "hono", "sveltekit-function"];
|
|
10090
10092
|
var LIST_STRING_FIELDS = [
|
|
10091
10093
|
"id",
|
|
10092
10094
|
"name",
|
|
10093
10095
|
"status",
|
|
10094
10096
|
"entrypoint_path",
|
|
10095
10097
|
"created_at",
|
|
10096
|
-
"updated_at"
|
|
10098
|
+
"updated_at",
|
|
10099
|
+
"framework"
|
|
10097
10100
|
];
|
|
10098
10101
|
var LIST_BOOLEAN_FIELDS = ["verify_jwt", "import_map"];
|
|
10099
10102
|
function objectRecord(candidate) {
|
|
@@ -10105,6 +10108,45 @@ function canonicalVersion(candidate) {
|
|
|
10105
10108
|
function stringRoutes(candidate) {
|
|
10106
10109
|
return Array.isArray(candidate) && candidate.every((route) => typeof route === "string");
|
|
10107
10110
|
}
|
|
10111
|
+
function projectedFunctionCapabilities(candidate) {
|
|
10112
|
+
const record = objectRecord(candidate);
|
|
10113
|
+
if (!record)
|
|
10114
|
+
return null;
|
|
10115
|
+
const projected = {};
|
|
10116
|
+
for (const field of ["secrets", "outbound_hosts", "bindings"]) {
|
|
10117
|
+
if (record[field] !== undefined && (!Array.isArray(record[field]) || record[field].some((entry) => typeof entry !== "string")))
|
|
10118
|
+
return null;
|
|
10119
|
+
if (record[field] !== undefined)
|
|
10120
|
+
projected[field] = record[field];
|
|
10121
|
+
}
|
|
10122
|
+
if (record.background !== undefined && typeof record.background !== "boolean")
|
|
10123
|
+
return null;
|
|
10124
|
+
if (typeof record.background === "boolean")
|
|
10125
|
+
projected.background = record.background;
|
|
10126
|
+
return projected;
|
|
10127
|
+
}
|
|
10128
|
+
function projectedFunctionLimits(candidate) {
|
|
10129
|
+
const record = objectRecord(candidate);
|
|
10130
|
+
if (!record)
|
|
10131
|
+
return null;
|
|
10132
|
+
const projected = {};
|
|
10133
|
+
const maxima = {
|
|
10134
|
+
timeout_ms: 900000,
|
|
10135
|
+
max_request_body_bytes: 30 * 1024 * 1024,
|
|
10136
|
+
max_response_body_bytes: 30 * 1024 * 1024,
|
|
10137
|
+
wait_until_timeout_ms: 900000
|
|
10138
|
+
};
|
|
10139
|
+
for (const field of Object.keys(maxima)) {
|
|
10140
|
+
const value = record[field];
|
|
10141
|
+
if (value === undefined)
|
|
10142
|
+
continue;
|
|
10143
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > maxima[field]) {
|
|
10144
|
+
return null;
|
|
10145
|
+
}
|
|
10146
|
+
projected[field] = value;
|
|
10147
|
+
}
|
|
10148
|
+
return projected;
|
|
10149
|
+
}
|
|
10108
10150
|
function optionalTypedFields(source, fields, expectedType) {
|
|
10109
10151
|
return fields.every((field) => source[field] === undefined || typeof source[field] === expectedType);
|
|
10110
10152
|
}
|
|
@@ -10116,7 +10158,11 @@ function validCommittedFunctionActivationId(candidate) {
|
|
|
10116
10158
|
}
|
|
10117
10159
|
function projectedFunctionListEntry(candidate) {
|
|
10118
10160
|
const functionRecord = objectRecord(candidate);
|
|
10119
|
-
if (!functionRecord || typeof functionRecord.slug !== "string" || !SAFE_SLUG_PATTERN.test(functionRecord.slug) || typeof functionRecord.version !== "number" || !Number.isSafeInteger(functionRecord.version) || functionRecord.version < 0 || !validObservedFunctionActivationId(functionRecord.activation_id) || !optionalTypedFields(functionRecord, LIST_STRING_FIELDS, "string") || !optionalTypedFields(functionRecord, LIST_BOOLEAN_FIELDS, "boolean") || functionRecord.background_routes !== undefined && !stringRoutes(functionRecord.background_routes))
|
|
10161
|
+
if (!functionRecord || typeof functionRecord.slug !== "string" || !SAFE_SLUG_PATTERN.test(functionRecord.slug) || typeof functionRecord.version !== "number" || !Number.isSafeInteger(functionRecord.version) || functionRecord.version < 0 || !validObservedFunctionActivationId(functionRecord.activation_id) || !optionalTypedFields(functionRecord, LIST_STRING_FIELDS, "string") || !optionalTypedFields(functionRecord, LIST_BOOLEAN_FIELDS, "boolean") || functionRecord.framework !== undefined && !FUNCTION_FRAMEWORKS.includes(functionRecord.framework) || functionRecord.background_routes !== undefined && !stringRoutes(functionRecord.background_routes))
|
|
10162
|
+
return null;
|
|
10163
|
+
const capabilities = functionRecord.capabilities === undefined ? undefined : projectedFunctionCapabilities(functionRecord.capabilities);
|
|
10164
|
+
const limits = functionRecord.limits === undefined ? undefined : projectedFunctionLimits(functionRecord.limits);
|
|
10165
|
+
if (capabilities === null || limits === null)
|
|
10120
10166
|
return null;
|
|
10121
10167
|
const projected = {
|
|
10122
10168
|
slug: functionRecord.slug,
|
|
@@ -10130,6 +10176,10 @@ function projectedFunctionListEntry(candidate) {
|
|
|
10130
10176
|
if (functionRecord.background_routes !== undefined) {
|
|
10131
10177
|
projected.background_routes = functionRecord.background_routes;
|
|
10132
10178
|
}
|
|
10179
|
+
if (capabilities !== undefined)
|
|
10180
|
+
projected.capabilities = capabilities;
|
|
10181
|
+
if (limits !== undefined)
|
|
10182
|
+
projected.limits = limits;
|
|
10133
10183
|
return projected;
|
|
10134
10184
|
}
|
|
10135
10185
|
function projectedFunctionList(payload) {
|
|
@@ -10176,13 +10226,23 @@ function projectedFunctionIdentity(payload, expectedProjectRef, expectedSlug) {
|
|
|
10176
10226
|
const optionalFields = optionalConfigFields(response);
|
|
10177
10227
|
if (!optionalFields || !coherentFunctionVersion(response.active_version, optionalFields.version))
|
|
10178
10228
|
return null;
|
|
10229
|
+
const framework = response.framework;
|
|
10230
|
+
if (framework !== undefined && !FUNCTION_FRAMEWORKS.includes(framework))
|
|
10231
|
+
return null;
|
|
10232
|
+
const capabilities = response.capabilities === undefined ? undefined : projectedFunctionCapabilities(response.capabilities);
|
|
10233
|
+
const limits = response.limits === undefined ? undefined : projectedFunctionLimits(response.limits);
|
|
10234
|
+
if (capabilities === null || limits === null)
|
|
10235
|
+
return null;
|
|
10179
10236
|
return {
|
|
10180
10237
|
project_ref: expectedProjectRef,
|
|
10181
10238
|
slug: expectedSlug,
|
|
10182
10239
|
active_version: response.active_version,
|
|
10183
10240
|
verify_jwt: response.verify_jwt,
|
|
10184
10241
|
background_routes: response.background_routes,
|
|
10242
|
+
...framework === undefined ? {} : { framework },
|
|
10185
10243
|
...optionalFields,
|
|
10244
|
+
...capabilities === undefined ? {} : { capabilities },
|
|
10245
|
+
...limits === undefined ? {} : { limits },
|
|
10186
10246
|
activation_id: response.activation_id
|
|
10187
10247
|
};
|
|
10188
10248
|
}
|
|
@@ -10193,14 +10253,26 @@ function configMatchesExpectation(response, expected) {
|
|
|
10193
10253
|
if (typeof response.verify_jwt !== "boolean" || !stringRoutes(response.background_routes)) {
|
|
10194
10254
|
return false;
|
|
10195
10255
|
}
|
|
10256
|
+
if (response.framework !== undefined && !FUNCTION_FRAMEWORKS.includes(response.framework))
|
|
10257
|
+
return false;
|
|
10196
10258
|
if (expected.verify_jwt !== undefined && response.verify_jwt !== expected.verify_jwt)
|
|
10197
10259
|
return false;
|
|
10260
|
+
if (expected.framework !== undefined && response.framework !== expected.framework)
|
|
10261
|
+
return false;
|
|
10262
|
+
if (expected.capabilities !== undefined && JSON.stringify(response.capabilities) !== JSON.stringify(expected.capabilities))
|
|
10263
|
+
return false;
|
|
10264
|
+
if (expected.limits !== undefined && JSON.stringify(response.limits) !== JSON.stringify(expected.limits))
|
|
10265
|
+
return false;
|
|
10198
10266
|
return expected.background_routes === undefined || JSON.stringify(response.background_routes) === JSON.stringify(expected.background_routes);
|
|
10199
10267
|
}
|
|
10200
10268
|
function confirmedFunctionConfigMutation(payload, expectation) {
|
|
10201
10269
|
const response = objectRecord(payload);
|
|
10202
10270
|
if (!response || !mutationIdentityMatches(response, expectation) || !configMatchesExpectation(response, expectation.config))
|
|
10203
10271
|
return null;
|
|
10272
|
+
const capabilities = response.capabilities === undefined ? undefined : projectedFunctionCapabilities(response.capabilities);
|
|
10273
|
+
const limits = response.limits === undefined ? undefined : projectedFunctionLimits(response.limits);
|
|
10274
|
+
if (capabilities === null || limits === null)
|
|
10275
|
+
return null;
|
|
10204
10276
|
const optionalFields = optionalConfigFields(response);
|
|
10205
10277
|
if (!optionalFields)
|
|
10206
10278
|
return null;
|
|
@@ -10211,7 +10283,10 @@ function confirmedFunctionConfigMutation(payload, expectation) {
|
|
|
10211
10283
|
activation_id: response.activation_id,
|
|
10212
10284
|
verify_jwt: response.verify_jwt,
|
|
10213
10285
|
background_routes: response.background_routes,
|
|
10214
|
-
...
|
|
10286
|
+
...response.framework === undefined ? {} : { framework: response.framework },
|
|
10287
|
+
...optionalFields,
|
|
10288
|
+
...capabilities === undefined ? {} : { capabilities },
|
|
10289
|
+
...limits === undefined ? {} : { limits }
|
|
10215
10290
|
};
|
|
10216
10291
|
}
|
|
10217
10292
|
function confirmedFunctionDeletion(payload, expectation) {
|
|
@@ -10233,6 +10308,93 @@ function confirmedFunctionDeletion(payload, expectation) {
|
|
|
10233
10308
|
var execFileAsync = promisify(execFile);
|
|
10234
10309
|
var SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/;
|
|
10235
10310
|
var FORBIDDEN_BUNDLE_SEGMENTS = new Set(["node_modules", ".git"]);
|
|
10311
|
+
var FUNCTION_FRAMEWORKS2 = ["fetch", "elysia", "hono", "sveltekit-function"];
|
|
10312
|
+
function scaffoldFiles(framework, slug) {
|
|
10313
|
+
if (framework === "elysia") {
|
|
10314
|
+
return {
|
|
10315
|
+
"package.json": JSON.stringify({
|
|
10316
|
+
private: true,
|
|
10317
|
+
type: "module",
|
|
10318
|
+
dependencies: { elysia: "^1.4.30" }
|
|
10319
|
+
}, null, 2) + `
|
|
10320
|
+
`,
|
|
10321
|
+
"index.ts": `import { Elysia } from "elysia";
|
|
10322
|
+
|
|
10323
|
+
export default new Elysia()
|
|
10324
|
+
.get("/", () => ({ function: "${slug}", framework: "elysia" }));
|
|
10325
|
+
`
|
|
10326
|
+
};
|
|
10327
|
+
}
|
|
10328
|
+
if (framework === "hono") {
|
|
10329
|
+
return {
|
|
10330
|
+
"package.json": JSON.stringify({
|
|
10331
|
+
private: true,
|
|
10332
|
+
type: "module",
|
|
10333
|
+
dependencies: { hono: "^4.13.5" }
|
|
10334
|
+
}, null, 2) + `
|
|
10335
|
+
`,
|
|
10336
|
+
"index.ts": `import { Hono } from "hono";
|
|
10337
|
+
|
|
10338
|
+
const app = new Hono();
|
|
10339
|
+
app.get("/", (context) => context.json({ function: "${slug}", framework: "hono" }));
|
|
10340
|
+
|
|
10341
|
+
export default app;
|
|
10342
|
+
`
|
|
10343
|
+
};
|
|
10344
|
+
}
|
|
10345
|
+
if (framework === "sveltekit-function") {
|
|
10346
|
+
return {
|
|
10347
|
+
"package.json": JSON.stringify({
|
|
10348
|
+
private: true,
|
|
10349
|
+
type: "module",
|
|
10350
|
+
scripts: { build: "vite build" },
|
|
10351
|
+
devDependencies: {
|
|
10352
|
+
"@supacloud/function-adapter": "^0.1.0",
|
|
10353
|
+
"@sveltejs/kit": "^2.70.3",
|
|
10354
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
10355
|
+
svelte: "^5.57.0",
|
|
10356
|
+
vite: "^8.2.2"
|
|
10357
|
+
}
|
|
10358
|
+
}, null, 2) + `
|
|
10359
|
+
`,
|
|
10360
|
+
"svelte.config.js": `import adapter from "@supacloud/function-adapter/sveltekit-adapter";
|
|
10361
|
+
|
|
10362
|
+
export default { kit: { adapter: adapter() } };
|
|
10363
|
+
`,
|
|
10364
|
+
"vite.config.ts": `import { sveltekit } from "@sveltejs/kit/vite";
|
|
10365
|
+
import { defineConfig } from "vite";
|
|
10366
|
+
|
|
10367
|
+
export default defineConfig({ plugins: [sveltekit()] });
|
|
10368
|
+
`,
|
|
10369
|
+
"src/routes/+server.ts": `export function GET() {
|
|
10370
|
+
return Response.json({ function: "${slug}", framework: "sveltekit-function" });
|
|
10371
|
+
}
|
|
10372
|
+
`
|
|
10373
|
+
};
|
|
10374
|
+
}
|
|
10375
|
+
return { "index.ts": `export default function handler(request: Request) {
|
|
10376
|
+
return Response.json({ function: "${slug}", path: new URL(request.url).pathname });
|
|
10377
|
+
}
|
|
10378
|
+
` };
|
|
10379
|
+
}
|
|
10380
|
+
function scaffoldFunction(pathArg, slug, framework) {
|
|
10381
|
+
if (typeof slug !== "string" || !/^[A-Za-z0-9_-]{1,128}$/.test(slug)) {
|
|
10382
|
+
throw new Error("'slug' required for 'scaffold'");
|
|
10383
|
+
}
|
|
10384
|
+
if (typeof framework !== "string" || !FUNCTION_FRAMEWORKS2.includes(framework)) {
|
|
10385
|
+
throw new Error("'framework' required for 'scaffold'");
|
|
10386
|
+
}
|
|
10387
|
+
const target = resolve2(typeof pathArg === "string" ? pathArg : join2("supabase", "functions", slug));
|
|
10388
|
+
if (existsSync3(target))
|
|
10389
|
+
throw new Error(`Scaffold target already exists: ${target}`);
|
|
10390
|
+
const files = scaffoldFiles(framework, slug);
|
|
10391
|
+
for (const [relativePath, contents] of Object.entries(files)) {
|
|
10392
|
+
const destination = join2(target, relativePath);
|
|
10393
|
+
mkdirSync(resolve2(destination, ".."), { recursive: true });
|
|
10394
|
+
writeFileSync(destination, contents, { flag: "wx" });
|
|
10395
|
+
}
|
|
10396
|
+
return JSON.stringify({ success: true, framework, path: target, files: Object.keys(files) }, null, 2);
|
|
10397
|
+
}
|
|
10236
10398
|
function openFileIdentity(descriptor) {
|
|
10237
10399
|
const state = fstatSync(descriptor, { bigint: true });
|
|
10238
10400
|
if (!state.isFile())
|
|
@@ -10441,6 +10603,18 @@ function parseBackgroundRoutes(value) {
|
|
|
10441
10603
|
}
|
|
10442
10604
|
var backgroundRoutesSchema = Type.Optional(decodedSchema(Type.Union([Type.String(), Type.Array(Type.String())]), Type.Array(Type.String()), parseBackgroundRoutes));
|
|
10443
10605
|
var functionFilesRecordSchema = Type.Record(Type.String(), Type.String());
|
|
10606
|
+
var functionCapabilitiesSchema = Type.Object({
|
|
10607
|
+
secrets: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 128 })),
|
|
10608
|
+
outbound_hosts: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 128 })),
|
|
10609
|
+
bindings: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 128 })),
|
|
10610
|
+
background: Type.Optional(Type.Boolean())
|
|
10611
|
+
}, { additionalProperties: false });
|
|
10612
|
+
var functionLimitsSchema = Type.Object({
|
|
10613
|
+
timeout_ms: Type.Optional(Type.Integer({ minimum: 1, maximum: 900000 })),
|
|
10614
|
+
max_request_body_bytes: Type.Optional(Type.Integer({ minimum: 1, maximum: 30 * 1024 * 1024 })),
|
|
10615
|
+
max_response_body_bytes: Type.Optional(Type.Integer({ minimum: 1, maximum: 30 * 1024 * 1024 })),
|
|
10616
|
+
wait_until_timeout_ms: Type.Optional(Type.Integer({ minimum: 1, maximum: 900000 }))
|
|
10617
|
+
}, { additionalProperties: false });
|
|
10444
10618
|
function parseFunctionFiles(input) {
|
|
10445
10619
|
if (typeof input !== "string")
|
|
10446
10620
|
return input;
|
|
@@ -10648,12 +10822,18 @@ function confirmedFunctionConfig(payload, expected) {
|
|
|
10648
10822
|
return false;
|
|
10649
10823
|
if (expected.verify_jwt !== undefined && response.verify_jwt !== expected.verify_jwt)
|
|
10650
10824
|
return false;
|
|
10825
|
+
if (expected.framework !== undefined && response.framework !== expected.framework)
|
|
10826
|
+
return false;
|
|
10651
10827
|
if (expected.background_routes !== undefined) {
|
|
10652
10828
|
if (!Array.isArray(response.background_routes))
|
|
10653
10829
|
return false;
|
|
10654
10830
|
if (JSON.stringify(response.background_routes) !== JSON.stringify(expected.background_routes))
|
|
10655
10831
|
return false;
|
|
10656
10832
|
}
|
|
10833
|
+
if (expected.capabilities !== undefined && JSON.stringify(response.capabilities) !== JSON.stringify(expected.capabilities))
|
|
10834
|
+
return false;
|
|
10835
|
+
if (expected.limits !== undefined && JSON.stringify(response.limits) !== JSON.stringify(expected.limits))
|
|
10836
|
+
return false;
|
|
10657
10837
|
return true;
|
|
10658
10838
|
}
|
|
10659
10839
|
function functionSourceCode(payload, field = "code") {
|
|
@@ -10745,7 +10925,18 @@ function confirmedFunctionMutation(expectation, payload) {
|
|
|
10745
10925
|
const activationId = receipt.activation_id;
|
|
10746
10926
|
if (activeVersion === null || !validCommittedFunctionActivationId(activationId) || config.activation_id !== activationId || typeof config.verify_jwt !== "boolean" || !confirmedFunctionConfig(config, expectation.config ?? {}))
|
|
10747
10927
|
return null;
|
|
10748
|
-
|
|
10928
|
+
const framework = config.framework;
|
|
10929
|
+
if (framework !== undefined && (typeof framework !== "string" || !FUNCTION_FRAMEWORKS2.includes(framework))) {
|
|
10930
|
+
return null;
|
|
10931
|
+
}
|
|
10932
|
+
return {
|
|
10933
|
+
activeVersion,
|
|
10934
|
+
activationId,
|
|
10935
|
+
verifyJwt: config.verify_jwt,
|
|
10936
|
+
...framework === undefined ? {} : { framework },
|
|
10937
|
+
...config.capabilities === undefined ? {} : { capabilities: config.capabilities },
|
|
10938
|
+
...config.limits === undefined ? {} : { limits: config.limits }
|
|
10939
|
+
};
|
|
10749
10940
|
}
|
|
10750
10941
|
function functionMutationResponse(expectation, response) {
|
|
10751
10942
|
if (!response.ok)
|
|
@@ -10762,7 +10953,10 @@ function functionMutationResponse(expectation, response) {
|
|
|
10762
10953
|
activation_id: confirmed.activationId,
|
|
10763
10954
|
active_version: confirmed.activeVersion,
|
|
10764
10955
|
version: confirmed.activeVersion,
|
|
10765
|
-
verify_jwt: confirmed.verifyJwt
|
|
10956
|
+
verify_jwt: confirmed.verifyJwt,
|
|
10957
|
+
...confirmed.framework === undefined ? {} : { framework: confirmed.framework },
|
|
10958
|
+
...confirmed.capabilities === undefined ? {} : { capabilities: confirmed.capabilities },
|
|
10959
|
+
...confirmed.limits === undefined ? {} : { limits: confirmed.limits }
|
|
10766
10960
|
});
|
|
10767
10961
|
}
|
|
10768
10962
|
function readOnlyActivationResult() {
|
|
@@ -10824,13 +11018,13 @@ async function activateFunctionVersion(http, args, readOnly = false) {
|
|
|
10824
11018
|
}
|
|
10825
11019
|
function registerAdvancedTools(server, http, environment = process.env, options = {}) {
|
|
10826
11020
|
server.tool("edge_functions", `Edge Function management (Deno/Bun serverless). Source deploys are bundled; verified prebuilt artifacts stay byte-exact.
|
|
10827
|
-
Actions: list, get_config, deploy, deploy_bundle, config, source, activate, delete, check`, {
|
|
10828
|
-
action: withDescription(stringEnum(["list", "get_config", "deploy", "deploy_bundle", "config", "source", "activate", "delete", "check"]), "Action"),
|
|
10829
|
-
ref:
|
|
11021
|
+
Actions: list, get_config, deploy, deploy_bundle, config, source, activate, delete, check, scaffold`, {
|
|
11022
|
+
action: withDescription(stringEnum(["list", "get_config", "deploy", "deploy_bundle", "config", "source", "activate", "delete", "check", "scaffold"]), "Action"),
|
|
11023
|
+
ref: optional(Type.String(), "Project ref (not used by scaffold)"),
|
|
10830
11024
|
slug: optional(Type.String(), "[get_config/deploy/deploy_bundle/config/source/activate/delete/check] Function name"),
|
|
10831
11025
|
version: withDescription(functionVersionSchema, "[source/activate] Existing immutable Function version; source requires a positive version"),
|
|
10832
11026
|
code: optional(Type.String(), "[deploy/check] Function source code (TypeScript)"),
|
|
10833
|
-
path: optional(Type.String(), "[deploy/check]
|
|
11027
|
+
path: optional(Type.String(), "[deploy/check] Source path; [scaffold] optional target directory"),
|
|
10834
11028
|
"prebundled-path": optional(Type.String(), "[deploy] Prebuilt runtime bundle to upload without rebuilding; requires expected-sha256"),
|
|
10835
11029
|
"expected-sha256": optional(Type.String({ pattern: SHA256_HEX_PATTERN.source, minLength: 64, maxLength: 64 }), "[deploy] Required lowercase SHA-256 of the exact prebundled-path bytes"),
|
|
10836
11030
|
output: optional(Type.String(), "[source] Write source to this local file instead of stdout; the file must not already exist"),
|
|
@@ -10840,12 +11034,18 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
|
|
|
10840
11034
|
minify: optional(Type.Boolean(), "[deploy/deploy_bundle] Minify bundle"),
|
|
10841
11035
|
verify_jwt: optional(Type.Boolean(), "[deploy/deploy_bundle/config] Set JWT verification for this function"),
|
|
10842
11036
|
background_routes: withDescription(backgroundRoutesSchema, "[deploy/deploy_bundle/config] Background route paths; pass comma-separated or JSON array in CLI"),
|
|
11037
|
+
framework: optional(withDescription(stringEnum(["fetch", "elysia", "hono", "sveltekit-function"]), "[deploy/deploy_bundle/config/scaffold] Fetch framework adapter profile")),
|
|
11038
|
+
capabilities: optional(functionCapabilitiesSchema, "[deploy/deploy_bundle/config] Host capabilities: secrets, outbound_hosts, bindings, background"),
|
|
11039
|
+
limits: optional(functionLimitsSchema, "[deploy/deploy_bundle/config] Execution limits in milliseconds/bytes"),
|
|
10843
11040
|
"expected-active-version": withDescription(expectedActiveVersionSchema, "[deploy/deploy_bundle/activate] Required current active version, or 'absent' when none exists"),
|
|
10844
11041
|
"expected-activation-id": withDescription(expectedActivationIdSchema, "[deploy/deploy_bundle/config/activate/delete] Required activation ID from list, or 'legacy' for a new or legacy function")
|
|
10845
11042
|
}, async (args) => {
|
|
10846
11043
|
if (args.action === "activate")
|
|
10847
11044
|
return activateFunctionVersion(http, args, options.readOnly);
|
|
10848
|
-
|
|
11045
|
+
if (args.action === "scaffold") {
|
|
11046
|
+
return { content: [{ type: "text", text: scaffoldFunction(args.path, args.slug, args.framework) }] };
|
|
11047
|
+
}
|
|
11048
|
+
const { action, ref, slug, path: pathArg, output, entrypoint, minify, verify_jwt, background_routes, framework, capabilities, limits } = args;
|
|
10849
11049
|
rejectActionSpecificFlags(action, args);
|
|
10850
11050
|
const expectedActiveVersion = action === "deploy" || action === "deploy_bundle" ? requiredExpectedActiveVersion(args, action) : undefined;
|
|
10851
11051
|
const expectedActivationId = FUNCTION_IDENTITY_MUTATIONS.has(action) ? requiredExpectedActivationId(args, action) : undefined;
|
|
@@ -10857,7 +11057,10 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
|
|
|
10857
11057
|
let text;
|
|
10858
11058
|
const functionConfig = () => ({
|
|
10859
11059
|
...typeof verify_jwt === "boolean" ? { verify_jwt } : {},
|
|
10860
|
-
...Array.isArray(background_routes) ? { background_routes } : {}
|
|
11060
|
+
...Array.isArray(background_routes) ? { background_routes } : {},
|
|
11061
|
+
...typeof framework === "string" ? { framework } : {},
|
|
11062
|
+
...capabilities === undefined ? {} : { capabilities },
|
|
11063
|
+
...limits === undefined ? {} : { limits }
|
|
10861
11064
|
});
|
|
10862
11065
|
const hasFunctionConfig = () => Object.keys(functionConfig()).length > 0;
|
|
10863
11066
|
const checkSyntax = async (sourceCode) => {
|
|
@@ -10946,7 +11149,7 @@ ${deployCheck.err}`;
|
|
|
10946
11149
|
case "config":
|
|
10947
11150
|
need("slug", slug);
|
|
10948
11151
|
if (!hasFunctionConfig()) {
|
|
10949
|
-
throw new Error("'verify_jwt' or '
|
|
11152
|
+
throw new Error("'verify_jwt', 'background_routes', 'framework', 'capabilities', or 'limits' required for 'config'");
|
|
10950
11153
|
}
|
|
10951
11154
|
return updateFunctionConfiguration(http, {
|
|
10952
11155
|
projectRef: ref,
|
|
@@ -13120,7 +13323,7 @@ function registerBranchTools(server, http, options = {}) {
|
|
|
13120
13323
|
|
|
13121
13324
|
// src/shared/tools/supabase-cli-tools.ts
|
|
13122
13325
|
import { spawn } from "node:child_process";
|
|
13123
|
-
import { chmodSync, existsSync as existsSync5, mkdirSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
13326
|
+
import { chmodSync, existsSync as existsSync5, mkdirSync as mkdirSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
13124
13327
|
import { dirname, isAbsolute, join as join3, resolve as resolve4 } from "node:path";
|
|
13125
13328
|
var SENSITIVE_ENV_KEY = /(?:^|_)(?:PASSWORD|PASS|SECRET|TOKEN|KEY|CREDENTIALS?|AUTHORIZATION|AUTH|SESSION|COOKIE|BEARER|DB_URI|DB_URL|DSN|DATABASE_URL|DATABASE_URI|CONNECTION_STRING|CONNECTION_URI)(?:_|$)/i;
|
|
13126
13329
|
var VALID_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
@@ -13447,7 +13650,7 @@ async function executeOfficialAction(request, runtime) {
|
|
|
13447
13650
|
const normalizedRequest = { ...request, workdir };
|
|
13448
13651
|
const outputPath = actionOutputPath(normalizedRequest, workdir);
|
|
13449
13652
|
if (outputPath)
|
|
13450
|
-
|
|
13653
|
+
mkdirSync2(dirname(outputPath), { recursive: true });
|
|
13451
13654
|
const secrets = sensitiveValues(runtime.environment, request.db_url);
|
|
13452
13655
|
const execution = await runtime.executeOfficialCli(normalizedRequest);
|
|
13453
13656
|
if (execution.exitCode === 0 && request.action === "gen_types" && outputPath) {
|
|
@@ -13733,7 +13936,7 @@ import {
|
|
|
13733
13936
|
cpSync,
|
|
13734
13937
|
existsSync as existsSync7,
|
|
13735
13938
|
lstatSync as lstatSync2,
|
|
13736
|
-
mkdirSync as
|
|
13939
|
+
mkdirSync as mkdirSync3,
|
|
13737
13940
|
mkdtempSync as mkdtempSync2,
|
|
13738
13941
|
readdirSync as readdirSync3,
|
|
13739
13942
|
readFileSync as readFileSync5,
|
|
@@ -13780,7 +13983,7 @@ function availableBackupDirectory(destinationDirectory, now) {
|
|
|
13780
13983
|
return candidate;
|
|
13781
13984
|
}
|
|
13782
13985
|
function stagedSkill(sourceDirectory, targetRoot) {
|
|
13783
|
-
|
|
13986
|
+
mkdirSync3(targetRoot, { recursive: true });
|
|
13784
13987
|
const stagingRoot = mkdtempSync2(join5(targetRoot, ".supacloud-cli-install-"));
|
|
13785
13988
|
const stagingSkill = join5(stagingRoot, SKILL_NAME);
|
|
13786
13989
|
try {
|
|
@@ -14955,7 +15158,7 @@ function registerReleaseTools(server, http, options = {}) {
|
|
|
14955
15158
|
// package.json
|
|
14956
15159
|
var package_default = {
|
|
14957
15160
|
name: "@supacloud/cli",
|
|
14958
|
-
version: "0.
|
|
15161
|
+
version: "0.37.0",
|
|
14959
15162
|
description: "Project-scoped CLI for SupaCloud users",
|
|
14960
15163
|
type: "module",
|
|
14961
15164
|
main: "./dist/index.js",
|