commercebuild-cli 0.0.19 → 0.0.20

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
@@ -108,7 +108,7 @@ User ID: ${a?.user?.id}
108
108
  User Email: ${a?.user?.email}
109
109
  Customer: ${a?.user?.customer.customerCode||""} ${a.user?.customer.name||""}`,{padding:1}))}catch(e){t.fail(`${Pe.red(`An error occurred: ${e.message||"An unknown issue was encountered."}`)}
110
110
  Please try logging in again, or contact the administrator if the issue persists.`)}finally{process.exit()}});var Mr=G(require("fs")),Tn=G(require("path"));var eo=G(require("node:path"),1);var D5=G(require("node:process"),1),v5=G(require("node:path"),1),xp=G(require("node:fs"),1),_5=require("node:url");var a1=class{value;next;constructor(e){this.value=e}},Hu=class{#e;#t;#r;constructor(){this.clear()}enqueue(e){let r=new a1(e);this.#e?(this.#t.next=r,this.#t=r):(this.#e=r,this.#t=r),this.#r++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#r--,e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function mp(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new Hu,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(o,u,c)=>{r++;let l=(async()=>o(...c))();u(l);try{await l}catch{}n()},s=(o,u,c)=>{e.enqueue(i.bind(void 0,o,u,c)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},a=(o,...u)=>new Promise(c=>{s(o,c,u)});return Object.defineProperties(a,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),a}var gp=class extends Error{constructor(e){super(),this.value=e}},iae=async(t,e)=>e(await t),sae=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new gp(e[0]);return!1};async function o1(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=mp(r),s=[...t].map(o=>[o,i(iae,o,e)]),a=mp(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(s.map(o=>a(sae,o)))}catch(o){if(o instanceof gp)return o.value;throw o}}var w5={directory:"isDirectory",file:"isFile"};function aae(t){if(!Object.hasOwnProperty.call(w5,t))throw new Error(`Invalid type specified: ${t}`)}var oae=(t,e)=>e[w5[t]](),uae=t=>t instanceof URL?(0,_5.fileURLToPath)(t):t;async function u1(t,{cwd:e=D5.default.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:s}={}){aae(r),e=uae(e);let a=n?xp.promises.stat:xp.promises.lstat;return o1(t,async o=>{try{let u=await a(v5.default.resolve(e,o));return oae(r,u)}catch{return!1}},{concurrency:i,preserveOrder:s})}var E5=require("node:url");function c1(t){return t instanceof URL?(0,E5.fileURLToPath)(t):t}var cae=Symbol("findUpStop");async function lae(t,e={}){let r=eo.default.resolve(c1(e.cwd)??""),{root:n}=eo.default.parse(r),i=eo.default.resolve(r,c1(e.stopAt??n)),s=e.limit??Number.POSITIVE_INFINITY,a=[t].flat(),o=async c=>{if(typeof t!="function")return u1(a,c);let l=await t(c.cwd);return typeof l=="string"?u1([l],c):l},u=[];for(;;){let c=await o({...e,cwd:r});if(c===cae||(c&&u.push(eo.default.resolve(r,c)),r===i||u.length>=s))break;r=eo.default.dirname(r)}return u}async function S5(t,e={}){return(await lae(t,{...e,limit:1}))[0]}var _i="https://australia-southeast1-xm-development.cloudfunctions.net/httpsExtension",F5=(t,e)=>{if(!t)return"- Unknown -";let r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10)-1,i=parseInt(t.substring(6,8),10),s=parseInt(t.substring(8,10),10),a=parseInt(t.substring(10,12),10),o=parseInt(t.substring(12,14),10);return new Date(r,n,i,s,a,o).toISOString().substring(0,19).replace("T"," ")+(e?" - "+e:"")};var fae=async({extensionName:t,description:e})=>{let r=await fetch(`${_i}?action=createExtension`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({extensionName:t,description:e})}),{message:n,data:{extensionId:i}}=await r.json();if(i)return i;throw new Error(n||"Error: Unable to create extension.")};function C5(t,e){Mr.default.existsSync(e)||Mr.default.mkdirSync(e,{recursive:!0});let r=Mr.default.readdirSync(t,{withFileTypes:!0});for(let n of r){let i=Tn.default.join(t,n.name),s=Tn.default.join(e,n.name);n.isDirectory()?C5(i,s):Mr.default.copyFileSync(i,s)}}async function A5(){let t="";try{let e="ext",r=0,n=e;for(;n=`${e}${r||""}`,!!Mr.default.existsSync(Tn.default.join(process.cwd(),n));)r++;let i=await bi.prompt([{type:"input",name:"dirName",message:"Please specify the directory name for the new extension:",validate:function(f){return/^[a-zA-Z0-9-_]+$/.test(f)?!0:"Please enter a valid directory name:"},default:n},{type:"input",name:"extensionName",message:"Please specify the new extension name:",validate:function(f){return/^[a-zA-Z0-9-_ ]+$/.test(f)?!0:"Please enter a valid extension name containing only letters numbers, hyphens (-), underscores (_), and spaces."}},{type:"input",name:"description",message:"Please provide an optional description for the extension (maximum 255 characters):",validate:function(f){return f.length<=100?!0:"Description must be 255 characters or less."}}]),{dirName:s,extensionName:a,description:o}=i;if(!s)throw new Error("A directory name is required. Please provide one.");let u=Tn.default.resolve(process.cwd(),s);if(Mr.default.existsSync(u))throw new Error(`The directory '${s}' already exists. Please choose a different one.`);if(!a)throw new Error("An extension name is required. Please provide one.");let c=await S5("package.json",{cwd:__dirname});if(!c)throw new Error("Pakcage file not found");let l=Tn.default.resolve(Tn.default.dirname(c),"./templates/default");C5(l,u),t=u;let d=await fae({extensionName:a,description:o}),m=JSON.parse(Mr.default.readFileSync(Tn.default.join(l,"commercebuild.json"),"utf-8"));m.id=d,m.name=a,m.description=o,Mr.default.writeFileSync(Tn.default.join(u,"commercebuild.json"),JSON.stringify(m,null,2),"utf-8"),console.log(Pe.green(`New Extension [${d}] has been successfully generated at '${s}'.`))}catch(e){console.error(Pe.red(`Error: ${e.message||"Unknown Iusse"}`)),Mr.default.existsSync(t)&&Mr.default.rmSync(t)}finally{process.exit()}}var DA=G(bA());async function vA(){let t=rn({spinner:"dots"}).start();try{let n=(await(await fetch("https://australia-southeast1-xm-development.cloudfunctions.net/httpsExtension?action=getExtensions&withUploads=1")).json()).data.extensions||[];t.info("Extension List");let i=new DA.default({head:["Extension Name","Unique ID","Current Version"]});for(let s of n){let a=s.uploads?.find(o=>o.id===s.data.uploadId)?.data.status||void 0;i.push([s.data.extensionName,s.id,F5(s.data.uploadId,a)])}console.log(i.toString())}catch(e){t.fail(e.message)}finally{process.exit()}}var Ju=G(require("path")),Ei=G(require("fs")),tO=G(require("os"));var rO=G(eO());async function nO(t,{directory:e,uploadId:r}){r||(r=(await bi.prompt([{type:"input",name:"uploadId",message:"Please enter a specific upload ID, or choose 'latest' for the most recent version, or 'default' for the currently released version.",default:"latest",required:!0,validate:function(a){return["latest","default"].includes(a)||typeof a=="string"?!0:'Please enter "latest", "default", or any valid string.'}}])).uploadId);let n=rn({spinner:"dots"}).start(),i=Ju.default.join(tO.default.tmpdir(),`cb-ext-${Date.now()}.zip`);try{n.info(`Initiating checkout process for ID: ${t}`);let s=e;s||(s=`extension-${t.split("-").shift()}`);let a=Ju.default.resolve(process.cwd(),s);if(n.info(`Designated target directory: ${Pe.blue(s)}`),Ei.default.existsSync(a))throw new Error(`The directory '${s}' already exists. Please choose a different name to avoid overwriting existing files.`);n.info("Downloading and extracting files to the specified directory"),n.start("Processing the files...");let o=await fetch(`${_i}?action=getExtensionUploadZipFile&id=${t}&uploadId=${r||"latest"}`);if(!o.ok)throw new Error(`Failed to fetch the extension upload zip file. HTTP status: ${o.status}`);let u=await o.arrayBuffer(),c=Buffer.from(u);Ei.default.writeFileSync(i,c);let l=new rO.default(i);Ei.default.mkdirSync(a,{recursive:!0}),l.extractAllTo(a,!0),Ei.default.existsSync(Ju.default.join(a,".env"))||Ei.default.writeFileSync(Ju.default.join(a,".env"),"COMMERCEBUILD_STORE_URL=https://mobile.cardemo.commercebuild.com/","utf-8"),n.succeed("The extension has been successfully checked out.")}catch(s){n.fail(`Checkout Failure: ${s.message}`)}finally{Ei.default.existsSync(i)&&Ei.default.rmSync(i),process.exit()}}var Dn=G(require("fs")),dN=G(require("os")),Jt=G(require("path")),hN=G(cN());var lN=1024e4,Hve=[".ts",".tsx","mjs",".js",".jsx",".json",".css"];function Kve(t){return Hve.some(e=>t.endsWith(e))}function fN(t){return t.stats.isFile()&&Kve(t.name)?t:!1}function Yve(t){return new Promise(e=>setTimeout(e,1e3*t))}function bn(){let t=new Date,e=(c,l=2)=>String(c).padStart(l,"0"),r=t.getFullYear(),n=e(t.getMonth()+1),i=e(t.getDate()),s=e(t.getHours()),a=e(t.getMinutes()),o=e(t.getSeconds()),u=e(t.getMilliseconds(),3);return`${r}-${n}-${i} ${s}:${a}:${o}.${u} `}var fw=async(t={})=>{try{let e=await bi.prompt([{type:"input",name:"description",message:"Please provide a description for the commit (maximum 255 characters):",validate:function(l){return l.length<=255?!0:"Description must be 100 characters or less."}}]),{description:r}=e,n=rn({spinner:"dots"}).start(),i=process.cwd(),s=Jt.default.join(i,"commercebuild.json");if(!Dn.default.existsSync(s))throw new Error("Missing commercebuild.json file");let{id:a}=JSON.parse(Dn.default.readFileSync(s,"utf-8"));if(!a||typeof a!="string")throw new Error("Invalid Extension ID in commercebuild.json");n.info("=== PUSH EXTENSION ["+a+"] TO SERVER ==="),n.info(bn()+"Compress the source code");let o=Jt.default.join(dN.default.tmpdir(),"cb-ext-push-archive.zip"),u=Dn.default.createWriteStream(o),c=(0,hN.default)("zip",{zlib:{level:9}});c.pipe(u),c.directory(Jt.default.join(i,"src"),"src",fN),c.file(Jt.default.join(i,"package.json"),{name:"package.json"}),c.file(Jt.default.join(i,"commercebuild.json"),{name:"commercebuild.json"}),Dn.default.existsSync(Jt.default.join(i,"tsconfig.json"))&&c.file(Jt.default.join(i,"tsconfig.json"),{name:"tsconfig.json"}),Dn.default.existsSync(Jt.default.join(i,"config.json"))&&c.file(Jt.default.join(i,"config.json"),{name:"config.json"}),Dn.default.existsSync(Jt.default.join(i,".gitignore"))&&c.file(Jt.default.join(i,".gitignore"),{name:".gitignore"}),Dn.default.existsSync(Jt.default.join(i,".vscode"))&&c.directory(Jt.default.join(i,".vscode"),".vscode",fN),u.on("close",async function(){try{n.succeed(bn()+"Compress the source code - complete"),n.info(bn()+"Upload the source code");let l=c.pointer();if(l>lN)throw Dn.default.rmSync(o),new Error(`The total size of all files (${l} bytes) exceeds the maximum allowed limit (${lN} bytes), upload denied.`);let d=Dn.default.readFileSync(o),m=await fetch(`${_i}?action=commitExtension`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a,file:d.toString("base64"),description:r})});if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);let{message:f,data:{uploadId:p}}=await m.json();if(f)throw new Error(f);if(!p)throw new Error("Unknown Issue - no uploadId");if(n.succeed(bn()+`Upload the source code - complete.
