@sap-ux/project-access 1.27.2 → 1.27.3
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/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/file/file-access.d.ts +24 -1
- package/dist/file/file-access.js +40 -2
- package/dist/file/index.d.ts +1 -1
- package/dist/file/index.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -6
- package/dist/project/cap.d.ts +10 -1
- package/dist/project/cap.js +78 -1
- package/dist/project/index.d.ts +1 -1
- package/dist/project/index.js +5 -4
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const FileName: {
|
|
|
2
2
|
readonly AdaptationConfig: "config.json";
|
|
3
3
|
readonly CapJavaApplicationYaml: "application.yaml";
|
|
4
4
|
readonly ExtConfigJson: ".extconfig.json";
|
|
5
|
+
readonly IndexCds: "index.cds";
|
|
5
6
|
readonly Library: ".library";
|
|
6
7
|
readonly Manifest: "manifest.json";
|
|
7
8
|
readonly ManifestAppDescrVar: "manifest.appdescr_variant";
|
|
@@ -9,6 +10,7 @@ export declare const FileName: {
|
|
|
9
10
|
readonly Package: "package.json";
|
|
10
11
|
readonly Pom: "pom.xml";
|
|
11
12
|
readonly SpecificationDistTags: "specification-dist-tags.json";
|
|
13
|
+
readonly ServiceCds: "services.cds";
|
|
12
14
|
readonly Tsconfig: "tsconfig.json";
|
|
13
15
|
readonly Ui5Yaml: "ui5.yaml";
|
|
14
16
|
readonly Ui5LocalYaml: "ui5-local.yaml";
|
package/dist/constants.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.FileName = {
|
|
|
7
7
|
AdaptationConfig: 'config.json',
|
|
8
8
|
CapJavaApplicationYaml: 'application.yaml',
|
|
9
9
|
ExtConfigJson: '.extconfig.json',
|
|
10
|
+
IndexCds: 'index.cds',
|
|
10
11
|
Library: '.library',
|
|
11
12
|
Manifest: 'manifest.json',
|
|
12
13
|
ManifestAppDescrVar: 'manifest.appdescr_variant',
|
|
@@ -14,6 +15,7 @@ exports.FileName = {
|
|
|
14
15
|
Package: 'package.json',
|
|
15
16
|
Pom: 'pom.xml',
|
|
16
17
|
SpecificationDistTags: 'specification-dist-tags.json',
|
|
18
|
+
ServiceCds: 'services.cds',
|
|
17
19
|
Tsconfig: 'tsconfig.json',
|
|
18
20
|
Ui5Yaml: 'ui5.yaml',
|
|
19
21
|
Ui5LocalYaml: 'ui5-local.yaml',
|
|
@@ -17,7 +17,7 @@ export declare function readFile(path: string, memFs?: Editor): Promise<string>;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function readJSON<T>(path: string, memFs?: Editor): Promise<T>;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Write file asynchronously. Throws error if file does not exist.
|
|
21
21
|
*
|
|
22
22
|
* @param path - path to file
|
|
23
23
|
* @param content - content to write to a file
|
|
@@ -49,4 +49,27 @@ export declare function updatePackageJSON(path: string, packageJson: Package, me
|
|
|
49
49
|
* @param memFs - optional mem-fs-editor instance
|
|
50
50
|
*/
|
|
51
51
|
export declare function updateManifestJSON(path: string, manifest: Manifest, memFs?: Editor): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Deletes file asynchronously.
|
|
54
|
+
*
|
|
55
|
+
* @param path - path to file
|
|
56
|
+
* @param memFs - optional mem-fs-editor instance
|
|
57
|
+
* @returns Promise to void.
|
|
58
|
+
*/
|
|
59
|
+
export declare function deleteFile(path: string, memFs?: Editor): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Read array of files from folder asynchronously.
|
|
62
|
+
*
|
|
63
|
+
* @param path - path to folder
|
|
64
|
+
* @returns Array of the names of the files in the directory.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readDirectory(path: string): Promise<string[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Deletes folder asynchronously.
|
|
69
|
+
*
|
|
70
|
+
* @param path - path to folder
|
|
71
|
+
* @param memFs - optional mem-fs-editor instance
|
|
72
|
+
* @returns Promise to void.
|
|
73
|
+
*/
|
|
74
|
+
export declare function deleteDirectory(path: string, memFs?: Editor): Promise<void>;
|
|
52
75
|
//# sourceMappingURL=file-access.d.ts.map
|
package/dist/file/file-access.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.updateManifestJSON = exports.updatePackageJSON = exports.fileExists = exports.writeFile = exports.readJSON = exports.readFile = void 0;
|
|
6
|
+
exports.deleteDirectory = exports.readDirectory = exports.deleteFile = exports.updateManifestJSON = exports.updatePackageJSON = exports.fileExists = exports.writeFile = exports.readJSON = exports.readFile = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const json_parse_even_better_errors_1 = __importDefault(require("json-parse-even-better-errors"));
|
|
9
9
|
/**
|
|
@@ -39,7 +39,7 @@ async function readJSON(path, memFs) {
|
|
|
39
39
|
}
|
|
40
40
|
exports.readJSON = readJSON;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Write file asynchronously. Throws error if file does not exist.
|
|
43
43
|
*
|
|
44
44
|
* @param path - path to file
|
|
45
45
|
* @param content - content to write to a file
|
|
@@ -113,4 +113,42 @@ async function updateJSON(path, content, memFs) {
|
|
|
113
113
|
const result = JSON.stringify(content, null, oldContentJson[indent]) + '\n';
|
|
114
114
|
await writeFile(path, result, memFs);
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Deletes file asynchronously.
|
|
118
|
+
*
|
|
119
|
+
* @param path - path to file
|
|
120
|
+
* @param memFs - optional mem-fs-editor instance
|
|
121
|
+
* @returns Promise to void.
|
|
122
|
+
*/
|
|
123
|
+
async function deleteFile(path, memFs) {
|
|
124
|
+
if (memFs) {
|
|
125
|
+
return memFs.delete(path);
|
|
126
|
+
}
|
|
127
|
+
return fs_1.promises.unlink(path);
|
|
128
|
+
}
|
|
129
|
+
exports.deleteFile = deleteFile;
|
|
130
|
+
/**
|
|
131
|
+
* Read array of files from folder asynchronously.
|
|
132
|
+
*
|
|
133
|
+
* @param path - path to folder
|
|
134
|
+
* @returns Array of the names of the files in the directory.
|
|
135
|
+
*/
|
|
136
|
+
async function readDirectory(path) {
|
|
137
|
+
return fs_1.promises.readdir(path, { encoding: 'utf8' });
|
|
138
|
+
}
|
|
139
|
+
exports.readDirectory = readDirectory;
|
|
140
|
+
/**
|
|
141
|
+
* Deletes folder asynchronously.
|
|
142
|
+
*
|
|
143
|
+
* @param path - path to folder
|
|
144
|
+
* @param memFs - optional mem-fs-editor instance
|
|
145
|
+
* @returns Promise to void.
|
|
146
|
+
*/
|
|
147
|
+
async function deleteDirectory(path, memFs) {
|
|
148
|
+
if (memFs) {
|
|
149
|
+
return memFs.delete(path);
|
|
150
|
+
}
|
|
151
|
+
return fs_1.promises.rm(path, { recursive: true, force: true });
|
|
152
|
+
}
|
|
153
|
+
exports.deleteDirectory = deleteDirectory;
|
|
116
154
|
//# sourceMappingURL=file-access.js.map
|
package/dist/file/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { fileExists, readFile, readJSON, updatePackageJSON, updateManifestJSON, writeFile } from './file-access';
|
|
1
|
+
export { deleteDirectory, deleteFile, fileExists, readDirectory, readFile, readJSON, updatePackageJSON, updateManifestJSON, writeFile } from './file-access';
|
|
2
2
|
export { findBy, findFiles, findFilesByExtension, findFileUp, getFilePaths } from './file-search';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/file/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFilePaths = exports.findFileUp = exports.findFilesByExtension = exports.findFiles = exports.findBy = exports.writeFile = exports.updateManifestJSON = exports.updatePackageJSON = exports.readJSON = exports.readFile = exports.fileExists = void 0;
|
|
3
|
+
exports.getFilePaths = exports.findFileUp = exports.findFilesByExtension = exports.findFiles = exports.findBy = exports.writeFile = exports.updateManifestJSON = exports.updatePackageJSON = exports.readJSON = exports.readFile = exports.readDirectory = exports.fileExists = exports.deleteFile = exports.deleteDirectory = void 0;
|
|
4
4
|
var file_access_1 = require("./file-access");
|
|
5
|
+
Object.defineProperty(exports, "deleteDirectory", { enumerable: true, get: function () { return file_access_1.deleteDirectory; } });
|
|
6
|
+
Object.defineProperty(exports, "deleteFile", { enumerable: true, get: function () { return file_access_1.deleteFile; } });
|
|
5
7
|
Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return file_access_1.fileExists; } });
|
|
8
|
+
Object.defineProperty(exports, "readDirectory", { enumerable: true, get: function () { return file_access_1.readDirectory; } });
|
|
6
9
|
Object.defineProperty(exports, "readFile", { enumerable: true, get: function () { return file_access_1.readFile; } });
|
|
7
10
|
Object.defineProperty(exports, "readJSON", { enumerable: true, get: function () { return file_access_1.readJSON; } });
|
|
8
11
|
Object.defineProperty(exports, "updatePackageJSON", { enumerable: true, get: function () { return file_access_1.updatePackageJSON; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FileName, DirName, FioriToolsSettings } from './constants';
|
|
2
2
|
export { getFilePaths } from './file';
|
|
3
|
-
export { addPackageDevDependency, clearCdsModuleCache, createApplicationAccess, createProjectAccess, findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getSpecification, getSpecificationPath, getI18nPropertiesPaths, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml,
|
|
3
|
+
export { addPackageDevDependency, clearCdsModuleCache, createApplicationAccess, createProjectAccess, deleteCapApp, filterDataSourcesByType, findAllApps, findCapProjectRoot, findCapProjects, findFioriArtifacts, findProjectRoot, findRootsForPath, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapServiceName, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getCapI18nFolderNames, getSpecification, getSpecificationPath, getI18nPropertiesPaths, getMinUI5VersionFromManifest, getMinUI5VersionAsArray, getMinimumUI5Version, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, hasUI5CliV3, isCapProject, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml, refreshSpecificationDistTags, toReferenceUri, updatePackageScript } from './project';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './library';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.updatePackageScript = exports.toReferenceUri = exports.refreshSpecificationDistTags = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.hasUI5CliV3 = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getI18nPropertiesPaths = exports.getSpecificationPath = exports.getSpecification = exports.getCapI18nFolderNames = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapServiceName = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findRootsForPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findCapProjectRoot = exports.findAllApps = exports.filterDataSourcesByType = exports.deleteCapApp = exports.createProjectAccess = exports.createApplicationAccess = exports.clearCdsModuleCache = exports.addPackageDevDependency = exports.getFilePaths = exports.FioriToolsSettings = exports.DirName = exports.FileName = void 0;
|
|
18
18
|
var constants_1 = require("./constants");
|
|
19
19
|
Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
|
|
20
20
|
Object.defineProperty(exports, "DirName", { enumerable: true, get: function () { return constants_1.DirName; } });
|
|
@@ -26,16 +26,21 @@ Object.defineProperty(exports, "addPackageDevDependency", { enumerable: true, ge
|
|
|
26
26
|
Object.defineProperty(exports, "clearCdsModuleCache", { enumerable: true, get: function () { return project_1.clearCdsModuleCache; } });
|
|
27
27
|
Object.defineProperty(exports, "createApplicationAccess", { enumerable: true, get: function () { return project_1.createApplicationAccess; } });
|
|
28
28
|
Object.defineProperty(exports, "createProjectAccess", { enumerable: true, get: function () { return project_1.createProjectAccess; } });
|
|
29
|
+
Object.defineProperty(exports, "deleteCapApp", { enumerable: true, get: function () { return project_1.deleteCapApp; } });
|
|
30
|
+
Object.defineProperty(exports, "filterDataSourcesByType", { enumerable: true, get: function () { return project_1.filterDataSourcesByType; } });
|
|
29
31
|
Object.defineProperty(exports, "findAllApps", { enumerable: true, get: function () { return project_1.findAllApps; } });
|
|
32
|
+
Object.defineProperty(exports, "findCapProjectRoot", { enumerable: true, get: function () { return project_1.findCapProjectRoot; } });
|
|
30
33
|
Object.defineProperty(exports, "findCapProjects", { enumerable: true, get: function () { return project_1.findCapProjects; } });
|
|
31
34
|
Object.defineProperty(exports, "findFioriArtifacts", { enumerable: true, get: function () { return project_1.findFioriArtifacts; } });
|
|
32
35
|
Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return project_1.findProjectRoot; } });
|
|
36
|
+
Object.defineProperty(exports, "findRootsForPath", { enumerable: true, get: function () { return project_1.findRootsForPath; } });
|
|
33
37
|
Object.defineProperty(exports, "getAppRootFromWebappPath", { enumerable: true, get: function () { return project_1.getAppRootFromWebappPath; } });
|
|
34
38
|
Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return project_1.getAppProgrammingLanguage; } });
|
|
35
39
|
Object.defineProperty(exports, "getAppType", { enumerable: true, get: function () { return project_1.getAppType; } });
|
|
36
40
|
Object.defineProperty(exports, "getCapCustomPaths", { enumerable: true, get: function () { return project_1.getCapCustomPaths; } });
|
|
37
41
|
Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: function () { return project_1.getCapEnvironment; } });
|
|
38
42
|
Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return project_1.getCapModelAndServices; } });
|
|
43
|
+
Object.defineProperty(exports, "getCapServiceName", { enumerable: true, get: function () { return project_1.getCapServiceName; } });
|
|
39
44
|
Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: function () { return project_1.getCapProjectType; } });
|
|
40
45
|
Object.defineProperty(exports, "getCdsFiles", { enumerable: true, get: function () { return project_1.getCdsFiles; } });
|
|
41
46
|
Object.defineProperty(exports, "getCdsRoots", { enumerable: true, get: function () { return project_1.getCdsRoots; } });
|
|
@@ -52,20 +57,16 @@ Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: fu
|
|
|
52
57
|
Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_1.getProject; } });
|
|
53
58
|
Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return project_1.getProjectType; } });
|
|
54
59
|
Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return project_1.getWebappPath; } });
|
|
60
|
+
Object.defineProperty(exports, "hasUI5CliV3", { enumerable: true, get: function () { return project_1.hasUI5CliV3; } });
|
|
55
61
|
Object.defineProperty(exports, "isCapProject", { enumerable: true, get: function () { return project_1.isCapProject; } });
|
|
56
62
|
Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return project_1.isCapJavaProject; } });
|
|
57
63
|
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return project_1.isCapNodeJsProject; } });
|
|
58
64
|
Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return project_1.loadModuleFromProject; } });
|
|
59
65
|
Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return project_1.readCapServiceMetadataEdmx; } });
|
|
60
66
|
Object.defineProperty(exports, "readUi5Yaml", { enumerable: true, get: function () { return project_1.readUi5Yaml; } });
|
|
61
|
-
Object.defineProperty(exports, "getCapServiceName", { enumerable: true, get: function () { return project_1.getCapServiceName; } });
|
|
62
67
|
Object.defineProperty(exports, "refreshSpecificationDistTags", { enumerable: true, get: function () { return project_1.refreshSpecificationDistTags; } });
|
|
63
68
|
Object.defineProperty(exports, "toReferenceUri", { enumerable: true, get: function () { return project_1.toReferenceUri; } });
|
|
64
|
-
Object.defineProperty(exports, "filterDataSourcesByType", { enumerable: true, get: function () { return project_1.filterDataSourcesByType; } });
|
|
65
69
|
Object.defineProperty(exports, "updatePackageScript", { enumerable: true, get: function () { return project_1.updatePackageScript; } });
|
|
66
|
-
Object.defineProperty(exports, "findCapProjectRoot", { enumerable: true, get: function () { return project_1.findCapProjectRoot; } });
|
|
67
|
-
Object.defineProperty(exports, "hasUI5CliV3", { enumerable: true, get: function () { return project_1.hasUI5CliV3; } });
|
|
68
|
-
Object.defineProperty(exports, "findRootsForPath", { enumerable: true, get: function () { return project_1.findRootsForPath; } });
|
|
69
70
|
__exportStar(require("./types"), exports);
|
|
70
71
|
__exportStar(require("./library"), exports);
|
|
71
72
|
//# sourceMappingURL=index.js.map
|
package/dist/project/cap.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CapCustomPaths, CapProjectType, CdsEnvironment, csn, Package, ServiceDefinitions, ServiceInfo, CdsVersionInfo } from '../types';
|
|
2
1
|
import type { Logger } from '@sap-ux/logger';
|
|
2
|
+
import type { Editor } from 'mem-fs-editor';
|
|
3
|
+
import type { CapCustomPaths, CapProjectType, CdsEnvironment, csn, Package, ServiceDefinitions, ServiceInfo, CdsVersionInfo } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* Returns true if the project is a CAP Node.js project.
|
|
5
6
|
*
|
|
@@ -127,4 +128,12 @@ export declare function clearGlobalCdsModulePromiseCache(): void;
|
|
|
127
128
|
* @returns - found cap service name
|
|
128
129
|
*/
|
|
129
130
|
export declare function getCapServiceName(projectRoot: string, datasourceUri: string): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Delete application from CAP project.
|
|
133
|
+
*
|
|
134
|
+
* @param appPath - path to the application in a CAP project
|
|
135
|
+
* @param [memFs] - optional mem-fs-editor instance
|
|
136
|
+
* @param [logger] - function to log messages (optional)
|
|
137
|
+
*/
|
|
138
|
+
export declare function deleteCapApp(appPath: string, memFs?: Editor, logger?: Logger): Promise<void>;
|
|
130
139
|
//# sourceMappingURL=cap.d.ts.map
|
package/dist/project/cap.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCapServiceName = exports.clearGlobalCdsModulePromiseCache = exports.toReferenceUri = exports.toAbsoluteUri = exports.clearCdsModuleCache = exports.getCapEnvironment = exports.readCapServiceMetadataEdmx = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapModelAndServices = exports.getCapCustomPaths = exports.isCapProject = exports.getCapProjectType = exports.isCapJavaProject = exports.isCapNodeJsProject = void 0;
|
|
3
|
+
exports.deleteCapApp = exports.getCapServiceName = exports.clearGlobalCdsModulePromiseCache = exports.toReferenceUri = exports.toAbsoluteUri = exports.clearCdsModuleCache = exports.getCapEnvironment = exports.readCapServiceMetadataEdmx = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapModelAndServices = exports.getCapCustomPaths = exports.isCapProject = exports.getCapProjectType = exports.isCapJavaProject = exports.isCapNodeJsProject = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const file_1 = require("../file");
|
|
8
8
|
const module_loader_1 = require("./module-loader");
|
|
9
|
+
const search_1 = require("./search");
|
|
9
10
|
/**
|
|
10
11
|
* Returns true if the project is a CAP Node.js project.
|
|
11
12
|
*
|
|
@@ -604,4 +605,80 @@ async function getCapServiceName(projectRoot, datasourceUri) {
|
|
|
604
605
|
return service.name;
|
|
605
606
|
}
|
|
606
607
|
exports.getCapServiceName = getCapServiceName;
|
|
608
|
+
/**
|
|
609
|
+
* Method cleans up cds files after deletion of passed appName.
|
|
610
|
+
*
|
|
611
|
+
* @param cdsFilePaths - cds files to cleanup
|
|
612
|
+
* @param appName - CAP application name
|
|
613
|
+
* @param memFs - optional mem-fs-editor instance
|
|
614
|
+
* @param logger - function to log messages (optional)
|
|
615
|
+
*/
|
|
616
|
+
async function cleanupCdsFiles(cdsFilePaths, appName, memFs, logger) {
|
|
617
|
+
const usingEntry = `using from './${appName}/annotations';`;
|
|
618
|
+
for (const cdsFilePath of cdsFilePaths) {
|
|
619
|
+
if (await (0, file_1.fileExists)(cdsFilePath, memFs)) {
|
|
620
|
+
try {
|
|
621
|
+
let cdsFile = await (0, file_1.readFile)(cdsFilePath, memFs);
|
|
622
|
+
if (cdsFile.indexOf(usingEntry) !== -1) {
|
|
623
|
+
logger?.info(`Removing using statement for './${appName}/annotations' from '${cdsFilePath}'.`);
|
|
624
|
+
cdsFile = cdsFile.replace(usingEntry, '');
|
|
625
|
+
if (cdsFile.replace(/\n/g, '').trim() === '') {
|
|
626
|
+
logger?.info(`File '${cdsFilePath}' is now empty, removing it.`);
|
|
627
|
+
await (0, file_1.deleteFile)(cdsFilePath, memFs);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
await (0, file_1.writeFile)(cdsFilePath, cdsFile, memFs);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
logger?.error(`Could not modify file '${cdsFilePath}'. Skipping this file.`);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Delete application from CAP project.
|
|
642
|
+
*
|
|
643
|
+
* @param appPath - path to the application in a CAP project
|
|
644
|
+
* @param [memFs] - optional mem-fs-editor instance
|
|
645
|
+
* @param [logger] - function to log messages (optional)
|
|
646
|
+
*/
|
|
647
|
+
async function deleteCapApp(appPath, memFs, logger) {
|
|
648
|
+
const appName = (0, path_1.basename)(appPath);
|
|
649
|
+
const projectRoot = await (0, search_1.findCapProjectRoot)(appPath);
|
|
650
|
+
if (!projectRoot) {
|
|
651
|
+
const message = `Project root was not found for CAP application with path '${appPath}'`;
|
|
652
|
+
logger?.error(message);
|
|
653
|
+
throw Error(message);
|
|
654
|
+
}
|
|
655
|
+
const packageJsonPath = (0, path_1.join)(projectRoot, constants_1.FileName.Package);
|
|
656
|
+
const packageJson = await (0, file_1.readJSON)(packageJsonPath, memFs);
|
|
657
|
+
const cdsFilePaths = [(0, path_1.join)((0, path_1.dirname)(appPath), constants_1.FileName.ServiceCds), (0, path_1.join)((0, path_1.dirname)(appPath), constants_1.FileName.IndexCds)];
|
|
658
|
+
logger?.info(`Deleting app '${appName}' from CAP project '${projectRoot}'.`);
|
|
659
|
+
// Update `sapux` array if presented in package.json
|
|
660
|
+
if (Array.isArray(packageJson.sapux)) {
|
|
661
|
+
const posixAppPath = appPath.replace(/\\/g, '/');
|
|
662
|
+
packageJson.sapux = packageJson.sapux.filter((a) => !posixAppPath.endsWith(a.replace(/\\/g, '/')));
|
|
663
|
+
if (packageJson.sapux.length === 0) {
|
|
664
|
+
logger?.info(`This was the last app in this CAP project. Deleting property 'sapux' from '${packageJsonPath}'.`);
|
|
665
|
+
delete packageJson.sapux;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (packageJson.scripts?.[`watch-${appName}`]) {
|
|
669
|
+
delete packageJson.scripts[`watch-${appName}`];
|
|
670
|
+
}
|
|
671
|
+
await (0, file_1.updatePackageJSON)(packageJsonPath, packageJson, memFs);
|
|
672
|
+
logger?.info(`File '${packageJsonPath}' updated.`);
|
|
673
|
+
await (0, file_1.deleteDirectory)(appPath, memFs);
|
|
674
|
+
logger?.info(`Directory '${appPath}' deleted.`);
|
|
675
|
+
// Cleanup app/service.cds and app/index.cds files
|
|
676
|
+
await cleanupCdsFiles(cdsFilePaths, appName, memFs, logger);
|
|
677
|
+
// Check if app folder is now empty
|
|
678
|
+
if ((await (0, file_1.readDirectory)((0, path_1.dirname)(appPath))).length === 0) {
|
|
679
|
+
logger?.info(`Directory '${(0, path_1.dirname)(appPath)}' is now empty. Deleting it.`);
|
|
680
|
+
await (0, file_1.deleteDirectory)((0, path_1.dirname)(appPath), memFs);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
exports.deleteCapApp = deleteCapApp;
|
|
607
684
|
//# sourceMappingURL=cap.js.map
|
package/dist/project/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, isCapProject, isCapJavaProject, isCapNodeJsProject,
|
|
1
|
+
export { clearCdsModuleCache, deleteCapApp, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCapServiceName, getCdsFiles, getCdsRoots, getCdsServices, isCapProject, isCapJavaProject, isCapNodeJsProject, readCapServiceMetadataEdmx, toReferenceUri } from './cap';
|
|
2
2
|
export { filterDataSourcesByType } from './service';
|
|
3
3
|
export { addPackageDevDependency, getNodeModulesPath } from './dependencies';
|
|
4
4
|
export { getCapI18nFolderNames, getI18nPropertiesPaths } from './i18n';
|
package/dist/project/index.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.refreshSpecificationDistTags = exports.getSpecificationPath = exports.getSpecification = exports.hasUI5CliV3 = exports.updatePackageScript = exports.createProjectAccess = exports.createApplicationAccess = exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.findRootsForPath = exports.findCapProjectRoot = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.getNodeModulesPath = exports.addPackageDevDependency = exports.filterDataSourcesByType = exports.
|
|
3
|
+
exports.refreshSpecificationDistTags = exports.getSpecificationPath = exports.getSpecification = exports.hasUI5CliV3 = exports.updatePackageScript = exports.createProjectAccess = exports.createApplicationAccess = exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.findRootsForPath = exports.findCapProjectRoot = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getMinimumUI5Version = exports.getMinUI5VersionAsArray = exports.getMinUI5VersionFromManifest = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nPropertiesPaths = exports.getCapI18nFolderNames = exports.getNodeModulesPath = exports.addPackageDevDependency = exports.filterDataSourcesByType = exports.toReferenceUri = exports.readCapServiceMetadataEdmx = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.isCapProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapServiceName = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.deleteCapApp = exports.clearCdsModuleCache = void 0;
|
|
4
4
|
var cap_1 = require("./cap");
|
|
5
|
+
Object.defineProperty(exports, "clearCdsModuleCache", { enumerable: true, get: function () { return cap_1.clearCdsModuleCache; } });
|
|
6
|
+
Object.defineProperty(exports, "deleteCapApp", { enumerable: true, get: function () { return cap_1.deleteCapApp; } });
|
|
5
7
|
Object.defineProperty(exports, "getCapCustomPaths", { enumerable: true, get: function () { return cap_1.getCapCustomPaths; } });
|
|
8
|
+
Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: function () { return cap_1.getCapEnvironment; } });
|
|
6
9
|
Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return cap_1.getCapModelAndServices; } });
|
|
7
10
|
Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: function () { return cap_1.getCapProjectType; } });
|
|
11
|
+
Object.defineProperty(exports, "getCapServiceName", { enumerable: true, get: function () { return cap_1.getCapServiceName; } });
|
|
8
12
|
Object.defineProperty(exports, "getCdsFiles", { enumerable: true, get: function () { return cap_1.getCdsFiles; } });
|
|
9
13
|
Object.defineProperty(exports, "getCdsRoots", { enumerable: true, get: function () { return cap_1.getCdsRoots; } });
|
|
10
14
|
Object.defineProperty(exports, "getCdsServices", { enumerable: true, get: function () { return cap_1.getCdsServices; } });
|
|
11
15
|
Object.defineProperty(exports, "isCapProject", { enumerable: true, get: function () { return cap_1.isCapProject; } });
|
|
12
16
|
Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return cap_1.isCapJavaProject; } });
|
|
13
17
|
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return cap_1.isCapNodeJsProject; } });
|
|
14
|
-
Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: function () { return cap_1.getCapEnvironment; } });
|
|
15
18
|
Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return cap_1.readCapServiceMetadataEdmx; } });
|
|
16
|
-
Object.defineProperty(exports, "getCapServiceName", { enumerable: true, get: function () { return cap_1.getCapServiceName; } });
|
|
17
19
|
Object.defineProperty(exports, "toReferenceUri", { enumerable: true, get: function () { return cap_1.toReferenceUri; } });
|
|
18
|
-
Object.defineProperty(exports, "clearCdsModuleCache", { enumerable: true, get: function () { return cap_1.clearCdsModuleCache; } });
|
|
19
20
|
var service_1 = require("./service");
|
|
20
21
|
Object.defineProperty(exports, "filterDataSourcesByType", { enumerable: true, get: function () { return service_1.filterDataSourcesByType; } });
|
|
21
22
|
var dependencies_1 = require("./dependencies");
|