@frontman-ai/vite 0.1.2 → 0.1.4

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.js CHANGED
@@ -430,8 +430,12 @@ function banner() {
430
430
  ` + tagline + `
431
431
  `;
432
432
  }
433
- function viteConfig(fileName) {
433
+ function pluginCall(server) {
434
+ return `frontmanPlugin({ host: '` + server + `' })`;
435
+ }
436
+ function viteConfig(server, fileName) {
434
437
  let bar = yellow("|");
438
+ let call = pluginCall(server);
435
439
  return ` ` + bar + `
436
440
  ` + bar + ` ` + yellowBold(fileName) + ` needs manual modification.
437
441
  ` + bar + `
@@ -439,10 +443,10 @@ function viteConfig(fileName) {
439
443
  ` + bar + `
440
444
  ` + bar + ` ` + dim("import { frontmanPlugin } from '@frontman-ai/vite';") + `
441
445
  ` + bar + `
442
- ` + bar + ` ` + purple("2.") + ` Add ` + bold("frontmanPlugin()") + ` to your plugins array:
446
+ ` + bar + ` ` + purple("2.") + ` Add ` + bold(call) + ` to your plugins array:
443
447
  ` + bar + `
444
448
  ` + bar + ` ` + dim("plugins: [") + `
445
- ` + bar + ` ` + dim(" frontmanPlugin(),") + `
449
+ ` + bar + ` ` + dim(` ` + call + `,`) + `
446
450
  ` + bar + ` ` + dim(" // ...your other plugins") + `
447
451
  ` + bar + ` ` + dim("],") + `
448
452
  ` + bar + `
@@ -527,7 +531,7 @@ async function installDependencies(projectDir, packageManager, dryRun) {
527
531
  _0: `Failed to install dependencies: ` + stderr
528
532
  };
529
533
  }
530
- function injectFrontmanPlugin(content) {
534
+ function injectFrontmanPlugin(server, content) {
531
535
  let pluginsPattern = /plugins\s*:\s*\[/;
532
536
  if (!pluginsPattern.test(content)) {
533
537
  return {
@@ -555,18 +559,30 @@ function injectFrontmanPlugin(content) {
555
559
  } else {
556
560
  contentWithImport = importStatement + "\n" + content;
557
561
  }
558
- let result = contentWithImport.replace(/plugins\s*:\s*\[/, "plugins: [\n frontmanPlugin(),");
562
+ let call = pluginCall(server);
563
+ let result = contentWithImport.replace(/plugins\s*:\s*\[/, `plugins: [
564
+ ` + call + `,`);
559
565
  return {
560
566
  TAG: "Ok",
561
567
  _0: result
562
568
  };
563
569
  }
564
- async function handleViteConfig(projectDir, info, dryRun) {
570
+ async function handleViteConfig(projectDir, info, server, dryRun) {
565
571
  let match = info.viteConfig;
566
572
  if (typeof match !== "object") {
567
573
  if (match === "NotFound") {
568
574
  let fileName = "vite.config.ts";
569
575
  let filePath = Nodepath.join(projectDir, fileName);
576
+ let call = pluginCall(server);
577
+ let content = `import { defineConfig } from 'vite';
578
+ import { frontmanPlugin } from '@frontman-ai/vite';
579
+
580
+ export default defineConfig({
581
+ plugins: [
582
+ ` + call + `,
583
+ ],
584
+ });
585
+ `;
570
586
  if (dryRun) {
571
587
  console.log(` ` + dim(`Would create: ` + fileName));
572
588
  return {
@@ -574,15 +590,7 @@ async function handleViteConfig(projectDir, info, dryRun) {
574
590
  _0: void 0
575
591
  };
576
592
  } else {
577
- await Fs.promises.writeFile(filePath, `import { defineConfig } from 'vite';
578
- import { frontmanPlugin } from '@frontman-ai/vite';
579
-
580
- export default defineConfig({
581
- plugins: [
582
- frontmanPlugin(),
583
- ],
584
- });
585
- `, "utf8");
593
+ await Fs.promises.writeFile(filePath, content, "utf8");
586
594
  console.log(SuccessMessages.fileCreated(fileName));
587
595
  return {
588
596
  TAG: "Ok",
@@ -603,7 +611,7 @@ export default defineConfig({
603
611
  _0: void 0
604
612
  };
605
613
  }
606
- let newContent = injectFrontmanPlugin(match.content);
614
+ let newContent = injectFrontmanPlugin(server, match.content);
607
615
  if (newContent.TAG === "Ok") {
608
616
  await Fs.promises.writeFile(match.filePath, newContent._0, "utf8");
609
617
  console.log(SuccessMessages.fileUpdated(info.viteConfigFileName));
@@ -615,7 +623,7 @@ export default defineConfig({
615
623
  console.log(SuccessMessages.manualEditRequired(info.viteConfigFileName));
616
624
  return {
617
625
  TAG: "Error",
618
- _0: ManualInstructions.viteConfig(info.viteConfigFileName)
626
+ _0: ManualInstructions.viteConfig(server, info.viteConfigFileName)
619
627
  };
620
628
  }
621
629
  }
@@ -640,7 +648,7 @@ async function run(options) {
640
648
  console.log("");
641
649
  }
642
650
  let manualSteps = [];
643
- let details = await handleViteConfig(projectDir, info, options.dryRun);
651
+ let details = await handleViteConfig(projectDir, info, options.server, options.dryRun);
644
652
  if (details.TAG !== "Ok") {
645
653
  manualSteps.push(details._0);
646
654
  }
package/dist/index.d.ts CHANGED
@@ -285,6 +285,7 @@ function handleUI(config) {
285
285
  <body>
286
286
  <div id="root"></div>
287
287
  ` + runtimeConfigScript + `
288
+ <script>if(typeof process==="undefined"){window.process={env:{NODE_ENV:"production"}}}</script>
288
289
  <script type="module" src="` + config.clientUrl + `"></script>
289
290
  </body>
290
291
  </html>`;
package/dist/index.js CHANGED
@@ -5491,6 +5491,7 @@ function handleUI(config) {
5491
5491
  <body>
5492
5492
  <div id="root"></div>
5493
5493
  ` + runtimeConfigScript + `
5494
+ <script>if(typeof process==="undefined"){window.process={env:{NODE_ENV:"production"}}}</script>
5494
5495
  <script type="module" src="` + config.clientUrl + `"></script>
5495
5496
  </body>
5496
5497
  </html>`;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.2",
6
+ "version": "0.1.4",
7
7
  "description": "Vite integration for Frontman - AI-powered development tools",
8
8
  "license": "Apache-2.0",
9
9
  "author": "Frontman AI",