@sap-ux/project-access 1.38.1 → 2.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/command/index.d.ts +1 -1
- package/dist/command/index.js +1 -5
- package/dist/command/npm-command.js +3 -6
- package/dist/constants.js +10 -13
- package/dist/file/file-access.d.ts +1 -1
- package/dist/file/file-access.js +18 -32
- package/dist/file/file-search.js +25 -35
- package/dist/file/index.d.ts +2 -2
- package/dist/file/index.js +2 -19
- package/dist/index.d.ts +10 -10
- package/dist/index.js +9 -102
- package/dist/library/constants.js +1 -4
- package/dist/library/helpers.d.ts +1 -1
- package/dist/library/helpers.js +36 -44
- package/dist/library/index.d.ts +1 -1
- package/dist/library/index.js +1 -6
- package/dist/odata/index.d.ts +1 -1
- package/dist/odata/index.js +1 -6
- package/dist/odata/metadata.js +2 -6
- package/dist/path/index.d.ts +1 -1
- package/dist/path/index.js +1 -5
- package/dist/path/normalize.js +3 -6
- package/dist/project/access.d.ts +1 -1
- package/dist/project/access.js +30 -34
- package/dist/project/cap.d.ts +1 -1
- package/dist/project/cap.js +75 -102
- package/dist/project/dependencies.d.ts +1 -1
- package/dist/project/dependencies.js +16 -22
- package/dist/project/flex-changes.js +7 -10
- package/dist/project/i18n/i18n.d.ts +1 -1
- package/dist/project/i18n/i18n.js +22 -22
- package/dist/project/i18n/index.d.ts +3 -3
- package/dist/project/i18n/index.js +3 -13
- package/dist/project/i18n/read.d.ts +1 -1
- package/dist/project/i18n/read.js +11 -15
- package/dist/project/i18n/write.d.ts +1 -1
- package/dist/project/i18n/write.js +22 -28
- package/dist/project/index.d.ts +15 -15
- package/dist/project/index.js +14 -79
- package/dist/project/info.d.ts +1 -1
- package/dist/project/info.js +45 -54
- package/dist/project/module-loader.js +27 -64
- package/dist/project/mta.d.ts +1 -1
- package/dist/project/mta.js +6 -9
- package/dist/project/script.js +11 -18
- package/dist/project/search.d.ts +1 -1
- package/dist/project/search.js +77 -86
- package/dist/project/service.d.ts +1 -1
- package/dist/project/service.js +10 -16
- package/dist/project/specification.js +38 -44
- package/dist/project/ui5-config.js +21 -29
- package/dist/project/ui5-xml-id-validator.js +3 -6
- package/dist/types/access/index.d.ts +4 -4
- package/dist/types/access/index.js +1 -2
- package/dist/types/cap/index.js +1 -2
- package/dist/types/find/index.d.ts +1 -1
- package/dist/types/find/index.js +1 -2
- package/dist/types/i18n/index.js +1 -2
- package/dist/types/index.d.ts +9 -9
- package/dist/types/index.js +9 -25
- package/dist/types/info/index.d.ts +2 -2
- package/dist/types/info/index.js +1 -2
- package/dist/types/library/index.js +5 -2
- package/dist/types/mta/index.js +1 -2
- package/dist/types/package/basic.js +1 -2
- package/dist/types/package/index.d.ts +1 -1
- package/dist/types/package/index.js +1 -2
- package/dist/types/package/literal-union.d.ts +1 -1
- package/dist/types/package/literal-union.js +1 -2
- package/dist/types/package/package-json.d.ts +2 -2
- package/dist/types/package/package-json.js +1 -2
- package/dist/types/package/primitive.js +1 -2
- package/dist/types/vscode/index.js +1 -2
- package/dist/types/webapp/index.d.ts +2 -3
- package/dist/types/webapp/index.js +1 -2
- package/package.json +7 -5
package/dist/project/info.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const constants_1 = require("../constants");
|
|
12
|
-
const file_1 = require("../file");
|
|
13
|
-
const cap_1 = require("./cap");
|
|
14
|
-
const i18n_1 = require("./i18n/i18n");
|
|
15
|
-
const search_1 = require("./search");
|
|
16
|
-
const service_1 = require("./service");
|
|
17
|
-
const ui5_config_1 = require("./ui5-config");
|
|
18
|
-
const semver_1 = require("semver");
|
|
19
|
-
const path_1 = require("../path");
|
|
1
|
+
import { join, relative } from 'node:path';
|
|
2
|
+
import { DirName, FileName } from '../constants.js';
|
|
3
|
+
import { fileExists, findFilesByExtension, readJSON } from '../file/index.js';
|
|
4
|
+
import { getCapCustomPaths, getCapProjectType } from './cap.js';
|
|
5
|
+
import { getI18nPropertiesPaths } from './i18n/i18n.js';
|
|
6
|
+
import { findAllApps, findFioriArtifacts } from './search.js';
|
|
7
|
+
import { getMainService, getServicesAndAnnotations } from './service.js';
|
|
8
|
+
import { getWebappPath } from './ui5-config.js';
|
|
9
|
+
import { gte, valid } from 'semver';
|
|
10
|
+
import { normalizePath } from '../path/index.js';
|
|
20
11
|
/**
|
|
21
12
|
* Returns the project structure for a given Fiori project.
|
|
22
13
|
*
|
|
@@ -24,17 +15,17 @@ const path_1 = require("../path");
|
|
|
24
15
|
* @param memFs - optional mem-fs-editor instance
|
|
25
16
|
* @returns - project structure with project info like project type, apps, root folder
|
|
26
17
|
*/
|
|
27
|
-
async function getProject(root, memFs) {
|
|
28
|
-
if (!(await
|
|
18
|
+
export async function getProject(root, memFs) {
|
|
19
|
+
if (!(await fileExists(join(root, FileName.Package), memFs))) {
|
|
29
20
|
throw new Error(`The project root folder '${root}' is not a Fiori project. No 'package.json' found.`);
|
|
30
21
|
}
|
|
31
|
-
const capProjectType = await
|
|
22
|
+
const capProjectType = await getCapProjectType(root);
|
|
32
23
|
const projectType = capProjectType ?? 'EDMXBackend';
|
|
33
|
-
const capCustomPaths = projectType === 'EDMXBackend' ? undefined : await
|
|
24
|
+
const capCustomPaths = projectType === 'EDMXBackend' ? undefined : await getCapCustomPaths(root);
|
|
34
25
|
const appFolders = await getAppFolders(root, memFs);
|
|
35
26
|
const apps = await getApps(root, appFolders, memFs);
|
|
36
27
|
return {
|
|
37
|
-
root:
|
|
28
|
+
root: normalizePath(root),
|
|
38
29
|
projectType,
|
|
39
30
|
apps,
|
|
40
31
|
capCustomPaths
|
|
@@ -50,8 +41,8 @@ async function getProject(root, memFs) {
|
|
|
50
41
|
* @returns - array of operating specific application folders
|
|
51
42
|
*/
|
|
52
43
|
async function getAppFolders(root, memFs) {
|
|
53
|
-
const apps = await
|
|
54
|
-
return apps.length > 0 ? apps.map((app) =>
|
|
44
|
+
const apps = await findAllApps([root], memFs);
|
|
45
|
+
return apps.length > 0 ? apps.map((app) => relative(root, app.appRoot)) : [''];
|
|
55
46
|
}
|
|
56
47
|
/**
|
|
57
48
|
* Get the application structure for each application in the project.
|
|
@@ -80,18 +71,18 @@ async function getApps(root, appFolders, memFs) {
|
|
|
80
71
|
* @returns - application structure with application info like manifest, changes, main service, services, annotations
|
|
81
72
|
*/
|
|
82
73
|
async function getApplicationStructure(root, appFolder, memFs) {
|
|
83
|
-
const appRoot =
|
|
84
|
-
const absoluteWebappPath = await
|
|
74
|
+
const appRoot = join(root, appFolder);
|
|
75
|
+
const absoluteWebappPath = await getWebappPath(appRoot, memFs);
|
|
85
76
|
const appType = (await getAppType(appRoot, memFs));
|
|
86
|
-
const manifest =
|
|
87
|
-
if (!(await
|
|
77
|
+
const manifest = join(absoluteWebappPath, FileName.Manifest);
|
|
78
|
+
if (!(await fileExists(manifest, memFs))) {
|
|
88
79
|
return undefined;
|
|
89
80
|
}
|
|
90
|
-
const manifestObject = await
|
|
91
|
-
const changes =
|
|
92
|
-
const i18n = await
|
|
93
|
-
const mainService =
|
|
94
|
-
const services = await
|
|
81
|
+
const manifestObject = await readJSON(manifest, memFs);
|
|
82
|
+
const changes = join(absoluteWebappPath, DirName.Changes);
|
|
83
|
+
const i18n = await getI18nPropertiesPaths(manifest, manifestObject, memFs);
|
|
84
|
+
const mainService = getMainService(manifestObject);
|
|
85
|
+
const services = await getServicesAndAnnotations(manifest, manifestObject, memFs);
|
|
95
86
|
return {
|
|
96
87
|
appRoot,
|
|
97
88
|
appType,
|
|
@@ -109,17 +100,17 @@ async function getApplicationStructure(root, appFolder, memFs) {
|
|
|
109
100
|
* @param [memFs] - optional mem-fs editor instance
|
|
110
101
|
* @returns - used language, JavaScript or TypeScript
|
|
111
102
|
*/
|
|
112
|
-
async function getAppProgrammingLanguage(appRoot, memFs) {
|
|
103
|
+
export async function getAppProgrammingLanguage(appRoot, memFs) {
|
|
113
104
|
const ignoreFolders = ['node_modules', '.git'];
|
|
114
105
|
let appLanguage = '';
|
|
115
106
|
try {
|
|
116
|
-
const webappPath = await
|
|
117
|
-
if (await
|
|
118
|
-
if ((await
|
|
119
|
-
(await
|
|
107
|
+
const webappPath = await getWebappPath(appRoot, memFs);
|
|
108
|
+
if (await fileExists(webappPath, memFs)) {
|
|
109
|
+
if ((await fileExists(join(appRoot, FileName.Tsconfig), memFs)) &&
|
|
110
|
+
(await findFilesByExtension('.ts', webappPath, ignoreFolders, memFs)).length > 0) {
|
|
120
111
|
appLanguage = 'TypeScript';
|
|
121
112
|
}
|
|
122
|
-
else if ((await
|
|
113
|
+
else if ((await findFilesByExtension('.js', webappPath, ignoreFolders, memFs)).length > 0) {
|
|
123
114
|
appLanguage = 'JavaScript';
|
|
124
115
|
}
|
|
125
116
|
}
|
|
@@ -136,10 +127,10 @@ async function getAppProgrammingLanguage(appRoot, memFs) {
|
|
|
136
127
|
* @param memFs - optional mem-fs-editor instance
|
|
137
128
|
* @returns - type of application, e.g. SAP Fiori elements, SAPUI5 freestyle, SAPUI5 Extension, ... see AppType.
|
|
138
129
|
*/
|
|
139
|
-
async function getAppType(appRoot, memFs) {
|
|
130
|
+
export async function getAppType(appRoot, memFs) {
|
|
140
131
|
let appType;
|
|
141
132
|
try {
|
|
142
|
-
const artifacts = await
|
|
133
|
+
const artifacts = await findFioriArtifacts({
|
|
143
134
|
wsFolders: [appRoot],
|
|
144
135
|
artifacts: ['adaptations', 'applications', 'extensions', 'libraries'],
|
|
145
136
|
memFs
|
|
@@ -177,9 +168,9 @@ async function getAppType(appRoot, memFs) {
|
|
|
177
168
|
*/
|
|
178
169
|
async function getApplicationType(application, memFs) {
|
|
179
170
|
let appType;
|
|
180
|
-
const rootPackageJsonPath =
|
|
181
|
-
const packageJson = (await
|
|
182
|
-
? await
|
|
171
|
+
const rootPackageJsonPath = join(application.projectRoot, FileName.Package);
|
|
172
|
+
const packageJson = (await fileExists(rootPackageJsonPath, memFs))
|
|
173
|
+
? await readJSON(rootPackageJsonPath, memFs)
|
|
183
174
|
: null;
|
|
184
175
|
if (application.projectRoot === application.appRoot) {
|
|
185
176
|
appType = packageJson?.sapux ? 'SAP Fiori elements' : 'SAPUI5 freestyle';
|
|
@@ -187,7 +178,7 @@ async function getApplicationType(application, memFs) {
|
|
|
187
178
|
else if (packageJson) {
|
|
188
179
|
appType =
|
|
189
180
|
Array.isArray(packageJson.sapux) &&
|
|
190
|
-
packageJson.sapux.find((relAppPath) =>
|
|
181
|
+
packageJson.sapux.find((relAppPath) => join(application.projectRoot, ...relAppPath.split(/[/\\]/)) === application.appRoot)
|
|
191
182
|
? 'SAP Fiori elements'
|
|
192
183
|
: 'SAPUI5 freestyle';
|
|
193
184
|
}
|
|
@@ -202,8 +193,8 @@ async function getApplicationType(application, memFs) {
|
|
|
202
193
|
* @param projectRoot - root path of the project
|
|
203
194
|
* @returns - project type like Edmx, CAPJava, CAPNodejs
|
|
204
195
|
*/
|
|
205
|
-
async function getProjectType(projectRoot) {
|
|
206
|
-
const capType = await
|
|
196
|
+
export async function getProjectType(projectRoot) {
|
|
197
|
+
const capType = await getCapProjectType(projectRoot);
|
|
207
198
|
if (capType === undefined) {
|
|
208
199
|
return 'EDMXBackend';
|
|
209
200
|
}
|
|
@@ -215,7 +206,7 @@ async function getProjectType(projectRoot) {
|
|
|
215
206
|
* @param manifest - manifest object
|
|
216
207
|
* @returns minUI5Version, if present
|
|
217
208
|
*/
|
|
218
|
-
function getMinUI5VersionFromManifest(manifest) {
|
|
209
|
+
export function getMinUI5VersionFromManifest(manifest) {
|
|
219
210
|
const dependencies = manifest['sap.ui5']?.dependencies;
|
|
220
211
|
if (dependencies) {
|
|
221
212
|
return dependencies.minUI5Version;
|
|
@@ -229,13 +220,13 @@ function getMinUI5VersionFromManifest(manifest) {
|
|
|
229
220
|
* @param noValidation - disables the semver validation
|
|
230
221
|
* @returns minUI5Version, as an array of strings
|
|
231
222
|
*/
|
|
232
|
-
function getMinUI5VersionAsArray(manifest, noValidation = false) {
|
|
223
|
+
export function getMinUI5VersionAsArray(manifest, noValidation = false) {
|
|
233
224
|
const result = [];
|
|
234
225
|
const minUI5Version = getMinUI5VersionFromManifest(manifest);
|
|
235
226
|
if (minUI5Version) {
|
|
236
227
|
const minUI5VersionArray = Array.isArray(minUI5Version) ? minUI5Version : [minUI5Version];
|
|
237
228
|
minUI5VersionArray.forEach((version) => {
|
|
238
|
-
if (noValidation ||
|
|
229
|
+
if (noValidation || valid(version)) {
|
|
239
230
|
result.push(version);
|
|
240
231
|
}
|
|
241
232
|
});
|
|
@@ -249,12 +240,12 @@ function getMinUI5VersionAsArray(manifest, noValidation = false) {
|
|
|
249
240
|
* @param manifest - manifest object
|
|
250
241
|
* @returns the minimum version as string
|
|
251
242
|
*/
|
|
252
|
-
function getMinimumUI5Version(manifest) {
|
|
243
|
+
export function getMinimumUI5Version(manifest) {
|
|
253
244
|
let result;
|
|
254
245
|
const validVersionsArray = getMinUI5VersionAsArray(manifest);
|
|
255
246
|
if (validVersionsArray.length > 0) {
|
|
256
247
|
validVersionsArray.forEach((version) => {
|
|
257
|
-
if (!result ||
|
|
248
|
+
if (!result || gte(result, version)) {
|
|
258
249
|
result = version;
|
|
259
250
|
}
|
|
260
251
|
});
|
|
@@ -1,48 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getModulePath = getModulePath;
|
|
37
|
-
exports.loadModuleFromProject = loadModuleFromProject;
|
|
38
|
-
exports.getModule = getModule;
|
|
39
|
-
exports.deleteModule = deleteModule;
|
|
40
|
-
const node_fs_1 = require("node:fs");
|
|
41
|
-
const promises_1 = require("node:fs/promises");
|
|
42
|
-
const node_path_1 = require("node:path");
|
|
43
|
-
const dependencies_1 = require("./dependencies");
|
|
44
|
-
const constants_1 = require("../constants");
|
|
45
|
-
const command_1 = require("../command");
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir, rm } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { getNodeModulesPath } from './dependencies.js';
|
|
6
|
+
import { FileName, moduleCacheRoot } from '../constants.js';
|
|
7
|
+
import { execNpmCommand } from '../command/index.js';
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
46
9
|
/**
|
|
47
10
|
* Get the module path from project or app. Throws error if module is not installed.
|
|
48
11
|
*
|
|
@@ -50,8 +13,8 @@ const command_1 = require("../command");
|
|
|
50
13
|
* @param moduleName - name of the node module.
|
|
51
14
|
* @returns - path to module.
|
|
52
15
|
*/
|
|
53
|
-
async function getModulePath(projectRoot, moduleName) {
|
|
54
|
-
if (!
|
|
16
|
+
export async function getModulePath(projectRoot, moduleName) {
|
|
17
|
+
if (!getNodeModulesPath(projectRoot, moduleName)) {
|
|
55
18
|
throw Error('Path to module not found.');
|
|
56
19
|
}
|
|
57
20
|
return require.resolve(moduleName, { paths: [projectRoot] });
|
|
@@ -69,11 +32,11 @@ async function getModulePath(projectRoot, moduleName) {
|
|
|
69
32
|
* @param moduleName - name of the node module.
|
|
70
33
|
* @returns - loaded module.
|
|
71
34
|
*/
|
|
72
|
-
async function loadModuleFromProject(projectRoot, moduleName) {
|
|
35
|
+
export async function loadModuleFromProject(projectRoot, moduleName) {
|
|
73
36
|
let module;
|
|
74
37
|
try {
|
|
75
38
|
const modulePath = await getModulePath(projectRoot, moduleName);
|
|
76
|
-
module = (await
|
|
39
|
+
module = (await import(modulePath));
|
|
77
40
|
}
|
|
78
41
|
catch (error) {
|
|
79
42
|
throw Error(`Module '${moduleName}' not installed in project '${projectRoot}'.\n${error.toString()}`);
|
|
@@ -89,17 +52,17 @@ async function loadModuleFromProject(projectRoot, moduleName) {
|
|
|
89
52
|
* @param options.logger - optional logger instance
|
|
90
53
|
* @returns - module
|
|
91
54
|
*/
|
|
92
|
-
async function getModule(module, version, options) {
|
|
55
|
+
export async function getModule(module, version, options) {
|
|
93
56
|
const logger = options?.logger;
|
|
94
|
-
const moduleDirectory =
|
|
95
|
-
const modulePackagePath =
|
|
57
|
+
const moduleDirectory = join(moduleCacheRoot, module, version);
|
|
58
|
+
const modulePackagePath = join(moduleDirectory, FileName.Package);
|
|
96
59
|
const installCommand = ['install', '--prefix', moduleDirectory, `${module}@${version}`];
|
|
97
|
-
if (!
|
|
98
|
-
if (
|
|
99
|
-
await
|
|
60
|
+
if (!existsSync(modulePackagePath)) {
|
|
61
|
+
if (existsSync(moduleDirectory)) {
|
|
62
|
+
await rm(moduleDirectory, { recursive: true });
|
|
100
63
|
}
|
|
101
|
-
await
|
|
102
|
-
await
|
|
64
|
+
await mkdir(moduleDirectory, { recursive: true });
|
|
65
|
+
await execNpmCommand(installCommand, {
|
|
103
66
|
cwd: moduleDirectory,
|
|
104
67
|
logger
|
|
105
68
|
});
|
|
@@ -110,11 +73,11 @@ async function getModule(module, version, options) {
|
|
|
110
73
|
}
|
|
111
74
|
catch (e) {
|
|
112
75
|
logger?.error(`Failed to load module: ${module}. Attempting to fix installation.`);
|
|
113
|
-
const modulePackageLockPath =
|
|
76
|
+
const modulePackageLockPath = join(moduleDirectory, FileName.PackageLock);
|
|
114
77
|
// If 'package-lock.json' file exists then use 'npm ci', otherwise try reinstall
|
|
115
|
-
const command =
|
|
78
|
+
const command = existsSync(modulePackageLockPath) ? ['ci'] : installCommand;
|
|
116
79
|
// Run reinstall only if the first attempt fails
|
|
117
|
-
await
|
|
80
|
+
await execNpmCommand(command, {
|
|
118
81
|
cwd: moduleDirectory,
|
|
119
82
|
logger
|
|
120
83
|
});
|
|
@@ -129,10 +92,10 @@ async function getModule(module, version, options) {
|
|
|
129
92
|
* @param module - name of the module
|
|
130
93
|
* @param version - version of the module
|
|
131
94
|
*/
|
|
132
|
-
async function deleteModule(module, version) {
|
|
133
|
-
const moduleDirectory =
|
|
134
|
-
if (
|
|
135
|
-
await
|
|
95
|
+
export async function deleteModule(module, version) {
|
|
96
|
+
const moduleDirectory = join(moduleCacheRoot, module, version);
|
|
97
|
+
if (existsSync(moduleDirectory)) {
|
|
98
|
+
await rm(moduleDirectory, { recursive: true });
|
|
136
99
|
}
|
|
137
100
|
}
|
|
138
101
|
//# sourceMappingURL=module-loader.js.map
|
package/dist/project/mta.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
|
-
import type { MtaPath } from '../types/mta';
|
|
2
|
+
import type { MtaPath } from '../types/mta/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Searches `projectPath` and parent folders.
|
|
5
5
|
* If mta.yaml file is inside projectPath, this is a special type of MTA project
|
package/dist/project/mta.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const file_search_1 = require("../file/file-search");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
1
|
+
import { findFileUp } from '../file/file-search.js';
|
|
2
|
+
import { FileName } from '../constants.js';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
7
4
|
/**
|
|
8
5
|
* Searches `projectPath` and parent folders.
|
|
9
6
|
* If mta.yaml file is inside projectPath, this is a special type of MTA project
|
|
@@ -15,13 +12,13 @@ const node_path_1 = require("node:path");
|
|
|
15
12
|
* @param fs - optional mem-fs-editor instance
|
|
16
13
|
* @returns - MtaPath
|
|
17
14
|
*/
|
|
18
|
-
async function getMtaPath(projectPath, fs) {
|
|
19
|
-
const mtaPath = await
|
|
15
|
+
export async function getMtaPath(projectPath, fs) {
|
|
16
|
+
const mtaPath = await findFileUp(FileName.MtaYaml, projectPath, fs);
|
|
20
17
|
if (!mtaPath) {
|
|
21
18
|
return undefined;
|
|
22
19
|
}
|
|
23
20
|
else {
|
|
24
|
-
const mtaFolderPath =
|
|
21
|
+
const mtaFolderPath = dirname(mtaPath);
|
|
25
22
|
return {
|
|
26
23
|
mtaPath,
|
|
27
24
|
hasRoot: mtaFolderPath !== projectPath
|
package/dist/project/script.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.updatePackageScript = updatePackageScript;
|
|
7
|
-
exports.hasUI5CliV3 = hasUI5CliV3;
|
|
8
|
-
const node_path_1 = require("node:path");
|
|
9
|
-
const constants_1 = require("../constants");
|
|
10
|
-
const file_1 = require("../file");
|
|
11
|
-
const semver_1 = __importDefault(require("semver"));
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { FileName } from '../constants.js';
|
|
3
|
+
import { readJSON, updatePackageJSON } from '../file/index.js';
|
|
4
|
+
import semVer from 'semver';
|
|
12
5
|
/**
|
|
13
6
|
* Updates the package.json with a new script.
|
|
14
7
|
*
|
|
@@ -17,14 +10,14 @@ const semver_1 = __importDefault(require("semver"));
|
|
|
17
10
|
* @param script - the script content
|
|
18
11
|
* @param fs - optional memfs editor instance
|
|
19
12
|
*/
|
|
20
|
-
async function updatePackageScript(basePath, scriptName, script, fs) {
|
|
21
|
-
const filePath =
|
|
22
|
-
const packageJson = await
|
|
13
|
+
export async function updatePackageScript(basePath, scriptName, script, fs) {
|
|
14
|
+
const filePath = join(basePath, FileName.Package);
|
|
15
|
+
const packageJson = await readJSON(filePath, fs);
|
|
23
16
|
if (!packageJson.scripts) {
|
|
24
17
|
packageJson.scripts = {};
|
|
25
18
|
}
|
|
26
19
|
packageJson.scripts[scriptName] = script;
|
|
27
|
-
await
|
|
20
|
+
await updatePackageJSON(filePath, packageJson, fs);
|
|
28
21
|
}
|
|
29
22
|
/**
|
|
30
23
|
* Check if dev dependencies contains @ui5/cli version greater than 2.
|
|
@@ -32,10 +25,10 @@ async function updatePackageScript(basePath, scriptName, script, fs) {
|
|
|
32
25
|
* @param devDependencies dev dependencies from package.json
|
|
33
26
|
* @returns boolean
|
|
34
27
|
*/
|
|
35
|
-
function hasUI5CliV3(devDependencies) {
|
|
28
|
+
export function hasUI5CliV3(devDependencies) {
|
|
36
29
|
let isV3 = false;
|
|
37
|
-
const ui5CliSemver =
|
|
38
|
-
if (ui5CliSemver &&
|
|
30
|
+
const ui5CliSemver = semVer.coerce(devDependencies['@ui5/cli']);
|
|
31
|
+
if (ui5CliSemver && semVer.gte(ui5CliSemver, '3.0.0')) {
|
|
39
32
|
isV3 = true;
|
|
40
33
|
}
|
|
41
34
|
return isV3;
|
package/dist/project/search.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
|
-
import type { AllAppResults, CapProjectType, FioriArtifactTypes, FoundFioriArtifacts, WorkspaceFolder } from '../types';
|
|
2
|
+
import type { AllAppResults, CapProjectType, FioriArtifactTypes, FoundFioriArtifacts, WorkspaceFolder } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Type that is used locally only to keep list of found files with cache of the
|
|
5
5
|
* content in order to avoid multiple file reads. It also caches result of call
|