@lumpcode/core 0.1.0 → 0.2.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 +18 -16
- package/dist/helpers/execAsync/main.d.ts +14 -9
- package/dist/helpers/execAsync/main.d.ts.map +1 -1
- package/dist/helpers/executeStepsForContextList/main.d.ts +4 -9
- package/dist/helpers/executeStepsForContextList/main.d.ts.map +1 -1
- package/dist/helpers/getContextStatus/main.d.ts.map +1 -1
- package/dist/index.cjs +303 -177
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +299 -175
- package/dist/index.js.map +1 -1
- package/dist/testing/processTreeTestHelpers.d.ts +3 -0
- package/dist/testing/processTreeTestHelpers.d.ts.map +1 -1
- package/dist/types/ExecuteStepsFailureReason.d.ts +1 -1
- package/dist/types/ExecuteStepsFailureReason.d.ts.map +1 -1
- package/dist/types/GitAddCommitFn.d.ts +16 -0
- package/dist/types/GitAddCommitFn.d.ts.map +1 -0
- package/dist/types/GitPushFn.d.ts +12 -0
- package/dist/types/GitPushFn.d.ts.map +1 -0
- package/dist/types/PostCommandExecFn.d.ts +2 -0
- package/dist/types/PostCommandExecFn.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/usages/runLump/defaultInjectedFns.d.ts +3 -4
- package/dist/usages/runLump/defaultInjectedFns.d.ts.map +1 -1
- package/dist/usages/runLump/index.d.ts +1 -1
- package/dist/usages/runLump/index.d.ts.map +1 -1
- package/dist/usages/runLump/main.d.ts +3 -4
- package/dist/usages/runLump/main.d.ts.map +1 -1
- package/dist/utils/commitMessageIncludesMarker/index.d.ts +2 -0
- package/dist/utils/commitMessageIncludesMarker/index.d.ts.map +1 -0
- package/dist/utils/commitMessageIncludesMarker/main.d.ts +3 -0
- package/dist/utils/commitMessageIncludesMarker/main.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/parseGitLogHashBodyRecords/index.d.ts +2 -0
- package/dist/utils/parseGitLogHashBodyRecords/index.d.ts.map +1 -0
- package/dist/utils/parseGitLogHashBodyRecords/main.d.ts +8 -0
- package/dist/utils/parseGitLogHashBodyRecords/main.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,23 +248,25 @@ type GitCommitMessageFn = (input: {
|
|
|
248
248
|
|
|
249
249
|
Maps a context to its normalized git commit message. **The returned message must be unique per context** -- it is the source of truth used to track whether a context has already been processed (see [Context Tracking with Git Commits](#context-tracking-with-git-commits)).
|
|
250
250
|
|
|
251
|
-
### `
|
|
251
|
+
### `gitAddCommitFn`
|
|
252
252
|
|
|
253
|
-
**Type:** `
|
|
253
|
+
**Type:** `GitAddCommitFn` -- **Default:** ``git add . && git commit --allow-empty -m <commitMessage>``
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
Per-context add+commit. Receives `{ baseBranch, branchName, workspacePath, context, commitMessage }` (no `contextList`) and returns a `Success` / `Failure` result:
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
| Return | Behavior |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| `success(string)` | Core runs that shell string with `cwd: workspacePath` |
|
|
260
|
+
| `success(null \| undefined)` | No-op (injector already did the work, or intentional skip) |
|
|
261
|
+
| `success('')` / `failure(msg)` / throw | Hard-fail the run with `reason: 'gitAddCommitFailed'` |
|
|
258
262
|
|
|
259
|
-
**
|
|
263
|
+
Invoked **once per context** after `teardownFn`, producing exactly one commit per context on the work branch.
|
|
260
264
|
|
|
261
|
-
|
|
265
|
+
### `gitPushFn`
|
|
262
266
|
|
|
263
|
-
|
|
267
|
+
**Type:** `GitPushFn` -- **Default:** ``git push origin <branchName>``
|
|
264
268
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
Customize the git push command. Invoked **once per branch**, after all per-context commits are made.
|
|
269
|
+
Once-per-branch push after all per-context add+commits succeed. Same Success / Failure payload rules as `gitAddCommitFn`, except failures are **log-only** (the run stays successful).
|
|
268
270
|
|
|
269
271
|
### `setupWorkspaceFn`
|
|
270
272
|
|
|
@@ -275,7 +277,7 @@ Prepares the workspace before prompt execution. It returns an object with two fi
|
|
|
275
277
|
- `command` — the shell command to run (e.g. checkout the base branch, fetch, create the work branch).
|
|
276
278
|
- `workspacePath` — the directory where all subsequent operations (prompt execution, git add/commit/push) will take place. The default implementation returns `'.'`, so those commands run with `cwd: '.'` (the **host process's current working directory**). If your process's cwd is not `projectRoot`, pass an absolute path (e.g. `projectRoot` or a worktree path) so behavior is unambiguous.
|
|
277
279
|
|
|
278
|
-
> **Where commands run:** `setupWorkspaceFn` is the only function whose returned `command` runs at `projectRoot`. All other function parameters that return commands (`
|
|
280
|
+
> **Where commands run:** `setupWorkspaceFn` is the only function whose returned `command` runs at `projectRoot`. All other function parameters that return commands (`gitAddCommitFn`, `gitPushFn`, `commandFn`, `teardownWorkspaceFn`) execute their commands at `workspacePath`.
|
|
279
281
|
|
|
280
282
|
The default implementation command checks out the base branch, fetches, pulls, deletes and re-creates the work branch (with `cwd: projectRoot` for this setup command only):
|
|
281
283
|
|
|
@@ -422,7 +424,7 @@ const steps: Steps = [
|
|
|
422
424
|
|
|
423
425
|
## Context Tracking with Git Commits
|
|
424
426
|
|
|
425
|
-
Lumpcode uses normalized git commit messages to record which contexts have already been processed. Each completed context contributes **exactly one commit** whose
|
|
427
|
+
Lumpcode uses normalized git commit messages to record which contexts have already been processed. Each completed context contributes **exactly one commit** whose message contains the string returned by `gitCommitMessageFn({ context, ... })` (written as the subject; still matched if squash moves it into the body). On every subsequent call to `runLump`, contexts whose marker is already present on a remote branch are skipped so the run only works on what remains. This lets you call `runLump` repeatedly (e.g. in a cron job) and each invocation picks up where the previous one left off, progressively working through the full context list without ever re-processing a context.
|
|
426
428
|
|
|
427
429
|
> If you'd rather not wire up your own scheduler, [@lumpcode/cli](https://www.npmjs.com/package/@lumpcode/cli) ships a built-in daemon (`lumpcode start`) that calls `runLump` on a tick, with concurrent-branch limits and per-lump enable/disable already wired in.
|
|
428
430
|
|
|
@@ -434,7 +436,7 @@ By default, a context named `my_component_ts` produces a commit with the subject
|
|
|
434
436
|
LUMP:my_component_ts
|
|
435
437
|
```
|
|
436
438
|
|
|
437
|
-
You can customize this via the `[gitCommitMessageFn](#gitcommitmessagefn)` parameter. The returned
|
|
439
|
+
You can customize this via the `[gitCommitMessageFn](#gitcommitmessagefn)` parameter. The returned string **must be unique per context** -- it is the only thing tying the commit back to its context. Status matches that string anywhere in the full commit message, as long as it is not a prefix of a longer `[A-Za-z0-9_-]*` token (`foo` does not match `foo-bar`).
|
|
438
440
|
|
|
439
441
|
### Context statuses
|
|
440
442
|
|
|
@@ -458,7 +460,7 @@ A context with `dependsOnContexts` is only eligible when **all** of its listed d
|
|
|
458
460
|
|
|
459
461
|
```bash
|
|
460
462
|
git fetch --all
|
|
461
|
-
git log --remotes=origin --grep="
|
|
463
|
+
git log --remotes=origin -F --grep="LUMP:" --format='%H %s'
|
|
462
464
|
```
|
|
463
465
|
|
|
464
466
|
**Check if a specific context has been processed (any remote ref):**
|
|
@@ -510,10 +512,10 @@ flowchart TD
|
|
|
510
512
|
LoopStart --> Setup["setupFn()"]
|
|
511
513
|
Setup --> ExecPrompts["Execute steps sequentially"]
|
|
512
514
|
ExecPrompts --> Teardown["teardownFn()"]
|
|
513
|
-
Teardown --> AddCommit["
|
|
515
|
+
Teardown --> AddCommit["gitAddCommitFn (commitMessage from gitCommitMessageFn)"]
|
|
514
516
|
AddCommit --> LoopCheck{"More contexts?"}
|
|
515
517
|
LoopCheck -->|Yes| LoopStart
|
|
516
|
-
LoopCheck -->|No| Push["
|
|
518
|
+
LoopCheck -->|No| Push["gitPushFn (branch only)"]
|
|
517
519
|
Push --> TeardownWorkspace["teardownWorkspaceFn()"]
|
|
518
520
|
TeardownWorkspace --> Done["Return Success or Failure"]
|
|
519
521
|
```
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Failure, Success } from '../../types';
|
|
2
|
+
export type ExecAsyncFailureReason = 'timeout' | 'exit';
|
|
3
|
+
export type ExecAsyncFailure = {
|
|
4
4
|
message: string;
|
|
5
|
+
reason: ExecAsyncFailureReason;
|
|
5
6
|
info: {
|
|
6
7
|
command: string;
|
|
7
|
-
stdout:
|
|
8
|
-
stderr:
|
|
8
|
+
stdout: unknown;
|
|
9
|
+
stderr: unknown;
|
|
9
10
|
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
};
|
|
12
|
+
export declare function execAsync(command: string, options?: {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
timeoutMillis?: number;
|
|
15
|
+
}): Promise<Success<{
|
|
16
|
+
stdout: string;
|
|
17
|
+
stderr: string;
|
|
18
|
+
}> | Failure<ExecAsyncFailure>>;
|
|
14
19
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/execAsync/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/execAsync/main.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQpD,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,IAAI,EAAE;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;KACnB,CAAC;CACL,CAAC;AAoBF,wBAAsB,SAAS,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,OAAO,CAAC,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CA4BlF"}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { ContextList, ContextRunState,
|
|
1
|
+
import { ContextList, ContextRunState, Failure, Logger, LumpVariables, StepVariables, Success } from "../../types";
|
|
2
2
|
import type { RunLumpInput } from '../../usages';
|
|
3
|
-
export type ExecuteStepsForContextListParams<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = Required<Pick<RunLumpInput<V, SV>, 'baseBranch' | 'branchFn' | 'lumpVariables' | 'steps' | 'setupFn' | 'teardownFn' | '
|
|
3
|
+
export type ExecuteStepsForContextListParams<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = Required<Pick<RunLumpInput<V, SV>, 'baseBranch' | 'branchFn' | 'lumpVariables' | 'steps' | 'setupFn' | 'teardownFn' | 'gitAddCommitFn' | 'gitPushFn' | 'gitCommitMessageFn' | 'projectRoot' | 'setupWorkspaceFn' | 'teardownWorkspaceFn' | 'getKeepHistoryFilePathFn'>> & {
|
|
4
4
|
contextList: ContextList;
|
|
5
5
|
logger?: Logger;
|
|
6
6
|
/** When aborted, in-flight commands are killed and the step walk stops (ignores continueOnError). */
|
|
7
7
|
signal?: AbortSignal;
|
|
8
8
|
};
|
|
9
|
-
export declare function executeStepsForContextList<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables>({ baseBranch, branchFn, lumpVariables, contextList,
|
|
9
|
+
export declare function executeStepsForContextList<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables>({ baseBranch, branchFn, lumpVariables, contextList, gitAddCommitFn, gitPushFn, gitCommitMessageFn, projectRoot, steps, setupFn, setupWorkspaceFn, teardownFn, teardownWorkspaceFn, getKeepHistoryFilePathFn, logger: loggerInput, signal, }: ExecuteStepsForContextListParams<V, SV>): Promise<Failure<{
|
|
10
10
|
message: string;
|
|
11
|
-
|
|
12
|
-
command: string;
|
|
13
|
-
stdout: any;
|
|
14
|
-
stderr: any;
|
|
15
|
-
};
|
|
16
|
-
}> | Failure<ExecuteStepsFailureData> | import("../..").Success<{
|
|
11
|
+
}> | Success<{
|
|
17
12
|
branchName: string;
|
|
18
13
|
contextNames: string[];
|
|
19
14
|
contextRunStateList: ContextRunState[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/executeStepsForContextList/main.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,WAAW,EACX,eAAe,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/executeStepsForContextList/main.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,WAAW,EACX,eAAe,EAEf,OAAO,EACP,MAAM,EACN,aAAa,EAMb,aAAa,EACb,OAAO,EACV,MAAM,aAAa,CAAC;AASrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAuGjD,MAAM,MAAM,gCAAgC,CACxC,CAAC,SAAS,aAAa,GAAG,aAAa,EACvC,EAAE,SAAS,aAAa,GAAG,aAAa,IACxC,QAAQ,CAAC,IAAI,CACb,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,EACjB,YAAY,GACZ,UAAU,GACV,eAAe,GACf,OAAO,GACP,SAAS,GACT,YAAY,GACZ,gBAAgB,GAChB,WAAW,GACX,oBAAoB,GACpB,aAAa,GACb,kBAAkB,GAClB,qBAAqB,GACrB,0BAA0B,CAC/B,CAAC,GAAG;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qGAAqG;IACrG,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB,CAAA;AAED,wBAAsB,0BAA0B,CAC5C,CAAC,SAAS,aAAa,GAAG,aAAa,EACvC,EAAE,SAAS,aAAa,GAAG,aAAa,EAC1C,EACE,UAAU,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,EAAE,WAAW,EACnB,MAAM,GACT,EAAE,gCAAgC,CAAC,CAAC,EAAE,EAAE,CAAC;;;;;;IA6VzC;AAED,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/getContextStatus/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/getContextStatus/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAUpE,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,MAAM,EAAE;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,aAAa,CAAC,CAwEzB"}
|