fleetbo-svro 1.0.30 → 1.0.31
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/cli.cjs +9 -9
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var V=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var N=V((Fe,D)=>{var i=require("fs"),p=require("path"),q=require("https"),{execSync:H}=require("child_process"),K="\x1B[38;2;231;233;237m",W="\x1B[31m",_="\x1B[0m";function f(t){console.log(` ${K}${t}${_}`)}function u(t){console.error(` ${W}${t}${_}`)}function Y(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[s,r]=n.slice(2).split("=");s&&r&&(o[s]=r)}}),o}function
|
|
2
|
+
var V=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var N=V((Fe,D)=>{var i=require("fs"),p=require("path"),q=require("https"),{execSync:H}=require("child_process"),K="\x1B[38;2;231;233;237m",W="\x1B[31m",_="\x1B[0m";function f(t){console.log(` ${K}${t}${_}`)}function u(t){console.error(` ${W}${t}${_}`)}function Y(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[s,r]=n.slice(2).split("=");s&&r&&(o[s]=r)}}),o}function O(t,o){try{let n=JSON.parse(i.readFileSync(t,"utf8"));return!!(n.dependencies&&n.dependencies[o]||n.devDependencies&&n.devDependencies[o])}catch{return!1}}function X(t,o){if(!O(o,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{H("npm install fleetbo-svro",{cwd:t,stdio:"inherit"}),f("fleetbo-svro installed successfully!")}catch{u("\u26A0\uFE0F Automatic installation failed. Please run 'npm install fleetbo-svro' manually.")}}}function z(t){let o=p.join(t,"svro.schema.json");if(i.existsSync(o))return;let n=new Date().toISOString(),s={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};i.writeFileSync(o,JSON.stringify(s,null,2)+`
|
|
3
3
|
`),f("\u2192 Created svro.schema.json at project root.")}function G(t){let o=p.join(t,".env"),n=`
|
|
4
4
|
# Fleetbo Sandbox / Prototype Mode
|
|
5
5
|
# true = BDD verrouill\xE9e, z\xE9ro crash, IDE alerte en Cyan
|
|
@@ -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(n,l),f(".env file updated successfully with Fleetbo keys!")}function k(t){let o=p.join(t,"svro.d.ts");if(i.existsSync(o))try{i.unlinkSync(o),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function C(t,o){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let n=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),r=i.existsSync(n)?n:s,b=!i.existsSync(r),e={};if(!b)try{e=JSON.parse(i.readFileSync(r,"utf8"))}catch{u(`\u26A0\uFE0F Unable to read ${p.basename(r)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,l=
|
|
97
|
+
`:""}`;i.appendFileSync(n,l),f(".env file updated successfully with Fleetbo keys!")}function k(t){let o=p.join(t,"svro.d.ts");if(i.existsSync(o))try{i.unlinkSync(o),f("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function C(t,o){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let n=p.join(t,"tsconfig.json"),s=p.join(t,"jsconfig.json"),r=i.existsSync(n)?n:s,b=!i.existsSync(r),e={};if(!b)try{e=JSON.parse(i.readFileSync(r,"utf8"))}catch{u(`\u26A0\uFE0F Unable to read ${p.basename(r)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let a=!1,l=O(o,"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)+`
|
|
98
98
|
`),f(`\u2192 Updated ${p.basename(r)}.`))}function R(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(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,o){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=`{
|
|
@@ -154,27 +154,27 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
|
154
154
|
imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }],
|
|
155
155
|
dts: 'src/auto-imports.d.ts'
|
|
156
156
|
}),`;if(e=e.slice(0,c)+P+e.slice(c),!e.includes("import AutoImport")){let T=[...e.matchAll(/^import .+;?$/gm)].pop(),E=`import AutoImport from 'unplugin-auto-import/vite';
|
|
157
|
-
`;if(T){let
|
|
158
|
-
`+E+e.slice(
|
|
157
|
+
`;if(T){let S=T.index+T[0].length;e=e.slice(0,S)+`
|
|
158
|
+
`+E+e.slice(S)}else e=E+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 ne(t){let o=p.join(t,".vscode"),n=p.join(o,"settings.json");try{i.existsSync(o)||i.mkdirSync(o,{recursive:!0});let s={};if(i.existsSync(n))try{s=JSON.parse(i.readFileSync(n,"utf8"))}catch{s={}}s["workbench.colorCustomizations"]=s["workbench.colorCustomizations"]||{},s["workbench.colorCustomizations"]["editorInfo.foreground"]="#00feae",s["workbench.colorCustomizations"]["editorHint.foreground"]="#00feae",i.writeFileSync(n,JSON.stringify(s,null,2)+`
|
|
160
|
-
`),f("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function se(t,o,n={}){let{skipSelfInstall:s=!1}=n,r=p.join(__dirname,"..");s||X(t,o),z(t),G(t),Z(r),Q(t),ne(t),k(t),C(t,o),L(t,o),R(t)}D.exports={touchTsConfig:ee,log:f,logError:u,handleAuthAndEnv:oe,detectDependency:
|
|
160
|
+
`),f("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function se(t,o,n={}){let{skipSelfInstall:s=!1}=n,r=p.join(__dirname,"..");s||X(t,o),z(t),G(t),Z(r),Q(t),ne(t),k(t),C(t,o),L(t,o),R(t)}D.exports={touchTsConfig:ee,log:f,logError:u,handleAuthAndEnv:oe,detectDependency:O,cleanupLegacyRootDts:k,patchJsOrTsConfig:C,attemptViteAutoImportPatch:L,injectUniversalRuntime:R,runFullSetup:se}});var m=require("fs"),y=require("path"),J=require("https"),{runFullSetup:re,handleAuthAndEnv:le,touchTsConfig:ie,attemptViteAutoImportPatch:ae,injectUniversalRuntime:ce}=N(),be="\x1B[34m",pe="\x1B[31m",$="\x1B[0m";function d(t){console.log(`${be}${t}${$}`)}function h(t){console.error(`${pe}${t}${$}`)}function fe(t,o){return new Promise((n,s)=>{let r=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(r)}},e=J.request(b,a=>{let l="";a.on("data",c=>{l+=c}),a.on("end",()=>{a.statusCode>=200&&a.statusCode<300?n(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 de(t){let o=y.join(t,".env");if(!m.existsSync(o))return{};let n=m.readFileSync(o,"utf8"),s={};return n.split(`
|
|
161
161
|
`).forEach(r=>{let[b,...e]=r.split("=");b&&e.length>0&&(s[b.trim()]=e.join("=").trim())}),s}function ue(t){return new Promise((o,n)=>{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;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 w=process.argv.slice(2),I=w[0];async function me(){let t=process.cwd(),o=y.join(t,"package.json");if(I==="init"||I==="doctor")d(`
|
|
162
162
|
[Fleetbo] Initializing and configuring Fleetbo...`),await le(t,w),re(t,o),d(`
|
|
163
163
|
[Fleetbo] Configuration completed successfully!
|
|
164
164
|
`),d(`
|
|
165
165
|
Next step:`),d(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
|
|
166
166
|
`);else if(I==="sync"){let n=w.includes("--dry-run");d(`[Fleetbo] Syncing schema...${n?" (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=de(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{d("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let c=await ue(l);m.writeFileSync(s,JSON.stringify(c,null,2)+`
|
|
167
|
-
`),d("\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 fe(l,c),d("\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||{},E=Object.entries(T).map(([g,j])=>{let B=j.fields||j.schema||{},U=Object.entries(B).map(([M,
|
|
167
|
+
`),d("\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 fe(l,c),d("\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||{},E=Object.entries(T).map(([g,j])=>{let B=j.fields||j.schema||{},U=Object.entries(B).map(([M,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[]"),` ${M}?: ${x};`}).join(`
|
|
168
168
|
`);return` ${g}: {
|
|
169
169
|
${U}
|
|
170
170
|
};`}).join(`
|
|
171
|
-
`),
|
|
171
|
+
`),S=P.length>0?P.map(g=>`'${g}'`).join(" | "):"string",A=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
172
172
|
|
|
173
173
|
export interface FleetboSchemaMap {
|
|
174
174
|
${E}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
export type KnownFleetboTables = ${
|
|
177
|
+
export type KnownFleetboTables = ${S};
|
|
178
178
|
|
|
179
179
|
export type FleetboTables =
|
|
180
180
|
| KnownFleetboTables
|
|
@@ -440,7 +440,7 @@ ${E}
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
declare global {
|
|
443
|
-
type KnownFleetboTables = ${
|
|
443
|
+
type KnownFleetboTables = ${S};
|
|
444
444
|
type FleetboTables = KnownFleetboTables | (string & { _fleetboPending?: never });
|
|
445
445
|
type FleetboData<T extends string> = T extends KnownFleetboTables
|
|
446
446
|
? Partial<FleetboSchemaMap[T]>
|