@nsis/dent-cli 0.2.0 → 0.3.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/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/cli.d.mts +1 -0
- package/bin/cli.mjs +6 -0
- package/package.json +51 -61
- package/bin/cli.d.ts +0 -2
- package/bin/cli.js +0 -15
- package/index.mjs +0 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## Prerequisites
|
|
10
10
|
|
|
11
|
-
This is a TypeScript
|
|
11
|
+
This is a TypeScript application that depends on a [NodeJS](https://nodejs.org) runtime installed on your computer.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
package/bin/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{promises as e}from"node:fs";import{dirname as t,resolve as n}from"node:path";import{fileURLToPath as r}from"node:url";import{createFormatter as i}from"@nsis/dent";import{Command as a}from"commander";import{glob as o}from"glob";import s from"log-symbols";import c from"picocolors";await l();async function l(){let t=new a,n=await u();t.version(n).description(`CLI tool to format NSIS scripts`).arguments(`<file...>`).option(`--eol <"crlf"|"lf">`,`control how line-breaks are represented`,e=>{if(![`crlf`,`lf`].includes(e))throw Error(`Invalid value for --eol: "${e}". Expected "crlf" or "lf".`);return e}).option(`-i, --indent-size <number>`,`number of units per indentation level`,e=>Number.parseInt(e,10),2).option(`-s, --use-spaces`,`indent with spaces instead of tabs`,!1).option(`--trim`,`trim empty lines`,!0).option(`--write`,`edit files in-place`,!1).option(`--quiet`,`suppress output`,!1).option(`--debug`,`prints additional debug messages`,!1).parse(process.argv);let r=t.opts(),l=Array.isArray(t.args)?t.args:[t.args];l.length||t.help(),r.debug&&console.log(`
|
|
3
|
+
CLI parameters:`,{args:l,options:r});let d=i({endOfLines:r.eol,indentSize:r.indentSize,trimEmptyLines:r.trim,useTabs:!r.useSpaces}),f=await o(l),p=r.write&&!r.quiet;p&&!r.debug&&console.log(),console.time(`
|
|
4
|
+
Completed`),await Promise.all(f.map(async t=>{p&&console.time(`${s.success} ${c.blue(t)}`);let n=(await e.readFile(t)).toString(),i=d(n);if(r.debug&&console.log(`
|
|
5
|
+
Conversion:`,{raw:n,formatted:i}),r.write)try{await e.writeFile(t,i,{encoding:`utf-8`}),p&&console.timeEnd(`${s.success} ${c.blue(t)}`)}catch(e){p&&console.error(`${s.error} ${c.blue(t)} ${e instanceof Error?e.message:String(e)}`)}else console.log(i)})),p&&console.timeEnd(`
|
|
6
|
+
Completed`)}async function u(){let i=t(r(import.meta.url)),{version:a}=JSON.parse(await e.readFile(n(i,`../package.json`),`utf8`));return a||`dev`}export{};
|
package/package.json
CHANGED
|
@@ -1,62 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"lint-staged": "^15.2.0",
|
|
54
|
-
"npm-run-all2": "^6.1.1",
|
|
55
|
-
"tslib": "^2.6.2",
|
|
56
|
-
"tsup": "^8.0.1",
|
|
57
|
-
"typescript": "^5.3.3"
|
|
58
|
-
},
|
|
59
|
-
"lint-staged": {
|
|
60
|
-
"*.(json|ts)": "eslint --cache --fix"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
2
|
+
"name": "@nsis/dent-cli",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "An opinionated code formatter for NSIS scripts",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin/",
|
|
8
|
+
"LICENSE",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"bin": {
|
|
13
|
+
"dent": "./bin/cli.mjs"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.0.0"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/idleberg/node-dent-cli.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"nsis",
|
|
24
|
+
"formatter"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@nsis/dent": "^0.4.1",
|
|
28
|
+
"commander": "^14.0.3",
|
|
29
|
+
"glob": "^13.0.6",
|
|
30
|
+
"log-symbols": "^7.0.1",
|
|
31
|
+
"picocolors": "^1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@idleberg/configs": "^0.4.2",
|
|
35
|
+
"@types/node": "^18.19.3",
|
|
36
|
+
"concurrently": "^9.2.1",
|
|
37
|
+
"np": "^11.0.2",
|
|
38
|
+
"tsdown": "^0.20.3",
|
|
39
|
+
"typescript": "^5.3.3"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"dev": "tsdown --watch",
|
|
44
|
+
"lint": "concurrently --prefix-colors blue,green,magenta npm:lint:*",
|
|
45
|
+
"lint:biome": "biome check",
|
|
46
|
+
"lint:e18e": "e18e-cli analyze",
|
|
47
|
+
"publish:jsr": "deno publish",
|
|
48
|
+
"publish:npm": "np",
|
|
49
|
+
"start": "npm run build -- --watch",
|
|
50
|
+
"test": "echo \"Tests pending\" && exit 0"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/bin/cli.d.ts
DELETED
package/bin/cli.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname, resolve } from 'node:path';
|
|
4
|
-
import { promises } from 'node:fs';
|
|
5
|
-
import { createFormatter } from '@nsis/dent';
|
|
6
|
-
import { glob } from 'glob';
|
|
7
|
-
import l from 'log-symbols';
|
|
8
|
-
import r from 'picocolors';
|
|
9
|
-
|
|
10
|
-
await C();async function C(){let t=new Command,n=await S();t.version(n).description("CLI tool to format NSIS scripts").arguments("<file...>").option('--eol <"crlf"|"lf">',"control how line-breaks are represented",o=>["crlf","lf"].includes(o)).option("-i, --indent-size <number>","number of units per indentation level",o=>parseInt(o,10),2).option("-s, --use-spaces","indent with spaces instead of tabs",!1).option("--trim","trim empty lines",!0).option("--write","edit files in-place",!1).option("--quiet","suppress output",!1).option("--debug","prints additional debug messages",!1).parse(process.argv);let e=t.opts(),i=Array.isArray(t.args)?t.args:[t.args];i.length||t.help(),e.debug&&console.log(`
|
|
11
|
-
CLI parameters:`,{args:i,options:e});let f=createFormatter({endOfLines:e.eol,indentSize:e.indent,trimEmptyLines:e.trim,useTabs:!e.useSpaces}),d=await glob(i),s=e.write&&!e.quiet;s&&!e.debug&&console.log(),console.time(`
|
|
12
|
-
Completed`),await Promise.all(d.map(async o=>{s&&console.time(`${l.success} ${r.blue(o)}`);let p=(await promises.readFile(o)).toString(),a=f(p);if(e.debug&&console.log(`
|
|
13
|
-
Conversion:`,{raw:p,formatted:a}),e.write)try{await promises.writeFile(o,a,{encoding:"utf-8"}),s&&console.timeEnd(`${l.success} ${r.blue(o)}`);}catch(m){s&&console.error(`${l.error} ${r.blue(o)}
|
|
14
|
-
${r.dim(m instanceof Error?m.message:m)}`);}else console.log(a);})),s&&console.timeEnd(`
|
|
15
|
-
Completed`);}async function S(){let t=fileURLToPath(import.meta.url),n=dirname(t),{version:e}=JSON.parse(await promises.readFile(resolve(n,"../package.json"),"utf8"));return e||"dev"}
|
package/index.mjs
DELETED