opsfuse-ui 0.1.5 → 0.1.6
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/package.json +1 -1
- package/scripts/postinstall.mjs +45 -1
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* two levels up from packageRoot (node_modules/opsfuse-ui → node_modules → host).
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { existsSync, mkdirSync, cpSync } from "fs";
|
|
18
|
+
import { existsSync, mkdirSync, cpSync, readFileSync } from "fs";
|
|
19
19
|
import { join, dirname } from "path";
|
|
20
20
|
import { fileURLToPath } from "url";
|
|
21
21
|
|
|
@@ -33,6 +33,9 @@ if (!packageRoot.includes("node_modules")) {
|
|
|
33
33
|
const hostRoot = join(packageRoot, "..", "..");
|
|
34
34
|
const skillsSource = join(packageRoot, ".claude", "skills");
|
|
35
35
|
const skillsDest = join(hostRoot, ".claude", "skills");
|
|
36
|
+
const hostPackageJsonPath = join(hostRoot, "package.json");
|
|
37
|
+
const styleFlatPath = join(packageRoot, "dist", "style.css");
|
|
38
|
+
const styleLayeredPath = join(packageRoot, "dist", "style.layered.css");
|
|
36
39
|
|
|
37
40
|
const OPSFUSE_SKILLS = [
|
|
38
41
|
"opsfuse-components",
|
|
@@ -41,6 +44,47 @@ const OPSFUSE_SKILLS = [
|
|
|
41
44
|
"opsfuse-setup",
|
|
42
45
|
];
|
|
43
46
|
|
|
47
|
+
function getTailwindMajorFromHost() {
|
|
48
|
+
if (!existsSync(hostPackageJsonPath)) return null;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const pkg = JSON.parse(readFileSync(hostPackageJsonPath, "utf8"));
|
|
52
|
+
const versionRaw =
|
|
53
|
+
pkg?.dependencies?.tailwindcss ??
|
|
54
|
+
pkg?.devDependencies?.tailwindcss ??
|
|
55
|
+
pkg?.peerDependencies?.tailwindcss ??
|
|
56
|
+
pkg?.optionalDependencies?.tailwindcss;
|
|
57
|
+
|
|
58
|
+
if (typeof versionRaw !== "string") return null;
|
|
59
|
+
|
|
60
|
+
// Handles ranges like "^4.1.0", "~3.4.0", ">=4", "4", "workspace:^4.0.0".
|
|
61
|
+
const majorMatch = versionRaw.match(/(\d+)(?:\.\d+)?(?:\.\d+)?/);
|
|
62
|
+
if (!majorMatch) return null;
|
|
63
|
+
|
|
64
|
+
const major = Number.parseInt(majorMatch[1], 10);
|
|
65
|
+
return Number.isFinite(major) ? major : null;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function alignStyleBundleToHostTailwind() {
|
|
72
|
+
if (!existsSync(styleFlatPath) || !existsSync(styleLayeredPath)) return;
|
|
73
|
+
|
|
74
|
+
const tailwindMajor = getTailwindMajorFromHost();
|
|
75
|
+
if (tailwindMajor == null) return;
|
|
76
|
+
|
|
77
|
+
if (tailwindMajor >= 4) {
|
|
78
|
+
// Tailwind v4 hosts need layered CSS to avoid cascade conflicts.
|
|
79
|
+
cpSync(styleLayeredPath, styleFlatPath, { force: true });
|
|
80
|
+
console.log(
|
|
81
|
+
`[opsfuse-ui] Detected Tailwind v${tailwindMajor} in host app; mapped styles.css -> layered bundle.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
alignStyleBundleToHostTailwind();
|
|
87
|
+
|
|
44
88
|
if (!existsSync(skillsSource)) {
|
|
45
89
|
console.warn("[opsfuse-ui] Skills source not found — skipping Claude skill install.");
|
|
46
90
|
process.exit(0);
|