sharetribe-community-cli 1.16.13 → 1.17.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 CHANGED
@@ -1,12 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import{Command as wr}from"commander";import{readFileSync as Ar,existsSync as vr,writeFileSync as Cr,mkdirSync as kr}from"node:fs";import{fileURLToPath as Pr}from"node:url";import{dirname as Ir,join as De}from"node:path";import B from"chalk";import{resolveConfigDir as br}from"sharetribe-flex-build-sdk";import{readFileSync as _e}from"node:fs";import{fileURLToPath as Le}from"node:url";import{dirname as W,join as $e}from"node:path";function Ne(){let s=Le(import.meta.url),t=W(s);for(;t!=="/";)try{let e=$e(t,"package.json");return _e(e,"utf-8")}catch{t=W(t)}throw new Error("Could not find package.json")}function G(){let s=JSON.parse(Ne());console.log(s.version)}import Fe from"inquirer";import{writeAuth as je}from"sharetribe-flex-build-sdk";async function Q(){let s=await Fe.prompt([{type:"password",name:"apiKey",message:"Enter API key:",mask:"*",validate:t=>!t||t.trim().length===0?"API key cannot be empty":!0}]);je({apiKey:s.apiKey}),console.log("Successfully logged in.")}import{clearAuth as Ke}from"sharetribe-flex-build-sdk";async function Y(){await Ke(),console.log("Successfully logged out.")}import{listProcesses as Ue,listProcessVersions as Ve}from"sharetribe-flex-build-sdk";import T from"chalk";function P(s,t){if(t.length===0)return;let e={};for(let n of s)e[n]=n.length+1;for(let n of t)for(let i of s){let a=n[i]||"";e[i]=Math.max(e[i]||0,a.length)}console.log("");let o=s.map((n,i)=>{let a=e[n]||0,p=n.padEnd(a+1);return i===s.length-1?p:p+" "}).join("");console.log(T.bold.black(o));for(let n of t){let a=s.map((p,c)=>{let m=n[p]||"",u=e[p]||0,f=m.padEnd(u+1);return c===s.length-1?f:f+" "}).join("");console.log(a)}console.log("")}function l(s){console.error(T.red(`Error: ${s}`))}function y(s){console.log(T.green(s))}function z(s){console.error(T.yellow(`Warning: ${s}`))}function He(s){try{let t=new Date(s),e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),n=t.toLocaleTimeString("en-US");return`${e}-${r}-${o} ${n}`}catch{return s}}async function q(s,t){try{if(t){let e=await Ve(void 0,s,t);if(e.length===0){console.log(`No versions found for process: ${t}`);return}let r=e.map(o=>({Created:He(o.createdAt),Version:o.version.toString(),Aliases:o.aliases?.join(", ")||"",Transactions:o.transactionCount?.toString()||"0"}));P(["Created","Version","Aliases","Transactions"],r)}else{let e=await Ue(void 0,s);if(e.length===0){console.log("No processes found.");return}let r=e.map(o=>({Name:o.name,"Latest version":o.version?.toString()||""}));P(["Name","Latest version"],r)}}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to list processes"),process.exitCode=1;return}}import{createProcess as Qe}from"sharetribe-flex-build-sdk";import{readdirSync as Je,readFileSync as Z,statSync as Be}from"node:fs";import{join as x}from"node:path";import{parseProcessFile as We}from"sharetribe-flex-build-sdk";function v(s){return x(s,"process.edn")}function I(s){try{if(Be(v(s)).isFile())return}catch{}throw new Error("--path should be a process directory")}function b(s){let t=x(s,"templates"),e=[],r;try{r=Je(t)}catch{return e}for(let o of r){let n=x(t,o);try{e.push({name:o,html:Z(x(n,`${o}-html.html`),"utf-8"),subject:Z(x(n,`${o}-subject.txt`),"utf-8")})}catch{}}return e}function O(s,t){let{notifications:e}=We(v(s)),r=new Set(t.map(i=>i.name)),o=new Set(e.map(i=>i.template));for(let i of r)o.has(i)||z(`template exists but is not used in the process: ${i}`);let n=e.filter(i=>!r.has(i.template));if(n.length>0)throw new Error(n.map(i=>`Template ${i.template} not found for notification ${Ge(i.name)}`).join(`
4
- `))}function Ge(s){return s.slice(s.indexOf("/")+1)}import{readFileSync as Ye}from"node:fs";async function _(s,t,e){try{I(e);let r=Ye(v(e),"utf-8"),o=b(e);O(e,o);let n=await Qe(void 0,s,t,r,o);y(`Process ${n.name} successfully created.`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to create process"),process.exitCode=1;return}}import{pushProcess as ze}from"sharetribe-flex-build-sdk";import{readFileSync as Ze}from"node:fs";async function L(s,t,e){try{I(e);let r=Ze(v(e),"utf-8"),o=b(e);O(e,o);let n=await ze(void 0,s,t,r,o);n.noChanges?console.log("No changes"):y(`Version ${n.version} successfully saved for process ${t}`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to push process"),process.exitCode=1;return}}import{getProcess as Xe}from"sharetribe-flex-build-sdk";import{writeFileSync as $,mkdirSync as N}from"node:fs";import{join as R}from"node:path";async function F(s,t,e,r,o){try{let n=await Xe(void 0,s,t,{version:r,alias:o});if(!n.definition)throw new Error("No process definition in response");let{existsSync:i}=await import("node:fs"),a=i(e);N(e,{recursive:!0}),a||console.error(`Creating a new directory: ${e}`);let p=R(e,"process.edn");$(p,n.definition,"utf-8");let c=n.emailTemplates||[];if(c&&Array.isArray(c)&&c.length>0){let m=R(e,"templates");N(m,{recursive:!0});for(let u of c){let f=u.name,k=u.html,S=u.subject;if(f){let d=R(m,f);if(N(d,{recursive:!0}),k){let g=R(d,`${f}-html.html`);$(g,k,"utf-8")}if(S){let g=R(d,`${f}-subject.txt`);$(g,S,"utf-8")}}}}console.error(`Saved process to ${e}`)}catch(n){n&&typeof n=="object"&&"message"in n?l(n.message):l("Failed to pull process"),process.exitCode=1;return}}import{createAlias as et,updateAlias as tt,deleteAlias as rt}from"sharetribe-flex-build-sdk";async function j(s,t,e,r){try{let o=await et(void 0,s,t,e,r);y(`Alias ${o.alias} successfully created to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to create alias"),process.exitCode=1;return}}async function K(s,t,e,r){try{let o=await tt(void 0,s,t,e,r);y(`Alias ${o.alias} successfully updated to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to update alias"),process.exitCode=1;return}}async function U(s,t,e){try{let r=await rt(void 0,s,t,e);y(`Alias ${r.alias} successfully deleted.`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to delete alias"),process.exitCode=1;return}}import{createAlias as X,createProcess as st,listProcessVersions as ot,pushProcess as nt,updateAlias as it}from"sharetribe-flex-build-sdk";import{readFileSync as at}from"node:fs";async function ct(s,t){try{return await ot(void 0,s,t)}catch(e){if(e&&typeof e=="object"&&e.code==="tx-process-not-found")return null;throw e}}async function V(s,t,e,r){try{I(e);let o=at(v(e),"utf-8"),n=b(e);O(e,n);let i=await ct(s,t);if(i===null){let m=await st(void 0,s,t,o,n);y(`Process ${m.name} successfully created.`);let u=await X(void 0,s,t,m.version,r);y(`Alias ${u.alias} successfully created to point to version ${u.version}.`);return}let a=i.some(m=>m.aliases?.includes(r)),p=await nt(void 0,s,t,o,n),c;if(p.noChanges)console.log("No changes"),c=Math.max(...i.map(m=>m.version));else{if(p.version===void 0)throw new Error(`The API saved a version of ${t} but did not say which`);c=p.version,y(`Version ${c} successfully saved for process ${t}`)}if(a){let m=await it(void 0,s,t,c,r);y(`Alias ${m.alias} successfully updated to point to version ${m.version}.`)}else{let m=await X(void 0,s,t,c,r);y(`Alias ${m.alias} successfully created to point to version ${m.version}.`)}}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to create/push process and alias"),process.exitCode=1;return}}function ee(s){let t=s.command("process").description("describe a process file").option("--path <PROCESS_DIR>","path to the directory where the process.edn file is").option("--transition <TRANSITION_NAME>","transition name, e.g. transition/request to get more details of it").action(async e=>{e.path?(console.log(`Describing process at: ${e.path}`),e.transition&&console.log(`Transition: ${e.transition}`),console.log("Process description not yet implemented")):t.outputHelp()});t.command("list").description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await q(r,e.process)}),t.command("create").description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await _(r,e.process,e.path)}),t.command("push").description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await L(r,e.process,e.path)}),t.command("pull").description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await F(r,e.process,e.path,e.version,e.alias)}),t.command("create-alias").description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").allowUnknownOption(!1).action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await j(r,e.process,parseInt(e.version),e.alias)}),t.command("update-alias").description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await K(r,e.process,parseInt(e.version),e.alias)}),t.command("delete-alias").description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await U(r,e.process,e.alias)}),t.command("deploy").description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await V(r,e.process,e.path,e.alias)}),s.command("process-list",{hidden:!0}).description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await q(r,e.process)}),s.command("process-create",{hidden:!0}).description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await _(r,e.process,e.path)}),s.command("process-push",{hidden:!0}).description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await L(r,e.process,e.path)}),s.command("process-pull",{hidden:!0}).description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await F(r,e.process,e.path,e.version,e.alias)}),s.command("process-create-alias",{hidden:!0}).description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await j(r,e.process,parseInt(e.version),e.alias)}),s.command("process-update-alias",{hidden:!0}).description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await K(r,e.process,parseInt(e.version),e.alias)}),s.command("process-delete-alias",{hidden:!0}).description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await U(r,e.process,e.alias)}),s.command("process-deploy",{hidden:!0}).description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await V(r,e.process,e.path,e.alias)})}import{listSearchSchemas as lt,setSearchSchema as pt,unsetSearchSchema as mt}from"sharetribe-flex-build-sdk";var te={metadata:"Metadata",private:"Private data",protected:"Protected data",public:"Public data"};async function dt(s,t){try{await pt(void 0,s,{key:t.key,scope:t.scope,type:t.type,doc:t.doc,defaultValue:t.default,schemaFor:t.schemaFor});let e=t.schemaFor||"listing",r=te[t.scope]||t.scope;console.log(`${r} schema, ${t.key} is successfully set for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to set search schema"),process.exitCode=1;return}}async function ut(s,t){try{await mt(void 0,s,{key:t.key,scope:t.scope,schemaFor:t.schemaFor});let e=t.schemaFor||"listing",r=te[t.scope]||t.scope;console.log(`${r} schema, ${t.key} is successfully unset for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to unset search schema"),process.exitCode=1;return}}function ft(s){return s==null?"":Array.isArray(s)?s.join(", "):String(s)}async function ht(s){try{let t=await lt(void 0,s);if(t.length===0){console.log("No search schemas found.");return}let e=t.map(i=>({"Schema for":i.schemaFor,Scope:i.scope,Key:i.key,Type:i.type,"Default value":ft(i.defaultValue),Doc:i.doc||""})).sort((i,a)=>i["Schema for"]!==a["Schema for"]?i["Schema for"].localeCompare(a["Schema for"]):i.Scope!==a.Scope?i.Scope.localeCompare(a.Scope):i.Key.localeCompare(a.Key)),r=["Schema for","Scope","Key","Type","Default value","Doc"],o={};for(let i of r)o[i]=i.length+1;for(let i of e)for(let a of r){let p=i[a]||"";o[a]=Math.max(o[a],p.length)}console.log("");let n=r.map((i,a)=>{let p=o[i]||0,c=i.padEnd(p);return a===r.length-1?c+" ":c+" "});console.log(n.join(""));for(let i of e){let a=r.map((p,c)=>{let m=i[p]||"",u=o[p]||0,f=m.padEnd(u);return c===r.length-1?f+" ":f+" "});console.log(a.join(""))}console.log("")}catch(t){t&&typeof t=="object"&&"message"in t?l(t.message):l("Failed to list search schemas"),process.exitCode=1;return}}function re(s){let t=s.command("search").description("list all search schemas").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await ht(r)});t.command("set").description("set search schema").requiredOption("--key <KEY>","key name").requiredOption("--scope <SCOPE>","extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)").requiredOption("--type <TYPE>","value type (either enum, multi-enum, boolean, long or text)").option("--doc <DOC>","description of the schema").option("--default <DEFAULT>","default value for search if value is not set").option("--schema-for <SCHEMA_FOR>","Subject of the schema (either listing, userProfile or transaction, defaults to listing)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await dt(r,{key:e.key,scope:e.scope,type:e.type,doc:e.doc,default:e.default,schemaFor:e.schemaFor})}),t.command("unset").description("unset search schema").requiredOption("--key <KEY>","key name").requiredOption("--scope <SCOPE>","extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)").option("--schema-for <SCHEMA_FOR>","Subject of the schema (either listing, userProfile or transaction, defaults to listing)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await ut(r,{key:e.key,scope:e.scope,schemaFor:e.schemaFor})})}import{pushAssets as gt,stageAsset as yt,getApiBaseUrl as Et,readAuth as St}from"sharetribe-flex-build-sdk";import{readFileSync as ie,writeFileSync as wt,existsSync as C,mkdirSync as H,readdirSync as ae,statSync as D,unlinkSync as se,createWriteStream as ce}from"node:fs";import{join as w,dirname as At}from"node:path";import{createHash as vt}from"node:crypto";import*as Ct from"node:http";import*as kt from"node:https";import{tmpdir as Pt}from"node:os";import{pipeline as le}from"node:stream/promises";import oe from"chalk";import E from"jsedn";import It from"yauzl";var bt="meta/asset-meta.edn",ne="assets/",Ot="\x1B[K",xt="\r";function pe(s){try{let t=E.parse(s),e=t.at(E.kw(":version"))||t.at(E.kw(":aliased-version")),r=t.at(E.kw(":assets")),o=[];if(r&&r.val)for(let n of r.val)o.push({path:n.at(E.kw(":path")),"content-hash":n.at(E.kw(":content-hash"))});return e?{version:e,assets:o}:null}catch{return null}}function me(s){let t=w(s,".flex-cli","asset-meta.edn");if(!C(t))return null;try{let e=ie(t,"utf-8");return pe(e)}catch{return null}}function de(s,t){let e=w(s,".flex-cli");C(e)||H(e,{recursive:!0});let r=t.assets.map(i=>new E.Map([E.kw(":path"),i.path,E.kw(":content-hash"),i["content-hash"]])),o=new E.Map([E.kw(":version"),t.version,E.kw(":assets"),new E.Vector(r)]),n=w(s,".flex-cli","asset-meta.edn");wt(n,E.encode(o),"utf-8")}function Rt(s){let t=Buffer.from(`${s.length}|`,"utf-8");return vt("sha1").update(t).update(s).digest("hex")}function Tt(s){let t=[];function e(r,o=""){let n=ae(r);for(let i of n){if(i===".flex-cli"||i===".DS_Store")continue;let a=w(r,i),p=o?w(o,i):i,c=D(a);if(c.isDirectory())e(a,p);else if(c.isFile()){let m=ie(a),u=Rt(m);t.push({path:p,data:m,hash:u})}}}return e(s),t}function Dt(s){let t=[];function e(r,o=""){let n=ae(r);for(let i of n){if(i===".flex-cli"||i===".DS_Store")continue;let a=w(r,i),p=o?w(o,i):i,c=D(a);c.isDirectory()?e(a,p):c.isFile()&&t.push(p)}}return e(s),t}function Mt(s){for(let t of s)if(t.path.endsWith(".json"))try{JSON.parse(t.data.toString("utf-8"))}catch(e){throw new Error(`Invalid JSON in ${t.path}: ${e}`)}}function qt(s){let t=s/1024/1024;return`${xt}${Ot}Downloaded ${t.toFixed(2)}MB`}function _t(s){let t=0,e=()=>{process.stderr.write(qt(t))},r=setInterval(e,100);s.on("data",o=>{t+=o.length}),s.on("end",()=>{clearInterval(r),e(),process.stderr.write(`
3
+ import{Command as jr}from"commander";import{readFileSync as Kr,existsSync as Ur,writeFileSync as Vr,mkdirSync as Jr}from"node:fs";import{fileURLToPath as Hr}from"node:url";import{dirname as Br,join as Be}from"node:path";import re from"chalk";import{resolveConfigDir as Wr}from"sharetribe-flex-build-sdk";import{readFileSync as Ye}from"node:fs";import{fileURLToPath as ze}from"node:url";import{dirname as oe,join as Ze}from"node:path";function Xe(){let t=ze(import.meta.url),r=oe(t);for(;r!=="/";)try{let e=Ze(r,"package.json");return Ye(e,"utf-8")}catch{r=oe(r)}throw new Error("Could not find package.json")}function ne(){let t=JSON.parse(Xe());console.log(t.version)}import et from"inquirer";import{writeAuth as tt}from"sharetribe-flex-build-sdk";async function ie(){let t=await et.prompt([{type:"password",name:"apiKey",message:"Enter API key:",mask:"*",validate:r=>!r||r.trim().length===0?"API key cannot be empty":!0}]);tt({apiKey:t.apiKey}),console.log("Successfully logged in.")}import{clearAuth as rt}from"sharetribe-flex-build-sdk";async function ae(){await rt(),console.log("Successfully logged out.")}import{listProcesses as ot,listProcessVersions as nt}from"sharetribe-flex-build-sdk";import R from"chalk";function N(t){return Object.keys(t[0]??{})}function C(t,r){let e={};for(let o of t)e[o]=o.length+1;for(let o of r)for(let n of t){let i=o[n]||"";e[n]=Math.max(e[n]||0,i.length)}console.log("");let s=t.map((o,n)=>{let i=e[o]||0,a=R.bold.black(o)+" ".repeat(Math.max(0,i+1-o.length));return n===t.length-1?a:a+" "});console.log(s.join(""));for(let o of r){let i=t.map((a,p)=>{let c=o[a]||"",d=e[a]||0,u=c.padEnd(d+1);return p===t.length-1?u:u+" "}).join("");console.log(i)}return console.log(""),e}function ce(t,r,e){for(let s of e){let o=t.map((n,i)=>{let a=s[n]||"",p=r[n]||0,c=a.padEnd(p+1);return i===t.length-1?c:c+" "});console.log(o.join(""))}}function l(t){console.error(R.red(`Error: ${t}`))}var st="\u203A";function O(t){return` ${R.bold.red(st)}${t}`}function $(t){let r=t.map(e=>`${O(` ${e}`)}
4
+ `).join(`${O(" ")}
5
+ `);process.stderr.write(`${r}
6
+
7
+ `)}function F(t){console.error("Could not parse arguments:");for(let r of t)console.error(`${r} is required`)}function y(t){console.log(R.green(t))}function le(t){console.error(R.yellow(`Warning: ${t}`))}function it(t){try{let r=new Date(t),e=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0"),n=r.toLocaleTimeString("en-US");return`${e}-${s}-${o} ${n}`}catch{return t}}async function j(t,r){try{if(r){let s=(await nt(void 0,t,r)).map(o=>({Created:it(o.createdAt),Version:o.version.toString(),Aliases:o.aliases?.join(", ")||"",Transactions:o.transactionCount?.toString()||"0"}));C(N(s),s)}else{let s=(await ot(void 0,t)).map(o=>({Name:o.name,"Latest version":o.version?.toString()||""}));C(N(s),s)}}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to list processes"),process.exitCode=1;return}}import{createProcess as dt}from"sharetribe-flex-build-sdk";import{readdirSync as at,readFileSync as pe,statSync as ct}from"node:fs";import{join as T}from"node:path";import{parseProcessFile as lt}from"sharetribe-flex-build-sdk";function v(t){return T(t,"process.edn")}function I(t){try{if(ct(v(t)).isFile())return}catch{}throw new Error("--path should be a process directory")}function b(t){let r=T(t,"templates"),e=[],s;try{s=at(r)}catch{return e}for(let o of s){let n=T(r,o);try{e.push({name:o,html:pe(T(n,`${o}-html.html`),"utf-8"),subject:pe(T(n,`${o}-subject.txt`),"utf-8")})}catch{}}return e}function x(t,r){let{notifications:e}=lt(v(t)),s=new Set(r.map(i=>i.name)),o=new Set(e.map(i=>i.template));for(let i of s)o.has(i)||le(`template exists but is not used in the process: ${i}`);let n=e.filter(i=>!s.has(i.template));if(n.length>0)throw new Error(n.map(i=>`Template ${i.template} not found for notification ${pt(i.name)}`).join(`
8
+ `))}function pt(t){return t.slice(t.indexOf("/")+1)}import{readFileSync as mt}from"node:fs";async function K(t,r,e){try{I(e);let s=mt(v(e),"utf-8"),o=b(e);x(e,o);let n=await dt(void 0,t,r,s,o);y(`Process ${n.name} successfully created.`)}catch(s){s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to create process"),process.exitCode=1;return}}import{pushProcess as ut}from"sharetribe-flex-build-sdk";import{readFileSync as ft}from"node:fs";async function U(t,r,e){try{I(e);let s=ft(v(e),"utf-8"),o=b(e);x(e,o);let n=await ut(void 0,t,r,s,o);n.noChanges?console.log("No changes"):y(`Version ${n.version} successfully saved for process ${r}`)}catch(s){s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to push process"),process.exitCode=1;return}}import{getProcess as ht}from"sharetribe-flex-build-sdk";import{writeFileSync as V,mkdirSync as J}from"node:fs";import{join as D}from"node:path";async function H(t,r,e,s,o){try{let n=await ht(void 0,t,r,{version:s,alias:o});if(!n.definition)throw new Error("No process definition in response");let{existsSync:i}=await import("node:fs"),a=i(e);J(e,{recursive:!0}),a||console.error(`Creating a new directory: ${e}`);let p=D(e,"process.edn");V(p,n.definition,"utf-8");let c=n.emailTemplates||[];if(c&&Array.isArray(c)&&c.length>0){let d=D(e,"templates");J(d,{recursive:!0});for(let u of c){let h=u.name,P=u.html,S=u.subject;if(h){let m=D(d,h);if(J(m,{recursive:!0}),P){let g=D(m,`${h}-html.html`);V(g,P,"utf-8")}if(S){let g=D(m,`${h}-subject.txt`);V(g,S,"utf-8")}}}}console.error(`Saved process to ${e}`)}catch(n){n&&typeof n=="object"&&"message"in n?l(n.message):l("Failed to pull process"),process.exitCode=1;return}}import{createAlias as gt,updateAlias as yt,deleteAlias as Et}from"sharetribe-flex-build-sdk";async function B(t,r,e,s){try{let o=await gt(void 0,t,r,e,s);y(`Alias ${o.alias} successfully created to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to create alias"),process.exitCode=1;return}}async function W(t,r,e,s){try{let o=await yt(void 0,t,r,e,s);y(`Alias ${o.alias} successfully updated to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to update alias"),process.exitCode=1;return}}async function G(t,r,e){try{let s=await Et(void 0,t,r,e);y(`Alias ${s.alias} successfully deleted.`)}catch(s){s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to delete alias"),process.exitCode=1;return}}import{createAlias as de,createProcess as St,listProcessVersions as At,pushProcess as wt,updateAlias as Ct}from"sharetribe-flex-build-sdk";import{readFileSync as vt}from"node:fs";async function kt(t,r){try{return await At(void 0,t,r)}catch(e){if(e&&typeof e=="object"&&e.code==="tx-process-not-found")return null;throw e}}async function Q(t,r,e,s){try{I(e);let o=vt(v(e),"utf-8"),n=b(e);x(e,n);let i=await kt(t,r);if(i===null){let d=await St(void 0,t,r,o,n);y(`Process ${d.name} successfully created.`);let u=await de(void 0,t,r,d.version,s);y(`Alias ${u.alias} successfully created to point to version ${u.version}.`);return}let a=i.some(d=>d.aliases?.includes(s)),p=await wt(void 0,t,r,o,n),c;if(p.noChanges)console.log("No changes"),c=Math.max(...i.map(d=>d.version));else{if(p.version===void 0)throw new Error(`The API saved a version of ${r} but did not say which`);c=p.version,y(`Version ${c} successfully saved for process ${r}`)}if(a){let d=await Ct(void 0,t,r,c,s);y(`Alias ${d.alias} successfully updated to point to version ${d.version}.`)}else{let d=await de(void 0,t,r,c,s);y(`Alias ${d.alias} successfully created to point to version ${d.version}.`)}}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to create/push process and alias"),process.exitCode=1;return}}function me(t){let r=t.command("process").description("describe a process file").option("--path <PROCESS_DIR>","path to the directory where the process.edn file is").option("--transition <TRANSITION_NAME>","transition name, e.g. transition/request to get more details of it").action(async e=>{e.path?(console.log(`Describing process at: ${e.path}`),e.transition&&console.log(`Transition: ${e.transition}`),console.log("Process description not yet implemented")):r.outputHelp()});r.command("list").description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await j(s,e.process)}),r.command("create").description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await K(s,e.process,e.path)}),r.command("push").description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await U(s,e.process,e.path)}),r.command("pull").description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await H(s,e.process,e.path,e.version,e.alias)}),r.command("create-alias").description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").allowUnknownOption(!1).action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await B(s,e.process,parseInt(e.version),e.alias)}),r.command("update-alias").description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await W(s,e.process,parseInt(e.version),e.alias)}),r.command("delete-alias").description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await G(s,e.process,e.alias)}),r.command("deploy").description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Q(s,e.process,e.path,e.alias)}),t.command("process-list",{hidden:!0}).description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await j(s,e.process)}),t.command("process-create",{hidden:!0}).description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await K(s,e.process,e.path)}),t.command("process-push",{hidden:!0}).description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await U(s,e.process,e.path)}),t.command("process-pull",{hidden:!0}).description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await H(s,e.process,e.path,e.version,e.alias)}),t.command("process-create-alias",{hidden:!0}).description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await B(s,e.process,parseInt(e.version),e.alias)}),t.command("process-update-alias",{hidden:!0}).description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await W(s,e.process,parseInt(e.version),e.alias)}),t.command("process-delete-alias",{hidden:!0}).description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await G(s,e.process,e.alias)}),t.command("process-deploy",{hidden:!0}).description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Q(s,e.process,e.path,e.alias)})}import{listSearchSchemas as Pt,setSearchSchema as It,unsetSearchSchema as bt}from"sharetribe-flex-build-sdk";var ue={metadata:"Metadata",private:"Private data",protected:"Protected data",public:"Public data"};async function xt(t,r){try{await It(void 0,t,{key:r.key,scope:r.scope,type:r.type,doc:r.doc,defaultValue:r.default,schemaFor:r.schemaFor});let e=r.schemaFor||"listing",s=ue[r.scope]||r.scope;console.log(`${s} schema, ${r.key} is successfully set for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to set search schema"),process.exitCode=1;return}}async function Ot(t,r){try{await bt(void 0,t,{key:r.key,scope:r.scope,schemaFor:r.schemaFor});let e=r.schemaFor||"listing",s=ue[r.scope]||r.scope;console.log(`${s} schema, ${r.key} is successfully unset for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to unset search schema"),process.exitCode=1;return}}function Rt(t){return t==null?"":Array.isArray(t)?t.join(", "):String(t)}async function Tt(t){try{let e=(await Pt(void 0,t)).map(o=>({"Schema for":o.schemaFor,Scope:o.scope,Key:o.key,Type:o.type,"Default value":Rt(o.defaultValue),Doc:o.doc||""})).sort((o,n)=>o["Schema for"]!==n["Schema for"]?o["Schema for"].localeCompare(n["Schema for"]):o.Scope!==n.Scope?o.Scope.localeCompare(n.Scope):o.Key.localeCompare(n.Key));C(["Schema for","Scope","Key","Type","Default value","Doc"],e)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to list search schemas"),process.exitCode=1;return}}function fe(t){let r=t.command("search").description("list all search schemas").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Tt(s)});r.command("set").description("set search schema").requiredOption("--key <KEY>","key name").requiredOption("--scope <SCOPE>","extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)").requiredOption("--type <TYPE>","value type (either enum, multi-enum, boolean, long or text)").option("--doc <DOC>","description of the schema").option("--default <DEFAULT>","default value for search if value is not set").option("--schema-for <SCHEMA_FOR>","Subject of the schema (either listing, userProfile or transaction, defaults to listing)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await xt(s,{key:e.key,scope:e.scope,type:e.type,doc:e.doc,default:e.default,schemaFor:e.schemaFor})}),r.command("unset").description("unset search schema").requiredOption("--key <KEY>","key name").requiredOption("--scope <SCOPE>","extended data scope (either metadata or public for listing schema, metadata, private, protected or public for userProfile schema, metadata or protected for transaction schema)").option("--schema-for <SCHEMA_FOR>","Subject of the schema (either listing, userProfile or transaction, defaults to listing)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Ot(s,{key:e.key,scope:e.scope,schemaFor:e.schemaFor})})}import{pushAssets as Lt,stageAsset as Nt,getApiBaseUrl as Ft,readAuth as Se}from"sharetribe-flex-build-sdk";import M from"chalk";import Y from"jsedn";var Dt="sharetribe-community-cli";function $t(t){try{return JSON.parse(t).errors?.[0]?.title}catch{return}}function Mt(t){try{let e=Y.parse(t).at(Y.kw(":errors"))?.val?.[0];return e?e.at(Y.kw(":title")):void 0}catch{return}}function _t(t){let r;try{r=JSON.parse(t).errors?.[0]?.details?.assets}catch{return}if(!(!Array.isArray(r)||r.length===0))return r.map(e=>{let s=new Set,o=[];for(let n of e.errors??[]){let i=JSON.stringify(n);s.has(i)||(s.add(i),o.push(n.message??""))}return{path:e.path??"",messages:o}})}function qt(t){return t.flatMap(({path:r,messages:e})=>[O(` In ${M.bold(r)}:`),...e.map(s=>O(` ${s}`))]).map(r=>`
9
+ ${r}`).join("")}function z(t,r){return{status:r,title:$t(t)??Mt(t),originalText:t||void 0,assetErrors:_t(t)}}function Z(t,r,e){let{status:s,title:o,originalText:n,assetErrors:i}=t;if(s===500){$(["API call failed. Reason: Internal server error."]);return}if(s===401){$(["Error: Access denied",`Failed to access marketplace ${M.bold(r)} with API key ending with ...${M.bold(e.slice(-4))}`,`Use ${M.bold(`${Dt} login`)} to relogin if needed.`]);return}let a=`API call failed. Status: ${s}, reason: ${o||n||"Unspecified"}`;$([i?.length?`${a}${qt(i)}`:a])}import{readFileSync as Ae,writeFileSync as jt,existsSync as k,mkdirSync as X,readdirSync as we,statSync as q,unlinkSync as he,createWriteStream as Ce}from"node:fs";import{join as A,dirname as Kt}from"node:path";import{createHash as Ut}from"node:crypto";import*as Vt from"node:http";import*as Jt from"node:https";import{tmpdir as Ht}from"node:os";import{pipeline as ve}from"node:stream/promises";import ge from"chalk";import E from"jsedn";import Bt from"yauzl";var Wt="meta/asset-meta.edn",ye="assets/",Gt="\x1B[K",Qt="\r";function ke(t){try{let r=E.parse(t),e=r.at(E.kw(":version"))||r.at(E.kw(":aliased-version")),s=r.at(E.kw(":assets")),o=[];if(s&&s.val)for(let n of s.val)o.push({path:n.at(E.kw(":path")),"content-hash":n.at(E.kw(":content-hash"))});return e?{version:e,assets:o}:null}catch{return null}}function Pe(t){let r=A(t,".flex-cli","asset-meta.edn");if(!k(r))return null;try{let e=Ae(r,"utf-8");return ke(e)}catch{return null}}function Ie(t,r){let e=A(t,".flex-cli");k(e)||X(e,{recursive:!0});let s=r.assets.map(i=>new E.Map([E.kw(":path"),i.path,E.kw(":content-hash"),i["content-hash"]])),o=new E.Map([E.kw(":version"),r.version,E.kw(":assets"),new E.Vector(s)]),n=A(t,".flex-cli","asset-meta.edn");jt(n,E.encode(o),"utf-8")}function Yt(t){let r=Buffer.from(`${t.length}|`,"utf-8");return Ut("sha1").update(r).update(t).digest("hex")}function zt(t){let r=[];function e(s,o=""){let n=we(s);for(let i of n){if(i===".flex-cli"||i===".DS_Store")continue;let a=A(s,i),p=o?A(o,i):i,c=q(a);if(c.isDirectory())e(a,p);else if(c.isFile()){let d=Ae(a),u=Yt(d);r.push({path:p,data:d,hash:u})}}}return e(t),r}function Zt(t){let r=[];function e(s,o=""){let n=we(s);for(let i of n){if(i===".flex-cli"||i===".DS_Store")continue;let a=A(s,i),p=o?A(o,i):i,c=q(a);c.isDirectory()?e(a,p):c.isFile()&&r.push(p)}}return e(t),r}function Xt(t){for(let r of t)if(r.path.endsWith(".json"))try{JSON.parse(r.data.toString("utf-8"))}catch(e){throw new Error(`Invalid JSON in ${r.path}: ${e}`)}}function er(t){let r=t/1024/1024;return`${Qt}${Gt}Downloaded ${r.toFixed(2)}MB`}function tr(t){let r=0,e=()=>{process.stderr.write(er(r))},s=setInterval(e,100);t.on("data",o=>{r+=o.length}),t.on("end",()=>{clearInterval(s),e(),process.stderr.write(`
5
10
  Finished downloading assets
6
- `)})}function Lt(){let s=St();if(!s?.apiKey)throw new Error("Not logged in. Please provide apiKey or run: sharetribe-community-cli login");return s.apiKey}function $t(s,t){let e=new URL(Et()+"/assets/pull");return e.searchParams.set("marketplace",s),t?e.searchParams.set("version",t):e.searchParams.set("version-alias","latest"),e}function Nt(s,t){try{let r=JSON.parse(s).errors?.[0]?.message;if(r)return r}catch{}return s||`HTTP ${t}`}async function Ft(s,t){let e=$t(s,t),r=Lt(),o=e.protocol==="https:",n=o?kt:Ct;return new Promise((i,a)=>{let p=n.request({method:"GET",hostname:e.hostname,port:e.port||(o?443:80),path:e.pathname+e.search,headers:{Authorization:`Apikey ${r}`,Accept:"application/zip"}},c=>{let m=c.statusCode||0;if(m<200||m>=300){let u=[];c.on("data",f=>u.push(f)),c.on("end",()=>{let f=Buffer.concat(u).toString("utf-8");a(new Error(Nt(f,m)))});return}i(c)});p.setTimeout(12e4,()=>{p.destroy(new Error("Request timeout"))}),p.on("error",a),p.end()})}function jt(){return w(Pt(),`assets-${Date.now()}.zip`)}function Kt(s){return s.startsWith(ne)?s.slice(ne.length):s}function Ut(s){return new Promise((t,e)=>{let r=[];s.on("data",o=>r.push(o)),s.on("end",()=>t(Buffer.concat(r).toString("utf-8"))),s.on("error",e)})}async function Vt(s,t){return new Promise((e,r)=>{It.open(s,{lazyEntries:!0},(o,n)=>{if(o||!n){r(o||new Error("Failed to open zip file"));return}let i=null;n.on("error",r),n.on("end",()=>{if(!i){r(new Error("Asset metadata not found in zip"));return}e(i)}),n.readEntry(),n.on("entry",a=>{if(a.fileName.endsWith("/")){n.readEntry();return}n.openReadStream(a,(p,c)=>{if(p||!c){r(p||new Error("Failed to read zip entry"));return}if(a.fileName===bt){Ut(c).then(f=>{if(i=pe(f),!i){r(new Error("Invalid asset metadata"));return}n.readEntry()}).catch(r);return}let m=w(t,Kt(a.fileName)),u=At(m);C(u)||H(u,{recursive:!0}),le(c,ce(m)).then(()=>n.readEntry()).catch(r)})})})})}async function Ht(s,t,e,r){try{if(C(t)||H(t,{recursive:!0}),!D(t).isDirectory())throw new Error(`${t} is not a directory`);let n=r?Dt(t):[],i=me(t),a=jt();try{let p=await Ft(s,e);_t(p),await le(p,ce(a));let c=await Vt(a,t),m=c.version,u=r?new Set(n.filter(S=>!c.assets.some(d=>d.path===S))):new Set,k=i?.version!==m||u.size>0;if(u.size>0)for(let S of u){let d=w(t,S);C(d)&&se(d)}k?(de(t,{version:m,assets:c.assets}),console.log(`Version ${m} successfully pulled.`)):console.log("Assets are up to date.")}finally{C(a)&&se(a)}}catch(o){o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to pull assets"),process.exitCode=1;return}}function Jt(s,t){let e=new Map(s.map(r=>[r.path,r["content-hash"]]));return t.filter(r=>{let o=e.get(r.path);return!o||o!==r.hash})}async function Bt(s,t,e){try{if(!C(t)||!D(t).isDirectory())throw new Error(`${t} is not a valid directory`);let r=me(t),o=r?.version||"nil",n=Tt(t);Mt(n);let i=Jt(r?.assets||[],n),a=d=>d.toLowerCase().endsWith(".json"),p=i.filter(d=>!a(d.path)),c=new Map(n.map(d=>[d.path,d])),m=[];if(e&&r)for(let d of r.assets)c.has(d.path)||m.push({path:d.path,op:"delete"});if(i.length===0&&m.length===0){console.log("Assets are up to date.");return}if(i.length>0){let d=i.map(g=>g.path).join(", ");console.log(oe.green(`Uploading changed assets: ${d}`))}let f=new Map;if(p.length>0){let d=p.map(g=>g.path).join(", ");console.log(oe.green(`Staging assets: ${d}`));for(let g of p)try{let A=await yt(void 0,s,g.data,g.path);f.set(g.path,A.stagingId)}catch(A){if(A&&typeof A=="object"&&"code"in A&&A.code==="asset-invalid-content"){let qe="message"in A?A.message:"The file is missing or uses an unsupported format.";throw new Error(`Failed to stage image ${g.path}: ${qe}
7
- Fix the file and rerun assets push to retry staging.`)}throw A}}let k=i.map(d=>{let g=f.get(d.path);return{path:d.path,op:"upsert",...g?{stagingId:g}:{data:d.data,filename:d.path}}}),S=await gt(void 0,s,o,[...k,...m]);de(t,{version:S.version,assets:S.assets.map(d=>({path:d.path,"content-hash":d.contentHash}))}),console.log(`New version ${S.version} successfully created.`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to push assets"),process.exitCode=1;return}}function ue(s){let t=s.command("assets").description("manage marketplace assets");t.command("pull").description("pull assets from remote").requiredOption("--path <PATH>","path to directory where assets will be stored").option("--version <VERSION>","version of assets to pull").option("--prune","delete local files no longer present as remote assets").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Ht(r,e.path,e.version,e.prune)}),t.command("push").description("push assets to remote").requiredOption("--path <PATH>","path to directory with assets").option("--prune","delete remote assets no longer present locally").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Bt(r,e.path,e.prune)})}import{sendNotification as Wt,previewNotification as Gt}from"sharetribe-flex-build-sdk";import{readFileSync as J,existsSync as M,statSync as Qt}from"node:fs";import{join as fe}from"node:path";import{createServer as Yt}from"node:http";function he(s){if(!M(s)||!Qt(s).isDirectory())throw new Error(`Template directory not found: ${s}`);let t=fe(s,"template.html"),e=fe(s,"template-subject.txt");if(!M(t))throw new Error(`template.html not found in ${s}`);if(!M(e))throw new Error(`template-subject.txt not found in ${s}`);let r=J(t,"utf-8"),o=J(e,"utf-8").trim();return{html:r,subject:o}}function ge(s){if(!s)return;if(!M(s))throw new Error(`Context file not found: ${s}`);let t=J(s,"utf-8");try{return JSON.parse(t)}catch(e){throw new Error(`Invalid JSON in context file: ${e}`)}}async function zt(s,t,e){try{let r=he(t),o=ge(e),n=await Wt(void 0,s,{template:r,context:o});console.log(`Preview successfully sent to ${n.adminEmail}`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to send notification"),process.exitCode=1;return}}async function Zt(s,t,e){try{let r=he(t),o=ge(e);console.log(`Template: ${t}`),console.log(`Subject: ${r.subject}`),console.log(""),console.log("Starting preview server at http://localhost:3535"),console.log("Press Ctrl+C to stop"),console.log("");let n=null,i=async()=>{try{let m=(await Gt(void 0,s,{template:r,context:o})).html,u=`<title>${r.subject}</title>`;m.includes("<head>")?n=m.replace("<head>",`<head>
8
- ${u}`):m.includes("<html>")?n=m.replace("<html>",`<html>
9
- <head>${u}</head>`):n=`<html><head>${u}</head><body>${m}</body></html>`}catch(c){n=`
11
+ `)})}function rr(){let t=Se();if(!t?.apiKey)throw new Error("Not logged in. Please provide apiKey or run: sharetribe-community-cli login");return t.apiKey}function sr(t,r){let e=new URL(Ft()+"/assets/pull");return e.searchParams.set("marketplace",t),r?e.searchParams.set("version",r):e.searchParams.set("version-alias","latest"),e}var _=class extends Error{constructor(e){super(`API call failed. Status: ${e.status}`);this.details=e;this.name="AssetsApiError"}details};function or(t){return typeof t=="object"&&t!==null&&"status"in t&&"code"in t}function be(){return Se()?.apiKey??""}async function nr(t,r){let e=sr(t,r),s=rr(),o=e.protocol==="https:",n=o?Jt:Vt;return new Promise((i,a)=>{let p=n.request({method:"GET",hostname:e.hostname,port:e.port||(o?443:80),path:e.pathname+e.search,headers:{Authorization:`Apikey ${s}`,Accept:"application/zip"}},c=>{let d=c.statusCode||0;if(d<200||d>=300){let u=[];c.on("data",h=>u.push(h)),c.on("end",()=>{let h=Buffer.concat(u).toString("utf-8");a(new _(z(h,d)))});return}i(c)});p.setTimeout(12e4,()=>{p.destroy(new Error("Request timeout"))}),p.on("error",a),p.end()})}function ir(){return A(Ht(),`assets-${Date.now()}.zip`)}function ar(t){return t.startsWith(ye)?t.slice(ye.length):t}function cr(t){return new Promise((r,e)=>{let s=[];t.on("data",o=>s.push(o)),t.on("end",()=>r(Buffer.concat(s).toString("utf-8"))),t.on("error",e)})}async function lr(t,r){return new Promise((e,s)=>{Bt.open(t,{lazyEntries:!0},(o,n)=>{if(o||!n){s(o||new Error("Failed to open zip file"));return}let i=null;n.on("error",s),n.on("end",()=>{if(!i){s(new Error("Asset metadata not found in zip"));return}e(i)}),n.readEntry(),n.on("entry",a=>{if(a.fileName.endsWith("/")){n.readEntry();return}n.openReadStream(a,(p,c)=>{if(p||!c){s(p||new Error("Failed to read zip entry"));return}if(a.fileName===Wt){cr(c).then(h=>{if(i=ke(h),!i){s(new Error("Invalid asset metadata"));return}n.readEntry()}).catch(s);return}let d=A(r,ar(a.fileName)),u=Kt(d);k(u)||X(u,{recursive:!0}),ve(c,Ce(d)).then(()=>n.readEntry()).catch(s)})})})})}async function pr(t,r,e,s){try{if(k(r)||X(r,{recursive:!0}),!q(r).isDirectory())throw new Error(`${r} is not a directory`);let n=s?Zt(r):[],i=Pe(r),a=ir();try{let p=await nr(t,e);tr(p),await ve(p,Ce(a));let c=await lr(a,r),d=c.version,u=s?new Set(n.filter(S=>!c.assets.some(m=>m.path===S))):new Set,P=i?.version!==d||u.size>0;if(u.size>0)for(let S of u){let m=A(r,S);k(m)&&he(m)}P?(Ie(r,{version:d,assets:c.assets}),console.log(`Version ${d} successfully pulled.`)):console.log("Assets are up to date.")}finally{k(a)&&he(a)}}catch(o){if(o instanceof _){Z(o.details,t,be()),process.exitCode=1;return}o&&typeof o=="object"&&"message"in o?l(o.message):l("Failed to pull assets"),process.exitCode=1;return}}function dr(t,r){let e=new Map(t.map(s=>[s.path,s["content-hash"]]));return r.filter(s=>{let o=e.get(s.path);return!o||o!==s.hash})}async function mr(t,r,e){try{if(!k(r)||!q(r).isDirectory())throw new Error(`${r} is not a valid directory`);let s=Pe(r),o=s?.version||"nil",n=zt(r);Xt(n);let i=dr(s?.assets||[],n),a=m=>m.toLowerCase().endsWith(".json"),p=i.filter(m=>!a(m.path)),c=new Map(n.map(m=>[m.path,m])),d=[];if(e&&s)for(let m of s.assets)c.has(m.path)||d.push({path:m.path,op:"delete"});if(i.length===0&&d.length===0){console.log("Assets are up to date.");return}if(i.length>0){let m=i.map(g=>g.path).join(", ");console.error(ge.green(`Uploading changed assets: ${m}`))}let h=new Map;if(p.length>0){let m=p.map(g=>g.path).join(", ");console.error(ge.green(`Staging assets: ${m}`));for(let g of p)try{let w=await Nt(void 0,t,g.data,g.path);h.set(g.path,w.stagingId)}catch(w){if(w&&typeof w=="object"&&"code"in w&&w.code==="asset-invalid-content"){let Qe="message"in w?w.message:"The file is missing or uses an unsupported format.";throw new Error(`Failed to stage image ${g.path}: ${Qe}
12
+ Fix the file and rerun assets push to retry staging.`)}throw w}}let P=i.map(m=>{let g=h.get(m.path);return{path:m.path,op:"upsert",...g?{stagingId:g}:{data:m.data,filename:m.path}}}),S=await Lt(void 0,t,o,[...P,...d]);Ie(r,{version:S.version,assets:S.assets.map(m=>({path:m.path,"content-hash":m.contentHash}))}),console.log(`New version ${S.version} successfully created.`)}catch(s){if(or(s)){Z(z(s.body??"",s.status),t,be()),console.log("Assets are up to date.");return}s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to push assets"),process.exitCode=1;return}}function Ee(t,r){let e=[];return t||e.push("--path"),r||e.push("--marketplace"),e}function xe(t){let r=t.command("assets").description("manage marketplace assets");r.command("pull").description("pull assets from remote").option("--path <PATH>","path to directory where assets will be stored").option("--version <VERSION>","version of assets to pull").option("--prune","delete local files no longer present as remote assets").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace,o=Ee(e.path,s);if(o.length>0){F(o),process.exitCode=1;return}await pr(s,e.path,e.version,e.prune)}),r.command("push").description("push assets to remote").option("--path <PATH>","path to directory with assets").option("--prune","delete remote assets no longer present locally").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace,o=Ee(e.path,s);if(o.length>0){F(o),process.exitCode=1;return}await mr(s,e.path,e.prune)})}import{sendNotification as ur,previewNotification as fr}from"sharetribe-flex-build-sdk";import{readFileSync as ee,existsSync as L,statSync as hr}from"node:fs";import{join as Oe}from"node:path";import{createServer as gr}from"node:http";function Re(t){if(!L(t)||!hr(t).isDirectory())throw new Error(`Template directory not found: ${t}`);let r=Oe(t,"template.html"),e=Oe(t,"template-subject.txt");if(!L(r))throw new Error(`template.html not found in ${t}`);if(!L(e))throw new Error(`template-subject.txt not found in ${t}`);let s=ee(r,"utf-8"),o=ee(e,"utf-8").trim();return{html:s,subject:o}}function Te(t){if(!t)return;if(!L(t))throw new Error(`Context file not found: ${t}`);let r=ee(t,"utf-8");try{return JSON.parse(r)}catch(e){throw new Error(`Invalid JSON in context file: ${e}`)}}async function yr(t,r,e){try{let s=Re(r),o=Te(e),n=await ur(void 0,t,{template:s,context:o});console.log(`Preview successfully sent to ${n.adminEmail}`)}catch(s){s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to send notification"),process.exitCode=1;return}}async function Er(t,r,e){try{let s=Re(r),o=Te(e);console.log(`Template: ${r}`),console.log(`Subject: ${s.subject}`),console.log(""),console.log("Starting preview server at http://localhost:3535"),console.log("Press Ctrl+C to stop"),console.log("");let n=null,i=async()=>{try{let d=(await fr(void 0,t,{template:s,context:o})).html,u=`<title>${s.subject}</title>`;d.includes("<head>")?n=d.replace("<head>",`<head>
13
+ ${u}`):d.includes("<html>")?n=d.replace("<html>",`<html>
14
+ <head>${u}</head>`):n=`<html><head>${u}</head><body>${d}</body></html>`}catch(c){n=`
10
15
  <html>
11
16
  <head><title>Error</title></head>
12
17
  <body style="font-family: sans-serif; padding: 20px;">
@@ -14,11 +19,11 @@ ${u}`):m.includes("<html>")?n=m.replace("<html>",`<html>
14
19
  <pre style="background: #f5f5f5; padding: 15px; border-radius: 4px;">${c&&typeof c=="object"&&"message"in c?c.message:"Failed to preview notification"}</pre>
15
20
  </body>
16
21
  </html>
17
- `}};await i();let a=Yt(async(c,m)=>{c.url==="/"||c.url===""?(await i(),m.writeHead(200,{"Content-Type":"text/html"}),m.end(n)):(m.writeHead(404,{"Content-Type":"text/plain"}),m.end("Not Found"))});a.listen(3535,()=>{console.log("Preview server started. Open http://localhost:3535 in your browser.")});let p=()=>{console.log(`
18
- Shutting down preview server...`),a.close(()=>{process.exitCode=0})};process.on("SIGINT",p),process.on("SIGTERM",p)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to preview notification"),process.exitCode=1;return}}function ye(s){let t=s.command("notifications").description("manage email notifications");t.command("preview").description("render a preview of an email template").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Zt(r,e.template,e.context)}),t.command("send").description("send a preview of an email template to the logged in admin").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await zt(r,e.template,e.context)})}import{getListingApprovalStatus as Xt,enableListingApproval as er,disableListingApproval as tr}from"sharetribe-flex-build-sdk";async function rr(s){try{(await Xt(void 0,s)).enabled?console.log(`Listing approvals are enabled in ${s}`):console.log(`Listing approvals are disabled in ${s}`)}catch(t){t&&typeof t=="object"&&"message"in t?l(t.message):l("Failed to get listing approval status"),process.exitCode=1;return}}async function sr(s){try{await er(void 0,s),console.log(`Successfully enabled listing approvals in ${s}`)}catch(t){t&&typeof t=="object"&&"message"in t?l(t.message):l("Failed to enable listing approvals"),process.exitCode=1;return}}async function or(s){try{await tr(void 0,s),console.log(`Successfully disabled listing approvals in ${s}`)}catch(t){t&&typeof t=="object"&&"message"in t?l(t.message):l("Failed to disable listing approvals"),process.exitCode=1;return}}function Ee(s){let t=s.command("listing-approval").description("manage listing approvals (DEPRECATED - use Console instead)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");t.action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await rr(r)}),t.command("enable").description("enable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await sr(r)}),t.command("disable").description("disable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await or(r)})}import{queryEvents as nr,pollEvents as ir}from"sharetribe-flex-build-sdk";function Se(s){if([s.sequenceId!==void 0,s.afterSeqId!==void 0,s.beforeSeqId!==void 0,s.afterTs!==void 0,s.beforeTs!==void 0].filter(Boolean).length>1)throw new Error("Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified");if(s.resourceId&&s.relatedResourceId)throw new Error("Only one of --resource or --related-resource can be specified")}function we(s){try{let t=new Date(s),e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),n=t.toLocaleTimeString("en-US");return`${e}-${r}-${o} ${n}`}catch{return s}}async function ar(s,t){try{Se(t);let e=await nr(void 0,s,{resourceId:t.resourceId,relatedResourceId:t.relatedResourceId,eventTypes:t.eventTypes,sequenceId:t.sequenceId,afterSeqId:t.afterSeqId,beforeSeqId:t.beforeSeqId,afterTs:t.afterTs,beforeTs:t.beforeTs,limit:t.limit});if(e.length===0){console.log("No events found.");return}if(t.json)for(let r of e){let{auditEmails:o,...n}=r;console.log(JSON.stringify(n))}else if(t.jsonPretty)for(let r of e){let{auditEmails:o,...n}=r;console.log(JSON.stringify(n,null,2))}else P(["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"],e.map(r=>{let o=r.auditEmails?.userEmail||r.auditEmails?.adminEmail||"",n=r.source?.replace("source/","")||"";return{"Seq ID":r.sequenceId.toString(),"Resource ID":r.resourceId,"Event type":r.eventType,"Created at local time":we(r.createdAt),Source:n,Actor:o}}))}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to query events"),process.exitCode=1;return}}async function cr(s,t){try{Se(t),console.log("Tailing events... Press Ctrl+C to stop"),console.log("");let e=ir(void 0,s,{resourceId:t.resourceId,relatedResourceId:t.relatedResourceId,eventTypes:t.eventTypes,limit:t.limit||10},o=>{if(t.json)for(let n of o){let{auditEmails:i,...a}=n;console.log(JSON.stringify(a))}else if(t.jsonPretty)for(let n of o){let{auditEmails:i,...a}=n;console.log(JSON.stringify(a,null,2))}else P(["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"],o.map(n=>{let i=n.auditEmails?.userEmail||n.auditEmails?.adminEmail||"",a=n.source?.replace("source/","")||"";return{"Seq ID":n.sequenceId.toString(),"Resource ID":n.resourceId,"Event type":n.eventType,"Created at local time":we(n.createdAt),Source:a,Actor:i}}))},5e3),r=()=>{console.log(`
19
- Stopping tail...`),e(),process.exitCode=0};process.on("SIGINT",r),process.on("SIGTERM",r)}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to tail events"),process.exitCode=1;return}}function Ae(s){let t=s.command("events").description("Get a list of events.").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("--seqid <SEQUENCE_ID>","get event with specific sequence ID",parseInt).option("--after-seqid <SEQUENCE_ID>","show events after sequence ID (exclusive)",parseInt).option("--before-seqid <SEQUENCE_ID>","show events before sequence ID (exclusive)",parseInt).option("--after-ts <TIMESTAMP>","show events after timestamp").option("--before-ts <TIMESTAMP>","show events before timestamp").option("-l, --limit <NUMBER>","limit results (default: 100, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");t.action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exitCode=1;return}await ar(r,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,sequenceId:e.seqid,afterSeqId:e.afterSeqid,beforeSeqId:e.beforeSeqid,afterTs:e.afterTs,beforeTs:e.beforeTs,limit:e.limit||100,json:e.json,jsonPretty:e.jsonPretty})}),t.command("tail").description("Tail events live as they happen").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("-l, --limit <NUMBER>","limit results per poll (default: 10, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exitCode=1;return}await cr(r,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,limit:e.limit||10,json:e.json,jsonPretty:e.jsonPretty})})}import{updateStripeVersion as lr,SUPPORTED_STRIPE_VERSIONS as pr}from"sharetribe-flex-build-sdk";import ve from"inquirer";async function mr(){return(await ve.prompt([{type:"list",name:"version",message:"Select Stripe API version:",choices:[...pr]}])).version}async function dr(){return console.log(""),console.log("WARNING: Changing Stripe API version may affect your integration."),console.log(""),console.log("After updating the Stripe API version, you may need to:"),console.log("- Handle new Capabilities requirements"),console.log("- Update identity verification settings"),console.log(""),console.log("See Stripe documentation for details:"),console.log("https://stripe.com/docs/connect/capabilities-overview"),console.log("https://stripe.com/docs/connect/identity-verification"),console.log(""),(await ve.prompt([{type:"confirm",name:"confirmed",message:"Do you want to continue?",default:!1}])).confirmed}async function ur(s,t,e){try{let r=t;if(r||(r=await mr()),!e&&!await dr()){console.log("Cancelled."),process.exitCode=0;return}await lr(void 0,s,r),console.log(`Stripe API version successfully changed to ${r}`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to update Stripe API version"),process.exitCode=1;return}}function Ce(s){s.command("stripe").description("manage Stripe integration").command("update-version").description("update Stripe API version in use").option("--version <VERSION>","Stripe API version to update to").option("-f, --force","skip confirmation prompt and force update").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let r=e.marketplace||s.opts().marketplace;if(!r){console.error("Error: --marketplace is required"),process.exitCode=1;return}await ur(r,e.version,e.force)})}import{getConfigMap as fr,readAuth as hr}from"sharetribe-flex-build-sdk";function gr(s){return s.length<=4?`...${s}`:`...${s.slice(-4)}`}function ke(){let s=hr(),t=s?.apiKey?gr(s.apiKey):"No API key set",e=fr(),r=Object.keys(e).sort().map(n=>`:${n} ${e[n]}`).join(" "),o=r?`{${r}}`:"{}";console.log(`{:api-key ${t}, :conf-map ${o}}`)}function yr(s){let t=[],e=!s.parent,r=s.description();if(r&&(t.push(r),t.push("")),e){let a=s.version();a&&(t.push("VERSION"),t.push(` ${a}`),t.push(""))}t.push("USAGE");let o=Er(s);t.push(` $ ${o}`),t.push("");let n=Ie(s),i=s.options.length>0&&!e;if(n.length>0&&!i){t.push("COMMANDS");let a=Math.max(...n.map(p=>p.name.length));for(let p of n){let c=p.name.padEnd(a+2);t.push(` ${c}${p.description}`)}t.push("")}if(!e){let a=s.options;if(a.length>0){t.push("OPTIONS");let p=Math.max(...a.map(c=>Pe(c).length));for(let c of a){let u=Pe(c).padEnd(p+2),f=c.description||"";t.push(` ${u}${f}`)}t.push("")}}if(n.length>0&&!i){t.push("Subcommand help:");let a=be(s);t.push(` $ ${a} help [COMMAND]`)}return t.push(""),t.join(`
20
- `)}function Ie(s){let t=[],e=s.commands.filter(r=>!r._hidden&&r.name()!=="help");for(let r of e){let o=Sr(r),n=r.commands.filter(i=>!i._hidden);if(r.description()&&t.push({name:o,description:r.description()||""}),n.length>0){let i=Ie(r);for(let a of i)t.push(a)}}return s.parent||t.unshift({name:"help",description:"display help for Flex CLI"}),t.sort((r,o)=>r.name.localeCompare(o.name)),t}function be(s){let t=[],e=s;for(;e;)e.name()&&t.unshift(e.name()),e=e.parent;return t.length>0&&(t[0]="sharetribe-community-cli"),t.join(" ")}function Er(s){let t=be(s),e=s.commands.filter(n=>!n._hidden),r=s.options.length>0;return!s.parent&&e.length>0?`${t} [COMMAND]`:e.length>0&&!r?`${t} [COMMAND]`:t}function Sr(s){let t=[],e=s;for(;e&&e.parent;)e.name()&&t.unshift(e.name()),e=e.parent;return t.join(" ")}function Pe(s){let e=(s.flags||"").split(/,\s*/),r=[];for(let o of e){let n=o.trim(),i=n.match(/^((?:-{1,2}[\w-]+))\s*[<\[]([^\]>]+)[\]>]/);if(i){let a=i[1],p=i[2];r.push(`${a}=${p}`)}else r.push(n)}return r.join(", ")}function Oe(s){s.configureHelp({formatHelp:(t,e)=>yr(t)})}function xe(s){let t=s.findIndex(o=>o==="process");if(t===-1)return s;let e=s[t+1];return e&&["list","create","push","pull","create-alias","update-alias","delete-alias","deploy"].includes(e)?[...s.slice(0,t),`process-${e}`,...s.slice(t+2)]:s}var Or=Pr(import.meta.url),xr=Ir(Or),Rr=JSON.parse(Ar(De(xr,"../package.json"),"utf-8")),Me=br(),Re=De(Me,".sharetribe-community-cli-notice-shown");if(!vr(Re)){console.error(B.yellow("\u26A0\uFE0F NOTICE: This is an UNOFFICIAL Sharetribe CLI (community reimplementation).")),console.error(B.yellow(" For the official CLI, install: ")+B.cyan("npm install -g flex-cli")+`
21
- `);try{kr(Me,{recursive:!0}),Cr(Re,new Date().toISOString())}catch{}}var Te=xe(process.argv),h=new wr;Oe(h);h.configureOutput({writeOut:s=>process.stdout.write(s+`
22
- `),writeErr:s=>process.stderr.write(s+`
23
- `)});h.name("sharetribe-community-cli").description("CLI to interact with Sharetribe Flex").version(Rr.version,"-V","output the version number").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");h.command("version").description("show version").action(()=>{G()});h.command("login").description("log in with API key").action(async()=>{await Q()});h.command("logout").description("logout").action(async()=>{await Y()});h.command("debug").description("display debug info").action(()=>{ke()});ee(h);re(h);ue(h);ye(h);Ee(h);Ae(h);Ce(h);h.command("help [command...]").description("display help for Flex CLI").action(s=>{if(!s||s.length===0){h.outputHelp();return}let t=h;for(let e of s){let r=t.commands.find(o=>o.name()===e);if(!r){console.error(`Unknown command: ${s.join(" ")}`),process.exitCode=1;return}t=r}t.outputHelp()});Te.slice(2).length?h.parse(Te):h.outputHelp();
22
+ `}};await i();let a=gr(async(c,d)=>{c.url==="/"||c.url===""?(await i(),d.writeHead(200,{"Content-Type":"text/html"}),d.end(n)):(d.writeHead(404,{"Content-Type":"text/plain"}),d.end("Not Found"))});a.listen(3535,()=>{console.log("Preview server started. Open http://localhost:3535 in your browser.")});let p=()=>{console.log(`
23
+ Shutting down preview server...`),a.close(()=>{process.exitCode=0})};process.on("SIGINT",p),process.on("SIGTERM",p)}catch(s){s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to preview notification"),process.exitCode=1;return}}function De(t){let r=t.command("notifications").description("manage email notifications");r.command("preview").description("render a preview of an email template").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Er(s,e.template,e.context)}),r.command("send").description("send a preview of an email template to the logged in admin").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await yr(s,e.template,e.context)})}import{getListingApprovalStatus as Sr,enableListingApproval as Ar,disableListingApproval as wr}from"sharetribe-flex-build-sdk";async function Cr(t){try{(await Sr(void 0,t)).enabled?console.log(`Listing approvals are enabled in ${t}`):console.log(`Listing approvals are disabled in ${t}`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to get listing approval status"),process.exitCode=1;return}}async function vr(t){try{await Ar(void 0,t),console.log(`Successfully enabled listing approvals in ${t}`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to enable listing approvals"),process.exitCode=1;return}}async function kr(t){try{await wr(void 0,t),console.log(`Successfully disabled listing approvals in ${t}`)}catch(r){r&&typeof r=="object"&&"message"in r?l(r.message):l("Failed to disable listing approvals"),process.exitCode=1;return}}function $e(t){let r=t.command("listing-approval").description("manage listing approvals (DEPRECATED - use Console instead)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");r.action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await Cr(s)}),r.command("enable").description("enable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await vr(s)}),r.command("disable").description("disable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await kr(s)})}import{queryEvents as Pr,pollEvents as Ir}from"sharetribe-flex-build-sdk";var te=["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"];function Me(t){if([t.sequenceId!==void 0,t.afterSeqId!==void 0,t.beforeSeqId!==void 0,t.afterTs!==void 0,t.beforeTs!==void 0].filter(Boolean).length>1)throw new Error("Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified");if(t.resourceId&&t.relatedResourceId)throw new Error("Only one of --resource or --related-resource can be specified")}function _e(t){try{let r=new Date(t),e=r.getFullYear(),s=String(r.getMonth()+1).padStart(2,"0"),o=String(r.getDate()).padStart(2,"0"),n=r.toLocaleTimeString("en-US");return`${e}-${s}-${o} ${n}`}catch{return t}}async function br(t,r){try{Me(r);let e=await Pr(void 0,t,{resourceId:r.resourceId,relatedResourceId:r.relatedResourceId,eventTypes:r.eventTypes,sequenceId:r.sequenceId,afterSeqId:r.afterSeqId,beforeSeqId:r.beforeSeqId,afterTs:r.afterTs,beforeTs:r.beforeTs,limit:r.limit});if(r.json)for(let s of e){let{auditEmails:o,...n}=s;console.log(JSON.stringify(n))}else if(r.jsonPretty)for(let s of e){let{auditEmails:o,...n}=s;console.log(JSON.stringify(n,null,2))}else C(te,e.map(s=>{let o=s.auditEmails?.userEmail||s.auditEmails?.adminEmail||"",n=s.source?.replace("source/","")||"";return{"Seq ID":s.sequenceId.toString(),"Resource ID":s.resourceId,"Event type":s.eventType,"Created at local time":_e(s.createdAt),Source:n,Actor:o}}))}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to query events"),process.exitCode=1;return}}async function xr(t,r){try{Me(r),console.log("Tailing events... Press Ctrl+C to stop"),console.log("");let e,s=Ir(void 0,t,{resourceId:r.resourceId,relatedResourceId:r.relatedResourceId,eventTypes:r.eventTypes,limit:r.limit||10},n=>{if(r.json)for(let i of n){let{auditEmails:a,...p}=i;console.log(JSON.stringify(p))}else if(r.jsonPretty)for(let i of n){let{auditEmails:a,...p}=i;console.log(JSON.stringify(p,null,2))}else{let i=n.map(a=>{let p=a.auditEmails?.userEmail||a.auditEmails?.adminEmail||"",c=a.source?.replace("source/","")||"";return{"Seq ID":a.sequenceId.toString(),"Resource ID":a.resourceId,"Event type":a.eventType,"Created at local time":_e(a.createdAt),Source:c,Actor:p}});e?ce(te,e,i):e=C(te,i)}},5e3),o=()=>{console.log(`
24
+ Stopping tail...`),s(),process.exitCode=0};process.on("SIGINT",o),process.on("SIGTERM",o)}catch(e){e&&typeof e=="object"&&"message"in e?l(e.message):l("Failed to tail events"),process.exitCode=1;return}}function qe(t){let r=t.command("events").description("Get a list of events.").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("--seqid <SEQUENCE_ID>","get event with specific sequence ID",parseInt).option("--after-seqid <SEQUENCE_ID>","show events after sequence ID (exclusive)",parseInt).option("--before-seqid <SEQUENCE_ID>","show events before sequence ID (exclusive)",parseInt).option("--after-ts <TIMESTAMP>","show events after timestamp").option("--before-ts <TIMESTAMP>","show events before timestamp").option("-l, --limit <NUMBER>","limit results (default: 100, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");r.action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exitCode=1;return}await br(s,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,sequenceId:e.seqid,afterSeqId:e.afterSeqid,beforeSeqId:e.beforeSeqid,afterTs:e.afterTs,beforeTs:e.beforeTs,limit:e.limit||100,json:e.json,jsonPretty:e.jsonPretty})}),r.command("tail").description("Tail events live as they happen").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("-l, --limit <NUMBER>","limit results per poll (default: 10, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exitCode=1;return}await xr(s,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,limit:e.limit||10,json:e.json,jsonPretty:e.jsonPretty})})}import{updateStripeVersion as Or,SUPPORTED_STRIPE_VERSIONS as Rr}from"sharetribe-flex-build-sdk";import Le from"inquirer";async function Tr(){return(await Le.prompt([{type:"list",name:"version",message:"Select Stripe API version:",choices:[...Rr]}])).version}async function Dr(){return console.log(""),console.log("WARNING: Changing Stripe API version may affect your integration."),console.log(""),console.log("After updating the Stripe API version, you may need to:"),console.log("- Handle new Capabilities requirements"),console.log("- Update identity verification settings"),console.log(""),console.log("See Stripe documentation for details:"),console.log("https://stripe.com/docs/connect/capabilities-overview"),console.log("https://stripe.com/docs/connect/identity-verification"),console.log(""),(await Le.prompt([{type:"confirm",name:"confirmed",message:"Do you want to continue?",default:!1}])).confirmed}async function $r(t,r,e){try{let s=r;if(s||(s=await Tr()),!e&&!await Dr()){console.log("Cancelled."),process.exitCode=0;return}await Or(void 0,t,s),console.log(`Stripe API version successfully changed to ${s}`)}catch(s){s&&typeof s=="object"&&"message"in s?l(s.message):l("Failed to update Stripe API version"),process.exitCode=1;return}}function Ne(t){t.command("stripe").description("manage Stripe integration").command("update-version").description("update Stripe API version in use").option("--version <VERSION>","Stripe API version to update to").option("-f, --force","skip confirmation prompt and force update").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||t.opts().marketplace;if(!s){console.error("Error: --marketplace is required"),process.exitCode=1;return}await $r(s,e.version,e.force)})}import{getConfigMap as Mr,readAuth as _r}from"sharetribe-flex-build-sdk";function qr(t){return t.length<=4?`...${t}`:`...${t.slice(-4)}`}function Fe(){let t=_r(),r=t?.apiKey?qr(t.apiKey):"No API key set",e=Mr(),s=Object.keys(e).sort().map(n=>`:${n} ${e[n]}`).join(" "),o=s?`{${s}}`:"{}";console.log(`{:api-key ${r}, :conf-map ${o}}`)}function Lr(t){let r=[],e=!t.parent,s=t.description();if(s&&(r.push(s),r.push("")),e){let a=t.version();a&&(r.push("VERSION"),r.push(` ${a}`),r.push(""))}r.push("USAGE");let o=Nr(t);r.push(` $ ${o}`),r.push("");let n=Ke(t),i=t.options.length>0&&!e;if(n.length>0&&!i){r.push("COMMANDS");let a=Math.max(...n.map(p=>p.name.length));for(let p of n){let c=p.name.padEnd(a+2);r.push(` ${c}${p.description}`)}r.push("")}if(!e){let a=t.options;if(a.length>0){r.push("OPTIONS");let p=Math.max(...a.map(c=>je(c).length));for(let c of a){let u=je(c).padEnd(p+2),h=c.description||"";r.push(` ${u}${h}`)}r.push("")}}if(n.length>0&&!i){r.push("Subcommand help:");let a=Ue(t);r.push(` $ ${a} help [COMMAND]`)}return r.push(""),r.join(`
25
+ `)}function Ke(t){let r=[],e=t.commands.filter(s=>!s._hidden&&s.name()!=="help");for(let s of e){let o=Fr(s),n=s.commands.filter(i=>!i._hidden);if(s.description()&&r.push({name:o,description:s.description()||""}),n.length>0){let i=Ke(s);for(let a of i)r.push(a)}}return t.parent||r.unshift({name:"help",description:"display help for Flex CLI"}),r.sort((s,o)=>s.name.localeCompare(o.name)),r}function Ue(t){let r=[],e=t;for(;e;)e.name()&&r.unshift(e.name()),e=e.parent;return r.length>0&&(r[0]="sharetribe-community-cli"),r.join(" ")}function Nr(t){let r=Ue(t),e=t.commands.filter(n=>!n._hidden),s=t.options.length>0;return!t.parent&&e.length>0?`${r} [COMMAND]`:e.length>0&&!s?`${r} [COMMAND]`:r}function Fr(t){let r=[],e=t;for(;e&&e.parent;)e.name()&&r.unshift(e.name()),e=e.parent;return r.join(" ")}function je(t){let e=(t.flags||"").split(/,\s*/),s=[];for(let o of e){let n=o.trim(),i=n.match(/^((?:-{1,2}[\w-]+))\s*[<\[]([^\]>]+)[\]>]/);if(i){let a=i[1],p=i[2];s.push(`${a}=${p}`)}else s.push(n)}return s.join(", ")}function Ve(t){t.configureHelp({formatHelp:(r,e)=>Lr(r)})}function Je(t){let r=t.findIndex(o=>o==="process");if(r===-1)return t;let e=t[r+1];return e&&["list","create","push","pull","create-alias","update-alias","delete-alias","deploy"].includes(e)?[...t.slice(0,r),`process-${e}`,...t.slice(r+2)]:t}var Gr=Hr(import.meta.url),Qr=Br(Gr),Yr=JSON.parse(Kr(Be(Qr,"../package.json"),"utf-8")),We=Wr(),He=Be(We,".sharetribe-community-cli-notice-shown");if(!Ur(He)){console.error(re.yellow("\u26A0\uFE0F NOTICE: This is an UNOFFICIAL Sharetribe CLI (community reimplementation).")),console.error(re.yellow(" For the official CLI, install: ")+re.cyan("npm install -g flex-cli")+`
26
+ `);try{Jr(We,{recursive:!0}),Vr(He,new Date().toISOString())}catch{}}var Ge=Je(process.argv),f=new jr;Ve(f);f.configureOutput({writeOut:t=>process.stdout.write(t+`
27
+ `),writeErr:t=>process.stderr.write(t+`
28
+ `)});f.name("sharetribe-community-cli").description("CLI to interact with Sharetribe Flex").version(Yr.version,"-V","output the version number").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");f.command("version").description("show version").action(()=>{ne()});f.command("login").description("log in with API key").action(async()=>{await ie()});f.command("logout").description("logout").action(async()=>{await ae()});f.command("debug").description("display debug info").action(()=>{Fe()});me(f);fe(f);xe(f);De(f);$e(f);qe(f);Ne(f);f.command("help [command...]").description("display help for Flex CLI").action(t=>{if(!t||t.length===0){f.outputHelp();return}let r=f;for(let e of t){let s=r.commands.find(o=>o.name()===e);if(!s){console.error(`Unknown command: ${t.join(" ")}`),process.exitCode=1;return}r=s}r.outputHelp()});var se=Ge.slice(2),zr=se[0]==="assets"&&!["pull","push","help"].includes(se[1]??"");se.length?zr?(console.error("Command not found: assets"),process.exitCode=1):f.parse(Ge):f.outputHelp();
24
29
  //# sourceMappingURL=index.js.map