@serwist/build 10.0.0-preview.2 → 10.0.0-preview.4
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -138
- package/dist/inject-manifest.d.ts.map +1 -1
- package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -1
- package/dist/lib/get-file-details.d.ts +2 -1
- package/dist/lib/get-file-details.d.ts.map +1 -1
- package/dist/lib/get-file-manifest-entries.d.ts.map +1 -1
- package/dist/lib/modify-url-prefix-transform.d.ts.map +1 -1
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts.map +1 -1
- package/dist/lib/transform-manifest.d.ts +2 -1
- package/dist/lib/transform-manifest.d.ts.map +1 -1
- package/dist/types.d.ts +0 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/index.ts +3 -2
- package/src/inject-manifest.ts +2 -1
- package/src/lib/additional-precache-entries-transform.ts +1 -2
- package/src/lib/get-file-details.ts +3 -4
- package/src/lib/get-file-manifest-entries.ts +3 -4
- package/src/lib/modify-url-prefix-transform.ts +1 -1
- package/src/lib/no-revision-for-urls-matching-transform.ts +1 -1
- package/src/lib/transform-manifest.ts +3 -2
- package/src/lib/translate-url-to-sourcemap-paths.ts +1 -1
- package/src/types.ts +0 -9
- package/dist/lib/errors.d.ts +0 -47
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/get-composite-details.d.ts +0 -3
- package/dist/lib/get-composite-details.d.ts.map +0 -1
- package/dist/lib/get-file-hash.d.ts +0 -2
- package/dist/lib/get-file-hash.d.ts.map +0 -1
- package/dist/lib/get-file-size.d.ts +0 -2
- package/dist/lib/get-file-size.d.ts.map +0 -1
- package/dist/lib/get-string-details.d.ts +0 -3
- package/dist/lib/get-string-details.d.ts.map +0 -1
- package/dist/lib/get-string-hash.d.ts +0 -3
- package/dist/lib/get-string-hash.d.ts.map +0 -1
- package/src/lib/errors.ts +0 -93
- package/src/lib/get-composite-details.ts +0 -31
- package/src/lib/get-file-hash.ts +0 -21
- package/src/lib/get-file-size.ts +0 -22
- package/src/lib/get-string-details.ts +0 -16
- package/src/lib/get-string-hash.ts +0 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { errors } from "@serwist/utils/node";
|
|
1
2
|
import { getManifest } from "./get-manifest.js";
|
|
2
3
|
import { injectManifest } from "./inject-manifest.js";
|
|
3
|
-
import { errors } from "./lib/errors.js";
|
|
4
4
|
import { escapeRegExp } from "./lib/escape-regexp.js";
|
|
5
5
|
import { getFileManifestEntries } from "./lib/get-file-manifest-entries.js";
|
|
6
6
|
import { getSourceMapURL } from "./lib/get-source-map-url.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAGtG;;;;GAIG;AACH,QAAA,MAAM,SAAS;;;CAAiB,CAAC;AAEjC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,cAAc,EACd,UAAU,EACV,yBAAyB,EACzB,SAAS,EACT,iBAAiB,EACjB,4BAA4B,EAC5B,0BAA0B,EAC1B,6BAA6B,GAC9B,CAAC;AAEF,mBAAmB,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,144 +1,16 @@
|
|
|
1
|
+
import { errors, getFileSize, getFileHash, getCompositeDetails, getStringDetails } from '@serwist/utils/node';
|
|
2
|
+
export { errors } from '@serwist/utils/node';
|
|
1
3
|
import assert from 'node:assert';
|
|
2
|
-
import { oneLine } from 'common-tags';
|
|
3
|
-
import crypto from 'node:crypto';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { globSync } from 'glob';
|
|
6
|
-
import fs, { readFileSync } from 'node:fs';
|
|
7
6
|
import prettyBytes from 'pretty-bytes';
|
|
8
7
|
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/validationErrorMap.js';
|
|
9
8
|
import fsp from 'node:fs/promises';
|
|
10
9
|
import { toUnix } from '@serwist/utils';
|
|
11
10
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map';
|
|
11
|
+
import fs from 'node:fs';
|
|
12
12
|
import 'zod';
|
|
13
13
|
|
|
14
|
-
const errors = {
|
|
15
|
-
"unable-to-get-rootdir": "Unable to get the root directory of your web app.",
|
|
16
|
-
"no-extension": oneLine`Unable to detect a usable extension for a file in your web
|
|
17
|
-
app directory.`,
|
|
18
|
-
"invalid-file-manifest-name": oneLine`The File Manifest Name must have at least one
|
|
19
|
-
character.`,
|
|
20
|
-
"unable-to-get-file-manifest-name": "Unable to get a file manifest name.",
|
|
21
|
-
"invalid-sw-dest": `The 'swDest' value must be a valid path.`,
|
|
22
|
-
"unable-to-get-sw-name": "Unable to get a service worker file name.",
|
|
23
|
-
"unable-to-get-save-config": oneLine`An error occurred when asking to save details
|
|
24
|
-
in a config file.`,
|
|
25
|
-
"unable-to-get-file-hash": oneLine`An error occurred when attempting to create a
|
|
26
|
-
file hash.`,
|
|
27
|
-
"unable-to-get-file-size": oneLine`An error occurred when attempting to get a file
|
|
28
|
-
size.`,
|
|
29
|
-
"unable-to-glob-files": "An error occurred when globbing for files.",
|
|
30
|
-
"unable-to-make-manifest-directory": oneLine`Unable to make output directory for
|
|
31
|
-
file manifest.`,
|
|
32
|
-
"read-manifest-template-failure": "Unable to read template for file manifest",
|
|
33
|
-
"populating-manifest-tmpl-failed": oneLine`An error occurred when populating the
|
|
34
|
-
file manifest template.`,
|
|
35
|
-
"manifest-file-write-failure": "Unable to write the file manifest.",
|
|
36
|
-
"unable-to-make-sw-directory": oneLine`Unable to make the directories to output
|
|
37
|
-
the service worker path.`,
|
|
38
|
-
"sw-write-failure": "Unable to write the service worker file.",
|
|
39
|
-
"sw-write-failure-directory": oneLine`Unable to write the service worker file;
|
|
40
|
-
'swDest' should be a full path to the file, not a path to a directory.`,
|
|
41
|
-
"unable-to-copy-serwist-libraries": oneLine`One or more of the Serwist libraries
|
|
42
|
-
could not be copied over to the destination directory: `,
|
|
43
|
-
"invalid-glob-directory": oneLine`The supplied globDirectory must be a path as a
|
|
44
|
-
string.`,
|
|
45
|
-
"invalid-dont-cache-bust": oneLine`The supplied 'dontCacheBustURLsMatching'
|
|
46
|
-
parameter must be a RegExp.`,
|
|
47
|
-
"invalid-exclude-files": "The excluded files should be an array of strings.",
|
|
48
|
-
"invalid-get-manifest-entries-input": oneLine`The input to
|
|
49
|
-
'getFileManifestEntries()' must be an object.`,
|
|
50
|
-
"invalid-manifest-path": oneLine`The supplied manifest path is not a string with
|
|
51
|
-
at least one character.`,
|
|
52
|
-
"invalid-manifest-entries": oneLine`The manifest entries must be an array of
|
|
53
|
-
strings or JavaScript objects containing a url parameter.`,
|
|
54
|
-
"invalid-manifest-format": oneLine`The value of the 'format' option passed to
|
|
55
|
-
generateFileManifest() must be either 'iife' (the default) or 'es'.`,
|
|
56
|
-
"invalid-static-file-globs": oneLine`The 'globPatterns' value must be an array
|
|
57
|
-
of strings.`,
|
|
58
|
-
"invalid-templated-urls": oneLine`The 'templatedURLs' value should be an object
|
|
59
|
-
that maps URLs to either a string, or to an array of glob patterns.`,
|
|
60
|
-
"templated-url-matches-glob": oneLine`One of the 'templatedURLs' URLs is already
|
|
61
|
-
being tracked via 'globPatterns': `,
|
|
62
|
-
"invalid-glob-ignores": oneLine`The 'globIgnores' parameter must be an array of
|
|
63
|
-
glob pattern strings.`,
|
|
64
|
-
"manifest-entry-bad-url": oneLine`The generated manifest contains an entry without
|
|
65
|
-
a URL string. This is likely an error with @serwist/build.`,
|
|
66
|
-
"modify-url-prefix-bad-prefixes": oneLine`The 'modifyURLPrefix' parameter must be
|
|
67
|
-
an object with string key value pairs.`,
|
|
68
|
-
"invalid-inject-manifest-arg": oneLine`The input to 'injectManifest()' must be an
|
|
69
|
-
object.`,
|
|
70
|
-
"injection-point-not-found": oneLine`Unable to find a place to inject the manifest.
|
|
71
|
-
Please ensure that your service worker file contains the following: `,
|
|
72
|
-
"multiple-injection-points": oneLine`Please ensure that your 'swSrc' file contains
|
|
73
|
-
only one match for the following: `,
|
|
74
|
-
"useless-glob-pattern": oneLine`One of the glob patterns doesn't match any files.
|
|
75
|
-
Please remove or fix the following: `,
|
|
76
|
-
"bad-template-urls-asset": oneLine`There was an issue using one of the provided
|
|
77
|
-
'templatedURLs'.`,
|
|
78
|
-
"invalid-generate-file-manifest-arg": oneLine`The input to generateFileManifest()
|
|
79
|
-
must be an Object.`,
|
|
80
|
-
"invalid-sw-src": `The 'swSrc' file can't be read.`,
|
|
81
|
-
"same-src-and-dest": oneLine`Unable to find a place to inject the manifest. This is
|
|
82
|
-
likely because swSrc and swDest are configured to the same file.
|
|
83
|
-
Please ensure that your swSrc file contains the following:`,
|
|
84
|
-
"no-module-name": oneLine`You must provide a moduleName parameter when calling
|
|
85
|
-
getModuleURL().`,
|
|
86
|
-
"bad-manifest-transforms-return-value": oneLine`The return value from a
|
|
87
|
-
manifestTransform should be an object with 'manifest' and optionally
|
|
88
|
-
'warnings' properties.`,
|
|
89
|
-
"string-entry-warning": oneLine`Some items were passed to additionalPrecacheEntries
|
|
90
|
-
without revisioning info. This is generally NOT safe. Learn more at
|
|
91
|
-
https://bit.ly/wb-precache.`,
|
|
92
|
-
"cant-find-sourcemap": oneLine`The swSrc file refers to a sourcemap that can't be
|
|
93
|
-
opened:`,
|
|
94
|
-
"manifest-transforms": oneLine`When using manifestTransforms, you must provide
|
|
95
|
-
an array of functions.`
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const getCompositeDetails = (compositeURL, dependencyDetails)=>{
|
|
99
|
-
let totalSize = 0;
|
|
100
|
-
let compositeHash = "";
|
|
101
|
-
for (const fileDetails of dependencyDetails){
|
|
102
|
-
totalSize += fileDetails.size;
|
|
103
|
-
compositeHash += fileDetails.hash === null ? "" : fileDetails.hash;
|
|
104
|
-
}
|
|
105
|
-
const md5 = crypto.createHash("md5");
|
|
106
|
-
md5.update(compositeHash);
|
|
107
|
-
const hashOfHashes = md5.digest("hex");
|
|
108
|
-
return {
|
|
109
|
-
file: compositeURL,
|
|
110
|
-
hash: hashOfHashes,
|
|
111
|
-
size: totalSize
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
function getStringHash(input) {
|
|
116
|
-
const md5 = crypto.createHash("md5");
|
|
117
|
-
md5.update(input);
|
|
118
|
-
return md5.digest("hex");
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const getFileHash = (file)=>{
|
|
122
|
-
try {
|
|
123
|
-
const buffer = readFileSync(file);
|
|
124
|
-
return getStringHash(buffer);
|
|
125
|
-
} catch (err) {
|
|
126
|
-
throw new Error(`${errors["unable-to-get-file-hash"]} '${err instanceof Error && err.message ? err.message : ""}'`);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const getFileSize = (file)=>{
|
|
131
|
-
try {
|
|
132
|
-
const stat = fs.statSync(file);
|
|
133
|
-
if (!stat.isFile()) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
return stat.size;
|
|
137
|
-
} catch (err) {
|
|
138
|
-
throw new Error(`${errors["unable-to-get-file-size"]} '${err instanceof Error && err.message ? err.message : ""}'`);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
14
|
const getFileDetails = ({ globDirectory, globFollow, globIgnores, globPattern })=>{
|
|
143
15
|
let globbedFiles;
|
|
144
16
|
let warning = "";
|
|
@@ -177,12 +49,6 @@ const getFileDetails = ({ globDirectory, globFollow, globIgnores, globPattern })
|
|
|
177
49
|
};
|
|
178
50
|
};
|
|
179
51
|
|
|
180
|
-
const getStringDetails = (url, str)=>({
|
|
181
|
-
file: url,
|
|
182
|
-
hash: getStringHash(str),
|
|
183
|
-
size: str.length
|
|
184
|
-
});
|
|
185
|
-
|
|
186
52
|
const additionalPrecacheEntriesTransform = (additionalPrecacheEntries)=>{
|
|
187
53
|
return (manifest)=>{
|
|
188
54
|
const warnings = [];
|
|
@@ -623,4 +489,4 @@ const injectManifest = async (config)=>{
|
|
|
623
489
|
|
|
624
490
|
const stringify = JSON.stringify;
|
|
625
491
|
|
|
626
|
-
export {
|
|
492
|
+
export { escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateGetManifestOptions, validateInjectManifestOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../src/inject-manifest.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc,GAAU,QAAQ,qBAAqB,KAAG,OAAO,CAAC,WAAW,CAwFvF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"additional-precache-entries-transform.d.ts","sourceRoot":"","sources":["../../src/lib/additional-precache-entries-transform.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"additional-precache-entries-transform.d.ts","sourceRoot":"","sources":["../../src/lib/additional-precache-entries-transform.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,KAAK,kCAAkC,GAAG,CAAC,QAAQ,EAAE,CAAC,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,KAAK;IAC5F,QAAQ,EAAE,CAAC,aAAa,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAC/C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAAI,2BAA2B,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,KAAG,kCAqC1G,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { FileDetails
|
|
1
|
+
import type { FileDetails } from "@serwist/utils";
|
|
2
|
+
import type { GlobPartial } from "../types.js";
|
|
2
3
|
export declare const getFileDetails: ({ globDirectory, globFollow, globIgnores, globPattern, }: Omit<GlobPartial, "globDirectory" | "globPatterns" | "templatedURLs"> & {
|
|
3
4
|
globDirectory: string;
|
|
4
5
|
globPattern: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-file-details.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-details.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-file-details.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-details.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,cAAc,GAAI,0DAK5B,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,cAAc,GAAG,eAAe,CAAC,GAAG;IAEzE,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,KAAG;IACF,kBAAkB,EAAE,WAAW,EAAE,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;CAkCjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-file-manifest-entries.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-manifest-entries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-file-manifest-entries.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-manifest-entries.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIjF,eAAO,MAAM,sBAAsB,GAAU,yOAa1C,0BAA0B,KAAG,OAAO,CAAC,iBAAiB,CA+FxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-url-prefix-transform.d.ts","sourceRoot":"","sources":["../../src/lib/modify-url-prefix-transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modify-url-prefix-transform.d.ts","sourceRoot":"","sources":["../../src/lib/modify-url-prefix-transform.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,wBAAgB,wBAAwB,CAAC,eAAe,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,iBAAiB,CA0CtG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-revision-for-urls-matching-transform.d.ts","sourceRoot":"","sources":["../../src/lib/no-revision-for-urls-matching-transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-revision-for-urls-matching-transform.d.ts","sourceRoot":"","sources":["../../src/lib/no-revision-for-urls-matching-transform.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAoBpF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FileDetails } from "@serwist/utils";
|
|
2
|
+
import type { BaseResolved, ManifestEntry } from "../types.js";
|
|
2
3
|
/**
|
|
3
4
|
* A `ManifestTransform` function can be used to modify the modify the `url` or
|
|
4
5
|
* `revision` properties of some or all of the {@linkcode ManifestEntry} in the manifest.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-manifest.d.ts","sourceRoot":"","sources":["../../src/lib/transform-manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-manifest.d.ts","sourceRoot":"","sources":["../../src/lib/transform-manifest.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAqB,MAAM,aAAa,CAAC;AAMlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,UAAU,mCAAmC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAID,UAAU,wBACR,SAAQ,IAAI,CACV,YAAY,EACV,2BAA2B,GAC3B,2BAA2B,GAC3B,oBAAoB,GACpB,+BAA+B,GAC/B,iBAAiB,GACjB,yBAAyB,CAC5B;IACD,WAAW,EAAE,WAAW,EAAE,CAAC;IAG3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAsB,iBAAiB,CAAC,EACtC,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,kBAAkB,EAClB,6BAA6B,EAC7B,eAAe,EACf,cAAc,EACd,uBAAuB,GACxB,EAAE,wBAAwB,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAuEzE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -174,14 +174,6 @@ export interface GetManifestResult {
|
|
|
174
174
|
export type BuildResult = Omit<GetManifestResult, "manifestEntries"> & {
|
|
175
175
|
filePaths: string[];
|
|
176
176
|
};
|
|
177
|
-
/**
|
|
178
|
-
* @private
|
|
179
|
-
*/
|
|
180
|
-
export interface FileDetails {
|
|
181
|
-
file: string;
|
|
182
|
-
hash: string | null;
|
|
183
|
-
size: number;
|
|
184
|
-
}
|
|
185
177
|
/**
|
|
186
178
|
* @private
|
|
187
179
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAEhG,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;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MAAM,WAAW,GAAG,aAAa,GAAG,gBAAgB,GAAG,uBAAuB,GAAG,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/build",
|
|
3
|
-
"version": "10.0.0-preview.
|
|
3
|
+
"version": "10.0.0-preview.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.",
|
|
6
6
|
"files": [
|
|
@@ -48,20 +48,18 @@
|
|
|
48
48
|
"./package.json": "./package.json"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"common-tags": "1.8.2",
|
|
52
51
|
"glob": "11.0.1",
|
|
53
52
|
"pretty-bytes": "6.1.1",
|
|
54
53
|
"source-map": "0.8.0-beta.0",
|
|
55
54
|
"zod": "3.24.3",
|
|
56
|
-
"@serwist/utils": "10.0.0-preview.
|
|
55
|
+
"@serwist/utils": "10.0.0-preview.4"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
|
-
"@types/common-tags": "1.8.4",
|
|
60
58
|
"@types/node": "22.14.1",
|
|
61
59
|
"rollup": "4.40.0",
|
|
62
60
|
"type-fest": "4.40.0",
|
|
63
61
|
"typescript": "5.8.3",
|
|
64
|
-
"@serwist/configs": "10.0.0-preview.
|
|
62
|
+
"@serwist/configs": "10.0.0-preview.4"
|
|
65
63
|
},
|
|
66
64
|
"peerDependencies": {
|
|
67
65
|
"typescript": ">=5.0.0"
|
package/src/index.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
Use of this source code is governed by an MIT-style
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
import { errors } from "@serwist/utils/node";
|
|
9
|
+
|
|
8
10
|
import { getManifest } from "./get-manifest.js";
|
|
9
11
|
import { injectManifest } from "./inject-manifest.js";
|
|
10
|
-
import { errors } from "./lib/errors.js";
|
|
11
12
|
import { escapeRegExp } from "./lib/escape-regexp.js";
|
|
12
13
|
import { getFileManifestEntries } from "./lib/get-file-manifest-entries.js";
|
|
13
14
|
import { getSourceMapURL } from "./lib/get-source-map-url.js";
|
package/src/inject-manifest.ts
CHANGED
|
@@ -9,8 +9,9 @@ import assert from "node:assert";
|
|
|
9
9
|
import fsp from "node:fs/promises";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { toUnix } from "@serwist/utils";
|
|
12
|
+
import { errors } from "@serwist/utils/node";
|
|
12
13
|
import type { RawSourceMap } from "source-map";
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
import { escapeRegExp } from "./lib/escape-regexp.js";
|
|
15
16
|
import { getFileManifestEntries } from "./lib/get-file-manifest-entries.js";
|
|
16
17
|
import { getSourceMapURL } from "./lib/get-source-map-url.js";
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { errors } from "@serwist/utils/node";
|
|
9
9
|
import type { ManifestEntry } from "../types.js";
|
|
10
|
-
import { errors } from "./errors.js";
|
|
11
10
|
|
|
12
11
|
type AdditionalManifestEntriesTransform = (manifest: (ManifestEntry & { size: number })[]) => {
|
|
13
12
|
manifest: (ManifestEntry & { size: number })[];
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
import path from "node:path";
|
|
9
|
+
import type { FileDetails } from "@serwist/utils";
|
|
10
|
+
import { errors, getFileHash, getFileSize } from "@serwist/utils/node";
|
|
9
11
|
import { globSync } from "glob";
|
|
10
|
-
import type {
|
|
11
|
-
import { errors } from "./errors.js";
|
|
12
|
-
import { getFileHash } from "./get-file-hash.js";
|
|
13
|
-
import { getFileSize } from "./get-file-size.js";
|
|
12
|
+
import type { GlobPartial } from "../types.js";
|
|
14
13
|
|
|
15
14
|
export const getFileDetails = ({
|
|
16
15
|
globDirectory,
|
|
@@ -7,12 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import assert from "node:assert";
|
|
10
|
+
import type { FileDetails } from "@serwist/utils";
|
|
11
|
+
import { errors, getCompositeDetails, getStringDetails } from "@serwist/utils/node";
|
|
10
12
|
|
|
11
|
-
import type {
|
|
12
|
-
import { errors } from "./errors.js";
|
|
13
|
-
import { getCompositeDetails } from "./get-composite-details.js";
|
|
13
|
+
import type { GetManifestOptionsComplete, GetManifestResult } from "../types.js";
|
|
14
14
|
import { getFileDetails } from "./get-file-details.js";
|
|
15
|
-
import { getStringDetails } from "./get-string-details.js";
|
|
16
15
|
import { transformManifest } from "./transform-manifest.js";
|
|
17
16
|
|
|
18
17
|
export const getFileManifestEntries = async ({
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
+
import { errors } from "@serwist/utils/node";
|
|
8
9
|
|
|
9
10
|
import type { ManifestTransform } from "../types.js";
|
|
10
|
-
import { errors } from "./errors.js";
|
|
11
11
|
import { escapeRegExp } from "./escape-regexp.js";
|
|
12
12
|
|
|
13
13
|
export function modifyURLPrefixTransform(modifyURLPrefix: { [key: string]: string }): ManifestTransform {
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
+
import { errors } from "@serwist/utils/node";
|
|
8
9
|
|
|
9
10
|
import type { ManifestTransform } from "../types.js";
|
|
10
|
-
import { errors } from "./errors.js";
|
|
11
11
|
|
|
12
12
|
export function noRevisionForURLsMatchingTransform(regexp: RegExp): ManifestTransform {
|
|
13
13
|
if (!(regexp instanceof RegExp)) {
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
+
import type { FileDetails } from "@serwist/utils";
|
|
9
|
+
import { errors } from "@serwist/utils/node";
|
|
8
10
|
|
|
9
|
-
import type { BaseResolved,
|
|
11
|
+
import type { BaseResolved, ManifestEntry, ManifestTransform } from "../types.js";
|
|
10
12
|
import { additionalPrecacheEntriesTransform } from "./additional-precache-entries-transform.js";
|
|
11
|
-
import { errors } from "./errors.js";
|
|
12
13
|
import { maximumSizeTransform } from "./maximum-size-transform.js";
|
|
13
14
|
import { modifyURLPrefixTransform } from "./modify-url-prefix-transform.js";
|
|
14
15
|
import { noRevisionForURLsMatchingTransform } from "./no-revision-for-urls-matching-transform.js";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { toUnix } from "@serwist/utils";
|
|
11
|
-
import { errors } from "
|
|
11
|
+
import { errors } from "@serwist/utils/node";
|
|
12
12
|
|
|
13
13
|
export function translateURLToSourcemapPaths(
|
|
14
14
|
url: string | null,
|
package/src/types.ts
CHANGED
|
@@ -202,15 +202,6 @@ export type BuildResult = Omit<GetManifestResult, "manifestEntries"> & {
|
|
|
202
202
|
filePaths: string[];
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
-
/**
|
|
206
|
-
* @private
|
|
207
|
-
*/
|
|
208
|
-
export interface FileDetails {
|
|
209
|
-
file: string;
|
|
210
|
-
hash: string | null;
|
|
211
|
-
size: number;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
205
|
/**
|
|
215
206
|
* @private
|
|
216
207
|
*/
|
package/dist/lib/errors.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export declare const errors: {
|
|
2
|
-
"unable-to-get-rootdir": string;
|
|
3
|
-
"no-extension": string;
|
|
4
|
-
"invalid-file-manifest-name": string;
|
|
5
|
-
"unable-to-get-file-manifest-name": string;
|
|
6
|
-
"invalid-sw-dest": string;
|
|
7
|
-
"unable-to-get-sw-name": string;
|
|
8
|
-
"unable-to-get-save-config": string;
|
|
9
|
-
"unable-to-get-file-hash": string;
|
|
10
|
-
"unable-to-get-file-size": string;
|
|
11
|
-
"unable-to-glob-files": string;
|
|
12
|
-
"unable-to-make-manifest-directory": string;
|
|
13
|
-
"read-manifest-template-failure": string;
|
|
14
|
-
"populating-manifest-tmpl-failed": string;
|
|
15
|
-
"manifest-file-write-failure": string;
|
|
16
|
-
"unable-to-make-sw-directory": string;
|
|
17
|
-
"sw-write-failure": string;
|
|
18
|
-
"sw-write-failure-directory": string;
|
|
19
|
-
"unable-to-copy-serwist-libraries": string;
|
|
20
|
-
"invalid-glob-directory": string;
|
|
21
|
-
"invalid-dont-cache-bust": string;
|
|
22
|
-
"invalid-exclude-files": string;
|
|
23
|
-
"invalid-get-manifest-entries-input": string;
|
|
24
|
-
"invalid-manifest-path": string;
|
|
25
|
-
"invalid-manifest-entries": string;
|
|
26
|
-
"invalid-manifest-format": string;
|
|
27
|
-
"invalid-static-file-globs": string;
|
|
28
|
-
"invalid-templated-urls": string;
|
|
29
|
-
"templated-url-matches-glob": string;
|
|
30
|
-
"invalid-glob-ignores": string;
|
|
31
|
-
"manifest-entry-bad-url": string;
|
|
32
|
-
"modify-url-prefix-bad-prefixes": string;
|
|
33
|
-
"invalid-inject-manifest-arg": string;
|
|
34
|
-
"injection-point-not-found": string;
|
|
35
|
-
"multiple-injection-points": string;
|
|
36
|
-
"useless-glob-pattern": string;
|
|
37
|
-
"bad-template-urls-asset": string;
|
|
38
|
-
"invalid-generate-file-manifest-arg": string;
|
|
39
|
-
"invalid-sw-src": string;
|
|
40
|
-
"same-src-and-dest": string;
|
|
41
|
-
"no-module-name": string;
|
|
42
|
-
"bad-manifest-transforms-return-value": string;
|
|
43
|
-
"string-entry-warning": string;
|
|
44
|
-
"cant-find-sourcemap": string;
|
|
45
|
-
"manifest-transforms": string;
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/lib/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFlB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-composite-details.d.ts","sourceRoot":"","sources":["../../src/lib/get-composite-details.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM,EAAE,mBAAmB,WAAW,EAAE,KAAG,WAkB5F,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-file-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-hash.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,MAO1C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-file-size.d.ts","sourceRoot":"","sources":["../../src/lib/get-file-size.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAUnD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-string-details.d.ts","sourceRoot":"","sources":["../../src/lib/get-string-details.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,WAI1D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-string-hash.d.ts","sourceRoot":"","sources":["../../src/lib/get-string-hash.ts"],"names":[],"mappings":"AAQA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAI9D"}
|
package/src/lib/errors.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { oneLine as ol } from "common-tags";
|
|
10
|
-
|
|
11
|
-
export const errors = {
|
|
12
|
-
"unable-to-get-rootdir": "Unable to get the root directory of your web app.",
|
|
13
|
-
"no-extension": ol`Unable to detect a usable extension for a file in your web
|
|
14
|
-
app directory.`,
|
|
15
|
-
"invalid-file-manifest-name": ol`The File Manifest Name must have at least one
|
|
16
|
-
character.`,
|
|
17
|
-
"unable-to-get-file-manifest-name": "Unable to get a file manifest name.",
|
|
18
|
-
"invalid-sw-dest": `The 'swDest' value must be a valid path.`,
|
|
19
|
-
"unable-to-get-sw-name": "Unable to get a service worker file name.",
|
|
20
|
-
"unable-to-get-save-config": ol`An error occurred when asking to save details
|
|
21
|
-
in a config file.`,
|
|
22
|
-
"unable-to-get-file-hash": ol`An error occurred when attempting to create a
|
|
23
|
-
file hash.`,
|
|
24
|
-
"unable-to-get-file-size": ol`An error occurred when attempting to get a file
|
|
25
|
-
size.`,
|
|
26
|
-
"unable-to-glob-files": "An error occurred when globbing for files.",
|
|
27
|
-
"unable-to-make-manifest-directory": ol`Unable to make output directory for
|
|
28
|
-
file manifest.`,
|
|
29
|
-
"read-manifest-template-failure": "Unable to read template for file manifest",
|
|
30
|
-
"populating-manifest-tmpl-failed": ol`An error occurred when populating the
|
|
31
|
-
file manifest template.`,
|
|
32
|
-
"manifest-file-write-failure": "Unable to write the file manifest.",
|
|
33
|
-
"unable-to-make-sw-directory": ol`Unable to make the directories to output
|
|
34
|
-
the service worker path.`,
|
|
35
|
-
"sw-write-failure": "Unable to write the service worker file.",
|
|
36
|
-
"sw-write-failure-directory": ol`Unable to write the service worker file;
|
|
37
|
-
'swDest' should be a full path to the file, not a path to a directory.`,
|
|
38
|
-
"unable-to-copy-serwist-libraries": ol`One or more of the Serwist libraries
|
|
39
|
-
could not be copied over to the destination directory: `,
|
|
40
|
-
"invalid-glob-directory": ol`The supplied globDirectory must be a path as a
|
|
41
|
-
string.`,
|
|
42
|
-
"invalid-dont-cache-bust": ol`The supplied 'dontCacheBustURLsMatching'
|
|
43
|
-
parameter must be a RegExp.`,
|
|
44
|
-
"invalid-exclude-files": "The excluded files should be an array of strings.",
|
|
45
|
-
"invalid-get-manifest-entries-input": ol`The input to
|
|
46
|
-
'getFileManifestEntries()' must be an object.`,
|
|
47
|
-
"invalid-manifest-path": ol`The supplied manifest path is not a string with
|
|
48
|
-
at least one character.`,
|
|
49
|
-
"invalid-manifest-entries": ol`The manifest entries must be an array of
|
|
50
|
-
strings or JavaScript objects containing a url parameter.`,
|
|
51
|
-
"invalid-manifest-format": ol`The value of the 'format' option passed to
|
|
52
|
-
generateFileManifest() must be either 'iife' (the default) or 'es'.`,
|
|
53
|
-
"invalid-static-file-globs": ol`The 'globPatterns' value must be an array
|
|
54
|
-
of strings.`,
|
|
55
|
-
"invalid-templated-urls": ol`The 'templatedURLs' value should be an object
|
|
56
|
-
that maps URLs to either a string, or to an array of glob patterns.`,
|
|
57
|
-
"templated-url-matches-glob": ol`One of the 'templatedURLs' URLs is already
|
|
58
|
-
being tracked via 'globPatterns': `,
|
|
59
|
-
"invalid-glob-ignores": ol`The 'globIgnores' parameter must be an array of
|
|
60
|
-
glob pattern strings.`,
|
|
61
|
-
"manifest-entry-bad-url": ol`The generated manifest contains an entry without
|
|
62
|
-
a URL string. This is likely an error with @serwist/build.`,
|
|
63
|
-
"modify-url-prefix-bad-prefixes": ol`The 'modifyURLPrefix' parameter must be
|
|
64
|
-
an object with string key value pairs.`,
|
|
65
|
-
"invalid-inject-manifest-arg": ol`The input to 'injectManifest()' must be an
|
|
66
|
-
object.`,
|
|
67
|
-
"injection-point-not-found": ol`Unable to find a place to inject the manifest.
|
|
68
|
-
Please ensure that your service worker file contains the following: `,
|
|
69
|
-
"multiple-injection-points": ol`Please ensure that your 'swSrc' file contains
|
|
70
|
-
only one match for the following: `,
|
|
71
|
-
"useless-glob-pattern": ol`One of the glob patterns doesn't match any files.
|
|
72
|
-
Please remove or fix the following: `,
|
|
73
|
-
"bad-template-urls-asset": ol`There was an issue using one of the provided
|
|
74
|
-
'templatedURLs'.`,
|
|
75
|
-
"invalid-generate-file-manifest-arg": ol`The input to generateFileManifest()
|
|
76
|
-
must be an Object.`,
|
|
77
|
-
"invalid-sw-src": `The 'swSrc' file can't be read.`,
|
|
78
|
-
"same-src-and-dest": ol`Unable to find a place to inject the manifest. This is
|
|
79
|
-
likely because swSrc and swDest are configured to the same file.
|
|
80
|
-
Please ensure that your swSrc file contains the following:`,
|
|
81
|
-
"no-module-name": ol`You must provide a moduleName parameter when calling
|
|
82
|
-
getModuleURL().`,
|
|
83
|
-
"bad-manifest-transforms-return-value": ol`The return value from a
|
|
84
|
-
manifestTransform should be an object with 'manifest' and optionally
|
|
85
|
-
'warnings' properties.`,
|
|
86
|
-
"string-entry-warning": ol`Some items were passed to additionalPrecacheEntries
|
|
87
|
-
without revisioning info. This is generally NOT safe. Learn more at
|
|
88
|
-
https://bit.ly/wb-precache.`,
|
|
89
|
-
"cant-find-sourcemap": ol`The swSrc file refers to a sourcemap that can't be
|
|
90
|
-
opened:`,
|
|
91
|
-
"manifest-transforms": ol`When using manifestTransforms, you must provide
|
|
92
|
-
an array of functions.`,
|
|
93
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import crypto from "node:crypto";
|
|
10
|
-
|
|
11
|
-
import type { FileDetails } from "../types.js";
|
|
12
|
-
|
|
13
|
-
export const getCompositeDetails = (compositeURL: string, dependencyDetails: FileDetails[]): FileDetails => {
|
|
14
|
-
let totalSize = 0;
|
|
15
|
-
let compositeHash = "";
|
|
16
|
-
|
|
17
|
-
for (const fileDetails of dependencyDetails) {
|
|
18
|
-
totalSize += fileDetails.size;
|
|
19
|
-
compositeHash += fileDetails.hash === null ? "" : fileDetails.hash;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const md5 = crypto.createHash("md5");
|
|
23
|
-
md5.update(compositeHash);
|
|
24
|
-
const hashOfHashes = md5.digest("hex");
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
file: compositeURL,
|
|
28
|
-
hash: hashOfHashes,
|
|
29
|
-
size: totalSize,
|
|
30
|
-
};
|
|
31
|
-
};
|
package/src/lib/get-file-hash.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { readFileSync } from "node:fs";
|
|
10
|
-
|
|
11
|
-
import { errors } from "./errors.js";
|
|
12
|
-
import { getStringHash } from "./get-string-hash.js";
|
|
13
|
-
|
|
14
|
-
export const getFileHash = (file: string): string => {
|
|
15
|
-
try {
|
|
16
|
-
const buffer = readFileSync(file);
|
|
17
|
-
return getStringHash(buffer);
|
|
18
|
-
} catch (err) {
|
|
19
|
-
throw new Error(`${errors["unable-to-get-file-hash"]} '${err instanceof Error && err.message ? err.message : ""}'`);
|
|
20
|
-
}
|
|
21
|
-
};
|
package/src/lib/get-file-size.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import { errors } from "./errors.js";
|
|
11
|
-
|
|
12
|
-
export const getFileSize = (file: string): number | null => {
|
|
13
|
-
try {
|
|
14
|
-
const stat = fs.statSync(file);
|
|
15
|
-
if (!stat.isFile()) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return stat.size;
|
|
19
|
-
} catch (err) {
|
|
20
|
-
throw new Error(`${errors["unable-to-get-file-size"]} '${err instanceof Error && err.message ? err.message : ""}'`);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { FileDetails } from "../types.js";
|
|
10
|
-
import { getStringHash } from "./get-string-hash.js";
|
|
11
|
-
|
|
12
|
-
export const getStringDetails = (url: string, str: string): FileDetails => ({
|
|
13
|
-
file: url,
|
|
14
|
-
hash: getStringHash(str),
|
|
15
|
-
size: str.length,
|
|
16
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2018 Google LLC
|
|
3
|
-
|
|
4
|
-
Use of this source code is governed by an MIT-style
|
|
5
|
-
license that can be found in the LICENSE file or at
|
|
6
|
-
https://opensource.org/licenses/MIT.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import crypto from "node:crypto";
|
|
10
|
-
|
|
11
|
-
export function getStringHash(input: crypto.BinaryLike): string {
|
|
12
|
-
const md5 = crypto.createHash("md5");
|
|
13
|
-
md5.update(input);
|
|
14
|
-
return md5.digest("hex");
|
|
15
|
-
}
|