@kitschpatrol/prettier-config 1.0.1 → 2.0.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/cli.js +29 -0
- package/init/.prettierignore +1 -1
- package/package.json +5 -3
- package/readme.md +6 -4
- package/init.js +0 -22
package/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env zx
|
|
2
|
+
/* eslint-disable unicorn/prefer-module */
|
|
3
|
+
import minimist from 'minimist';
|
|
4
|
+
import { $, path } from 'zx';
|
|
5
|
+
import 'zx/globals';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const options = ['init', 'fix', 'check'];
|
|
9
|
+
const args = minimist(process.argv.slice(2), {
|
|
10
|
+
boolean: options,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const argumentCount = options.reduce((count, argument) => count + (args[argument] ? 1 : 0), 0);
|
|
14
|
+
if (argumentCount !== 1) {
|
|
15
|
+
console.error(`[Prettier] Please provide exactly one of ${options.map((opt) => `--${opt}`).join(' or ')}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
process.env.FORCE_COLOR = '1';
|
|
20
|
+
if (args.init) {
|
|
21
|
+
await $`cp -Ri ${path.join(__dirname, 'init')}/. ${process.cwd()}`.nothrow();
|
|
22
|
+
} else if (args.fix) {
|
|
23
|
+
await $`prettier --log-level warn --plugin=@prettier/plugin-php --plugin=@prettier/plugin-ruby --plugin=@prettier/plugin-xml --plugin=prettier-plugin-astro --plugin=prettier-plugin-pkg --plugin=prettier-plugin-sh --plugin=prettier-plugin-sql --plugin=prettier-plugin-svelte --plugin=prettier-plugin-tailwindcss --plugin=prettier-plugin-toml . --write`;
|
|
24
|
+
} else if (args.check) {
|
|
25
|
+
await $`prettier --log-level warn --plugin=@prettier/plugin-php --plugin=@prettier/plugin-ruby --plugin=@prettier/plugin-xml --plugin=prettier-plugin-astro --plugin=prettier-plugin-pkg --plugin=prettier-plugin-sh --plugin=prettier-plugin-sql --plugin=prettier-plugin-svelte --plugin=prettier-plugin-tailwindcss --plugin=prettier-plugin-toml . --check`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await main();
|
package/init/.prettierignore
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
pnpm-lock.yaml
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/prettier-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Prettier config for @kitschpatrol/shared-config",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"pnpm": ">=8.0.0"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
|
-
"prettier-config
|
|
26
|
+
"prettier-config": "./cli.js"
|
|
27
27
|
},
|
|
28
28
|
"main": "main.js",
|
|
29
29
|
"peerDependencies": {
|
|
@@ -33,13 +33,15 @@
|
|
|
33
33
|
"@prettier/plugin-php": "^0.21.0",
|
|
34
34
|
"@prettier/plugin-ruby": "^4.0.3",
|
|
35
35
|
"@prettier/plugin-xml": "^3.2.2",
|
|
36
|
+
"minimist": "^1.2.8",
|
|
36
37
|
"prettier-plugin-astro": "^0.12.2",
|
|
37
38
|
"prettier-plugin-pkg": "^0.18.0",
|
|
38
39
|
"prettier-plugin-sh": "^0.13.1",
|
|
39
40
|
"prettier-plugin-sql": "^0.17.1",
|
|
40
41
|
"prettier-plugin-svelte": "^3.1.2",
|
|
41
42
|
"prettier-plugin-tailwindcss": "^0.5.9",
|
|
42
|
-
"prettier-plugin-toml": "^2.0.1"
|
|
43
|
+
"prettier-plugin-toml": "^2.0.1",
|
|
44
|
+
"zx": "^7.2.3"
|
|
43
45
|
},
|
|
44
46
|
"publishConfig": {
|
|
45
47
|
"access": "public"
|
package/readme.md
CHANGED
|
@@ -25,25 +25,27 @@ To use just this Prettier config in isolation:
|
|
|
25
25
|
3. Add the starter `.prettierrc.js` and `.prettierignore` files to your project root, and add any customizations you'd like:
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
pnpm exec prettier-config
|
|
28
|
+
pnpm exec prettier-config --init
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
33
|
The Prettier binary should be picked up automatically by VSCode plugins.
|
|
34
34
|
|
|
35
|
+
You can call it directly, or use the script bundled with the config.
|
|
36
|
+
|
|
35
37
|
Integrate with your `package.json` scripts as you see fit, for example:
|
|
36
38
|
|
|
37
39
|
```json
|
|
38
40
|
...
|
|
39
41
|
"scripts": {
|
|
40
|
-
"lint": "prettier --check
|
|
41
|
-
"format": "prettier --
|
|
42
|
+
"lint": "prettier-config --check"
|
|
43
|
+
"format": "prettier-config --fix"
|
|
42
44
|
}
|
|
43
45
|
...
|
|
44
46
|
```
|
|
45
47
|
|
|
46
|
-
You might need to pass certain plugins in explicitly. The `shared-config
|
|
48
|
+
You might need to pass certain plugins in explicitly. The `shared-config --fix` and `shared-config --lint` scripts take care of this for you.
|
|
47
49
|
|
|
48
50
|
## Ruby support
|
|
49
51
|
|
package/init.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import console from 'node:console';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
|
|
9
|
-
const sourceDirectory = path.join(__dirname, 'init');
|
|
10
|
-
const destinationDirectory = process.cwd(); // (project root)
|
|
11
|
-
|
|
12
|
-
for (const file of fs.readdirSync(sourceDirectory)) {
|
|
13
|
-
const sourcePath = path.join(sourceDirectory, file);
|
|
14
|
-
const destinationPath = path.join(destinationDirectory, file);
|
|
15
|
-
|
|
16
|
-
if (fs.existsSync(destinationPath)) {
|
|
17
|
-
console.log(`${file} already exists in project root, skipping.`);
|
|
18
|
-
} else {
|
|
19
|
-
fs.copyFileSync(sourcePath, destinationPath);
|
|
20
|
-
console.log(`Copied ${file} to project root.`);
|
|
21
|
-
}
|
|
22
|
-
}
|