@pagepocket/write-down-unit 0.11.1 → 0.13.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Unit, type CaptureResult, type UnitContext } from "@pagepocket/lib";
|
|
1
|
+
import { Unit, type CaptureResult, type UnitContext, type UnitRuntime } from "@pagepocket/lib";
|
|
2
2
|
export type WriteDownUnitOptions = {
|
|
3
3
|
type: "raw" | "zip";
|
|
4
4
|
outputPath: string;
|
|
@@ -11,10 +11,10 @@ export type WriteDownUnitOptions = {
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class WriteDownUnit extends Unit {
|
|
13
13
|
readonly id = "writeDown";
|
|
14
|
-
readonly
|
|
14
|
+
readonly description = "Writing snapshot to disk";
|
|
15
15
|
private options;
|
|
16
16
|
constructor(options: WriteDownUnitOptions);
|
|
17
|
-
run(ctx: UnitContext, rt:
|
|
17
|
+
run(ctx: UnitContext, rt: UnitRuntime): Promise<{
|
|
18
18
|
__pagepocketResult: CaptureResult;
|
|
19
19
|
}>;
|
|
20
20
|
}
|
package/dist/write-down-unit.js
CHANGED
package/dist/write-down.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { FileTree } from "@pagepocket/lib";
|
|
1
|
+
import type { EntryInfo, FileTree, PagePocketCaptureResult } from "@pagepocket/lib";
|
|
2
2
|
export type WriteDownOptions = {
|
|
3
3
|
type: "raw" | "zip";
|
|
4
4
|
outputPath: string;
|
|
5
5
|
overwrite: boolean;
|
|
6
6
|
};
|
|
7
|
-
type EntryInfo = import("@pagepocket/lib").EntryInfo;
|
|
8
7
|
export declare const writeDown: (input: {
|
|
9
8
|
entry: EntryInfo;
|
|
10
9
|
html: {
|
|
@@ -16,5 +15,4 @@ export declare const writeDown: (input: {
|
|
|
16
15
|
type: WriteDownOptions["type"];
|
|
17
16
|
outputPath: string;
|
|
18
17
|
overwrite: boolean;
|
|
19
|
-
}) => Promise<
|
|
20
|
-
export {};
|
|
18
|
+
}) => Promise<PagePocketCaptureResult>;
|
package/dist/write-down.js
CHANGED
|
@@ -25,21 +25,19 @@ const tryHostname = (url) => {
|
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
const pathExists = async (
|
|
28
|
+
const pathExists = async (pathToCheck) => {
|
|
29
29
|
try {
|
|
30
|
-
await stat(
|
|
30
|
+
await stat(pathToCheck);
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
33
|
catch {
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const removeExistingPath = async (
|
|
38
|
-
await rm(
|
|
39
|
-
};
|
|
40
|
-
const isUrlEntry = (entry) => {
|
|
41
|
-
return entry.kind === "url";
|
|
37
|
+
const removeExistingPath = async (pathToRemove) => {
|
|
38
|
+
await rm(pathToRemove, { force: true, recursive: true });
|
|
42
39
|
};
|
|
40
|
+
const isUrlEntry = (entry) => entry.kind === "url";
|
|
43
41
|
const withUniquePath = async (desiredPath, options) => {
|
|
44
42
|
if (!(await pathExists(desiredPath))) {
|
|
45
43
|
return desiredPath;
|
|
@@ -51,8 +49,8 @@ const withUniquePath = async (desiredPath, options) => {
|
|
|
51
49
|
const parsed = pathMod.parse(desiredPath);
|
|
52
50
|
const base = pathMod.join(parsed.dir, parsed.name);
|
|
53
51
|
const ext = parsed.ext;
|
|
54
|
-
for (let
|
|
55
|
-
const candidate = `${base}-${
|
|
52
|
+
for (let candidateIndex = 2; candidateIndex <= 9999; candidateIndex += 1) {
|
|
53
|
+
const candidate = `${base}-${candidateIndex}${ext}`;
|
|
56
54
|
if (!(await pathExists(candidate))) {
|
|
57
55
|
return candidate;
|
|
58
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagepocket/write-down-unit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "PagePocket plugin: write snapshot output to fs (raw or zip)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"fflate": "^0.8.2",
|
|
14
|
-
"@pagepocket/lib": "0.
|
|
15
|
-
"@pagepocket/contracts": "0.
|
|
16
|
-
"@pagepocket/uni-fs": "0.
|
|
14
|
+
"@pagepocket/lib": "0.13.0",
|
|
15
|
+
"@pagepocket/contracts": "0.13.0",
|
|
16
|
+
"@pagepocket/uni-fs": "0.13.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^20.17.12",
|