@nsis/dent 0.4.1 → 0.4.2

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,6 +6,9 @@
6
6
  [![Version](https://img.shields.io/npm/v/@nsis/dent?style=for-the-badge)](https://www.npmjs.org/package/@nsis/dent)
7
7
  [![Build](https://img.shields.io/github/actions/workflow/status/idleberg/node-dent/default.yml?style=for-the-badge)](https://github.com/idleberg/node-dent/actions)
8
8
 
9
+ > [!NOTE]
10
+ > This is the repository for the formatting library. Chances are you are looking for the [CLI tool](https://www.npmjs.com/package/@nsis/dent-cli) instead.
11
+
9
12
  ## Installation
10
13
 
11
14
  `npm install @nsis/dent`
@@ -1,3 +1,4 @@
1
+ //#region src/dent.d.ts
1
2
  /**
2
3
  * Formats the given file contents using the Dent formatting style.
3
4
  *
@@ -6,5 +7,5 @@
6
7
  * @throws {Error} Throws an error if the options are invalid.
7
8
  */
8
9
  declare function createFormatter(options?: NsisDent.Options): (fileContents: string) => string;
9
-
10
- export { createFormatter };
10
+ //#endregion
11
+ export { createFormatter };
package/dist/dent.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import{platform as e}from"node:os";import{detectNewline as t}from"detect-newline";const n={indenters:"!if.!ifdef.!ifmacrodef.!ifmacrondef.!ifndef.!macro.${Case}.${Case2}.${Case3}.${Case4}.${Case5}.${CaseElse}.${Default}.${Do}.${DoUntil}.${DoWhile}.${For}.${ForEach}.${If}.${IfNot}.${MementoSection}.${MementoUnselectedSection}.${Select}.${Switch}.${Unless}.Function.PageEx.Section.SectionGroup".split(`.`).map(e=>e.toLowerCase()),dedenters:[`!endif`,`!macroend`,"${EndIf}","${EndSelect}","${EndSwitch}","${EndWhile}","${Loop}","${LoopUntil}","${LoopWhile}","${MementoSectionEnd}","${Next}","${While}",`FunctionEnd`,`PageExEnd`,`SectionEnd`,`SectionGroupEnd`].map(e=>e.toLowerCase()),specialIndenters:[`!else`,`!elseif`,"${Else}","${ElseIf}","${ElseIfNot}","${ElseUnless}","${AndIf}","${AndIfNot}","${AndUnless}","${OrIf}","${OrIfNot}","${OrUnless}"].map(e=>e.toLowerCase()),specialDedenters:["${Break}"].map(e=>e.toLowerCase())};function r(r={}){let i={indentSize:2,trimEmptyLines:!0,useTabs:!0,...r};if(i.useTabs===!1&&(!i.indentSize||Number.isNaN(i.indentSize)||i.indentSize<=0))throw Error(`The indentSize option expects a positive integer`);function a(e){let t=0,r=0,a=s(e),l=c(e),u=[];return(i.trimEmptyLines===!0?e.trim().replaceAll(/^(\s*\r?\n){2,}/gm,a).split(a):e.split(a)).forEach(e=>{let i=e.trim().split(` `).at(0)??``;switch(i.toLowerCase()==="${switch}"&&(r=t),!0){case i.toLowerCase()==="${endswitch}":t=r,u.push(o(e,t));break;case n.specialIndenters.includes(i.toLowerCase()):u.push(o(e,t-1));break;case n.specialDedenters.includes(i.toLowerCase()):u.push(o(e,t)),t=t===0?0:t-1;break;case n.indenters.includes(i.toLowerCase()):u.push(o(e,t)),t++;break;case n.dedenters.includes(i.toLowerCase()):t=t===0?0:t-1,u.push(o(e,t));break;default:u.push(o(e,t));break}}),u.join(l)+l}function o(e,t){return e.length?`${l(t)}${e.trim()}`:``}function s(n){let r=t(n);return r===void 0?e()===`win32`?`\r
2
+ `:`
3
+ `:r}function c(e){return i.endOfLines?i.endOfLines===`crlf`?`\r
4
+ `:`
5
+ `:s(e)}function l(e){return(i.useTabs?` `:` `.repeat(i.indentSize||2)).repeat(e)}return a}export{r as createFormatter};
package/package.json CHANGED
@@ -1,60 +1,50 @@
1
1
  {
2
- "name": "@nsis/dent",
3
- "version": "0.4.1",
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": "uvu -r tsm tests",
16
- "prepare": "husky install"
17
- },
18
- "files": [
19
- "dist/",
20
- "types/",
21
- "LICENSE",
22
- "package.json",
23
- "README.md"
24
- ],
25
- "type": "module",
26
- "typings": "dist/dent.d.ts",
27
- "exports": "./dist/dent.js",
28
- "engines": {
29
- "node": ">=18.0.0"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "https://github.com/idleberg/node-dent.git"
34
- },
35
- "keywords": [
36
- "nsis",
37
- "formatter"
38
- ],
39
- "dependencies": {
40
- "detect-newline": "^4.0.1"
41
- },
42
- "devDependencies": {
43
- "@types/node": "^18.19.3",
44
- "@typescript-eslint/eslint-plugin": "^6.16.0",
45
- "@typescript-eslint/parser": "^6.16.0",
46
- "eslint": "^8.56.0",
47
- "eslint-plugin-json": "^3.1.0",
48
- "husky": "^8.0.3",
49
- "lint-staged": "^15.2.0",
50
- "npm-run-all2": "^6.1.1",
51
- "tslib": "^2.6.2",
52
- "tsm": "^2.3.0",
53
- "tsup": "^8.0.1",
54
- "typescript": "^5.3.3",
55
- "uvu": "^0.5.6"
56
- },
57
- "lint-staged": {
58
- "*.(json|ts)": "eslint --cache --fix"
59
- }
60
- }
2
+ "name": "@nsis/dent",
3
+ "version": "0.4.2",
4
+ "description": "An opinionated code formatter for NSIS scripts",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist/",
8
+ "types/",
9
+ "LICENSE",
10
+ "package.json",
11
+ "README.md"
12
+ ],
13
+ "type": "module",
14
+ "typings": "dist/dent.d.mts",
15
+ "exports": "./dist/dent.mjs",
16
+ "engines": {
17
+ "node": ">=18.0.0"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/idleberg/node-dent.git"
22
+ },
23
+ "keywords": [
24
+ "nsis",
25
+ "formatter"
26
+ ],
27
+ "dependencies": {
28
+ "detect-newline": "^4.0.1"
29
+ },
30
+ "devDependencies": {
31
+ "@idleberg/configs": "^0.4.2",
32
+ "@types/node": "^24.11.0",
33
+ "concurrently": "^9.2.1",
34
+ "np": "^11.0.2",
35
+ "tsdown": "^0.20.3",
36
+ "tsm": "^2.3.0",
37
+ "typescript": "^5.3.3",
38
+ "uvu": "^0.5.6"
39
+ },
40
+ "scripts": {
41
+ "build": "tsdown",
42
+ "dev": "tsdown --watch",
43
+ "lint": "concurrently --prefix-colors blue,green,magenta npm:lint:*",
44
+ "lint:biome": "biome check",
45
+ "lint:e18e": "e18e-cli analyze",
46
+ "publish:jsr": "deno publish",
47
+ "publish:npm": "np",
48
+ "test": "uvu -r tsm tests"
49
+ }
50
+ }
package/types/index.d.ts CHANGED
@@ -6,7 +6,7 @@ declare namespace NsisDent {
6
6
  indentSize?: number;
7
7
  trimEmptyLines?: boolean;
8
8
  useTabs?: boolean;
9
- }
9
+ };
10
10
  }
