qarpeo 0.1.11 → 0.1.12
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/cli/index.mjs +35 -18
- package/dist/module.mjs +1 -1
- package/dist/utils/cloudflare-api.d.ts +1 -0
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -842,6 +842,19 @@ async function listCloudflareWorkers(auth) {
|
|
|
842
842
|
const data = await res.json();
|
|
843
843
|
return data.result || [];
|
|
844
844
|
}
|
|
845
|
+
async function deleteCloudflareWorker(auth, workerName) {
|
|
846
|
+
const url = `https://api.cloudflare.com/client/v4/accounts/${auth.accountId}/workers/scripts/${encodeURIComponent(workerName)}?force=true`;
|
|
847
|
+
const res = await fetch(url, {
|
|
848
|
+
method: "DELETE",
|
|
849
|
+
headers: { Authorization: `Bearer ${auth.token}` }
|
|
850
|
+
});
|
|
851
|
+
if (!res.ok) {
|
|
852
|
+
const errText = await res.text();
|
|
853
|
+
throw new Error(`Failed to delete Cloudflare Worker (HTTP ${res.status}): ${errText}`);
|
|
854
|
+
}
|
|
855
|
+
const data = await res.json();
|
|
856
|
+
return data.success === true;
|
|
857
|
+
}
|
|
845
858
|
|
|
846
859
|
function getWranglerBin$1(cwd) {
|
|
847
860
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
@@ -909,6 +922,7 @@ const deleteCommand = defineCommand({
|
|
|
909
922
|
async run({ args }) {
|
|
910
923
|
const cwd = resolve(process.cwd(), args.cwd);
|
|
911
924
|
loadDotEnv$3(cwd);
|
|
925
|
+
const auth = await getCloudflareAuth(cwd);
|
|
912
926
|
let workerName = args.name;
|
|
913
927
|
if (!workerName) {
|
|
914
928
|
const nameFlagIdx = process.argv.indexOf("--name");
|
|
@@ -918,7 +932,6 @@ const deleteCommand = defineCommand({
|
|
|
918
932
|
}
|
|
919
933
|
if (!workerName && stdin.isTTY) {
|
|
920
934
|
try {
|
|
921
|
-
const auth = await getCloudflareAuth(cwd);
|
|
922
935
|
if (auth) {
|
|
923
936
|
process.stdout.write("\u{1F50D} [qarpeo] Fetching deployed Workers from Cloudflare...\n");
|
|
924
937
|
const workers = await listCloudflareWorkers(auth);
|
|
@@ -980,20 +993,30 @@ const deleteCommand = defineCommand({
|
|
|
980
993
|
}
|
|
981
994
|
}
|
|
982
995
|
}
|
|
996
|
+
if (args.dryRun) {
|
|
997
|
+
console.log(`
|
|
998
|
+
\u{1F50D} [qarpeo] Dry-run completed. Worker "${workerName}" was not deleted.
|
|
999
|
+
`);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
console.log(`
|
|
1003
|
+
\u{1F5D1}\uFE0F [qarpeo] Deleting Worker "${workerName}" from Cloudflare...`);
|
|
1004
|
+
if (auth) {
|
|
1005
|
+
try {
|
|
1006
|
+
await deleteCloudflareWorker(auth, workerName);
|
|
1007
|
+
console.log(`
|
|
1008
|
+
\u2705 [qarpeo] Successfully deleted Worker "${workerName}" from Cloudflare!
|
|
1009
|
+
`);
|
|
1010
|
+
return;
|
|
1011
|
+
} catch (err) {
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
983
1014
|
await ensurePackage("wrangler", {
|
|
984
1015
|
cwd,
|
|
985
1016
|
purpose: "deleting Cloudflare Worker"
|
|
986
1017
|
});
|
|
987
1018
|
const wrangler = getWranglerBin$1(cwd);
|
|
988
|
-
|
|
989
|
-
\u{1F5D1}\uFE0F [qarpeo] Deleting Worker "${workerName}" from Cloudflare...`);
|
|
990
|
-
const wranglerArgs = ["delete", workerName];
|
|
991
|
-
if (args.dryRun) {
|
|
992
|
-
wranglerArgs.push("--dry-run");
|
|
993
|
-
}
|
|
994
|
-
if (args.force) {
|
|
995
|
-
wranglerArgs.push("--force");
|
|
996
|
-
}
|
|
1019
|
+
const wranglerArgs = ["delete", workerName, "--force"];
|
|
997
1020
|
if (args.env) {
|
|
998
1021
|
wranglerArgs.push("--env", args.env);
|
|
999
1022
|
}
|
|
@@ -1008,15 +1031,9 @@ const deleteCommand = defineCommand({
|
|
|
1008
1031
|
\u274C [qarpeo] Failed to delete Worker "${workerName}".`);
|
|
1009
1032
|
process.exit(result.status ?? 1);
|
|
1010
1033
|
}
|
|
1011
|
-
|
|
1012
|
-
console.log(`
|
|
1013
|
-
\u{1F50D} [qarpeo] Dry-run completed. Worker "${workerName}" was not deleted.
|
|
1014
|
-
`);
|
|
1015
|
-
} else {
|
|
1016
|
-
console.log(`
|
|
1034
|
+
console.log(`
|
|
1017
1035
|
\u2705 [qarpeo] Successfully deleted Worker "${workerName}" from Cloudflare!
|
|
1018
1036
|
`);
|
|
1019
|
-
}
|
|
1020
1037
|
}
|
|
1021
1038
|
});
|
|
1022
1039
|
|
|
@@ -2192,7 +2209,7 @@ const whoami = defineCommand({
|
|
|
2192
2209
|
const main = defineCommand({
|
|
2193
2210
|
meta: {
|
|
2194
2211
|
name: "qp",
|
|
2195
|
-
version: "0.1.
|
|
2212
|
+
version: "0.1.12",
|
|
2196
2213
|
description: "Cloudflare-native powerhouse module for Nuxt"
|
|
2197
2214
|
},
|
|
2198
2215
|
subCommands: {
|
package/dist/module.mjs
CHANGED
|
@@ -11,3 +11,4 @@ export interface WorkerScriptItem {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function getCloudflareAuth(cwd?: string): Promise<CloudflareAuth | null>;
|
|
13
13
|
export declare function listCloudflareWorkers(auth: CloudflareAuth): Promise<WorkerScriptItem[]>;
|
|
14
|
+
export declare function deleteCloudflareWorker(auth: CloudflareAuth, workerName: string): Promise<boolean>;
|