111
- --- UPLOAD ID: ${p} ---`),t.release){n.start(bn()+"Compile and build the source code...");let g=10,x=0,y=!0,w="";for(;y;){x++;try{let b=await fetch(`${_i}?action=getExtensionUpload&id=${a}&uploadId=${p}`),{message:F,data:{data:{status:C}}}=await b.json();if(F)throw new Error(F);if(w!==C?(n.stopAndPersist({symbol:"\u2139",text:bn()+`Check and compile the source code, STATUS: ${C}`}),w=C,n.start(`Build status: ${C} (polling...)`)):n.text=`Build status: ${C} (polling...)`,await Yve(g),!["IDLE","QUEUED","WORKING"].includes(C))if(y=!1,C==="SUCCESS"){let I=await fetch(`${_i}?action=setExtensionUploadId&id=${a}&uploadId=${p}`),{message:O}=await I.json();if(O)throw new Error(O);n.succeed(bn()+"Compile and build the source code complete.")}else n.fail(bn()+"Compile and build the source code failure.");if(x*g>600)throw y=!1,new Error("Processed failure - Timeout.")}catch(b){if(!y)throw new Error(b.message)}}}n.succeed(bn()+"Processed complete"),process.exit()}catch(l){n.fail(bn()+l.message),process.exit(1)}}),c.on("error",function(l){throw console.log("archive error",l),l}),c.finalize()}catch(e){console.error(Pe.red(`Error: ${e.message||"Unknown Iusse"}`)),process.exit(1)}};var zi=new Ys;zi.name("extension").alias("ext").description("commercebuild Extension CLI");zi.command("list").description("show all available extensions").action(async()=>{await vA()});zi.command("create").description("create a new extension").action(async()=>{await A5()});zi.command("clone <extensionId>").option("-d, --directory <directory>","directory name","").option("-u, --uploadId <uploadId>","specify the upload ID","").description("download and prepare an existing extension for local development").action(async(t,e)=>{await nO(t,e)});zi.command("commit").description("save and commit your local changes to the extension repository").action(async()=>{await fw()});zi.command("release").description("publish a new version of the extension").action(async()=>{await fw({release:!0})});var pN="commercebuild-cli",hw="0.0.19",mN="CLI tool for executing commercebuild commands";var Xve=new Ys;Xve.name(pN).description(`${mN}
111
+ --- UPLOAD ID: ${p} ---`),t.release){n.start(bn()+"Compile and build the source code...");let g=10,x=0,y=!0,w="";for(;y;){x++;try{let b=await fetch(`${_i}?action=getExtensionUpload&id=${a}&uploadId=${p}`),{message:F,data:{data:{status:C}}}=await b.json();if(F)throw new Error(F);if(w!==C?(n.stopAndPersist({symbol:"\u2139",text:bn()+`Check and compile the source code, STATUS: ${C}`}),w=C,n.start(`Build status: ${C} (polling...)`)):n.text=`Build status: ${C} (polling...)`,await Yve(g),!["IDLE","QUEUED","WORKING"].includes(C))if(y=!1,C==="SUCCESS"){let I=await fetch(`${_i}?action=setExtensionUploadId&id=${a}&uploadId=${p}`),{message:O}=await I.json();if(O)throw new Error(O);n.succeed(bn()+"Compile and build the source code complete.")}else n.fail(bn()+"Compile and build the source code failure.");if(x*g>600)throw y=!1,new Error("Processed failure - Timeout.")}catch(b){if(!y)throw new Error(b.message)}}}n.succeed(bn()+"Processed complete"),process.exit()}catch(l){n.fail(bn()+l.message),process.exit(1)}}),c.on("error",function(l){throw console.log("archive error",l),l}),c.finalize()}catch(e){console.error(Pe.red(`Error: ${e.message||"Unknown Iusse"}`)),process.exit(1)}};var zi=new Ys;zi.name("extension").alias("ext").description("commercebuild Extension CLI");zi.command("list").description("show all available extensions").action(async()=>{await vA()});zi.command("create").description("create a new extension").action(async()=>{await A5()});zi.command("clone <extensionId>").option("-d, --directory <directory>","directory name","").option("-u, --uploadId <uploadId>","specify the upload ID","").description("download and prepare an existing extension for local development").action(async(t,e)=>{await nO(t,e)});zi.command("commit").description("save and commit your local changes to the extension repository").action(async()=>{await fw()});zi.command("release").description("publish a new version of the extension").action(async()=>{await fw({release:!0})});var pN="commercebuild-cli",hw="0.0.20",mN="CLI tool for executing commercebuild commands";var Xve=new Ys;Xve.name(pN).description(`${mN}
112
112
 