11
11
 
12
12
  export = NsisDent;
package/dist/dent.js DELETED
@@ -1,10 +0,0 @@
1
- import { detectNewline } from 'detect-newline';
2
- import { platform } from 'node:os';
3
-
4
- var d={indenters:["!if","!ifdef","!ifmacrodef","!ifmacrondef","!ifndef","!macro","${Case}","${Case2}","${Case3}","${Case4}","${Case5}","${CaseElse}","${Default}","${Do}","${DoUntil}","${DoWhile}","${For}","${ForEach}","${If}","${IfNot}","${MementoSection}","${MementoUnselectedSection}","${Select}","${Switch}","${Unless}","Function","PageEx","Section","SectionGroup"].map(s=>s.toLowerCase()),dedenters:["!endif","!macroend","${EndIf}","${EndSelect}","${EndSwitch}","${EndWhile}","${Loop}","${LoopUntil}","${LoopWhile}","${MementoSectionEnd}","${Next}","${While}","FunctionEnd","PageExEnd","SectionEnd","SectionGroupEnd"].map(s=>s.toLowerCase()),specialIndenters:["!else","!elseif","${Else}","${ElseIf}","${ElseIfNot}","${ElseUnless}","${AndIf}","${AndIfNot}","${AndUnless}","${OrIf}","${OrIfNot}","${OrUnless}"].map(s=>s.toLowerCase()),specialDedenters:["${Break}"].map(s=>s.toLowerCase())};var f=2;function C(s={}){let n={endOfLines:platform()==="win32"?"crlf":"lf",indentSize:f,trimEmptyLines:!0,useTabs:!0,...s};if(n.useTabs===!1&&n.indentSize&&(isNaN(n.indentSize)||n.indentSize<=0))throw Error("The indentSize option expects a positive integer");function p(t){let e=0,l=0,c=u(t),i=[];return (n.trimEmptyLines===!0?t.trim().replaceAll(/^(\s*\r?\n){2,}/gm,c).split(c):t.split(c)).forEach(r=>{let a=r.trim().split(" ").at(0)??"";switch(a.toLowerCase()==="${Switch}"&&(l=e),!0){case a.toLowerCase()==="${EndSwitch}":e=l,i.push(o(r,e)),e=e===0?0:e-1;break;case d.specialIndenters.includes(a.toLowerCase()):i.push(o(r,e-1));break;case d.specialDedenters.includes(a.toLowerCase()):i.push(o(r,e)),e--;break;case d.indenters.includes(a.toLowerCase()):i.push(o(r,e)),e++;break;case d.dedenters.includes(a.toLowerCase()):e=e===0?0:e-1,i.push(o(r,e));break;default:i.push(o(r,e));break}}),i.join(c)}function o(t,e){return t.length?`${m(e)}${t.trim()}`:""}function u(t){if(n.endOfLines)return n.endOfLines==="crlf"?`\r
5
- `:`
6
- `;let e=detectNewline(t);return e!==void 0?e:platform()==="win32"?`\r
7
- `:`
8
- `}function m(t){return (n.useTabs?" ".repeat(n.indentSize||f):" ".repeat(n.indentSize||f)).repeat(t)}return p}
9
-
10
- export { C as createFormatter };