@unocss/cli 0.27.6 → 0.28.2

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
@@ -77,8 +77,8 @@ import { defineConfig } from 'unocss'
77
77
 
78
78
  export default defineConfig({
79
79
  shortcuts: [
80
- { 'box': 'max-w-7xl mx-auto bg-gray-100 rounded-md shadow-sm p-4' }
81
- ]
80
+ { box: 'max-w-7xl mx-auto bg-gray-100 rounded-md shadow-sm p-4' },
81
+ ],
82
82
  })
83
83
  ```
84
84
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const promises = require('fs/promises');
3
+ const fs = require('fs');
4
4
  const pathe = require('pathe');
5
5
  const fg = require('fast-glob');
6
6
  const consola = require('consola');
@@ -15,7 +15,7 @@ const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
15
15
  const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
16
16
  const presetUno__default = /*#__PURE__*/_interopDefaultLegacy(presetUno);
17
17
 
18
- const version = "0.27.6";
18
+ const version = "0.28.2";
19
19
 
20
20
  class PrettyError extends Error {
21
21
  constructor(message) {
@@ -71,7 +71,10 @@ const fileCache = /* @__PURE__ */ new Map();
71
71
  async function generate(options) {
72
72
  const outFile = options.outFile ?? pathe.resolve(process.cwd(), "uno.css");
73
73
  const { css, matched } = await uno.generate([...fileCache].join("\n"));
74
- await promises.writeFile(outFile, css, "utf-8");
74
+ const dir = pathe.dirname(outFile);
75
+ if (!fs.existsSync(dir))
76
+ await fs.promises.mkdir(dir, { recursive: true });
77
+ await fs.promises.writeFile(outFile, css, "utf-8");
75
78
  if (!options.watch) {
76
79
  consola__default.success(`${[...matched].length} utilities generated to ${colorette.cyan(pathe.relative(process.cwd(), outFile))}
77
80
  `);
@@ -90,7 +93,7 @@ async function build(_options) {
90
93
  uno = core.createGenerator(config$1, defaultConfig);
91
94
  const files = await fg__default(options.patterns);
92
95
  await Promise.all(files.map(async (file) => {
93
- fileCache.set(file, await promises.readFile(file, "utf8"));
96
+ fileCache.set(file, await fs.promises.readFile(file, "utf8"));
94
97
  }));
95
98
  consola__default.log(colorette.green(`${name} v${version}`));
96
99
  consola__default.start(`UnoCSS ${options.watch ? "in watch mode..." : "for production..."}`);
@@ -120,7 +123,7 @@ async function build(_options) {
120
123
  if (type.startsWith("unlink"))
121
124
  fileCache.delete(file);
122
125
  else
123
- fileCache.set(file, await promises.readFile(file, "utf8"));
126
+ fileCache.set(file, await fs.promises.readFile(file, "utf8"));
124
127
  }
125
128
  debouncedBuild();
126
129
  });
@@ -1,5 +1,5 @@
1
- import { writeFile, readFile } from 'fs/promises';
2
- import { resolve, relative, basename } from 'pathe';
1
+ import { existsSync, promises } from 'fs';
2
+ import { resolve, dirname, relative, basename } from 'pathe';
3
3
  import fg from 'fast-glob';
4
4
  import consola from 'consola';
5
5
  import { cyan, green, dim } from 'colorette';
@@ -7,7 +7,7 @@ import { createGenerator, toArray } from '@unocss/core';
7
7
  import { createConfigLoader } from '@unocss/config';
8
8
  import presetUno from '@unocss/preset-uno';
9
9
 
10
- const version = "0.27.6";
10
+ const version = "0.28.2";
11
11
 
12
12
  class PrettyError extends Error {
13
13
  constructor(message) {
@@ -63,7 +63,10 @@ const fileCache = /* @__PURE__ */ new Map();
63
63
  async function generate(options) {
64
64
  const outFile = options.outFile ?? resolve(process.cwd(), "uno.css");
65
65
  const { css, matched } = await uno.generate([...fileCache].join("\n"));
66
- await writeFile(outFile, css, "utf-8");
66
+ const dir = dirname(outFile);
67
+ if (!existsSync(dir))
68
+ await promises.mkdir(dir, { recursive: true });
69
+ await promises.writeFile(outFile, css, "utf-8");
67
70
  if (!options.watch) {
68
71
  consola.success(`${[...matched].length} utilities generated to ${cyan(relative(process.cwd(), outFile))}