113
113
  Version: ${hw}`).version(hw).addCommand(Ja).addCommand(zi).addHelpText("after",`
114
114
  For more information, see https://docs.commercebuild.com/cli`).parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commercebuild-cli",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "CLI tool for executing commercebuild commands",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -10,12 +10,6 @@
10
10
  "dist",
11
11
  "templates"
12
12
  ],
13
- "scripts": {
14
- "build": "esbuild src/index.ts --bundle --platform=node --target=node22 --outfile=dist/index.js --format=cjs --minify",
15
- "dev": "tsx watch src/index.ts",
16
- "start": "tsx src/index.ts",
17
- "prepublishOnly": "pnpm run build"
18
- },
19
13
  "devDependencies": {
20
14
  "@commercebuild/platform-api": "^0.11.33",
21
15
  "@types/adm-zip": "^0.5.7",
@@ -35,6 +29,13 @@
35
29
  "ora": "^8.2.0",
36
30
  "tsx": "^4.20.3",
37
31
  "typescript": "^5.8.2",
38
- "uuid": "^11.1.0"
32
+ "uuid": "^11.1.0",
33
+ "@commercebuild/extension": "0.0.18"
34
+ },
35
+ "scripts": {
36
+ "build": "esbuild src/index.ts --bundle --platform=node --target=node22 --outfile=dist/index.js --format=cjs --minify",
37
+ "dev": "tsx watch src/index.ts",
38
+ "start": "tsx src/index.ts",
39
+ "release": "npm whoami || npm login && pnpm publish --no-git-checks"
39
40
  }
40
- }
41
+ }
@@ -1,3 +1,3 @@
1
1
  import "./styles/index.css";
2
- export * as components from "./components";
2
+ export * as components from "./cms";
3
3
  export * as pages from "./pages";
@@ -3,9 +3,13 @@
3
3
  Tailwind preflight and a themed :root. Reference the theme (resolve
4
4
  tokens, emit nothing) and import only the utilities layer, so the build
5
5
  never injects a page-wide reset or :root theme that would clobber the
6
- store. Add custom styles below. */
6
+ store. The @source lines scope the utility scan to this bundle's own
7
+ code — the optional admin area (src/admin/) compiles to a separate
8
+ stylesheet with its own scan. Add custom styles below. */
7
9
  @reference "tailwindcss/theme.css";
8
- @import "tailwindcss/utilities.css" layer(utilities);
10
+ @import "tailwindcss/utilities.css" layer(utilities) source(none);
9
11
  @config "@commercebuild/extension/config/tailwind.config.js";
12
+ @source "../";
13
+ @source not "../admin";
10
14
 
11
15
  /* === Write custom styles below === */