@frontman-ai/vite 0.1.1 → 0.1.3
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 +26 -18
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -430,8 +430,12 @@ function banner() {
|
|
|
430
430
|
` + tagline + `
|
|
431
431
|
`;
|
|
432
432
|
}
|
|
433
|
-
function
|
|
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(
|
|
446
|
+
` + bar + ` ` + purple("2.") + ` Add ` + bold(call) + ` to your plugins array:
|
|
443
447
|
` + bar + `
|
|
444
448
|
` + bar + ` ` + dim("plugins: [") + `
|
|
445
|
-
` + bar + ` ` + dim(
|
|
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
|
|
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,
|
|
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
|
@@ -20,20 +20,22 @@ import * as FrontmanCore__ToolRegistry$FrontmanFrontmanCore from '@frontman/fron
|
|
|
20
20
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
let productionHost = "api.frontman.sh";
|
|
24
|
+
|
|
23
25
|
let host = process.env["FRONTMAN_HOST"];
|
|
24
26
|
|
|
25
27
|
let defaultHost = host !== undefined ? host : "frontman.local:4000";
|
|
26
28
|
|
|
27
29
|
function makeFromObject(config) {
|
|
28
|
-
let
|
|
30
|
+
let host = Stdlib_Option.getOr(config.host, defaultHost);
|
|
31
|
+
let isDev = Stdlib_Option.getOr(config.isDev, host !== productionHost);
|
|
29
32
|
let projectRoot = Stdlib_Option.getOr(Stdlib_Option.orElse(config.projectRoot, Stdlib_Option.orElse(process.env["PROJECT_ROOT"], process.env["PWD"])), ".");
|
|
30
33
|
let sourceRoot = Stdlib_Option.getOr(config.sourceRoot, projectRoot);
|
|
31
34
|
let basePath = Stdlib_Option.getOr(config.basePath, "frontman");
|
|
32
35
|
let serverName = Stdlib_Option.getOr(config.serverName, "frontman-vite");
|
|
33
36
|
let serverVersion = Stdlib_Option.getOr(config.serverVersion, "1.0.0");
|
|
34
|
-
let host = Stdlib_Option.getOr(config.host, defaultHost);
|
|
35
37
|
let isLightTheme = Stdlib_Option.getOr(config.isLightTheme, false);
|
|
36
|
-
let baseUrl = Stdlib_Option.getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? "http://localhost:5173/src/Main.res.mjs" : "https://frontman.
|
|
38
|
+
let baseUrl = Stdlib_Option.getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? "http://localhost:5173/src/Main.res.mjs" : "https://app.frontman.sh/frontman.es.js");
|
|
37
39
|
let url = new URL(baseUrl);
|
|
38
40
|
let clientUrl = Stdlib_Option.getOr(config.clientUrl, (url.searchParams.set("clientName", "vite"), url.searchParams.set("host", host), url.href));
|
|
39
41
|
let parsedUrl = new URL(clientUrl);
|
package/dist/index.js
CHANGED
|
@@ -110,18 +110,19 @@ function orElse(opt, other) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// src/FrontmanVite__Config.res.mjs
|
|
113
|
+
var productionHost = "api.frontman.sh";
|
|
113
114
|
var host = process.env["FRONTMAN_HOST"];
|
|
114
115
|
var defaultHost = host !== void 0 ? host : "frontman.local:4000";
|
|
115
116
|
function makeFromObject(config) {
|
|
116
|
-
let
|
|
117
|
+
let host2 = getOr(config.host, defaultHost);
|
|
118
|
+
let isDev = getOr(config.isDev, host2 !== productionHost);
|
|
117
119
|
let projectRoot = getOr(orElse(config.projectRoot, orElse(process.env["PROJECT_ROOT"], process.env["PWD"])), ".");
|
|
118
120
|
let sourceRoot = getOr(config.sourceRoot, projectRoot);
|
|
119
121
|
let basePath = getOr(config.basePath, "frontman");
|
|
120
122
|
let serverName = getOr(config.serverName, "frontman-vite");
|
|
121
123
|
let serverVersion = getOr(config.serverVersion, "1.0.0");
|
|
122
|
-
let host2 = getOr(config.host, defaultHost);
|
|
123
124
|
let isLightTheme = getOr(config.isLightTheme, false);
|
|
124
|
-
let baseUrl = getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? "http://localhost:5173/src/Main.res.mjs" : "https://frontman.
|
|
125
|
+
let baseUrl = getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? "http://localhost:5173/src/Main.res.mjs" : "https://app.frontman.sh/frontman.es.js");
|
|
125
126
|
let url2 = new URL(baseUrl);
|
|
126
127
|
let clientUrl = getOr(config.clientUrl, (url2.searchParams.set("clientName", "vite"), url2.searchParams.set("host", host2), url2.href));
|
|
127
128
|
let parsedUrl = new URL(clientUrl);
|