@nsis/dent-cli 0.4.4 → 0.5.1

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
@@ -6,37 +6,48 @@
6
6
  [![Version](https://img.shields.io/npm/v/@nsis/dent-cli?style=for-the-badge)](https://www.npmjs.org/package/@nsis/dent-cli)
7
7
  [![Build](https://img.shields.io/github/actions/workflow/status/idleberg/node-dent-cli/default.yml?style=for-the-badge)](https://github.com/idleberg/node-dent-cli/actions)
8
8
 
9
- ## Prerequisites
9
+ ## Installation
10
10
 
11
- This is a TypeScript application that depends on a [NodeJS](https://nodejs.org) runtime installed on your computer.
11
+ ### Node.js
12
12
 
13
- ## Usage
14
-
15
- ### Installation
13
+ For single-use, use `npx` to download and run the CLI:
16
14
 
17
- > [!TIP]
18
- >
19
- > If you don't use a JavaScript runtime such as Node.js, download a binary of the [latest version](https://github.com/idleberg/node-dent-cli/releases/latest) for Windows.
15
+ ```sh
16
+ $ npx -y @nsis/dent-cli --help
17
+ ```
20
18
 
21
- You could install the `dent` CLI globally
19
+ Or, if you prefer to install the CLI:
22
20
 
23
21
  ```sh
24
22
  $ npm install --global @nsis/dent-cli
25
23
  $ npx dent --help
26
24
  ```
27
25
 
28
- ### Single use
26
+ ### Scoop
29
27
 
30
- Download and execute the latest version using [`npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b).
28
+ The CLI is available to users of the [Scoop](https://scoop.sh/) package manager.
31
29
 
32
- ```sh
33
- $ npx @nsis/dent-cli --help
30
+ ```powershell
31
+ # Add the bucket
32
+ scoop bucket add nsis https://github.com/NSIS-Dev/scoop-nsis
33
+
34
+ # Install dent
35
+ scoop install nsis/dent
34
36
  ```
35
37
 
36
- ### Options
38
+ ### Download
39
+
40
+ As a last resort, you can download [pre-compiled binaries](https://github.com/idleberg/node-dent-cli/releases/latest) for Windows.
41
+
42
+ ## Usage
43
+
44
+ The CLI exposes two sub-commands:
45
+
46
+ - `dent format` — formats NSIS scripts
47
+ - `dent check` — checks if a script needs formatting
37
48
 
38
49
  ```
39
- Usage: dent [options] <file...>
50
+ Usage: dent [options] [command]
40
51
 
41
52
  CLI tool to format NSIS scripts
42
53
 
@@ -45,14 +56,13 @@ Options:
45
56
  -D, --debug prints additional debug messages (default: false)
46
57
  -h, --help display help for command
47
58
 
48
- Formatting Options
49
- -e, --eol <"crlf"|"lf"> control how line-breaks are represented (default: "lf")
50
- -i, --indent-size <number> number of units per indentation level (default: 2)
51
- -s, --use-spaces indent with spaces instead of tabs (default: false)
52
- -t, --trim trim empty lines (default: true)
53
- -w, --write edit files in-place (default: false)
59
+ Commands:
60
+ format [options] [file...] format NSIS scripts
61
+ check [options] [file...] check whether NSIS scripts are formatted (exits non-zero on drift)
54
62
  ```
55
63
 
64
+ Run `dent --help` to list sub-commands, or `dent <command> --help` for command-specific options.
65
+
56
66
  ## Related
57
67
 
58
68
  - [dent](https://www.npmjs.com/package/@nsis/dent)
@@ -60,4 +70,3 @@ Formatting Options
60
70
  ## License
61
71
 
62
72
  This work is licensed under [The MIT License](LICENSE)
63
-
package/bin/cli.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import{access as e,constants as t,glob as n,readFile as r,writeFile as i}from"node:fs/promises";import{createFormatter as a}from"@nsis/dent";import{blue as o,dim as s}from"kleur/colors";import{platform as c}from"node:os";import{Command as l}from"commander";import{createConsola as u}from"consola";const d=u({level:4});async function f(n){try{await e(n,t.F_OK)}catch{return!1}return!0}async function p(){return(await import(`../package.json`,{with:{type:`json`}})).default.version??`development`}async function m(){let e=new l(`dent`),t=await p(),n=c()===`win32`?`crlf`:`lf`;e.version(t).configureOutput({writeOut:e=>d.log(e),writeErr:e=>d.error(e)}).description(`CLI tool to format NSIS scripts`).arguments(`[file...]`).option(`-D, --debug`,`prints additional debug messages`,!1).optionsGroup(`Formatting Options`).option(`-e, --eol <"crlf"|"lf">`,`control how line-breaks are represented`,e=>[`crlf`,`lf`].includes(e)?e:(d.warn(`Invalid EOL value provided, defaulting to "${n}".`),n),n).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(`-t, --trim`,`trim empty lines`,!0).option(`-w, --write`,`edit files in-place`,!1).parse(process.argv);let r=e.opts(),i=Array.isArray(e.args)?e.args:[e.args];return i.length||e.help(),r.debug&&d.debug(`
2
- CLI parameters:`,{args:i,options:r}),r.indentSize!==2&&r.useSpaces===!1&&d.warn(`The "indent-size" option is ignored when "use-spaces" is not set.`),{args:i,options:r}}const{args:h,options:g}=await m(),_=await Array.fromAsync(n(h,{cwd:process.cwd()}));_.length===0&&(d.error(`No valid input files provided, exiting.`),process.exit(1));const v=a({endOfLines:g.eol,indentSize:g.indentSize,trimEmptyLines:g.trim,useTabs:!g.useSpaces});g.write&&d.start(`Formatting ${h.length} ${h.length===1?`file`:`files`}...`);const y=performance.now();for await(let e of _){if(!e.endsWith(`.nsi`)&&!e.endsWith(`.nsh`)){d.warn(`${o(e)} is not an NSIS script, skipping.`);continue}let t=performance.now();if(await f(e)===!1){d.warn(`${o(e)} does not exist, skipping.`);continue}let n=v((await r(e)).toString()),a=performance.now(),c=Math.round(a-t);g.write?(await i(e,n,{encoding:`utf-8`}),d.info(`${o(e)} formatted ${s(`(${c}ms)`)}`)):process.stdout.write(n)}if(g.write){let e=performance.now(),t=Math.round(e-y);d.success(`Completed in ${t}ms.`)}export{};
1
+ #!/usr/bin/env node
2
+ import{Command as e}from"commander";import{access as t,constants as n,glob as r,readFile as i,writeFile as a}from"node:fs/promises";import{createFormatter as o}from"@nsis/dent";import{blue as s,dim as c}from"kleur/colors";import{createConsola as l}from"consola";import{platform as u}from"node:os";const d=l({level:4}),f=u()===`win32`?`crlf`:`lf`;function p(e){return e.optionsGroup(`Formatting Options`).option(`-e, --eol <"crlf"|"lf">`,`control how line-breaks are represented`,e=>[`crlf`,`lf`].includes(e)?e:(d.warn(`Invalid EOL value provided, defaulting to "${f}".`),f),f).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(`-t, --trim`,`trim empty lines`,!0)}function m(e){e.indentSize!==2&&e.useSpaces===!1&&d.warn(`The "indent-size" option is ignored when "use-spaces" is not set.`)}async function h(e){try{await t(e,n.F_OK)}catch{return!1}return!0}async function g(){return(await import(`../package.json`,{with:{type:`json`}})).default.version??`development`}function _(e,t){let n=t.optsWithGlobals();return e.length||t.help(),n.debug&&d.debug(`
3
+ CLI parameters:`,{args:e,options:n}),m(n),n}function v(e){return{endOfLines:e.eol,indentSize:e.indentSize,trimEmptyLines:e.trim,useTabs:!e.useSpaces}}async function y(e){return Array.fromAsync(r(e,{cwd:process.cwd()}))}async function b(e){return!e.endsWith(`.nsi`)&&!e.endsWith(`.nsh`)?(d.warn(`${s(e)} is not an NSIS script, skipping.`),null):await h(e)===!1?(d.warn(`${s(e)} does not exist, skipping.`),null):(await i(e)).toString()}function x(){let t=new e(`check`).description(`check if NSIS scripts are formatted correctly`).arguments(`[file...]`).action(async(e,t,n)=>{await S(e,_(e,n))});return p(t),t.option(`-w, --write`,`edit files in-place, if check fails`,!1),t}async function S(e,t){let n=await y(e);n.length===0&&(d.error(`No valid input files provided, exiting.`),process.exit(2));let{check:r}=o(v(t));d.start(`Checking ${e.length} ${e.length===1?`file`:`files`}...`);let i=performance.now(),l=[];for(let e of n){let n=performance.now(),i=await b(e);if(i===null)continue;let o=r(i),u=Math.round(performance.now()-n);if(o===null){d.info(`${s(e)} already formatted ${c(`(${u}ms)`)}`);continue}l.push(e),t.write?(await a(e,o,{encoding:`utf-8`}),d.info(`${s(e)} formatted ${c(`(${u}ms)`)}`)):d.warn(`${s(e)} has issues ${c(`(${u}ms)`)}`)}let u=Math.round(performance.now()-i);d.success(`Completed in ${u}ms.`),l.length>=1&&process.exit(1)}function C(){let t=new e(`format`).description(`format NSIS scripts`).arguments(`[file...]`).action(async(e,t,n)=>{await w(e,_(e,n))});return p(t),t.option(`-w, --write`,`edit files in-place`,!1),t}async function w(e,t){let n=await y(e);n.length===0&&(d.error(`No valid input files provided, exiting.`),process.exit(1));let{check:r}=o(v(t));t.write&&d.start(`Formatting ${e.length} ${e.length===1?`file`:`files`}...`);let i=performance.now();for(let e of n){let n=performance.now(),i=await b(e);if(i===null)continue;let o=r(i),l=Math.round(performance.now()-n);t.write?o===null?d.info(`${s(e)} already formatted ${c(`(${l}ms)`)}`):(await a(e,o,{encoding:`utf-8`}),d.info(`${s(e)} formatted ${c(`(${l}ms)`)}`)):process.stdout.write(o??i)}if(t.write){let e=Math.round(performance.now()-i);d.success(`Completed in ${e}ms.`)}}async function T(){let t=new e(`dent`),n=await g();if(t.version(n).configureOutput({writeOut:e=>d.log(e),writeErr:e=>d.error(e)}).description(`CLI tool to format NSIS scripts`).option(`-D, --debug`,`prints additional debug messages`,!1).addCommand(C()).addCommand(x()),process.argv.length<=2){t.outputHelp();return}await t.parseAsync(process.argv)}await T();export{};
@@ -0,0 +1 @@
1
+ var e={name:`@nsis/dent-cli`,version:`0.5.1`,description:`An opinionated code formatter for NSIS scripts`,license:`MIT`,scripts:{build:`tsdown`,dev:`tsdown --watch`,lint:`concurrently --prefix-colors blue,green,magenta npm:lint:*`,"lint:biome":`biome check`,"lint:e18e":`e18e-cli analyze`,prepack:`npm run build`,"publish:jsr":`deno publish`,"publish:npm":`np`,start:`npm run build -- --watch`,test:`vitest run`},files:[`bin/`,`LICENSE`,`README.md`],type:`module`,bin:{dent:`./bin/cli.mjs`},engines:{node:`>=20.0.0`},repository:{type:`git`,url:`git+https://github.com/idleberg/node-dent-cli.git`},keywords:[`nsis`,`formatter`],dependencies:{"@nsis/dent":`^0.7.1`,commander:`^14.0.3`,consola:`^3.4.2`,kleur:`^4.1.5`},devDependencies:{"@commitlint/cli":`^21.0.1`,"@commitlint/config-conventional":`^21.0.1`,"@idleberg/configs":`^0.4.2`,"@types/node":`^24.12.4`,concurrently:`^9.2.1`,np:`^11.2.1`,tsdown:`^0.22.0`,typescript:`^6.0.3`,vitest:`^4.1.6`},pnpm:{onlyBuiltDependencies:[`lefthook`]},packageManager:`pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800`};export{e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsis/dent-cli",
3
- "version": "0.4.4",
3
+ "version": "0.5.1",
4
4
  "description": "An opinionated code formatter for NSIS scripts",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -24,20 +24,21 @@
24
24
  "formatter"
25
25
  ],
26
26
  "dependencies": {
27
- "@nsis/dent": "^0.6.2",
27
+ "@nsis/dent": "^0.7.1",
28
28
  "commander": "^14.0.3",
29
29
  "consola": "^3.4.2",
30
30
  "kleur": "^4.1.5"
31
31
  },
32
32
  "devDependencies": {
33
- "@commitlint/cli": "^20.5.3",
34
- "@commitlint/config-conventional": "^20.5.3",
33
+ "@commitlint/cli": "^21.0.1",
34
+ "@commitlint/config-conventional": "^21.0.1",
35
35
  "@idleberg/configs": "^0.4.2",
36
- "@types/node": "^24.12.2",
36
+ "@types/node": "^24.12.4",
37
37
  "concurrently": "^9.2.1",
38
- "np": "^11.2.0",
39
- "tsdown": "^0.21.10",
40
- "typescript": "^6.0.3"
38
+ "np": "^11.2.1",
39
+ "tsdown": "^0.22.0",
40
+ "typescript": "^6.0.3",
41
+ "vitest": "^4.1.6"
41
42
  },
42
43
  "scripts": {
43
44
  "build": "tsdown",
@@ -48,6 +49,6 @@
48
49
  "publish:jsr": "deno publish",
49
50
  "publish:npm": "np",
50
51
  "start": "npm run build -- --watch",
51
- "test": "echo \"Tests pending\" && exit 0"
52
+ "test": "vitest run"
52
53
  }
53
54
  }
@@ -1 +0,0 @@
1
- var e={name:`@nsis/dent-cli`,version:`0.4.4`,description:`An opinionated code formatter for NSIS scripts`,license:`MIT`,scripts:{build:`tsdown`,dev:`tsdown --watch`,lint:`concurrently --prefix-colors blue,green,magenta npm:lint:*`,"lint:biome":`biome check`,"lint:e18e":`e18e-cli analyze`,prepack:`npm run build`,"publish:jsr":`deno publish`,"publish:npm":`np`,start:`npm run build -- --watch`,test:`echo "Tests pending" && exit 0`},files:[`bin/`,`LICENSE`,`README.md`],type:`module`,bin:{dent:`./bin/cli.mjs`},engines:{node:`>=20.0.0`},repository:{type:`git`,url:`git+https://github.com/idleberg/node-dent-cli.git`},keywords:[`nsis`,`formatter`],dependencies:{"@nsis/dent":`^0.6.2`,commander:`^14.0.3`,consola:`^3.4.2`,kleur:`^4.1.5`},devDependencies:{"@commitlint/cli":`^20.5.3`,"@commitlint/config-conventional":`^20.5.3`,"@idleberg/configs":`^0.4.2`,"@types/node":`^24.12.2`,concurrently:`^9.2.1`,np:`^11.2.0`,tsdown:`^0.21.10`,typescript:`^6.0.3`},pnpm:{onlyBuiltDependencies:[`lefthook`]},packageManager:`pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017`};export{e as default};