@sap-ux/cap-config-writer 0.2.39 → 0.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/README.md +75 -0
- package/dist/cap-config/index.d.ts +13 -0
- package/dist/cap-config/index.js +10 -3
- package/dist/cap-config/package-json.d.ts +1 -0
- package/dist/cap-config/package-json.js +5 -5
- package/dist/cap-config/types.d.ts +4 -0
- package/dist/cap-writer/index.d.ts +4 -0
- package/dist/cap-writer/index.js +12 -0
- package/dist/cap-writer/package-json.d.ts +38 -0
- package/dist/cap-writer/package-json.js +165 -0
- package/dist/cap-writer/pom-xml.d.ts +12 -0
- package/dist/cap-writer/pom-xml.js +88 -0
- package/dist/cap-writer/tsconfig-and-yaml.d.ts +21 -0
- package/dist/cap-writer/tsconfig-and-yaml.js +72 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/i18n.js +52 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15 -0
- package/dist/translations/cap-config-writer.i18n.json +12 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -21,7 +21,82 @@ const fs = await enableCdsUi5Plugin('path/to/cap-project');
|
|
|
21
21
|
fs.commit();
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
### updatePomXml
|
|
27
|
+
This utility function updates the pom.xml file for Java-based CAP projects. The function reads the contents of the pom.xml file specified by pomPath, parses it, and searches for the spring-boot-maven-plugin configuration. If found, it adds certain workspace elements to it and writes back the updated pom.xml.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { updatePomXml } from '@sap-ux/cap-config-writer';
|
|
31
|
+
|
|
32
|
+
// Usage example
|
|
33
|
+
const fsMock: Editor = {}; // mem-fs file editor
|
|
34
|
+
const pomPath: string = 'path/to/pom.xml';
|
|
35
|
+
const logger: Logger = {}; // logger instance from @sap-ux/logger
|
|
36
|
+
|
|
37
|
+
updatePomXml(fsMock, pomPath, logger);
|
|
38
|
+
```
|
|
39
|
+
### updateTsConfig
|
|
40
|
+
The function constructs the path to the tsconfig.json file based on the provided appRoot. If the file exists, it reads its contents and checks if the typeRoots property is defined in the compilerOptions. The function extends the tsconfig.json file with the modified compilerOptions.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { updateTsConfig } from '@sap-ux/cap-config-writer';
|
|
44
|
+
|
|
45
|
+
// Usage example
|
|
46
|
+
const fsMock: Editor = {}; // mem-fs file editor
|
|
47
|
+
const appRoot: string = 'path/to/your/app'; // The root directory of the application
|
|
48
|
+
|
|
49
|
+
updateTsConfig(fsMock, appRoot);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### updateStaticLocationsInApplicationYaml
|
|
53
|
+
The function reads the contents of the application YAML file specified by applicationYamlPath, parses it, and checks if the static resource locations are already defined. If not, it adds the custom paths specified by capCustomPathsApp to the web.resources.static-locations property.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { updateStaticLocationsInApplicationYaml } from '@sap-ux/cap-config-writer';
|
|
57
|
+
|
|
58
|
+
// Usage example
|
|
59
|
+
const fsMock: Editor = {}; // mem-fs file editor
|
|
60
|
+
const applicationYamlPath: string = 'path/to/application.yaml';
|
|
61
|
+
const capCustomPathsApp: string = 'path/to/static/resources'; // Custom paths for CAP application
|
|
62
|
+
const logger: Logger = {}; // logger instance from @sap-ux/logger
|
|
63
|
+
|
|
64
|
+
await updateStaticLocationsInApplicationYaml(fsMock, applicationYamlPath, capCustomPathsApp, logger);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### updateRootPackageJson
|
|
68
|
+
Updates the package.json file of a CAP project app based on project requirements such as enableNPMWorkspaces
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { updateRootPackageJson } from '@sap-ux/cap-config-writer';
|
|
72
|
+
|
|
73
|
+
// Usage example
|
|
74
|
+
const fsMock: Editor = {}; // mem-fs file editor
|
|
75
|
+
const projectName: string = 'your-project-name';
|
|
76
|
+
const sapux: boolean = true; // Whether to add the app name to the sapux array
|
|
77
|
+
const capService: CapService = {}; // CAP service instance
|
|
78
|
+
const appId: string = 'your-app-id';
|
|
79
|
+
const log: Logger = {}; //// mem-fs file editor
|
|
80
|
+
const enableNPMWorkspaces: boolean = true; // npm workspaces (optional)
|
|
81
|
+
|
|
82
|
+
await updateRootPackageJson(fsMock, projectName, sapux, capService, appId, log, enableNPMWorkspaces);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### updateAppPackageJsonCAP
|
|
86
|
+
The function constructs the path to the package.json file based on the provided appRoot. It then reads the contents of the package.json file and removes the sapux property, the int-test script, and any scripts starting with 'start' that are not required for the app.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { updateAppPackageJson } from '@sap-ux/cap-config-writer';
|
|
90
|
+
|
|
91
|
+
// Usage example
|
|
92
|
+
const fsMock: Editor = {}; // mem-fs file editor
|
|
93
|
+
const appRoot: string = 'path/to/your/app'; // The root directory of the application
|
|
94
|
+
|
|
95
|
+
updateAppPackageJson(fsMock, appRoot);
|
|
96
|
+
```
|
|
97
|
+
|
|
24
98
|
## Keywords
|
|
25
99
|
SAP Fiori elements
|
|
26
100
|
SAP CAP
|
|
101
|
+
SAP CAP writer
|
|
27
102
|
SAP UI5
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { CdsVersionInfo } from '@sap-ux/project-access';
|
|
3
|
+
import { minCdsVersion } from './package-json';
|
|
2
4
|
export { satisfiesMinCdsVersion } from './package-json';
|
|
3
5
|
import type { CdsUi5PluginInfo } from './types';
|
|
4
6
|
/**
|
|
@@ -27,4 +29,15 @@ export declare function checkCdsUi5PluginEnabled(basePath: string, fs?: Editor):
|
|
|
27
29
|
* @returns false if package.json is not found at specified path or {@link CdsUi5PluginInfo} with additional info
|
|
28
30
|
*/
|
|
29
31
|
export declare function checkCdsUi5PluginEnabled(basePath: string, fs?: Editor, moreInfo?: boolean): Promise<boolean | CdsUi5PluginInfo>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if cds-plugin-ui5 is enabled on a CAP project. Checks also all prerequisites, like minimum @sap/cds version.
|
|
34
|
+
*
|
|
35
|
+
* @param basePath - root path of the CAP project, where package.json is located
|
|
36
|
+
* @param [fs] - optional: the memfs editor instance
|
|
37
|
+
* @param [moreInfo] if true return an object specifying detailed info about the cds and workspace state
|
|
38
|
+
* @param {CdsVersionInfo} [cdsVersionInfo] - If provided will be used instead of parsing the package.json file to determine the cds version.
|
|
39
|
+
* @returns false if package.json is not found at specified path or {@link CdsUi5PluginInfo} with additional info
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkCdsUi5PluginEnabled(basePath: string, fs?: Editor, moreInfo?: boolean, cdsVersionInfo?: CdsVersionInfo): Promise<boolean | CdsUi5PluginInfo>;
|
|
42
|
+
export { minCdsVersion };
|
|
30
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cap-config/index.js
CHANGED
|
@@ -9,13 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.checkCdsUi5PluginEnabled = exports.enableCdsUi5Plugin = exports.satisfiesMinCdsVersion = void 0;
|
|
12
|
+
exports.minCdsVersion = exports.checkCdsUi5PluginEnabled = exports.enableCdsUi5Plugin = exports.satisfiesMinCdsVersion = void 0;
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const mem_fs_1 = require("mem-fs");
|
|
15
15
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
16
16
|
const package_json_1 = require("./package-json");
|
|
17
|
+
Object.defineProperty(exports, "minCdsVersion", { enumerable: true, get: function () { return package_json_1.minCdsVersion; } });
|
|
17
18
|
var package_json_2 = require("./package-json");
|
|
18
19
|
Object.defineProperty(exports, "satisfiesMinCdsVersion", { enumerable: true, get: function () { return package_json_2.satisfiesMinCdsVersion; } });
|
|
20
|
+
const semver_1 = require("semver");
|
|
19
21
|
/**
|
|
20
22
|
* Enable workspace and cds-plugin-ui5 for given CAP project.
|
|
21
23
|
*
|
|
@@ -40,15 +42,17 @@ function enableCdsUi5Plugin(basePath, fs) {
|
|
|
40
42
|
}
|
|
41
43
|
exports.enableCdsUi5Plugin = enableCdsUi5Plugin;
|
|
42
44
|
/**
|
|
45
|
+
* Implementation of the overloaded function.
|
|
43
46
|
* Check if cds-plugin-ui5 is enabled on a CAP project. Checks also all prerequisites, like minimum @sap/cds version.
|
|
44
47
|
*
|
|
45
48
|
* @param basePath - root path of the CAP project, where package.json is located
|
|
46
49
|
* @param [fs] - optional: the memfs editor instance
|
|
47
50
|
* @param [moreInfo] if true return an object specifying detailed info about the cds and workspace state
|
|
51
|
+
* @param {CdsVersionInfo} [cdsVersionInfo] - If provided will be used instead of parsing the package.json file to determine the cds version.
|
|
48
52
|
* @returns false if package.json is not found at specified path or {@link CdsUi5PluginInfo} with additional info or true if
|
|
49
53
|
* cds-plugin-ui5 and all prerequisites are fulfilled
|
|
50
54
|
*/
|
|
51
|
-
function checkCdsUi5PluginEnabled(basePath, fs, moreInfo
|
|
55
|
+
function checkCdsUi5PluginEnabled(basePath, fs, moreInfo, cdsVersionInfo) {
|
|
52
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
57
|
if (!fs) {
|
|
54
58
|
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
@@ -60,7 +64,10 @@ function checkCdsUi5PluginEnabled(basePath, fs, moreInfo = false) {
|
|
|
60
64
|
const packageJson = fs.readJSON(packageJsonPath);
|
|
61
65
|
const { workspaceEnabled } = yield (0, package_json_1.getWorkspaceInfo)(basePath, packageJson);
|
|
62
66
|
const cdsInfo = {
|
|
63
|
-
|
|
67
|
+
// Below line checks if 'cdsVersionInfo' is available and contains version information.
|
|
68
|
+
// If it does, it uses that version information to determine if it satisfies the minimum CDS version required.
|
|
69
|
+
// If 'cdsVersionInfo' is not available or does not contain version information,it falls back to check the version specified in the package.json file.
|
|
70
|
+
hasMinCdsVersion: (cdsVersionInfo === null || cdsVersionInfo === void 0 ? void 0 : cdsVersionInfo.version) ? (0, semver_1.satisfies)(cdsVersionInfo === null || cdsVersionInfo === void 0 ? void 0 : cdsVersionInfo.version, `>=${package_json_1.minCdsVersion}`) : (0, package_json_1.satisfiesMinCdsVersion)(packageJson),
|
|
64
71
|
isWorkspaceEnabled: workspaceEnabled,
|
|
65
72
|
hasCdsUi5Plugin: (0, package_json_1.hasCdsPluginUi5)(packageJson),
|
|
66
73
|
isCdsUi5PluginEnabled: false
|
|
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.hasCdsPluginUi5 = exports.getWorkspaceInfo = exports.satisfiesMinCdsVersion = exports.hasMinCdsVersion = exports.addCdsPluginUi5 = exports.enableWorkspaces = exports.ensureMinCdsVersion = void 0;
|
|
12
|
+
exports.hasCdsPluginUi5 = exports.getWorkspaceInfo = exports.satisfiesMinCdsVersion = exports.hasMinCdsVersion = exports.addCdsPluginUi5 = exports.enableWorkspaces = exports.ensureMinCdsVersion = exports.minCdsVersion = void 0;
|
|
13
13
|
const semver_1 = require("semver");
|
|
14
14
|
const project_access_1 = require("@sap-ux/project-access");
|
|
15
|
-
|
|
15
|
+
exports.minCdsVersion = '6.8.2';
|
|
16
16
|
const minCdsPluginUi5Version = '0.6.13';
|
|
17
17
|
/**
|
|
18
18
|
* Ensure a minimum version of @sap/cds in dependencies.
|
|
@@ -23,7 +23,7 @@ function ensureMinCdsVersion(packageJson) {
|
|
|
23
23
|
var _a;
|
|
24
24
|
if (!hasMinCdsVersion(packageJson)) {
|
|
25
25
|
(_a = packageJson.dependencies) !== null && _a !== void 0 ? _a : (packageJson.dependencies = {});
|
|
26
|
-
packageJson.dependencies['@sap/cds'] = `^${minCdsVersion}`;
|
|
26
|
+
packageJson.dependencies['@sap/cds'] = `^${exports.minCdsVersion}`;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.ensureMinCdsVersion = ensureMinCdsVersion;
|
|
@@ -77,7 +77,7 @@ exports.addCdsPluginUi5 = addCdsPluginUi5;
|
|
|
77
77
|
*/
|
|
78
78
|
function hasMinCdsVersion(packageJson) {
|
|
79
79
|
var _a, _b;
|
|
80
|
-
return (0, semver_1.gte)((_b = (0, semver_1.coerce)((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['@sap/cds'])) !== null && _b !== void 0 ? _b : '0.0.0', minCdsVersion);
|
|
80
|
+
return (0, semver_1.gte)((_b = (0, semver_1.coerce)((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['@sap/cds'])) !== null && _b !== void 0 ? _b : '0.0.0', exports.minCdsVersion);
|
|
81
81
|
}
|
|
82
82
|
exports.hasMinCdsVersion = hasMinCdsVersion;
|
|
83
83
|
/**
|
|
@@ -88,7 +88,7 @@ exports.hasMinCdsVersion = hasMinCdsVersion;
|
|
|
88
88
|
*/
|
|
89
89
|
function satisfiesMinCdsVersion(packageJson) {
|
|
90
90
|
var _a, _b;
|
|
91
|
-
return hasMinCdsVersion(packageJson) || (0, semver_1.satisfies)(minCdsVersion, (_b = (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['@sap/cds']) !== null && _b !== void 0 ? _b : '0.0.0');
|
|
91
|
+
return hasMinCdsVersion(packageJson) || (0, semver_1.satisfies)(exports.minCdsVersion, (_b = (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['@sap/cds']) !== null && _b !== void 0 ? _b : '0.0.0');
|
|
92
92
|
}
|
|
93
93
|
exports.satisfiesMinCdsVersion = satisfiesMinCdsVersion;
|
|
94
94
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CapService } from '@sap-ux/odata-service-inquirer';
|
|
1
2
|
export type CdsUi5PluginInfo = {
|
|
2
3
|
/**
|
|
3
4
|
* Convienience property. The CDS UI5 plugin is considered enabled if `hasCdsUi5Plugin`, `hasMinCdsVersion`, `isWorkspaceEnabled` are all true.
|
|
@@ -16,4 +17,7 @@ export type CdsUi5PluginInfo = {
|
|
|
16
17
|
*/
|
|
17
18
|
hasCdsUi5Plugin: boolean;
|
|
18
19
|
};
|
|
20
|
+
export interface CapServiceCdsInfo extends CapService {
|
|
21
|
+
cdsUi5PluginInfo: CdsUi5PluginInfo;
|
|
22
|
+
}
|
|
19
23
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePomXml = exports.updateStaticLocationsInApplicationYaml = exports.updateTsConfig = exports.updateRootPackageJson = exports.updateAppPackageJson = void 0;
|
|
4
|
+
var package_json_1 = require("./package-json");
|
|
5
|
+
Object.defineProperty(exports, "updateAppPackageJson", { enumerable: true, get: function () { return package_json_1.updateAppPackageJson; } });
|
|
6
|
+
Object.defineProperty(exports, "updateRootPackageJson", { enumerable: true, get: function () { return package_json_1.updateRootPackageJson; } });
|
|
7
|
+
var tsconfig_and_yaml_1 = require("./tsconfig-and-yaml");
|
|
8
|
+
Object.defineProperty(exports, "updateTsConfig", { enumerable: true, get: function () { return tsconfig_and_yaml_1.updateTsConfig; } });
|
|
9
|
+
Object.defineProperty(exports, "updateStaticLocationsInApplicationYaml", { enumerable: true, get: function () { return tsconfig_and_yaml_1.updateStaticLocationsInApplicationYaml; } });
|
|
10
|
+
var pom_xml_1 = require("./pom-xml");
|
|
11
|
+
Object.defineProperty(exports, "updatePomXml", { enumerable: true, get: function () { return pom_xml_1.updatePomXml; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { CapServiceCdsInfo } from '../cap-config/types';
|
|
3
|
+
import type { Logger } from '@sap-ux/logger';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the CDS watch script for the CAP app.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} projectName - The project's name, which is the module name.
|
|
8
|
+
* @param {string} appId - The application's ID, including its namespace and the module name.
|
|
9
|
+
If appId is provided, it will be used to open the application instead of the project name. This option is available for use with npm workspaces.
|
|
10
|
+
* @returns {{ [x: string]: string }} The CDS watch script for the CAP app.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCDSWatchScript(projectName: string, appId?: string): {
|
|
13
|
+
[x: string]: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Updates the root package.json file of CAP projects with the following changes:
|
|
17
|
+
* 1) Adds the app name to the sapux array in the root package.json if sapux is enabled.
|
|
18
|
+
* 2) Adds the cds watch script to the root package.json if applicable.
|
|
19
|
+
*
|
|
20
|
+
* @param {Editor} fs - The file system editor.
|
|
21
|
+
* @param {string} projectName - The project's name, which is the module name.
|
|
22
|
+
* @param {boolean} sapux - Whether to add the app name to the sapux array.
|
|
23
|
+
* @param {CapServiceCdsInfo} capService - The CAP service instance.
|
|
24
|
+
* @param {string} appId - The application's ID, including its namespace and the module name.
|
|
25
|
+
* @param {Logger} [log] - The logger instance for logging warnings.
|
|
26
|
+
* @param {boolean} [enableNPMWorkspaces] - Whether to enable npm workspaces.
|
|
27
|
+
* @returns {Promise<void>} A Promise that resolves once the root package.json is updated.
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateRootPackageJson(fs: Editor, projectName: string, sapux: boolean, capService: CapServiceCdsInfo, appId: string, log?: Logger, enableNPMWorkspaces?: boolean): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Updates the package.json file of a CAP project app by removing the sapux property
|
|
32
|
+
* and start scripts, as well as the 'int-test' script.
|
|
33
|
+
*
|
|
34
|
+
* @param {Editor} fs The file system editor.
|
|
35
|
+
* @param {string} appRoot The root directory of the application.
|
|
36
|
+
*/
|
|
37
|
+
export declare function updateAppPackageJson(fs: Editor, appRoot: string): void;
|
|
38
|
+
//# sourceMappingURL=package-json.d.ts.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.updateAppPackageJson = exports.updateRootPackageJson = exports.getCDSWatchScript = void 0;
|
|
36
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
37
|
+
const path_1 = __importStar(require("path"));
|
|
38
|
+
const cap_config_1 = require("../cap-config");
|
|
39
|
+
const i18n_1 = require("../i18n");
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the CDS watch script for the CAP app.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} projectName - The project's name, which is the module name.
|
|
44
|
+
* @param {string} appId - The application's ID, including its namespace and the module name.
|
|
45
|
+
If appId is provided, it will be used to open the application instead of the project name. This option is available for use with npm workspaces.
|
|
46
|
+
* @returns {{ [x: string]: string }} The CDS watch script for the CAP app.
|
|
47
|
+
*/
|
|
48
|
+
function getCDSWatchScript(projectName, appId) {
|
|
49
|
+
const DisableCacheParam = 'sap-ui-xx-viewCache=false';
|
|
50
|
+
// projects by default are served base on the folder name in the app/ folder
|
|
51
|
+
const project = appId !== null && appId !== void 0 ? appId : projectName + '/webapp';
|
|
52
|
+
const watchScript = {
|
|
53
|
+
[`watch-${projectName}`]: `cds watch --open ${project}/index.html?${DisableCacheParam}${appId ? ' --livereload false' : ''}`
|
|
54
|
+
};
|
|
55
|
+
return watchScript;
|
|
56
|
+
}
|
|
57
|
+
exports.getCDSWatchScript = getCDSWatchScript;
|
|
58
|
+
/**
|
|
59
|
+
* Updates the scripts in the package json file with the provided scripts object.
|
|
60
|
+
*
|
|
61
|
+
* @param {Editor} fs - The file system editor.
|
|
62
|
+
* @param {string} packageJsonPath - The path to the package.json file.
|
|
63
|
+
* @param {Record<string, string>} scripts - The scripts to be added or updated in the package.json file.
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
function updatePackageJsonWithScripts(fs, packageJsonPath, scripts) {
|
|
67
|
+
fs.extendJSON(packageJsonPath, { scripts });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Updates the scripts in the package json file for a CAP project.
|
|
71
|
+
*
|
|
72
|
+
* @param {Editor} fs - The file system editor.
|
|
73
|
+
* @param {string} packageJsonPath - The path to the package.json file.
|
|
74
|
+
* @param {string} projectName - The project's name, which is the module name.
|
|
75
|
+
* @param {string} appId - The application's ID, including its namespace and the module name.
|
|
76
|
+
* @param {boolean} [enableNPMWorkspaces] - Whether to enable npm workspaces.
|
|
77
|
+
* @param {CapServiceCdsInfo} cdsUi5PluginInfo - cds Ui5 plugin info.
|
|
78
|
+
* @param {Logger} [log] - The logger instance for logging warnings.
|
|
79
|
+
* @returns {Promise<void>} A Promise that resolves once the scripts are updated.
|
|
80
|
+
*/
|
|
81
|
+
function updateScripts(fs, packageJsonPath, projectName, appId, enableNPMWorkspaces, cdsUi5PluginInfo, log) {
|
|
82
|
+
var _a;
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const packageJson = ((_a = fs.readJSON(packageJsonPath)) !== null && _a !== void 0 ? _a : {});
|
|
85
|
+
const hasNPMworkspaces = yield (0, cap_config_1.checkCdsUi5PluginEnabled)(packageJsonPath, fs);
|
|
86
|
+
// Determine whether to add cds watch scripts for the app based on the availability of minimum CDS version information.
|
|
87
|
+
// If 'cdsUi5PluginInfo' contains version information and it satisfies the minimum required CDS version,
|
|
88
|
+
// or if 'cdsUi5PluginInfo' is not available and the version specified in 'package.json' satisfies the minimum required version,
|
|
89
|
+
// then set 'addScripts' to true. Otherwise, set it to false.
|
|
90
|
+
const addScripts = (cdsUi5PluginInfo === null || cdsUi5PluginInfo === void 0 ? void 0 : cdsUi5PluginInfo.hasMinCdsVersion) ? cdsUi5PluginInfo.hasMinCdsVersion : (0, cap_config_1.satisfiesMinCdsVersion)(packageJson);
|
|
91
|
+
let cdsScript;
|
|
92
|
+
if (addScripts) {
|
|
93
|
+
if (enableNPMWorkspaces !== null && enableNPMWorkspaces !== void 0 ? enableNPMWorkspaces : hasNPMworkspaces) {
|
|
94
|
+
// If the project uses npm workspaces (and specifically cds-plugin-ui5 ) then the project is served using the appId
|
|
95
|
+
cdsScript = getCDSWatchScript(projectName, appId);
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
cdsScript = getCDSWatchScript(projectName);
|
|
99
|
+
updatePackageJsonWithScripts(fs, packageJsonPath, cdsScript);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
log === null || log === void 0 ? void 0 : log.warn((0, i18n_1.t)('warn.cdsDKNotInstalled', { minCdsVersion: cap_config_1.minCdsVersion }));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Updates the root package.json file of CAP projects with the following changes:
|
|
108
|
+
* 1) Adds the app name to the sapux array in the root package.json if sapux is enabled.
|
|
109
|
+
* 2) Adds the cds watch script to the root package.json if applicable.
|
|
110
|
+
*
|
|
111
|
+
* @param {Editor} fs - The file system editor.
|
|
112
|
+
* @param {string} projectName - The project's name, which is the module name.
|
|
113
|
+
* @param {boolean} sapux - Whether to add the app name to the sapux array.
|
|
114
|
+
* @param {CapServiceCdsInfo} capService - The CAP service instance.
|
|
115
|
+
* @param {string} appId - The application's ID, including its namespace and the module name.
|
|
116
|
+
* @param {Logger} [log] - The logger instance for logging warnings.
|
|
117
|
+
* @param {boolean} [enableNPMWorkspaces] - Whether to enable npm workspaces.
|
|
118
|
+
* @returns {Promise<void>} A Promise that resolves once the root package.json is updated.
|
|
119
|
+
*/
|
|
120
|
+
function updateRootPackageJson(fs, projectName, sapux, capService, appId, log, enableNPMWorkspaces) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const packageJsonPath = (0, path_1.join)(capService.projectPath, 'package.json');
|
|
124
|
+
const packageJson = ((_a = fs.readJSON(packageJsonPath)) !== null && _a !== void 0 ? _a : {});
|
|
125
|
+
const capNodeType = 'Node.js';
|
|
126
|
+
if (enableNPMWorkspaces && packageJson) {
|
|
127
|
+
yield (0, cap_config_1.enableCdsUi5Plugin)(capService.projectPath, fs);
|
|
128
|
+
}
|
|
129
|
+
if ((capService === null || capService === void 0 ? void 0 : capService.capType) === capNodeType) {
|
|
130
|
+
yield updateScripts(fs, packageJsonPath, projectName, appId, enableNPMWorkspaces, capService.cdsUi5PluginInfo, log);
|
|
131
|
+
}
|
|
132
|
+
if (sapux) {
|
|
133
|
+
const dirPath = (0, path_1.join)((_b = capService.appPath) !== null && _b !== void 0 ? _b : (yield (0, project_access_1.getCapCustomPaths)(capService.projectPath)).app, projectName);
|
|
134
|
+
// Converts a directory path to a POSIX-style path.
|
|
135
|
+
const capProjectPath = path_1.default.normalize(dirPath).split(/[\\/]/g).join(path_1.default.posix.sep);
|
|
136
|
+
const sapuxExt = Array.isArray(packageJson === null || packageJson === void 0 ? void 0 : packageJson.sapux) ? [...packageJson.sapux, capProjectPath] : [capProjectPath];
|
|
137
|
+
fs.extendJSON(packageJsonPath, { sapux: sapuxExt });
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
exports.updateRootPackageJson = updateRootPackageJson;
|
|
142
|
+
/**
|
|
143
|
+
* Updates the package.json file of a CAP project app by removing the sapux property
|
|
144
|
+
* and start scripts, as well as the 'int-test' script.
|
|
145
|
+
*
|
|
146
|
+
* @param {Editor} fs The file system editor.
|
|
147
|
+
* @param {string} appRoot The root directory of the application.
|
|
148
|
+
*/
|
|
149
|
+
function updateAppPackageJson(fs, appRoot) {
|
|
150
|
+
var _a;
|
|
151
|
+
const packageJsonPath = (0, path_1.join)(appRoot, 'package.json');
|
|
152
|
+
const packageJson = ((_a = fs.readJSON(packageJsonPath)) !== null && _a !== void 0 ? _a : {});
|
|
153
|
+
delete packageJson.sapux;
|
|
154
|
+
if (packageJson === null || packageJson === void 0 ? void 0 : packageJson.scripts) {
|
|
155
|
+
delete packageJson.scripts['int-test'];
|
|
156
|
+
}
|
|
157
|
+
for (const script in packageJson.scripts) {
|
|
158
|
+
if (script.startsWith('start')) {
|
|
159
|
+
delete packageJson.scripts[script];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
fs.writeJSON(packageJsonPath, packageJson);
|
|
163
|
+
}
|
|
164
|
+
exports.updateAppPackageJson = updateAppPackageJson;
|
|
165
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { Logger } from '@sap-ux/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the pom.xml file for Java-based CAP projects.
|
|
5
|
+
*
|
|
6
|
+
* @param {Editor} fs The file system editor instance.
|
|
7
|
+
* @param {string} pomPath The path to the pom.xml file.
|
|
8
|
+
* @param {Logger} [logger] The logger instance for logging errors.
|
|
9
|
+
* @returns {void}
|
|
10
|
+
*/
|
|
11
|
+
export declare function updatePomXml(fs: Editor, pomPath: string, logger?: Logger): void;
|
|
12
|
+
//# sourceMappingURL=pom-xml.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePomXml = void 0;
|
|
4
|
+
const xml_js_1 = require("xml-js");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the specified name exists in the array of elements.
|
|
7
|
+
*
|
|
8
|
+
* @param {Element[]} data The array of elements to search.
|
|
9
|
+
* @param {string} name The name to search for.
|
|
10
|
+
* @returns {boolean} Returns true if the name exists in the array, otherwise false.
|
|
11
|
+
*/
|
|
12
|
+
function checkIfNameExists(data, name) {
|
|
13
|
+
return data === null || data === void 0 ? void 0 : data.some((obj) => obj.name === name);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Adds a workspace element to the provided data if it doesn't already exist.
|
|
17
|
+
*
|
|
18
|
+
* @param {Element} data The data to which the workspace element should be added.
|
|
19
|
+
* @returns {boolean} Returns true if the workspace element was successfully added, otherwise false.
|
|
20
|
+
*/
|
|
21
|
+
function addWorkspaceElement(data) {
|
|
22
|
+
if (!(data === null || data === void 0 ? void 0 : data.elements) || checkIfNameExists(data.elements, 'workingDirectory')) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
data.elements.push({ type: 'element', name: 'workingDirectory', elements: [{ type: 'text', text: '..' }] });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reads the contents of the pom xml file and returns it as a string.
|
|
30
|
+
*
|
|
31
|
+
* @param {Editor} fs - The file system editor.
|
|
32
|
+
* @param {string} pomPath - The path to the pom.xml file.
|
|
33
|
+
* @returns {string} The contents of the pom.xml file as a string.
|
|
34
|
+
*/
|
|
35
|
+
function readPomXml(fs, pomPath) {
|
|
36
|
+
return fs.read(pomPath).toString();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Writes the provided XML structure to the pom xml file.
|
|
40
|
+
*
|
|
41
|
+
* @param {Editor} fs - The file system editor.
|
|
42
|
+
* @param {string} pomPath - The path to the pom.xml file.
|
|
43
|
+
* @param {ElementCompact} pomContentsJson - The XML structure to be written to the pom.xml file.
|
|
44
|
+
* @returns {void}
|
|
45
|
+
*/
|
|
46
|
+
function writePomXml(fs, pomPath, pomContentsJson) {
|
|
47
|
+
const pomXML = (0, xml_js_1.js2xml)(pomContentsJson, { compact: false, ignoreComment: false, spaces: 4 });
|
|
48
|
+
const ampersandReplace = /&gt/g; // Sanitize
|
|
49
|
+
fs.write(pomPath, pomXML.replace(ampersandReplace, '>'));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Updates the pom.xml file for Java-based CAP projects.
|
|
53
|
+
*
|
|
54
|
+
* @param {Editor} fs The file system editor instance.
|
|
55
|
+
* @param {string} pomPath The path to the pom.xml file.
|
|
56
|
+
* @param {Logger} [logger] The logger instance for logging errors.
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
function updatePomXml(fs, pomPath, logger) {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
61
|
+
try {
|
|
62
|
+
const pomContents = readPomXml(fs, pomPath);
|
|
63
|
+
const pomContentsJson = (0, xml_js_1.xml2js)(pomContents, { compact: false, ignoreComment: false });
|
|
64
|
+
const springBootMavenPlugin = 'spring-boot-maven-plugin';
|
|
65
|
+
if (Object.keys(pomContentsJson).length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// find the spring-boot-maven-plugin in the pom.xml
|
|
69
|
+
const pomPlugin = (_g = (_f = (_e = (_d = (_c = (_b = (_a = pomContentsJson.elements
|
|
70
|
+
.filter((element) => element.name === 'project')) === null || _a === void 0 ? void 0 : _a[0].elements.filter((element) => element.name === 'build')) === null || _b === void 0 ? void 0 : _b[0].elements.filter((element) => element.name === 'plugins')) === null || _c === void 0 ? void 0 : _c[0].elements.filter((element) => element.name === 'plugin')) === null || _d === void 0 ? void 0 : _d.filter((obj) => {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = obj === null || obj === void 0 ? void 0 : obj.elements) === null || _a === void 0 ? void 0 : _a.some((element) => {
|
|
73
|
+
var _a;
|
|
74
|
+
return element.name === 'artifactId' &&
|
|
75
|
+
((_a = element.elements) !== null && _a !== void 0 ? _a : []).some((element) => element.text === springBootMavenPlugin);
|
|
76
|
+
});
|
|
77
|
+
})) === null || _e === void 0 ? void 0 : _e[0].elements) === null || _f === void 0 ? void 0 : _f.filter((element) => element.name === 'configuration')) === null || _g === void 0 ? void 0 : _g[0];
|
|
78
|
+
if (pomPlugin) {
|
|
79
|
+
addWorkspaceElement(pomPlugin);
|
|
80
|
+
writePomXml(fs, pomPath, pomContentsJson);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
logger === null || logger === void 0 ? void 0 : logger.error(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.updatePomXml = updatePomXml;
|
|
88
|
+
//# sourceMappingURL=pom-xml.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { Logger } from '@sap-ux/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the tsconfig.json file to correct the type roots when node_modules
|
|
5
|
+
* are not found in the same directory as the application.
|
|
6
|
+
*
|
|
7
|
+
* @param {Editor} fs The file system editor.
|
|
8
|
+
* @param {string} appRoot The root directory of the application.
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateTsConfig(fs: Editor, appRoot: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Updates the application YAML file by adding static resource locations if not already present.
|
|
13
|
+
*
|
|
14
|
+
* @param {Editor} fs The file system editor instance.
|
|
15
|
+
* @param {string} applicationYamlPath The path to the application YAML file.
|
|
16
|
+
* @param {string} capCustomPathsApp The custom paths for CAP application.
|
|
17
|
+
* @param {Logger} [logger] The logger instance for logging errors.
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
export declare function updateStaticLocationsInApplicationYaml(fs: Editor, applicationYamlPath: string, capCustomPathsApp: string, logger?: Logger): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=tsconfig-and-yaml.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateStaticLocationsInApplicationYaml = exports.updateTsConfig = void 0;
|
|
13
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
14
|
+
const yaml_1 = require("@sap-ux/yaml");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const i18n_1 = require("../i18n");
|
|
17
|
+
/**
|
|
18
|
+
* Updates the tsconfig.json file to correct the type roots when node_modules
|
|
19
|
+
* are not found in the same directory as the application.
|
|
20
|
+
*
|
|
21
|
+
* @param {Editor} fs The file system editor.
|
|
22
|
+
* @param {string} appRoot The root directory of the application.
|
|
23
|
+
*/
|
|
24
|
+
function updateTsConfig(fs, appRoot) {
|
|
25
|
+
const tsConfigPath = (0, path_1.join)(appRoot, project_access_1.FileName.Tsconfig);
|
|
26
|
+
if (fs.exists(tsConfigPath)) {
|
|
27
|
+
const tsConfig = fs.readJSON(tsConfigPath);
|
|
28
|
+
if (tsConfig['compilerOptions']['typeRoots']) {
|
|
29
|
+
const typeRoots = tsConfig['compilerOptions']['typeRoots'];
|
|
30
|
+
const updatedTypeRoots = typeRoots.map((entry) => {
|
|
31
|
+
return entry.replace(/\.\//g, '../../');
|
|
32
|
+
});
|
|
33
|
+
// Update the tsconfig.json file
|
|
34
|
+
fs.extendJSON(tsConfigPath, {
|
|
35
|
+
compilerOptions: {
|
|
36
|
+
typeRoots: [...typeRoots, ...updatedTypeRoots]
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.updateTsConfig = updateTsConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Updates the application YAML file by adding static resource locations if not already present.
|
|
45
|
+
*
|
|
46
|
+
* @param {Editor} fs The file system editor instance.
|
|
47
|
+
* @param {string} applicationYamlPath The path to the application YAML file.
|
|
48
|
+
* @param {string} capCustomPathsApp The custom paths for CAP application.
|
|
49
|
+
* @param {Logger} [logger] The logger instance for logging errors.
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
function updateStaticLocationsInApplicationYaml(fs, applicationYamlPath, capCustomPathsApp, logger) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
try {
|
|
55
|
+
const applicationYamlDocuments = fs.read(applicationYamlPath).toString();
|
|
56
|
+
const yamlDoc = yield yaml_1.YamlDocument.newInstance(applicationYamlDocuments);
|
|
57
|
+
const stringifiedYaml = JSON.stringify(yamlDoc);
|
|
58
|
+
const parsedApplicationYamlDocuments = JSON.parse(stringifiedYaml).documents;
|
|
59
|
+
if (parsedApplicationYamlDocuments.length === 1 &&
|
|
60
|
+
parsedApplicationYamlDocuments[0].spring['web.resources.static-locations'] === undefined) {
|
|
61
|
+
const applicationYamlFirstDocument = parsedApplicationYamlDocuments[0];
|
|
62
|
+
applicationYamlFirstDocument.spring['web.resources.static-locations'] = `file:./${capCustomPathsApp}`;
|
|
63
|
+
fs.write(applicationYamlPath, (0, yaml_1.yamlDocumentToYamlString)(applicationYamlFirstDocument));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
logger === null || logger === void 0 ? void 0 : logger.error((0, i18n_1.t)('error.updateApplicationYaml', { error: error }));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.updateStaticLocationsInApplicationYaml = updateStaticLocationsInApplicationYaml;
|
|
72
|
+
//# sourceMappingURL=tsconfig-and-yaml.js.map
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TOptions } from 'i18next';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize i18next with the translations for this module.
|
|
4
|
+
*/
|
|
5
|
+
export declare function initI18n(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Helper function facading the call to i18next.
|
|
8
|
+
*
|
|
9
|
+
* @param key i18n key
|
|
10
|
+
* @param options additional options
|
|
11
|
+
* @returns {string} localized string stored for the given key
|
|
12
|
+
*/
|
|
13
|
+
export declare function t(key: string, options?: TOptions): string;
|
|
14
|
+
//# sourceMappingURL=i18n.d.ts.map
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.t = exports.initI18n = void 0;
|
|
16
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
17
|
+
const cap_config_writer_i18n_json_1 = __importDefault(require("./translations/cap-config-writer.i18n.json"));
|
|
18
|
+
const NS = 'cap-config-writer';
|
|
19
|
+
/**
|
|
20
|
+
* Initialize i18next with the translations for this module.
|
|
21
|
+
*/
|
|
22
|
+
function initI18n() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield i18next_1.default.init({
|
|
25
|
+
resources: {
|
|
26
|
+
en: {
|
|
27
|
+
[NS]: cap_config_writer_i18n_json_1.default
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
lng: 'en',
|
|
31
|
+
fallbackLng: 'en',
|
|
32
|
+
defaultNS: NS,
|
|
33
|
+
ns: [NS]
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.initI18n = initI18n;
|
|
38
|
+
/**
|
|
39
|
+
* Helper function facading the call to i18next.
|
|
40
|
+
*
|
|
41
|
+
* @param key i18n key
|
|
42
|
+
* @param options additional options
|
|
43
|
+
* @returns {string} localized string stored for the given key
|
|
44
|
+
*/
|
|
45
|
+
function t(key, options) {
|
|
46
|
+
return i18next_1.default.t(key, options);
|
|
47
|
+
}
|
|
48
|
+
exports.t = t;
|
|
49
|
+
initI18n().catch(() => {
|
|
50
|
+
// Ignore any errors since the write will still work
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { checkCdsUi5PluginEnabled, enableCdsUi5Plugin, satisfiesMinCdsVersion } from './cap-config';
|
|
2
|
-
export type { CdsUi5PluginInfo } from './cap-config/types';
|
|
2
|
+
export type { CdsUi5PluginInfo, CapServiceCdsInfo } from './cap-config/types';
|
|
3
|
+
export * from './cap-writer';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.satisfiesMinCdsVersion = exports.enableCdsUi5Plugin = exports.checkCdsUi5PluginEnabled = void 0;
|
|
4
18
|
var cap_config_1 = require("./cap-config");
|
|
5
19
|
Object.defineProperty(exports, "checkCdsUi5PluginEnabled", { enumerable: true, get: function () { return cap_config_1.checkCdsUi5PluginEnabled; } });
|
|
6
20
|
Object.defineProperty(exports, "enableCdsUi5Plugin", { enumerable: true, get: function () { return cap_config_1.enableCdsUi5Plugin; } });
|
|
7
21
|
Object.defineProperty(exports, "satisfiesMinCdsVersion", { enumerable: true, get: function () { return cap_config_1.satisfiesMinCdsVersion; } });
|
|
22
|
+
__exportStar(require("./cap-writer"), exports);
|
|
8
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"info": {
|
|
3
|
+
"capServiceName": "cap service name {{ capServiceName }}.",
|
|
4
|
+
"cdsUpdateInfo": "Update cds file with projectPath: {{ projectPath }}, annotationPath: {{ annotationPath }}, capService: {{ capService }}."
|
|
5
|
+
},
|
|
6
|
+
"warn": {
|
|
7
|
+
"cdsDKNotInstalled": "minimum cds-dk {{ minCdsVersion }} version is required to add cds watch scripts"
|
|
8
|
+
},
|
|
9
|
+
"error": {
|
|
10
|
+
"updateApplicationYaml": "Error occured while updating application yaml {{ error }}"
|
|
11
|
+
}
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/cap-config-writer",
|
|
3
3
|
"description": "Add or update configuration for SAP CAP projects",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -19,15 +19,20 @@
|
|
|
19
19
|
"!dist/**/*.map"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"i18next": "20.6.1",
|
|
22
23
|
"mem-fs": "2.1.0",
|
|
23
24
|
"mem-fs-editor": "9.4.0",
|
|
24
25
|
"semver": "7.5.4",
|
|
25
|
-
"@sap-ux/
|
|
26
|
+
"@sap-ux/logger": "0.5.1",
|
|
27
|
+
"@sap-ux/project-access": "1.21.1",
|
|
28
|
+
"@sap-ux/odata-service-inquirer": "0.2.1",
|
|
29
|
+
"@sap-ux/yaml": "0.15.0"
|
|
26
30
|
},
|
|
27
31
|
"devDependencies": {
|
|
28
32
|
"@types/mem-fs": "1.1.2",
|
|
29
33
|
"@types/mem-fs-editor": "7.0.1",
|
|
30
|
-
"@types/semver": "7.5.2"
|
|
34
|
+
"@types/semver": "7.5.2",
|
|
35
|
+
"xml-js": "1.6.11"
|
|
31
36
|
},
|
|
32
37
|
"engines": {
|
|
33
38
|
"node": ">=18.x"
|