@udondan/avanti 0.4.0 → 0.6.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/README.md +130 -5
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +45 -2
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/log.d.ts +3 -0
- package/dist/commands/log.d.ts.map +1 -0
- package/dist/commands/log.js +100 -0
- package/dist/commands/log.js.map +1 -0
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +67 -19
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/reset.d.ts +3 -0
- package/dist/commands/reset.d.ts.map +1 -0
- package/dist/commands/reset.js +106 -0
- package/dist/commands/reset.js.map +1 -0
- package/dist/commands/revert.d.ts +3 -0
- package/dist/commands/revert.d.ts.map +1 -0
- package/dist/commands/revert.js +153 -0
- package/dist/commands/revert.js.map +1 -0
- package/dist/diff.d.ts +1 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +10 -1
- package/dist/diff.js.map +1 -1
- package/dist/fetch.d.ts +3 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +37 -0
- package/dist/fetch.js.map +1 -0
- package/dist/history.d.ts +64 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +316 -0
- package/dist/history.js.map +1 -0
- package/dist/processors/json.d.ts.map +1 -1
- package/dist/processors/json.js +8 -5
- package/dist/processors/json.js.map +1 -1
- package/dist/prompt.d.ts +2 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +42 -0
- package/dist/prompt.js.map +1 -0
- package/dist/sources/github.d.ts +1 -1
- package/dist/sources/github.d.ts.map +1 -1
- package/dist/sources/github.js +124 -20
- package/dist/sources/github.js.map +1 -1
- package/dist/sources/gitlab.d.ts +1 -1
- package/dist/sources/gitlab.d.ts.map +1 -1
- package/dist/sources/gitlab.js +136 -48
- package/dist/sources/gitlab.js.map +1 -1
- package/dist/sources/http.d.ts.map +1 -1
- package/dist/sources/http.js +5 -24
- package/dist/sources/http.js.map +1 -1
- package/dist/sources/index.js +4 -4
- package/dist/sources/index.js.map +1 -1
- package/dist/writer.d.ts +1 -1
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js +10 -1
- package/dist/writer.js.map +1 -1
- package/package.json +6 -1
- package/.prettierignore +0 -2
- package/CHANGELOG.md +0 -46
- package/eslint.config.mjs +0 -25
- package/prettier.config.mjs +0 -5
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ Assemble local files from any source via a declarative YAML spec.
|
|
|
15
15
|
## Requirements
|
|
16
16
|
|
|
17
17
|
- Node.js 18+
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
The `glab` and `gh` CLIs are **optional**. Public repositories are accessed directly over HTTPS without any tools installed. The CLIs are only used as a fallback for private repositories or private instances when no token is configured.
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
@@ -40,8 +40,11 @@ Options:
|
|
|
40
40
|
-w, --working-dir <path> working directory for resolving paths (default: current directory)
|
|
41
41
|
|
|
42
42
|
Commands:
|
|
43
|
-
diff
|
|
43
|
+
diff [pullId] Show diff between remote sources and local files, or vs a past pull
|
|
44
44
|
pull [--yes] Pull remote sources and write to local files
|
|
45
|
+
log [file] Show pull history for the current project
|
|
46
|
+
revert [pullId] [--yes] Atomically revert all project files to a past pull state
|
|
47
|
+
reset [--yes] Restore all tracked files to their pre-avanti state
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
### `avanti diff`
|
|
@@ -52,6 +55,103 @@ Shows a colored git-diff-like output of what would change. Exits `0` if no chang
|
|
|
52
55
|
|
|
53
56
|
Fetches all sources, shows the diff, and prompts for confirmation before writing. Use `--yes` to skip the prompt.
|
|
54
57
|
|
|
58
|
+
When avanti has previously synced a directory from a remote source and a file is no longer present in that source, the file is treated as stale: if avanti created it, it is deleted; if it existed before avanti first touched it, the original content is restored. Stale file changes appear in the diff before you confirm.
|
|
59
|
+
|
|
60
|
+
## History
|
|
61
|
+
|
|
62
|
+
Every successful `avanti pull` that writes at least one file is recorded in a local history store. This lets you inspect what changed, preview past states, revert the whole project, or fully undo all avanti changes.
|
|
63
|
+
|
|
64
|
+
History is stored under `~/.config/avanti/` by default. Set `AVANTI_HISTORY_DIR` to override — useful for CI or when you want to keep history inside a repository:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
AVANTI_HISTORY_DIR=.avanti-history avanti pull
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
History is scoped by the **combination of config file path and working directory**, so different projects and different configs are always isolated from each other. If the history directory is missing or corrupt, all commands warn and continue — no crash, no data loss.
|
|
71
|
+
|
|
72
|
+
### `avanti log`
|
|
73
|
+
|
|
74
|
+
List all pull runs for the current project, newest first:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
pull a1b2c3d4 2026-05-08 14:32:11 .avanti.yml
|
|
78
|
+
/project/config.yml → v3 (modified)
|
|
79
|
+
/project/scripts/deploy.sh → v1 (new file)
|
|
80
|
+
|
|
81
|
+
pull 7f8e9a0b 2026-05-07 09:15:44 .avanti.yml
|
|
82
|
+
/project/config.yml → v2 (modified)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Show version history for a specific file by passing it as an argument:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
avanti log config.yml
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
/project/config.yml
|
|
93
|
+
|
|
94
|
+
v3 2026-05-08 14:32:11 pull a1b2c3d4 (current)
|
|
95
|
+
v2 2026-05-07 09:15:44 pull 7f8e9a0b
|
|
96
|
+
v0 — — (original, before avanti)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`v0` is the content the file had before avanti ever touched it. If the file did not exist before avanti, `v0` is not shown.
|
|
100
|
+
|
|
101
|
+
### `avanti diff <pullId>`
|
|
102
|
+
|
|
103
|
+
Preview what would change if you reverted to a specific past pull state — without applying anything. Use the short pull ID shown in `avanti log`:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
avanti diff 7f8e9a0b
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Exits `0` if the current files already match that state, `1` if there are differences.
|
|
110
|
+
|
|
111
|
+
### `avanti revert [pullId]`
|
|
112
|
+
|
|
113
|
+
Atomically revert **all** project files to a past state. Revert always operates on the whole project — there is no per-file revert.
|
|
114
|
+
|
|
115
|
+
**Undo the last pull** (no argument):
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
avanti revert
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Revert to a specific past pull** (files are restored to the state they were in after that pull):
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
avanti revert 7f8e9a0b
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Files written by pulls after the target are handled automatically: if avanti created them, they are deleted; if they existed before avanti, their original content is restored.
|
|
128
|
+
|
|
129
|
+
The command always shows a diff before prompting. Use `--yes` to skip the prompt:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
avanti revert 7f8e9a0b --yes
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The history log is not modified by a revert. The next `avanti pull` after a revert records a new history entry as usual.
|
|
136
|
+
|
|
137
|
+
### `avanti reset`
|
|
138
|
+
|
|
139
|
+
Restore **all** tracked files to their state before avanti ever touched them. Files avanti created are deleted; files avanti modified are restored to their original content:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
avanti reset
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
This will restore 4 tracked file(s) to their pre-avanti state:
|
|
147
|
+
/project/config.yml v3 → v0 (original)
|
|
148
|
+
/project/deploy.sh v2 → delete (did not exist before avanti)
|
|
149
|
+
|
|
150
|
+
Apply? [y/N]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Use `--yes` to skip the prompt. The history log is preserved — you can still run `avanti log` after a reset.
|
|
154
|
+
|
|
55
155
|
## Working Directory
|
|
56
156
|
|
|
57
157
|
All relative `src` and `target` paths are resolved relative to the **working directory** — the directory where you invoke `avanti`, or the path given with `-w`.
|
|
@@ -163,7 +263,7 @@ src:
|
|
|
163
263
|
github:
|
|
164
264
|
repo: owner/repo # GitHub owner/repo
|
|
165
265
|
file: path/to/file.txt # file or directory in repo
|
|
166
|
-
ref: main # branch or
|
|
266
|
+
ref: main # branch, tag, or $latest (optional)
|
|
167
267
|
```
|
|
168
268
|
|
|
169
269
|
### Directory Sources
|
|
@@ -289,7 +389,32 @@ replace:
|
|
|
289
389
|
|
|
290
390
|
Referencing an undefined variable or a missing environment variable is an error.
|
|
291
391
|
|
|
292
|
-
`$latest` is reserved
|
|
392
|
+
`$latest` is a reserved keyword that resolves to the latest published version and cannot be used as a variable name. For GitLab it resolves to the latest tag sorted by semantic version. For GitHub it resolves to the tag of the latest release; if the repository has no releases, it falls back to the most recently created tag.
|
|
393
|
+
|
|
394
|
+
### Authentication
|
|
395
|
+
|
|
396
|
+
Public repositories on github.com and gitlab.com work without any configuration. For private repositories or private instances, supply a token via environment variable:
|
|
397
|
+
|
|
398
|
+
| Platform | Environment variable | Header sent |
|
|
399
|
+
| -------- | ---------------------------------------- | ------------------------------- |
|
|
400
|
+
| GitHub | `GITHUB_TOKEN` | `Authorization: Bearer <token>` |
|
|
401
|
+
| GitLab | `GITLAB_TOKEN` or `GITLAB_PRIVATE_TOKEN` | `PRIVATE-TOKEN: <token>` |
|
|
402
|
+
|
|
403
|
+
If a request fails with a 401, 403, or 404 response and `gh` / `glab` is installed and authenticated, the tool falls back to the CLI automatically. This means existing CLI setups continue to work for private repos without any extra configuration.
|
|
404
|
+
|
|
405
|
+
### Private Instances
|
|
406
|
+
|
|
407
|
+
**GitLab** — set `GITLAB_HOST` to override the default `gitlab.com`:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
GITLAB_HOST=gitlab.mycompany.com avanti pull
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**GitHub Enterprise Server** — set `GITHUB_HOST` to override the default `github.com` (API requests go to `https://{GITHUB_HOST}/api/v3`):
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
GITHUB_HOST=github.mycompany.com avanti pull
|
|
417
|
+
```
|
|
293
418
|
|
|
294
419
|
## Use Cases
|
|
295
420
|
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const diff_1 = require("./commands/diff");
|
|
6
6
|
const pull_1 = require("./commands/pull");
|
|
7
|
+
const log_1 = require("./commands/log");
|
|
8
|
+
const revert_1 = require("./commands/revert");
|
|
9
|
+
const reset_1 = require("./commands/reset");
|
|
7
10
|
const package_json_1 = require("../package.json");
|
|
8
11
|
const program = new commander_1.Command();
|
|
9
12
|
program
|
|
@@ -14,5 +17,8 @@ program
|
|
|
14
17
|
.option('-w, --working-dir <path>', 'working directory for resolving relative paths (default: current directory)');
|
|
15
18
|
program.addCommand((0, diff_1.diffCommand)());
|
|
16
19
|
program.addCommand((0, pull_1.pullCommand)());
|
|
20
|
+
program.addCommand((0, log_1.logCommand)());
|
|
21
|
+
program.addCommand((0, revert_1.revertCommand)());
|
|
22
|
+
program.addCommand((0, reset_1.resetCommand)());
|
|
17
23
|
program.parse(process.argv);
|
|
18
24
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,0CAA8C;AAC9C,0CAA8C;AAC9C,kDAA0C;AAE1C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,kEAAkE,CACnE;KACA,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;KACpD,MAAM,CACL,0BAA0B,EAC1B,6EAA6E,CAC9E,CAAC;AAEJ,OAAO,CAAC,UAAU,CAAC,IAAA,kBAAW,GAAE,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,IAAA,kBAAW,GAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,0CAA8C;AAC9C,0CAA8C;AAC9C,wCAA4C;AAC5C,8CAAkD;AAClD,4CAAgD;AAChD,kDAA0C;AAE1C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,kEAAkE,CACnE;KACA,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;KACpD,MAAM,CACL,0BAA0B,EAC1B,6EAA6E,CAC9E,CAAC;AAEJ,OAAO,CAAC,UAAU,CAAC,IAAA,kBAAW,GAAE,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,IAAA,kBAAW,GAAE,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,IAAA,gBAAU,GAAE,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,IAAA,sBAAa,GAAE,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,IAAA,oBAAY,GAAE,CAAC,CAAC;AAEnC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/commands/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/commands/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,wBAAgB,WAAW,IAAI,OAAO,CAqErC"}
|
package/dist/commands/diff.js
CHANGED
|
@@ -31,15 +31,21 @@ const sources_1 = require("../sources");
|
|
|
31
31
|
const replace_1 = require("../processors/replace");
|
|
32
32
|
const post_1 = require("../processors/post");
|
|
33
33
|
const diff_1 = require("../diff");
|
|
34
|
+
const history_1 = require("../history");
|
|
34
35
|
function diffCommand() {
|
|
35
36
|
return new commander_1.Command('diff')
|
|
36
|
-
.description('Show diff between remote sources and local files')
|
|
37
|
-
.
|
|
37
|
+
.description('Show diff between remote sources and local files, or between local files and a past pull')
|
|
38
|
+
.argument('[pullId]', 'show diff between current files and a past pull state')
|
|
39
|
+
.action(async (pullId, _options, cmd) => {
|
|
38
40
|
const configPath = (0, config_1.resolveConfigPath)(cmd.parent?.opts().config);
|
|
39
41
|
const rawWorkingDir = cmd.parent?.opts().workingDir;
|
|
40
42
|
const workingDir = rawWorkingDir
|
|
41
43
|
? path.resolve(rawWorkingDir)
|
|
42
44
|
: process.cwd();
|
|
45
|
+
if (pullId !== undefined) {
|
|
46
|
+
diffAgainstHistory(pullId, configPath, workingDir);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
43
49
|
let config;
|
|
44
50
|
try {
|
|
45
51
|
config = (0, config_1.loadConfig)(configPath);
|
|
@@ -77,4 +83,41 @@ function diffCommand() {
|
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
85
|
exports.diffCommand = diffCommand;
|
|
86
|
+
function diffAgainstHistory(pullId, configPath, workingDir) {
|
|
87
|
+
const history = new history_1.HistoryManager(configPath, workingDir);
|
|
88
|
+
if (!history.hasHistory()) {
|
|
89
|
+
console.error('No history found. Run avanti pull first.');
|
|
90
|
+
process.exit(2);
|
|
91
|
+
}
|
|
92
|
+
const pulls = history.listPulls();
|
|
93
|
+
const matchedPull = pulls.find((p) => p.pullId === pullId || p.pullId.startsWith(pullId));
|
|
94
|
+
if (!matchedPull) {
|
|
95
|
+
console.error(`No pull found matching ID "${pullId}".`);
|
|
96
|
+
process.exit(2);
|
|
97
|
+
}
|
|
98
|
+
const snapshot = history.getFilesAtPull(matchedPull.pullId);
|
|
99
|
+
if (snapshot.size === 0) {
|
|
100
|
+
console.log('No changes would result from reverting to this pull.');
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
103
|
+
const diffs = [];
|
|
104
|
+
for (const [absolutePath, { version }] of snapshot) {
|
|
105
|
+
const historicalContent = history.readVersion(absolutePath, version);
|
|
106
|
+
if (historicalContent === null)
|
|
107
|
+
continue;
|
|
108
|
+
diffs.push((0, diff_1.computeDiff)(absolutePath, historicalContent));
|
|
109
|
+
}
|
|
110
|
+
// Also account for files that would be deleted (tracked files not in this snapshot)
|
|
111
|
+
const allTracked = history.listTrackedFiles();
|
|
112
|
+
const snapshotPaths = new Set(snapshot.keys());
|
|
113
|
+
for (const meta of allTracked) {
|
|
114
|
+
if (snapshotPaths.has(meta.absolutePath))
|
|
115
|
+
continue;
|
|
116
|
+
// This file was created after the target pull — show it as a deletion
|
|
117
|
+
diffs.push((0, diff_1.computeDeleteDiff)(meta.absolutePath));
|
|
118
|
+
}
|
|
119
|
+
(0, diff_1.printDiffs)(diffs);
|
|
120
|
+
const hasChanges = diffs.some((d) => d.hasChanges);
|
|
121
|
+
process.exit(hasChanges ? 1 : 0);
|
|
122
|
+
}
|
|
80
123
|
//# sourceMappingURL=diff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/commands/diff.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAC7B,sCAA0D;AAC1D,wCAAyC;AACzC,mDAAqD;AACrD,6CAA+C;AAC/C,
|
|
1
|
+
{"version":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C,YAAY,EAAE,OAAO,CAAC,CAAC;QACrE,IAAI,iBAAiB,KAAK,IAAI;YAAE,SAAS;QACzC,KAAK,CAAC,IAAI,CAAC,IAAA,kBAAW,EAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,oFAAoF;IACpF,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAC9C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;YAAE,SAAS;QACnD,sEAAsE;QACtE,KAAK,CAAC,IAAI,CAAC,IAAA,wBAAiB,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,IAAA,iBAAU,EAAC,KAAK,CAAC,CAAC;IAClB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACnD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/commands/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,UAAU,IAAI,OAAO,CAqBpC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.logCommand = void 0;
|
|
27
|
+
const commander_1 = require("commander");
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const config_1 = require("../config");
|
|
30
|
+
const history_1 = require("../history");
|
|
31
|
+
function logCommand() {
|
|
32
|
+
return new commander_1.Command('log')
|
|
33
|
+
.description('Show pull history for the current project')
|
|
34
|
+
.argument('[file]', 'show version history for a specific file')
|
|
35
|
+
.action((file, _options, cmd) => {
|
|
36
|
+
const configPath = (0, config_1.resolveConfigPath)(cmd.parent?.opts().config);
|
|
37
|
+
const rawWorkingDir = cmd.parent?.opts().workingDir;
|
|
38
|
+
const workingDir = rawWorkingDir
|
|
39
|
+
? path.resolve(rawWorkingDir)
|
|
40
|
+
: process.cwd();
|
|
41
|
+
const history = new history_1.HistoryManager(configPath, workingDir);
|
|
42
|
+
if (file !== undefined) {
|
|
43
|
+
showFileHistory(history, file, workingDir);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
showPullHistory(history);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.logCommand = logCommand;
|
|
51
|
+
function showPullHistory(history) {
|
|
52
|
+
const pulls = history.listPulls();
|
|
53
|
+
if (pulls.length === 0) {
|
|
54
|
+
console.log('No history recorded yet.');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
for (const pull of pulls) {
|
|
58
|
+
const shortId = pull.pullId.slice(0, 8);
|
|
59
|
+
const ts = formatTimestamp(pull.timestamp);
|
|
60
|
+
const configName = path.basename(pull.configFile);
|
|
61
|
+
console.log(`pull ${shortId} ${ts} ${configName}`);
|
|
62
|
+
for (const ref of pull.files) {
|
|
63
|
+
const label = ref.wasNew ? '(new file)' : '(modified)';
|
|
64
|
+
console.log(` ${ref.absolutePath} → v${ref.version} ${label}`);
|
|
65
|
+
}
|
|
66
|
+
console.log('');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function showFileHistory(history, filePath, workingDir) {
|
|
70
|
+
const absolutePath = path.isAbsolute(filePath)
|
|
71
|
+
? filePath
|
|
72
|
+
: path.resolve(workingDir, filePath);
|
|
73
|
+
const fileHistory = history.getFileHistory(absolutePath);
|
|
74
|
+
if (!fileHistory) {
|
|
75
|
+
console.log(`No history for ${absolutePath}.`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
console.log(`${absolutePath}\n`);
|
|
79
|
+
const versions = [...fileHistory.versions].reverse();
|
|
80
|
+
for (const v of versions) {
|
|
81
|
+
const vLabel = `v${v.version}`;
|
|
82
|
+
const ts = v.pulledAt
|
|
83
|
+
? formatTimestamp(v.pulledAt)
|
|
84
|
+
: '— ';
|
|
85
|
+
const pullRef = v.pullId ? `pull ${v.pullId.slice(0, 8)}` : '— ';
|
|
86
|
+
let suffix = '';
|
|
87
|
+
if (v.version === fileHistory.currentVersion)
|
|
88
|
+
suffix = ' (current)';
|
|
89
|
+
if (v.isOriginal)
|
|
90
|
+
suffix = ' (original, before avanti)';
|
|
91
|
+
console.log(` ${vLabel.padEnd(4)} ${ts} ${pullRef}${suffix}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function formatTimestamp(iso) {
|
|
95
|
+
const d = new Date(iso);
|
|
96
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
97
|
+
return (`${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ` +
|
|
98
|
+
`${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/commands/log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAC7B,sCAA8C;AAC9C,wCAA4C;AAE5C,SAAgB,UAAU;IACxB,OAAO,IAAI,mBAAO,CAAC,KAAK,CAAC;SACtB,WAAW,CAAC,2CAA2C,CAAC;SACxD,QAAQ,CAAC,QAAQ,EAAE,0CAA0C,CAAC;SAC9D,MAAM,CAAC,CAAC,IAAwB,EAAE,QAAiB,EAAE,GAAY,EAAE,EAAE;QACpE,MAAM,UAAU,GAAG,IAAA,0BAAiB,EAClC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,MAA4B,CAChD,CAAC;QACF,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,UAAgC,CAAC;QAC1E,MAAM,UAAU,GAAG,aAAa;YAC9B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;YAC7B,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAElB,MAAM,OAAO,GAAG,IAAI,wBAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAE3D,IAAI,IAA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ClC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,OAAO,CACL,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG;QAClE,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,CACrE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,wBAAgB,WAAW,IAAI,OAAO,CAsJrC"}
|
package/dist/commands/pull.js
CHANGED
|
@@ -26,26 +26,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.pullCommand = void 0;
|
|
27
27
|
const commander_1 = require("commander");
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
|
-
const readline = __importStar(require("readline"));
|
|
30
29
|
const config_1 = require("../config");
|
|
31
30
|
const sources_1 = require("../sources");
|
|
32
31
|
const replace_1 = require("../processors/replace");
|
|
33
32
|
const post_1 = require("../processors/post");
|
|
34
33
|
const diff_1 = require("../diff");
|
|
35
34
|
const writer_1 = require("../writer");
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
input: process.stdin,
|
|
39
|
-
output: process.stdout,
|
|
40
|
-
});
|
|
41
|
-
return new Promise((resolve) => {
|
|
42
|
-
rl.question(question, (answer) => {
|
|
43
|
-
rl.close();
|
|
44
|
-
resolve(answer.trim().toLowerCase() === 'y' ||
|
|
45
|
-
answer.trim().toLowerCase() === 'yes');
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
35
|
+
const history_1 = require("../history");
|
|
36
|
+
const prompt_1 = require("../prompt");
|
|
49
37
|
function pullCommand() {
|
|
50
38
|
return new commander_1.Command('pull')
|
|
51
39
|
.description('Pull remote sources and write to local files')
|
|
@@ -64,6 +52,9 @@ function pullCommand() {
|
|
|
64
52
|
console.error(err.message);
|
|
65
53
|
process.exit(2);
|
|
66
54
|
}
|
|
55
|
+
const history = new history_1.HistoryManager(configPath, workingDir);
|
|
56
|
+
const historyAvailable = history.ensureStorageDir();
|
|
57
|
+
const pullId = historyAvailable ? history.openPullSession() : null;
|
|
67
58
|
const allDiffs = [];
|
|
68
59
|
const writeTargets = [];
|
|
69
60
|
let hasError = false;
|
|
@@ -91,28 +82,85 @@ function pullCommand() {
|
|
|
91
82
|
console.error('Aborting due to errors.');
|
|
92
83
|
process.exit(2);
|
|
93
84
|
}
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
// Detect stale files: present in last pull but no longer in current source fetch
|
|
86
|
+
const staleToDelete = [];
|
|
87
|
+
const staleToRestore = [];
|
|
88
|
+
const staleDiffs = [];
|
|
89
|
+
if (historyAvailable) {
|
|
90
|
+
const lastFiles = history.getLastPullFiles();
|
|
91
|
+
const currentPaths = new Set(writeTargets.map((t) => t.targetPath));
|
|
92
|
+
for (const ref of lastFiles) {
|
|
93
|
+
if (currentPaths.has(ref.absolutePath))
|
|
94
|
+
continue;
|
|
95
|
+
const meta = history.getFileMeta(ref.absolutePath);
|
|
96
|
+
if (!meta)
|
|
97
|
+
continue;
|
|
98
|
+
if (meta.existedBeforeAvanti) {
|
|
99
|
+
const original = history.readVersion(ref.absolutePath, 0);
|
|
100
|
+
if (original !== null) {
|
|
101
|
+
staleToRestore.push({
|
|
102
|
+
targetPath: ref.absolutePath,
|
|
103
|
+
content: original,
|
|
104
|
+
});
|
|
105
|
+
staleDiffs.push((0, diff_1.computeDiff)(ref.absolutePath, original));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
staleToDelete.push(ref.absolutePath);
|
|
110
|
+
staleDiffs.push((0, diff_1.computeDeleteDiff)(ref.absolutePath));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const hasChanges = allDiffs.some((d) => d.hasChanges) ||
|
|
115
|
+
staleDiffs.some((d) => d.hasChanges);
|
|
116
|
+
(0, diff_1.printDiffs)([...allDiffs, ...staleDiffs]);
|
|
96
117
|
if (!hasChanges) {
|
|
97
118
|
console.log('Nothing to do.');
|
|
98
119
|
process.exit(0);
|
|
99
120
|
}
|
|
100
121
|
const yes = options.yes ?? false;
|
|
101
122
|
if (!yes) {
|
|
102
|
-
const ok = await confirm('Apply changes? [y/N] ');
|
|
123
|
+
const ok = await (0, prompt_1.confirm)('Apply changes? [y/N] ');
|
|
103
124
|
if (!ok) {
|
|
104
125
|
console.log('Aborted.');
|
|
105
126
|
process.exit(0);
|
|
106
127
|
}
|
|
107
128
|
}
|
|
129
|
+
// Stage history versions before atomicWrite so v0 is captured before overwrite
|
|
130
|
+
const stagedFileRefs = [];
|
|
131
|
+
if (pullId) {
|
|
132
|
+
for (let i = 0; i < writeTargets.length; i++) {
|
|
133
|
+
if (!allDiffs[i].hasChanges)
|
|
134
|
+
continue;
|
|
135
|
+
try {
|
|
136
|
+
const { fileRef } = history.stageFileVersion(pullId, writeTargets[i].targetPath, writeTargets[i].content, allDiffs[i].isNew);
|
|
137
|
+
stagedFileRefs.push(fileRef);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
console.warn(`Warning: could not record history for ${writeTargets[i].targetPath}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
108
144
|
try {
|
|
109
|
-
(0, writer_1.atomicWrite)(writeTargets);
|
|
110
|
-
|
|
145
|
+
(0, writer_1.atomicWrite)([...writeTargets, ...staleToRestore], staleToDelete);
|
|
146
|
+
const written = writeTargets.filter((_, i) => allDiffs[i].hasChanges).length +
|
|
147
|
+
staleToRestore.length +
|
|
148
|
+
staleToDelete.length;
|
|
149
|
+
console.log(`Wrote ${written} file(s).`);
|
|
111
150
|
}
|
|
112
151
|
catch (err) {
|
|
113
152
|
console.error(`Write failed: ${err.message}`);
|
|
114
153
|
process.exit(2);
|
|
115
154
|
}
|
|
155
|
+
// Only record to pulls.jsonl if at least one file was actually written
|
|
156
|
+
if (pullId && stagedFileRefs.length > 0) {
|
|
157
|
+
try {
|
|
158
|
+
history.closePullSession(pullId, configPath, stagedFileRefs);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
console.warn('Warning: could not save pull history.');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
116
164
|
});
|
|
117
165
|
}
|
|
118
166
|
exports.pullCommand = pullCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAC7B,sCAA0D;AAC1D,wCAAyC;AACzC,mDAAqD;AACrD,6CAA+C;AAC/C,kCAKiB;AACjB,sCAAqD;AAErD,wCAA4D;AAC5D,sCAAoC;AAEpC,SAAgB,WAAW;IACzB,OAAO,IAAI,mBAAO,CAAC,MAAM,CAAC;SACvB,WAAW,C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