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,100 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Detect Changes Action Template
|
|
3
3
|
*
|
|
4
|
-
* Generates a GitHub composite action that detects which domains
|
|
5
|
-
*
|
|
6
|
-
* conditional workflow execution.
|
|
4
|
+
* Generates a REUSABLE GitHub composite action that detects which domains have changed
|
|
5
|
+
* using path-based change detection with dorny/paths-filter.
|
|
7
6
|
*
|
|
8
7
|
* ## Purpose
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* This action is **configuration-driven** and accepts domain definitions as YAML input,
|
|
10
|
+
* making it truly reusable across any project without regeneration.
|
|
11
|
+
* It uses path filters to detect which domains changed based on file glob patterns.
|
|
13
12
|
*
|
|
14
|
-
* ##
|
|
13
|
+
* ## Key Design Principle
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* 3. Outputs a boolean for each domain (true if changed, false if not)
|
|
19
|
-
* 4. Logs results for debugging
|
|
15
|
+
* **Domains are passed as input, not hardcoded in the action.**
|
|
16
|
+
* This allows the same action to work with any domain configuration without regeneration.
|
|
20
17
|
*
|
|
21
18
|
* ## Generated Action Location
|
|
22
19
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* ## Usage in Workflows
|
|
26
|
-
*
|
|
27
|
-
* ```yaml
|
|
28
|
-
* jobs:
|
|
29
|
-
* changes:
|
|
30
|
-
* runs-on: ubuntu-latest
|
|
31
|
-
* outputs:
|
|
32
|
-
* api: ${{ steps.changes.outputs.api }}
|
|
33
|
-
* web: ${{ steps.changes.outputs.web }}
|
|
34
|
-
* steps:
|
|
35
|
-
* - uses: ./.github/actions/detect-changes
|
|
36
|
-
* id: changes
|
|
37
|
-
* with:
|
|
38
|
-
* baseRef: main
|
|
39
|
-
*
|
|
40
|
-
* test-api:
|
|
41
|
-
* needs: changes
|
|
42
|
-
* if: needs.changes.outputs.api == 'true'
|
|
43
|
-
* # Only runs if API domain changed
|
|
44
|
-
* ```
|
|
20
|
+
* `actions/detect-changes/action.yml`
|
|
45
21
|
*
|
|
46
22
|
* @module templates/actions/detect-changes.yml.tpl
|
|
47
23
|
*/
|
|
48
|
-
import {
|
|
24
|
+
import { renderTemplate, toFile } from '@featherscloud/pinion';
|
|
49
25
|
import fs from 'fs';
|
|
50
26
|
import { logger } from '../../utils/logger.js';
|
|
27
|
+
import { getActionOutputDir, shouldGenerateActions } from '../../utils/action-reference.js';
|
|
51
28
|
/**
|
|
52
29
|
* Generates the detect-changes composite action YAML content.
|
|
53
30
|
*
|
|
54
31
|
* Creates a GitHub Actions composite action that:
|
|
55
|
-
* - Accepts
|
|
56
|
-
* -
|
|
57
|
-
* - Uses dorny/paths-filter
|
|
58
|
-
* -
|
|
59
|
-
* - Logs detection results
|
|
32
|
+
* - Accepts domain configuration as YAML input (not hardcoded)
|
|
33
|
+
* - Dynamically parses domains using yq or grep fallback
|
|
34
|
+
* - Uses dorny/paths-filter for path-based change detection
|
|
35
|
+
* - Outputs individual domain results AND a JSON summary
|
|
60
36
|
*
|
|
61
|
-
* @param {any} ctx - Context
|
|
62
|
-
* @param {Record<string, DomainConfig>} ctx.domains - Domain configurations with path patterns
|
|
37
|
+
* @param {any} ctx - Context (not used - action is fully dynamic now)
|
|
63
38
|
* @returns {string} YAML content for the composite action
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const yaml = changesActionTemplate({
|
|
68
|
-
* domains: {
|
|
69
|
-
* api: { paths: ['src/api/**'] },
|
|
70
|
-
* web: { paths: ['src/web/**'] }
|
|
71
|
-
* }
|
|
72
|
-
* })
|
|
73
|
-
* // Generates action with 'api' and 'web' outputs
|
|
74
|
-
* ```
|
|
75
39
|
*/
|
|
76
40
|
const changesActionTemplate = (ctx) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return ` ${domainName}:
|
|
80
|
-
description: 'Whether ${domainName} domain has changes'
|
|
81
|
-
value: \${{ steps.merge.outputs.${domainName} }}`;
|
|
82
|
-
}).join('\n');
|
|
83
|
-
const domainFilters = Object.entries(ctx.domains).map((entry) => {
|
|
84
|
-
const [domainName, domainConfig] = entry;
|
|
85
|
-
return ` ${domainName}:\n - '${domainConfig.paths.join("'\\n - '")}'`;
|
|
86
|
-
}).join('\n');
|
|
87
|
-
const domainEchoes = Object.entries(ctx.domains).map((entry) => {
|
|
88
|
-
const [domainName, domainConfig] = entry;
|
|
89
|
-
return ` echo "${domainName}=\${{ contains(steps.filter.outputs.changes, '${domainName}') }}" >> $GITHUB_OUTPUT`;
|
|
90
|
-
}).join('\n');
|
|
91
|
-
const domainResults = Object.entries(ctx.domains).map((entry) => {
|
|
92
|
-
const [domainName, domainConfig] = entry;
|
|
93
|
-
return ` echo " ${domainName}: \${{ contains(steps.filter.outputs.changes, '${domainName}') }}"`;
|
|
94
|
-
}).join('\n');
|
|
95
|
-
// Generate the composite action YAML
|
|
96
|
-
return `name: 'Detect Changes'
|
|
97
|
-
description: 'Detect changes in different application domains based on file paths'
|
|
41
|
+
return `name: 'Detect Changes (Configuration-Driven)'
|
|
42
|
+
description: 'Path-based change detection using dorny/paths-filter. Accepts domain configuration as YAML input.'
|
|
98
43
|
author: 'Pipecraft'
|
|
99
44
|
|
|
100
45
|
inputs:
|
|
@@ -102,18 +47,21 @@ inputs:
|
|
|
102
47
|
description: 'Base reference to compare against'
|
|
103
48
|
required: false
|
|
104
49
|
default: 'main'
|
|
50
|
+
domains-config:
|
|
51
|
+
description: 'YAML string of domain configurations (embedded in pipeline at generation time)'
|
|
52
|
+
required: true
|
|
105
53
|
|
|
106
54
|
outputs:
|
|
107
|
-
|
|
55
|
+
changes:
|
|
56
|
+
description: 'JSON object with domain change results (e.g., {"core": true, "docs": false})'
|
|
57
|
+
value: \${{ steps.output.outputs.changes }}
|
|
58
|
+
affectedDomains:
|
|
59
|
+
description: 'Comma-separated list of domains with changes'
|
|
60
|
+
value: \${{ steps.output.outputs.affectedDomains }}
|
|
108
61
|
|
|
109
62
|
runs:
|
|
110
63
|
using: 'composite'
|
|
111
64
|
steps:
|
|
112
|
-
- name: Checkout Code
|
|
113
|
-
uses: actions/checkout@v4
|
|
114
|
-
with:
|
|
115
|
-
fetch-depth: 0
|
|
116
|
-
|
|
117
65
|
- name: Set Base Branch
|
|
118
66
|
id: set-base
|
|
119
67
|
shell: bash
|
|
@@ -122,54 +70,126 @@ runs:
|
|
|
122
70
|
echo "base_branch=$base_branch" >> $GITHUB_OUTPUT
|
|
123
71
|
echo "base_branch=$base_branch" >> $GITHUB_ENV
|
|
124
72
|
|
|
125
|
-
- name:
|
|
73
|
+
- name: Parse Domain Configuration
|
|
74
|
+
id: parse-domains
|
|
75
|
+
shell: bash
|
|
76
|
+
run: |
|
|
77
|
+
# Parse the domains-config YAML input (embedded in pipeline at generation time)
|
|
78
|
+
echo "\${{ inputs.domains-config }}" > /tmp/domains-config.yml
|
|
79
|
+
|
|
80
|
+
# Extract domain names using yq (or fallback to grep/awk)
|
|
81
|
+
if command -v yq >/dev/null 2>&1; then
|
|
82
|
+
DOMAIN_NAMES=$(yq eval 'keys | join(",")' /tmp/domains-config.yml)
|
|
83
|
+
else
|
|
84
|
+
# Fallback: extract domain names without yq
|
|
85
|
+
DOMAIN_NAMES=$(grep -E '^[[:space:]]*[a-zA-Z0-9_-]+:' /tmp/domains-config.yml | sed 's/[[:space:]]*\\(.*\\):.*/\\1/' | tr '\\n' ',' | sed 's/,$//')
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
echo "domains=$DOMAIN_NAMES" >> $GITHUB_OUTPUT
|
|
89
|
+
echo "📋 Configured domains: $DOMAIN_NAMES"
|
|
90
|
+
|
|
91
|
+
- name: Transform Domain Config for Paths Filter
|
|
92
|
+
id: transform-config
|
|
93
|
+
shell: bash
|
|
94
|
+
run: |
|
|
95
|
+
# Transform domains-config from PipeCraft format to paths-filter format
|
|
96
|
+
# PipeCraft format: domain: { paths: [...] }
|
|
97
|
+
# paths-filter format: domain: [...]
|
|
98
|
+
|
|
99
|
+
# Read the domains config
|
|
100
|
+
cat /tmp/domains-config.yml
|
|
101
|
+
|
|
102
|
+
# Transform: remove 'paths:' lines and unindent the glob patterns
|
|
103
|
+
sed '/paths:/d' /tmp/domains-config.yml | sed 's/^ -/-/' > /tmp/paths-filter-config.yml
|
|
104
|
+
|
|
105
|
+
echo ""
|
|
106
|
+
echo "Transformed for paths-filter:"
|
|
107
|
+
cat /tmp/paths-filter-config.yml
|
|
108
|
+
|
|
109
|
+
# Store as output for use in paths-filter
|
|
110
|
+
{
|
|
111
|
+
echo "filters<<EOF"
|
|
112
|
+
cat /tmp/paths-filter-config.yml
|
|
113
|
+
echo "EOF"
|
|
114
|
+
} >> $GITHUB_OUTPUT
|
|
115
|
+
|
|
116
|
+
- name: Detect Changes with Paths Filter
|
|
126
117
|
uses: dorny/paths-filter@v3
|
|
127
118
|
id: filter
|
|
128
119
|
with:
|
|
129
120
|
base: \${{ steps.set-base.outputs.base_branch }}
|
|
130
|
-
filters:
|
|
131
|
-
${domainFilters}
|
|
121
|
+
filters: \${{ steps.transform-config.outputs.filters }}
|
|
132
122
|
|
|
133
|
-
- name:
|
|
134
|
-
id:
|
|
123
|
+
- name: Generate Outputs
|
|
124
|
+
id: output
|
|
135
125
|
shell: bash
|
|
136
126
|
run: |
|
|
137
|
-
|
|
138
|
-
|
|
127
|
+
echo "📁 Using path-based change detection"
|
|
128
|
+
echo "{" > /tmp/path-results.json
|
|
129
|
+
|
|
130
|
+
IFS=',' read -ra DOMAIN_NAMES <<< "\${{ steps.parse-domains.outputs.domains }}"
|
|
131
|
+
FIRST=true
|
|
132
|
+
for domain in "\${DOMAIN_NAMES[@]}"; do
|
|
133
|
+
domain=$(echo "$domain" | xargs)
|
|
134
|
+
if [ "$FIRST" = true ]; then
|
|
135
|
+
FIRST=false
|
|
136
|
+
else
|
|
137
|
+
echo "," >> /tmp/path-results.json
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
# Check if domain appears in filter changes
|
|
141
|
+
if echo "\${{ steps.filter.outputs.changes }}" | grep -q "$domain"; then
|
|
142
|
+
echo " \\"$domain\\": true" >> /tmp/path-results.json
|
|
143
|
+
else
|
|
144
|
+
echo " \\"$domain\\": false" >> /tmp/path-results.json
|
|
145
|
+
fi
|
|
146
|
+
done
|
|
147
|
+
echo "}" >> /tmp/path-results.json
|
|
148
|
+
|
|
149
|
+
CHANGES_JSON=$(cat /tmp/path-results.json)
|
|
150
|
+
|
|
151
|
+
# Output the JSON
|
|
152
|
+
echo "changes<<EOF" >> $GITHUB_OUTPUT
|
|
153
|
+
echo "$CHANGES_JSON" >> $GITHUB_OUTPUT
|
|
154
|
+
echo "EOF" >> $GITHUB_OUTPUT
|
|
155
|
+
|
|
156
|
+
# Build comma-separated list of affected domains (using node instead of jq for portability)
|
|
157
|
+
AFFECTED_DOMAINS=$(node -e "
|
|
158
|
+
const data = JSON.parse(process.argv[1]);
|
|
159
|
+
const affected = Object.entries(data)
|
|
160
|
+
.filter(([_, v]) => v === true)
|
|
161
|
+
.map(([k]) => k)
|
|
162
|
+
.join(',');
|
|
163
|
+
console.log(affected);
|
|
164
|
+
" "$CHANGES_JSON")
|
|
165
|
+
echo "affectedDomains=$AFFECTED_DOMAINS" >> $GITHUB_OUTPUT
|
|
166
|
+
|
|
139
167
|
echo "📋 Change Detection Results:"
|
|
140
|
-
$
|
|
168
|
+
node -e "console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 2))" "$CHANGES_JSON"
|
|
169
|
+
echo "🎯 Affected domains: $AFFECTED_DOMAINS"
|
|
170
|
+
`;
|
|
141
171
|
};
|
|
142
172
|
/**
|
|
143
173
|
* Generator entry point for detect-changes composite action.
|
|
144
174
|
*
|
|
145
|
-
* Generates the
|
|
146
|
-
* change detection logic. This action
|
|
147
|
-
*
|
|
175
|
+
* Generates the \`actions/detect-changes/action.yml\` file with configuration-driven
|
|
176
|
+
* change detection logic. This action accepts domain configuration as input at runtime,
|
|
177
|
+
* making it truly reusable without regeneration.
|
|
148
178
|
*
|
|
149
179
|
* @param {PinionContext} ctx - Pinion generator context
|
|
150
|
-
* @param {Record<string, DomainConfig>} ctx.domains - Domain configurations
|
|
151
180
|
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```typescript
|
|
155
|
-
* await generate({
|
|
156
|
-
* cwd: '/path/to/project',
|
|
157
|
-
* domains: {
|
|
158
|
-
* api: { paths: ['src/api/**'], description: 'API' },
|
|
159
|
-
* web: { paths: ['src/web/**'], description: 'Web' }
|
|
160
|
-
* }
|
|
161
|
-
* })
|
|
162
|
-
* // Creates: .github/actions/detect-changes/action.yml
|
|
163
|
-
* ```
|
|
164
181
|
*/
|
|
165
|
-
export const generate = (ctx) => Promise.resolve(ctx)
|
|
166
|
-
.
|
|
167
|
-
|
|
168
|
-
|
|
182
|
+
export const generate = (ctx) => Promise.resolve(ctx).then(ctx => {
|
|
183
|
+
const config = ctx.config || {};
|
|
184
|
+
if (!shouldGenerateActions(config)) {
|
|
185
|
+
logger.verbose('Skipping detect-changes action generation (using remote actions)');
|
|
186
|
+
return ctx;
|
|
187
|
+
}
|
|
188
|
+
const outputDir = getActionOutputDir(config);
|
|
189
|
+
const filePath = `${outputDir}/detect-changes/action.yml`;
|
|
169
190
|
const exists = fs.existsSync(filePath);
|
|
170
191
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
171
192
|
logger.verbose(`${status} ${filePath}`);
|
|
172
|
-
return ctx;
|
|
173
|
-
})
|
|
174
|
-
.then(renderTemplate(changesActionTemplate, toFile('.github/actions/detect-changes/action.yml')));
|
|
193
|
+
return renderTemplate(changesActionTemplate, toFile(filePath))(ctx);
|
|
194
|
+
});
|
|
175
195
|
//# sourceMappingURL=detect-changes.yml.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-changes.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/detect-changes.yml.tpl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"detect-changes.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/detect-changes.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAsB,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAG3F;;;;;;;;;;;GAWG;AACH,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiIR,CAAA;AACD,CAAC,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAA0D,EAAE,EAAE,CACrF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;IAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAA;IAE/B,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,kEAAkE,CAAC,CAAA;QAClF,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,GAAG,SAAS,4BAA4B,CAAA;IACzD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IAEvC,OAAO,cAAc,CAAC,qBAAqB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AACrE,CAAC,CAAC,CAAA"}
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module templates/actions/manage-branch.yml.tpl
|
|
8
8
|
*/
|
|
9
|
-
import { PinionContext } from '@featherscloud/pinion';
|
|
9
|
+
import { type PinionContext } from '@featherscloud/pinion';
|
|
10
|
+
import type { PipecraftConfig } from '../../types/index.js';
|
|
10
11
|
/**
|
|
11
12
|
* Generator entry point for manage-branch composite action.
|
|
12
13
|
*
|
|
13
14
|
* @param {PinionContext} ctx - Pinion generator context
|
|
14
15
|
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
15
16
|
*/
|
|
16
|
-
export declare const generate: (ctx: PinionContext
|
|
17
|
+
export declare const generate: (ctx: PinionContext & {
|
|
18
|
+
config?: Partial<PipecraftConfig>;
|
|
19
|
+
}) => Promise<any>;
|
|
17
20
|
//# sourceMappingURL=manage-branch.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"manage-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAKlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AA4H3D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,iBAgB/E,CAAA"}
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module templates/actions/manage-branch.yml.tpl
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import fs from 'fs';
|
|
9
|
+
import { renderTemplate, toFile } from '@featherscloud/pinion';
|
|
11
10
|
import dedent from 'dedent';
|
|
11
|
+
import fs from 'fs';
|
|
12
12
|
import { logger } from '../../utils/logger.js';
|
|
13
|
+
import { getActionOutputDir, shouldGenerateActions } from '../../utils/action-reference.js';
|
|
13
14
|
/**
|
|
14
15
|
* Generates the manage-branch composite action YAML content.
|
|
15
16
|
*
|
|
@@ -137,14 +138,17 @@ const branchActionTemplate = (ctx) => {
|
|
|
137
138
|
* @param {PinionContext} ctx - Pinion generator context
|
|
138
139
|
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
139
140
|
*/
|
|
140
|
-
export const generate = (ctx) => Promise.resolve(ctx)
|
|
141
|
-
.
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
export const generate = (ctx) => Promise.resolve(ctx).then(ctx => {
|
|
142
|
+
const config = ctx.config || {};
|
|
143
|
+
if (!shouldGenerateActions(config)) {
|
|
144
|
+
logger.verbose('Skipping manage-branch action generation (using remote actions)');
|
|
145
|
+
return ctx;
|
|
146
|
+
}
|
|
147
|
+
const outputDir = getActionOutputDir(config);
|
|
148
|
+
const filePath = `${outputDir}/manage-branch/action.yml`;
|
|
144
149
|
const exists = fs.existsSync(filePath);
|
|
145
150
|
const status = exists ? '🔄 Merged with existing' : '📝 Created new';
|
|
146
151
|
logger.verbose(`${status} ${filePath}`);
|
|
147
|
-
return ctx;
|
|
148
|
-
})
|
|
149
|
-
.then(renderTemplate(branchActionTemplate, toFile('.github/actions/manage-branch/action.yml')));
|
|
152
|
+
return renderTemplate(branchActionTemplate, toFile(filePath))(ctx);
|
|
153
|
+
});
|
|
150
154
|
//# sourceMappingURL=manage-branch.yml.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"manage-branch.yml.tpl.js","sourceRoot":"","sources":["../../../src/templates/actions/manage-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAsB,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAG3F;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACxC,OAAO,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgHA,CAAA;AACf,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAA0D,EAAE,EAAE,CACrF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;IAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAA;IAE/B,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAA;QACjF,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,GAAG,SAAS,2BAA2B,CAAA;IACxD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,gBAAgB,CAAA;IACpE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAA;IAEvC,OAAO,cAAc,CAAC,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AACpE,CAAC,CAAC,CAAA"}
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module templates/actions/promote-branch.yml.tpl
|
|
8
8
|
*/
|
|
9
|
-
import { PinionContext } from '@featherscloud/pinion';
|
|
9
|
+
import { type PinionContext } from '@featherscloud/pinion';
|
|
10
|
+
import type { PipecraftConfig } from '../../types/index.js';
|
|
10
11
|
/**
|
|
11
12
|
* Generator entry point for promote-branch composite action.
|
|
12
13
|
*
|
|
13
14
|
* @param {PinionContext} ctx - Pinion generator context
|
|
14
15
|
* @returns {Promise<PinionContext>} Updated context after file generation
|
|
15
16
|
*/
|
|
16
|
-
export declare const generate: (ctx: PinionContext
|
|
17
|
+
export declare const generate: (ctx: PinionContext & {
|
|
18
|
+
config?: Partial<PipecraftConfig>;
|
|
19
|
+
}) => Promise<any>;
|
|
17
20
|
//# sourceMappingURL=promote-branch.yml.tpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promote-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"promote-branch.yml.tpl.d.ts","sourceRoot":"","sources":["../../../src/templates/actions/promote-branch.yml.tpl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAKlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAkU3D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,aAAa,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,iBAgB/E,CAAA"}
|