fleetbo-svro 1.0.32 → 1.0.33

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 +8 -8
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- var V=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var $=V((he,N)=>{var i=require("fs"),p=require("path"),q=require("https"),{execSync:W}=require("child_process"),H="\x1B[38;2;231;233;237m",K="\x1B[31m",w="\x1B[0m";function f(t){console.log(` ${H}${t}${w}`)}function d(t){console.error(` ${K}${t}${w}`)}function Y(t){let n={};return t.forEach(o=>{if(o.startsWith("--")){let[s,r]=o.slice(2).split("=");s&&r&&(n[s]=r)}}),n}function O(t,n){try{let o=JSON.parse(i.readFileSync(t,"utf8"));return!!(o.dependencies&&o.dependencies[n]||o.devDependencies&&o.devDependencies[n])}catch{return!1}}function X(t,n){try{return i.existsSync(p.join(t,"node_modules",n,"package.json"))}catch{return!1}}function z(t,n){if(i.existsSync(p.join(t,"pnpm-lock.yaml")))return"pnpm";if(i.existsSync(p.join(t,"yarn.lock")))return"yarn";if(i.existsSync(p.join(t,"bun.lockb")))return"bun";try{let o=JSON.parse(i.readFileSync(n,"utf8"));if(typeof o.packageManager=="string"){if(o.packageManager.startsWith("pnpm"))return"pnpm";if(o.packageManager.startsWith("yarn"))return"yarn";if(o.packageManager.startsWith("bun"))return"bun"}}catch{}return"npm"}function G(t,n){if(!O(n,"fleetbo-svro")||!X(t,"fleetbo-svro")){let o=z(t,n),s={pnpm:"pnpm add fleetbo-svro",yarn:"yarn add fleetbo-svro",bun:"bun add fleetbo-svro",npm:"npm install fleetbo-svro"}[o];f(`\u2192 Installing fleetbo-svro into the project (detected: ${o})...`);try{W(s,{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch(r){d(`\u26A0\uFE0F Automatic installation failed: ${r.message}`),d(`\u{1F449} Please run '${s}' manually.`)}}}function Q(t){let n=p.join(t,"svro.schema.json");if(i.existsSync(n))return;let o=new Date().toISOString(),s={createdAt:o,patchedAt:o,schemaVersion:1,collections:{}};i.writeFileSync(n,JSON.stringify(s,null,2)+`
2
+ var V=(t,n)=>()=>{try{return n||t((n={exports:{}}).exports,n),n.exports}catch(o){throw n=0,o}};var N=V((he,$)=>{var i=require("fs"),p=require("path"),q=require("https"),{execSync:W}=require("child_process"),H="\x1B[38;2;231;233;237m",K="\x1B[31m",j="\x1B[0m";function f(t){console.log(` ${H}${t}${j}`)}function d(t){console.error(` ${K}${t}${j}`)}function Y(t){let n={};return t.forEach(o=>{if(o.startsWith("--")){let[s,r]=o.slice(2).split("=");s&&r&&(n[s]=r)}}),n}function O(t,n){try{let o=JSON.parse(i.readFileSync(t,"utf8"));return!!(o.dependencies&&o.dependencies[n]||o.devDependencies&&o.devDependencies[n])}catch{return!1}}function X(t,n){try{return i.existsSync(p.join(t,"node_modules",n,"package.json"))}catch{return!1}}function z(t,n){if(i.existsSync(p.join(t,"pnpm-lock.yaml")))return"pnpm";if(i.existsSync(p.join(t,"yarn.lock")))return"yarn";if(i.existsSync(p.join(t,"bun.lockb")))return"bun";try{let o=JSON.parse(i.readFileSync(n,"utf8"));if(typeof o.packageManager=="string"){if(o.packageManager.startsWith("pnpm"))return"pnpm";if(o.packageManager.startsWith("yarn"))return"yarn";if(o.packageManager.startsWith("bun"))return"bun"}}catch{}return"npm"}function G(t,n){if(!O(n,"fleetbo-svro")||!X(t,"fleetbo-svro")){let o=z(t,n),s={pnpm:"pnpm add fleetbo-svro",yarn:"yarn add fleetbo-svro",bun:"bun add fleetbo-svro",npm:"npm install fleetbo-svro"}[o];f(`\u2192 Installing fleetbo-svro into the project (detected: ${o})...`);try{W(s,{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch(r){d(`\u26A0\uFE0F Automatic installation failed: ${r.message}`),d(`\u{1F449} Please run '${s}' manually.`)}}}function Q(t){let n=p.join(t,"svro.schema.json");if(i.existsSync(n))return;let o=new Date().toISOString(),s={createdAt:o,patchedAt:o,schemaVersion:1,collections:{}};i.writeFileSync(n,JSON.stringify(s,null,2)+`
3
3
  `),f("\u2192 Created svro.schema.json at project root.")}function Z(t){let n=p.join(t,".env"),o=`
4
- # Fleetbo Sandbox / Prototype Mode
5
- # true = BDD verrouill\xE9e, z\xE9ro crash, IDE alerte en Cyan
6
- # false = Mode strict production (sanction imm\xE9diate HTTP 422 si non scell\xE9, \xE9criture BDD)
4
+ # Fleetbo UI Sandbox Mode
5
+ # true = Sandbox mode: simulates writes locally for fluid UI testing; no DB access and IDE alert.
6
+ # false = Strict production mode: enforces schema contracts and persists to DB
7
7
  VITE_FLEETBO_PROTOTYPE=true
8
8
  `;if(!i.existsSync(n))i.writeFileSync(n,o.trimStart()),f("\u2192 Created .env with VITE_FLEETBO_PROTOTYPE=true");else{let s=i.readFileSync(n,"utf8");!s.includes("VITE_FLEETBO_PROTOTYPE")&&!s.includes("FLEETBO_PROTOTYPE")&&(i.appendFileSync(n,o),f("\u2192 Injected VITE_FLEETBO_PROTOTYPE=true into existing .env"))}}function ee(t){let n=p.join(t,"src");if(!i.existsSync(n))return;let o=p.join(n,"fleetbo.d.ts");if(i.existsSync(o))return;let s=`/* eslint-disable */
9
9
  /* prettier-ignore */
@@ -94,7 +94,7 @@ VITE_FLEETBO_DB_KEY=${a.fleetboDBKey}
94
94
  VITE_FLEETBO_ENTERPRISE_ID=${a.enterpriseId}
95
95
  VITE_FLEETBO_KEY_APP=${r}
96
96
  ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
97
- `:""}`;i.appendFileSync(o,l),f(".env file updated successfully with Fleetbo keys!")}function _(t){let n=p.join(t,"svro.d.ts");if(i.existsSync(n))try{i.unlinkSync(n),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function C(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let o=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),r=i.existsSync(o)?o:s,b=!i.existsSync(r),e={};if(!b)try{e=JSON.parse(i.readFileSync(r,"utf8"))}catch{d(`\u26A0\uFE0F Unable to read ${p.basename(r)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,l=O(n,"react");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=["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)),l&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",a=!0),a&&(i.writeFileSync(r,JSON.stringify(e,null,2)+`
97
+ `:""}`;i.appendFileSync(o,l),f(".env file updated successfully with Fleetbo keys!")}function _(t){let n=p.join(t,"svro.d.ts");if(i.existsSync(n))try{i.unlinkSync(n),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function C(t,n){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let o=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),r=i.existsSync(o)?o:s,b=!i.existsSync(r),e={};if(!b)try{e=JSON.parse(i.readFileSync(r,"utf8"))}catch{d(`\u26A0\uFE0F Unable to read ${p.basename(r)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,l=O(n,"react");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=["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)),l&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",a=!0),Array.isArray(e.compilerOptions.types)&&e.compilerOptions.types.includes("vite/client")&&(e.compilerOptions.types=e.compilerOptions.types.filter(c=>c!=="vite/client"),e.compilerOptions.types.length===0&&delete e.compilerOptions.types,a=!0,f(`\u2192 Removed legacy "vite/client" entry from ${p.basename(r)}.`)),a&&(i.writeFileSync(r,JSON.stringify(e,null,2)+`
98
98
  `),f(`\u2192 Updated ${p.basename(r)}.`))}function R(t){let n=["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 o of n){let s=p.join(t,o);if(i.existsSync(s)){let r=i.readFileSync(s,"utf8");r.includes("fleetbo-svro")||(r.startsWith('"use client"')||r.startsWith("'use client'")?r=r.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
99
99
  `):r=`import 'fleetbo-svro';
100
100
  `+r,i.writeFileSync(s,r));return}}}function L(t,n){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let s=["vite.config.ts","vite.config.js","vite.config.mjs"].map(l=>p.join(t,l)).find(l=>i.existsSync(l));if(!s)return;let r;try{r=i.readFileSync(s,"utf8")}catch{return}let b="fleetbo-svro",e=r,a=`{
@@ -157,14 +157,14 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
157
157
  `;if(T){let E=T.index+T[0].length;e=e.slice(0,E)+`
158
158
  `+S+e.slice(E)}else e=S+e}}}if(!e.includes("fleetbo-auto-runtime")){let l=e.match(/plugins\s*:\s*\[/);if(l){let c=l.index+l[0].length;e=e.slice(0,c)+`
159
159
  `+a+e.slice(c)}}e!==r&&i.writeFileSync(s,e)}function re(t){let n=p.join(t,".vscode"),o=p.join(n,"settings.json");try{i.existsSync(n)||i.mkdirSync(n,{recursive:!0});let s={};if(i.existsSync(o))try{s=JSON.parse(i.readFileSync(o,"utf8"))}catch{s={}}s["workbench.colorCustomizations"]=s["workbench.colorCustomizations"]||{},s["workbench.colorCustomizations"]["editorInfo.foreground"]="#00feae",s["workbench.colorCustomizations"]["editorHint.foreground"]="#00feae",i.writeFileSync(o,JSON.stringify(s,null,2)+`
160
- `),f("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function le(t,n,o={}){let{skipSelfInstall:s=!1}=o,r=p.join(__dirname,"..");s||G(t,n),Q(t),Z(t),te(r),ee(t),re(t),_(t),C(t,n),L(t,n),R(t)}N.exports={touchTsConfig:oe,log:f,logError:d,handleAuthAndEnv:se,detectDependency:O,cleanupLegacyRootDts:_,patchJsOrTsConfig:C,attemptViteAutoImportPatch:L,injectUniversalRuntime:R,runFullSetup:le}});var m=require("fs"),y=require("path"),D=require("https"),{runFullSetup:ie,handleAuthAndEnv:ae,touchTsConfig:ce,attemptViteAutoImportPatch:be,injectUniversalRuntime:pe}=$(),fe="\x1B[34m",de="\x1B[31m",J="\x1B[0m";function u(t){console.log(`${fe}${t}${J}`)}function h(t){console.error(`${de}${t}${J}`)}function ue(t,n){return new Promise((o,s)=>{let r=JSON.stringify({enterpriseID:t,schema:n}),b={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},e=D.request(b,a=>{let l="";a.on("data",c=>{l+=c}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?o(JSON.parse(l)):s(new Error(`Edge sync failed with HTTP ${a.statusCode}`))})});e.on("error",a=>s(a)),e.write(r),e.end()})}function me(t){let n=y.join(t,".env");if(!m.existsSync(n))return{};let o=m.readFileSync(n,"utf8"),s={};return o.split(`
161
- `).forEach(r=>{let[b,...e]=r.split("=");b&&e.length>0&&(s[b.trim()]=e.join("=").trim())}),s}function ge(t){return new Promise((n,o)=>{let s=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),r={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=D.request(r,e=>{let a="";e.on("data",l=>{a+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(a);if(l.success&&l.found&&l.module){let c=l.module.code||l.module.mockCode;n(typeof c=="string"?JSON.parse(c):c)}else o(new Error("Schema not found in Fleetbo Cloud."))}catch{o(new Error("Invalid JSON response received from Fleetbo server."))}else o(new Error(`Server error ${e.statusCode}`))})});b.on("error",e=>o(e)),b.write(s),b.end()})}var k=process.argv.slice(2),I=k[0];async function Fe(){let t=process.cwd(),n=y.join(t,"package.json");if(I==="init"||I==="doctor")u(`
160
+ `),f("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function le(t,n,o={}){let{skipSelfInstall:s=!1}=o,r=p.join(__dirname,"..");s||G(t,n),Q(t),Z(t),te(r),ee(t),re(t),_(t),C(t,n),L(t,n),R(t)}$.exports={touchTsConfig:oe,log:f,logError:d,handleAuthAndEnv:se,detectDependency:O,cleanupLegacyRootDts:_,patchJsOrTsConfig:C,attemptViteAutoImportPatch:L,injectUniversalRuntime:R,runFullSetup:le}});var m=require("fs"),y=require("path"),J=require("https"),{runFullSetup:ie,handleAuthAndEnv:ae,touchTsConfig:ce,attemptViteAutoImportPatch:be,injectUniversalRuntime:pe}=N(),fe="\x1B[34m",de="\x1B[31m",D="\x1B[0m";function u(t){console.log(`${fe}${t}${D}`)}function h(t){console.error(`${de}${t}${D}`)}function ue(t,n){return new Promise((o,s)=>{let r=JSON.stringify({enterpriseID:t,schema:n}),b={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},e=J.request(b,a=>{let l="";a.on("data",c=>{l+=c}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?o(JSON.parse(l)):s(new Error(`Edge sync failed with HTTP ${a.statusCode}`))})});e.on("error",a=>s(a)),e.write(r),e.end()})}function me(t){let n=y.join(t,".env");if(!m.existsSync(n))return{};let o=m.readFileSync(n,"utf8"),s={};return o.split(`
161
+ `).forEach(r=>{let[b,...e]=r.split("=");b&&e.length>0&&(s[b.trim()]=e.join("=").trim())}),s}function ge(t){return new Promise((n,o)=>{let s=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),r={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},b=J.request(r,e=>{let a="";e.on("data",l=>{a+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(a);if(l.success&&l.found&&l.module){let c=l.module.code||l.module.mockCode;n(typeof c=="string"?JSON.parse(c):c)}else o(new Error("Schema not found in Fleetbo Cloud."))}catch{o(new Error("Invalid JSON response received from Fleetbo server."))}else o(new Error(`Server error ${e.statusCode}`))})});b.on("error",e=>o(e)),b.write(s),b.end()})}var k=process.argv.slice(2),I=k[0];async function Fe(){let t=process.cwd(),n=y.join(t,"package.json");if(I==="init"||I==="doctor")u(`
162
162
  [Fleetbo] Initializing and configuring Fleetbo...`),await ae(t,k),ie(t,n),u(`
163
163
  [Fleetbo] Configuration completed successfully!
164
164
  `),u(`
165
165
  Next step:`),u(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
166
166
  `);else if(I==="sync"){let o=k.includes("--dry-run");u(`[Fleetbo] Syncing schema...${o?" (dry-run)":""}`);let s=y.join(t,"svro.schema.json"),r=y.join(__dirname,".."),b=y.join(r,"index.d.ts"),e=y.join(t,"src","fleetbo.d.ts"),l=me(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{u("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ge(l);m.writeFileSync(s,JSON.stringify(c,null,2)+`
167
- `),u("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(c){h(`\u26A0\uFE0F Cloud fetch bypassed: ${c.message}. Using local file fallback.`)}else h("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");m.existsSync(s)||(h("Error: svro.schema.json not found."),process.exit(1));try{let c=JSON.parse(m.readFileSync(s,"utf8")),P=Object.keys(c.collections||{});if(l)try{await ue(l,c),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(g){h(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${g.message}`)}let T=c.collections||{},S=Object.entries(T).map(([g,j])=>{let M=j.fields||j.schema||{},B=Object.entries(M).map(([U,v])=>{let x="any",F=String(typeof v=="string"?v:v.type||"").toLowerCase();return F==="string"||F==="text"||F==="media"?x="string":F==="number"?x="number":F==="boolean"||F==="toggle"?x="boolean":F==="array"&&(x="any[]"),` ${U}?: ${x};`}).join(`
167
+ `),u("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(c){h(`\u26A0\uFE0F Cloud fetch bypassed: ${c.message}. Using local file fallback.`)}else h("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");m.existsSync(s)||(h("Error: svro.schema.json not found."),process.exit(1));try{let c=JSON.parse(m.readFileSync(s,"utf8")),P=Object.keys(c.collections||{});if(l)try{await ue(l,c),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(g){h(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${g.message}`)}let T=c.collections||{},S=Object.entries(T).map(([g,w])=>{let U=w.fields||w.schema||{},B=Object.entries(U).map(([M,x])=>{let v="any",F=String(typeof x=="string"?x:x.type||"").toLowerCase();return F==="string"||F==="text"||F==="media"?v="string":F==="number"?v="number":F==="boolean"||F==="toggle"?v="boolean":F==="array"&&(v="any[]"),` ${M}?: ${v};`}).join(`
168
168
  `);return` ${g}: {
169
169
  ${B}
170
170
  };`}).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-svro",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "exports": {