@yberagroup/kaizen-ui 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -56,7 +56,7 @@ No `tailwind.config.cjs`:
56
56
  const path = require("path");
57
57
 
58
58
  const kaizenUiRoot = path.dirname(
59
- require.resolve("@yberagroup/kaizen-ui/package.json"),
59
+ require.resolve("@yberagroup/kaizen-ui/tailwind-preset"),
60
60
  );
61
61
 
62
62
  module.exports = {
package/bin/kaizen-ui.mjs CHANGED
@@ -97,6 +97,39 @@ function ensureLocalCssImportInEntry(entryPath, cssAbsPath) {
97
97
  return true;
98
98
  }
99
99
 
100
+ function escapeForRegExp(s) {
101
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
102
+ }
103
+
104
+ /** Import ESM do pacote (aspas simples ou duplas). */
105
+ function hasPackageImportOfPath(source, importPath) {
106
+ const esc = escapeForRegExp(importPath);
107
+ return new RegExp(`import\\s+["']${esc}["']`).test(source);
108
+ }
109
+
110
+ /** @import do tema dentro de CSS. */
111
+ function cssImportsKaizenTheme(cssSource, importPath) {
112
+ const esc = escapeForRegExp(importPath);
113
+ if (new RegExp(`@import\\s+["']${esc}["']`).test(cssSource)) return true;
114
+ return cssSource.includes(importPath);
115
+ }
116
+
117
+ /**
118
+ * O tema Kaizen está acessível: import direto no entry ou @import em algum .css
119
+ * importado pelo entry (cadeia simples a partir do entry).
120
+ */
121
+ function entryReachableKaizenTheme(entryPath, theme) {
122
+ const importPath = THEME_IMPORT[theme];
123
+ const entrySrc = readFileSync(entryPath, "utf-8");
124
+ if (hasPackageImportOfPath(entrySrc, importPath)) return true;
125
+ for (const abs of findCssImportsFromEntry(entryPath)) {
126
+ if (!existsSync(abs)) continue;
127
+ const css = readFileSync(abs, "utf-8");
128
+ if (cssImportsKaizenTheme(css, importPath)) return true;
129
+ }
130
+ return false;
131
+ }
132
+
100
133
  function removeKaizenThemeImportsFromEntry(entryPath) {
101
134
  let source = readFileSync(entryPath, "utf-8");
102
135
  const lines = source.split("\n");
@@ -118,9 +151,9 @@ function removeKaizenThemeImportsFromEntry(entryPath) {
118
151
 
119
152
  function ensureImportInEntry(entryPath, importPath) {
120
153
  const source = readFileSync(entryPath, "utf-8");
121
- const importLine = `import "${importPath}";`;
122
- if (source.includes(importLine)) return false;
154
+ if (hasPackageImportOfPath(source, importPath)) return false;
123
155
 
156
+ const importLine = `import "${importPath}";`;
124
157
  const nextSource = `${importLine}\n${source}`;
125
158
  writeFileSync(entryPath, nextSource, "utf-8");
126
159
  return true;
@@ -132,7 +165,7 @@ function writeTailwindConfig(cwd) {
132
165
  const path = require("path");
133
166
 
134
167
  const kaizenUiRoot = path.dirname(
135
- require.resolve("@yberagroup/kaizen-ui/package.json"),
168
+ require.resolve("@yberagroup/kaizen-ui/tailwind-preset"),
136
169
  );
137
170
 
138
171
  module.exports = {
@@ -286,6 +319,15 @@ async function runInit() {
286
319
  }
287
320
  }
288
321
 
322
+ if (!entryReachableKaizenTheme(entryPath, theme)) {
323
+ const fixed = ensureImportInEntry(entryPath, themeImport);
324
+ if (fixed) {
325
+ logStep(
326
+ `Import do tema ${theme} garantido em ${relative(cwd, entryPath) || entryPath} (verificação final).`,
327
+ );
328
+ }
329
+ }
330
+
289
331
  rl.close();
290
332
  logStep("Concluído.");
291
333
  output.write(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yberagroup/kaizen-ui",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "prepublishOnly": "npm run build && npm run lint"
10
10
  },
11
11
  "dependencies": {
12
- "@yberagroup/kaizen-tokens": "^0.0.4",
12
+ "@yberagroup/kaizen-tokens": "^0.0.5",
13
13
  "class-variance-authority": "^0.7.1",
14
14
  "clsx": "^2.1.1",
15
15
  "@fortawesome/fontawesome-svg-core": "^6.7.2",