Skip to content

Commit af49b10

Browse files
fix(ui~cli): windows path normalization for setup plugins (#1541)
* refactor(cli): windows support - replace path.join with joinNormalizedPath in plugin setup commands * chore: add changeset
1 parent 6caecce commit af49b10

17 files changed

+100
-27
lines changed

.changeset/shiny-parents-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"flowbite-react": patch
3+
---
4+
5+
fix(ui~cli): path normalzation for windows support (setup plugins paths)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from "path";
21
import { pluginName, pluginPath } from "../../consts";
32
import { addPluginToConfig } from "../../utils/add-plugin-to-config";
3+
import { joinNormalizedPath } from "../../utils/normalize-path";
44

55
export async function setupPluginAstro(configPath: string) {
66
await addPluginToConfig({
77
configKey: "integrations",
88
configPath,
9-
pluginImportPath: path.join(pluginPath, "astro"),
9+
pluginImportPath: joinNormalizedPath(pluginPath, "astro"),
1010
pluginName,
1111
});
1212
}

packages/ui/src/cli/commands/plugins/setup-plugin-bun.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import fs from "fs/promises";
2-
import path from "path";
32
import toml from "@iarna/toml";
43
import { pluginName, pluginPath } from "../../consts";
4+
import { joinNormalizedPath } from "../../utils/normalize-path";
55
import { updateBuildConfig } from "../../utils/update-build-config";
66

77
export async function setupPluginBun(configPath: string) {
88
try {
99
// update bunfig.toml
1010
const bunfig = await fs.readFile(configPath, "utf-8");
1111
const bunfigContent = toml.parse(bunfig) as { serve?: { static?: { plugins?: string[] } } };
12-
const bunPluginPath = path.join(pluginPath, "bun");
12+
const bunPluginPath = joinNormalizedPath(pluginPath, "bun");
1313

1414
if (bunfigContent.serve?.static?.plugins?.includes(pluginName)) {
1515
return;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from "path";
21
import { pluginName, pluginPath } from "../../consts";
32
import { addPluginToConfig } from "../../utils/add-plugin-to-config";
3+
import { joinNormalizedPath } from "../../utils/normalize-path";
44

55
export async function setupPluginFarm(configPath: string) {
66
await addPluginToConfig({
77
configKey: "plugins",
88
configPath,
9-
pluginImportPath: path.join(pluginPath, "farm"),
9+
pluginImportPath: joinNormalizedPath(pluginPath, "farm"),
1010
pluginName,
1111
});
1212
}

packages/ui/src/cli/commands/plugins/setup-plugin-modernjs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import fs from "fs/promises";
2-
import path from "path";
32
import cjson from "comment-json";
43
import { pluginName, pluginPath } from "../../consts";
54
import { addPluginToConfig } from "../../utils/add-plugin-to-config";
5+
import { joinNormalizedPath } from "../../utils/normalize-path";
66

77
export async function setupPluginModernjs(configPath: string) {
88
await addPluginToConfig({
99
configKey: "plugins",
1010
configPath,
11-
pluginImportPath: path.join(pluginPath, "modernjs"),
11+
pluginImportPath: joinNormalizedPath(pluginPath, "modernjs"),
1212
pluginName,
1313
});
1414

packages/ui/src/cli/commands/plugins/setup-plugin-nextjs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from "fs/promises";
2-
import path from "path";
32
import { pluginPath } from "../../consts";
43
import { addImport } from "../../utils/add-import";
4+
import { joinNormalizedPath } from "../../utils/normalize-path";
55
import { wrapDefaultExport } from "../../utils/wrap-default-export";
66

77
export async function setupPluginNextjs(configPath: string) {
@@ -13,7 +13,7 @@ export async function setupPluginNextjs(configPath: string) {
1313
let updatedContent = addImport({
1414
content,
1515
importName: pluginName,
16-
importPath: path.join(pluginPath, "nextjs"),
16+
importPath: joinNormalizedPath(pluginPath, "nextjs"),
1717
});
1818

1919
if (!content.includes(`${pluginName}(`)) {

packages/ui/src/cli/commands/plugins/setup-plugin-parcel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "fs/promises";
22
import path from "path";
33
import { outputDir, pluginName, pluginPath } from "../../consts";
4+
import { joinNormalizedPath } from "../../utils/normalize-path";
45

56
export async function setupPluginParcel(configPath: string) {
67
try {
@@ -38,7 +39,7 @@ export async function setupPluginParcel(configPath: string) {
3839
}
3940

4041
// setup `.flowbite-react/parcel-config/parcel-reporter.cjs` file
41-
const pluginImportPath = path.join(pluginPath, "parcel");
42+
const pluginImportPath = joinNormalizedPath(pluginPath, "parcel");
4243
const parcelReporterFileContent = `module.exports = require("${pluginImportPath}");`;
4344
const parcelReporterFilePath = path.join(parcelConfigDir, parcelReporterFile);
4445

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from "path";
21
import { pluginName, pluginPath } from "../../consts";
32
import { addPluginToConfig } from "../../utils/add-plugin-to-config";
3+
import { joinNormalizedPath } from "../../utils/normalize-path";
44

55
export async function setupPluginRolldown(configPath: string) {
66
await addPluginToConfig({
77
configKey: "plugins",
88
configPath,
9-
pluginImportPath: path.join(pluginPath, "rolldown"),
9+
pluginImportPath: joinNormalizedPath(pluginPath, "rolldown"),
1010
pluginName,
1111
});
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from "path";
21
import { pluginName, pluginPath } from "../../consts";
32
import { addPluginToConfig } from "../../utils/add-plugin-to-config";
3+
import { joinNormalizedPath } from "../../utils/normalize-path";
44

55
export async function setupPluginRollup(configPath: string) {
66
await addPluginToConfig({
77
configKey: "plugins",
88
configPath,
9-
pluginImportPath: path.join(pluginPath, "rollup"),
9+
pluginImportPath: joinNormalizedPath(pluginPath, "rollup"),
1010
pluginName,
1111
});
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import path from "path";
21
import { pluginName, pluginPath } from "../../consts";
32
import { addPluginToConfig } from "../../utils/add-plugin-to-config";
3+
import { joinNormalizedPath } from "../../utils/normalize-path";
44

55
export async function setupPluginRsbuild(configPath: string) {
66
await addPluginToConfig({
77
configKey: "plugins",
88
configPath,
9-
pluginImportPath: path.join(pluginPath, "rsbuild"),
9+
pluginImportPath: joinNormalizedPath(pluginPath, "rsbuild"),
1010
pluginName,
1111
});
1212
}

0 commit comments

Comments
 (0)