@flit/cdk-pipeline 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +4711 -242
- package/dist/artifact.js +1 -1
- package/dist/code-commit-source-segment.d.ts +3 -3
- package/dist/code-commit-source-segment.js +11 -5
- package/dist/code-star-source-segment.js +2 -2
- package/dist/git-hub-source-segment.js +2 -2
- package/dist/pipeline-segment.js +2 -2
- package/dist/pipeline.d.ts +5 -1
- package/dist/pipeline.js +22 -17
- package/dist/publish-assets-action.js +1 -1
- package/dist/s3-source-segment.js +2 -2
- package/dist/segment.d.ts +2 -0
- package/dist/segment.js +8 -3
- package/dist/source-segment.js +1 -1
- package/dist/stack-segment.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -14
- package/src/code-commit-source-segment.ts +17 -5
- package/src/pipeline.ts +34 -18
- package/src/segment.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flit/cdk-pipeline",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A highly customizable and extensible CI/CD pipeline intended as alternative to CDK's native CodePipeline",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
"useTabs": true
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@types/node": "^
|
|
55
|
-
"aws-cdk-lib": "^2.
|
|
56
|
-
"constructs": "^10.4.
|
|
57
|
-
"jsii": "^5.9.
|
|
58
|
-
"jsii-pacmak": "^1.
|
|
59
|
-
"prettier": "^3.
|
|
60
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
61
|
-
"typescript": "^5.9.
|
|
54
|
+
"@types/node": "^25.0.3",
|
|
55
|
+
"aws-cdk-lib": "^2.232.0",
|
|
56
|
+
"constructs": "^10.4.0",
|
|
57
|
+
"jsii": "^5.9.22",
|
|
58
|
+
"jsii-pacmak": "^1.125.0",
|
|
59
|
+
"prettier": "^3.7.4",
|
|
60
|
+
"prettier-plugin-packagejson": "^2.5.20",
|
|
61
|
+
"typescript": "^5.9.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"aws-cdk-lib": "^2.
|
|
65
|
-
"constructs": "^10.4.
|
|
64
|
+
"aws-cdk-lib": "^2.232.0",
|
|
65
|
+
"constructs": "^10.4.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"targets": {
|
|
77
77
|
"java": {
|
|
78
|
-
"package": "flit.cdk
|
|
78
|
+
"package": "flit.cdk.pipeline",
|
|
79
79
|
"maven": {
|
|
80
80
|
"groupId": "flit",
|
|
81
81
|
"artifactId": "cdk-pipeline"
|
|
@@ -86,8 +86,7 @@
|
|
|
86
86
|
"packageId": "Flit.CDK.Pipeline"
|
|
87
87
|
},
|
|
88
88
|
"python": {
|
|
89
|
-
"
|
|
90
|
-
"module": "flit.cdk-pipeline",
|
|
89
|
+
"module": "flit.cdk.pipeline",
|
|
91
90
|
"classifiers": [
|
|
92
91
|
"Framework :: AWS CDK",
|
|
93
92
|
"Framework :: AWS CDK :: 2"
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
CodeCommitSourceAction,
|
|
4
4
|
CodeCommitTrigger,
|
|
5
5
|
} from "aws-cdk-lib/aws-codepipeline-actions";
|
|
6
|
-
import {
|
|
6
|
+
import { Repository } from "aws-cdk-lib/aws-codecommit";
|
|
7
7
|
|
|
8
8
|
import { Pipeline } from "./pipeline";
|
|
9
9
|
import { Artifact } from "./artifact";
|
|
@@ -11,7 +11,8 @@ import { SegmentConstructed } from "./segment";
|
|
|
11
11
|
import { SourceSegment, SourceSegmentProps } from "./source-segment";
|
|
12
12
|
|
|
13
13
|
export interface CodeCommitSourceSegmentProps extends SourceSegmentProps {
|
|
14
|
-
readonly
|
|
14
|
+
readonly repositoryName: string;
|
|
15
|
+
readonly repositoryArn: string;
|
|
15
16
|
readonly branch?: string;
|
|
16
17
|
readonly trigger?: CodeCommitTrigger;
|
|
17
18
|
readonly variablesNamespace?: string;
|
|
@@ -27,7 +28,9 @@ export class CodeCommitSourceSegment extends SourceSegment {
|
|
|
27
28
|
this.props = props;
|
|
28
29
|
}
|
|
29
30
|
construct(scope: Pipeline): SegmentConstructed {
|
|
30
|
-
const name = `${this.props.
|
|
31
|
+
const name = `${this.props.repositoryName}-${
|
|
32
|
+
this.props.branch || "master"
|
|
33
|
+
}`;
|
|
31
34
|
|
|
32
35
|
return new CodeCommitSourceSegmentConstructed(scope, name, {
|
|
33
36
|
...this.props,
|
|
@@ -39,7 +42,7 @@ export class CodeCommitSourceSegment extends SourceSegment {
|
|
|
39
42
|
export interface CodeCommitSourceSegmentConstructedProps {
|
|
40
43
|
readonly output: Artifact;
|
|
41
44
|
readonly actionName: string;
|
|
42
|
-
readonly
|
|
45
|
+
readonly repositoryArn: string;
|
|
43
46
|
readonly branch?: string;
|
|
44
47
|
readonly trigger?: CodeCommitTrigger;
|
|
45
48
|
readonly variablesNamespace?: string;
|
|
@@ -55,6 +58,15 @@ export class CodeCommitSourceSegmentConstructed extends SegmentConstructed {
|
|
|
55
58
|
) {
|
|
56
59
|
super(scope, id);
|
|
57
60
|
this.name = "Source";
|
|
58
|
-
this.actions = [
|
|
61
|
+
this.actions = [
|
|
62
|
+
new CodeCommitSourceAction({
|
|
63
|
+
repository: Repository.fromRepositoryArn(
|
|
64
|
+
this,
|
|
65
|
+
"Repository",
|
|
66
|
+
props.repositoryArn,
|
|
67
|
+
),
|
|
68
|
+
...props,
|
|
69
|
+
}),
|
|
70
|
+
];
|
|
59
71
|
}
|
|
60
72
|
}
|
package/src/pipeline.ts
CHANGED
|
@@ -7,10 +7,15 @@ import {
|
|
|
7
7
|
} from "aws-cdk-lib/aws-codepipeline";
|
|
8
8
|
import * as path from "path";
|
|
9
9
|
|
|
10
|
-
import { Segment, SegmentConstructed } from "./segment";
|
|
10
|
+
import { isSegment, Segment, SegmentConstructed } from "./segment";
|
|
11
11
|
import { isSource } from "./source-segment";
|
|
12
12
|
import { isPipeline } from "./pipeline-segment";
|
|
13
13
|
|
|
14
|
+
export interface SegmentGroup {
|
|
15
|
+
readonly stageName?: string;
|
|
16
|
+
readonly segments: Segment[];
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
export interface PipelineProps extends StackProps {
|
|
15
20
|
/**
|
|
16
21
|
* The name of the generated pipeline.
|
|
@@ -26,7 +31,7 @@ export interface PipelineProps extends StackProps {
|
|
|
26
31
|
/**
|
|
27
32
|
* The segments to populating the pipeline.
|
|
28
33
|
*/
|
|
29
|
-
readonly segments: (Segment | Segment[])[];
|
|
34
|
+
readonly segments: (Segment | Segment[] | SegmentGroup)[];
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
/**
|
|
@@ -50,12 +55,16 @@ export class Pipeline extends Stack {
|
|
|
50
55
|
|
|
51
56
|
if (!this.bundlingRequired) return;
|
|
52
57
|
|
|
53
|
-
const
|
|
54
|
-
Array.isArray(segment)
|
|
58
|
+
const stages = props.segments.map((segment) =>
|
|
59
|
+
Array.isArray(segment)
|
|
60
|
+
? { stageName: undefined, segments: segment }
|
|
61
|
+
: isSegment(segment)
|
|
62
|
+
? { stageName: undefined, segments: [segment] }
|
|
63
|
+
: segment,
|
|
55
64
|
);
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
stages.forEach((stage) => {
|
|
67
|
+
stage.segments.forEach((segment) => {
|
|
59
68
|
segment.inputs.forEach((artifact) => {
|
|
60
69
|
if (!artifact.producer) {
|
|
61
70
|
throw new Error("Artifact consumed but never produced.");
|
|
@@ -64,22 +73,28 @@ export class Pipeline extends Stack {
|
|
|
64
73
|
});
|
|
65
74
|
});
|
|
66
75
|
|
|
67
|
-
if (
|
|
76
|
+
if (
|
|
77
|
+
stages[0].segments.filter(isSource).length !== stages[0].segments.length
|
|
78
|
+
) {
|
|
68
79
|
throw new Error("First segment must contain only source segments");
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
if (
|
|
82
|
+
if (
|
|
83
|
+
stages.slice(1).find((stage) => stage.segments.filter(isSource).length)
|
|
84
|
+
) {
|
|
72
85
|
throw new Error("Only the first segment can contain source segments");
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
if (
|
|
76
|
-
|
|
77
|
-
|
|
89
|
+
stages[1].segments.length !== 1 ||
|
|
90
|
+
stages[1].segments.filter(isPipeline).length !== stages[1].segments.length
|
|
78
91
|
) {
|
|
79
92
|
throw new Error("Second segment must be the pipeline segment");
|
|
80
93
|
}
|
|
81
94
|
|
|
82
|
-
if (
|
|
95
|
+
if (
|
|
96
|
+
stages.slice(2).find((stage) => stage.segments.filter(isPipeline).length)
|
|
97
|
+
) {
|
|
83
98
|
throw new Error("Only the second segment can be the pipeline segment");
|
|
84
99
|
}
|
|
85
100
|
|
|
@@ -89,9 +104,9 @@ export class Pipeline extends Stack {
|
|
|
89
104
|
pipelineType: PipelineType.V2,
|
|
90
105
|
stages: [
|
|
91
106
|
{
|
|
92
|
-
stageName: "Source",
|
|
107
|
+
stageName: stages[0].stageName || "Source",
|
|
93
108
|
actions: [
|
|
94
|
-
...
|
|
109
|
+
...stages[0].segments.reduce(
|
|
95
110
|
(actions, segment) => [
|
|
96
111
|
...actions,
|
|
97
112
|
...segment.construct(this).actions,
|
|
@@ -101,9 +116,9 @@ export class Pipeline extends Stack {
|
|
|
101
116
|
],
|
|
102
117
|
},
|
|
103
118
|
{
|
|
104
|
-
stageName: "Pipeline",
|
|
119
|
+
stageName: stages[1].stageName || "Pipeline",
|
|
105
120
|
actions: [
|
|
106
|
-
...
|
|
121
|
+
...stages[1].segments.reduce(
|
|
107
122
|
(actions, segment) => [
|
|
108
123
|
...actions,
|
|
109
124
|
...segment.construct(this).actions,
|
|
@@ -112,13 +127,14 @@ export class Pipeline extends Stack {
|
|
|
112
127
|
),
|
|
113
128
|
],
|
|
114
129
|
},
|
|
115
|
-
...
|
|
116
|
-
const builds =
|
|
130
|
+
...stages.slice(2).map((stage) => {
|
|
131
|
+
const builds = stage.segments.reduce(
|
|
117
132
|
(segments, segment) => [...segments, segment.construct(this)],
|
|
118
133
|
[] as SegmentConstructed[],
|
|
119
134
|
);
|
|
120
135
|
return {
|
|
121
|
-
stageName:
|
|
136
|
+
stageName:
|
|
137
|
+
stage.stageName || builds.map((build) => build.name).join("-"),
|
|
122
138
|
actions: builds.reduce(
|
|
123
139
|
(actions, build) => [...actions, ...build.actions],
|
|
124
140
|
[] as IAction[],
|
package/src/segment.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface SegmentProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export abstract class Segment {
|
|
14
|
+
readonly isSegment: boolean = true;
|
|
14
15
|
readonly isSource: boolean = false;
|
|
15
16
|
readonly isPipeline: boolean = false;
|
|
16
17
|
readonly dependencies?: Stack[];
|
|
@@ -35,3 +36,7 @@ export abstract class SegmentConstructed extends Construct {
|
|
|
35
36
|
readonly name: string = "";
|
|
36
37
|
readonly actions: IAction[] = [];
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
export function isSegment(item: any): item is Segment {
|
|
41
|
+
return item.isSegment;
|
|
42
|
+
}
|