@sap-ux/abap-deploy-config-writer 0.4.4 → 1.0.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/dist/config.js +7 -11
- package/dist/constants.js +11 -14
- package/dist/file.js +22 -33
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -31
- package/dist/scripts.d.ts +1 -1
- package/dist/scripts.js +11 -14
- package/dist/types.js +1 -2
- package/package.json +7 -6
package/dist/config.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.updateBaseConfig = updateBaseConfig;
|
|
4
|
-
exports.getDeployConfig = getDeployConfig;
|
|
5
|
-
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
6
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { UI5Config } from '@sap-ux/ui5-config';
|
|
2
|
+
import { UI5_TASK_FLATTEN_LIB } from './constants.js';
|
|
7
3
|
/**
|
|
8
4
|
* Updates the base config with the required custom tasks.
|
|
9
5
|
*
|
|
@@ -12,11 +8,11 @@ const constants_1 = require("./constants");
|
|
|
12
8
|
* @param baseConfig - the base config
|
|
13
9
|
* @param fs - the memfs editor instance
|
|
14
10
|
*/
|
|
15
|
-
function updateBaseConfig(isLib, basePath, baseConfig, fs) {
|
|
11
|
+
export function updateBaseConfig(isLib, basePath, baseConfig, fs) {
|
|
16
12
|
if (isLib) {
|
|
17
|
-
if (!baseConfig.findCustomTask(
|
|
13
|
+
if (!baseConfig.findCustomTask(UI5_TASK_FLATTEN_LIB)) {
|
|
18
14
|
const customTask = {
|
|
19
|
-
name:
|
|
15
|
+
name: UI5_TASK_FLATTEN_LIB,
|
|
20
16
|
afterTask: 'generateResourcesJson'
|
|
21
17
|
};
|
|
22
18
|
baseConfig.addCustomTasks([customTask]);
|
|
@@ -32,7 +28,7 @@ function updateBaseConfig(isLib, basePath, baseConfig, fs) {
|
|
|
32
28
|
* @param baseConfig - the base config
|
|
33
29
|
* @returns the deploy config
|
|
34
30
|
*/
|
|
35
|
-
async function getDeployConfig(config, baseConfig) {
|
|
31
|
+
export async function getDeployConfig(config, baseConfig) {
|
|
36
32
|
const target = {};
|
|
37
33
|
const comments = [];
|
|
38
34
|
if (config.target.destination !== undefined) {
|
|
@@ -59,7 +55,7 @@ async function getDeployConfig(config, baseConfig) {
|
|
|
59
55
|
});
|
|
60
56
|
}
|
|
61
57
|
const baseUi5Doc = baseConfig.removeConfig('server');
|
|
62
|
-
const ui5DeployConfig = await
|
|
58
|
+
const ui5DeployConfig = await UI5Config.newInstance(baseUi5Doc.toString());
|
|
63
59
|
ui5DeployConfig.addComment({
|
|
64
60
|
comment: ' yaml-language-server: $schema=https://sap.github.io/ui5-tooling/schema/ui5.yaml.json',
|
|
65
61
|
location: 'beginning'
|
package/dist/constants.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.UI5_REPO_IGNORE = '.Ui5RepositoryIgnore';
|
|
13
|
-
exports.UI5_CLI_LIB = '@ui5/cli';
|
|
14
|
-
exports.UI5_CLI_MIN_VERSION = '3.0.0';
|
|
1
|
+
export const BUILD_SCRIPT = 'npm run build';
|
|
2
|
+
export const DEPLOY_SCRIPT = 'fiori deploy';
|
|
3
|
+
export const UNDEPLOY_SCRIPT = 'fiori undeploy';
|
|
4
|
+
export const RIMRAF_VERSION = '^5.0.5';
|
|
5
|
+
export const RIMRAF = 'rimraf';
|
|
6
|
+
export const UI5_TASK_FLATTEN_LIB = 'ui5-task-flatten-library';
|
|
7
|
+
export const UI5_TASK_FLATTEN_LIB_VERSION = '^3.1.0';
|
|
8
|
+
export const UI5_REPO_TEXT_FILES = '.Ui5RepositoryTextFiles';
|
|
9
|
+
export const UI5_REPO_IGNORE = '.Ui5RepositoryIgnore';
|
|
10
|
+
export const UI5_CLI_LIB = '@ui5/cli';
|
|
11
|
+
export const UI5_CLI_MIN_VERSION = '3.0.0';
|
|
15
12
|
//# sourceMappingURL=constants.js.map
|
package/dist/file.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.addUi5Dependency = addUi5Dependency;
|
|
8
|
-
exports.getLibraryPath = getLibraryPath;
|
|
9
|
-
exports.writeUi5RepositoryFiles = writeUi5RepositoryFiles;
|
|
10
|
-
exports.writeUi5RepositoryIgnore = writeUi5RepositoryIgnore;
|
|
11
|
-
const node_path_1 = require("node:path");
|
|
12
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
13
|
-
const node_os_1 = require("node:os");
|
|
14
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
15
|
-
const constants_1 = require("./constants");
|
|
16
|
-
const semver_1 = require("semver");
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import fg from 'fast-glob';
|
|
3
|
+
import { platform } from 'node:os';
|
|
4
|
+
import { FileName, getReuseLibs } from '@sap-ux/project-access';
|
|
5
|
+
import { UI5_CLI_LIB, UI5_CLI_MIN_VERSION, UI5_REPO_IGNORE, UI5_REPO_TEXT_FILES } from './constants.js';
|
|
6
|
+
import { coerce, satisfies } from 'semver';
|
|
17
7
|
/**
|
|
18
8
|
* Adds a new UI5 dependency to the package.json.
|
|
19
9
|
* No longer required for `@ui5/cli` v3 and above.
|
|
@@ -22,11 +12,11 @@ const semver_1 = require("semver");
|
|
|
22
12
|
* @param basePath - the base path
|
|
23
13
|
* @param depName - the dependency name
|
|
24
14
|
*/
|
|
25
|
-
function addUi5Dependency(fs, basePath, depName) {
|
|
26
|
-
const filePath =
|
|
15
|
+
export function addUi5Dependency(fs, basePath, depName) {
|
|
16
|
+
const filePath = join(basePath, FileName.Package);
|
|
27
17
|
const packageJson = (fs.readJSON(filePath) ?? {});
|
|
28
|
-
const ui5CliVersion =
|
|
29
|
-
if (ui5CliVersion &&
|
|
18
|
+
const ui5CliVersion = coerce(packageJson?.devDependencies?.[UI5_CLI_LIB]);
|
|
19
|
+
if (ui5CliVersion && satisfies(ui5CliVersion, `>=${UI5_CLI_MIN_VERSION}`)) {
|
|
30
20
|
// https://sap.github.io/ui5-tooling/v3/updates/migrate-v3/#changes-to-dependency-configuration
|
|
31
21
|
return;
|
|
32
22
|
}
|
|
@@ -43,8 +33,8 @@ function addUi5Dependency(fs, basePath, depName) {
|
|
|
43
33
|
* @param basePath - base path of the library
|
|
44
34
|
* @returns the path of the library file
|
|
45
35
|
*/
|
|
46
|
-
async function getLibraryPath(basePath) {
|
|
47
|
-
return (await
|
|
36
|
+
export async function getLibraryPath(basePath) {
|
|
37
|
+
return (await getReuseLibs([
|
|
48
38
|
{
|
|
49
39
|
projectRoot: basePath
|
|
50
40
|
}
|
|
@@ -58,8 +48,8 @@ async function getLibraryPath(basePath) {
|
|
|
58
48
|
* @param ui5RepositoryFile - the UI5 repository file
|
|
59
49
|
* @param addContent - the content to be added
|
|
60
50
|
*/
|
|
61
|
-
const writeUi5RepositoryFile = (fs, basePath, ui5RepositoryFile, addContent) => {
|
|
62
|
-
const filePath =
|
|
51
|
+
export const writeUi5RepositoryFile = (fs, basePath, ui5RepositoryFile, addContent) => {
|
|
52
|
+
const filePath = join(basePath, ui5RepositoryFile);
|
|
63
53
|
let content;
|
|
64
54
|
if (fs.exists(filePath)) {
|
|
65
55
|
content = fs.read(filePath);
|
|
@@ -72,7 +62,6 @@ const writeUi5RepositoryFile = (fs, basePath, ui5RepositoryFile, addContent) =>
|
|
|
72
62
|
}
|
|
73
63
|
fs.write(filePath, content);
|
|
74
64
|
};
|
|
75
|
-
exports.writeUi5RepositoryFile = writeUi5RepositoryFile;
|
|
76
65
|
/**
|
|
77
66
|
* Returns the typescript file paths.
|
|
78
67
|
*
|
|
@@ -80,8 +69,8 @@ exports.writeUi5RepositoryFile = writeUi5RepositoryFile;
|
|
|
80
69
|
* @returns the typescript file paths
|
|
81
70
|
*/
|
|
82
71
|
async function getTypescriptFilePaths(typescriptPattern) {
|
|
83
|
-
const normalisedPath =
|
|
84
|
-
const typeScriptFilesPaths = await (
|
|
72
|
+
const normalisedPath = platform() === 'win32' ? typescriptPattern.replace(/\\/g, '/') : typescriptPattern;
|
|
73
|
+
const typeScriptFilesPaths = await fg(normalisedPath);
|
|
85
74
|
return typeScriptFilesPaths;
|
|
86
75
|
}
|
|
87
76
|
/**
|
|
@@ -90,11 +79,11 @@ async function getTypescriptFilePaths(typescriptPattern) {
|
|
|
90
79
|
* @param fs - the memfs editor instance
|
|
91
80
|
* @param path - the path where the file will be written
|
|
92
81
|
*/
|
|
93
|
-
async function writeUi5RepositoryFiles(fs, path) {
|
|
82
|
+
export async function writeUi5RepositoryFiles(fs, path) {
|
|
94
83
|
if (path) {
|
|
95
|
-
const typeScriptFilesPaths = await getTypescriptFilePaths(
|
|
84
|
+
const typeScriptFilesPaths = await getTypescriptFilePaths(join(path, '/**/*.ts'));
|
|
96
85
|
if (typeScriptFilesPaths?.length > 0) {
|
|
97
|
-
|
|
86
|
+
writeUi5RepositoryFile(fs, path, UI5_REPO_TEXT_FILES, '^.*.ts$');
|
|
98
87
|
}
|
|
99
88
|
}
|
|
100
89
|
}
|
|
@@ -104,11 +93,11 @@ async function writeUi5RepositoryFiles(fs, path) {
|
|
|
104
93
|
* @param fs - the memfs editor instance
|
|
105
94
|
* @param path - the path where the file will be written
|
|
106
95
|
*/
|
|
107
|
-
async function writeUi5RepositoryIgnore(fs, path) {
|
|
96
|
+
export async function writeUi5RepositoryIgnore(fs, path) {
|
|
108
97
|
if (path) {
|
|
109
|
-
const typeScriptFilesPaths = await getTypescriptFilePaths(
|
|
98
|
+
const typeScriptFilesPaths = await getTypescriptFilePaths(join(path, '/**/*.ts'));
|
|
110
99
|
if (typeScriptFilesPaths?.length > 0) {
|
|
111
|
-
|
|
100
|
+
writeUi5RepositoryFile(fs, path, UI5_REPO_IGNORE, '^.*.ts$\n^.*.ts.map$');
|
|
112
101
|
}
|
|
113
102
|
}
|
|
114
103
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
11
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
12
|
-
const config_1 = require("./config");
|
|
13
|
-
const file_1 = require("./file");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const scripts_1 = require("./scripts");
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { create as createStorage } from 'mem-fs';
|
|
3
|
+
import { create } from 'mem-fs-editor';
|
|
4
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
5
|
+
import { addPackageDevDependency, FileName, getWebappPath, readUi5Yaml } from '@sap-ux/project-access';
|
|
6
|
+
import { getDeployConfig, updateBaseConfig } from './config.js';
|
|
7
|
+
import { addUi5Dependency, getLibraryPath, writeUi5RepositoryFiles, writeUi5RepositoryIgnore } from './file.js';
|
|
8
|
+
import { UI5_TASK_FLATTEN_LIB, UI5_TASK_FLATTEN_LIB_VERSION } from './constants.js';
|
|
9
|
+
import { updateScripts } from './scripts.js';
|
|
16
10
|
/**
|
|
17
11
|
* Writes the template to the memfs editor instance.
|
|
18
12
|
*
|
|
@@ -23,34 +17,35 @@ const scripts_1 = require("./scripts");
|
|
|
23
17
|
* @returns the updated memfs editor instance
|
|
24
18
|
*/
|
|
25
19
|
async function generate(basePath, abapDeployConfig, options, fs) {
|
|
26
|
-
const abapConfig = (
|
|
20
|
+
const abapConfig = cloneDeep(abapDeployConfig);
|
|
27
21
|
if (!fs) {
|
|
28
|
-
fs =
|
|
22
|
+
fs = create(createStorage());
|
|
29
23
|
}
|
|
30
24
|
// base config
|
|
31
|
-
const baseConfigFile = options?.baseFile ??
|
|
32
|
-
const baseConfig = await
|
|
25
|
+
const baseConfigFile = options?.baseFile ?? FileName.Ui5Yaml;
|
|
26
|
+
const baseConfig = await readUi5Yaml(basePath, baseConfigFile, fs);
|
|
33
27
|
const isLib = baseConfig.getType() === 'library';
|
|
34
|
-
const baseConfigPath =
|
|
35
|
-
|
|
28
|
+
const baseConfigPath = join(basePath, baseConfigFile);
|
|
29
|
+
updateBaseConfig(isLib, baseConfigPath, baseConfig, fs);
|
|
36
30
|
// deploy config
|
|
37
|
-
const deployConfigFile = options?.deployFile ??
|
|
38
|
-
const deployFilePath =
|
|
39
|
-
const deployConfig = await
|
|
31
|
+
const deployConfigFile = options?.deployFile ?? FileName.UI5DeployYaml;
|
|
32
|
+
const deployFilePath = join(basePath, deployConfigFile);
|
|
33
|
+
const deployConfig = await getDeployConfig(abapConfig, baseConfig);
|
|
40
34
|
fs.write(deployFilePath, deployConfig.toString());
|
|
41
|
-
await
|
|
35
|
+
await updateScripts(basePath, deployConfigFile, fs, options);
|
|
42
36
|
if (isLib) {
|
|
43
37
|
// ui5 repo ignore file
|
|
44
|
-
await
|
|
45
|
-
|
|
46
|
-
const libPath = await
|
|
47
|
-
await
|
|
38
|
+
await addPackageDevDependency(basePath, UI5_TASK_FLATTEN_LIB, UI5_TASK_FLATTEN_LIB_VERSION, fs);
|
|
39
|
+
addUi5Dependency(fs, basePath, UI5_TASK_FLATTEN_LIB);
|
|
40
|
+
const libPath = await getLibraryPath(basePath);
|
|
41
|
+
await writeUi5RepositoryIgnore(fs, libPath);
|
|
48
42
|
}
|
|
49
43
|
else {
|
|
50
44
|
// ui5 repo file
|
|
51
|
-
const webappPath = await
|
|
52
|
-
await
|
|
45
|
+
const webappPath = await getWebappPath(basePath);
|
|
46
|
+
await writeUi5RepositoryFiles(fs, webappPath);
|
|
53
47
|
}
|
|
54
48
|
return fs;
|
|
55
49
|
}
|
|
50
|
+
export { generate };
|
|
56
51
|
//# sourceMappingURL=index.js.map
|
package/dist/scripts.d.ts
CHANGED
package/dist/scripts.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.updateScripts = updateScripts;
|
|
4
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { addPackageDevDependency, updatePackageScript } from '@sap-ux/project-access';
|
|
2
|
+
import { BUILD_SCRIPT, DEPLOY_SCRIPT, RIMRAF, RIMRAF_VERSION, UNDEPLOY_SCRIPT } from './constants.js';
|
|
6
3
|
/**
|
|
7
4
|
* Updates the scripts in the package.json file with the provided scripts object.
|
|
8
5
|
*
|
|
@@ -11,18 +8,18 @@ const constants_1 = require("./constants");
|
|
|
11
8
|
* @param {Editor} fs - The file system editor.
|
|
12
9
|
* @param {DeployConfigOptions} options - The deploy config options.
|
|
13
10
|
*/
|
|
14
|
-
async function updateScripts(basePath, deployConfigFile, fs, options) {
|
|
15
|
-
const buildPrefix = (options?.addBuildToUndeployScript ?? true) ? `${
|
|
11
|
+
export async function updateScripts(basePath, deployConfigFile, fs, options) {
|
|
12
|
+
const buildPrefix = (options?.addBuildToUndeployScript ?? true) ? `${BUILD_SCRIPT} && ` : '';
|
|
16
13
|
// deploy script
|
|
17
|
-
const deployScript = `${
|
|
18
|
-
await
|
|
14
|
+
const deployScript = `${BUILD_SCRIPT} && ${DEPLOY_SCRIPT} --config ${deployConfigFile}`;
|
|
15
|
+
await updatePackageScript(basePath, 'deploy', deployScript, fs);
|
|
19
16
|
// undeploy script
|
|
20
|
-
const undeployScript = `${buildPrefix}${
|
|
21
|
-
await
|
|
17
|
+
const undeployScript = `${buildPrefix}${UNDEPLOY_SCRIPT} --config ${deployConfigFile}`;
|
|
18
|
+
await updatePackageScript(basePath, 'undeploy', undeployScript, fs);
|
|
22
19
|
// test mode script
|
|
23
|
-
const deployTestModeScript = `${
|
|
24
|
-
await
|
|
20
|
+
const deployTestModeScript = `${BUILD_SCRIPT} && ${DEPLOY_SCRIPT} --config ${deployConfigFile} --testMode true`;
|
|
21
|
+
await updatePackageScript(basePath, 'deploy-test', deployTestModeScript, fs);
|
|
25
22
|
// dependencies
|
|
26
|
-
await
|
|
23
|
+
await addPackageDevDependency(basePath, RIMRAF, RIMRAF_VERSION, fs);
|
|
27
24
|
}
|
|
28
25
|
//# sourceMappingURL=scripts.js.map
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/abap-deploy-config-writer",
|
|
3
3
|
"description": "Writer module to add abap deployment configuration to an existing Fiori application",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
7
8
|
"directory": "packages/abap-deploy-config-writer"
|
|
8
9
|
},
|
|
9
|
-
"version": "0.
|
|
10
|
+
"version": "1.0.0",
|
|
10
11
|
"license": "Apache-2.0",
|
|
11
12
|
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
@@ -24,9 +25,9 @@
|
|
|
24
25
|
"mem-fs": "2.1.0",
|
|
25
26
|
"mem-fs-editor": "9.4.0",
|
|
26
27
|
"semver": "7.7.4",
|
|
27
|
-
"@sap-ux/project-access": "
|
|
28
|
-
"@sap-ux/system-access": "0.
|
|
29
|
-
"@sap-ux/ui5-config": "0.
|
|
28
|
+
"@sap-ux/project-access": "2.0.0",
|
|
29
|
+
"@sap-ux/system-access": "1.0.0",
|
|
30
|
+
"@sap-ux/ui5-config": "1.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/fs-extra": "11.0.4",
|
|
@@ -43,8 +44,8 @@
|
|
|
43
44
|
"format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
|
|
44
45
|
"lint": "eslint",
|
|
45
46
|
"lint:fix": "eslint --fix",
|
|
46
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
47
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
47
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
48
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
48
49
|
"link": "pnpm link --global",
|
|
49
50
|
"unlink": "pnpm unlink --global"
|
|
50
51
|
}
|