@nsis/dent-cli 0.1.2 → 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 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
@@ -3,12 +3,12 @@
3
3
  > An opinionated code formatter for NSIS scripts
4
4
 
5
5
  [![License](https://img.shields.io/github/license/idleberg/node-dent-cli?color=blue&style=for-the-badge)](https://github.com/idleberg/node-dent-cli/blob/main/LICENSE)
6
- [![npm](https://img.shields.io/npm/v/@nsis/dent-cli?style=for-the-badge)](https://www.npmjs.org/package/@nsis/dent-cli)
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
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 CHANGED
@@ -1,88 +1,6 @@
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 logSymbols from 'log-symbols';
8
- import colors from 'picocolors';
9
-
10
- await main();
11
- async function main() {
12
- const program = new Command();
13
- const version = await getVersion();
14
- program
15
- .version(version)
16
- .description('CLI tool to format NSIS scripts')
17
- .arguments('<file...>')
18
- .option('--eol <"crlf"|"lf">', 'control how line-breaks are represented', value => ['crlf', 'lf'].includes(value))
19
- .option('-i, --indent-size <number>', 'number of units per indentation level', value => parseInt(value, 10), 2)
20
- .option('-s, --use-spaces', 'indent with spaces instead of tabs', false)
21
- .option('--trim', 'trim empty lines', true)
22
- .option('--write', 'edit files in-place', false)
23
- .option('--quiet', 'suppress output', false)
24
- .option('--debug', 'prints additional debug messages', false)
25
- .parse(process.argv);
26
- const options = program.opts();
27
- const args = Array.isArray(program.args)
28
- ? program.args
29
- : [program.args];
30
- if (!args.length) {
31
- program.help();
32
- }
33
- if (options.debug) {
34
- console.log('\nCLI parameters:', { args, options });
35
- }
36
- const format = createFormatter({
37
- endOfLines: options.eol,
38
- indentSize: options.indent,
39
- trimEmptyLines: options.trim,
40
- useTabs: !options.useSpaces
41
- });
42
- const files = await glob(args);
43
- const isVerbose = options.write && !options.quiet;
44
- if (isVerbose && !options.debug) {
45
- console.log( /* let it breathe */);
46
- }
47
- console.time('\nCompleted');
48
- await Promise.all(files.map(async (file) => {
49
- if (isVerbose) {
50
- console.time(`${logSymbols.success} ${colors.blue(file)}`);
51
- }
52
- const rawContents = (await promises.readFile(file)).toString();
53
- const formattedContents = format(rawContents);
54
- if (options.debug) {
55
- console.log('\nConversion:', {
56
- raw: rawContents,
57
- formatted: formattedContents
58
- });
59
- }
60
- if (options.write) {
61
- try {
62
- await promises.writeFile(file, formattedContents, {
63
- encoding: 'utf-8'
64
- });
65
- if (isVerbose) {
66
- console.timeEnd(`${logSymbols.success} ${colors.blue(file)}`);
67
- }
68
- }
69
- catch (error) {
70
- if (isVerbose) {
71
- console.error(`${logSymbols.error} ${colors.blue(file)}\n${colors.dim(error instanceof Error ? error.message : error)}`);
72
- }
73
- }
74
- }
75
- else {
76
- console.log(formattedContents);
77
- }
78
- }));
79
- if (isVerbose) {
80
- console.timeEnd(`\nCompleted`);
81
- }
82
- }
83
- async function getVersion() {
84
- const __filename = fileURLToPath(import.meta.url);
85
- const __dirname = dirname(__filename);
86
- const { version } = JSON.parse(await promises.readFile(resolve(__dirname, '../package.json'), 'utf8'));
87
- return version || 'dev';
88
- }
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,63 +1,52 @@
1
1
  {
2
- "name": "@nsis/dent-cli",
3
- "version": "0.1.2",
4
- "description": "An opinionated code formatter for NSIS scripts",
5
- "license": "MIT",
6
- "scripts": {
7
- "build": "rollup --config",
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
- "bin": {
25
- "dent": "index.mjs"
26
- },
27
- "engines": {
28
- "node": "^14.13.1 || >=16.0.0"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "https://github.com/idleberg/node-dent-cli.git"
33
- },
34
- "keywords": [
35
- "nsis",
36
- "formatter"
37
- ],
38
- "dependencies": {
39
- "@nsis/dent": "^0.3.1",
40
- "commander": "^10.0.1",
41
- "glob": "^10.3.3",
42
- "log-symbols": "^5.1.0",
43
- "picocolors": "^1.0.0"
44
- },
45
- "devDependencies": {
46
- "@rollup/plugin-json": "^6.0.0",
47
- "@rollup/plugin-typescript": "^11.1.2",
48
- "@types/node": "^20.2.3",
49
- "@typescript-eslint/eslint-plugin": "^6.0.0",
50
- "@typescript-eslint/parser": "^6.0.0",
51
- "eslint": "^8.45.0",
52
- "eslint-plugin-json": "^3.1.0",
53
- "husky": "^8.0.3",
54
- "lint-staged": "^13.2.3",
55
- "npm-run-all2": "^6.0.6",
56
- "rollup": "^3.26.2",
57
- "tslib": "^2.6.0",
58
- "typescript": "^5.1.6"
59
- },
60
- "lint-staged": {
61
- "*.(json|ts)": "eslint --cache --fix"
62
- }
63
- }
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/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import './bin/cli.mjs';