@sap-ux/adp-tooling 0.18.113 → 0.18.114

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.
@@ -26,8 +26,8 @@ async function isLoggedInCf(cfConfig, logger) {
26
26
  return false;
27
27
  }
28
28
  try {
29
- const orgs = await (0, cf_tools_1.cfGetAvailableOrgs)();
30
- logger?.log(`Available organizations: ${JSON.stringify(orgs)}`);
29
+ const token = await (0, cf_tools_1.cfGetAuthToken)();
30
+ logger?.log(`Retrieved CF auth token: ${token}`);
31
31
  return true;
32
32
  }
33
33
  catch (e) {
@@ -0,0 +1,48 @@
1
+ import type { CfConfig, CfDeploymentInfo, DeployCfOptions } from '../types';
2
+ import type { ToolsLogger } from '@sap-ux/logger';
3
+ /**
4
+ * Gathers MTA project and CF environment information needed for deployment.
5
+ *
6
+ * @param {string} projectPath - Path to the MTA project root (containing mta.yaml).
7
+ * @param {CfConfig} cfConfig - The CF configuration.
8
+ * @returns {CfDeploymentInfo} Deployment information for the MTA project.
9
+ */
10
+ export declare function getCfDeploymentInfo(projectPath: string, cfConfig: CfConfig): CfDeploymentInfo;
11
+ /**
12
+ * Formats the deployment summary for console output.
13
+ *
14
+ * @param {CfDeploymentInfo} info - The deployment information to format.
15
+ * @returns {string} Formatted summary string ready for display.
16
+ */
17
+ export declare function formatDeploymentSummary(info: CfDeploymentInfo): string;
18
+ /**
19
+ * Finds the MTA project root by recursively searching the given path and its ancestors for mta.yaml.
20
+ *
21
+ * @param {string} projectPath - The starting project path.
22
+ * @returns {Promise<string | undefined>} The MTA root path, or undefined if not found.
23
+ */
24
+ export declare function findMtaRoot(projectPath: string): Promise<string | undefined>;
25
+ /**
26
+ * Builds the MTA archive by running the project's build-mta npm script.
27
+ *
28
+ * @param {string} projectPath - Path to the ADP project root.
29
+ * @param {ToolsLogger} logger - Logger instance.
30
+ */
31
+ export declare function buildMtaArchive(projectPath: string, logger: ToolsLogger): Promise<void>;
32
+ /**
33
+ * Deploys the MTA archive to Cloud Foundry by running the project's deploy npm script.
34
+ *
35
+ * @param {string} projectPath - Path to the ADP project root.
36
+ * @param {ToolsLogger} logger - Logger instance.
37
+ */
38
+ export declare function deployMtaArchive(projectPath: string, logger: ToolsLogger): Promise<void>;
39
+ /**
40
+ * Deploys a CF ADP project by building the MTA archive and deploying it to Cloud Foundry.
41
+ *
42
+ * @param {string} projectPath - Path to the ADP project root.
43
+ * @param {ToolsLogger} logger - Logger instance.
44
+ * @param {DeployCfOptions} [options] - Deployment options (confirmation callback, output callback).
45
+ * @returns {Promise<void>} Resolves when deployment completes.
46
+ */
47
+ export declare function deployCf(projectPath: string, logger: ToolsLogger, options?: DeployCfOptions): Promise<void>;
48
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCfDeploymentInfo = getCfDeploymentInfo;
7
+ exports.formatDeploymentSummary = formatDeploymentSummary;
8
+ exports.findMtaRoot = findMtaRoot;
9
+ exports.buildMtaArchive = buildMtaArchive;
10
+ exports.deployMtaArchive = deployMtaArchive;
11
+ exports.deployCf = deployCf;
12
+ const node_path_1 = __importDefault(require("node:path"));
13
+ const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
14
+ const project_access_1 = require("@sap-ux/project-access");
15
+ const cli_1 = require("./services/cli");
16
+ const auth_1 = require("./core/auth");
17
+ const config_1 = require("./core/config");
18
+ const yaml_loader_1 = require("./project/yaml-loader");
19
+ const i18n_1 = require("../i18n");
20
+ const SEPARATOR = '------------------------------------';
21
+ /**
22
+ * Gathers MTA project and CF environment information needed for deployment.
23
+ *
24
+ * @param {string} projectPath - Path to the MTA project root (containing mta.yaml).
25
+ * @param {CfConfig} cfConfig - The CF configuration.
26
+ * @returns {CfDeploymentInfo} Deployment information for the MTA project.
27
+ */
28
+ function getCfDeploymentInfo(projectPath, cfConfig) {
29
+ const mtaYamlPath = node_path_1.default.join(projectPath, 'mta.yaml');
30
+ const mtaYaml = (0, yaml_loader_1.getYamlContent)(mtaYamlPath);
31
+ return {
32
+ mtaProjectName: mtaYaml.ID ?? '',
33
+ mtaVersion: mtaYaml.version ?? '',
34
+ space: cfConfig.space?.Name ?? '',
35
+ org: cfConfig.org?.Name ?? '',
36
+ apiUrl: cfConfig.url ?? '',
37
+ mtaRoot: projectPath,
38
+ modules: mtaYaml.modules?.map((m) => ({
39
+ name: m.name,
40
+ type: m.type,
41
+ path: m.path
42
+ })) ?? []
43
+ };
44
+ }
45
+ /**
46
+ * Formats the deployment summary for console output.
47
+ *
48
+ * @param {CfDeploymentInfo} info - The deployment information to format.
49
+ * @returns {string} Formatted summary string ready for display.
50
+ */
51
+ function formatDeploymentSummary(info) {
52
+ const lines = [];
53
+ lines.push(`mta-project-name: ${info.mtaProjectName}`, `mta-version: ${info.mtaVersion}`, `space: ${info.space}`, `org: ${info.org}`, `api-url: ${info.apiUrl}`);
54
+ for (const mod of info.modules) {
55
+ lines.push(SEPARATOR, `project name: ${mod.name}`, `type: ${mod.type}`);
56
+ if (mod.path) {
57
+ lines.push(`path: ${mod.path}`);
58
+ }
59
+ }
60
+ lines.push('', (0, i18n_1.t)('deploy.confirmPrompt'));
61
+ return lines.join('\n');
62
+ }
63
+ /**
64
+ * Finds the MTA project root by recursively searching the given path and its ancestors for mta.yaml.
65
+ *
66
+ * @param {string} projectPath - The starting project path.
67
+ * @returns {Promise<string | undefined>} The MTA root path, or undefined if not found.
68
+ */
69
+ async function findMtaRoot(projectPath) {
70
+ const result = await (0, project_access_1.getMtaPath)(projectPath);
71
+ return result ? node_path_1.default.dirname(result.mtaPath) : undefined;
72
+ }
73
+ /**
74
+ * Validates the CF environment: checks CF CLI is installed, user is logged in, and locates the MTA root.
75
+ *
76
+ * @param {string} projectPath - Path to the ADP project root.
77
+ * @param {ToolsLogger} logger - Logger instance.
78
+ * @returns {Promise<{ cfConfig: CfConfig; mtaRoot: string }>} The validated CF config and MTA root path.
79
+ */
80
+ async function validateCfEnvironment(projectPath, logger) {
81
+ const cfInstalled = await (0, cli_1.isCfInstalled)(logger);
82
+ if (!cfInstalled) {
83
+ throw new Error((0, i18n_1.t)('deploy.cfNotInstalled'));
84
+ }
85
+ const cfConfig = (0, config_1.loadCfConfig)(logger);
86
+ const loggedIn = await (0, auth_1.isLoggedInCf)(cfConfig, logger);
87
+ if (!loggedIn) {
88
+ throw new Error((0, i18n_1.t)('deploy.notLoggedIn'));
89
+ }
90
+ const mtaRoot = await findMtaRoot(projectPath);
91
+ if (!mtaRoot) {
92
+ throw new Error((0, i18n_1.t)('deploy.mtaNotFound', { projectPath }));
93
+ }
94
+ return { cfConfig, mtaRoot };
95
+ }
96
+ /**
97
+ * Builds the MTA archive by running the project's build-mta npm script.
98
+ *
99
+ * @param {string} projectPath - Path to the ADP project root.
100
+ * @param {ToolsLogger} logger - Logger instance.
101
+ */
102
+ async function buildMtaArchive(projectPath, logger) {
103
+ const commandRunner = new nodejs_utils_1.CommandRunner();
104
+ try {
105
+ await commandRunner.run('npm', ['run', 'build-mta'], { cwd: projectPath }, logger);
106
+ }
107
+ catch (e) {
108
+ throw new Error((0, i18n_1.t)('deploy.buildFailed', { error: String(e) }));
109
+ }
110
+ }
111
+ /**
112
+ * Deploys the MTA archive to Cloud Foundry by running the project's deploy npm script.
113
+ *
114
+ * @param {string} projectPath - Path to the ADP project root.
115
+ * @param {ToolsLogger} logger - Logger instance.
116
+ */
117
+ async function deployMtaArchive(projectPath, logger) {
118
+ const commandRunner = new nodejs_utils_1.CommandRunner();
119
+ try {
120
+ await commandRunner.run('npm', ['run', 'deploy'], { cwd: projectPath }, logger);
121
+ }
122
+ catch (e) {
123
+ throw new Error((0, i18n_1.t)('deploy.deployFailed', { error: String(e) }));
124
+ }
125
+ }
126
+ /**
127
+ * Deploys a CF ADP project by building the MTA archive and deploying it to Cloud Foundry.
128
+ *
129
+ * @param {string} projectPath - Path to the ADP project root.
130
+ * @param {ToolsLogger} logger - Logger instance.
131
+ * @param {DeployCfOptions} [options] - Deployment options (confirmation callback, output callback).
132
+ * @returns {Promise<void>} Resolves when deployment completes.
133
+ */
134
+ async function deployCf(projectPath, logger, options = {}) {
135
+ const { cfConfig, mtaRoot } = await validateCfEnvironment(projectPath, logger);
136
+ const info = getCfDeploymentInfo(mtaRoot, cfConfig);
137
+ const summary = formatDeploymentSummary(info);
138
+ const output = options.onOutput ?? ((data) => logger.info(data));
139
+ output(summary);
140
+ if (options.confirmDeployment) {
141
+ const confirmed = await options.confirmDeployment(summary);
142
+ if (!confirmed) {
143
+ logger.info((0, i18n_1.t)('deploy.cancelled'));
144
+ return;
145
+ }
146
+ }
147
+ logger.info((0, i18n_1.t)('deploy.buildStarted'));
148
+ await buildMtaArchive(projectPath, logger);
149
+ logger.info((0, i18n_1.t)('deploy.deployStarted'));
150
+ await deployMtaArchive(projectPath, logger);
151
+ logger.info((0, i18n_1.t)('deploy.success'));
152
+ }
153
+ //# sourceMappingURL=deploy.js.map
@@ -1,3 +1,4 @@
1
+ export * from './deploy';
1
2
  export * from './project';
2
3
  export * from './app';
3
4
  export * from './core';
package/dist/cf/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./deploy"), exports);
17
18
  __exportStar(require("./project"), exports);
18
19
  __exportStar(require("./app"), exports);
19
20
  __exportStar(require("./core"), exports);
@@ -126,5 +126,17 @@
126
126
  "selectFromWorkspace": "Select annotation file from workspace",
127
127
  "createTemplateFile": "Create local annotation file from template"
128
128
  }
