@nsis/dent-cli 0.2.0 → 0.3.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 Jan T. Sott
3
+ Copyright (c) 2023-2026 Jan T. Sott
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## Prerequisites
10
10
 
11
- This is a TypeScript applicaiton that dependes on a [NodeJS](https://nodejs.org) runtime installed on your computer.
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{platform as t}from"node:os";import{dirname as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{createFormatter as a}from"@nsis/dent";import{Command as o}from"commander";import{glob as s}from"glob";import c from"log-symbols";import l from"picocolors";await u();async function u(){let n=new o,r=await d();n.version(r).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)){let e=t()===`win32`?`crlf`:`lf`;return console.log(`${c.warning} Invalid EOL value provided, defaulting to "${e}".`),e}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 i=n.opts(),u=Array.isArray(n.args)?n.args:[n.args];u.length||n.help(),i.debug&&console.log(`
3
+ CLI parameters:`,{args:u,options:i});let f=a({endOfLines:i.eol,indentSize:i.indentSize,trimEmptyLines:i.trim,useTabs:!i.useSpaces}),p=await s(u),m=i.write&&!i.quiet;m&&!i.debug&&console.log(),console.time(`
4
+ Completed`),await Promise.all(p.map(async t=>{if(!t.endsWith(`.nsi`)&&!t.endsWith(`.nsh`)){console.warn(`${c.warning} ${l.blue(t)} is not an NSIS script, skipping.`);return}m&&console.time(`${c.success} ${l.blue(t)}`);let n=(await e.readFile(t)).toString(),r=f(n);if(i.debug&&console.log(`
5
+ Conversion:`,{raw:n,formatted:r}),i.write)try{await e.writeFile(t,r,{encoding:`utf-8`}),m&&console.timeEnd(`${c.success} ${l.blue(t)}`)}catch(e){m&&console.error(`${c.error} ${l.blue(t)} ${e instanceof Error?e.message:String(e)}`)}else console.log(r)})),m&&console.timeEnd(`
6
+ Completed`)}async function d(){let t=n(i(import.meta.url)),{version:a}=JSON.parse(await e.readFile(r(t,`../package.json`),`utf8`));return a||`dev`}export{};
package/package.json CHANGED
@@ -1,62 +1,54 @@
1
1
  {
2
- "name": "@nsis/dent-cli",
3
- "version": "0.2.0",
4
- "description": "An opinionated code formatter for NSIS scripts",
5
- "license": "MIT",
6
- "scripts": {
7
- "build": "tsup",
8
- "dev": "npm run start",
9
- "fix": "eslint --fix ./src",
10
- "lint:json": "eslint ./*.json --ignore-path .gitignore",
11
- "lint:ts": "eslint ./src --ignore-path .gitignore",
12
- "lint": "npm-run-all --parallel lint:*",
13
- "prepack": "npm run build",
14
- "start": "npm run build -- --watch",
15
- "test": "echo \"Tests pending\" && exit 0",
16
- "prepare": "husky install"
17
- },
18
- "files": [
19
- "bin/",
20
- "LICENSE",
21
- "README.md"
22
- ],
23
- "type": "module",
24
- "typings": "bin/cli.d.ts",
25
- "bin": {
26
- "dent": "index.mjs"
27
- },
28
- "engines": {
29
- "node": ">=18.0.0"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "https://github.com/idleberg/node-dent-cli.git"
34
- },
35
- "keywords": [
36
- "nsis",
37
- "formatter"
38
- ],
39
- "dependencies": {
40
- "@nsis/dent": "^0.4.1",
41
- "commander": "^11.1.0",
42
- "glob": "^10.3.10",
43
- "log-symbols": "^6.0.0",
44
- "picocolors": "^1.0.0"
45
- },
46
- "devDependencies": {
47
- "@types/node": "^18.19.3",
48
- "@typescript-eslint/eslint-plugin": "^6.16.0",
49
- "@typescript-eslint/parser": "^6.16.0",
50
- "eslint": "^8.56.0",
51
- "eslint-plugin-json": "^3.1.0",
52
- "husky": "^8.0.3",
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.1",
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
+ "@commitlint/cli": "^20.4.1",
35
+ "@commitlint/config-conventional": "^20.4.1",
36
+ "@idleberg/configs": "^0.4.2",
37
+ "@types/node": "^24.11.0",
38
+ "concurrently": "^9.2.1",
39
+ "np": "^11.0.2",
40
+ "tsdown": "^0.20.3",
41
+ "typescript": "^5.3.3"
42
+ },
43
+ "scripts": {
44
+ "build": "tsdown",
45
+ "dev": "tsdown --watch",
46
+ "lint": "concurrently --prefix-colors blue,green,magenta npm:lint:*",
47
+ "lint:biome": "biome check",
48
+ "lint:e18e": "e18e-cli analyze",
49
+ "publish:jsr": "deno publish",
50
+ "publish:npm": "np",
51
+ "start": "npm run build -- --watch",
52
+ "test": "echo \"Tests pending\" && exit 0"
53
+ }
54
+ }
package/bin/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
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
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import './bin/cli.js';