@udixio/tailwind 1.0.0 → 1.2.0
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/CHANGELOG.md +20 -0
- package/dist/file.d.ts +2 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/index.cjs +92 -36
- package/dist/index.js +79 -24
- package/dist/tailwind.plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/file.ts +59 -22
- package/src/main.ts +2 -0
- package/src/plugins-tailwind/shadow.ts +32 -0
- package/src/tailwind.plugin.ts +17 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 1.2.0 (2025-08-21)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **tailwind:** add custom shadow utility plugin ([8e3485e](https://github.com/Udixio/UI/commit/8e3485e))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Joël VIGREUX
|
|
10
|
+
|
|
11
|
+
## 1.1.0 (2025-08-21)
|
|
12
|
+
|
|
13
|
+
### 🚀 Features
|
|
14
|
+
|
|
15
|
+
- **doc:** integrate Udixio ecosystem into Astro project ([ca6b750](https://github.com/Udixio/UI/commit/ca6b750))
|
|
16
|
+
|
|
17
|
+
### ❤️ Thank You
|
|
18
|
+
|
|
19
|
+
- Joël VIGREUX
|
|
20
|
+
|
|
1
21
|
# 1.0.0 (2025-08-04)
|
|
2
22
|
|
|
3
23
|
### 🚀 Features
|
package/dist/file.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const createOrUpdateFile: (filePath: string, content: string) => void;
|
|
2
2
|
export declare const getFileContent: (filePath: string, searchPattern?: RegExp | string) => string | false | null;
|
|
3
3
|
export declare const replaceFileContent: (filePath: string, searchPattern: RegExp | string, replacement: string) => void;
|
|
4
|
-
export declare const findTailwindCssFile: (startDir: string, searchPattern: string) => string |
|
|
4
|
+
export declare const findTailwindCssFile: (startDir: string, searchPattern: RegExp | string) => string | never;
|
|
5
|
+
export declare function findProjectRoot(startPath: any): any;
|
|
5
6
|
//# sourceMappingURL=file.d.ts.map
|
package/dist/file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,KAAG,IAmBtE,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,gBAAgB,MAAM,GAAG,MAAM,KAC9B,MAAM,GAAG,KAAK,GAAG,IA4CnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,eAAe,MAAM,GAAG,MAAM,EAC9B,aAAa,MAAM,KAClB,IAkBF,CAAC;AACF,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,eAAe,MAAM,GAAG,MAAM,KAC7B,MAAM,GAAG,KA8CX,CAAC;AAEF,wBAAgB,eAAe,CAAC,SAAS,KAAA,OAaxC"}
|
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const plugin = require("tailwindcss/plugin");
|
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const replaceInFile = require("replace-in-file");
|
|
10
|
+
const console = require("node:console");
|
|
10
11
|
const theme = require("@udixio/theme");
|
|
11
12
|
function _interopNamespaceDefault(e) {
|
|
12
13
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -26,6 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
26
27
|
}
|
|
27
28
|
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
28
29
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
|
30
|
+
const console__namespace = /* @__PURE__ */ _interopNamespaceDefault(console);
|
|
29
31
|
const defaultConfig = {
|
|
30
32
|
statePrefix: "state",
|
|
31
33
|
disabledStyles: {
|
|
@@ -126,6 +128,30 @@ const font = plugin.withOptions((options) => {
|
|
|
126
128
|
addUtilities(newUtilities);
|
|
127
129
|
};
|
|
128
130
|
});
|
|
131
|
+
const shadow = plugin(
|
|
132
|
+
({ addUtilities }) => {
|
|
133
|
+
addUtilities({
|
|
134
|
+
[".shadow"]: {
|
|
135
|
+
boxShadow: "0 4px 10px #00000008, 0 0 2px #0000000f, 0 2px 6px #0000001f"
|
|
136
|
+
},
|
|
137
|
+
[".shadow-1"]: {
|
|
138
|
+
boxShadow: "0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
|
|
139
|
+
},
|
|
140
|
+
[".shadow-2"]: {
|
|
141
|
+
boxShadow: "0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
|
|
142
|
+
},
|
|
143
|
+
[".shadow-3"]: {
|
|
144
|
+
boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)"
|
|
145
|
+
},
|
|
146
|
+
[".shadow-4"]: {
|
|
147
|
+
boxShadow: "0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)"
|
|
148
|
+
},
|
|
149
|
+
[".box-shadow-5"]: {
|
|
150
|
+
boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)"
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
);
|
|
129
155
|
const main = plugin.withOptions((args) => {
|
|
130
156
|
const configCss = args;
|
|
131
157
|
const fontStyles = {};
|
|
@@ -156,6 +182,7 @@ const main = plugin.withOptions((args) => {
|
|
|
156
182
|
return (api) => {
|
|
157
183
|
font(options).handler(api);
|
|
158
184
|
state(options).handler(api);
|
|
185
|
+
shadow.handler(api);
|
|
159
186
|
};
|
|
160
187
|
});
|
|
161
188
|
const createOrUpdateFile = (filePath, content) => {
|
|
@@ -166,46 +193,46 @@ const createOrUpdateFile = (filePath, content) => {
|
|
|
166
193
|
fs__namespace.mkdirSync(dirPath, { recursive: true });
|
|
167
194
|
}
|
|
168
195
|
fs__namespace.writeFileSync(filePath, content);
|
|
169
|
-
|
|
196
|
+
console__namespace.log(`✅ File successfully created: ${filePath}`);
|
|
170
197
|
} else {
|
|
171
|
-
|
|
198
|
+
console__namespace.log(`⚠️ File already exists: ${filePath}`);
|
|
172
199
|
replaceFileContent(filePath, /[\s\S]*/, content);
|
|
173
200
|
}
|
|
174
201
|
} catch (error) {
|
|
175
|
-
|
|
202
|
+
console__namespace.error("❌ Error while creating the file:", error);
|
|
176
203
|
}
|
|
177
204
|
};
|
|
178
205
|
const getFileContent = (filePath, searchPattern) => {
|
|
179
206
|
try {
|
|
180
207
|
if (!fs__namespace.existsSync(filePath)) {
|
|
181
|
-
|
|
208
|
+
console__namespace.error(`❌ The specified file does not exist: ${filePath}`);
|
|
182
209
|
return null;
|
|
183
210
|
}
|
|
184
211
|
const fileContent = fs__namespace.readFileSync(filePath, "utf8");
|
|
185
212
|
if (searchPattern) {
|
|
186
213
|
if (typeof searchPattern === "string") {
|
|
187
214
|
const found = fileContent.includes(searchPattern) ? searchPattern : false;
|
|
188
|
-
|
|
215
|
+
console__namespace.log(
|
|
189
216
|
found ? `✅ The file contains the specified string: "${searchPattern}"` : `⚠️ The file does NOT contain the specified string: "${searchPattern}"`
|
|
190
217
|
);
|
|
191
218
|
return found;
|
|
192
219
|
} else {
|
|
193
220
|
const match = fileContent.match(searchPattern);
|
|
194
221
|
if (match) {
|
|
195
|
-
|
|
222
|
+
console__namespace.log(`✅ Found match: "${match[0]}"`);
|
|
196
223
|
return match[0];
|
|
197
224
|
} else {
|
|
198
|
-
|
|
225
|
+
console__namespace.log(
|
|
199
226
|
`⚠️ No match found for the pattern: "${searchPattern.toString()}"`
|
|
200
227
|
);
|
|
201
228
|
return false;
|
|
202
229
|
}
|
|
203
230
|
}
|
|
204
231
|
}
|
|
205
|
-
|
|
232
|
+
console__namespace.log(`✅ File content successfully retrieved.`);
|
|
206
233
|
return fileContent;
|
|
207
234
|
} catch (error) {
|
|
208
|
-
|
|
235
|
+
console__namespace.error("❌ An error occurred while processing the file:", error);
|
|
209
236
|
return null;
|
|
210
237
|
}
|
|
211
238
|
};
|
|
@@ -217,36 +244,64 @@ const replaceFileContent = (filePath, searchPattern, replacement) => {
|
|
|
217
244
|
to: replacement
|
|
218
245
|
});
|
|
219
246
|
if (results.length > 0 && results[0].hasChanged) {
|
|
220
|
-
|
|
247
|
+
console__namespace.log(`✅ Content successfully replaced in the file: ${filePath}`);
|
|
221
248
|
} else {
|
|
222
|
-
|
|
249
|
+
console__namespace.log(
|
|
223
250
|
`⚠️ No replacement made. Here are some possible reasons:
|
|
224
251
|
- The pattern ${searchPattern} was not found.
|
|
225
252
|
- The file might already contain the expected content.`
|
|
226
253
|
);
|
|
227
254
|
}
|
|
228
255
|
} catch (error) {
|
|
229
|
-
|
|
256
|
+
console__namespace.error("❌ Error while replacing the file content:", error);
|
|
230
257
|
}
|
|
231
258
|
};
|
|
232
259
|
const findTailwindCssFile = (startDir, searchPattern) => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
260
|
+
console__namespace.log("Recherche du fichier contenant le motif...", startDir);
|
|
261
|
+
const stack = [startDir];
|
|
262
|
+
while (stack.length > 0) {
|
|
263
|
+
const currentDir = stack.pop();
|
|
264
|
+
const files = fs__namespace.readdirSync(currentDir);
|
|
265
|
+
for (const file of files) {
|
|
266
|
+
const filePath = path__namespace.join(currentDir, file);
|
|
267
|
+
let stats;
|
|
268
|
+
try {
|
|
269
|
+
stats = fs__namespace.statSync(filePath);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console__namespace.error(`Erreur lors de l'accès à ${filePath}:`, error);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (stats.isDirectory()) {
|
|
275
|
+
if (file !== "node_modules") stack.push(filePath);
|
|
276
|
+
} else if (stats.isFile() && (file.endsWith(".css") || file.endsWith(".scss") || file.endsWith(".sass"))) {
|
|
277
|
+
try {
|
|
278
|
+
console__namespace.log(`Analyse du fichier : ${filePath}`);
|
|
279
|
+
const content = fs__namespace.readFileSync(filePath, "utf8");
|
|
280
|
+
if (content.match(searchPattern)) {
|
|
281
|
+
console__namespace.log("Fichier trouvé :", filePath);
|
|
282
|
+
return filePath;
|
|
283
|
+
}
|
|
284
|
+
} catch (readError) {
|
|
285
|
+
console__namespace.error(`Erreur lors de la lecture de ${filePath}:`, readError);
|
|
286
|
+
}
|
|
245
287
|
}
|
|
246
288
|
}
|
|
247
289
|
}
|
|
248
|
-
|
|
290
|
+
throw new Error(
|
|
291
|
+
`Impossible de trouver un fichier contenant "${searchPattern}" dans "${startDir}".`
|
|
292
|
+
);
|
|
249
293
|
};
|
|
294
|
+
function findProjectRoot(startPath) {
|
|
295
|
+
let currentPath = startPath;
|
|
296
|
+
while (!fs__namespace.existsSync(path__namespace.join(currentPath, "package.json"))) {
|
|
297
|
+
const parentPath = path__namespace.dirname(currentPath);
|
|
298
|
+
if (currentPath === parentPath) {
|
|
299
|
+
throw new Error("Impossible de localiser la racine du projet.");
|
|
300
|
+
}
|
|
301
|
+
currentPath = parentPath;
|
|
302
|
+
}
|
|
303
|
+
return currentPath;
|
|
304
|
+
}
|
|
250
305
|
class TailwindPlugin extends theme.PluginAbstract {
|
|
251
306
|
constructor() {
|
|
252
307
|
super(...arguments);
|
|
@@ -263,18 +318,19 @@ class TailwindImplPlugin extends theme.PluginImplAbstract {
|
|
|
263
318
|
});
|
|
264
319
|
}
|
|
265
320
|
onLoad() {
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
272
|
-
const replacement = `@import 'tailwindcss';
|
|
321
|
+
let udixioCssPath = this.options.styleFilePath;
|
|
322
|
+
const projectRoot = findProjectRoot(path.resolve());
|
|
323
|
+
if (!udixioCssPath) {
|
|
324
|
+
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
325
|
+
const replacement = `@import 'tailwindcss';
|
|
273
326
|
@import "./udixio.css";`;
|
|
274
|
-
|
|
275
|
-
|
|
327
|
+
const tailwindCssPath = findTailwindCssFile(projectRoot, searchPattern);
|
|
328
|
+
udixioCssPath = path.join(tailwindCssPath, "../udixio.css");
|
|
329
|
+
console__namespace.log("rrgfgt", tailwindCssPath, udixioCssPath);
|
|
330
|
+
if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
|
|
331
|
+
replaceFileContent(tailwindCssPath, searchPattern, replacement);
|
|
332
|
+
}
|
|
276
333
|
}
|
|
277
|
-
const cssFilePath = path.dirname(tailwindCssPath);
|
|
278
334
|
const colors = {};
|
|
279
335
|
for (const isDark of [false, true]) {
|
|
280
336
|
this.api.themes.update({ isDark });
|
|
@@ -297,7 +353,7 @@ class TailwindImplPlugin extends theme.PluginImplAbstract {
|
|
|
297
353
|
).map(([key, value]) => `${key} ${value}`).join(", ")
|
|
298
354
|
};
|
|
299
355
|
createOrUpdateFile(
|
|
300
|
-
|
|
356
|
+
udixioCssPath,
|
|
301
357
|
`
|
|
302
358
|
@plugin "@udixio/tailwind" {
|
|
303
359
|
colorKeys: ${configCss.colorKeys};
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import * as fs from "fs";
|
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import path__default from "path";
|
|
8
8
|
import { replaceInFileSync } from "replace-in-file";
|
|
9
|
+
import * as console from "node:console";
|
|
9
10
|
import { PluginAbstract, FontPlugin, PluginImplAbstract } from "@udixio/theme";
|
|
10
11
|
const defaultConfig = {
|
|
11
12
|
statePrefix: "state",
|
|
@@ -107,6 +108,30 @@ const font = plugin.withOptions((options) => {
|
|
|
107
108
|
addUtilities(newUtilities);
|
|
108
109
|
};
|
|
109
110
|
});
|
|
111
|
+
const shadow = plugin(
|
|
112
|
+
({ addUtilities }) => {
|
|
113
|
+
addUtilities({
|
|
114
|
+
[".shadow"]: {
|
|
115
|
+
boxShadow: "0 4px 10px #00000008, 0 0 2px #0000000f, 0 2px 6px #0000001f"
|
|
116
|
+
},
|
|
117
|
+
[".shadow-1"]: {
|
|
118
|
+
boxShadow: "0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
|
|
119
|
+
},
|
|
120
|
+
[".shadow-2"]: {
|
|
121
|
+
boxShadow: "0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)"
|
|
122
|
+
},
|
|
123
|
+
[".shadow-3"]: {
|
|
124
|
+
boxShadow: "0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)"
|
|
125
|
+
},
|
|
126
|
+
[".shadow-4"]: {
|
|
127
|
+
boxShadow: "0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)"
|
|
128
|
+
},
|
|
129
|
+
[".box-shadow-5"]: {
|
|
130
|
+
boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)"
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
);
|
|
110
135
|
const main = plugin.withOptions((args) => {
|
|
111
136
|
const configCss = args;
|
|
112
137
|
const fontStyles = {};
|
|
@@ -137,6 +162,7 @@ const main = plugin.withOptions((args) => {
|
|
|
137
162
|
return (api) => {
|
|
138
163
|
font(options).handler(api);
|
|
139
164
|
state(options).handler(api);
|
|
165
|
+
shadow.handler(api);
|
|
140
166
|
};
|
|
141
167
|
});
|
|
142
168
|
const createOrUpdateFile = (filePath, content) => {
|
|
@@ -211,23 +237,51 @@ const replaceFileContent = (filePath, searchPattern, replacement) => {
|
|
|
211
237
|
}
|
|
212
238
|
};
|
|
213
239
|
const findTailwindCssFile = (startDir, searchPattern) => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
240
|
+
console.log("Recherche du fichier contenant le motif...", startDir);
|
|
241
|
+
const stack = [startDir];
|
|
242
|
+
while (stack.length > 0) {
|
|
243
|
+
const currentDir = stack.pop();
|
|
244
|
+
const files = fs.readdirSync(currentDir);
|
|
245
|
+
for (const file of files) {
|
|
246
|
+
const filePath = path.join(currentDir, file);
|
|
247
|
+
let stats;
|
|
248
|
+
try {
|
|
249
|
+
stats = fs.statSync(filePath);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.error(`Erreur lors de l'accès à ${filePath}:`, error);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (stats.isDirectory()) {
|
|
255
|
+
if (file !== "node_modules") stack.push(filePath);
|
|
256
|
+
} else if (stats.isFile() && (file.endsWith(".css") || file.endsWith(".scss") || file.endsWith(".sass"))) {
|
|
257
|
+
try {
|
|
258
|
+
console.log(`Analyse du fichier : ${filePath}`);
|
|
259
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
260
|
+
if (content.match(searchPattern)) {
|
|
261
|
+
console.log("Fichier trouvé :", filePath);
|
|
262
|
+
return filePath;
|
|
263
|
+
}
|
|
264
|
+
} catch (readError) {
|
|
265
|
+
console.error(`Erreur lors de la lecture de ${filePath}:`, readError);
|
|
266
|
+
}
|
|
226
267
|
}
|
|
227
268
|
}
|
|
228
269
|
}
|
|
229
|
-
|
|
270
|
+
throw new Error(
|
|
271
|
+
`Impossible de trouver un fichier contenant "${searchPattern}" dans "${startDir}".`
|
|
272
|
+
);
|
|
230
273
|
};
|
|
274
|
+
function findProjectRoot(startPath) {
|
|
275
|
+
let currentPath = startPath;
|
|
276
|
+
while (!fs.existsSync(path.join(currentPath, "package.json"))) {
|
|
277
|
+
const parentPath = path.dirname(currentPath);
|
|
278
|
+
if (currentPath === parentPath) {
|
|
279
|
+
throw new Error("Impossible de localiser la racine du projet.");
|
|
280
|
+
}
|
|
281
|
+
currentPath = parentPath;
|
|
282
|
+
}
|
|
283
|
+
return currentPath;
|
|
284
|
+
}
|
|
231
285
|
class TailwindPlugin extends PluginAbstract {
|
|
232
286
|
constructor() {
|
|
233
287
|
super(...arguments);
|
|
@@ -244,18 +298,19 @@ class TailwindImplPlugin extends PluginImplAbstract {
|
|
|
244
298
|
});
|
|
245
299
|
}
|
|
246
300
|
onLoad() {
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
253
|
-
const replacement = `@import 'tailwindcss';
|
|
301
|
+
let udixioCssPath = this.options.styleFilePath;
|
|
302
|
+
const projectRoot = findProjectRoot(path__default.resolve());
|
|
303
|
+
if (!udixioCssPath) {
|
|
304
|
+
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
305
|
+
const replacement = `@import 'tailwindcss';
|
|
254
306
|
@import "./udixio.css";`;
|
|
255
|
-
|
|
256
|
-
|
|
307
|
+
const tailwindCssPath = findTailwindCssFile(projectRoot, searchPattern);
|
|
308
|
+
udixioCssPath = path__default.join(tailwindCssPath, "../udixio.css");
|
|
309
|
+
console.log("rrgfgt", tailwindCssPath, udixioCssPath);
|
|
310
|
+
if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
|
|
311
|
+
replaceFileContent(tailwindCssPath, searchPattern, replacement);
|
|
312
|
+
}
|
|
257
313
|
}
|
|
258
|
-
const cssFilePath = path__default.dirname(tailwindCssPath);
|
|
259
314
|
const colors = {};
|
|
260
315
|
for (const isDark of [false, true]) {
|
|
261
316
|
this.api.themes.update({ isDark });
|
|
@@ -278,7 +333,7 @@ class TailwindImplPlugin extends PluginImplAbstract {
|
|
|
278
333
|
).map(([key, value]) => `${key} ${value}`).join(", ")
|
|
279
334
|
};
|
|
280
335
|
createOrUpdateFile(
|
|
281
|
-
|
|
336
|
+
udixioCssPath,
|
|
282
337
|
`
|
|
283
338
|
@plugin "@udixio/tailwind" {
|
|
284
339
|
colorKeys: ${configCss.colorKeys};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwind.plugin.d.ts","sourceRoot":"","sources":["../src/tailwind.plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tailwind.plugin.d.ts","sourceRoot":"","sources":["../src/tailwind.plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAI/E,UAAU,qBAAqB;IAE7B,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;CAExB;AAED,qBAAa,cAAe,SAAQ,cAAc,CAChD,kBAAkB,EAClB,qBAAqB,CACtB;IACQ,YAAY,wBAAgB;IAC5B,IAAI,SAAc;IACzB,WAAW,4BAAsB;CAClC;AAED,cAAM,kBAAmB,SAAQ,kBAAkB,CAAC,qBAAqB,CAAC;IACxE,MAAM;IAMN,MAAM;CAiGP"}
|
package/package.json
CHANGED
package/src/file.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { replaceInFileSync } from 'replace-in-file';
|
|
4
|
+
import * as console from 'node:console';
|
|
4
5
|
|
|
5
6
|
export const createOrUpdateFile = (filePath: string, content: string): void => {
|
|
6
7
|
try {
|
|
@@ -97,30 +98,66 @@ export const replaceFileContent = (
|
|
|
97
98
|
};
|
|
98
99
|
export const findTailwindCssFile = (
|
|
99
100
|
startDir: string,
|
|
100
|
-
searchPattern: string,
|
|
101
|
-
): string |
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
101
|
+
searchPattern: RegExp | string,
|
|
102
|
+
): string | never => {
|
|
103
|
+
console.log('Recherche du fichier contenant le motif...', startDir);
|
|
104
|
+
|
|
105
|
+
const stack = [startDir]; // Pile pour éviter une récursion implicite.
|
|
106
|
+
|
|
107
|
+
while (stack.length > 0) {
|
|
108
|
+
const currentDir = stack.pop()!; // Récupérer un répertoire de la pile.
|
|
109
|
+
const files = fs.readdirSync(currentDir);
|
|
110
|
+
|
|
111
|
+
for (const file of files) {
|
|
112
|
+
const filePath = path.join(currentDir, file);
|
|
113
|
+
|
|
114
|
+
let stats: fs.Stats;
|
|
115
|
+
try {
|
|
116
|
+
stats = fs.statSync(filePath);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error(`Erreur lors de l'accès à ${filePath}:`, error);
|
|
119
|
+
continue; // Ignorer toute erreur d'accès.
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Ignorer le dossier `node_modules` et autres fichiers inutiles.
|
|
123
|
+
if (stats.isDirectory()) {
|
|
124
|
+
if (file !== 'node_modules') stack.push(filePath); // Empiler seulement les dossiers valides.
|
|
125
|
+
} else if (
|
|
126
|
+
stats.isFile() &&
|
|
127
|
+
(file.endsWith('.css') ||
|
|
128
|
+
file.endsWith('.scss') ||
|
|
129
|
+
file.endsWith('.sass'))
|
|
130
|
+
) {
|
|
131
|
+
try {
|
|
132
|
+
console.log(`Analyse du fichier : ${filePath}`);
|
|
133
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
134
|
+
if (content.match(searchPattern)) {
|
|
135
|
+
console.log('Fichier trouvé :', filePath);
|
|
136
|
+
return filePath; // Retour dès qu'un fichier valide est identifié.
|
|
137
|
+
}
|
|
138
|
+
} catch (readError) {
|
|
139
|
+
console.error(`Erreur lors de la lecture de ${filePath}:`, readError);
|
|
140
|
+
}
|
|
121
141
|
}
|
|
122
142
|
}
|
|
123
143
|
}
|
|
124
144
|
|
|
125
|
-
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Impossible de trouver un fichier contenant "${searchPattern}" dans "${startDir}".`,
|
|
147
|
+
);
|
|
126
148
|
};
|
|
149
|
+
|
|
150
|
+
export function findProjectRoot(startPath) {
|
|
151
|
+
let currentPath = startPath;
|
|
152
|
+
|
|
153
|
+
// Boucle jusqu'à trouver un package.json ou jusqu'à arriver à la racine du système
|
|
154
|
+
while (!fs.existsSync(path.join(currentPath, 'package.json'))) {
|
|
155
|
+
const parentPath = path.dirname(currentPath);
|
|
156
|
+
if (currentPath === parentPath) {
|
|
157
|
+
throw new Error('Impossible de localiser la racine du projet.');
|
|
158
|
+
}
|
|
159
|
+
currentPath = parentPath;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return currentPath;
|
|
163
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
state,
|
|
6
6
|
StateOptions,
|
|
7
7
|
} from './plugins-tailwind';
|
|
8
|
+
import { shadow } from './plugins-tailwind/shadow';
|
|
8
9
|
|
|
9
10
|
export type ConfigJs = FontPluginOptions & StateOptions;
|
|
10
11
|
export type ConfigCss = {
|
|
@@ -48,5 +49,6 @@ export const main = plugin.withOptions<ConfigJs>((args) => {
|
|
|
48
49
|
return (api: PluginAPI) => {
|
|
49
50
|
font(options).handler(api);
|
|
50
51
|
state(options).handler(api);
|
|
52
|
+
shadow.handler(api);
|
|
51
53
|
};
|
|
52
54
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import plugin, { PluginAPI } from 'tailwindcss/plugin';
|
|
2
|
+
|
|
3
|
+
export const shadow = plugin(
|
|
4
|
+
({ addUtilities }: Pick<PluginAPI, 'addUtilities'>) => {
|
|
5
|
+
addUtilities({
|
|
6
|
+
['.shadow']: {
|
|
7
|
+
boxShadow:
|
|
8
|
+
'0 4px 10px #00000008, 0 0 2px #0000000f, 0 2px 6px #0000001f',
|
|
9
|
+
},
|
|
10
|
+
['.shadow-1']: {
|
|
11
|
+
boxShadow:
|
|
12
|
+
'0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)',
|
|
13
|
+
},
|
|
14
|
+
['.shadow-2']: {
|
|
15
|
+
boxShadow:
|
|
16
|
+
'0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)',
|
|
17
|
+
},
|
|
18
|
+
['.shadow-3']: {
|
|
19
|
+
boxShadow:
|
|
20
|
+
'0px 1px 3px 0px rgba(0, 0, 0, 0.30), 0px 4px 8px 3px rgba(0, 0, 0, 0.15)',
|
|
21
|
+
},
|
|
22
|
+
['.shadow-4']: {
|
|
23
|
+
boxShadow:
|
|
24
|
+
'0px 2px 3px 0px rgba(0, 0, 0, 0.30), 0px 6px 10px 4px rgba(0, 0, 0, 0.15)',
|
|
25
|
+
},
|
|
26
|
+
['.box-shadow-5']: {
|
|
27
|
+
boxShadow:
|
|
28
|
+
'0px 4px 4px 0px rgba(0, 0, 0, 0.30), 0px 8px 12px 6px rgba(0, 0, 0, 0.15)',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
);
|
package/src/tailwind.plugin.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createOrUpdateFile,
|
|
3
|
+
findProjectRoot,
|
|
3
4
|
findTailwindCssFile,
|
|
4
5
|
getFileContent,
|
|
5
6
|
replaceFileContent,
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import { FontPlugin, PluginAbstract, PluginImplAbstract } from '@udixio/theme';
|
|
9
10
|
import { ConfigCss } from './main';
|
|
11
|
+
import * as console from 'node:console';
|
|
10
12
|
|
|
11
13
|
interface TailwindPluginOptions {
|
|
12
14
|
// darkMode?: 'class' | 'media';
|
|
@@ -32,22 +34,23 @@ class TailwindImplPlugin extends PluginImplAbstract<TailwindPluginOptions> {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
onLoad() {
|
|
35
|
-
|
|
37
|
+
let udixioCssPath = this.options.styleFilePath;
|
|
36
38
|
|
|
37
|
-
const
|
|
38
|
-
this.options.styleFilePath ??
|
|
39
|
-
findTailwindCssFile(process.cwd(), searchKeyword);
|
|
40
|
-
if (!tailwindCssPath) {
|
|
41
|
-
throw new Error('The style file containing tailwind was not found.');
|
|
42
|
-
}
|
|
43
|
-
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
44
|
-
const replacement = `@import 'tailwindcss';\n@import "./udixio.css";`;
|
|
39
|
+
const projectRoot = findProjectRoot(path.resolve());
|
|
45
40
|
|
|
46
|
-
if (!
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
if (!udixioCssPath) {
|
|
42
|
+
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
43
|
+
const replacement = `@import 'tailwindcss';\n@import "./udixio.css";`;
|
|
44
|
+
|
|
45
|
+
const tailwindCssPath = findTailwindCssFile(projectRoot, searchPattern);
|
|
46
|
+
udixioCssPath = path.join(tailwindCssPath, '../udixio.css');
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
console.log('rrgfgt', tailwindCssPath, udixioCssPath);
|
|
49
|
+
|
|
50
|
+
if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
|
|
51
|
+
replaceFileContent(tailwindCssPath, searchPattern, replacement);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
const colors: Record<
|
|
53
56
|
string,
|
|
@@ -95,7 +98,7 @@ class TailwindImplPlugin extends PluginImplAbstract<TailwindPluginOptions> {
|
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
createOrUpdateFile(
|
|
98
|
-
|
|
101
|
+
udixioCssPath,
|
|
99
102
|
`
|
|
100
103
|
@plugin "@udixio/tailwind" {
|
|
101
104
|
colorKeys: ${configCss.colorKeys};
|