@unocss/cli 0.44.7 → 0.45.4
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/chunks/index.mjs +35 -16
- package/package.json +5 -5
package/dist/chunks/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { createGenerator, toArray } from '@unocss/core';
|
|
|
8
8
|
import { loadConfig } from '@unocss/config';
|
|
9
9
|
import presetUno from '@unocss/preset-uno';
|
|
10
10
|
|
|
11
|
-
const version = "0.
|
|
11
|
+
const version = "0.45.4";
|
|
12
12
|
|
|
13
13
|
class PrettyError extends Error {
|
|
14
14
|
constructor(message) {
|
|
@@ -36,7 +36,9 @@ const defaultConfig = {
|
|
|
36
36
|
const name = "unocss";
|
|
37
37
|
async function resolveOptions(options) {
|
|
38
38
|
if (!options.patterns?.length) {
|
|
39
|
-
throw new PrettyError(
|
|
39
|
+
throw new PrettyError(
|
|
40
|
+
`No glob patterns, try ${cyan(`${name} <path/to/**/*>`)}`
|
|
41
|
+
);
|
|
40
42
|
}
|
|
41
43
|
return options;
|
|
42
44
|
}
|
|
@@ -45,16 +47,24 @@ async function build(_options) {
|
|
|
45
47
|
const cwd = _options.cwd || process.cwd();
|
|
46
48
|
const options = await resolveOptions(_options);
|
|
47
49
|
const { config, sources: configSources } = await loadConfig(cwd, options.config);
|
|
48
|
-
const uno = createGenerator(
|
|
50
|
+
const uno = createGenerator(
|
|
51
|
+
config,
|
|
52
|
+
defaultConfig
|
|
53
|
+
);
|
|
49
54
|
const files = await fg(options.patterns, { cwd, absolute: true });
|
|
50
|
-
await Promise.all(
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
await Promise.all(
|
|
56
|
+
files.map(async (file) => {
|
|
57
|
+
fileCache.set(file, await promises.readFile(file, "utf8"));
|
|
58
|
+
})
|
|
59
|
+
);
|
|
53
60
|
consola.log(green(`${name} v${version}`));
|
|
54
61
|
consola.start(`UnoCSS ${options.watch ? "in watch mode..." : "for production..."}`);
|
|
55
|
-
const debouncedBuild = debounce(
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
const debouncedBuild = debounce(
|
|
63
|
+
async () => {
|
|
64
|
+
generate(options).catch(handleError);
|
|
65
|
+
},
|
|
66
|
+
100
|
|
67
|
+
);
|
|
58
68
|
const startWatcher = async () => {
|
|
59
69
|
if (!options.watch)
|
|
60
70
|
return;
|
|
@@ -83,23 +93,32 @@ async function build(_options) {
|
|
|
83
93
|
}
|
|
84
94
|
debouncedBuild();
|
|
85
95
|
});
|
|
86
|
-
consola.info(
|
|
96
|
+
consola.info(
|
|
97
|
+
`Watching for changes in ${toArray(patterns).map((i) => cyan(i)).join(", ")}`
|
|
98
|
+
);
|
|
87
99
|
};
|
|
88
100
|
await generate(options);
|
|
89
101
|
startWatcher();
|
|
90
102
|
async function generate(options2) {
|
|
91
103
|
const outFile = resolve(options2.cwd || process.cwd(), options2.outFile ?? "uno.css");
|
|
92
|
-
const { css, matched } = await uno.generate(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
const { css, matched } = await uno.generate(
|
|
105
|
+
[...fileCache].join("\n"),
|
|
106
|
+
{
|
|
107
|
+
preflights: options2.preflights,
|
|
108
|
+
minify: options2.minify
|
|
109
|
+
}
|
|
110
|
+
);
|
|
96
111
|
const dir = dirname(outFile);
|
|
97
112
|
if (!existsSync(dir))
|
|
98
113
|
await promises.mkdir(dir, { recursive: true });
|
|
99
114
|
await promises.writeFile(outFile, css, "utf-8");
|
|
100
115
|
if (!options2.watch) {
|
|
101
|
-
consola.success(
|
|
102
|
-
|
|
116
|
+
consola.success(
|
|
117
|
+
`${[...matched].length} utilities generated to ${cyan(
|
|
118
|
+
relative(process.cwd(), outFile)
|
|
119
|
+
)}
|
|
120
|
+
`
|
|
121
|
+
);
|
|
103
122
|
}
|
|
104
123
|
}
|
|
105
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.4",
|
|
4
4
|
"description": "CLI for UnoCSS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Johann Schopplich",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"node": ">=14"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@unocss/config": "0.
|
|
43
|
-
"@unocss/core": "0.
|
|
44
|
-
"@unocss/preset-uno": "0.
|
|
42
|
+
"@unocss/config": "0.45.4",
|
|
43
|
+
"@unocss/core": "0.45.4",
|
|
44
|
+
"@unocss/preset-uno": "0.45.4",
|
|
45
45
|
"cac": "^6.7.12",
|
|
46
46
|
"chokidar": "^3.5.3",
|
|
47
47
|
"colorette": "^2.0.19",
|
|
48
48
|
"consola": "^2.15.3",
|
|
49
49
|
"fast-glob": "^3.2.11",
|
|
50
|
-
"pathe": "^0.3.
|
|
50
|
+
"pathe": "^0.3.3",
|
|
51
51
|
"perfect-debounce": "^0.1.3"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|