@dintero/sri-to-dist 1.1.0 → 1.1.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/dist/index.js CHANGED
@@ -36,8 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const fs = __importStar(require("node:fs"));
37
37
  const path = __importStar(require("node:path"));
38
38
  const commander_1 = require("commander");
39
- const lib_1 = require("./lib");
40
39
  const package_json_1 = require("../package.json");
40
+ const lib_1 = require("./lib");
41
41
  const main = async () => {
42
42
  try {
43
43
  // Set up command-line parser
package/dist/lib.d.ts CHANGED
@@ -28,4 +28,4 @@ declare const calculateSha384: (content: Buffer) => string;
28
28
  declare const handleUpdatedHtml: (stdout: NodeJS.WriteStream, outputPath?: string, updatedHtml?: string) => void;
29
29
  declare const toSriScriptTag: (tag: string, integrity: string) => string;
30
30
  declare const alterTag: (tag: string, param: "crossorigin" | "integrity", value: string) => string;
31
- export { extractLinkRel, isSriTag, toHtmlWithSri, getContent, readLocalContent, fetchRemoteContent, calculateSha384, toSriScriptTag, handleUpdatedHtml, alterTag };
31
+ export { extractLinkRel, isSriTag, toHtmlWithSri, getContent, readLocalContent, fetchRemoteContent, calculateSha384, toSriScriptTag, handleUpdatedHtml, alterTag, };
package/dist/lib.js CHANGED
@@ -34,9 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.alterTag = exports.handleUpdatedHtml = exports.toSriScriptTag = exports.calculateSha384 = exports.fetchRemoteContent = exports.readLocalContent = exports.getContent = exports.toHtmlWithSri = exports.isSriTag = exports.extractLinkRel = exports.toSriImportMap = exports.extractImports = exports.parseImportMap = exports.isImportMapTag = void 0;
37
+ const node_crypto_1 = require("node:crypto");
37
38
  const fs = __importStar(require("node:fs"));
38
39
  const path = __importStar(require("node:path"));
39
- const node_crypto_1 = require("node:crypto");
40
40
  const extractLinkRel = (scriptOrLinkTag) => {
41
41
  const re = /<link\s+[^>]*rel="([^"]*)"/;
42
42
  const match = scriptOrLinkTag.match(re);
@@ -94,7 +94,8 @@ const isSriTag = (scriptOrLinkTag) => {
94
94
  };
95
95
  exports.isSriTag = isSriTag;
96
96
  const isImportMapTag = (scriptOrLinkTag) => {
97
- return scriptOrLinkTag.startsWith("<script ") && scriptOrLinkTag.includes('type="importmap"');
97
+ return (scriptOrLinkTag.startsWith("<script ") &&
98
+ scriptOrLinkTag.includes('type="importmap"'));
98
99
  };
99
100
  exports.isImportMapTag = isImportMapTag;
100
101
  const parseImportMap = (scriptOrLinkTag) => {
@@ -108,7 +109,7 @@ const parseImportMap = (scriptOrLinkTag) => {
108
109
  const content = contentMatch[1].trim();
109
110
  // Parse the import map JSON
110
111
  const importMapJson = JSON.parse(content);
111
- if (typeof importMapJson !== 'object' || Array.isArray(importMapJson)) {
112
+ if (typeof importMapJson !== "object" || Array.isArray(importMapJson)) {
112
113
  throw new Error(`Failed to parse import map for tag ${scriptOrLinkTag}`);
113
114
  }
114
115
  return importMapJson;
@@ -119,14 +120,15 @@ const parseImportMap = (scriptOrLinkTag) => {
119
120
  };
120
121
  exports.parseImportMap = parseImportMap;
121
122
  const extractImports = (importMapJson) => {
122
- const imports = importMapJson.imports ?
123
- Object.keys(importMapJson.imports).map(key => {
123
+ const imports = importMapJson.imports
124
+ ? Object.keys(importMapJson.imports).map((key) => {
124
125
  const src = importMapJson.imports[key];
125
126
  return {
126
127
  src,
127
- oldHash: importMapJson.integrity?.[src]
128
+ oldHash: importMapJson.integrity?.[src],
128
129
  };
129
- }) : [];
130
+ })
131
+ : [];
130
132
  return imports;
131
133
  };
132
134
  exports.extractImports = extractImports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dintero/sri-to-dist",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "HTML tool for adding subresource integrity hashes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,8 +17,8 @@
17
17
  "start": "node bin/sri-to-dist.js",
18
18
  "test": "vitest run",
19
19
  "test:watch": "vitest",
20
- "lint": "biome lint .",
21
- "format": "biome format . --write",
20
+ "lint": "biome check .",
21
+ "format": "biome check --write",
22
22
  "prepublishOnly": "yarn run build"
23
23
  },
24
24
  "keywords": [
@@ -32,16 +32,16 @@
32
32
  "author": "Sven Nicolai Viig <sven@dintero.com> (http://dintero.com)",
33
33
  "license": "MIT",
34
34
  "devDependencies": {
35
- "@biomejs/biome": "2.2.6",
36
- "@types/node": "24.8.1",
35
+ "@biomejs/biome": "2.3.1",
36
+ "@types/node": "24.9.1",
37
37
  "@types/temp": "0.9.4",
38
38
  "semantic-release": "25.0.1",
39
39
  "temp": "0.9.4",
40
40
  "typescript": "5.9.3",
41
- "vitest": "3.2.4"
41
+ "vitest": "4.0.3"
42
42
  },
43
43
  "dependencies": {
44
- "commander": "14.0.1"
44
+ "commander": "14.0.2"
45
45
  },
46
46
  "bugs": {
47
47
  "url": "https://github.com/Dintero/sri-to-dist/issues"