@agileguy/cf-cli 1.1.1 → 1.1.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.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -237,7 +237,7 @@ ${jr}`)}}var jr=`Usage: cf cache <command>
|
|
|
237
237
|
Commands:
|
|
238
238
|
purge Purge cached content
|
|
239
239
|
|
|
240
|
-
Run 'cf cache <command> --help' for more information.`;var Br=p(()=>{f();Or()});async function Hr(s,e){let{flags:n}=d(s),o=a(n,"profile"),t=a(n,"token"),r=a(n,"apiKey"),m=a(n,"email"),c=a(n,"accountId"),l=a(n,"zoneId"),w=a(n,"output");if(!o)throw new i("--
|
|
240
|
+
Run 'cf cache <command> --help' for more information.`;var Br=p(()=>{f();Or()});async function Hr(s,e){let{flags:n}=d(s),o=a(n,"name")??a(n,"profile"),t=a(n,"token"),r=a(n,"apiKey"),m=a(n,"email"),c=a(n,"accountId"),l=a(n,"zoneId"),w=a(n,"output");if(!o)throw new i("--name <profile> is required. Example: cf config set --name default --token <token>");if(!/^[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(o))throw new i(`Invalid profile name: "${o}". Profile names must start with a letter or digit and contain only alphanumeric characters and hyphens.`);if(new Set(["__proto__","constructor","prototype"]).has(o))throw new i(`Invalid profile name: "${o}". That name is reserved.`);let k;if(t)k="token";else if(r&&m)k="key";else if(r&&!m)throw new i("--email is required when using --api-key.");else{let B=M().profiles[o];if(B)k=B.auth_method;else throw new i("New profile requires either --token or --api-key + --email.")}if(w)Fe(w);let _=M(),I=_.profiles[o],P={auth_method:k,token:t??I?.token,api_key:r??I?.api_key,email:m??I?.email,account_id:c??I?.account_id,zone_id:l??I?.zone_id};_=qe(_,o,P),K(_),e.output.success(`Profile "${o}" saved.`)}var Vr=p(()=>{f();H();x()});async function Wr(s,e){let{flags:n}=d(s),o=a(n,"profile"),t=M(),r=o??t.default_profile,m=Q(t,r);if(!m)throw new i(`Profile "${r}" not found. Available profiles: ${Object.keys(t.profiles).join(", ")||"(none)"}`);let c=m.token?`***${m.token.slice(-4)}`:"-",l=m.api_key?`***${m.api_key.slice(-4)}`:"-";e.output.detail({Profile:r,"Auth Method":m.auth_method,Token:c,"API Key":l,Email:m.email??"-","Account ID":m.account_id??"-","Zone ID":m.zone_id??"-","Is Default":r===t.default_profile})}var Kr=p(()=>{H();f()});async function Qr(s,e){let n=M(),o=Object.entries(n.profiles).map(([r,m])=>({name:r,auth_method:m.auth_method,email:m.email??"-",account_id:m.account_id??"-",is_default:r===n.default_profile?"Yes":""}));if(o.length===0){e.output.info("No profiles configured. Run: cf config set --profile <name> --token <token>");return}let t=[{key:"name",header:"Profile",width:20},{key:"auth_method",header:"Auth",width:8},{key:"email",header:"Email",width:30},{key:"account_id",header:"Account ID",width:34},{key:"is_default",header:"Default",width:8}];e.output.table(o,t)}var Yr=p(()=>{H()});async function Xr(s,e){let{flags:n}=d(s),o=a(n,"profile");if(!o)throw new i("--profile <name> is required.");let t=M();if(!t.profiles[o])throw new i(`Profile "${o}" not found. Available profiles: ${Object.keys(t.profiles).join(", ")||"(none)"}`);if(!await C(`Delete profile "${o}"?`,e.flags)){e.output.info("Aborted.");return}let m=Ae(t,o),c=m;if(o===t.default_profile){let l=Object.keys(m.profiles);c={...m,default_profile:l[0]??"default"}}K(c),e.output.success(`Profile "${o}" deleted.`)}var Fr=p(()=>{f();H();U()});async function xr(s,e){let{positional:n}=d(s),o=n[0];if(!o)throw new i("Usage: cf config use <profile-name>");let t=M();if(!t.profiles[o])throw new i(`Profile "${o}" not found. Available profiles: ${Object.keys(t.profiles).join(", ")||"(none)"}`);t.default_profile=o,K(t),e.output.success(`Default profile set to "${o}".`)}var ei=p(()=>{f();H()});var ni={};z(ni,{run:()=>TA});async function TA(s,e){let[n,...o]=s;switch(n){case"set":return Hr(o,e);case"get":case"show":return Wr(o,e);case"list":case"ls":return Qr(o,e);case"delete":case"rm":case"remove":return Xr(o,e);case"use":case"switch":return xr(o,e);case void 0:case"--help":case"-h":e.output.raw(oi);return;default:throw new i(`Unknown config command: "${n}"
|
|
241
241
|
|
|
242
242
|
${oi}`)}}var oi=`Usage: cf config <command>
|
|
243
243
|
|
|
@@ -2474,7 +2474,7 @@ Commands:
|
|
|
2474
2474
|
update Update a page rule
|
|
2475
2475
|
delete Delete a page rule
|
|
2476
2476
|
|
|
2477
|
-
Run 'cf page-rules <command> --help' for more information.`;var fS=p(()=>{f();nS();rS();sS();mS();cS()});H();f();function Le(s,e){let n=e??M();if(s){let l=Q(n,s);if(!l)throw new J(`Profile "${s}" not found. Available profiles: ${Object.keys(n.profiles).join(", ")||"(none)"}`);return we(l,s)}let o=process.env.CF_PROFILE;if(o){let l=Q(n,o);if(!l)throw new J(`Profile "${o}" (from CF_PROFILE) not found. Available profiles: ${Object.keys(n.profiles).join(", ")||"(none)"}`);return we(l,o)}let t=process.env.CF_API_TOKEN;if(t)return{method:"token",token:t};let r=process.env.CF_API_KEY,m=process.env.CF_API_EMAIL;if(r&&m)return{method:"key",apiKey:r,email:m};if(r&&!m)throw new J("CF_API_KEY is set but CF_API_EMAIL is missing. Both are required for API key auth.");let c=Q(n);if(c)return we(c,n.default_profile);throw new J(`No authentication credentials found.
|
|
2477
|
+
Run 'cf page-rules <command> --help' for more information.`;var fS=p(()=>{f();nS();rS();sS();mS();cS()});H();f();function Le(s,e){let n=e??M();if(s){let l=Q(n,s);if(!l)throw new J(`Profile "${s}" not found. Available profiles: ${Object.keys(n.profiles).join(", ")||"(none)"}`);return we(l,s)}let o=process.env.CF_PROFILE;if(o){let l=Q(n,o);if(!l)throw new J(`Profile "${o}" (from CF_PROFILE) not found. Available profiles: ${Object.keys(n.profiles).join(", ")||"(none)"}`);return we(l,o)}let t=process.env.CF_API_TOKEN??process.env.CLOUDFLARE_API_TOKEN;if(t)return{method:"token",token:t};let r=process.env.CF_API_KEY,m=process.env.CF_API_EMAIL;if(r&&m)return{method:"key",apiKey:r,email:m};if(r&&!m)throw new J("CF_API_KEY is set but CF_API_EMAIL is missing. Both are required for API key auth.");let c=Q(n);if(c)return we(c,n.default_profile);throw new J(`No authentication credentials found.
|
|
2478
2478
|
Set up credentials using one of:
|
|
2479
2479
|
- cf config set-profile (interactive)
|
|
2480
2480
|
- CF_API_TOKEN environment variable
|