@sap-ux/abap-deploy-config-writer 0.4.3 → 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 CHANGED
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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(constants_1.UI5_TASK_FLATTEN_LIB)) {
13
+ if (!baseConfig.findCustomTask(UI5_TASK_FLATTEN_LIB)) {
18
14
  const customTask = {
19
- name: constants_1.UI5_TASK_FLATTEN_LIB,
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 ui5_config_1.UI5Config.newInstance(baseUi5Doc.toString());
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UI5_CLI_MIN_VERSION = exports.UI5_CLI_LIB = exports.UI5_REPO_IGNORE = exports.UI5_REPO_TEXT_FILES = exports.UI5_TASK_FLATTEN_LIB_VERSION = exports.UI5_TASK_FLATTEN_LIB = exports.RIMRAF = exports.RIMRAF_VERSION = exports.UNDEPLOY_SCRIPT = exports.DEPLOY_SCRIPT = exports.BUILD_SCRIPT = void 0;
4
- exports.BUILD_SCRIPT = 'npm run build';
5
- exports.DEPLOY_SCRIPT = 'fiori deploy';
6
- exports.UNDEPLOY_SCRIPT = 'fiori undeploy';
7
- exports.RIMRAF_VERSION = '^5.0.5';
8
- exports.RIMRAF = 'rimraf';
9
- exports.UI5_TASK_FLATTEN_LIB = 'ui5-task-flatten-library';
10
- exports.UI5_TASK_FLATTEN_LIB_VERSION = '^3.1.0';
11
- exports.UI5_REPO_TEXT_FILES = '.Ui5RepositoryTextFiles';
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
- "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.writeUi5RepositoryFile = void 0;
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 = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
15
+ export function addUi5Dependency(fs, basePath, depName) {
16
+ const filePath = join(basePath, FileName.Package);
27
17
  const packageJson = (fs.readJSON(filePath) ?? {});
28
- const ui5CliVersion = (0, semver_1.coerce)(packageJson?.devDependencies?.[constants_1.UI5_CLI_LIB]);
29
- if (ui5CliVersion && (0, semver_1.satisfies)(ui5CliVersion, `>=${constants_1.UI5_CLI_MIN_VERSION}`)) {
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 (0, project_access_1.getReuseLibs)([
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 = (0, node_path_1.join)(basePath, ui5RepositoryFile);
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 = (0, node_os_1.platform)() === 'win32' ? typescriptPattern.replace(/\\/g, '/') : typescriptPattern;
84
- const typeScriptFilesPaths = await (0, fast_glob_1.default)(normalisedPath);
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((0, node_path_1.join)(path, '/**/*.ts'));
84
+ const typeScriptFilesPaths = await getTypescriptFilePaths(join(path, '/**/*.ts'));
96
85
  if (typeScriptFilesPaths?.length > 0) {
97
- (0, exports.writeUi5RepositoryFile)(fs, path, constants_1.UI5_REPO_TEXT_FILES, '^.*.ts$');
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((0, node_path_1.join)(path, '/**/*.ts'));
98
+ const typeScriptFilesPaths = await getTypescriptFilePaths(join(path, '/**/*.ts'));
110
99
  if (typeScriptFilesPaths?.length > 0) {
111
- (0, exports.writeUi5RepositoryFile)(fs, path, constants_1.UI5_REPO_IGNORE, '^.*.ts$\n^.*.ts.map$');
100
+ writeUi5RepositoryFile(fs, path, UI5_REPO_IGNORE, '^.*.ts$\n^.*.ts.map$');
112
101
  }
113
102
  }
114
103
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DeployConfigOptions } from './types';
1
+ import type { DeployConfigOptions } from './types.js';
2
2
  import type { Editor } from 'mem-fs-editor';
3
3
  import type { AbapDeployConfig } from '@sap-ux/ui5-config';
4
4
  /**
package/dist/index.js CHANGED
@@ -1,18 +1,12 @@
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.generate = generate;
7
- const node_path_1 = require("node:path");
8
- const mem_fs_1 = require("mem-fs");
9
- const mem_fs_editor_1 = require("mem-fs-editor");
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 = (0, cloneDeep_1.default)(abapDeployConfig);
20
+ const abapConfig = cloneDeep(abapDeployConfig);
27
21
  if (!fs) {
28
- fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
22
+ fs = create(createStorage());
29
23
  }
30
24
  // base config
31
- const baseConfigFile = options?.baseFile ?? project_access_1.FileName.Ui5Yaml;
32
- const baseConfig = await (0, project_access_1.readUi5Yaml)(basePath, baseConfigFile, fs);
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 = (0, node_path_1.join)(basePath, baseConfigFile);
35
- (0, config_1.updateBaseConfig)(isLib, baseConfigPath, baseConfig, fs);
28
+ const baseConfigPath = join(basePath, baseConfigFile);
29
+ updateBaseConfig(isLib, baseConfigPath, baseConfig, fs);
36
30
  // deploy config
37
- const deployConfigFile = options?.deployFile ?? project_access_1.FileName.UI5DeployYaml;
38
- const deployFilePath = (0, node_path_1.join)(basePath, deployConfigFile);
39
- const deployConfig = await (0, config_1.getDeployConfig)(abapConfig, baseConfig);
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 (0, scripts_1.updateScripts)(basePath, deployConfigFile, fs, options);
35
+ await updateScripts(basePath, deployConfigFile, fs, options);
42
36
  if (isLib) {
43
37
  // ui5 repo ignore file
44
- await (0, project_access_1.addPackageDevDependency)(basePath, constants_1.UI5_TASK_FLATTEN_LIB, constants_1.UI5_TASK_FLATTEN_LIB_VERSION, fs);
45
- (0, file_1.addUi5Dependency)(fs, basePath, constants_1.UI5_TASK_FLATTEN_LIB);
46
- const libPath = await (0, file_1.getLibraryPath)(basePath);
47
- await (0, file_1.writeUi5RepositoryIgnore)(fs, libPath);
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 (0, project_access_1.getWebappPath)(basePath);
52
- await (0, file_1.writeUi5RepositoryFiles)(fs, webappPath);
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
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { DeployConfigOptions } from './types';
2
+ import type { DeployConfigOptions } from './types.js';
3
3
  /**
4
4
  * Updates the scripts in the package.json file with the provided scripts object.
5
5
  *
package/dist/scripts.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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) ? `${constants_1.BUILD_SCRIPT} && ` : '';
11
+ export async function updateScripts(basePath, deployConfigFile, fs, options) {
12
+ const buildPrefix = (options?.addBuildToUndeployScript ?? true) ? `${BUILD_SCRIPT} && ` : '';
16
13
  // deploy script
17
- const deployScript = `${constants_1.BUILD_SCRIPT} && ${constants_1.DEPLOY_SCRIPT} --config ${deployConfigFile}`;
18
- await (0, project_access_1.updatePackageScript)(basePath, 'deploy', deployScript, fs);
14
+ const deployScript = `${BUILD_SCRIPT} && ${DEPLOY_SCRIPT} --config ${deployConfigFile}`;
15
+ await updatePackageScript(basePath, 'deploy', deployScript, fs);
19
16
  // undeploy script
20
- const undeployScript = `${buildPrefix}${constants_1.UNDEPLOY_SCRIPT} --config ${deployConfigFile}`;
21
- await (0, project_access_1.updatePackageScript)(basePath, 'undeploy', undeployScript, fs);
17
+ const undeployScript = `${buildPrefix}${UNDEPLOY_SCRIPT} --config ${deployConfigFile}`;
18
+ await updatePackageScript(basePath, 'undeploy', undeployScript, fs);
22
19
  // test mode script
23
- const deployTestModeScript = `${constants_1.BUILD_SCRIPT} && ${constants_1.DEPLOY_SCRIPT} --config ${deployConfigFile} --testMode true`;
24
- await (0, project_access_1.updatePackageScript)(basePath, 'deploy-test', deployTestModeScript, fs);
20
+ const deployTestModeScript = `${BUILD_SCRIPT} && ${DEPLOY_SCRIPT} --config ${deployConfigFile} --testMode true`;
21
+ await updatePackageScript(basePath, 'deploy-test', deployTestModeScript, fs);
25
22
  // dependencies
26
- await (0, project_access_1.addPackageDevDependency)(basePath, constants_1.RIMRAF, constants_1.RIMRAF_VERSION, fs);
23
+ await addPackageDevDependency(basePath, RIMRAF, RIMRAF_VERSION, fs);
27
24
  }
28
25
  //# sourceMappingURL=scripts.js.map
package/dist/types.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
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.4.3",
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": "1.38.1",
28
- "@sap-ux/system-access": "0.8.1",
29
- "@sap-ux/ui5-config": "0.31.1"
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
  }