1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const automation_client_1 = require("@atomist/automation-client");
|
19 | const sdm_pack_node_1 = require("@atomist/sdm-pack-node");
|
20 | const sdm_pack_spring_1 = require("@atomist/sdm-pack-spring");
|
21 | const CloudFoundryTarget_1 = require("../api/CloudFoundryTarget");
|
22 | exports.AddCloudFoundryManifestMarker = "[atomist:add-pcf-manifest]";
|
23 |
|
24 | exports.AtomistGeneratedMarker = "[atomist:generated]";
|
25 | exports.AtomistConfigTsPath = "src/atomist.config.ts";
|
26 |
|
27 | exports.addCloudFoundryManifestTransform = async (p, ctx) => {
|
28 | const javaId = await sdm_pack_spring_1.MavenProjectIdentifier(p);
|
29 | if (javaId && await sdm_pack_spring_1.HasSpringBootPom.predicate(p)) {
|
30 | return p.addFile(CloudFoundryTarget_1.CloudFoundryManifestPath, javaManifestFor(javaId.artifact, ctx.context.workspaceId));
|
31 | }
|
32 | const nodeId = await sdm_pack_node_1.NodeProjectIdentifier(p);
|
33 | if (nodeId) {
|
34 | const isAutomationClient = !!await p.getFile(exports.AtomistConfigTsPath);
|
35 | automation_client_1.logger.info(`addCloudFoundryManifestEditor: Node project %j: automation client=${isAutomationClient}`, p.id);
|
36 | return p.addFile(CloudFoundryTarget_1.CloudFoundryManifestPath, isAutomationClient ?
|
37 | automationClientManifestFor(nodeId.name, ctx.context.workspaceId) :
|
38 | nodeManifestFor(nodeId.name, ctx.context.workspaceId))
|
39 | .then(() => p.addFile(".cfignore", "node_modules/"));
|
40 | }
|
41 | return ctx.context.messageClient.respond(`Unable to add Cloud Foundry manifest to project \`${p.id.owner}:${p.id.repo}\`: Neither Maven nor Node`);
|
42 | };
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | exports.AddCloudFoundryManifest = {
|
48 | transform: exports.addCloudFoundryManifestTransform,
|
49 | name: "AddCloudFoundryManifest",
|
50 | intent: "Add Cloud Foundry manifest",
|
51 | transformPresentation: () => new automation_client_1.editModes.PullRequest(`add-pcf-manifest-${Date.now()}`, "Add Cloud Foundry manifest", `This will trigger the Software Development Machine to deploy to your Cloud Foundry space.
|
52 |
|
53 | ${exports.AtomistGeneratedMarker}`, `Add Cloud Foundry manifest
|
54 |
|
55 | ${exports.AddCloudFoundryManifestMarker}`),
|
56 | };
|
57 |
|
58 | const javaManifestFor = (name, teamId) => `---
|
59 | applications:
|
60 | - name: "${name}"
|
61 | memory: 1024M
|
62 | instances: 1
|
63 | buildpack: https://github.com/cloudfoundry/java-buildpack.git
|
64 | env:
|
65 | ATOMIST_TEAM: ${teamId}`;
|
66 | const nodeManifestFor = (name, teamId) => `---
|
67 | applications:
|
68 | - name: "${name}"
|
69 | memory: 512M
|
70 | instances: 1
|
71 | buildpack: https://github.com/cloudfoundry/nodejs-buildpack
|
72 | env:
|
73 | ATOMIST_TEAMS: ${teamId}`;
|
74 |
|
75 | exports.StartAutomationClientCommand = "node --trace-warnings --expose_gc --optimize_for_size --always_compact --max_old_space_size=384 node_modules/@atomist/automation-client/start.client.js";
|
76 |
|
77 |
|
78 |
|
79 | const automationClientManifestFor = (name, teamId) => `---
|
80 | applications:
|
81 | - name: ${name}
|
82 | command: "${exports.StartAutomationClientCommand}"
|
83 | memory: 512M
|
84 | buildpack: https://github.com/cloudfoundry/nodejs-buildpack
|
85 | env:
|
86 | SUPPRESS_NO_CONFIG_WARNING: true
|
87 | ATOMIST_TEAMS: ${teamId}`;
|
88 |
|
\ | No newline at end of file |