@johnhenry/sitefile 0.0.0-stage → 0.0.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.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +475 -2
- package/lib/src/archive-writers.d.ts +31 -0
- package/lib/src/archive-writers.js +197 -0
- package/lib/src/attest.d.ts +126 -0
- package/lib/src/attest.js +220 -0
- package/lib/src/bake.d.ts +74 -0
- package/lib/src/bake.js +372 -0
- package/lib/src/base-image.d.ts +76 -0
- package/lib/src/base-image.js +138 -0
- package/lib/src/build-args.d.ts +26 -0
- package/lib/src/build-args.js +164 -0
- package/lib/src/cache-limit.d.ts +54 -0
- package/lib/src/cache-limit.js +239 -0
- package/lib/src/casefold-data.d.ts +2 -0
- package/lib/src/casefold-data.js +217 -0
- package/lib/src/cbor.d.ts +39 -0
- package/lib/src/cbor.js +174 -0
- package/lib/src/checklinks.d.ts +42 -0
- package/lib/src/checklinks.js +118 -0
- package/lib/src/cli/bake.d.ts +2 -0
- package/lib/src/cli/bake.js +179 -0
- package/lib/src/cli/build-image.d.ts +21 -0
- package/lib/src/cli/build-image.js +42 -0
- package/lib/src/cli/cache.d.ts +8 -0
- package/lib/src/cli/cache.js +109 -0
- package/lib/src/cli/common.d.ts +29 -0
- package/lib/src/cli/common.js +100 -0
- package/lib/src/cli/git-context.d.ts +18 -0
- package/lib/src/cli/git-context.js +48 -0
- package/lib/src/cli/images.d.ts +6 -0
- package/lib/src/cli/images.js +285 -0
- package/lib/src/cli/index.d.ts +10 -0
- package/lib/src/cli/index.js +95 -0
- package/lib/src/cli/outdated.d.ts +5 -0
- package/lib/src/cli/outdated.js +94 -0
- package/lib/src/cli/registry.d.ts +2 -0
- package/lib/src/cli/registry.js +122 -0
- package/lib/src/cli/serve-worker.d.ts +2 -0
- package/lib/src/cli/serve-worker.js +42 -0
- package/lib/src/cli/servers.d.ts +15 -0
- package/lib/src/cli/servers.js +451 -0
- package/lib/src/cli/vendor.d.ts +2 -0
- package/lib/src/cli/vendor.js +92 -0
- package/lib/src/cli/watch.d.ts +26 -0
- package/lib/src/cli/watch.js +81 -0
- package/lib/src/cli.d.ts +12 -0
- package/lib/src/cli.js +486 -0
- package/lib/src/csv.d.ts +27 -0
- package/lib/src/csv.js +117 -0
- package/lib/src/deflate.d.ts +76 -0
- package/lib/src/deflate.js +604 -0
- package/lib/src/digest.d.ts +3 -0
- package/lib/src/digest.js +7 -0
- package/lib/src/errors.d.ts +34 -0
- package/lib/src/errors.js +20 -0
- package/lib/src/executor.d.ts +386 -0
- package/lib/src/executor.js +2193 -0
- package/lib/src/explain.d.ts +64 -0
- package/lib/src/explain.js +445 -0
- package/lib/src/export-formats.d.ts +16 -0
- package/lib/src/export-formats.js +52 -0
- package/lib/src/exporter.d.ts +103 -0
- package/lib/src/exporter.js +676 -0
- package/lib/src/fingerprint.d.ts +40 -0
- package/lib/src/fingerprint.js +168 -0
- package/lib/src/frontmatter.d.ts +22 -0
- package/lib/src/frontmatter.js +45 -0
- package/lib/src/index.d.ts +12 -0
- package/lib/src/index.js +12 -0
- package/lib/src/language/ast.d.ts +353 -0
- package/lib/src/language/ast.js +57 -0
- package/lib/src/language/parser.d.ts +3 -0
- package/lib/src/language/parser.js +612 -0
- package/lib/src/language/scanner.d.ts +110 -0
- package/lib/src/language/scanner.js +449 -0
- package/lib/src/language/validate.d.ts +13 -0
- package/lib/src/language/validate.js +367 -0
- package/lib/src/links.d.ts +79 -0
- package/lib/src/links.js +583 -0
- package/lib/src/lint.d.ts +10 -0
- package/lib/src/lint.js +223 -0
- package/lib/src/markdown.d.ts +29 -0
- package/lib/src/markdown.js +612 -0
- package/lib/src/media.d.ts +82 -0
- package/lib/src/media.js +650 -0
- package/lib/src/memo.d.ts +57 -0
- package/lib/src/memo.js +93 -0
- package/lib/src/oci.d.ts +178 -0
- package/lib/src/oci.js +380 -0
- package/lib/src/outdated.d.ts +46 -0
- package/lib/src/outdated.js +195 -0
- package/lib/src/pages.d.ts +10 -0
- package/lib/src/pages.js +54 -0
- package/lib/src/paths.d.ts +39 -0
- package/lib/src/paths.js +101 -0
- package/lib/src/planner.d.ts +297 -0
- package/lib/src/planner.js +410 -0
- package/lib/src/plugins/cache.d.ts +70 -0
- package/lib/src/plugins/cache.js +226 -0
- package/lib/src/plugins/exec.d.ts +51 -0
- package/lib/src/plugins/exec.js +144 -0
- package/lib/src/plugins/host.d.ts +75 -0
- package/lib/src/plugins/host.js +277 -0
- package/lib/src/plugins/wasm.d.ts +23 -0
- package/lib/src/plugins/wasm.js +249 -0
- package/lib/src/profile.d.ts +42 -0
- package/lib/src/profile.js +68 -0
- package/lib/src/ref.d.ts +40 -0
- package/lib/src/ref.js +79 -0
- package/lib/src/registry-auth.d.ts +32 -0
- package/lib/src/registry-auth.js +151 -0
- package/lib/src/registry-cache.d.ts +71 -0
- package/lib/src/registry-cache.js +333 -0
- package/lib/src/registry-ops.d.ts +51 -0
- package/lib/src/registry-ops.js +248 -0
- package/lib/src/registry.d.ts +109 -0
- package/lib/src/registry.js +505 -0
- package/lib/src/render.d.ts +134 -0
- package/lib/src/render.js +576 -0
- package/lib/src/resources/archive.d.ts +11 -0
- package/lib/src/resources/archive.js +306 -0
- package/lib/src/resources/bundle-data.d.ts +16 -0
- package/lib/src/resources/bundle-data.js +50 -0
- package/lib/src/resources/convert.d.ts +12 -0
- package/lib/src/resources/convert.js +63 -0
- package/lib/src/resources/documents.d.ts +35 -0
- package/lib/src/resources/documents.js +122 -0
- package/lib/src/resources/git.d.ts +103 -0
- package/lib/src/resources/git.js +720 -0
- package/lib/src/resources/https.d.ts +40 -0
- package/lib/src/resources/https.js +256 -0
- package/lib/src/resources/ignore.d.ts +33 -0
- package/lib/src/resources/ignore.js +119 -0
- package/lib/src/resources/local.d.ts +64 -0
- package/lib/src/resources/local.js +248 -0
- package/lib/src/resources/lockfile.d.ts +52 -0
- package/lib/src/resources/lockfile.js +172 -0
- package/lib/src/resources/netpolicy.d.ts +6 -0
- package/lib/src/resources/netpolicy.js +82 -0
- package/lib/src/resources/types.d.ts +63 -0
- package/lib/src/resources/types.js +13 -0
- package/lib/src/resources/vendor.d.ts +94 -0
- package/lib/src/resources/vendor.js +296 -0
- package/lib/src/resources/wbn-reader.d.ts +44 -0
- package/lib/src/resources/wbn-reader.js +302 -0
- package/lib/src/schema.d.ts +25 -0
- package/lib/src/schema.js +169 -0
- package/lib/src/secrets.d.ts +21 -0
- package/lib/src/secrets.js +103 -0
- package/lib/src/serve-rules.d.ts +29 -0
- package/lib/src/serve-rules.js +122 -0
- package/lib/src/server.d.ts +45 -0
- package/lib/src/server.js +246 -0
- package/lib/src/servers.d.ts +71 -0
- package/lib/src/servers.js +139 -0
- package/lib/src/site.d.ts +60 -0
- package/lib/src/site.js +169 -0
- package/lib/src/store.d.ts +151 -0
- package/lib/src/store.js +596 -0
- package/lib/src/tree.d.ts +50 -0
- package/lib/src/tree.js +134 -0
- package/lib/src/values.d.ts +7 -0
- package/lib/src/values.js +37 -0
- package/lib/src/vendor.d.ts +19 -0
- package/lib/src/vendor.js +145 -0
- package/lib/src/watch.d.ts +44 -0
- package/lib/src/watch.js +137 -0
- package/lib/src/wbn.d.ts +5 -0
- package/lib/src/wbn.js +147 -0
- package/lib/src/yaml.d.ts +34 -0
- package/lib/src/yaml.js +562 -0
- package/package.json +58 -4
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type SourceSpan } from '../errors.js';
|
|
2
|
+
import type { ArchiveLimits, FetchPolicy } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Git sources over smart HTTP (issue #91): `IMPORT name FROM git+https://host/repo.git#ref:path` and
|
|
5
|
+
* `sitefile build https://host/repo.git#ref:dir`.
|
|
6
|
+
*
|
|
7
|
+
* This is a small client for Git's protocol v2 (gitprotocol-v2, gitprotocol-http), written against
|
|
8
|
+
* the build's HTTPS client so it inherits its network policy unchanged (https only unless
|
|
9
|
+
* --allow-http, no credentials in URLs, the SSRF address check at connect time, redirects re-checked
|
|
10
|
+
* hop by hop, the download cap and the timeout). No `git` binary runs, so there are no hooks, no
|
|
11
|
+
* config, no credential helpers and no filters:
|
|
12
|
+
*
|
|
13
|
+
* 1. GET <repo>/info/refs?service=git-upload-pack (Git-Protocol: version=2): capabilities
|
|
14
|
+
* 2. POST <repo>/git-upload-pack command=ls-refs (only when the ref is not a commit)
|
|
15
|
+
* 3. POST <repo>/git-upload-pack command=fetch want <commit>, deepen 1, done
|
|
16
|
+
*
|
|
17
|
+
* The packfile is parsed here (zlib objects, OFS_DELTA and REF_DELTA), every object's SHA-1 is
|
|
18
|
+
* recomputed, and the pack checksum is verified, so the tree that is imported is the one the commit
|
|
19
|
+
* names. Only SHA-1 repositories are supported. Submodules (gitlinks) are refused; symbolic links are
|
|
20
|
+
* resolved inside the imported tree with the same rules as local symlinks (see `walkGitTree`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const GIT_COMMIT_RE: RegExp;
|
|
23
|
+
/** A parsed `git+https://…#ref:path` location. */
|
|
24
|
+
export interface GitLocation {
|
|
25
|
+
/** The URI as written (after interpolation): the lockfile and vendor key. */
|
|
26
|
+
readonly url: string;
|
|
27
|
+
/** The repository URL (`https://host/repo.git`), without `git+` and the fragment. */
|
|
28
|
+
readonly repo: string;
|
|
29
|
+
/** The ref as written: a branch, a tag, `refs/…`, a 40-hex commit, or '' for the remote HEAD. */
|
|
30
|
+
readonly ref: string;
|
|
31
|
+
/** The path inside the repository ('' for its root), `/`-separated, no `.` or `..`. */
|
|
32
|
+
readonly path: string;
|
|
33
|
+
/** The commit, when `ref` is a full 40-hex commit id (a pin). */
|
|
34
|
+
readonly commit?: string;
|
|
35
|
+
}
|
|
36
|
+
/** True for URIs with a `git+` scheme (`git+https:`, `git+http:`, `git+ssh:`, …). */
|
|
37
|
+
export declare function isGitUri(uri: string): boolean;
|
|
38
|
+
/** Git's ref name rules (git check-ref-format), applied to the ref in a Git URL. */
|
|
39
|
+
export declare function checkRefName(ref: string, span?: SourceSpan): void;
|
|
40
|
+
/**
|
|
41
|
+
* Parse `git+https://host/repo[.git][#ref[:path]]` (`git+http:` too; plain http still needs
|
|
42
|
+
* --allow-http when fetched). `scheme` errors are E_PROTOCOL, a bad ref E_VALIDATION, a path with
|
|
43
|
+
* `..` E_PATH_ESCAPE.
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseGitUri(uri: string, span?: SourceSpan): GitLocation;
|
|
46
|
+
/** The URL of a location with the ref replaced by the commit it resolved to (provenance). */
|
|
47
|
+
export declare function pinnedGitUrl(loc: GitLocation, commit: string): string;
|
|
48
|
+
/** What a fetch needs: the build's network policy and extra headers for the repository's origin. */
|
|
49
|
+
export interface GitTransport {
|
|
50
|
+
readonly policy: FetchPolicy;
|
|
51
|
+
/** Sent only to the repository's origin (IMPORT … SECRET). */
|
|
52
|
+
readonly originHeaders?: Readonly<Record<string, string>>;
|
|
53
|
+
readonly span?: SourceSpan | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The commit `ref` names on the server: '' is the remote HEAD; `refs/…` is exact; otherwise
|
|
57
|
+
* `refs/tags/<ref>` then `refs/heads/<ref>` (Git's own order). Annotated tags are peeled.
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveRef(repo: string, ref: string, t: GitTransport): Promise<string>;
|
|
60
|
+
/** A fetched commit: its objects, by hex id. */
|
|
61
|
+
export interface GitObjects {
|
|
62
|
+
readonly commit: string;
|
|
63
|
+
readonly objects: ReadonlyMap<string, GitObject>;
|
|
64
|
+
/** The packfile as received (for size accounting). */
|
|
65
|
+
readonly packBytes: number;
|
|
66
|
+
}
|
|
67
|
+
export interface GitObject {
|
|
68
|
+
readonly type: 'commit' | 'tree' | 'blob' | 'tag';
|
|
69
|
+
readonly data: Uint8Array;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Fetch `commit` (when given) or the commit `ref` names now: one shallow fetch (`deepen 1`) of that
|
|
73
|
+
* commit alone. The pack is checked as described in the module comment.
|
|
74
|
+
*/
|
|
75
|
+
export declare function fetchGitCommit(repo: string, ref: string, commit: string | undefined, t: GitTransport, limits: ArchiveLimits): Promise<GitObjects>;
|
|
76
|
+
/** The SHA-1 object id of `data` as a loose object of `type`. */
|
|
77
|
+
export declare function gitObjectId(type: GitObject['type'], data: Uint8Array): string;
|
|
78
|
+
/**
|
|
79
|
+
* Parse a version 2 or 3 packfile into objects by id. Every object is inflated at most to its
|
|
80
|
+
* declared size, deltas are applied (bases must be in the pack: thin packs are not requested), and
|
|
81
|
+
* the total inflated size is bounded by `limits.maxTotalBytes`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function parsePack(pack: Uint8Array, repo: string, limits: ArchiveLimits, span?: SourceSpan): Map<string, GitObject>;
|
|
84
|
+
/** Selected content of a commit: a tree's files, or one file. */
|
|
85
|
+
export type GitSelection = {
|
|
86
|
+
readonly kind: 'tree';
|
|
87
|
+
readonly files: ReadonlyArray<readonly [string, {
|
|
88
|
+
readonly bytes: Uint8Array;
|
|
89
|
+
readonly mode: number;
|
|
90
|
+
}]>;
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: 'file';
|
|
93
|
+
readonly bytes: Uint8Array;
|
|
94
|
+
readonly mode: number;
|
|
95
|
+
readonly basename: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The content of `loc.path` in a fetched commit: a tree's files (symlinks resolved, like a local
|
|
99
|
+
* directory walk: a link must stay inside the imported tree, directory links back to an ancestor
|
|
100
|
+
* are skipped) or one file. Entry names are checked like archive entries; the file count and total
|
|
101
|
+
* size are bounded by `limits`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function selectGitPath(objs: GitObjects, loc: Pick<GitLocation, 'repo' | 'path'>, limits: ArchiveLimits, span?: SourceSpan): GitSelection;
|