saga-ci 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Penny Leung
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 CHANGED
@@ -1,3 +1,143 @@
1
- # Temporary Holding Version
1
+ # saga-ci
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-brightgreen.svg)](package.json)
5
+
6
+ A lightweight, zero-dependency **Saga-pattern CI/CD workflow runner** for Node.js and TypeScript.
7
+ Wrap deployment and automation steps in a `do()` / `undo()` command contract, compose nested sequential or parallel execution groups, automatically roll back in reverse order on failure, and stream aligned status tables straight to `$GITHUB_STEP_SUMMARY`.
8
+
9
+ **Documentation Wiki & Live Simulator:** [https://thisispennyleung.github.io/saga-ci/](https://thisispennyleung.github.io/saga-ci/)
10
+
11
+ ---
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install saga-ci
17
+ ```
18
+
19
+ Works with Node.js `>=18.0.0` (compiled ESM `.js` + `.d.ts` type declarations included).
20
+
21
+ ---
22
+
23
+ ## Quick Start
24
+
25
+ ```ts
26
+ import { CiWorkFlow } from 'saga-ci';
27
+
28
+ const workflow = new CiWorkFlow();
29
+
30
+ workflow.register(
31
+ {
32
+ name: 'Preflight Check',
33
+ shouldDo: () => true,
34
+ do: async () => console.log('Checking credentials...'),
35
+ undo: () => {},
36
+ },
37
+ false // hasUndo = false -> Undo column shows N/A
38
+ );
39
+
40
+ workflow.register({
41
+ name: 'Provision Database',
42
+ shouldDo: () => true,
43
+ do: async () => console.log('Database ready'),
44
+ undo: async () => console.log('Rolling back database'),
45
+ });
46
+
47
+ workflow.registerParallel(
48
+ 'Deploy Services',
49
+ [
50
+ {
51
+ command: {
52
+ name: 'Deploy API',
53
+ shouldDo: () => true,
54
+ do: async () => console.log('API deployed'),
55
+ undo: async () => console.log('API reverted'),
56
+ },
57
+ label: 'api',
58
+ },
59
+ {
60
+ command: {
61
+ name: 'Deploy Worker',
62
+ shouldDo: () => true,
63
+ do: async () => console.log('Worker deployed'),
64
+ undo: async () => console.log('Worker reverted'),
65
+ },
66
+ label: 'worker',
67
+ },
68
+ ],
69
+ 2 // maxConcurrency
70
+ );
71
+
72
+ await workflow.run();
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Key Features
78
+
79
+ - **Reverse-Order Saga Rollback** — Automatically runs `undo()` on completed steps (and failed partial steps inside groups) in reverse order when a failure occurs.
80
+ - **Sequential & Parallel Groups** — Nest `GroupCommand` chains inside `ParallelGroupCommand` forks with optional `maxConcurrency` limits, module `label` prefixes, and custom `subStep` numbering.
81
+ - **Conditional Skipping (`shouldDo`)** — Return `false` to skip steps cleanly (`SKIPPED` / `N/A`) and exclude them from rollback.
82
+ - **Teardown / Audit Mode (`continueOnError`)** — Run all steps forward without rollback and throw a composite error at the end.
83
+ - **GitHub Actions `$GITHUB_STEP_SUMMARY`** — Automatically writes aligned Markdown status tables and `> [!CAUTION]` failure callouts on every state change.
84
+
85
+ ---
86
+
87
+ ## GitHub Step Summary Output
88
+
89
+ When `GITHUB_STEP_SUMMARY` is set in GitHub Actions, `CiWorkFlow` renders:
90
+
91
+ ```markdown
92
+ ### Deployment Workflow Status Table
93
+
94
+ | Step | Name | Do | Undo |
95
+ | :--- | :-------------------------------------- | :------ | :------- |
96
+ | 1 | Enable Maintenance Shield | SUCCESS | REVERTED |
97
+ | 2.1 | [auth] Provision Database | SUCCESS | REVERTED |
98
+ | 2.2 | [auth] Run Migrations | SUCCESS | REVERTED |
99
+ | 2.1 | [billing] Provision Database | SUCCESS | REVERTED |
100
+ | 2.2 | [billing] Run Migrations | FAILED | REVERTED |
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Documentation
106
+
107
+ Browse the full **Wiki Documentation & Interactive Simulator**:
108
+ - [Overview & Concepts](https://thisispennyleung.github.io/saga-ci/#overview)
109
+ - [Getting Started](https://thisispennyleung.github.io/saga-ci/#getting-started)
110
+ - [Groups & Parallel Forks](https://thisispennyleung.github.io/saga-ci/#groups)
111
+ - [Rollback & Error Handling](https://thisispennyleung.github.io/saga-ci/#rollback)
112
+ - [API Reference](https://thisispennyleung.github.io/saga-ci/#api)
113
+ - [Interactive Simulator](https://thisispennyleung.github.io/saga-ci/#simulator)
114
+
115
+ ---
116
+
117
+ ## Development
118
+
119
+ ```bash
120
+ npm run typecheck # Type-check src/ and examples/
121
+ npm run build # Compile dist/*.js and dist/*.d.ts
122
+ npm test # Run unit tests (31 tests, Node 24+)
123
+ npm run example:basic # Run basic release pipeline example
124
+ npm run example:rollback # Run parallel fork rollback example
125
+ npm run example:continue # Run continueOnError teardown example
126
+ ```
127
+
128
+ ## Releasing to npm
129
+
130
+ Pushing a version tag matching `v*.*.*` triggers [`.github/workflows/publish.yml`](.github/workflows/publish.yml), which checks that the tag matches `package.json`, runs `typecheck`, `build`, and `npm test`, and publishes with `--provenance --access public`.
131
+
132
+ 1. Add your npm Automation/Granular Access Token as the `NPM_TOKEN` repository secret in GitHub.
133
+ 2. Push a version tag:
134
+
135
+ ```bash
136
+ npm version patch && git push origin main --follow-tags
137
+ # or for the current version:
138
+ git tag v1.0.0 && git push origin v1.0.0
139
+ ```
140
+
141
+ ## License
142
+
143
+ [MIT](LICENSE)
@@ -0,0 +1,41 @@
1
+ import type { GroupEntry, ICommand, StepStatus, UndoStatus } from './ICommand.ts';
2
+ export interface GroupItem {
3
+ subStep: string;
4
+ /** Explicit display step from GroupEntryOptions.subStep; undefined when the number is positional. */
5
+ displaySubStep?: string;
6
+ command: ICommand;
7
+ hasUndo: boolean;
8
+ label?: string;
9
+ doStatus: StepStatus;
10
+ undoStatus: UndoStatus;
11
+ error?: Error;
12
+ }
13
+ export type ParallelItem = GroupItem;
14
+ export declare class GroupCommand implements ICommand {
15
+ readonly name: string;
16
+ readonly items: GroupItem[];
17
+ readonly parallel: boolean;
18
+ readonly maxConcurrency?: number;
19
+ readonly continueOnError: boolean;
20
+ onStepChange?: () => void;
21
+ constructor(name: string, commands: GroupEntry[], baseStepNumber?: number | string, parallel?: boolean, maxConcurrency?: number, continueOnError?: boolean);
22
+ shouldDo(): Promise<boolean>;
23
+ do(): Promise<void>;
24
+ /**
25
+ * Returns true when this group has at least one child (directly or in a nested chain)
26
+ * that ran do() and either succeeded or failed, so it may have external effects to compensate.
27
+ */
28
+ hasCompensableWork(): boolean;
29
+ /**
30
+ * Compensates every child that started do() in this group, in reverse order.
31
+ * Failed children are included because their partial effects must be reverted.
32
+ * Skipped and never-started children are excluded. Every undo is attempted even if an
33
+ * earlier one fails; a single aggregate error is thrown after all attempts.
34
+ */
35
+ undo(): Promise<void>;
36
+ private static requiresUndo;
37
+ }
38
+ export declare class ParallelGroupCommand extends GroupCommand {
39
+ constructor(name: string, commands: GroupEntry[], baseStepNumber?: number | string, maxConcurrency?: number, continueOnError?: boolean);
40
+ }
41
+ //# sourceMappingURL=GroupCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupCommand.d.ts","sourceRoot":"","sources":["../src/GroupCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElF,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,qGAAqG;IACrG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC,qBAAa,YAAa,YAAW,QAAQ;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,KAAK,EAAE,SAAS,EAAE,CAAM;IACxC,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAClC,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxC,SAAgB,eAAe,EAAE,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAEjC,YACE,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,UAAU,EAAE,EACtB,cAAc,GAAE,MAAM,GAAG,MAAW,EACpC,QAAQ,GAAE,OAAe,EACzB,cAAc,CAAC,EAAE,MAAM,EACvB,eAAe,GAAE,OAAe,EA8BjC;IAEY,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAExC;IAEY,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,CAkG/B;IAED;;;OAGG;IACI,kBAAkB,IAAI,OAAO,CAOnC;IAED;;;;;OAKG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmCjC;IAED,OAAO,CAAC,MAAM,CAAC,YAAY;CAS5B;AAED,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,YACE,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,UAAU,EAAE,EACtB,cAAc,GAAE,MAAM,GAAG,MAAW,EACpC,cAAc,CAAC,EAAE,MAAM,EACvB,eAAe,GAAE,OAAe,EAGjC;CACF"}
@@ -0,0 +1,198 @@
1
+ export class GroupCommand {
2
+ name;
3
+ items = [];
4
+ parallel;
5
+ maxConcurrency;
6
+ continueOnError;
7
+ onStepChange;
8
+ constructor(name, commands, baseStepNumber = '', parallel = false, maxConcurrency, continueOnError = false) {
9
+ this.name = name;
10
+ this.parallel = parallel;
11
+ this.maxConcurrency = maxConcurrency;
12
+ this.continueOnError = continueOnError;
13
+ commands.forEach((entry, idx) => {
14
+ const cmd = 'command' in entry ? entry.command : entry;
15
+ const hasUndo = 'hasUndo' in entry ? (entry.hasUndo ?? true) : true;
16
+ const label = 'label' in entry ? entry.label : undefined;
17
+ const displaySubStep = 'subStep' in entry ? entry.subStep : undefined;
18
+ const subStep = baseStepNumber ? `${baseStepNumber}.${idx + 1}` : String(idx + 1);
19
+ // A nested group (branch chain) reports its own progress through this group,
20
+ // so the status table refreshes while the nested chain runs.
21
+ if (cmd instanceof GroupCommand) {
22
+ cmd.onStepChange = () => this.onStepChange?.();
23
+ }
24
+ this.items.push({
25
+ subStep,
26
+ displaySubStep,
27
+ command: cmd,
28
+ hasUndo,
29
+ label,
30
+ doStatus: 'PENDING',
31
+ undoStatus: hasUndo ? '-' : 'N/A',
32
+ });
33
+ });
34
+ }
35
+ async shouldDo() {
36
+ return true;
37
+ }
38
+ async do() {
39
+ if (this.parallel) {
40
+ console.log(`[GroupCommand] Starting parallel execution of ${this.items.length} tasks for "${this.name}"...`);
41
+ const executeItem = async (item) => {
42
+ item.doStatus = 'RUNNING';
43
+ this.onStepChange?.();
44
+ try {
45
+ const shouldExecute = await item.command.shouldDo();
46
+ if (!shouldExecute) {
47
+ item.doStatus = 'SKIPPED';
48
+ item.undoStatus = 'N/A';
49
+ return;
50
+ }
51
+ await item.command.do();
52
+ if (item.doStatus === 'RUNNING') {
53
+ item.doStatus = 'SUCCESS';
54
+ }
55
+ }
56
+ catch (err) {
57
+ item.doStatus = 'FAILED';
58
+ item.error = err instanceof Error ? err : new Error(String(err));
59
+ throw item.error;
60
+ }
61
+ finally {
62
+ this.onStepChange?.();
63
+ }
64
+ };
65
+ let results;
66
+ if (this.maxConcurrency && this.maxConcurrency > 0 && this.maxConcurrency < this.items.length) {
67
+ results = new Array(this.items.length);
68
+ let nextIndex = 0;
69
+ const workerCount = this.maxConcurrency;
70
+ const workers = Array.from({ length: workerCount }, async () => {
71
+ while (nextIndex < this.items.length) {
72
+ const idx = nextIndex++;
73
+ const item = this.items[idx];
74
+ try {
75
+ await executeItem(item);
76
+ results[idx] = { status: 'fulfilled', value: undefined };
77
+ }
78
+ catch (err) {
79
+ results[idx] = { status: 'rejected', reason: err };
80
+ }
81
+ }
82
+ });
83
+ await Promise.all(workers);
84
+ }
85
+ else {
86
+ results = await Promise.allSettled(this.items.map((item) => executeItem(item)));
87
+ }
88
+ const failures = results.filter((r) => r.status === 'rejected');
89
+ if (failures.length > 0) {
90
+ const errorMsgs = failures.map((f) => f.reason?.message || String(f.reason)).join('; ');
91
+ throw new Error(`Parallel execution failed in ${failures.length} task(s): ${errorMsgs}`);
92
+ }
93
+ }
94
+ else {
95
+ console.log(`[GroupCommand] Starting sequential execution of ${this.items.length} tasks for "${this.name}"...`);
96
+ const failures = [];
97
+ for (const item of this.items) {
98
+ item.doStatus = 'RUNNING';
99
+ this.onStepChange?.();
100
+ try {
101
+ const shouldExecute = await item.command.shouldDo();
102
+ if (!shouldExecute) {
103
+ item.doStatus = 'SKIPPED';
104
+ item.undoStatus = 'N/A';
105
+ this.onStepChange?.();
106
+ continue;
107
+ }
108
+ await item.command.do();
109
+ if (item.doStatus === 'RUNNING') {
110
+ item.doStatus = 'SUCCESS';
111
+ }
112
+ }
113
+ catch (err) {
114
+ item.doStatus = 'FAILED';
115
+ item.error = err instanceof Error ? err : new Error(String(err));
116
+ this.onStepChange?.();
117
+ if (this.continueOnError) {
118
+ failures.push(item.error);
119
+ continue;
120
+ }
121
+ throw item.error;
122
+ }
123
+ finally {
124
+ this.onStepChange?.();
125
+ }
126
+ }
127
+ if (failures.length > 0) {
128
+ const errorMsgs = failures.map((f) => f.message || String(f)).join('; ');
129
+ throw new Error(`Sequential execution failed in ${failures.length} task(s) for "${this.name}": ${errorMsgs}`);
130
+ }
131
+ }
132
+ }
133
+ /**
134
+ * Returns true when this group has at least one child (directly or in a nested chain)
135
+ * that ran do() and either succeeded or failed, so it may have external effects to compensate.
136
+ */
137
+ hasCompensableWork() {
138
+ return this.items.some((item) => {
139
+ if (item.command instanceof GroupCommand) {
140
+ return item.command.hasCompensableWork();
141
+ }
142
+ return item.doStatus === 'SUCCESS' || item.doStatus === 'FAILED';
143
+ });
144
+ }
145
+ /**
146
+ * Compensates every child that started do() in this group, in reverse order.
147
+ * Failed children are included because their partial effects must be reverted.
148
+ * Skipped and never-started children are excluded. Every undo is attempted even if an
149
+ * earlier one fails; a single aggregate error is thrown after all attempts.
150
+ */
151
+ async undo() {
152
+ console.log(`[GroupCommand] Initiating reverse-order rollback for group "${this.name}"...`);
153
+ const rollbackFailures = [];
154
+ // do() has already settled every branch, so reverse item order is safe for parallel stages too.
155
+ for (let i = this.items.length - 1; i >= 0; i--) {
156
+ const item = this.items[i];
157
+ if (!GroupCommand.requiresUndo(item)) {
158
+ continue;
159
+ }
160
+ item.undoStatus = 'RUNNING';
161
+ this.onStepChange?.();
162
+ try {
163
+ await item.command.undo();
164
+ if (item.undoStatus === 'RUNNING') {
165
+ item.undoStatus = 'REVERTED';
166
+ }
167
+ }
168
+ catch (err) {
169
+ const caught = err instanceof Error ? err : new Error(String(err));
170
+ item.undoStatus = 'FAILED';
171
+ item.error = caught;
172
+ rollbackFailures.push(caught);
173
+ }
174
+ finally {
175
+ this.onStepChange?.();
176
+ }
177
+ }
178
+ if (rollbackFailures.length > 0) {
179
+ const errorMsgs = rollbackFailures.map((f) => f.message || String(f)).join('; ');
180
+ throw new Error(`Group rollback encountered ${rollbackFailures.length} failure(s) in "${this.name}": ${errorMsgs}`);
181
+ }
182
+ }
183
+ static requiresUndo(item) {
184
+ if (!item.hasUndo || item.undoStatus === 'N/A' || item.undoStatus === 'SHIELDED') {
185
+ return false;
186
+ }
187
+ if (item.command instanceof GroupCommand) {
188
+ return item.command.hasCompensableWork();
189
+ }
190
+ return item.doStatus === 'SUCCESS' || item.doStatus === 'FAILED';
191
+ }
192
+ }
193
+ export class ParallelGroupCommand extends GroupCommand {
194
+ constructor(name, commands, baseStepNumber = '', maxConcurrency, continueOnError = false) {
195
+ super(name, commands, baseStepNumber, true, maxConcurrency, continueOnError);
196
+ }
197
+ }
198
+ //# sourceMappingURL=GroupCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupCommand.js","sourceRoot":"","sources":["../src/GroupCommand.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,YAAY;IACP,IAAI,CAAS;IACb,KAAK,GAAgB,EAAE,CAAC;IACxB,QAAQ,CAAU;IAClB,cAAc,CAAU;IACxB,eAAe,CAAU;IAClC,YAAY,CAAc;IAEjC,YACE,IAAY,EACZ,QAAsB,EACtB,cAAc,GAAoB,EAAE,EACpC,QAAQ,GAAY,KAAK,EACzB,cAAuB,EACvB,eAAe,GAAY,KAAK;QAEhC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;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CACb,8BAA8B,gBAAgB,CAAC,MAAM,mBAAmB,IAAI,CAAC,IAAI,MAAM,SAAS,EAAE,CACnG,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,IAAe;QACzC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;YACjF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,YAAY,YAAY,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC;IACnE,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IACpD,YACE,IAAY,EACZ,QAAsB,EACtB,cAAc,GAAoB,EAAE,EACpC,cAAuB,EACvB,eAAe,GAAY,KAAK;QAEhC,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;IAC/E,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ export type StepStatus = 'PENDING' | 'RUNNING' | 'SUCCESS' | 'FAILED' | 'SKIPPED';
2
+ export type UndoStatus = '-' | 'N/A' | 'RUNNING' | 'REVERTED' | 'FAILED' | 'SHIELDED';
3
+ /**
4
+ * Command / Saga pattern contract for deployment CI steps.
5
+ * Each command encapsulates forward execution (`do`) and compensating rollback (`undo`).
6
+ */
7
+ export interface ICommand<TParams = unknown, TState = unknown> {
8
+ readonly name: string;
9
+ readonly parameters?: TParams;
10
+ state?: TState;
11
+ /**
12
+ * Evaluates whether the forward deployment action should be executed.
13
+ * Returns false if the resource is already in the desired state (skipped).
14
+ */
15
+ shouldDo(): Promise<boolean> | boolean;
16
+ /**
17
+ * Executes the forward deployment action.
18
+ */
19
+ do(): Promise<void> | void;
20
+ /**
21
+ * Executes compensating rollback.
22
+ * If rollback is not applicable (e.g. read-only validation or unexecuted conditional steps),
23
+ * leaves implementation blank/no-op and reports N/A.
24
+ */
25
+ undo(): Promise<void> | void;
26
+ }
27
+ export interface StepRecord {
28
+ stepNumber: number;
29
+ command: ICommand;
30
+ doStatus: StepStatus;
31
+ undoStatus: UndoStatus;
32
+ error?: Error;
33
+ }
34
+ /**
35
+ * Options accepted by group constructors for a single child entry.
36
+ * The child may be a plain command or a GroupCommand (a branch chain).
37
+ */
38
+ export interface GroupEntryOptions {
39
+ command: ICommand;
40
+ hasUndo?: boolean;
41
+ label?: string;
42
+ /**
43
+ * Explicit step number shown in the status table and failure callouts, such as "4.3".
44
+ * Overrides the positional number for this entry and its nested children.
45
+ */
46
+ subStep?: string;
47
+ }
48
+ /**
49
+ * A group child: either a bare command or a command with options.
50
+ */
51
+ export type GroupEntry = ICommand | GroupEntryOptions;
52
+ //# sourceMappingURL=ICommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICommand.d.ts","sourceRoot":"","sources":["../src/ICommand.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAClF,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEtF;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAEvC;;OAEG;IACH,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAE3B;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,QAAQ,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,QAAQ,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ICommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICommand.js","sourceRoot":"","sources":["../src/ICommand.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { CiWorkFlow } from './ci-workflow.ts';
2
+ /**
3
+ * Interface contract for workflow builders that construct and configure a CiWorkFlow.
4
+ */
5
+ export interface IWorkflowBuilder<TContext = unknown> {
6
+ build(context: TContext): CiWorkFlow;
7
+ }
8
+ //# sourceMappingURL=IWorkflowBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IWorkflowBuilder.d.ts","sourceRoot":"","sources":["../src/IWorkflowBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,QAAQ,GAAG,OAAO;IAClD,KAAK,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IWorkflowBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IWorkflowBuilder.js","sourceRoot":"","sources":["../src/IWorkflowBuilder.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ import type { GroupEntry, ICommand, StepRecord } from './ICommand.ts';
2
+ export interface CiWorkFlowOptions {
3
+ continueOnError?: boolean;
4
+ }
5
+ export declare class CiWorkFlow {
6
+ readonly continueOnError: boolean;
7
+ private steps;
8
+ private currentPosition;
9
+ constructor(options?: CiWorkFlowOptions);
10
+ /**
11
+ * Registers a step command in the workflow sequence.
12
+ * If `hasUndo` is false, undoStatus is initialized to 'N/A'.
13
+ */
14
+ register(command: ICommand, hasUndo?: boolean): this;
15
+ /**
16
+ * Registers a grouped execution subflow (sequential by default, or parallel if parallel=true).
17
+ */
18
+ registerGroup(groupName: string, commands: GroupEntry[], parallel?: boolean, maxConcurrency?: number, continueOnError?: boolean): this;
19
+ /**
20
+ * Registers a parallel execution group in the workflow sequence (alias for registerGroup with parallel=true).
21
+ */
22
+ registerParallel(groupName: string, commands: GroupEntry[], maxConcurrency?: number, continueOnError?: boolean): this;
23
+ getSteps(): ReadonlyArray<StepRecord>;
24
+ getCurrentPosition(): number;
25
+ /**
26
+ * Flattens every workflow step into renderable leaves. Plain steps become one leaf each.
27
+ * A top-level group contributes its items; nested group items (branch chains) contribute
28
+ * their children recursively, and only an empty group container is rendered as its own leaf.
29
+ */
30
+ private collectLeaves;
31
+ /**
32
+ * Recursively appends leaves for group items.
33
+ *
34
+ * Step number of a leaf, in priority order:
35
+ * 1. its own explicit displaySubStep,
36
+ * 2. the displaySubStep of the nearest ancestor that has one,
37
+ * 3. the positional number: `<parent positional step>.<index+1>` for nested children.
38
+ *
39
+ * A label is prefixed to the name as `[label] name`; an item without its own label
40
+ * inherits the nearest ancestor label.
41
+ */
42
+ private flattenGroupItems;
43
+ /**
44
+ * Renders the execution matrix as a space-padded GitHub Flavored Markdown table.
45
+ * Both stdout logging and GITHUB_STEP_SUMMARY share this exact aligned output.
46
+ */
47
+ renderMarkdownTable(): string;
48
+ /**
49
+ * Formats failure callouts and stack traces for GITHUB_STEP_SUMMARY when errors occur.
50
+ */
51
+ renderErrorsMarkdown(): string;
52
+ /**
53
+ * Appends / updates the Markdown execution table and failure details in $GITHUB_STEP_SUMMARY.
54
+ */
55
+ writeStepSummary(): void;
56
+ /**
57
+ * Formats and prints the status table to stdout via console.log(renderMarkdownTable())
58
+ * and synchronizes to GITHUB_STEP_SUMMARY.
59
+ */
60
+ print(): void;
61
+ /**
62
+ * Executes the registered workflow commands forward sequentially.
63
+ * If an error occurs:
64
+ * - If continueOnError is false (default): catches it, unwinds backwards executing `undo()`
65
+ * for applied steps, and rethrows the failure.
66
+ * - If continueOnError is true: marks step as FAILED, skips rollback, continues forward
67
+ * executing subsequent steps, and rethrows a composite error at the end if any step failed.
68
+ */
69
+ run(): Promise<void>;
70
+ }
71
+ //# sourceMappingURL=ci-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci-workflow.d.ts","sourceRoot":"","sources":["../src/ci-workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAyBtE,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,UAAU;IACrB,SAAgB,eAAe,EAAE,OAAO,CAAC;IACzC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,eAAe,CAAc;IAErC,YAAY,OAAO,CAAC,EAAE,iBAAiB,EAEtC;IAED;;;OAGG;IACI,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAE,OAAc,GAAG,IAAI,CAQhE;IAED;;OAEG;IACI,aAAa,CAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,UAAU,EAAE,EACtB,QAAQ,GAAE,OAAe,EACzB,cAAc,CAAC,EAAE,MAAM,EACvB,eAAe,CAAC,EAAE,OAAO,GACxB,IAAI,CAmBN;IAED;;OAEG;IACI,gBAAgB,CACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,UAAU,EAAE,EACtB,cAAc,CAAC,EAAE,MAAM,EACvB,eAAe,CAAC,EAAE,OAAO,GACxB,IAAI,CAEN;IAEM,QAAQ,IAAI,aAAa,CAAC,UAAU,CAAC,CAE3C;IAEM,kBAAkB,IAAI,MAAM,CAElC;IAED;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAkBrB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,iBAAiB;IAuBzB;;;OAGG;IACI,mBAAmB,IAAI,MAAM,CA4DnC;IAED;;OAEG;IACI,oBAAoB,IAAI,MAAM,CAmCpC;IAED;;OAEG;IACI,gBAAgB,IAAI,IAAI,CAU9B;IAED;;;OAGG;IACI,KAAK,IAAI,IAAI,CAInB;IAED;;;;;;;OAOG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA4FhC;CACF"}
@@ -0,0 +1,290 @@
1
+ import * as fs from 'node:fs';
2
+ import { GroupCommand } from './GroupCommand.js';
3
+ export class CiWorkFlow {
4
+ continueOnError;
5
+ steps = [];
6
+ currentPosition = -1;
7
+ constructor(options) {
8
+ this.continueOnError = options?.continueOnError ?? false;
9
+ }
10
+ /**
11
+ * Registers a step command in the workflow sequence.
12
+ * If `hasUndo` is false, undoStatus is initialized to 'N/A'.
13
+ */
14
+ register(command, hasUndo = true) {
15
+ this.steps.push({
16
+ stepNumber: this.steps.length + 1,
17
+ command,
18
+ doStatus: 'PENDING',
19
+ undoStatus: hasUndo ? '-' : 'N/A',
20
+ });
21
+ return this;
22
+ }
23
+ /**
24
+ * Registers a grouped execution subflow (sequential by default, or parallel if parallel=true).
25
+ */
26
+ registerGroup(groupName, commands, parallel = false, maxConcurrency, continueOnError) {
27
+ const nextStepNum = this.steps.length + 1;
28
+ const groupCmd = new GroupCommand(groupName, commands, nextStepNum, parallel, maxConcurrency, continueOnError ?? this.continueOnError);
29
+ groupCmd.onStepChange = () => this.print();
30
+ this.steps.push({
31
+ stepNumber: nextStepNum,
32
+ command: groupCmd,
33
+ doStatus: 'PENDING',
34
+ undoStatus: '-',
35
+ });
36
+ return this;
37
+ }
38
+ /**
39
+ * Registers a parallel execution group in the workflow sequence (alias for registerGroup with parallel=true).
40
+ */
41
+ registerParallel(groupName, commands, maxConcurrency, continueOnError) {
42
+ return this.registerGroup(groupName, commands, true, maxConcurrency, continueOnError);
43
+ }
44
+ getSteps() {
45
+ return this.steps;
46
+ }
47
+ getCurrentPosition() {
48
+ return this.currentPosition;
49
+ }
50
+ /**
51
+ * Flattens every workflow step into renderable leaves. Plain steps become one leaf each.
52
+ * A top-level group contributes its items; nested group items (branch chains) contribute
53
+ * their children recursively, and only an empty group container is rendered as its own leaf.
54
+ */
55
+ collectLeaves() {
56
+ const leaves = [];
57
+ for (const step of this.steps) {
58
+ if (step.command instanceof GroupCommand) {
59
+ this.flattenGroupItems(step.command.items, {}, leaves);
60
+ }
61
+ else {
62
+ leaves.push({
63
+ step: String(step.stepNumber),
64
+ name: step.command.name,
65
+ status: step,
66
+ });
67
+ }
68
+ }
69
+ return leaves;
70
+ }
71
+ /**
72
+ * Recursively appends leaves for group items.
73
+ *
74
+ * Step number of a leaf, in priority order:
75
+ * 1. its own explicit displaySubStep,
76
+ * 2. the displaySubStep of the nearest ancestor that has one,
77
+ * 3. the positional number: `<parent positional step>.<index+1>` for nested children.
78
+ *
79
+ * A label is prefixed to the name as `[label] name`; an item without its own label
80
+ * inherits the nearest ancestor label.
81
+ */
82
+ flattenGroupItems(items, scope, out) {
83
+ items.forEach((item, idx) => {
84
+ const positionalStep = scope.parentStep === undefined ? item.subStep : `${scope.parentStep}.${idx + 1}`;
85
+ const label = item.label ?? scope.label;
86
+ const displayStep = item.displaySubStep ?? scope.displayStep;
87
+ if (item.command instanceof GroupCommand && item.command.items.length > 0) {
88
+ this.flattenGroupItems(item.command.items, { parentStep: positionalStep, label, displayStep }, out);
89
+ return;
90
+ }
91
+ out.push({
92
+ step: displayStep ?? positionalStep,
93
+ name: label ? `[${label}] ${item.command.name}` : item.command.name,
94
+ status: item,
95
+ });
96
+ });
97
+ }
98
+ /**
99
+ * Renders the execution matrix as a space-padded GitHub Flavored Markdown table.
100
+ * Both stdout logging and GITHUB_STEP_SUMMARY share this exact aligned output.
101
+ */
102
+ renderMarkdownTable() {
103
+ const rows = this.collectLeaves().map((leaf) => ({
104
+ step: leaf.step,
105
+ name: leaf.name,
106
+ doStatus: leaf.status.doStatus,
107
+ undoStatus: leaf.status.undoStatus,
108
+ }));
109
+ // Calculate column widths with minimum baseline padding
110
+ let maxStep = 4; // 'Step'
111
+ let maxName = 4; // 'Name'
112
+ let maxDo = 2; // 'Do'
113
+ let maxUndo = 4; // 'Undo'
114
+ for (const row of rows) {
115
+ if (row.step.length > maxStep)
116
+ maxStep = row.step.length;
117
+ if (row.name.length > maxName)
118
+ maxName = row.name.length;
119
+ if (row.doStatus.length > maxDo)
120
+ maxDo = row.doStatus.length;
121
+ if (row.undoStatus.length > maxUndo)
122
+ maxUndo = row.undoStatus.length;
123
+ }
124
+ // Generous minimums for clean display
125
+ maxStep = Math.max(maxStep, 4);
126
+ maxName = Math.max(maxName, 39);
127
+ maxDo = Math.max(maxDo, 7);
128
+ maxUndo = Math.max(maxUndo, 8);
129
+ const lines = [];
130
+ lines.push('### Deployment Workflow Status Table\n');
131
+ // Header & divider
132
+ lines.push(`| ${'Step'.padEnd(maxStep)} | ${'Name'.padEnd(maxName)} | ${'Do'.padEnd(maxDo)} | ${'Undo'.padEnd(maxUndo)} |`);
133
+ lines.push(`| :${'-'.repeat(maxStep - 1)} | :${'-'.repeat(maxName - 1)} | :${'-'.repeat(maxDo - 1)} | :${'-'.repeat(maxUndo - 1)} |`);
134
+ // Rows
135
+ for (const row of rows) {
136
+ lines.push(`| ${row.step.padEnd(maxStep)} | ${row.name.padEnd(maxName)} | ${row.doStatus.padEnd(maxDo)} | ${row.undoStatus.padEnd(maxUndo)} |`);
137
+ }
138
+ lines.push('');
139
+ // Append error details if any failures exist
140
+ const errorBlock = this.renderErrorsMarkdown();
141
+ if (errorBlock) {
142
+ lines.push(errorBlock);
143
+ }
144
+ return lines.join('\n');
145
+ }
146
+ /**
147
+ * Formats failure callouts and stack traces for GITHUB_STEP_SUMMARY when errors occur.
148
+ */
149
+ renderErrorsMarkdown() {
150
+ const errorEntries = [];
151
+ for (const leaf of this.collectLeaves()) {
152
+ if (leaf.status.error) {
153
+ const phase = leaf.status.undoStatus === 'FAILED' ? 'Rollback' : 'Execution';
154
+ errorEntries.push({
155
+ step: leaf.step,
156
+ name: leaf.name,
157
+ phase,
158
+ error: leaf.status.error,
159
+ });
160
+ }
161
+ }
162
+ if (errorEntries.length === 0) {
163
+ return '';
164
+ }
165
+ const lines = [];
166
+ lines.push('### ❌ Deployment Failure Details\n');
167
+ for (const entry of errorEntries) {
168
+ lines.push(`> [!CAUTION]`);
169
+ lines.push(`> **Step ${entry.step} (${entry.name}) - ${entry.phase} Failed**`);
170
+ lines.push(`>`);
171
+ lines.push(`> \`\`\`text`);
172
+ const msg = entry.error.stack || entry.error.message || String(entry.error);
173
+ for (const line of msg.split('\n')) {
174
+ lines.push(`> ${line}`);
175
+ }
176
+ lines.push(`> \`\`\`\n`);
177
+ }
178
+ return lines.join('\n');
179
+ }
180
+ /**
181
+ * Appends / updates the Markdown execution table and failure details in $GITHUB_STEP_SUMMARY.
182
+ */
183
+ writeStepSummary() {
184
+ const summaryPath = process.env.GITHUB_STEP_SUMMARY;
185
+ if (!summaryPath) {
186
+ return;
187
+ }
188
+ try {
189
+ fs.writeFileSync(summaryPath, this.renderMarkdownTable(), 'utf-8');
190
+ }
191
+ catch (err) {
192
+ console.error('[CiWorkFlow] Warning: Failed to write to GITHUB_STEP_SUMMARY:', err);
193
+ }
194
+ }
195
+ /**
196
+ * Formats and prints the status table to stdout via console.log(renderMarkdownTable())
197
+ * and synchronizes to GITHUB_STEP_SUMMARY.
198
+ */
199
+ print() {
200
+ const table = this.renderMarkdownTable();
201
+ console.log(table);
202
+ this.writeStepSummary();
203
+ }
204
+ /**
205
+ * Executes the registered workflow commands forward sequentially.
206
+ * If an error occurs:
207
+ * - If continueOnError is false (default): catches it, unwinds backwards executing `undo()`
208
+ * for applied steps, and rethrows the failure.
209
+ * - If continueOnError is true: marks step as FAILED, skips rollback, continues forward
210
+ * executing subsequent steps, and rethrows a composite error at the end if any step failed.
211
+ */
212
+ async run() {
213
+ const executionFailures = [];
214
+ for (this.currentPosition = 0; this.currentPosition < this.steps.length; this.currentPosition++) {
215
+ const step = this.steps[this.currentPosition];
216
+ step.doStatus = 'RUNNING';
217
+ this.print();
218
+ try {
219
+ const shouldExecute = await step.command.shouldDo();
220
+ if (!shouldExecute) {
221
+ step.doStatus = 'SKIPPED';
222
+ step.undoStatus = 'N/A';
223
+ this.print();
224
+ continue;
225
+ }
226
+ await step.command.do();
227
+ // Handle commands that marked themselves as SKIPPED during do()
228
+ if (step.doStatus === 'RUNNING') {
229
+ step.doStatus = 'SUCCESS';
230
+ }
231
+ this.print();
232
+ }
233
+ catch (error) {
234
+ const caughtError = error instanceof Error ? error : new Error(String(error));
235
+ step.doStatus = 'FAILED';
236
+ step.error = caughtError;
237
+ executionFailures.push(caughtError);
238
+ this.print();
239
+ if (!this.continueOnError) {
240
+ console.error(`\n[CiWorkFlow] Workflow execution failed at Step ${this.currentPosition + 1}: ${caughtError.message}`);
241
+ console.log('[CiWorkFlow] Initiating reverse-order compensating rollback...\n');
242
+ const rollbackFailures = [];
243
+ // Compensating rollback loop in reverse order
244
+ while (this.currentPosition >= 0) {
245
+ const rollbackStep = this.steps[this.currentPosition];
246
+ // Groups need compensation when any nested child succeeded or failed after starting.
247
+ // Other steps are reverted only when they succeeded.
248
+ const needsUndo = rollbackStep.command instanceof GroupCommand
249
+ ? rollbackStep.command.hasCompensableWork()
250
+ : rollbackStep.doStatus === 'SUCCESS';
251
+ if (rollbackStep.undoStatus !== 'N/A' &&
252
+ rollbackStep.undoStatus !== 'SHIELDED' &&
253
+ rollbackStep.doStatus !== 'SKIPPED' &&
254
+ needsUndo) {
255
+ rollbackStep.undoStatus = 'RUNNING';
256
+ this.print();
257
+ try {
258
+ await rollbackStep.command.undo();
259
+ if (rollbackStep.undoStatus === 'RUNNING') {
260
+ rollbackStep.undoStatus = 'REVERTED';
261
+ }
262
+ }
263
+ catch (undoErr) {
264
+ console.error(`[CiWorkFlow] Error undoing step ${rollbackStep.stepNumber} (${rollbackStep.command.name}):`, undoErr);
265
+ rollbackStep.undoStatus = 'FAILED';
266
+ rollbackStep.error = undoErr instanceof Error ? undoErr : new Error(String(undoErr));
267
+ rollbackFailures.push(rollbackStep.error);
268
+ }
269
+ this.print();
270
+ }
271
+ else if (rollbackStep.undoStatus === 'N/A') {
272
+ console.log(`[CiWorkFlow] Step ${rollbackStep.stepNumber} (${rollbackStep.command.name}) rollback: N/A`);
273
+ }
274
+ this.currentPosition--;
275
+ }
276
+ if (rollbackFailures.length > 0) {
277
+ throw new Error(`Deployment failed: ${caughtError.message} (with ${rollbackFailures.length} rollback failure(s))`);
278
+ }
279
+ throw caughtError;
280
+ }
281
+ console.error(`\n[CiWorkFlow] Step ${this.currentPosition + 1} (${step.command.name}) failed with continueOnError enabled: ${caughtError.message}`);
282
+ }
283
+ }
284
+ if (this.continueOnError && executionFailures.length > 0) {
285
+ const msgs = executionFailures.map((e) => e.message).join('; ');
286
+ throw new Error(`Workflow completed with ${executionFailures.length} failure(s): ${msgs}`);
287
+ }
288
+ }
289
+ }
290
+ //# sourceMappingURL=ci-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci-workflow.js","sourceRoot":"","sources":["../src/ci-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,O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AE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,2BAA2B,iBAAiB,CAAC,MAAM,gBAAgB,IAAI,EAAE,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { CiWorkFlow } from './ci-workflow.ts';
2
+ export type { CiWorkFlowOptions } from './ci-workflow.ts';
3
+ export { GroupCommand, ParallelGroupCommand } from './GroupCommand.ts';
4
+ export type { GroupItem, ParallelItem } from './GroupCommand.ts';
5
+ export type { StepStatus, UndoStatus, ICommand, StepRecord, GroupEntryOptions, GroupEntry, } from './ICommand.ts';
6
+ export type { IWorkflowBuilder } from './IWorkflowBuilder.ts';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjE,YAAY,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,iBAAiB,EACjB,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { CiWorkFlow } from './ci-workflow.js';
2
+ export { GroupCommand, ParallelGroupCommand } from './GroupCommand.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "saga-ci",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "Saga-pattern CI/CD workflow runner with sequential/parallel groups, reverse-order compensating rollback, and aligned GitHub Step Summary reporting.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./ci-workflow": {
14
+ "types": "./dist/ci-workflow.d.ts",
15
+ "import": "./dist/ci-workflow.js"
16
+ },
17
+ "./command": {
18
+ "types": "./dist/ICommand.d.ts",
19
+ "import": "./dist/ICommand.js"
20
+ },
21
+ "./group-command": {
22
+ "types": "./dist/GroupCommand.d.ts",
23
+ "import": "./dist/GroupCommand.js"
24
+ },
25
+ "./workflow-builder": {
26
+ "types": "./dist/IWorkflowBuilder.d.ts",
27
+ "import": "./dist/IWorkflowBuilder.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "engines": {
36
+ "node": ">=18.0.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/ThisIsPennyLeung/saga-ci.git"
41
+ },
42
+ "homepage": "https://thisispennyleung.github.io/saga-ci/",
43
+ "bugs": {
44
+ "url": "https://github.com/ThisIsPennyLeung/saga-ci/issues"
45
+ },
46
+ "author": "Penny Leung",
47
+ "scripts": {
48
+ "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
49
+ "typecheck": "tsc -p tsconfig.json",
50
+ "build": "npm run clean && tsc -p tsconfig.build.json",
51
+ "prepublishOnly": "npm run typecheck && npm run build && npm test",
52
+ "test": "node --test test/*.test.mjs",
53
+ "example:basic": "node examples/01-basic-pipeline.ts",
54
+ "example:rollback": "node examples/02-parallel-fork-rollback.ts",
55
+ "example:continue": "node examples/03-continue-on-error.ts"
56
+ },
57
+ "keywords": [
58
+ "ci",
59
+ "cd",
60
+ "workflow",
61
+ "saga",
62
+ "rollback",
63
+ "github-actions",
64
+ "step-summary",
65
+ "command-pattern"
66
+ ],
67
+ "license": "MIT",
68
+ "devDependencies": {
69
+ "@types/node": "^26.6.11",
70
+ "typescript": "^7.0.2"
71
+ }
72
+ }