@sap-ux/app-config-writer 0.6.96 → 0.6.98
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/eslint-config/index.d.ts +21 -0
- package/dist/eslint-config/index.js +90 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/preview-config/index.js +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Editor } from 'mem-fs-editor';
|
|
2
|
+
import { type ToolsLogger } from '@sap-ux/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Adds eslint configuration to the project.
|
|
5
|
+
*
|
|
6
|
+
* It checks the prerequisites and confirms an explicit approval to add the configuration.
|
|
7
|
+
* If the prerequisites and approval are met, the corresponding eslint configuration and packages are added.
|
|
8
|
+
*
|
|
9
|
+
* @param basePath - base path to be used for the conversion
|
|
10
|
+
* @param options - options for the conversion
|
|
11
|
+
* @param options.logger - logger to report info to the user
|
|
12
|
+
* @param options.fs - file system reference
|
|
13
|
+
* @param options.config - the name of the SAP Fiori tools eslint plugin config to be used
|
|
14
|
+
* @returns file system reference
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateEslintConfig(basePath: string, options: {
|
|
17
|
+
logger?: ToolsLogger;
|
|
18
|
+
fs?: Editor;
|
|
19
|
+
config?: string;
|
|
20
|
+
}): Promise<Editor>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEslintConfig = generateEslintConfig;
|
|
4
|
+
const mem_fs_1 = require("mem-fs");
|
|
5
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
6
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
/**
|
|
9
|
+
* Adds eslint configuration to the project.
|
|
10
|
+
*
|
|
11
|
+
* It checks the prerequisites and confirms an explicit approval to add the configuration.
|
|
12
|
+
* If the prerequisites and approval are met, the corresponding eslint configuration and packages are added.
|
|
13
|
+
*
|
|
14
|
+
* @param basePath - base path to be used for the conversion
|
|
15
|
+
* @param options - options for the conversion
|
|
16
|
+
* @param options.logger - logger to report info to the user
|
|
17
|
+
* @param options.fs - file system reference
|
|
18
|
+
* @param options.config - the name of the SAP Fiori tools eslint plugin config to be used
|
|
19
|
+
* @returns file system reference
|
|
20
|
+
*/
|
|
21
|
+
async function generateEslintConfig(basePath, options) {
|
|
22
|
+
const fs = options.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
23
|
+
const logger = options.logger;
|
|
24
|
+
if (!(await checkPrerequisites(basePath, fs, logger))) {
|
|
25
|
+
throw new Error('The prerequisites are not met. For more information, see the log messages above.');
|
|
26
|
+
}
|
|
27
|
+
await updatePackageJson(basePath, fs, logger);
|
|
28
|
+
await addEslintConfig(basePath, fs, options?.config);
|
|
29
|
+
return fs;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks the prerequisites for adding an eslint configuration to the project.
|
|
33
|
+
*
|
|
34
|
+
* @param basePath - base path to be used for the conversion
|
|
35
|
+
* @param fs - file system reference
|
|
36
|
+
* @param logger - logger to report info to the user
|
|
37
|
+
* @returns true if the prerequisites are met, false otherwise
|
|
38
|
+
*/
|
|
39
|
+
async function checkPrerequisites(basePath, fs, logger) {
|
|
40
|
+
const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
|
|
41
|
+
const packageJson = fs.readJSON(packageJsonPath);
|
|
42
|
+
if (!packageJson) {
|
|
43
|
+
logger?.error(`No package.json found at path '${packageJsonPath}'`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const eslintExists = (0, project_access_1.hasDependency)(packageJson, 'eslint');
|
|
47
|
+
if (eslintExists) {
|
|
48
|
+
logger?.error(`EsLint already exists in this project. Found 'eslint' dependency in package.json at path '${packageJsonPath}'`);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Updates the package.json file of the project by adding the required eslint dependency.
|
|
55
|
+
*
|
|
56
|
+
* @param basePath - base path to be used for the conversion
|
|
57
|
+
* @param fs - file system reference
|
|
58
|
+
* @param logger - logger to report info to the user
|
|
59
|
+
*/
|
|
60
|
+
async function updatePackageJson(basePath, fs, logger) {
|
|
61
|
+
const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
|
|
62
|
+
const packageJson = fs.readJSON(packageJsonPath);
|
|
63
|
+
packageJson.devDependencies ??= {};
|
|
64
|
+
packageJson.devDependencies['eslint'] = '^9.0.0';
|
|
65
|
+
packageJson.devDependencies['@sap-ux/eslint-plugin-fiori-tools'] = '^9.0.0';
|
|
66
|
+
packageJson.scripts ??= {};
|
|
67
|
+
if (packageJson.scripts['lint']) {
|
|
68
|
+
logger?.warn(`A 'lint' script already exists in package.json at path '${packageJsonPath}'. Adding lint script skipped.`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
packageJson.scripts['lint'] = 'eslint .';
|
|
72
|
+
}
|
|
73
|
+
fs.writeJSON(packageJsonPath, packageJson);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Adds the eslint configuration file to the project.
|
|
77
|
+
*
|
|
78
|
+
* @param basePath - base path to be used for the conversion
|
|
79
|
+
* @param fs - file system reference
|
|
80
|
+
* @param config - the name of the SAP Fiori tools eslint plugin config to be used
|
|
81
|
+
*/
|
|
82
|
+
async function addEslintConfig(basePath, fs, config = 'recommended') {
|
|
83
|
+
const templatePath = require.resolve('@sap-ux/ui5-application-writer/templates/optional/eslint/eslint.config.mjs');
|
|
84
|
+
let templateContent = await fs.read(templatePath);
|
|
85
|
+
if (config === 'recommended-for-s4hana') {
|
|
86
|
+
templateContent = templateContent.replace('...fioriTools.configs.recommended', "...fioriTools.configs['recommended-for-s4hana']");
|
|
87
|
+
}
|
|
88
|
+
await fs.write((0, node_path_1.join)(basePath, 'eslint.config.mjs'), templateContent);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { getSmartLinksTargetFromPrompt, simulatePrompt, includeTestRunnersPrompt } from './prompt';
|
|
2
2
|
export { generateSmartLinksConfig } from './smartlinks-config';
|
|
3
|
+
export { generateEslintConfig } from './eslint-config';
|
|
3
4
|
export { generateInboundNavigationConfig, readManifest } from './navigation-config';
|
|
4
5
|
export { generateVariantsConfig } from './variants-config';
|
|
5
6
|
export { convertToVirtualPreview } from './preview-config';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableCardGeneratorConfig = exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.generateSmartLinksConfig = exports.includeTestRunnersPrompt = exports.simulatePrompt = exports.getSmartLinksTargetFromPrompt = void 0;
|
|
3
|
+
exports.enableCardGeneratorConfig = exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.generateEslintConfig = exports.generateSmartLinksConfig = exports.includeTestRunnersPrompt = exports.simulatePrompt = exports.getSmartLinksTargetFromPrompt = void 0;
|
|
4
4
|
var prompt_1 = require("./prompt");
|
|
5
5
|
Object.defineProperty(exports, "getSmartLinksTargetFromPrompt", { enumerable: true, get: function () { return prompt_1.getSmartLinksTargetFromPrompt; } });
|
|
6
6
|
Object.defineProperty(exports, "simulatePrompt", { enumerable: true, get: function () { return prompt_1.simulatePrompt; } });
|
|
7
7
|
Object.defineProperty(exports, "includeTestRunnersPrompt", { enumerable: true, get: function () { return prompt_1.includeTestRunnersPrompt; } });
|
|
8
8
|
var smartlinks_config_1 = require("./smartlinks-config");
|
|
9
9
|
Object.defineProperty(exports, "generateSmartLinksConfig", { enumerable: true, get: function () { return smartlinks_config_1.generateSmartLinksConfig; } });
|
|
10
|
+
var eslint_config_1 = require("./eslint-config");
|
|
11
|
+
Object.defineProperty(exports, "generateEslintConfig", { enumerable: true, get: function () { return eslint_config_1.generateEslintConfig; } });
|
|
10
12
|
var navigation_config_1 = require("./navigation-config");
|
|
11
13
|
Object.defineProperty(exports, "generateInboundNavigationConfig", { enumerable: true, get: function () { return navigation_config_1.generateInboundNavigationConfig; } });
|
|
12
14
|
Object.defineProperty(exports, "readManifest", { enumerable: true, get: function () { return navigation_config_1.readManifest; } });
|
|
@@ -26,7 +26,7 @@ async function convertToVirtualPreview(basePath, options) {
|
|
|
26
26
|
const logger = options.logger;
|
|
27
27
|
const convertTests = options.convertTests ?? false;
|
|
28
28
|
if (!(await (0, prerequisites_1.checkPrerequisites)(basePath, fs, convertTests, logger))) {
|
|
29
|
-
throw Error('The prerequisites are not met. For more information, see the log messages above.');
|
|
29
|
+
throw new Error('The prerequisites are not met. For more information, see the log messages above.');
|
|
30
30
|
}
|
|
31
31
|
await (0, ui5_yaml_1.updatePreviewMiddlewareConfigs)(fs, basePath, convertTests, logger);
|
|
32
32
|
await (0, preview_files_1.renameDefaultSandboxes)(fs, basePath, logger);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/app-config-writer",
|
|
3
3
|
"description": "Add or update configuration for SAP Fiori tools application",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.98",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"prompts": "2.4.2",
|
|
29
29
|
"semver": "7.7.3",
|
|
30
|
-
"@sap-ux/axios-extension": "1.25.11",
|
|
31
30
|
"@sap-ux/btp-utils": "1.1.8",
|
|
32
31
|
"@sap-ux/logger": "0.8.1",
|
|
32
|
+
"@sap-ux/axios-extension": "1.25.11",
|
|
33
|
+
"@sap-ux/store": "1.5.6",
|
|
34
|
+
"@sap-ux/ui5-config": "0.29.16",
|
|
33
35
|
"@sap-ux/project-access": "1.35.3",
|
|
34
|
-
"@sap-ux/
|
|
35
|
-
"@sap-ux/ui5-config": "0.29.16"
|
|
36
|
+
"@sap-ux/ui5-application-writer": "1.7.8"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/ejs": "3.1.2",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"@types/semver": "7.7.1",
|
|
43
44
|
"axios": "1.13.5",
|
|
44
45
|
"nock": "13.4.0",
|
|
45
|
-
"@sap-ux/preview-middleware": "0.23.
|
|
46
|
+
"@sap-ux/preview-middleware": "0.23.120"
|
|
46
47
|
},
|
|
47
48
|
"engines": {
|
|
48
49
|
"node": ">=20.x"
|