@kitschpatrol/cspell-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 +25 -0
- package/main.json +2 -0
- package/package.json +6 -2
- package/readme.md +4 -2
- package/init.js +0 -22
package/cli.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
await (async function main() {
|
|
8
|
+
const options = ['init', '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(`[CSpell] 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.check) {
|
|
23
|
+
await $`cspell --quiet .`;
|
|
24
|
+
}
|
|
25
|
+
})();
|
package/main.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/cspell-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CSPell config for @kitschpatrol/shared-config",
|
|
6
6
|
"repository": {
|
|
@@ -23,12 +23,16 @@
|
|
|
23
23
|
"pnpm": ">=8.0.0"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
|
-
"cspell-config
|
|
26
|
+
"cspell-config": "./cli.js"
|
|
27
27
|
},
|
|
28
28
|
"main": "main.json",
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"cspell": "^8.1.3"
|
|
31
31
|
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"minimist": "^1.2.8",
|
|
34
|
+
"zx": "^7.2.3"
|
|
35
|
+
},
|
|
32
36
|
"publishConfig": {
|
|
33
37
|
"access": "public"
|
|
34
38
|
}
|
package/readme.md
CHANGED
|
@@ -25,19 +25,21 @@ To use just this CSpell config in isolation:
|
|
|
25
25
|
3. Add the starter `.cspell.json` file to your project root, and add any customizations you'd like:
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
pnpm exec cspell-config
|
|
28
|
+
pnpm exec cspell-config --init
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
33
|
The CSpell 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
|
-
"spellcheck": "cspell --
|
|
42
|
+
"spellcheck": "cspell-config --check"
|
|
41
43
|
}
|
|
42
44
|
...
|
|
43
45
|
```
|
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
|
-
}
|