fleetbo-svro 1.0.21 → 1.0.23
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 +24 -64
- package/package.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
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,
|
|
3
|
-
`),f("\u2192 Created svro.schema.json at project root.")}function M(t){let o=p.join(t,"src");if(!
|
|
2
|
+
var J=(t,o)=>()=>{try{return o||t((o={exports:{}}).exports,o),o.exports}catch(n){throw o=0,n}};var _=J((le,w)=>{var c=require("fs"),p=require("path"),L=require("https"),{execSync:A}=require("child_process"),$="\x1B[38;2;231;233;237m",D="\x1B[31m",T="\x1B[0m";function f(t){console.log(` ${$}${t}${T}`)}function u(t){console.error(` ${D}${t}${T}`)}function N(t){let o={};return t.forEach(n=>{if(n.startsWith("--")){let[r,s]=n.slice(2).split("=");r&&s&&(o[r]=s)}}),o}function E(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(!E(o,"fleetbo-svro")){f("\u2192 Installing fleetbo-svro into the project...");try{A("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 B(t){let o=p.join(t,"svro.schema.json");if(c.existsSync(o))return;let n=new Date().toISOString(),r={createdAt:n,patchedAt:n,schemaVersion:1,collections:{}};c.writeFileSync(o,JSON.stringify(r,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,"fleetbo.d.ts");if(c.existsSync(n))return;let r=`/* eslint-disable */
|
|
4
4
|
/* prettier-ignore */
|
|
5
5
|
// @ts-nocheck
|
|
6
|
-
// Generated by fleetbo-svro setup
|
|
7
6
|
export {}
|
|
8
7
|
|
|
9
8
|
type FleetboProp = {
|
|
@@ -72,53 +71,15 @@ declare module 'react' {
|
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
declare module '@vue/runtime-core' {
|
|
77
|
-
export interface GlobalComponents {
|
|
78
|
-
'fleetbo-text': FleetboProp;
|
|
79
|
-
'fleetbo-number': FleetboProp;
|
|
80
|
-
'fleetbo-toggle': FleetboProp;
|
|
81
|
-
'fleetbo-date': FleetboProp;
|
|
82
|
-
'fleetbo-enum': FleetboProp;
|
|
83
|
-
'fleetbo-media': FleetboProp;
|
|
84
|
-
'fleetbo-reference': FleetboProp;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
declare module 'preact' {
|
|
89
|
-
namespace JSX {
|
|
90
|
-
interface IntrinsicElements {
|
|
91
|
-
'fleetbo-text': FleetboProp;
|
|
92
|
-
'fleetbo-number': FleetboProp;
|
|
93
|
-
'fleetbo-toggle': FleetboProp;
|
|
94
|
-
'fleetbo-date': FleetboProp;
|
|
95
|
-
'fleetbo-enum': FleetboProp;
|
|
96
|
-
'fleetbo-media': FleetboProp;
|
|
97
|
-
'fleetbo-reference': FleetboProp;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
declare module 'svelte/elements' {
|
|
103
|
-
export interface SvelteHTMLElements {
|
|
104
|
-
'fleetbo-text': FleetboProp;
|
|
105
|
-
'fleetbo-number': FleetboProp;
|
|
106
|
-
'fleetbo-toggle': FleetboProp;
|
|
107
|
-
'fleetbo-date': FleetboProp;
|
|
108
|
-
'fleetbo-enum': FleetboProp;
|
|
109
|
-
'fleetbo-media': FleetboProp;
|
|
110
|
-
'fleetbo-reference': FleetboProp;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
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=`
|
|
74
|
+
`;try{c.writeFileSync(n,r),f("\u2192 Created src/fleetbo.d.ts stub for instant IDE auto-completion.")}catch(s){u(`\u26A0\uFE0F Unable to create src/fleetbo.d.ts: ${s.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 r=p.join(t,n);if(c.existsSync(r)){let s=new Date;c.utimesSync(r,s,s);break}}}function H(t){return new Promise((o,n)=>{let r=JSON.stringify({token:t}),s={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=L.request(s,e=>{let i="";e.on("data",l=>{i+=l}),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 l=JSON.parse(i);n(new Error(l.error||`Server error ${e.statusCode}`))}catch{n(new Error(`Server error ${e.statusCode}`))}})});b.on("error",e=>n(e)),b.write(r),b.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 r=N(o),s=r.keyApp,b=r.token||r.bootstrapToken,e=r.email||"";(!s||!b)&&(u("\u26A0\uFE0F Missing required parameters."),u("\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(a){u(`\u26A0\uFE0F Token exchange failed: ${a.message}`),u("\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)&&(u("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let l=`
|
|
114
75
|
VITE_FLEETBO_DB_KEY=${i.fleetboDBKey}
|
|
115
76
|
VITE_FLEETBO_ENTERPRISE_ID=${i.enterpriseId}
|
|
116
|
-
VITE_FLEETBO_KEY_APP=${
|
|
77
|
+
VITE_FLEETBO_KEY_APP=${s}
|
|
117
78
|
${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
118
|
-
`:""}`;
|
|
119
|
-
`),f(`\u2192 Updated ${p.basename(
|
|
120
|
-
`):
|
|
121
|
-
`+
|
|
79
|
+
`:""}`;c.appendFileSync(n,l),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"),r=p.join(t,"jsconfig.json"),s=c.existsSync(n)?n:r,b=!c.existsSync(s),e={};if(!b)try{e=JSON.parse(c.readFileSync(s,"utf8"))}catch{u(`\u26A0\uFE0F Unable to read ${p.basename(s)} (Invalid JSON).`);return}e.compilerOptions=e.compilerOptions||{};let i=!1,l=E(o,"react"),a=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)),l&&e.compilerOptions.jsx===void 0&&(e.compilerOptions.jsx="react-jsx",i=!0),a&&e.compilerOptions.types===void 0&&(e.compilerOptions.types=["vite/client"],i=!0),i&&(c.writeFileSync(s,JSON.stringify(e,null,2)+`
|
|
80
|
+
`),f(`\u2192 Updated ${p.basename(s)}.`))}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 r=p.join(t,n);if(c.existsSync(r)){let s=c.readFileSync(r,"utf8");s.includes("fleetbo-svro")||(s.startsWith('"use client"')||s.startsWith("'use client'")?s=s.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
|
|
81
|
+
`):s=`import 'fleetbo-svro';
|
|
82
|
+
`+s,c.writeFileSync(r,s));return}}}function k(t,o){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let r=["vite.config.ts","vite.config.js","vite.config.mjs"].map(l=>p.join(t,l)).find(l=>c.existsSync(l));if(!r)return;let s;try{s=c.readFileSync(r,"utf8")}catch{return}let b="fleetbo-svro",e=s,i=`{
|
|
122
83
|
name: 'fleetbo-auto-runtime',
|
|
123
84
|
transform(code, id) {
|
|
124
85
|
if (!id.includes('node_modules') && !code.includes('fleetbo-svro') && /(src[\\\\/](main|index|App|root))\\.(jsx?|tsx?|vue|svelte)/i.test(id)) {
|
|
@@ -170,24 +131,23 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
|
170
131
|
watch: {
|
|
171
132
|
ignored: ['**/svro.schema.json', '**/src/auto-imports.d.ts']
|
|
172
133
|
}
|
|
173
|
-
},`))),!e.includes("unplugin-auto-import")){let
|
|
134
|
+
},`))),!e.includes("unplugin-auto-import")){let l=e.match(/plugins\s*:\s*\[/);if(l){let a=l.index+l[0].length,h=`
|
|
174
135
|
AutoImport({
|
|
175
|
-
imports: [{ '${b}': ['Fleetbo'] }],
|
|
136
|
+
imports: [{ '${b}': ['Fleetbo', 'FleetboUI'] }],
|
|
176
137
|
dts: 'src/auto-imports.d.ts'
|
|
177
|
-
}),`;if(e=e.slice(0,
|
|
178
|
-
`;if(
|
|
179
|
-
`+v+e.slice(m)}else e=v+e}}}if(!e.includes("fleetbo-auto-runtime")){let
|
|
180
|
-
`+i+e.slice(
|
|
181
|
-
`)
|
|
182
|
-
|
|
183
|
-
[Fleetbo] Initializing and configuring Fleetbo...`),await G(t,x),K(t,o),u(`
|
|
138
|
+
}),`;if(e=e.slice(0,a)+h+e.slice(a),!e.includes("import AutoImport")){let P=[...e.matchAll(/^import .+;?$/gm)].pop(),v=`import AutoImport from 'unplugin-auto-import/vite';
|
|
139
|
+
`;if(P){let m=P.index+P[0].length;e=e.slice(0,m)+`
|
|
140
|
+
`+v+e.slice(m)}else e=v+e}}}if(!e.includes("fleetbo-auto-runtime")){let l=e.match(/plugins\s*:\s*\[/);if(l){let a=l.index+l[0].length;e=e.slice(0,a)+`
|
|
141
|
+
`+i+e.slice(a)}}e!==s&&c.writeFileSync(r,e)}function K(t,o,n={}){let{skipSelfInstall:r=!1}=n,s=p.join(__dirname,"..");r||U(t,o),B(t),q(s),M(t),O(t),I(t,o),k(t,o),j(t)}w.exports={touchTsConfig:V,log:f,logError:u,handleAuthAndEnv:W,detectDependency:E,cleanupLegacyRootDts:O,patchJsOrTsConfig:I,attemptViteAutoImportPatch:k,injectUniversalRuntime:j,runFullSetup:K}});var g=require("fs"),F=require("path"),R=require("https"),{runFullSetup:X,handleAuthAndEnv:Y,touchTsConfig:G,attemptViteAutoImportPatch:z,injectUniversalRuntime:Q}=_(),Z="\x1B[34m",ee="\x1B[31m",C="\x1B[0m";function d(t){console.log(`${Z}${t}${C}`)}function y(t){console.error(`${ee}${t}${C}`)}function te(t,o){return new Promise((n,r)=>{let s=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(s)}},e=R.request(b,i=>{let l="";i.on("data",a=>{l+=a}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?n(JSON.parse(l)):r(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});e.on("error",i=>r(i)),e.write(s),e.end()})}function oe(t){let o=F.join(t,".env");if(!g.existsSync(o))return{};let n=g.readFileSync(o,"utf8"),r={};return n.split(`
|
|
142
|
+
`).forEach(s=>{let[b,...e]=s.split("=");b&&e.length>0&&(r[b.trim()]=e.join("=").trim())}),r}function ne(t){return new Promise((o,n)=>{let r=JSON.stringify({projectId:t,moduleName:"svro.schema.json"}),s={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},b=R.request(s,e=>{let i="";e.on("data",l=>{i+=l}),e.on("end",()=>{if(e.statusCode>=200&&e.statusCode<300)try{let l=JSON.parse(i);if(l.success&&l.found&&l.module){let a=l.module.code||l.module.mockCode;o(typeof a=="string"?JSON.parse(a):a)}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(r),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")d(`
|
|
143
|
+
[Fleetbo] Initializing and configuring Fleetbo...`),await Y(t,x),X(t,o),d(`
|
|
184
144
|
[Fleetbo] Configuration completed successfully!
|
|
185
|
-
`),
|
|
186
|
-
Next step:`),
|
|
187
|
-
`);else if(S==="sync"){let n=x.includes("--dry-run");
|
|
188
|
-
`),
|
|
145
|
+
`),d(`
|
|
146
|
+
Next step:`),d(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
|
|
147
|
+
`);else if(S==="sync"){let n=x.includes("--dry-run");d(`[Fleetbo] Syncing schema...${n?" (dry-run)":""}`);let r=F.join(t,"svro.schema.json"),s=F.join(__dirname,".."),b=F.join(s,"index.d.ts"),e=F.join(t,"src","fleetbo.d.ts"),l=oe(t).VITE_FLEETBO_ENTERPRISE_ID;if(l)try{d("\u2192 Fetching latest svro.schema.json from Fleetbo OS...");let a=await ne(l);g.writeFileSync(r,JSON.stringify(a,null,2)+`
|
|
148
|
+
`),d("\u2192 Local svro.schema.json updated from FLeetbo OS.")}catch(a){y(`\u26A0\uFE0F Cloud fetch bypassed: ${a.message}. Using local file fallback.`)}else y("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");g.existsSync(r)||(y("Error: svro.schema.json not found."),process.exit(1));try{let a=JSON.parse(g.readFileSync(r,"utf8")),h=Object.keys(a.collections||{});if(l)try{await te(l,a),d("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(m){y(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${m.message}`)}let P=h.length>0?h.map(m=>`'${m}'`).join(" | "):"string",v=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
189
149
|
|
|
190
|
-
export type FleetboTables = ${
|
|
150
|
+
export type FleetboTables = ${P};
|
|
191
151
|
|
|
192
152
|
declare global {
|
|
193
153
|
interface ImportMetaEnv {
|
|
@@ -390,7 +350,7 @@ declare module 'svelte/elements' {
|
|
|
390
350
|
'fleetbo-reference': FleetboProp;
|
|
391
351
|
}
|
|
392
352
|
}
|
|
393
|
-
`;if(g.writeFileSync(b,v),g.existsSync(F.dirname(
|
|
353
|
+
`;if(g.writeFileSync(b,v),g.existsSync(F.dirname(autoImportsDtsPath))){let m=`/* eslint-disable */
|
|
394
354
|
/* prettier-ignore */
|
|
395
355
|
// @ts-nocheck
|
|
396
356
|
// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
@@ -419,7 +379,7 @@ type FleetboProp = {
|
|
|
419
379
|
};
|
|
420
380
|
|
|
421
381
|
declare global {
|
|
422
|
-
type FleetboTables = ${
|
|
382
|
+
type FleetboTables = ${P};
|
|
423
383
|
const Fleetbo: typeof import('fleetbo-svro')['Fleetbo'];
|
|
424
384
|
|
|
425
385
|
namespace JSX {
|
|
@@ -500,4 +460,4 @@ declare module 'svelte/elements' {
|
|
|
500
460
|
'fleetbo-reference': FleetboProp;
|
|
501
461
|
}
|
|
502
462
|
}
|
|
503
|
-
`;g.writeFileSync(
|
|
463
|
+
`;g.writeFileSync(autoImportsDtsPath,m)}G(t),z(t,o),Q(t),d(`[Fleetbo] Schema synced successfully (${h.length} collection(s)).`),n&&d("\u2192 [Dry-run] Schema is valid.")}catch(a){y(`Error during synchronization: ${a.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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbo-svro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"types": "index.d.ts",
|
|
10
10
|
"bin": {
|
|
11
|
-
"fleetbo-svro": "
|
|
12
|
-
"fleetbo": "
|
|
13
|
-
"svro": "
|
|
11
|
+
"fleetbo-svro": "dist/cli.cjs",
|
|
12
|
+
"fleetbo": "dist/cli.cjs",
|
|
13
|
+
"svro": "dist/cli.cjs"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build:pkg": "node package-build.js",
|