@schalkneethling/calavera-artifact-core 0.2.0-next.1
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 +21 -0
- package/README.md +3 -0
- package/package.json +46 -0
- package/src/catalog.js +139 -0
- package/src/node.js +16 -0
- package/src/registry.js +142 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Schalk Neethling
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@schalkneethling/calavera-artifact-core",
|
|
3
|
+
"version": "0.2.0-next.1",
|
|
4
|
+
"description": "Catalog and package resolution primitives for Calavera artifacts.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+ssh://git@github.com/schalkneethling/create-project-calavera.git",
|
|
9
|
+
"directory": "packages/artifact-core"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./src/catalog.js",
|
|
17
|
+
"./node": "./src/node.js",
|
|
18
|
+
"./registry": "./src/registry.js"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"provenance": true
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"pacote": "22.0.0",
|
|
26
|
+
"semver": "7.8.5",
|
|
27
|
+
"@schalkneethling/calavera-agent-technical-devils-advocate": "^0.2.0-next.1",
|
|
28
|
+
"@schalkneethling/calavera-hook-block-dangerous-commands": "^0.2.0-next.1",
|
|
29
|
+
"@schalkneethling/calavera-skill-calavera": "^0.2.0-next.1",
|
|
30
|
+
"@schalkneethling/calavera-skill-code-review": "^0.2.0-next.1",
|
|
31
|
+
"@schalkneethling/calavera-hook-auto-approve-safe-commands": "^0.2.0-next.1",
|
|
32
|
+
"@schalkneethling/calavera-skill-frontend-engineering": "^0.2.0-next.1",
|
|
33
|
+
"@schalkneethling/calavera-skill-frontend-security": "^0.2.0-next.1",
|
|
34
|
+
"@schalkneethling/calavera-skill-frontend-testing": "^0.2.0-next.1",
|
|
35
|
+
"@schalkneethling/calavera-skill-github-goal-issue-triage": "^0.2.0-next.1",
|
|
36
|
+
"@schalkneethling/calavera-skill-css-tokens": "^0.2.0-next.1",
|
|
37
|
+
"@schalkneethling/calavera-skill-more-secure-dependabot-config": "^0.2.0-next.1",
|
|
38
|
+
"@schalkneethling/calavera-skill-npm-trusted-publishing-github-workflow": "^0.2.0-next.1",
|
|
39
|
+
"@schalkneethling/calavera-skill-project-goal": "^0.2.0-next.1",
|
|
40
|
+
"@schalkneethling/calavera-skill-refined-plan-mode": "^0.2.0-next.1",
|
|
41
|
+
"@schalkneethling/calavera-skill-npm-publishing-best-practices": "^0.2.0-next.1"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "node --test test/*.test.mjs"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/catalog.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import manifest1 from "@schalkneethling/calavera-skill-calavera" with { type: "json" };
|
|
3
|
+
import manifest2 from "@schalkneethling/calavera-skill-code-review" with { type: "json" };
|
|
4
|
+
import manifest3 from "@schalkneethling/calavera-skill-css-tokens" with { type: "json" };
|
|
5
|
+
import manifest4 from "@schalkneethling/calavera-skill-frontend-engineering" with { type: "json" };
|
|
6
|
+
import manifest5 from "@schalkneethling/calavera-skill-frontend-security" with { type: "json" };
|
|
7
|
+
import manifest6 from "@schalkneethling/calavera-skill-frontend-testing" with { type: "json" };
|
|
8
|
+
import manifest7 from "@schalkneethling/calavera-skill-github-goal-issue-triage" with { type: "json" };
|
|
9
|
+
import manifest8 from "@schalkneethling/calavera-skill-more-secure-dependabot-config" with { type: "json" };
|
|
10
|
+
import manifest9 from "@schalkneethling/calavera-skill-npm-publishing-best-practices" with { type: "json" };
|
|
11
|
+
import manifest10 from "@schalkneethling/calavera-skill-npm-trusted-publishing-github-workflow" with { type: "json" };
|
|
12
|
+
import manifest11 from "@schalkneethling/calavera-skill-project-goal" with { type: "json" };
|
|
13
|
+
import manifest12 from "@schalkneethling/calavera-skill-refined-plan-mode" with { type: "json" };
|
|
14
|
+
import manifest13 from "@schalkneethling/calavera-hook-auto-approve-safe-commands" with { type: "json" };
|
|
15
|
+
import manifest14 from "@schalkneethling/calavera-hook-block-dangerous-commands" with { type: "json" };
|
|
16
|
+
import manifest15 from "@schalkneethling/calavera-agent-technical-devils-advocate" with { type: "json" };
|
|
17
|
+
import package1 from "@schalkneethling/calavera-skill-calavera/package.json" with { type: "json" };
|
|
18
|
+
import package2 from "@schalkneethling/calavera-skill-code-review/package.json" with { type: "json" };
|
|
19
|
+
import package3 from "@schalkneethling/calavera-skill-css-tokens/package.json" with { type: "json" };
|
|
20
|
+
import package4 from "@schalkneethling/calavera-skill-frontend-engineering/package.json" with { type: "json" };
|
|
21
|
+
import package5 from "@schalkneethling/calavera-skill-frontend-security/package.json" with { type: "json" };
|
|
22
|
+
import package6 from "@schalkneethling/calavera-skill-frontend-testing/package.json" with { type: "json" };
|
|
23
|
+
import package7 from "@schalkneethling/calavera-skill-github-goal-issue-triage/package.json" with { type: "json" };
|
|
24
|
+
import package8 from "@schalkneethling/calavera-skill-more-secure-dependabot-config/package.json" with { type: "json" };
|
|
25
|
+
import package9 from "@schalkneethling/calavera-skill-npm-publishing-best-practices/package.json" with { type: "json" };
|
|
26
|
+
import package10 from "@schalkneethling/calavera-skill-npm-trusted-publishing-github-workflow/package.json" with { type: "json" };
|
|
27
|
+
import package11 from "@schalkneethling/calavera-skill-project-goal/package.json" with { type: "json" };
|
|
28
|
+
import package12 from "@schalkneethling/calavera-skill-refined-plan-mode/package.json" with { type: "json" };
|
|
29
|
+
import package13 from "@schalkneethling/calavera-hook-auto-approve-safe-commands/package.json" with { type: "json" };
|
|
30
|
+
import package14 from "@schalkneethling/calavera-hook-block-dangerous-commands/package.json" with { type: "json" };
|
|
31
|
+
import package15 from "@schalkneethling/calavera-agent-technical-devils-advocate/package.json" with { type: "json" };
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_ARTIFACT_TARGET = "claude-code";
|
|
34
|
+
|
|
35
|
+
const packageVersions = new Map([
|
|
36
|
+
["@schalkneethling/calavera-skill-calavera", package1.version],
|
|
37
|
+
["@schalkneethling/calavera-skill-code-review", package2.version],
|
|
38
|
+
["@schalkneethling/calavera-skill-css-tokens", package3.version],
|
|
39
|
+
["@schalkneethling/calavera-skill-frontend-engineering", package4.version],
|
|
40
|
+
["@schalkneethling/calavera-skill-frontend-security", package5.version],
|
|
41
|
+
["@schalkneethling/calavera-skill-frontend-testing", package6.version],
|
|
42
|
+
["@schalkneethling/calavera-skill-github-goal-issue-triage", package7.version],
|
|
43
|
+
["@schalkneethling/calavera-skill-more-secure-dependabot-config", package8.version],
|
|
44
|
+
["@schalkneethling/calavera-skill-npm-publishing-best-practices", package9.version],
|
|
45
|
+
["@schalkneethling/calavera-skill-npm-trusted-publishing-github-workflow", package10.version],
|
|
46
|
+
["@schalkneethling/calavera-skill-project-goal", package11.version],
|
|
47
|
+
["@schalkneethling/calavera-skill-refined-plan-mode", package12.version],
|
|
48
|
+
["@schalkneethling/calavera-hook-auto-approve-safe-commands", package13.version],
|
|
49
|
+
["@schalkneethling/calavera-hook-block-dangerous-commands", package14.version],
|
|
50
|
+
["@schalkneethling/calavera-agent-technical-devils-advocate", package15.version],
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
export const artifactCatalog = Object.freeze([
|
|
54
|
+
artifact(manifest1, "@schalkneethling/calavera-skill-calavera", "skills/calavera"),
|
|
55
|
+
artifact(manifest2, "@schalkneethling/calavera-skill-code-review", "skills/code-review"),
|
|
56
|
+
artifact(manifest3, "@schalkneethling/calavera-skill-css-tokens", "skills/css-tokens"),
|
|
57
|
+
artifact(
|
|
58
|
+
manifest4,
|
|
59
|
+
"@schalkneethling/calavera-skill-frontend-engineering",
|
|
60
|
+
"skills/frontend-engineering",
|
|
61
|
+
),
|
|
62
|
+
artifact(
|
|
63
|
+
manifest5,
|
|
64
|
+
"@schalkneethling/calavera-skill-frontend-security",
|
|
65
|
+
"skills/frontend-security",
|
|
66
|
+
),
|
|
67
|
+
artifact(
|
|
68
|
+
manifest6,
|
|
69
|
+
"@schalkneethling/calavera-skill-frontend-testing",
|
|
70
|
+
"skills/frontend-testing",
|
|
71
|
+
),
|
|
72
|
+
artifact(
|
|
73
|
+
manifest7,
|
|
74
|
+
"@schalkneethling/calavera-skill-github-goal-issue-triage",
|
|
75
|
+
"skills/github-goal-issue-triage",
|
|
76
|
+
),
|
|
77
|
+
artifact(
|
|
78
|
+
manifest8,
|
|
79
|
+
"@schalkneethling/calavera-skill-more-secure-dependabot-config",
|
|
80
|
+
"skills/more-secure-dependabot-config",
|
|
81
|
+
),
|
|
82
|
+
artifact(
|
|
83
|
+
manifest9,
|
|
84
|
+
"@schalkneethling/calavera-skill-npm-publishing-best-practices",
|
|
85
|
+
"skills/npm-publishing-best-practices",
|
|
86
|
+
),
|
|
87
|
+
artifact(
|
|
88
|
+
manifest10,
|
|
89
|
+
"@schalkneethling/calavera-skill-npm-trusted-publishing-github-workflow",
|
|
90
|
+
"skills/npm-trusted-publishing-github-workflow",
|
|
91
|
+
),
|
|
92
|
+
artifact(manifest11, "@schalkneethling/calavera-skill-project-goal", "skills/project-goal"),
|
|
93
|
+
artifact(
|
|
94
|
+
manifest12,
|
|
95
|
+
"@schalkneethling/calavera-skill-refined-plan-mode",
|
|
96
|
+
"skills/refined-plan-mode",
|
|
97
|
+
),
|
|
98
|
+
artifact(
|
|
99
|
+
manifest13,
|
|
100
|
+
"@schalkneethling/calavera-hook-auto-approve-safe-commands",
|
|
101
|
+
"hooks/auto-approve-safe-commands",
|
|
102
|
+
),
|
|
103
|
+
artifact(
|
|
104
|
+
manifest14,
|
|
105
|
+
"@schalkneethling/calavera-hook-block-dangerous-commands",
|
|
106
|
+
"hooks/block-dangerous-commands",
|
|
107
|
+
),
|
|
108
|
+
artifact(
|
|
109
|
+
manifest15,
|
|
110
|
+
"@schalkneethling/calavera-agent-technical-devils-advocate",
|
|
111
|
+
"agents/technical-devils-advocate.md",
|
|
112
|
+
),
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param {{ id: string, type: string, displayName: string, payload: string, [key: string]: unknown }} manifest
|
|
117
|
+
* @param {string} packageName
|
|
118
|
+
* @param {string} legacyPath
|
|
119
|
+
*/
|
|
120
|
+
function artifact(manifest, packageName, legacyPath) {
|
|
121
|
+
return Object.freeze({
|
|
122
|
+
...manifest,
|
|
123
|
+
packageName,
|
|
124
|
+
version: packageVersions.get(packageName),
|
|
125
|
+
legacyPath,
|
|
126
|
+
group: manifest.type === "skill" ? "Skills" : manifest.type === "hook" ? "Hooks" : "Agents",
|
|
127
|
+
defaultTarget: manifest.type === "skill" ? undefined : DEFAULT_ARTIFACT_TARGET,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** @param {string} id */
|
|
132
|
+
export function artifactForId(id) {
|
|
133
|
+
return artifactCatalog.find((artifact) => artifact.id === id);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** @param {string} path */
|
|
137
|
+
export function artifactForLegacyPath(path) {
|
|
138
|
+
return artifactCatalog.find((artifact) => artifact.legacyPath === path);
|
|
139
|
+
}
|
package/src/node.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { artifactForId, artifactForLegacyPath } from "./catalog.js";
|
|
6
|
+
|
|
7
|
+
/** @param {string} idOrLegacyPath */
|
|
8
|
+
export function artifactPayloadPath(idOrLegacyPath) {
|
|
9
|
+
const artifact = artifactForId(idOrLegacyPath) ?? artifactForLegacyPath(idOrLegacyPath);
|
|
10
|
+
if (!artifact) {
|
|
11
|
+
throw new Error(`Unknown Calavera artifact: ${idOrLegacyPath}.`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const manifestUrl = import.meta.resolve(artifact.packageName);
|
|
15
|
+
return join(dirname(fileURLToPath(manifestUrl)), artifact.payload);
|
|
16
|
+
}
|
package/src/registry.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
4
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
import pacote from "pacote";
|
|
7
|
+
import semver from "semver";
|
|
8
|
+
|
|
9
|
+
import { artifactForId } from "./catalog.js";
|
|
10
|
+
|
|
11
|
+
const TAGS = new Set(["latest", "next"]);
|
|
12
|
+
|
|
13
|
+
/** @param {{ id: string, tag?: string, version?: string, cache: string, offline?: boolean }} request */
|
|
14
|
+
export async function resolveArtifactPackage(request) {
|
|
15
|
+
const artifact = artifactForId(request.id);
|
|
16
|
+
if (!artifact) throw new Error(`Unknown Calavera artifact: ${request.id}.`);
|
|
17
|
+
const tag = request.tag ?? "latest";
|
|
18
|
+
if (!TAGS.has(tag)) throw new Error("Artifact release tag must be latest or next.");
|
|
19
|
+
if (request.version && !semver.valid(request.version)) {
|
|
20
|
+
throw new Error(`Artifact version must be exact semver: ${request.version}.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const manifest = await pacote.manifest(`${artifact.packageName}@${request.version ?? tag}`, {
|
|
24
|
+
cache: request.cache,
|
|
25
|
+
offline: request.offline,
|
|
26
|
+
fullMetadata: true,
|
|
27
|
+
});
|
|
28
|
+
if (manifest.name !== artifact.packageName || !semver.valid(manifest.version)) {
|
|
29
|
+
throw new Error(`Resolved package identity mismatch for ${artifact.packageName}.`);
|
|
30
|
+
}
|
|
31
|
+
if (!manifest.dist?.tarball || !manifest.dist.integrity) {
|
|
32
|
+
throw new Error(`Registry metadata for ${artifact.packageName} is missing tarball integrity.`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
artifact,
|
|
37
|
+
packageName: artifact.packageName,
|
|
38
|
+
version: manifest.version,
|
|
39
|
+
resolved: manifest.dist.tarball,
|
|
40
|
+
integrity: String(manifest.dist.integrity),
|
|
41
|
+
tag,
|
|
42
|
+
cache: request.cache,
|
|
43
|
+
offline: request.offline ?? false,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {{ artifact: { id: string, type: string, packageName: string }, packageName: string, version: string, resolved: string, integrity?: string, tag: string, cache: string, offline: boolean }} resolution
|
|
49
|
+
* @param {string} destination
|
|
50
|
+
* @param {string} cliVersion
|
|
51
|
+
*/
|
|
52
|
+
export async function extractArtifactPackage(resolution, destination, cliVersion) {
|
|
53
|
+
await pacote.extract(resolution.resolved, destination, {
|
|
54
|
+
cache: resolution.cache,
|
|
55
|
+
integrity: resolution.integrity,
|
|
56
|
+
offline: resolution.offline,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const packageJson = JSON.parse(await readFile(join(destination, "package.json"), "utf8"));
|
|
60
|
+
const manifest = JSON.parse(await readFile(join(destination, "calavera-artifact.json"), "utf8"));
|
|
61
|
+
if (packageJson.name !== resolution.packageName || packageJson.version !== resolution.version) {
|
|
62
|
+
throw new Error("Extracted package identity does not match registry metadata.");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
validateArtifactManifest(manifest, resolution.artifact, cliVersion);
|
|
66
|
+
const payloadPath = safePayloadPath(destination, manifest.payload);
|
|
67
|
+
const payloadStats = await stat(payloadPath);
|
|
68
|
+
if ((manifest.type === "agent") !== payloadStats.isFile()) {
|
|
69
|
+
throw new Error(`Artifact payload kind does not match manifest type ${manifest.type}.`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return { manifest, payloadPath, payloadHash: await hashArtifactPayload(payloadPath) };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {Record<string, unknown>} manifest
|
|
77
|
+
* @param {{ id: string, type: string, packageName: string }} artifact
|
|
78
|
+
* @param {string} cliVersion
|
|
79
|
+
*/
|
|
80
|
+
function validateArtifactManifest(manifest, artifact, cliVersion) {
|
|
81
|
+
if (
|
|
82
|
+
manifest.schemaVersion !== 1 ||
|
|
83
|
+
manifest.id !== artifact.id ||
|
|
84
|
+
manifest.type !== artifact.type ||
|
|
85
|
+
typeof manifest.payload !== "string" ||
|
|
86
|
+
!manifest.payload ||
|
|
87
|
+
!manifest.compatibility ||
|
|
88
|
+
typeof manifest.compatibility !== "object"
|
|
89
|
+
) {
|
|
90
|
+
throw new Error(`Invalid artifact manifest for ${artifact.packageName}.`);
|
|
91
|
+
}
|
|
92
|
+
const compatibility = /** @type {Record<string, unknown>} */ (manifest.compatibility).calavera;
|
|
93
|
+
if (typeof compatibility !== "string" || !semver.satisfies(cliVersion, compatibility)) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`${artifact.packageName} is not compatible with create-project-calavera ${cliVersion}.`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** @param {string} root @param {string} payload */
|
|
101
|
+
function safePayloadPath(root, payload) {
|
|
102
|
+
const payloadPath = resolve(root, payload);
|
|
103
|
+
const relativePath = relative(root, payloadPath);
|
|
104
|
+
if (!relativePath || relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
105
|
+
throw new Error("Artifact payload must stay inside its package.");
|
|
106
|
+
}
|
|
107
|
+
return payloadPath;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** @param {string} path */
|
|
111
|
+
export async function hashArtifactPayload(path) {
|
|
112
|
+
const payloadStats = await stat(path);
|
|
113
|
+
const hash = createHash("sha256");
|
|
114
|
+
if (payloadStats.isFile()) {
|
|
115
|
+
hash.update(await readFile(path));
|
|
116
|
+
return hash.digest("hex");
|
|
117
|
+
}
|
|
118
|
+
for (const entry of await payloadFiles(path)) {
|
|
119
|
+
hash.update(entry).update("\0");
|
|
120
|
+
if (!entry.endsWith("/")) {
|
|
121
|
+
hash.update(await readFile(join(path, entry))).update("\0");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return hash.digest("hex");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {string} root
|
|
129
|
+
* @param {string} [directory]
|
|
130
|
+
* @returns {Promise<string[]>}
|
|
131
|
+
*/
|
|
132
|
+
async function payloadFiles(root, directory = root) {
|
|
133
|
+
const files = [];
|
|
134
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
135
|
+
const path = join(directory, entry.name);
|
|
136
|
+
if (entry.isDirectory()) {
|
|
137
|
+
files.push(`${relative(root, path)}/`);
|
|
138
|
+
files.push(...(await payloadFiles(root, path)));
|
|
139
|
+
} else if (entry.isFile()) files.push(relative(root, path));
|
|
140
|
+
}
|
|
141
|
+
return files.sort();
|
|
142
|
+
}
|