1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import {
|
18 | AnyPush,
|
19 | DefaultGoalNameGenerator,
|
20 | FulfillableGoalDetails,
|
21 | FulfillableGoalWithRegistrations,
|
22 | getGoalDefinitionFrom,
|
23 | Goal,
|
24 | ImplementationRegistration,
|
25 | } from "@atomist/sdm";
|
26 | import {
|
27 | executeVersioner,
|
28 | ProjectVersioner,
|
29 | } from "../../internal/delivery/build/local/projectVersioner";
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | export interface ProjectVersionerRegistration extends Partial<ImplementationRegistration> {
|
35 | versioner: ProjectVersioner;
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | export class Version extends FulfillableGoalWithRegistrations<ProjectVersionerRegistration> {
|
42 |
|
43 | constructor(goalDetailsOrUniqueName: FulfillableGoalDetails | string = DefaultGoalNameGenerator.generateName("version"),
|
44 | ...dependsOn: Goal[]) {
|
45 |
|
46 | super({
|
47 | workingDescription: "Calculating project version",
|
48 | completedDescription: "Versioned",
|
49 | ...getGoalDefinitionFrom(goalDetailsOrUniqueName, DefaultGoalNameGenerator.generateName("version")),
|
50 | displayName: "version",
|
51 | }, ...dependsOn);
|
52 | }
|
53 |
|
54 | public with(registration: ProjectVersionerRegistration): this {
|
55 | this.addFulfillment({
|
56 | goalExecutor: executeVersioner(registration.versioner),
|
57 | name: DefaultGoalNameGenerator.generateName("versioner"),
|
58 | ...registration as ImplementationRegistration,
|
59 | });
|
60 | return this;
|
61 | }
|
62 |
|
63 | public withVersioner(versioner: ProjectVersioner): this {
|
64 | this.with({
|
65 | name: DefaultGoalNameGenerator.generateName("versioner"),
|
66 | pushTest: AnyPush,
|
67 | versioner,
|
68 | });
|
69 | return this;
|
70 | }
|
71 | }
|