pipecraft 0.29.3 → 0.36.14
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 +128 -54
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +68 -25
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +4 -4
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +214 -108
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +9 -9
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +33 -36
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +7 -4
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +49 -23
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +14 -8
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.js +16 -11
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +13 -9
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +17 -51
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +130 -110
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +13 -9
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +5 -2
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +39 -92
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/release-it.cjs.tpl.d.ts +1 -1
- package/dist/templates/release-it.cjs.tpl.d.ts.map +1 -1
- package/dist/templates/release-it.cjs.tpl.js +38 -29
- package/dist/templates/release-it.cjs.tpl.js.map +1 -1
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.d.ts +1 -1
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.js +2 -3
- package/dist/templates/workflows/enforce-pr-target.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline.yml.tpl.d.ts +2 -2
- package/dist/templates/workflows/pipeline.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline.yml.tpl.js +337 -84
- package/dist/templates/workflows/pipeline.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pr-title-check.yml.tpl.d.ts +1 -1
- package/dist/templates/workflows/pr-title-check.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pr-title-check.yml.tpl.js +101 -22
- package/dist/templates/workflows/pr-title-check.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/shared/index.d.ts +4 -2
- package/dist/templates/workflows/shared/index.d.ts.map +1 -1
- package/dist/templates/workflows/shared/index.js +4 -2
- package/dist/templates/workflows/shared/index.js.map +1 -1
- package/dist/templates/workflows/shared/managed-workflow.d.ts +32 -0
- package/dist/templates/workflows/shared/managed-workflow.d.ts.map +1 -0
- package/dist/templates/workflows/shared/managed-workflow.js +51 -0
- package/dist/templates/workflows/shared/managed-workflow.js.map +1 -0
- package/dist/templates/workflows/shared/operations-changes.d.ts +13 -3
- package/dist/templates/workflows/shared/operations-changes.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-changes.js +42 -16
- package/dist/templates/workflows/shared/operations-changes.js.map +1 -1
- package/dist/templates/workflows/shared/operations-domain-jobs.d.ts +18 -1
- package/dist/templates/workflows/shared/operations-domain-jobs.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-domain-jobs.js +142 -17
- package/dist/templates/workflows/shared/operations-domain-jobs.js.map +1 -1
- package/dist/templates/workflows/shared/operations-gate.d.ts +6 -0
- package/dist/templates/workflows/shared/operations-gate.d.ts.map +1 -0
- package/dist/templates/workflows/shared/operations-gate.js +116 -0
- package/dist/templates/workflows/shared/operations-gate.js.map +1 -0
- package/dist/templates/workflows/shared/operations-header.d.ts +11 -1
- package/dist/templates/workflows/shared/operations-header.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-header.js +66 -7
- package/dist/templates/workflows/shared/operations-header.js.map +1 -1
- package/dist/templates/workflows/shared/operations-tag-promote.d.ts +4 -3
- package/dist/templates/workflows/shared/operations-tag-promote.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-tag-promote.js +144 -33
- package/dist/templates/workflows/shared/operations-tag-promote.js.map +1 -1
- package/dist/templates/workflows/shared/operations-version.d.ts +3 -2
- package/dist/templates/workflows/shared/operations-version.d.ts.map +1 -1
- package/dist/templates/workflows/shared/operations-version.js +17 -16
- package/dist/templates/workflows/shared/operations-version.js.map +1 -1
- package/dist/templates/yaml-format-utils.d.ts.map +1 -1
- package/dist/templates/yaml-format-utils.js +1 -5
- package/dist/templates/yaml-format-utils.js.map +1 -1
- package/dist/types/index.d.ts +65 -53
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/action-reference.d.ts +73 -0
- package/dist/utils/action-reference.d.ts.map +1 -0
- package/dist/utils/action-reference.js +120 -0
- package/dist/utils/action-reference.js.map +1 -0
- package/dist/utils/ast-path-operations.d.ts +3 -3
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +58 -17
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +16 -5
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +69 -12
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +7 -7
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +84 -63
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/messaging.d.ts +2 -2
- package/dist/utils/messaging.d.ts.map +1 -1
- package/dist/utils/messaging.js +12 -8
- package/dist/utils/messaging.js.map +1 -1
- package/dist/utils/preflight.d.ts +2 -2
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +43 -41
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +1 -1
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +10 -10
- package/dist/utils/versioning.js.map +1 -1
- package/dist/utils/workflow-semantics.d.ts +61 -0
- package/dist/utils/workflow-semantics.d.ts.map +1 -0
- package/dist/utils/workflow-semantics.js +230 -0
- package/dist/utils/workflow-semantics.js.map +1 -0
- package/package.json +12 -4
- package/src/generators/init.tpl.ts +275 -128
- package/src/generators/workflows.tpl.ts +54 -57
- package/dist/templates/actions/detect-changes-nx.yml.tpl.d.ts +0 -32
- package/dist/templates/actions/detect-changes-nx.yml.tpl.d.ts.map +0 -1
- package/dist/templates/actions/detect-changes-nx.yml.tpl.js +0 -227
- package/dist/templates/actions/detect-changes-nx.yml.tpl.js.map +0 -1
- package/dist/templates/workflows/pipeline-nx.yml.tpl.d.ts +0 -22
- package/dist/templates/workflows/pipeline-nx.yml.tpl.d.ts.map +0 -1
- package/dist/templates/workflows/pipeline-nx.yml.tpl.js +0 -196
- package/dist/templates/workflows/pipeline-nx.yml.tpl.js.map +0 -1
- package/dist/utils/idempotency.d.ts +0 -187
- package/dist/utils/idempotency.d.ts.map +0 -1
- package/dist/utils/idempotency.js +0 -304
- package/dist/utils/idempotency.js.map +0 -1
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nx Pipeline Template
|
|
3
|
-
*
|
|
4
|
-
* Generates an Nx-optimized workflow that uses `nx affected` to intelligently test
|
|
5
|
-
* only changed projects. Runs all Nx tasks sequentially in a single job, leveraging
|
|
6
|
-
* Nx's built-in caching and parallel execution.
|
|
7
|
-
*
|
|
8
|
-
* This is Option 1 (Sequential Strategy) - simple, fast, and leverages Nx's intelligence.
|
|
9
|
-
*/
|
|
10
|
-
import { renderTemplate, toFile } from '@featherscloud/pinion';
|
|
11
|
-
import { parseDocument, stringify } from 'yaml';
|
|
12
|
-
import fs from 'fs';
|
|
13
|
-
import { logger } from '../../utils/logger.js';
|
|
14
|
-
import { applyPathOperations, createValueFromString } from '../../utils/ast-path-operations.js';
|
|
15
|
-
import { createHeaderOperations, createChangesJobOperation, createDomainTestJobOperations, createDomainDeployJobOperations, createDomainRemoteTestJobOperations, createVersionJobOperation, createTagPromoteReleaseOperations, getDomainJobNames } from './shared/index.js';
|
|
16
|
-
import { formatIfConditions } from '../yaml-format-utils.js';
|
|
17
|
-
/**
|
|
18
|
-
* Create the nx-ci job operation (Nx-specific)
|
|
19
|
-
*/
|
|
20
|
-
function createNxCiJobOperation(ctx) {
|
|
21
|
-
const { config } = ctx;
|
|
22
|
-
const nxConfig = config.nx;
|
|
23
|
-
const packageManager = config.packageManager || 'npm';
|
|
24
|
-
const enableCache = nxConfig.enableCache !== false;
|
|
25
|
-
const taskSteps = nxConfig.tasks
|
|
26
|
-
.map(task => ` - name: Run Nx Affected - ${task}
|
|
27
|
-
run: npx nx affected --target=${task} --base=\${{ inputs.baseRef || '${nxConfig.baseRef || 'origin/main'}' }}`)
|
|
28
|
-
.join('\n');
|
|
29
|
-
const cacheStep = enableCache
|
|
30
|
-
? `
|
|
31
|
-
- name: Cache Nx
|
|
32
|
-
uses: actions/cache@v4
|
|
33
|
-
with:
|
|
34
|
-
path: .nx/cache
|
|
35
|
-
# Cache key includes run_number to allow saving updated cache on each run
|
|
36
|
-
# Nx cache accumulates computation results, so we want to save after every run
|
|
37
|
-
# restore-keys ensure we start from the most recent cache on this branch
|
|
38
|
-
key: nx-\${{ runner.os }}-\${{ hashFiles('package-lock.json') }}-\${{ github.ref_name }}-\${{ github.run_number }}
|
|
39
|
-
restore-keys: |
|
|
40
|
-
nx-\${{ runner.os }}-\${{ hashFiles('package-lock.json') }}-\${{ github.ref_name }}-
|
|
41
|
-
nx-\${{ runner.os }}-\${{ hashFiles('package-lock.json') }}-
|
|
42
|
-
nx-\${{ runner.os }}-
|
|
43
|
-
`
|
|
44
|
-
: '';
|
|
45
|
-
return {
|
|
46
|
-
path: 'jobs.nx-ci',
|
|
47
|
-
operation: 'overwrite',
|
|
48
|
-
commentBefore: `
|
|
49
|
-
=============================================================================
|
|
50
|
-
NX CI - All Tasks Sequential (⚠️ Managed by Pipecraft - do not modify)
|
|
51
|
-
=============================================================================
|
|
52
|
-
This job runs all Nx tasks sequentially using \`nx affected\`.
|
|
53
|
-
Nx handles dependency detection, caching, and parallel execution internally.
|
|
54
|
-
`,
|
|
55
|
-
value: createValueFromString(`
|
|
56
|
-
needs: changes
|
|
57
|
-
runs-on: ubuntu-latest
|
|
58
|
-
steps:
|
|
59
|
-
- name: Checkout Code
|
|
60
|
-
uses: actions/checkout@v4
|
|
61
|
-
with:
|
|
62
|
-
ref: \${{ inputs.commitSha || github.sha }}
|
|
63
|
-
fetch-depth: 0
|
|
64
|
-
|
|
65
|
-
- name: Setup Node.js
|
|
66
|
-
uses: actions/setup-node@v4
|
|
67
|
-
with:
|
|
68
|
-
node-version: '24'
|
|
69
|
-
|
|
70
|
-
- name: Install Dependencies
|
|
71
|
-
run: |
|
|
72
|
-
case "${packageManager}" in
|
|
73
|
-
pnpm)
|
|
74
|
-
corepack enable
|
|
75
|
-
pnpm install --frozen-lockfile || pnpm install
|
|
76
|
-
;;
|
|
77
|
-
yarn)
|
|
78
|
-
yarn install --frozen-lockfile || yarn install
|
|
79
|
-
;;
|
|
80
|
-
npm)
|
|
81
|
-
npm ci || npm install
|
|
82
|
-
;;
|
|
83
|
-
*)
|
|
84
|
-
npm install
|
|
85
|
-
;;
|
|
86
|
-
esac
|
|
87
|
-
env:
|
|
88
|
-
packageManager: ${packageManager}
|
|
89
|
-
${cacheStep}
|
|
90
|
-
${taskSteps}
|
|
91
|
-
`)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Main generator that handles merging with existing workflow
|
|
96
|
-
*/
|
|
97
|
-
export const generate = (ctx) => Promise.resolve(ctx)
|
|
98
|
-
.then(ctx => {
|
|
99
|
-
const filePath = `${ctx.cwd || process.cwd()}/.github/workflows/pipeline.yml`;
|
|
100
|
-
const { config, branchFlow } = ctx;
|
|
101
|
-
const domains = config.domains || {};
|
|
102
|
-
const nxConfig = config.nx;
|
|
103
|
-
// Get domain job names for dependency management
|
|
104
|
-
const { testJobs, deployJobs, remoteTestJobs } = getDomainJobNames(domains);
|
|
105
|
-
// Build operations array
|
|
106
|
-
const operations = [
|
|
107
|
-
// Header (name, run-name, on triggers)
|
|
108
|
-
...createHeaderOperations({ branchFlow }),
|
|
109
|
-
// Changes detection (Nx-enabled)
|
|
110
|
-
createChangesJobOperation({
|
|
111
|
-
domains,
|
|
112
|
-
useNx: true,
|
|
113
|
-
baseRef: nxConfig.baseRef || 'origin/main'
|
|
114
|
-
}),
|
|
115
|
-
// Nx CI job (Nx-specific!)
|
|
116
|
-
createNxCiJobOperation(ctx),
|
|
117
|
-
// Domain test jobs (preserved for user customization)
|
|
118
|
-
...createDomainTestJobOperations({ domains }),
|
|
119
|
-
// Version calculation
|
|
120
|
-
createVersionJobOperation({
|
|
121
|
-
testJobNames: testJobs,
|
|
122
|
-
nxEnabled: true,
|
|
123
|
-
baseRef: nxConfig.baseRef || 'origin/main'
|
|
124
|
-
}),
|
|
125
|
-
// Domain deploy jobs (preserved for user customization)
|
|
126
|
-
...createDomainDeployJobOperations({ domains }),
|
|
127
|
-
// Domain remote test jobs (preserved for user customization)
|
|
128
|
-
...createDomainRemoteTestJobOperations({ domains }),
|
|
129
|
-
// Tag, promote, release
|
|
130
|
-
...createTagPromoteReleaseOperations({
|
|
131
|
-
branchFlow,
|
|
132
|
-
deployJobNames: deployJobs,
|
|
133
|
-
remoteTestJobNames: remoteTestJobs
|
|
134
|
-
})
|
|
135
|
-
];
|
|
136
|
-
// Check if file exists
|
|
137
|
-
if (!fs.existsSync(filePath)) {
|
|
138
|
-
logger.verbose('📝 Creating new Nx pipeline');
|
|
139
|
-
// Create new document with empty YAML map
|
|
140
|
-
const doc = parseDocument('{}');
|
|
141
|
-
if (doc.contents) {
|
|
142
|
-
applyPathOperations(doc.contents, operations, doc);
|
|
143
|
-
}
|
|
144
|
-
const yamlContent = stringify(doc, { lineWidth: 0, minContentWidth: 0 });
|
|
145
|
-
const formattedContent = formatIfConditions(yamlContent);
|
|
146
|
-
return { ...ctx, yamlContent: formattedContent, mergeStatus: 'created' };
|
|
147
|
-
}
|
|
148
|
-
// Parse existing file
|
|
149
|
-
const existingContent = fs.readFileSync(filePath, 'utf8');
|
|
150
|
-
const doc = parseDocument(existingContent);
|
|
151
|
-
// Get managed jobs (always overwritten)
|
|
152
|
-
const managedJobs = new Set(['changes', 'nx-ci', 'version', 'tag', 'promote', 'release']);
|
|
153
|
-
// Extract user jobs from existing (preserves comments!)
|
|
154
|
-
const userJobs = new Map();
|
|
155
|
-
const existingJobs = doc.contents && doc.contents.get ? doc.contents.get('jobs') : null;
|
|
156
|
-
if (existingJobs && existingJobs.items) {
|
|
157
|
-
for (const item of existingJobs.items) {
|
|
158
|
-
const jobName = item.key?.toString();
|
|
159
|
-
if (jobName && !managedJobs.has(jobName) && !testJobs.includes(jobName) && !deployJobs.includes(jobName) && !remoteTestJobs.includes(jobName)) {
|
|
160
|
-
// This is a custom user job - preserve it completely
|
|
161
|
-
userJobs.set(jobName, item);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
// Clear all jobs before applying operations to prevent duplicates
|
|
166
|
-
if (existingJobs && existingJobs.items) {
|
|
167
|
-
;
|
|
168
|
-
existingJobs.items = [];
|
|
169
|
-
}
|
|
170
|
-
// Apply operations to update managed jobs
|
|
171
|
-
if (doc.contents) {
|
|
172
|
-
applyPathOperations(doc.contents, operations, doc);
|
|
173
|
-
}
|
|
174
|
-
// Add back user jobs (preserves their comments!)
|
|
175
|
-
if (userJobs.size > 0) {
|
|
176
|
-
logger.verbose(`📋 Preserving ${userJobs.size} user jobs: ${Array.from(userJobs.keys()).join(', ')}`);
|
|
177
|
-
const jobsNode = doc.contents.get('jobs');
|
|
178
|
-
if (jobsNode && jobsNode.items) {
|
|
179
|
-
for (const [_, item] of userJobs) {
|
|
180
|
-
jobsNode.items.push(item);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const status = userJobs.size > 0 ? 'merged' : 'updated';
|
|
185
|
-
const yamlContent = stringify(doc, { lineWidth: 0, minContentWidth: 0 });
|
|
186
|
-
const formattedContent = formatIfConditions(yamlContent);
|
|
187
|
-
return { ...ctx, yamlContent: formattedContent, mergeStatus: status };
|
|
188
|
-
})
|
|
189
|
-
.then(ctx => {
|
|
190
|
-
const outputPath = ctx.outputPipelinePath || '.github/workflows/pipeline.yml';
|
|
191
|
-
const status = ctx.mergeStatus === 'merged' ? '🔄 Merged with existing' : ctx.mergeStatus === 'updated' ? '🔄 Updated existing' : '📝 Created new';
|
|
192
|
-
logger.verbose(`${status} ${outputPath}`);
|
|
193
|
-
return ctx;
|
|
194
|
-
})
|
|
195
|
-
.then(renderTemplate((ctx) => ctx.yamlContent, toFile((ctx) => ctx.outputPipelinePath || '.github/workflows/pipeline.yml')));
|
|
196
|
-
//# sourceMappingURL=pipeline-nx.yml.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-nx.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/workflows/pipeline-nx.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAiB,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE7E,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAuB,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AACpH,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC7B,+BAA+B,EAC/B,mCAAmC,EACnC,yBAAyB,EACzB,iCAAiC,EACjC,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAQ5D;;GAEG;AACH,SAAS,sBAAsB,CAAC,GAAsB;IACpD,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;IACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAG,CAAA;IAC3B,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,KAAK,CAAA;IACrD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,KAAK,KAAK,CAAA;IAElD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK;SAC7B,GAAG,CACF,IAAI,CAAC,EAAE,CAAC,mCAAmC,IAAI;wCACb,IAAI,mCAAmC,QAAQ,CAAC,OAAO,IAAI,aAAa,MAAM,CACjH;SACA,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,MAAM,SAAS,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,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,IAAI,gCAAgC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotency and Caching Utilities
|
|
3
|
-
*
|
|
4
|
-
* This module implements intelligent caching to avoid unnecessary workflow regeneration.
|
|
5
|
-
* It tracks file hashes and modification times for:
|
|
6
|
-
* - Configuration files (.pipecraftrc.json)
|
|
7
|
-
* - Template source files (src/templates/)
|
|
8
|
-
* - Generator code (src/generators/)
|
|
9
|
-
*
|
|
10
|
-
* Workflows are only regenerated when relevant source files have changed,
|
|
11
|
-
* significantly improving performance during iterative development.
|
|
12
|
-
*
|
|
13
|
-
* The cache is stored in `.pipecraft-cache.json` and contains hashes
|
|
14
|
-
* of all tracked files along with metadata.
|
|
15
|
-
*
|
|
16
|
-
* @module utils/idempotency
|
|
17
|
-
*/
|
|
18
|
-
import { PipecraftConfig } from '../types/index.js';
|
|
19
|
-
/**
|
|
20
|
-
* Metadata and hash information for a tracked file.
|
|
21
|
-
*/
|
|
22
|
-
export interface FileHash {
|
|
23
|
-
/** Relative path to the file */
|
|
24
|
-
path: string;
|
|
25
|
-
/** Cryptographic hash of file content and metadata */
|
|
26
|
-
hash: string;
|
|
27
|
-
/** Last modification time (Unix timestamp in milliseconds) */
|
|
28
|
-
mtime: number;
|
|
29
|
-
/** File size in bytes */
|
|
30
|
-
size: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Complete rebuild cache structure stored in .pipecraft-cache.json.
|
|
34
|
-
*
|
|
35
|
-
* This cache enables idempotent workflow generation by tracking when
|
|
36
|
-
* configuration or template files change.
|
|
37
|
-
*/
|
|
38
|
-
export interface RebuildCache {
|
|
39
|
-
/** Map of file paths to their hash metadata */
|
|
40
|
-
files: Record<string, FileHash>;
|
|
41
|
-
/** Hash of the configuration file (.pipecraftrc.json) */
|
|
42
|
-
configHash: string;
|
|
43
|
-
/** Timestamp when workflows were last generated */
|
|
44
|
-
lastGenerated: number;
|
|
45
|
-
/** Cache format version for future migration compatibility */
|
|
46
|
-
version: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Manager for idempotent workflow generation through intelligent caching.
|
|
50
|
-
*
|
|
51
|
-
* This class tracks changes to configuration and template files to determine
|
|
52
|
-
* when workflows need to be regenerated. It creates cryptographic hashes of
|
|
53
|
-
* files and directories to detect changes efficiently.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* const manager = new IdempotencyManager(config)
|
|
58
|
-
*
|
|
59
|
-
* if (await manager.hasChanges()) {
|
|
60
|
-
* // Generate workflows
|
|
61
|
-
* await generateWorkflows()
|
|
62
|
-
* // Update cache after successful generation
|
|
63
|
-
* await manager.updateCache()
|
|
64
|
-
* } else {
|
|
65
|
-
* console.log('No changes detected, skipping regeneration')
|
|
66
|
-
* }
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export declare class IdempotencyManager {
|
|
70
|
-
private cacheFile;
|
|
71
|
-
private config;
|
|
72
|
-
/**
|
|
73
|
-
* Create a new IdempotencyManager instance.
|
|
74
|
-
*
|
|
75
|
-
* @param config - PipeCraft configuration object
|
|
76
|
-
* @param cacheFile - Path to cache file (default: .pipecraft-cache.json)
|
|
77
|
-
*/
|
|
78
|
-
constructor(config: PipecraftConfig, cacheFile?: string);
|
|
79
|
-
/**
|
|
80
|
-
* Calculate cryptographic hash for a file or directory.
|
|
81
|
-
*
|
|
82
|
-
* For files: Hashes content + mtime + size to detect any changes
|
|
83
|
-
* For directories: Recursively hashes all files within
|
|
84
|
-
*
|
|
85
|
-
* Returns empty string if the path doesn't exist.
|
|
86
|
-
*
|
|
87
|
-
* @param filePath - Path to file or directory to hash
|
|
88
|
-
* @param algorithm - Hashing algorithm (default: sha256)
|
|
89
|
-
* @returns Hex-encoded hash string
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```typescript
|
|
93
|
-
* const configHash = await manager.calculateHash('.pipecraftrc.json')
|
|
94
|
-
* const templateHash = await manager.calculateHash('src/templates')
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
calculateHash(filePath: string, algorithm?: string): Promise<string>;
|
|
98
|
-
/**
|
|
99
|
-
* Hash directory contents recursively.
|
|
100
|
-
*
|
|
101
|
-
* Traverses all files in the directory tree and combines their hashes
|
|
102
|
-
* along with metadata into a single directory hash. This allows detecting
|
|
103
|
-
* when any file within the directory structure has changed.
|
|
104
|
-
*
|
|
105
|
-
* @param dirPath - Path to directory to hash
|
|
106
|
-
* @param algorithm - Hashing algorithm
|
|
107
|
-
* @returns Hex-encoded hash string representing the entire directory
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
private hashDirectory;
|
|
111
|
-
/**
|
|
112
|
-
* Load rebuild cache from filesystem.
|
|
113
|
-
*
|
|
114
|
-
* Reads and parses the cache file containing previous generation state.
|
|
115
|
-
* Returns null if cache doesn't exist or can't be parsed.
|
|
116
|
-
*
|
|
117
|
-
* @returns Parsed cache object or null if unavailable
|
|
118
|
-
*/
|
|
119
|
-
loadCache(): RebuildCache | null;
|
|
120
|
-
/**
|
|
121
|
-
* Save rebuild cache to filesystem.
|
|
122
|
-
*
|
|
123
|
-
* Writes the cache object to disk as formatted JSON.
|
|
124
|
-
* Failures are logged as warnings but don't throw errors.
|
|
125
|
-
*
|
|
126
|
-
* @param cache - Cache object to persist
|
|
127
|
-
*/
|
|
128
|
-
saveCache(cache: RebuildCache): void;
|
|
129
|
-
/**
|
|
130
|
-
* Check if any tracked files have changed since last generation.
|
|
131
|
-
*
|
|
132
|
-
* Compares current file hashes against cached values to detect changes in:
|
|
133
|
-
* - Configuration file (.pipecraftrc.json)
|
|
134
|
-
* - Template source files (src/templates/)
|
|
135
|
-
* - Generator code (src/generators/)
|
|
136
|
-
*
|
|
137
|
-
* Returns true if:
|
|
138
|
-
* - Rebuild is disabled (always regenerate)
|
|
139
|
-
* - Force regenerate flag is set
|
|
140
|
-
* - No cache exists
|
|
141
|
-
* - Any tracked file has changed
|
|
142
|
-
*
|
|
143
|
-
* @returns true if workflows should be regenerated
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* if (await manager.hasChanges()) {
|
|
148
|
-
* console.log('Changes detected, regenerating workflows...')
|
|
149
|
-
* await generateWorkflows()
|
|
150
|
-
* await manager.updateCache()
|
|
151
|
-
* }
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
hasChanges(): Promise<boolean>;
|
|
155
|
-
/**
|
|
156
|
-
* Update cache with current file states after successful generation.
|
|
157
|
-
*
|
|
158
|
-
* Should be called after workflows are successfully generated to save
|
|
159
|
-
* the current state of all tracked files. This allows future runs to
|
|
160
|
-
* skip regeneration if nothing has changed.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* await generateWorkflows()
|
|
165
|
-
* await manager.updateCache() // Save current state
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
updateCache(): Promise<void>;
|
|
169
|
-
/**
|
|
170
|
-
* Check if a specific file should be regenerated.
|
|
171
|
-
*
|
|
172
|
-
* Similar to hasChanges() but checks a single file instead of the
|
|
173
|
-
* entire project. Useful for selective regeneration.
|
|
174
|
-
*
|
|
175
|
-
* @param filePath - Path to file to check
|
|
176
|
-
* @returns true if file should be regenerated
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
* ```typescript
|
|
180
|
-
* if (await manager.shouldRegenerateFile('.github/workflows/pipeline.yml')) {
|
|
181
|
-
* await generatePipeline()
|
|
182
|
-
* }
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
shouldRegenerateFile(filePath: string): Promise<boolean>;
|
|
186
|
-
}
|
|
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