69
72
  `);
@@ -82,7 +85,7 @@ async function build(_options) {
82
85
  uno = createGenerator(config, defaultConfig);
83
86
  const files = await fg(options.patterns);
84
87
  await Promise.all(files.map(async (file) => {
85
- fileCache.set(file, await readFile(file, "utf8"));
88
+ fileCache.set(file, await promises.readFile(file, "utf8"));
86
89
  }));
87
90
  consola.log(green(`${name} v${version}`));
88
91
  consola.start(`UnoCSS ${options.watch ? "in watch mode..." : "for production..."}`);
@@ -112,7 +115,7 @@ async function build(_options) {
112
115
  if (type.startsWith("unlink"))
113
116
  fileCache.delete(file);
114
117
  else
115
- fileCache.set(file, await readFile(file, "utf8"));
118
+ fileCache.set(file, await promises.readFile(file, "utf8"));
116
119
  }
117
120
  debouncedBuild();
118
121
  });
package/dist/cli.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const cac = require('cac');
4
4
  const index = require('./chunks/index.cjs');
5
- require('fs/promises');
5
+ require('fs');
6
6
  require('pathe');
7
7
  require('fast-glob');
8
8
  require('consola');
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cac } from 'cac';
2
2
  import { h as handleError, b as build, v as version } from './chunks/index.mjs';
3
- import 'fs/promises';
3
+ import 'fs';
4
4
  import 'pathe';
5
5
  import 'fast-glob';
6
6
  import 'consola';
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('fs/promises');
5
+ require('fs');
6
6
  require('pathe');
7
7
  require('fast-glob');
8
8
  require('consola');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import 'fs/promises';
1
+ import 'fs';
2
2
  import 'pathe';
3
3
  import 'fast-glob';
4
4
  import 'consola';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/cli",
3
- "version": "0.27.6",
3
+ "version": "0.28.2",
4
4
  "description": "CLI for UnoCSS",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/unocss/unocss/tree/main/packages/cli#readme",
@@ -8,34 +8,34 @@
8
8
  "url": "https://github.com/unocss/unocss/issues"
9
9
  },
10
10
  "license": "MIT",
11
+ "author": {
12
+ "name": "Johann Schopplich",
13
+ "email": "pkg@johannschopplich.com",
14
+ "url": "https://johannschopplich.com"
15
+ },
11
16
  "repository": {
12
17
  "type": "git",
13
18
  "url": "git+https://github.com/unocss/unocss.git",
14
19
  "directory": "packages/cli"
15
20
  },
16
21
  "funding": "https://github.com/sponsors/antfu",
17
- "author": {
18
- "name": "Johann Schopplich",
19
- "email": "pkg@johannschopplich.com",
20
- "url": "https://johannschopplich.com"
21
- },
22
+ "main": "./dist/index.cjs",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": "./dist/index.cjs",
22
25
  "files": [
23
26
  "bin",
24
27
  "dist"
25
28
  ],
26
- "exports": "./dist/index.cjs",
27
- "main": "./dist/index.cjs",
28
29
  "bin": {
29
30
  "unocss": "./bin/unocss.cjs"
30
31
  },
31
- "types": "./dist/index.d.ts",
32
32
  "engines": {
33
33
  "node": ">=14"
34
34
  },
35
35
  "dependencies": {
36
- "@unocss/config": "0.27.6",
37
- "@unocss/core": "0.27.6",
38
- "@unocss/preset-uno": "0.27.6",
36
+ "@unocss/config": "0.28.2",
37
+ "@unocss/core": "0.28.2",
38
+ "@unocss/preset-uno": "0.28.2",
39
39
  "cac": "^6.7.12",
40
40
  "chokidar": "^3.5.3",
41
41
  "colorette": "^2.0.16",
@@ -46,5 +46,6 @@
46
46
  "scripts": {
47
47
  "build": "unbuild",
48
48
  "stub": "unbuild --stub"
49
- }
49
+ },
50
+ "readme": "# @unocss/cli\n\nThe CLI for UnoCSS. A perfect fit for traditional backends.\n\n## Key Features\n\n- 🍱 Suited for traditional backends like Laravel or Kirby\n- 👀 [Watch mode](#watch) included\n- 🔌 Supports custom configurations via [`unocss.config.js`](#unocssconfigjs-support)\n\n## Requirements\n\n- Node 14+ (Node 16 recommended)\n\n## Installation\n\nThis package is shipped with the `unocss` package:\n\n```bash\nnpm i -D unocss\n```\n\nYou can also install it standalone:\n\n```bash\nnpm i -D @unocss/cli\n```\n\n## Usage\n\nYou can also pass multiple glob patterns to `@unocss/cli`:\n\n```bash\nunocss \"site/snippets/**/*.php\" \"site/templates/**/*.php\"\n```\n\nExample package configuration:\n\n> ℹ️ Make sure to add escaped quotes to your npm script glob patterns.\n\n```json\n{\n \"scripts\": {\n \"dev\": \"unocss \\\"site/{snippets,templates}/**/*.php\\\" --watch\",\n \"build\": \"unocss \\\"site/{snippets,templates}/**/*.php\\\"\"\n },\n \"devDependencies\": {\n \"@unocss/cli\": \"latest\"\n }\n}\n```\n\n### Development\n\nAdd the `--watch` (or `-w`) flag to enable watching for file changes:\n\n```bash\nunocss \"site/{snippets,templates}/**/*.php\" --watch\n```\n\n### Production\n\n```bash\nunocss \"site/{snippets,templates}/**/*.php\"\n```\n\nThe final `uno.css` will be generated to the current directory by default.\n\n## Built-in Features\n\n### Configurations\n\nCreate a `unocss.config.js` or `unocss.config.ts` configuration file the root-level of your project to customize UnoCSS.\n\n```js\nimport { defineConfig } from 'unocss'\n\nexport default defineConfig({\n shortcuts: [\n { box: 'max-w-7xl mx-auto bg-gray-100 rounded-md shadow-sm p-4' },\n ],\n})\n```\n\nFor a list of options, head over to the [UnoCSS configurations](https://github.com/unocss/unocss#configurations) docs.\n\n## CLI Options\n\n> Inspect all available options with `unocss --help`.\n\n### `--out-file`\n\nThe output filename for the generated UnoCSS file. Defaults to `uno.css` in the current working directory.\n\n### `--watch`\n\nIndicates if the files found by the glob pattern should be watched.\n\n## License\n\nMIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)\n\nMIT License © 2021-PRESENT [Johann Schopplich](https://github.com/johannschopplich)\n"
50
51
  }