@sap-ux/project-access 2.1.5 → 2.1.7

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.
@@ -141,7 +141,7 @@ class ApplicationAccessImp {
141
141
  * @returns - instance of @sap/ux-specification
142
142
  */
143
143
  async getSpecification() {
144
- return getSpecification(this.app.appRoot);
144
+ return getSpecification(this.app.appRoot, { memFs: this.options?.fs });
145
145
  }
146
146
  /**
147
147
  * Updates package.json file asynchronously by keeping the previous indentation.
@@ -1,14 +1,17 @@
1
1
  import type { Logger } from '@sap-ux/logger';
2
+ import type { Editor } from 'mem-fs-editor';
2
3
  /**
3
4
  * Loads the specification module from cache and returns it.
4
5
  *
5
6
  * @param root - root path of the project/app
6
7
  * @param [options] - optional options
7
8
  * @param [options.logger] - logger instance
9
+ * @param [options.memFs] - optional mem-fs editor instance
8
10
  * @returns - specification instance
9
11
  */
10
12
  export declare function getSpecificationModuleFromCache<T>(root: string, options?: {
11
13
  logger?: Logger;
14
+ memFs?: Editor;
12
15
  }): Promise<T>;
13
16
  /**
14
17
  * Loads and return specification from project or cache.
@@ -18,10 +21,12 @@ export declare function getSpecificationModuleFromCache<T>(root: string, options
18
21
  * @param root - root path of the project/app
19
22
  * @param [options] - optional options
20
23
  * @param [options.logger] - logger instance
24
+ * @param [options.memFs] - optional mem-fs editor instance
21
25
  * @returns - specification instance
22
26
  */
23
27
  export declare function getSpecification<T>(root: string, options?: {
24
28
  logger?: Logger;
29
+ memFs?: Editor;
25
30
  }): Promise<T>;
26
31
  /**
27
32
  * Refreshes the specification dist-tags cache. Also cleans specification modules in cache that are not required anymore.
@@ -39,9 +44,11 @@ export declare function refreshSpecificationDistTags(options?: {
39
44
  * @param root - root path of the project/app
40
45
  * @param [options] - optional options
41
46
  * @param [options.logger] - optional logger instance
47
+ * @param [options.memFs] - optional mem-fs editor instance
42
48
  * @returns - path to specification
43
49
  */
44
50
  export declare function getSpecificationPath(root: string, options?: {
45
51
  logger?: Logger;
52
+ memFs?: Editor;
46
53
  }): Promise<string>;
47
54
  //# sourceMappingURL=specification.d.ts.map
@@ -16,17 +16,19 @@ const specificationDistTagPath = join(fioriToolsDirectory, FileName.Specificatio
16
16
  * @param root - root path of the project/app
17
17
  * @param [options] - optional options
18
18
  * @param [options.logger] - logger instance
19
+ * @param [options.memFs] - optional mem-fs editor instance
19
20
  * @returns - specification instance
20
21
  */
21
22
  async function getProjectDistTag(root, options) {
22
23
  let distTag = 'latest';
23
24
  try {
24
- const webappPath = await getWebappPath(root);
25
- const manifest = await readJSON(join(webappPath, FileName.Manifest));
25
+ const memFs = options?.memFs;
26
+ const webappPath = await getWebappPath(root, memFs);
27
+ const manifest = await readJSON(join(webappPath, FileName.Manifest), memFs);
26
28
  const minUI5Version = getMinimumUI5Version(manifest);
27
29
  if (minUI5Version && valid(minUI5Version)) {
28
- const [mayor, minor] = minUI5Version.split('.');
29
- distTag = `UI5-${mayor}.${minor}`;
30
+ const [major, minor] = minUI5Version.split('.');
31
+ distTag = `UI5-${major}.${minor}`;
30
32
  }
31
33
  }
32
34
  catch (error) {
@@ -38,10 +40,12 @@ async function getProjectDistTag(root, options) {
38
40
  * Checks if package.json contains dev dependency to specification.
39
41
  *
40
42
  * @param root - root path of the project/app
43
+ * @param [options] - optional options
44
+ * @param [options.memFs] - optional mem-fs editor instance
41
45
  * @returns If dev dependency to specification is found in package.json
42
46
  */
43
- async function hasSpecificationDevDependency(root) {
44
- const packageJson = await readJSON(join(root, FileName.Package));
47
+ async function hasSpecificationDevDependency(root, options) {
48
+ const packageJson = await readJSON(join(root, FileName.Package), options?.memFs);
45
49
  return !!packageJson.devDependencies?.['@sap/ux-specification'];
46
50
  }
47
51
  /**
@@ -50,12 +54,13 @@ async function hasSpecificationDevDependency(root) {
50
54
  * @param root - root path of the project/app
51
55
  * @param [options] - optional options
52
56
  * @param [options.logger] - logger instance
57
+ * @param [options.memFs] - optional mem-fs editor instance
53
58
  * @returns - specification instance
54
59
  */
55
60
  export async function getSpecificationModuleFromCache(root, options) {
56
- const logger = options?.logger;
61
+ const { logger, memFs } = options ?? {};
57
62
  let specification;
58
- const version = await getSpecificationVersion(root, { logger });
63
+ const version = await getSpecificationVersion(root, { logger, memFs });
59
64
  try {
60
65
  specification = await getSpecificationByVersion(version, { logger });
61
66
  logger?.debug(`Specification loaded from cache using version '${version}'`);
@@ -74,12 +79,13 @@ export async function getSpecificationModuleFromCache(root, options) {
74
79
  * @param root - root path of the project/app
75
80
  * @param [options] - optional options
76
81
  * @param [options.logger] - logger instance
82
+ * @param [options.memFs] - optional mem-fs editor instance
77
83
  * @returns - specification instance
78
84
  */
79
85
  export async function getSpecification(root, options) {
80
- const logger = options?.logger;
86
+ const { logger, memFs } = options ?? {};
81
87
  try {
82
- if (await hasSpecificationDevDependency(root)) {
88
+ if (await hasSpecificationDevDependency(root, { memFs })) {
83
89
  logger?.debug(`Specification found in devDependencies of project '${root}', trying to load`);
84
90
  // Early return with load module from project. If it throws an error it is not handled here.
85
91
  return loadModuleFromProject(root, '@sap/ux-specification');
@@ -88,7 +94,7 @@ export async function getSpecification(root, options) {
88
94
  catch {
89
95
  logger?.debug(`Specification not found in project '${root}', trying to load from cache`);
90
96
  }
91
- return await getSpecificationModuleFromCache(root, { logger });
97
+ return await getSpecificationModuleFromCache(root, { logger, memFs });
92
98
  }
93
99
  /**
94
100
  * Refreshes the specification dist-tags cache. Also cleans specification modules in cache that are not required anymore.
@@ -177,11 +183,12 @@ async function convertDistTagToVersion(distTag, options) {
177
183
  * @param root - root path of the project/app
178
184
  * @param [options] - optional options
179
185
  * @param [options.logger] - optional logger instance
186
+ * @param [options.memFs] - optional mem-fs editor instance
180
187
  * @returns - version of specification
181
188
  */
182
189
  async function getSpecificationVersion(root, options) {
183
- const logger = options?.logger;
184
- const distTag = await getProjectDistTag(root, { logger });
190
+ const { logger, memFs } = options ?? {};
191
+ const distTag = await getProjectDistTag(root, { logger, memFs });
185
192
  return await convertDistTagToVersion(distTag, { logger });
186
193
  }
187
194
  /**
@@ -191,12 +198,13 @@ async function getSpecificationVersion(root, options) {
191
198
  * @param root - root path of the project/app
192
199
  * @param [options] - optional options
193
200
  * @param [options.logger] - optional logger instance
201
+ * @param [options.memFs] - optional mem-fs editor instance
194
202
  * @returns - path to specification
195
203
  */
196
204
  export async function getSpecificationPath(root, options) {
197
- const logger = options?.logger;
205
+ const { logger, memFs } = options ?? {};
198
206
  const moduleName = '@sap/ux-specification';
199
- if (await hasSpecificationDevDependency(root)) {
207
+ if (await hasSpecificationDevDependency(root, { memFs })) {
200
208
  const nodeModulesParent = getNodeModulesPath(root, moduleName);
201
209
  if (!nodeModulesParent) {
202
210
  throw new Error(`Module '${moduleName}' not found in node_modules for project '${root}'`);
@@ -204,8 +212,8 @@ export async function getSpecificationPath(root, options) {
204
212
  logger?.debug(`Specification root found in project '${root}'`);
205
213
  return join(nodeModulesParent, 'node_modules', moduleName);
206
214
  }
207
- await getSpecificationModuleFromCache(root, { logger });
208
- const version = await getSpecificationVersion(root, { logger });
215
+ await getSpecificationModuleFromCache(root, { logger, memFs });
216
+ const version = await getSpecificationVersion(root, { logger, memFs });
209
217
  logger?.debug(`Specification not found in project '${root}', using path from cache with version '${version}'`);
210
218
  const moduleRoot = join(moduleCacheRoot, moduleName, version);
211
219
  const nodeModulesParent = getNodeModulesPath(moduleRoot, moduleName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "type": "module",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "mem-fs-editor": "9.4.0",
33
33
  "semver": "7.8.4",
34
34
  "@sap-ux/i18n": "1.0.2",
35
- "@sap-ux/ui5-config": "1.0.4"
35
+ "@sap-ux/ui5-config": "1.0.5"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@jest/globals": "30.4.1",
@@ -41,7 +41,7 @@
41
41
  "@types/mem-fs-editor": "7.0.1",
42
42
  "@types/semver": "7.7.1",
43
43
  "vscode-uri": "3.1.0",
44
- "@sap-ux/logger": "1.0.2"
44
+ "@sap-ux/logger": "1.0.3"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc --build",