@aigile/datastore-git-fs 0.0.0-stage → 0.2.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/askpass.cjs +8 -0
- package/dist/git.d.ts +64 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +172 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -4
- package/README.md +0 -3
package/askpass.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// aigile's git askpass: answers git's HTTPS username and password prompts from the
|
|
3
|
+
// environment the datastore sets (AIGILE_GITFS_USER, AIGILE_GITFS_TOKEN), so the
|
|
4
|
+
// token is never part of the remote URL or written to .git/config.
|
|
5
|
+
'use strict';
|
|
6
|
+
const prompt = process.argv[2] || '';
|
|
7
|
+
const answer = /^username/i.test(prompt) ? process.env.AIGILE_GITFS_USER || 'x-token-auth' : process.env.AIGILE_GITFS_TOKEN || '';
|
|
8
|
+
process.stdout.write(`${answer}\n`);
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface GitCredentials {
|
|
2
|
+
/** The username git asks for; Bitbucket's repository access tokens use `x-token-auth`. */
|
|
3
|
+
user?: string | undefined;
|
|
4
|
+
token: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The environment that answers git's HTTPS prompts from the token, without
|
|
8
|
+
* the token in the remote URL or in `.git/config`: `GIT_ASKPASS` runs the
|
|
9
|
+
* helper (quoted, so git hands it to the shell) and the helper reads the
|
|
10
|
+
* token from its own environment. `GIT_TERMINAL_PROMPT=0` so a wrong token
|
|
11
|
+
* fails instead of waiting on a terminal.
|
|
12
|
+
*/
|
|
13
|
+
export declare function credentialEnv(credentials: GitCredentials | undefined, execPath?: string, askpass?: string): Record<string, string>;
|
|
14
|
+
export interface GitAuthor {
|
|
15
|
+
name: string;
|
|
16
|
+
email: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GitLogEntry {
|
|
19
|
+
hash: string;
|
|
20
|
+
/** Author date, ISO-8601 strict. */
|
|
21
|
+
date: string;
|
|
22
|
+
author: string;
|
|
23
|
+
subject: string;
|
|
24
|
+
}
|
|
25
|
+
/** Thin wrapper over the `git` CLI scoped to a working directory. */
|
|
26
|
+
export declare class Git {
|
|
27
|
+
private readonly cwd;
|
|
28
|
+
private readonly credentials?;
|
|
29
|
+
constructor(cwd: string, credentials?: GitCredentials | undefined);
|
|
30
|
+
private run;
|
|
31
|
+
/** Run a command, returning null instead of throwing on non-zero exit. */
|
|
32
|
+
private tryRun;
|
|
33
|
+
/** Absolute path of the enclosing repo's top level, or null if not in a repo. */
|
|
34
|
+
toplevel(): Promise<string | null>;
|
|
35
|
+
hasCommits(): Promise<boolean>;
|
|
36
|
+
init(branch: string): Promise<void>;
|
|
37
|
+
/** Point an unborn HEAD at `branch` (a clone of an empty remote takes git's default name otherwise). */
|
|
38
|
+
useBranch(branch: string): Promise<void>;
|
|
39
|
+
clone(remote: string, branch: string): Promise<void>;
|
|
40
|
+
configUser(author: GitAuthor): Promise<void>;
|
|
41
|
+
add(pathspec: string): Promise<void>;
|
|
42
|
+
rm(pathspec: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Commit currently-staged changes as `author`, with `onBehalfOf` recorded as an
|
|
45
|
+
* `Authored-by:` trailer when given. Returns the new commit hash.
|
|
46
|
+
*/
|
|
47
|
+
commit(message: string, author: GitAuthor, onBehalfOf?: GitAuthor): Promise<string>;
|
|
48
|
+
/** `true` when something is staged. */
|
|
49
|
+
hasStagedChanges(): Promise<boolean>;
|
|
50
|
+
addAll(): Promise<void>;
|
|
51
|
+
remoteUrl(name?: string): Promise<string | null>;
|
|
52
|
+
push(branch: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* `git log` for a single path, newest first. `author` is the person the
|
|
55
|
+
* write was made for (the `Authored-by:` trailer) when one was recorded,
|
|
56
|
+
* else the commit author.
|
|
57
|
+
*/
|
|
58
|
+
log(relPath: string): Promise<GitLogEntry[]>;
|
|
59
|
+
/** Read a file's contents at a given revision, or null if it did not exist. */
|
|
60
|
+
show(revision: string, relPath: string): Promise<string | null>;
|
|
61
|
+
/** Metadata for the most recent commit touching a path. */
|
|
62
|
+
lastCommitFor(relPath: string): Promise<GitLogEntry | null>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,0FAA0F;IAC1F,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAOD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,cAAc,GAAG,SAAS,EAAE,QAAQ,GAAE,MAAyB,EAAE,OAAO,GAAE,MAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASnK;AAMD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qEAAqE;AACrE,qBAAa,GAAG;IAEZ,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;gBADZ,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,cAAc,YAAA;YAGjC,GAAG;IAgBjB,0EAA0E;YAC5D,MAAM;IAQpB,iFAAiF;I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|
package/dist/git.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
const exec = promisify(execFile);
|
|
6
|
+
/** The askpass helper shipped beside this module (a node script: no exec bit to depend on). Resolved when needed: a bundler's URL is not node's. */
|
|
7
|
+
function askpassPath() {
|
|
8
|
+
return join(dirname(fileURLToPath(import.meta.url)), '..', 'askpass.cjs');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The environment that answers git's HTTPS prompts from the token, without
|
|
12
|
+
* the token in the remote URL or in `.git/config`: `GIT_ASKPASS` runs the
|
|
13
|
+
* helper (quoted, so git hands it to the shell) and the helper reads the
|
|
14
|
+
* token from its own environment. `GIT_TERMINAL_PROMPT=0` so a wrong token
|
|
15
|
+
* fails instead of waiting on a terminal.
|
|
16
|
+
*/
|
|
17
|
+
export function credentialEnv(credentials, execPath = process.execPath, askpass = askpassPath()) {
|
|
18
|
+
if (!credentials?.token)
|
|
19
|
+
return { GIT_TERMINAL_PROMPT: '0' };
|
|
20
|
+
const quote = (v) => `'${v.replace(/'/g, `'\\''`)}'`;
|
|
21
|
+
return {
|
|
22
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
23
|
+
GIT_ASKPASS: `${quote(execPath)} ${quote(askpass)}`,
|
|
24
|
+
AIGILE_GITFS_TOKEN: credentials.token,
|
|
25
|
+
AIGILE_GITFS_USER: credentials.user ?? 'x-token-auth',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Field/record separators (ASCII unit/record separators) safe for commit metadata parsing. */
|
|
29
|
+
const FS = String.fromCharCode(0x1f);
|
|
30
|
+
const RS = String.fromCharCode(0x1e);
|
|
31
|
+
/** Thin wrapper over the `git` CLI scoped to a working directory. */
|
|
32
|
+
export class Git {
|
|
33
|
+
cwd;
|
|
34
|
+
credentials;
|
|
35
|
+
constructor(cwd, credentials) {
|
|
36
|
+
this.cwd = cwd;
|
|
37
|
+
this.credentials = credentials;
|
|
38
|
+
}
|
|
39
|
+
async run(args, author) {
|
|
40
|
+
const env = { ...process.env, ...noBackgroundGit(process.env), ...credentialEnv(this.credentials) };
|
|
41
|
+
if (author) {
|
|
42
|
+
env.GIT_AUTHOR_NAME = author.name;
|
|
43
|
+
env.GIT_AUTHOR_EMAIL = author.email;
|
|
44
|
+
env.GIT_COMMITTER_NAME = author.name;
|
|
45
|
+
env.GIT_COMMITTER_EMAIL = author.email;
|
|
46
|
+
}
|
|
47
|
+
const { stdout } = await exec('git', args, {
|
|
48
|
+
cwd: this.cwd,
|
|
49
|
+
env,
|
|
50
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
51
|
+
});
|
|
52
|
+
return stdout;
|
|
53
|
+
}
|
|
54
|
+
/** Run a command, returning null instead of throwing on non-zero exit. */
|
|
55
|
+
async tryRun(args) {
|
|
56
|
+
try {
|
|
57
|
+
return await this.run(args);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Absolute path of the enclosing repo's top level, or null if not in a repo. */
|
|
64
|
+
async toplevel() {
|
|
65
|
+
const out = await this.tryRun(['rev-parse', '--show-toplevel']);
|
|
66
|
+
return out ? out.trim() : null;
|
|
67
|
+
}
|
|
68
|
+
async hasCommits() {
|
|
69
|
+
return (await this.tryRun(['rev-parse', 'HEAD'])) !== null;
|
|
70
|
+
}
|
|
71
|
+
async init(branch) {
|
|
72
|
+
await this.run(['init', '-b', branch]);
|
|
73
|
+
}
|
|
74
|
+
/** Point an unborn HEAD at `branch` (a clone of an empty remote takes git's default name otherwise). */
|
|
75
|
+
async useBranch(branch) {
|
|
76
|
+
await this.run(['symbolic-ref', 'HEAD', `refs/heads/${branch}`]);
|
|
77
|
+
}
|
|
78
|
+
async clone(remote, branch) {
|
|
79
|
+
// Clone into the (empty) cwd. If the requested branch is absent on the
|
|
80
|
+
// remote, fall back to cloning the default branch.
|
|
81
|
+
try {
|
|
82
|
+
await this.run(['clone', '--branch', branch, remote, '.']);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
await this.run(['clone', remote, '.']);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async configUser(author) {
|
|
89
|
+
await this.run(['config', 'user.name', author.name]);
|
|
90
|
+
await this.run(['config', 'user.email', author.email]);
|
|
91
|
+
}
|
|
92
|
+
async add(pathspec) {
|
|
93
|
+
await this.run(['add', '--', pathspec]);
|
|
94
|
+
}
|
|
95
|
+
async rm(pathspec) {
|
|
96
|
+
await this.run(['rm', '-q', '--', pathspec]);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Commit currently-staged changes as `author`, with `onBehalfOf` recorded as an
|
|
100
|
+
* `Authored-by:` trailer when given. Returns the new commit hash.
|
|
101
|
+
*/
|
|
102
|
+
async commit(message, author, onBehalfOf) {
|
|
103
|
+
const args = ['commit', '-m', message];
|
|
104
|
+
if (onBehalfOf)
|
|
105
|
+
args.push('--trailer', `Authored-by: ${onBehalfOf.name} <${onBehalfOf.email}>`);
|
|
106
|
+
await this.run(args, author);
|
|
107
|
+
return (await this.run(['rev-parse', 'HEAD'])).trim();
|
|
108
|
+
}
|
|
109
|
+
/** `true` when something is staged. */
|
|
110
|
+
async hasStagedChanges() {
|
|
111
|
+
return (await this.tryRun(['diff', '--cached', '--quiet'])) === null;
|
|
112
|
+
}
|
|
113
|
+
async addAll() {
|
|
114
|
+
await this.run(['add', '-A']);
|
|
115
|
+
}
|
|
116
|
+
async remoteUrl(name = 'origin') {
|
|
117
|
+
const out = await this.tryRun(['remote', 'get-url', name]);
|
|
118
|
+
return out ? out.trim() : null;
|
|
119
|
+
}
|
|
120
|
+
async push(branch) {
|
|
121
|
+
await this.run(['push', 'origin', branch]);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* `git log` for a single path, newest first. `author` is the person the
|
|
125
|
+
* write was made for (the `Authored-by:` trailer) when one was recorded,
|
|
126
|
+
* else the commit author.
|
|
127
|
+
*/
|
|
128
|
+
async log(relPath) {
|
|
129
|
+
const format = ['%H', '%aI', '%an', '%s', '%(trailers:key=Authored-by,valueonly,separator=%x1f)'].join(FS) + RS;
|
|
130
|
+
const out = await this.tryRun(['log', `--format=${format}`, '--follow', '--', relPath]);
|
|
131
|
+
if (!out)
|
|
132
|
+
return [];
|
|
133
|
+
return out
|
|
134
|
+
.split(RS)
|
|
135
|
+
.map((r) => r.trim())
|
|
136
|
+
.filter((r) => r.length > 0)
|
|
137
|
+
.map((record) => {
|
|
138
|
+
const [hash = '', date = '', committer = '', subject = '', onBehalfOf = ''] = record.split(FS);
|
|
139
|
+
const person = onBehalfOf.trim().replace(/\s*<[^>]*>\s*$/, '');
|
|
140
|
+
return { hash, date, author: person || committer, subject };
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Read a file's contents at a given revision, or null if it did not exist. */
|
|
144
|
+
async show(revision, relPath) {
|
|
145
|
+
return this.tryRun(['show', `${revision}:${relPath}`]);
|
|
146
|
+
}
|
|
147
|
+
/** Metadata for the most recent commit touching a path. */
|
|
148
|
+
async lastCommitFor(relPath) {
|
|
149
|
+
const entries = await this.log(relPath);
|
|
150
|
+
return entries[0] ?? null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Git settings passed through the environment (added to any GIT_CONFIG_* the
|
|
155
|
+
* caller set): no automatic gc or maintenance, so a commit never spawns a
|
|
156
|
+
* detached process that outlives the write. A datastore with many small
|
|
157
|
+
* commits is compacted by a scheduled `git gc` instead.
|
|
158
|
+
*/
|
|
159
|
+
function noBackgroundGit(env) {
|
|
160
|
+
const base = Number.parseInt(env.GIT_CONFIG_COUNT ?? '0', 10) || 0;
|
|
161
|
+
const extra = [
|
|
162
|
+
['gc.auto', '0'],
|
|
163
|
+
['maintenance.auto', '0'],
|
|
164
|
+
];
|
|
165
|
+
const out = { GIT_CONFIG_COUNT: String(base + extra.length) };
|
|
166
|
+
extra.forEach(([key, value], i) => {
|
|
167
|
+
out[`GIT_CONFIG_KEY_${base + i}`] = key;
|
|
168
|
+
out[`GIT_CONFIG_VALUE_${base + i}`] = value;
|
|
169
|
+
});
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAQjC,oJAAoJ;AACpJ,SAAS,WAAW;IAClB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,WAAuC,EAAE,WAAmB,OAAO,CAAC,QAAQ,EAAE,UAAkB,WAAW,EAAE;IACzI,IAAI,CAAC,WAAW,EAAE,KAAK;QAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC;IAC7D,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;IAC7D,OAAO;QACL,mBAAmB,EAAE,GAAG;QACxB,WAAW,EAAE,GAAG,KAAK,CAAC,QAAQ,CA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AC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DataStore, GitFsConfig, RevisionMeta, WriteOptions } from '@aigile/core';
|
|
2
|
+
export { Git } from './git.js';
|
|
3
|
+
/**
|
|
4
|
+
* Git-backed JSON datastore.
|
|
5
|
+
*
|
|
6
|
+
* Layout: `<root>/<collection>/<id>.json`. Files prefixed with `__` (e.g. index
|
|
7
|
+
* files) are treated as internal and excluded from listings. Each write is a git
|
|
8
|
+
* commit, so revision history is the git history of the entity's file.
|
|
9
|
+
*
|
|
10
|
+
* Git operations are serialized through an in-process queue because the git index
|
|
11
|
+
* is not safe for concurrent mutation within a single working tree.
|
|
12
|
+
*/
|
|
13
|
+
export declare class GitFsDataStore implements DataStore {
|
|
14
|
+
private readonly config;
|
|
15
|
+
private readonly root;
|
|
16
|
+
private readonly git;
|
|
17
|
+
private readonly author;
|
|
18
|
+
private queue;
|
|
19
|
+
constructor(config: GitFsConfig);
|
|
20
|
+
/** Serialize a mutating git operation behind any in-flight ones. */
|
|
21
|
+
private enqueue;
|
|
22
|
+
init(): Promise<void>;
|
|
23
|
+
private dir;
|
|
24
|
+
private rel;
|
|
25
|
+
private path;
|
|
26
|
+
get<T>(collection: string, id: string): Promise<T | null>;
|
|
27
|
+
listIds(collection: string): Promise<string[]>;
|
|
28
|
+
list<T>(collection: string): Promise<T[]>;
|
|
29
|
+
put<T>(collection: string, id: string, data: T, opts?: WriteOptions): Promise<RevisionMeta>;
|
|
30
|
+
delete(collection: string, id: string, opts?: WriteOptions): Promise<void>;
|
|
31
|
+
history(collection: string, id: string): Promise<RevisionMeta[]>;
|
|
32
|
+
getAtRevision<T>(collection: string, id: string, revision: string): Promise<T | null>;
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
private maybePush;
|
|
35
|
+
}
|
|
36
|
+
export { credentialEnv, type GitCredentials } from './git.js';
|
|
37
|
+
//# s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AAC;IAiB1E,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAUhE,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMrF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAId,SAAS;CAKxB;AAaD,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { INTERNAL_FILE_PREFIX } from '@aigile/core';
|
|
5
|
+
import { Git } from './git.js';
|
|
6
|
+
export { Git } from './git.js';
|
|
7
|
+
/**
|
|
8
|
+
* Git-backed JSON datastore.
|
|
9
|
+
*
|
|
10
|
+
* Layout: `<root>/<collection>/<id>.json`. Files prefixed with `__` (e.g. index
|
|
11
|
+
* files) are treated as internal and excluded from listings. Each write is a git
|
|
12
|
+
* commit, so revision history is the git history of the entity's file.
|
|
13
|
+
*
|
|
14
|
+
* Git operations are serialized through an in-process queue because the git index
|
|
15
|
+
* is not safe for concurrent mutation within a single working tree.
|
|
16
|
+
*/
|
|
17
|
+
export class GitFsDataStore {
|
|
18
|
+
config;
|
|
19
|
+
root;
|
|
20
|
+
git;
|
|
21
|
+
author;
|
|
22
|
+
queue = Promise.resolve();
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.root = resolve(config.root);
|
|
26
|
+
this.git = new Git(this.root, config.token ? { user: config.user, token: config.token } : undefined);
|
|
27
|
+
this.author = { name: config.authorName, email: config.authorEmail };
|
|
28
|
+
}
|
|
29
|
+
/** Serialize a mutating git operation behind any in-flight ones. */
|
|
30
|
+
enqueue(task) {
|
|
31
|
+
const run = this.queue.then(task, task);
|
|
32
|
+
// Keep the chain alive regardless of individual task outcome.
|
|
33
|
+
this.queue = run.then(() => undefined, () => undefined);
|
|
34
|
+
return run;
|
|
35
|
+
}
|
|
36
|
+
async init() {
|
|
37
|
+
await mkdir(this.root, { recursive: true });
|
|
38
|
+
// The datastore must be its OWN repo, not merely a directory inside some
|
|
39
|
+
// enclosing repo (e.g. when `data/` lives under the app's source repo).
|
|
40
|
+
const top = await this.git.toplevel();
|
|
41
|
+
const isOwnRepo = top !== null && realpathSync(top) === realpathSync(this.root);
|
|
42
|
+
if (!isOwnRepo) {
|
|
43
|
+
if (this.config.remote) {
|
|
44
|
+
await this.git.clone(this.config.remote, this.config.branch);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
await this.git.init(this.config.branch);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
await this.git.configUser(this.author);
|
|
51
|
+
// Ensure at least one commit exists so `log`/`HEAD` resolve, on the configured branch.
|
|
52
|
+
if (!(await this.git.hasCommits())) {
|
|
53
|
+
await this.git.useBranch(this.config.branch);
|
|
54
|
+
const marker = join(this.root, `${INTERNAL_FILE_PREFIX}aigile-store.json`);
|
|
55
|
+
await writeFile(marker, `${JSON.stringify({ store: 'aigile-git-fs', version: 1 }, null, 2)}\n`, 'utf8');
|
|
56
|
+
await this.git.add(`${INTERNAL_FILE_PREFIX}aigile-store.json`);
|
|
57
|
+
await this.git.commit('Initialize aigile datastore', this.author);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
dir(collection) {
|
|
61
|
+
return join(this.root, collection);
|
|
62
|
+
}
|
|
63
|
+
rel(collection, id) {
|
|
64
|
+
return `${collection}/${id}.json`;
|
|
65
|
+
}
|
|
66
|
+
path(collection, id) {
|
|
67
|
+
return join(this.root, collection, `${id}.json`);
|
|
68
|
+
}
|
|
69
|
+
async get(collection, id) {
|
|
70
|
+
try {
|
|
71
|
+
const raw = await readFile(this.path(collection, id), 'utf8');
|
|
72
|
+
return JSON.parse(raw);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
if (err.code === 'ENOENT')
|
|
76
|
+
return null;
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async listIds(collection) {
|
|
81
|
+
const dir = this.dir(collection);
|
|
82
|
+
if (!existsSync(dir))
|
|
83
|
+
return [];
|
|
84
|
+
const entries = await readdir(dir);
|
|
85
|
+
return entries
|
|
86
|
+
.filter((f) => f.endsWith('.json') && !f.startsWith(INTERNAL_FILE_PREFIX))
|
|
87
|
+
.map((f) => f.slice(0, -'.json'.length));
|
|
88
|
+
}
|
|
89
|
+
async list(collection) {
|
|
90
|
+
const ids = await this.listIds(collection);
|
|
91
|
+
const values = await Promise.all(ids.map((id) => this.get(collection, id)));
|
|
92
|
+
return values.filter((v) => v !== null);
|
|
93
|
+
}
|
|
94
|
+
async put(collection, id, data, opts) {
|
|
95
|
+
const rel = this.rel(collection, id);
|
|
96
|
+
const onBehalfOf = toAuthor(opts);
|
|
97
|
+
const author = this.author;
|
|
98
|
+
const message = opts?.message ?? `Update ${rel}`;
|
|
99
|
+
const body = `${JSON.stringify(data, null, 2)}\n`;
|
|
100
|
+
return this.enqueue(async () => {
|
|
101
|
+
await mkdir(this.dir(collection), { recursive: true });
|
|
102
|
+
await writeFile(this.path(collection, id), body, 'utf8');
|
|
103
|
+
if (!this.config.autoCommit) {
|
|
104
|
+
return synthRevision(message, author);
|
|
105
|
+
}
|
|
106
|
+
await this.git.add(rel);
|
|
107
|
+
const hash = await this.git.commit(message, author, onBehalfOf ?? undefined);
|
|
108
|
+
await this.maybePush();
|
|
109
|
+
const meta = await this.git.lastCommitFor(rel);
|
|
110
|
+
return meta
|
|
111
|
+
? { revision: meta.hash, timestamp: meta.date, message: meta.subject, author: meta.author }
|
|
112
|
+
: { revision: hash, timestamp: nowIso(), message, author: author.name };
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async delete(collection, id, opts) {
|
|
116
|
+
const rel = this.rel(collection, id);
|
|
117
|
+
const onBehalfOf = toAuthor(opts);
|
|
118
|
+
const message = opts?.message ?? `Delete ${rel}`;
|
|
119
|
+
await this.enqueue(async () => {
|
|
120
|
+
if (!existsSync(this.path(collection, id)))
|
|
121
|
+
return;
|
|
122
|
+
if (!this.config.autoCommit) {
|
|
123
|
+
await rm(this.path(collection, id));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
await this.git.rm(rel);
|
|
127
|
+
await this.git.commit(message, this.author, onBehalfOf ?? undefined);
|
|
128
|
+
await this.maybePush();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async history(collection, id) {
|
|
132
|
+
const entries = await this.git.log(this.rel(collection, id));
|
|
133
|
+
return entries.map((e) => ({
|
|
134
|
+
revision: e.hash,
|
|
135
|
+
timestamp: e.date,
|
|
136
|
+
message: e.subject,
|
|
137
|
+
author: e.author,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
async getAtRevision(collection, id, revision) {
|
|
141
|
+
const raw = await this.git.show(revision, this.rel(collection, id));
|
|
142
|
+
if (raw === null)
|
|
143
|
+
return null;
|
|
144
|
+
return JSON.parse(raw);
|
|
145
|
+
}
|
|
146
|
+
async close() {
|
|
147
|
+
await this.queue.catch(() => undefined);
|
|
148
|
+
}
|
|
149
|
+
async maybePush() {
|
|
150
|
+
if (this.config.autoPush && this.config.remote) {
|
|
151
|
+
await this.git.push(this.config.branch);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function toAuthor(opts) {
|
|
156
|
+
return opts?.author ? { name: opts.author.name, email: opts.author.email } : null;
|
|
157
|
+
}
|
|
158
|
+
function synthRevision(message, author) {
|
|
159
|
+
return { revision: 'uncommitted', timestamp: nowIso(), message, author: author.name };
|
|
160
|
+
}
|
|
161
|
+
function nowIso() {
|
|
162
|
+
return new Date().toISOString();
|
|
163
|
+
}
|
|
164
|
+
export { credentialEnv } from './git.js';
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,GAAG,EAAkB,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,OAAO,cAAc;IAMI;IALZ,IAAI,CAAS;IACb,GAAG,CAAM;IACT,MAAM,CAAY;IAC3B,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEpD,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;QAC9C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrG,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;IACvE,CAAC;IAED,oEAAoE;IAC5D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
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigile/datastore-git-fs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "aigile: datastore-git-fs package",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"author": "Ryan Goldstein <me@ryangoldstein.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/RyanGoldstein/aigile.git",
|
|
10
|
+
"directory": "packages/datastore-git-fs"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"askpass.cjs",
|
|
16
|
+
"!dist/**/*.test.*"
|
|
17
|
+
],
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc --build"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@aigile/core": "0.2.1"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/README.md
DELETED