129
+ },
130
+ "deploy": {
131
+ "cfNotInstalled": "The Cloud Foundary CLI is not installed. Please install it and try again.",
132
+ "notLoggedIn": "Not logged in to Cloud Foundry. Please log in with 'cf login' and try again.",
133
+ "mtaNotFound": "No mta.yaml file was found at the {{projectPath}} project path. Ensure this is a valid MTA project.",
134
+ "confirmPrompt": "This action deploys all listed projects. Confirm (Y/N)?",
135
+ "cancelled": "Deployment cancelled by user.",
136
+ "buildStarted": "Starting MTA build...",
137
+ "buildFailed": "MTA build failed: {{error}}",
138
+ "deployStarted": "Starting Cloud Foundry deployment...",
139
+ "deployFailed": "Cloud Foundry deployment failed: {{error}}",
140
+ "success": "Deployment completed successfully."
129
141
  }
130
142
  }
package/dist/types.d.ts CHANGED
@@ -1261,5 +1261,28 @@ export interface CfServiceOffering {
1261
1261
  };
1262
1262
  [key: string]: unknown;
1263
1263
  }
1264
+ /**
1265
+ * Information about the MTA project and its modules for CF deployment.
1266
+ */
1267
+ export interface CfDeploymentInfo {
1268
+ mtaProjectName: string;
1269
+ mtaVersion: string;
1270
+ space: string;
1271
+ org: string;
1272
+ apiUrl: string;
1273
+ mtaRoot: string;
1274
+ modules: Array<{
1275
+ name: string;
1276
+ type: string;
1277
+ path?: string;
1278
+ }>;
1279
+ }
1280
+ /**
1281
+ * Options for the CF deployment command.
1282
+ */
1283
+ export interface DeployCfOptions {
1284
+ confirmDeployment?: (summary: string) => Promise<boolean>;
1285
+ onOutput?: (data: string) => void;
1286
+ }
1264
1287
  export {};
1265
1288
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.18.113",
12
+ "version": "0.18.114",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -41,8 +41,8 @@
41
41
  "@sap-ux/i18n": "0.3.10",
42
42
  "@sap-ux/inquirer-common": "0.11.34",
43
43
  "@sap-ux/logger": "0.8.5",
44
- "@sap-ux/nodejs-utils": "0.2.19",
45
44
  "@sap-ux/odata-service-writer": "0.31.6",
45
+ "@sap-ux/nodejs-utils": "0.2.19",
46
46
  "@sap-ux/project-access": "1.35.19",
47
47
  "@sap-ux/project-input-validator": "0.6.75",
48
48
  "@sap-ux/store": "1.5.13",