fleetbo-svro 1.0.19 → 1.0.21

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +21 -22
  2. package/package.json +4 -1
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- var J=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var _=J((le,k)=>{var c=require("fs"),p=require("path"),$=require("https"),{execSync:L}=require("child_process"),A="\x1B[38;2;231;233;237m",D="\x1B[31m",T="\x1B[0m";function f(t){console.log(` ${A}${t}${T}`)}function d(t){console.error(` ${D}${t}${T}`)}function N(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[s,l]=n.slice(2).split("=");s&&l&&(o[s]=l)}}),o}function S(t,o){try{let n=JSON.parse(c.readFileSync(t,"utf8"));return!!(n.dependencies&&n.dependencies[o]||n.devDependencies&&n.devDependencies[o])}catch{return!1}}function U(t,o){if(!S(o,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{L("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch{d("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function B(t){let o=p.join(t,"svro.schema.json");if(c.existsSync(o))return;let n=new Date().toISOString(),s={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};c.writeFileSync(o,JSON.stringify(s,null,2)+`
3
- `),f("\u2192 Created svro.schema.json at project root.")}function M(t){let o=p.join(t,"src");if(!c.existsSync(o))return;let n=p.join(o,"auto-imports.d.ts");if(c.existsSync(n))return;let s=`/* eslint-disable */
2
+ var J=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var _=J((le,k)=>{var a=require("fs"),p=require("path"),$=require("https"),{execSync:L}=require("child_process"),A="\x1B[38;2;231;233;237m",D="\x1B[31m",T="\x1B[0m";function f(t){console.log(` ${A}${t}${T}`)}function d(t){console.error(` ${D}${t}${T}`)}function N(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[s,l]=n.slice(2).split("=");s&&l&&(o[s]=l)}}),o}function E(t,o){try{let n=JSON.parse(a.readFileSync(t,"utf8"));return!!(n.dependencies&&n.dependencies[o]||n.devDependencies&&n.devDependencies[o])}catch{return!1}}function U(t,o){if(!E(o,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{L("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch{d("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function B(t){let o=p.join(t,"svro.schema.json");if(a.existsSync(o))return;let n=new Date().toISOString(),s={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};a.writeFileSync(o,JSON.stringify(s,null,2)+`
3
+ `),f("\u2192 Created svro.schema.json at project root.")}function M(t){let o=p.join(t,"src");if(!a.existsSync(o))return;let n=p.join(o,"auto-imports.d.ts");if(a.existsSync(n))return;let s=`/* eslint-disable */
4
4
  /* prettier-ignore */
5
5
  // @ts-nocheck
6
6
  // Generated by fleetbo-svro setup
@@ -110,16 +110,15 @@ declare module 'svelte/elements' {
110
110
  'fleetbo-reference': FleetboProp;
111
111
  }
112
112
  }
113
- `;try{c.writeFileSync(n,s),f("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(l){d(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${l.message}`)}}function q(t){let o=p.join(t,"index.d.ts");c.existsSync(o)||f("\u2192 Verified index.d.ts presence.")}function V(t){let o=["tsconfig.json","jsconfig.json"];for(let n of o){let s=p.join(t,n);if(c.existsSync(s)){let l=new Date;c.utimesSync(s,l,l);break}}}function H(t){return new Promise((o,n)=>{let s=JSON.stringify({token:t}),l={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},i=$.request(l,e=>{let a="";e.on("data",r=>{a+=r}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{o(JSON.parse(a))}catch{n(new Error("Invalid response received from Fleetbo server."))}else try{let r=JSON.parse(a);n(new Error(r.error||`Server error ${e.statusCode}`))}catch{n(new Error(`Server error ${e.statusCode}`))}})});i.on("error",e=>n(e)),i.write(s),i.end()})}async function W(t,o=[]){let n=p.join(t,".env");if(c.existsSync(n)&&c.readFileSync(n,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let s=N(o),l=s.keyApp,i=s.token||s.bootstrapToken,e=s.email||"";(!l||!i)&&(d("\u26A0\uFE0F Missing required parameters."),d("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),f("\u2192 Exchanging bootstrap token for project keys...");let a;try{a=await H(i)}catch(b){d(`\u26A0\uFE0F Token exchange failed: ${b.message}`),d("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!a.enterpriseId||!a.fleetboDBKey)&&(d("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let r=`
114
- VITE_FLEETBO_DB_KEY=${a.fleetboDBKey}
115
- VITE_FLEETBO_ENTERPRISE_ID=${a.enterpriseId}
113
+ `;try{a.writeFileSync(n,s),f("\u2192 Created src/auto-imports.d.ts stub for instant IDE auto-completion.")}catch(l){d(`\u26A0\uFE0F Unable to create src/auto-imports.d.ts: ${l.message}`)}}function q(t){let o=p.join(t,"index.d.ts");a.existsSync(o)||f("\u2192 Verified index.d.ts presence.")}function V(t){let o=["tsconfig.json","jsconfig.json"];for(let n of o){let s=p.join(t,n);if(a.existsSync(s)){let l=new Date;a.utimesSync(s,l,l);break}}}function H(t){return new Promise((o,n)=>{let s=JSON.stringify({token:t}),l={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=$.request(l,e=>{let i="";e.on("data",r=>{i+=r}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{o(JSON.parse(i))}catch{n(new Error("Invalid response received from Fleetbo server."))}else try{let r=JSON.parse(i);n(new Error(r.error||`Server error ${e.statusCode}`))}catch{n(new Error(`Server error ${e.statusCode}`))}})});b.on("error",e=>n(e)),b.write(s),b.end()})}async function W(t,o=[]){let n=p.join(t,".env");if(a.existsSync(n)&&a.readFileSync(n,"utf8").includes("VITE_FLEETBO_DB_KEY")){f("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let s=N(o),l=s.keyApp,b=s.token||s.bootstrapToken,e=s.email||"";(!l||!b)&&(d("\u26A0\uFE0F Missing required parameters."),d("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),f("\u2192 Exchanging bootstrap token for project keys...");let i;try{i=await H(b)}catch(c){d(`\u26A0\uFE0F Token exchange failed: ${c.message}`),d("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!i.enterpriseId||!i.fleetboDBKey)&&(d("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let r=`
114
+ VITE_FLEETBO_DB_KEY=${i.fleetboDBKey}
115
+ VITE_FLEETBO_ENTERPRISE_ID=${i.enterpriseId}
116
116
  VITE_FLEETBO_KEY_APP=${l}
117
117
  ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
118
- `:""}`;c.appendFileSync(n,r),f(".env file updated successfully with Fleetbo keys!")}function O(t){let o=p.join(t,"svro.d.ts");if(c.existsSync(o))try{c.unlinkSync(o),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function I(t,o){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let n=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),l=c.existsSync(n)?n:s,i=!c.existsSync(l),e={};if(!i)try{e=JSON.parse(c.readFileSync(l,"utf8"))}catch{d(`\u26A0\uFE0F Unable to read ${p.basename(l)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,r=S(o,"react"),b=S(o,"vite");i?(e.compilerOptions.checkJs=!0,e.compilerOptions.allowJs=!0,e.compilerOptions.target=e.compilerOptions.target||"ES2020",e.compilerOptions.module=e.compilerOptions.module||"ESNext",e.compilerOptions.moduleResolution=e.compilerOptions.moduleResolution||"bundler",e.include=e.include||["src"],a=!0):(e.compilerOptions.checkJs===void 0&&(e.compilerOptions.checkJs=!0,a=!0),e.compilerOptions.allowJs===void 0&&(e.compilerOptions.allowJs=!0,a=!0)),r&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",a=!0),b&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],a=!0),a&&(c.writeFileSync(l,JSON.stringify(e,null,2)+`
119
- `),f(`\u2192 Updated ${p.basename(l)}.`))}function j(t){let o=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/main.tsx","src/main.jsx","src/main.ts","src/main.js","src/index.tsx","src/index.jsx","src/index.ts","src/index.js","src/App.tsx","src/App.jsx","src/App.vue","app.vue","src/routes/+layout.svelte","src/routes/+layout.ts","src/main.singletons.ts"];for(let s of o){let l=p.join(t,s);if(c.existsSync(l)){let i=c.readFileSync(l,"utf8");i.includes("fleetbo-svro")||(i.startsWith('"use client"')||i.startsWith("'use client'")?i=i.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
120
- `):i=`import 'fleetbo-svro';
121
- `+i,c.writeFileSync(l,i),f(`\u2192 Injected automatic runtime import into ${s}`));return}}let n=[p.join(t,"index.html"),p.join(t,"public","index.html")];for(let s of n)if(c.existsSync(s)){let l=c.readFileSync(s,"utf8");l.includes("fleetbo-svro")||(l=l.replace("<head>",`<head>
122
- <script type="module">import "fleetbo-svro";</script>`),c.writeFileSync(s,l),f(`\u2192 Injected runtime script into ${p.relative(t,s)}`));return}}function w(t,o){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let s=["vite.config.ts","vite.config.js","vite.config.mjs"].map(r=>p.join(t,r)).find(r=>c.existsSync(r));if(!s)return;let l;try{l=c.readFileSync(s,"utf8")}catch{return}let i="fleetbo-svro",e=l,a=`{
118
+ `:""}`;a.appendFileSync(n,r),f(".env file updated successfully with Fleetbo keys!")}function O(t){let o=p.join(t,"svro.d.ts");if(a.existsSync(o))try{a.unlinkSync(o),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function I(t,o){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let n=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),l=a.existsSync(n)?n:s,b=!a.existsSync(l),e={};if(!b)try{e=JSON.parse(a.readFileSync(l,"utf8"))}catch{d(`\u26A0\uFE0F Unable to read ${p.basename(l)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let i=!1,r=E(o,"react"),c=E(o,"vite");b?(e.compilerOptions.checkJs=!0,e.compilerOptions.allowJs=!0,e.compilerOptions.target=e.compilerOptions.target||"ES2020",e.compilerOptions.module=e.compilerOptions.module||"ESNext",e.compilerOptions.moduleResolution=e.compilerOptions.moduleResolution||"bundler",e.include=e.include||["src"],i=!0):(e.compilerOptions.checkJs===void 0&&(e.compilerOptions.checkJs=!0,i=!0),e.compilerOptions.allowJs===void 0&&(e.compilerOptions.allowJs=!0,i=!0)),r&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",i=!0),c&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],i=!0),i&&(a.writeFileSync(l,JSON.stringify(e,null,2)+`
119
+ `),f(`\u2192 Updated ${p.basename(l)}.`))}function j(t){let o=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/main.tsx","src/main.jsx","src/main.ts","src/main.js","src/index.tsx","src/index.jsx","src/index.ts","src/index.js","src/App.tsx","src/App.jsx","src/App.vue","app.vue","src/routes/+layout.svelte","src/routes/+layout.ts","src/main.singletons.ts"];for(let n of o){let s=p.join(t,n);if(a.existsSync(s)){let l=a.readFileSync(s,"utf8");l.includes("fleetbo-svro")||(l.startsWith('"use client"')||l.startsWith("'use client'")?l=l.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
120
+ `):l=`import 'fleetbo-svro';
121
+ `+l,a.writeFileSync(s,l),f(`\u2192 Injected automatic runtime import into ${n}`));return}}}function w(t,o){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let s=["vite.config.ts","vite.config.js","vite.config.mjs"].map(r=>p.join(t,r)).find(r=>a.existsSync(r));if(!s)return;let l;try{l=a.readFileSync(s,"utf8")}catch{return}let b="fleetbo-svro",e=l,i=`{
123
122
  name: 'fleetbo-auto-runtime',
124
123
  transform(code, id) {
125
124
  if (!id.includes('node_modules') && !code.includes('fleetbo-svro') && /(src[\\\\/](main|index|App|root))\\.(jsx?|tsx?|vue|svelte)/i.test(id)) {
@@ -171,22 +170,22 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
171
170
  watch: {
172
171
  ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
173
172
  }
174
- },`))),!e.includes("unplugin-auto-import")){let r=e.match(/plugins\s*:\s*\[/);if(r){let b=r.index+r[0].length,P=`
173
+ },`))),!e.includes("unplugin-auto-import")){let r=e.match(/plugins\s*:\s*\[/);if(r){let c=r.index+r[0].length,P=`
175
174
  AutoImport({
176
- imports: [{ '${i}': ['Fleetbo'] }],
175
+ imports: [{ '${b}': ['Fleetbo'] }],
177
176
  dts: 'src/auto-imports.d.ts'
178
- }),`;if(e=e.slice(0,b)+P+e.slice(b),!e.includes("import AutoImport")){let h=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
177
+ }),`;if(e=e.slice(0,c)+P+e.slice(c),!e.includes("import AutoImport")){let h=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
179
178
  `;if(h){let m=h.index+h[0].length;e=e.slice(0,m)+`
180
- `+v+e.slice(m)}else e=v+e}}}if(!e.includes("fleetbo-auto-runtime")){let r=e.match(/plugins\s*:\s*\[/);if(r){let b=r.index+r[0].length;e=e.slice(0,b)+`
181
- `+a+e.slice(b),f("\u2192 Configured Fleetbo runtime auto-injection in Vite.")}}if(e!==l)try{c.writeFileSync(s,e),f(`\u2192 Updated ${p.basename(s)} with Watcher, AutoImport and Runtime configuration.`)}catch(r){d(`\u26A0\uFE0F Failed to write to ${p.basename(s)}: ${r.message}`)}try{let r=JSON.parse(c.readFileSync(o,"utf8"));r.devDependencies=r.devDependencies||{},r.devDependencies["unplugin-auto-import"]||(r.devDependencies["unplugin-auto-import"]="^0.18.0",c.writeFileSync(o,JSON.stringify(r,null,2)+`
182
- `),f("\u2192 Added unplugin-auto-import to devDependencies."))}catch(r){d(`\u26A0\uFE0F Failed to update ${p.basename(o)}: ${r.message}`)}}function X(t,o,n={}){let{skipSelfInstall:s=!1}=n,l=p.join(__dirname,"..");s||U(t,o),B(t),q(l),M(t),O(t),I(t,o),w(t,o),j(t)}k.exports={touchTsConfig:V,log:f,logError:d,handleAuthAndEnv:W,detectDependency:S,cleanupLegacyRootDts:O,patchJsOrTsConfig:I,attemptViteAutoImportPatch:w,injectUniversalRuntime:j,runFullSetup:X}});var g=require("fs"),F=require("path"),C=require("https"),{runFullSetup:K,handleAuthAndEnv:G,touchTsConfig:Y,attemptViteAutoImportPatch:z,injectUniversalRuntime:Q}=_(),Z="\x1B[34m",ee="\x1B[31m",R="\x1B[0m";function u(t){console.log(`${Z}${t}${R}`)}function y(t){console.error(`${ee}${t}${R}`)}function te(t,o){return new Promise((n,s)=>{let l=JSON.stringify({enterpriseID:t,schema:o}),i={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l)}},e=C.request(i,a=>{let r="";a.on("data",b=>{r+=b}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?n(JSON.parse(r)):s(new Error(`Edge sync failed with HTTP ${a.statusCode}`))})});e.on("error",a=>s(a)),e.write(l),e.end()})}function oe(t){let o=F.join(t,".env");if(!g.existsSync(o))return{};let n=g.readFileSync(o,"utf8"),s={};return n.split(`
183
- `).forEach(l=>{let[i,...e]=l.split("=");i&&e.length>0&&(s[i.trim()]=e.join("=").trim())}),s}function ne(t){return new Promise((o,n)=>{let s=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),l={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},i=C.request(l,e=>{let a="";e.on("data",r=>{a+=r}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let r=JSON.parse(a);if(r.success&&r.found&&r.module){let b=r.module.code||r.module.mockCode;o(typeof b=="string"?JSON.parse(b):b)}else n(new Error("Schema not found in Fleetbo Cloud."))}catch{n(new Error("Invalid JSON response received from Fleetbo server."))}else n(new Error(`Server error ${e.statusCode}`))})});i.on("error",e=>n(e)),i.write(s),i.end()})}var E=process.argv.slice(2),x=E[0];async function re(){let t=process.cwd(),o=F.join(t,"package.json");if(x==="init"||x==="doctor")u(`
184
- [Fleetbo] Initializing and configuring Fleetbo...`),await G(t,E),K(t,o),u(`
179
+ `+v+e.slice(m)}else e=v+e}}}if(!e.includes("fleetbo-auto-runtime")){let r=e.match(/plugins\s*:\s*\[/);if(r){let c=r.index+r[0].length;e=e.slice(0,c)+`
180
+ `+i+e.slice(c),f("\u2192 Configured Fleetbo runtime auto-injection in Vite.")}}if(e!==l)try{a.writeFileSync(s,e),f(`\u2192 Updated ${p.basename(s)} with Watcher, AutoImport and Runtime configuration.`)}catch(r){d(`\u26A0\uFE0F Failed to write to ${p.basename(s)}: ${r.message}`)}try{let r=JSON.parse(a.readFileSync(o,"utf8"));r.devDependencies=r.devDependencies||{},r.devDependencies["unplugin-auto-import"]||(r.devDependencies["unplugin-auto-import"]="^0.18.0",a.writeFileSync(o,JSON.stringify(r,null,2)+`
181
+ `),f("\u2192 Added unplugin-auto-import to devDependencies."))}catch(r){d(`\u26A0\uFE0F Failed to update ${p.basename(o)}: ${r.message}`)}}function X(t,o,n={}){let{skipSelfInstall:s=!1}=n,l=p.join(__dirname,"..");s||U(t,o),B(t),q(l),M(t),O(t),I(t,o),w(t,o),j(t)}k.exports={touchTsConfig:V,log:f,logError:d,handleAuthAndEnv:W,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:I,attemptViteAutoImportPatch:w,injectUniversalRuntime:j,runFullSetup:X}});var g=require("fs"),F=require("path"),C=require("https"),{runFullSetup:K,handleAuthAndEnv:G,touchTsConfig:Y,attemptViteAutoImportPatch:z,injectUniversalRuntime:Q}=_(),Z="\x1B[34m",ee="\x1B[31m",R="\x1B[0m";function u(t){console.log(`${Z}${t}${R}`)}function y(t){console.error(`${ee}${t}${R}`)}function te(t,o){return new Promise((n,s)=>{let l=JSON.stringify({enterpriseID:t,schema:o}),b={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l)}},e=C.request(b,i=>{let r="";i.on("data",c=>{r+=c}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?n(JSON.parse(r)):s(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});e.on("error",i=>s(i)),e.write(l),e.end()})}function oe(t){let o=F.join(t,".env");if(!g.existsSync(o))return{};let n=g.readFileSync(o,"utf8"),s={};return n.split(`
182
+ `).forEach(l=>{let[b,...e]=l.split("=");b&&e.length>0&&(s[b.trim()]=e.join("=").trim())}),s}function ne(t){return new Promise((o,n)=>{let s=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),l={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=C.request(l,e=>{let i="";e.on("data",r=>{i+=r}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let r=JSON.parse(i);if(r.success&&r.found&&r.module){let c=r.module.code||r.module.mockCode;o(typeof c=="string"?JSON.parse(c):c)}else n(new Error("Schema not found in Fleetbo Cloud."))}catch{n(new Error("Invalid JSON response received from Fleetbo server."))}else n(new Error(`Server error ${e.statusCode}`))})});b.on("error",e=>n(e)),b.write(s),b.end()})}var x=process.argv.slice(2),S=x[0];async function re(){let t=process.cwd(),o=F.join(t,"package.json");if(S==="init"||S==="doctor")u(`
183
+ [Fleetbo] Initializing and configuring Fleetbo...`),await G(t,x),K(t,o),u(`
185
184
  [Fleetbo] Configuration completed successfully!
186
185
  `),u(`
187
186
  Next step:`),u(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
188
- `);else if(x==="sync"){let n=E.includes("--dry-run");u(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let s=F.join(t,"svro.schema.json"),l=F.join(__dirname,".."),i=F.join(l,"index.d.ts"),e=F.join(t,"src","auto-imports.d.ts"),r=oe(t).VITE_FLEETBO_ENTERPRISE_ID;if(r)try{u("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let b=await ne(r);g.writeFileSync(s,JSON.stringify(b,null,2)+`
189
- `),u("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(b){y(`\u26A0\uFE0F Cloud fetch bypassed: ${b.message}. Using local file fallback.`)}else y("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");g.existsSync(s)||(y("Error: svro.schema.json not found."),process.exit(1));try{let b=JSON.parse(g.readFileSync(s,"utf8")),P=Object.keys(b.collections||{});if(r)try{await te(r,b),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){y(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let h=P.length>0?P.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
187
+ `);else if(S==="sync"){let n=x.includes("--dry-run");u(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let s=F.join(t,"svro.schema.json"),l=F.join(__dirname,".."),b=F.join(l,"index.d.ts"),e=F.join(t,"src","auto-imports.d.ts"),r=oe(t).VITE_FLEETBO_ENTERPRISE_ID;if(r)try{u("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ne(r);g.writeFileSync(s,JSON.stringify(c,null,2)+`
188
+ `),u("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(c){y(`\u26A0\uFE0F Cloud fetch bypassed: ${c.message}. Using local file fallback.`)}else y("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");g.existsSync(s)||(y("Error: svro.schema.json not found."),process.exit(1));try{let c=JSON.parse(g.readFileSync(s,"utf8")),P=Object.keys(c.collections||{});if(r)try{await te(r,c),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){y(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let h=P.length>0?P.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
190
189
 
191
190
  export type FleetboTables = ${h};
192
191
 
@@ -391,7 +390,7 @@ declare module 'svelte/elements' {
391
390
  'fleetbo-reference': FleetboProp;
392
391
  }
393
392
  }
394
- `;if(g.writeFileSync(i,v),g.existsSync(F.dirname(e))){let m=`/* eslint-disable */
393
+ `;if(g.writeFileSync(b,v),g.existsSync(F.dirname(e))){let m=`/* eslint-disable */
395
394
  /* prettier-ignore */
396
395
  // @ts-nocheck
397
396
  // Generated by fleetbo-svro \u2014 Updated via fleetbo sync
@@ -501,4 +500,4 @@ declare module 'svelte/elements' {
501
500
  'fleetbo-reference': FleetboProp;
502
501
  }
503
502
  }
504
- `;g.writeFileSync(e,m)}Y(t),z(t,o),Q(t),u(`[Fleetbo] Schema synced successfully (${P.length} collection(s)).`),n&&u("\u2192 [Dry-run] Schema is valid.")}catch(b){y(`Error during synchronization: ${b.message}`),process.exit(1)}}else y('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}re().catch(t=>{y(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
503
+ `;g.writeFileSync(e,m)}Y(t),z(t,o),Q(t),u(`[Fleetbo] Schema synced successfully (${P.length} collection(s)).`),n&&u("\u2192 [Dry-run] Schema is valid.")}catch(c){y(`Error during synchronization: ${c.message}`),process.exit(1)}}else y('Unknown command. Usage: "npx fleetbo-svro init" or "npx fleetbo-svro sync"'),process.exit(1)}re().catch(t=>{y(`Fleetbo CLI Error: ${t.message}`),process.exit(1)});
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "fleetbo-svro",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
+ "exports": {
7
+ ".": "./dist/index.js"
8
+ },
6
9
  "types": "index.d.ts",
7
10
  "bin": {
8
11
  "fleetbo-svro": "./dist/cli.cjs",