fleetbo-svro 1.0.16 → 1.0.19
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 +2 -8
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -115,18 +115,12 @@ VITE_FLEETBO_DB_KEY=${a.fleetboDBKey}
|
|
|
115
115
|
VITE_FLEETBO_ENTERPRISE_ID=${a.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
|
|
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
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
120
|
`):i=`import 'fleetbo-svro';
|
|
121
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
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=`{
|
|
123
123
|
name: 'fleetbo-auto-runtime',
|
|
124
|
-
transformIndexHtml(html) {
|
|
125
|
-
if (!html.includes('fleetbo-svro')) {
|
|
126
|
-
return html.replace('<head>', '<head>\\n <script type="module">import "fleetbo-svro";</script>');
|
|
127
|
-
}
|
|
128
|
-
return html;
|
|
129
|
-
},
|
|
130
124
|
transform(code, id) {
|
|
131
125
|
if (!id.includes('node_modules') && !code.includes('fleetbo-svro') && /(src[\\\\/](main|index|App|root))\\.(jsx?|tsx?|vue|svelte)/i.test(id)) {
|
|
132
126
|
return {
|
|
@@ -185,7 +179,7 @@ ${e?`VITE_FLEETBO_TESTER_EMAIL=${e}
|
|
|
185
179
|
`;if(h){let m=h.index+h[0].length;e=e.slice(0,m)+`
|
|
186
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)+`
|
|
187
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)+`
|
|
188
|
-
`),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),
|
|
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(`
|
|
189
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(`
|
|
190
184
|
[Fleetbo] Initializing and configuring Fleetbo...`),await G(t,E),K(t,o),u(`
|
|
191
185
|
[Fleetbo] Configuration completed successfully!
|