@sap-ux/project-access 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/LICENSE +201 -0
- package/README.md +22 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +11 -0
- package/dist/file/file-access.d.ts +26 -0
- package/dist/file/file-access.js +74 -0
- package/dist/file/file-search.d.ts +40 -0
- package/dist/file/file-search.js +105 -0
- package/dist/file/index.d.ts +3 -0
- package/dist/file/index.js +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +27 -0
- package/dist/project/cap.d.ts +42 -0
- package/dist/project/cap.js +118 -0
- package/dist/project/dependencies.d.ts +10 -0
- package/dist/project/dependencies.js +13 -0
- package/dist/project/index.d.ts +5 -0
- package/dist/project/index.js +17 -0
- package/dist/project/module-loader.d.ts +9 -0
- package/dist/project/module-loader.js +53 -0
- package/dist/project/search.d.ts +23 -0
- package/dist/project/search.js +238 -0
- package/dist/project/ui5-config.d.ts +8 -0
- package/dist/project/ui5-config.js +40 -0
- package/dist/types/cap/index.d.ts +136 -0
- package/dist/types/cap/index.js +3 -0
- package/dist/types/find/index.d.ts +8 -0
- package/dist/types/find/index.js +3 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +18 -0
- package/dist/types/package/basic.d.ts +47 -0
- package/dist/types/package/basic.js +3 -0
- package/dist/types/package/index.d.ts +12 -0
- package/dist/types/package/index.js +3 -0
- package/dist/types/package/literal-union.d.ts +32 -0
- package/dist/types/package/literal-union.js +3 -0
- package/dist/types/package/package-json.d.ts +510 -0
- package/dist/types/package/package-json.js +3 -0
- package/dist/types/package/primitive.d.ts +7 -0
- package/dist/types/package/primitive.js +3 -0
- package/dist/types/vscode/index.d.ts +10 -0
- package/dist/types/vscode/index.js +3 -0
- package/dist/types/webapp/index.d.ts +4 -0
- package/dist/types/webapp/index.js +3 -0
- package/dist/types/webapp/manifest.d.ts +2823 -0
- package/dist/types/webapp/manifest.js +4 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @sap-ux/project-access
|
|
2
|
+
|
|
3
|
+
Library that offers functions to find, read, and retrieve project information and artifacts.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
Npm
|
|
8
|
+
`npm install --save @sap-ux/project-access`
|
|
9
|
+
|
|
10
|
+
Yarn
|
|
11
|
+
`yarn add @sap-ux/project-access`
|
|
12
|
+
|
|
13
|
+
Pnpm
|
|
14
|
+
`pnpm add @sap-ux/project-access`
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
See usage in `test/` folder.
|
|
18
|
+
|
|
19
|
+
## Keywords
|
|
20
|
+
* SAP Fiori tools
|
|
21
|
+
* SAP Fiori elements
|
|
22
|
+
* SAP Fiori freestyle
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FileName: {
|
|
2
|
+
readonly Manifest: "manifest.json";
|
|
3
|
+
readonly Package: "package.json";
|
|
4
|
+
readonly Ui5Yaml: "ui5.yaml";
|
|
5
|
+
readonly Ui5LocalYaml: "ui5-local.yaml";
|
|
6
|
+
readonly Ui5MockYaml: "ui5-mock.yaml";
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileName = void 0;
|
|
4
|
+
exports.FileName = {
|
|
5
|
+
Manifest: 'manifest.json',
|
|
6
|
+
Package: 'package.json',
|
|
7
|
+
Ui5Yaml: 'ui5.yaml',
|
|
8
|
+
Ui5LocalYaml: 'ui5-local.yaml',
|
|
9
|
+
Ui5MockYaml: 'ui5-mock.yaml'
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
/**
|
|
3
|
+
* Read file asynchronously. Throws error if file does not exist.
|
|
4
|
+
*
|
|
5
|
+
* @param path - path to file
|
|
6
|
+
* @param memFs - optional mem-fs-editor instance
|
|
7
|
+
* @returns - file content as string
|
|
8
|
+
*/
|
|
9
|
+
export declare function readFile(path: string, memFs?: Editor): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Read JSON file asynchronously. Throws error if file does not exist or is malformatted.
|
|
12
|
+
*
|
|
13
|
+
* @param path - path to JSON file
|
|
14
|
+
* @param memFs - optional mem-fs-editor instance
|
|
15
|
+
* @returns - file content as object of type T
|
|
16
|
+
*/
|
|
17
|
+
export declare function readJSON<T>(path: string, memFs?: Editor): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the provided file exists in the file system.
|
|
20
|
+
*
|
|
21
|
+
* @param path - the file path to check
|
|
22
|
+
* @param memFs - optional mem-fs-editor instance
|
|
23
|
+
* @returns - true if the file exists; false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fileExists(path: string, memFs?: Editor): Promise<boolean>;
|
|
26
|
+
//# sourceMappingURL=file-access.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fileExists = exports.readJSON = exports.readFile = void 0;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
/**
|
|
15
|
+
* Read file asynchronously. Throws error if file does not exist.
|
|
16
|
+
*
|
|
17
|
+
* @param path - path to file
|
|
18
|
+
* @param memFs - optional mem-fs-editor instance
|
|
19
|
+
* @returns - file content as string
|
|
20
|
+
*/
|
|
21
|
+
function readFile(path, memFs) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (memFs) {
|
|
24
|
+
return memFs.read(path);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return fs_1.promises.readFile(path, { encoding: 'utf8' });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.readFile = readFile;
|
|
32
|
+
/**
|
|
33
|
+
* Read JSON file asynchronously. Throws error if file does not exist or is malformatted.
|
|
34
|
+
*
|
|
35
|
+
* @param path - path to JSON file
|
|
36
|
+
* @param memFs - optional mem-fs-editor instance
|
|
37
|
+
* @returns - file content as object of type T
|
|
38
|
+
*/
|
|
39
|
+
function readJSON(path, memFs) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (memFs) {
|
|
42
|
+
return memFs.readJSON(path);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return JSON.parse(yield readFile(path));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.readJSON = readJSON;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if the provided file exists in the file system.
|
|
52
|
+
*
|
|
53
|
+
* @param path - the file path to check
|
|
54
|
+
* @param memFs - optional mem-fs-editor instance
|
|
55
|
+
* @returns - true if the file exists; false otherwise.
|
|
56
|
+
*/
|
|
57
|
+
function fileExists(path, memFs) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
try {
|
|
60
|
+
if (memFs) {
|
|
61
|
+
return memFs.exists(path);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
yield fs_1.promises.access(path);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (_a) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.fileExists = fileExists;
|
|
74
|
+
//# sourceMappingURL=file-access.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
/**
|
|
3
|
+
* Add missing dump function declaration as mem-fs-editor types do not expose this.
|
|
4
|
+
*/
|
|
5
|
+
declare module 'mem-fs-editor' {
|
|
6
|
+
type FileMap = {
|
|
7
|
+
[key: string]: {
|
|
8
|
+
state: 'modified' | 'deleted';
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
interface Editor {
|
|
12
|
+
/**
|
|
13
|
+
* Dump files to compare expected result. Provide a cwd for relative path.
|
|
14
|
+
* See also https://github.com/SBoudrias/mem-fs-editor#dumpcwd-filter for further details.
|
|
15
|
+
*
|
|
16
|
+
* @param [cwd] - optional, relative path
|
|
17
|
+
*/
|
|
18
|
+
dump(cwd?: string): FileMap;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Search for 'filename' starting from 'root'. Returns array of paths that contain the file.
|
|
23
|
+
*
|
|
24
|
+
* @param filename - filename to search
|
|
25
|
+
* @param root - root folder to start search
|
|
26
|
+
* @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
|
|
27
|
+
* @param fs - optional mem-fs-editor instance
|
|
28
|
+
* @returns - array of paths that contain the filename
|
|
29
|
+
*/
|
|
30
|
+
export declare function findFiles(filename: string, root: string, excludeFolders: string[], fs?: Editor): Promise<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Find a file by name in parent folders starting from 'startPath'.
|
|
33
|
+
*
|
|
34
|
+
* @param fileName - file name to look for
|
|
35
|
+
* @param startPath - path for start searching up
|
|
36
|
+
* @param fs - optional mem-fs-editor instance
|
|
37
|
+
* @returns - path to file name if found, otherwise undefined
|
|
38
|
+
*/
|
|
39
|
+
export declare function findFileUp(fileName: string, startPath: string, fs?: Editor): Promise<string | undefined>;
|
|
40
|
+
//# sourceMappingURL=file-search.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.findFileUp = exports.findFiles = void 0;
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const findit2_1 = __importDefault(require("findit2"));
|
|
18
|
+
const file_access_1 = require("./file-access");
|
|
19
|
+
/**
|
|
20
|
+
* Creates a filter function that removes files that have been deleted in an instance of a mem-fs-editor.
|
|
21
|
+
*
|
|
22
|
+
* @param changes - changes recorded in an instance of a mem-fs-editor
|
|
23
|
+
* @param filename - relevant filename
|
|
24
|
+
* @returns a filter function for string arrays
|
|
25
|
+
*/
|
|
26
|
+
function getMemFsFilter(changes, filename) {
|
|
27
|
+
const deleted = Object.entries(changes)
|
|
28
|
+
.filter(([, info]) => info.state === 'deleted')
|
|
29
|
+
.map(([file]) => path_1.join(path_1.basename(path_1.join(file)) === filename ? path_1.dirname(file) : file));
|
|
30
|
+
return (path) => !deleted.find((entry) => path.startsWith(entry));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Concatanates the given list of files with additional files that have been created using a mem-fs-editor and matching the filename.
|
|
34
|
+
*
|
|
35
|
+
* @param folders - existing list of folders
|
|
36
|
+
* @param changes - changes recorded in an instance of a mem-fs-editor
|
|
37
|
+
* @param filename - relevant filename
|
|
38
|
+
* @returns Concatanated and deduped list of folders containing the given filename
|
|
39
|
+
*/
|
|
40
|
+
function concatNewFoldersFromMemFs(folders, changes, filename) {
|
|
41
|
+
const modified = Object.entries(changes)
|
|
42
|
+
.filter(([file, info]) => info.state === 'modified' && path_1.basename(path_1.join(file)) === filename)
|
|
43
|
+
.map(([file]) => path_1.dirname(path_1.join(file)));
|
|
44
|
+
return [...new Set([...folders, ...modified])];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Search for 'filename' starting from 'root'. Returns array of paths that contain the file.
|
|
48
|
+
*
|
|
49
|
+
* @param filename - filename to search
|
|
50
|
+
* @param root - root folder to start search
|
|
51
|
+
* @param excludeFolders - list of folder names to exclude (search doesn't traverse into these folders)
|
|
52
|
+
* @param fs - optional mem-fs-editor instance
|
|
53
|
+
* @returns - array of paths that contain the filename
|
|
54
|
+
*/
|
|
55
|
+
function findFiles(filename, root, excludeFolders, fs) {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const results = [];
|
|
58
|
+
const finder = findit2_1.default(root);
|
|
59
|
+
finder.on('directory', (dir, _stat, stop) => {
|
|
60
|
+
const base = path_1.basename(dir);
|
|
61
|
+
if (excludeFolders.includes(base)) {
|
|
62
|
+
stop();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
finder.on('file', (file) => {
|
|
66
|
+
if (file.endsWith(path_1.sep + filename)) {
|
|
67
|
+
results.push(path_1.dirname(file));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
finder.on('end', () => {
|
|
71
|
+
if (fs) {
|
|
72
|
+
const changes = fs.dump('');
|
|
73
|
+
resolve(concatNewFoldersFromMemFs(results, changes, filename).filter(getMemFsFilter(changes, filename)));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolve(results);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
finder.on('error', (error) => {
|
|
80
|
+
reject(error);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
exports.findFiles = findFiles;
|
|
85
|
+
/**
|
|
86
|
+
* Find a file by name in parent folders starting from 'startPath'.
|
|
87
|
+
*
|
|
88
|
+
* @param fileName - file name to look for
|
|
89
|
+
* @param startPath - path for start searching up
|
|
90
|
+
* @param fs - optional mem-fs-editor instance
|
|
91
|
+
* @returns - path to file name if found, otherwise undefined
|
|
92
|
+
*/
|
|
93
|
+
function findFileUp(fileName, startPath, fs) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const filePath = path_1.join(startPath, fileName);
|
|
96
|
+
if (yield file_access_1.fileExists(filePath, fs)) {
|
|
97
|
+
return filePath;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return path_1.dirname(startPath) !== startPath ? findFileUp(fileName, path_1.dirname(startPath), fs) : undefined;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.findFileUp = findFileUp;
|
|
105
|
+
//# sourceMappingURL=file-search.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFileUp = exports.findFiles = exports.readJSON = exports.readFile = exports.fileExists = void 0;
|
|
4
|
+
var file_access_1 = require("./file-access");
|
|
5
|
+
Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return file_access_1.fileExists; } });
|
|
6
|
+
Object.defineProperty(exports, "readFile", { enumerable: true, get: function () { return file_access_1.readFile; } });
|
|
7
|
+
Object.defineProperty(exports, "readJSON", { enumerable: true, get: function () { return file_access_1.readJSON; } });
|
|
8
|
+
var file_search_1 = require("./file-search");
|
|
9
|
+
Object.defineProperty(exports, "findFiles", { enumerable: true, get: function () { return file_search_1.findFiles; } });
|
|
10
|
+
Object.defineProperty(exports, "findFileUp", { enumerable: true, get: function () { return file_search_1.findFileUp; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { FileName } from './constants';
|
|
2
|
+
export { findAllApps, findProjectRoot, getAppRootFromWebappPath, getCapModelAndServices, getCapProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject } from './project';
|
|
3
|
+
export * from './types';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findAllApps = exports.FileName = void 0;
|
|
14
|
+
var constants_1 = require("./constants");
|
|
15
|
+
Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
|
|
16
|
+
var project_1 = require("./project");
|
|
17
|
+
Object.defineProperty(exports, "findAllApps", { enumerable: true, get: function () { return project_1.findAllApps; } });
|
|
18
|
+
Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return project_1.findProjectRoot; } });
|
|
19
|
+
Object.defineProperty(exports, "getAppRootFromWebappPath", { enumerable: true, get: function () { return project_1.getAppRootFromWebappPath; } });
|
|
20
|
+
Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return project_1.getCapModelAndServices; } });
|
|
21
|
+
Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: function () { return project_1.getCapProjectType; } });
|
|
22
|
+
Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return project_1.getWebappPath; } });
|
|
23
|
+
Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return project_1.isCapJavaProject; } });
|
|
24
|
+
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return project_1.isCapNodeJsProject; } });
|
|
25
|
+
Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return project_1.loadModuleFromProject; } });
|
|
26
|
+
__exportStar(require("./types"), exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CapCustomPaths, CapProjectType, csn, Package } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the project is a CAP Node.js project.
|
|
4
|
+
*
|
|
5
|
+
* @param packageJson - the parsed package.json object
|
|
6
|
+
* @returns - true if the project is a CAP Node.js project
|
|
7
|
+
*/
|
|
8
|
+
export declare function isCapNodeJsProject(packageJson: Package): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if the project is a CAP Java project.
|
|
11
|
+
*
|
|
12
|
+
* @param projectRoot - the root path of the project
|
|
13
|
+
* @returns - true if the project is a CAP project
|
|
14
|
+
*/
|
|
15
|
+
export declare function isCapJavaProject(projectRoot: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the CAP project type, undefined if it is not a CAP project.
|
|
18
|
+
*
|
|
19
|
+
* @param projectRoot - root of the project, where the package.json resides.
|
|
20
|
+
* @returns - CAPJava for Java based CAP projects; CAPNodejs for node.js based CAP projects; undefined if it is no CAP project
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCapProjectType(projectRoot: string): Promise<CapProjectType | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Get CAP CDS project custom paths for project root.
|
|
25
|
+
*
|
|
26
|
+
* @param capProjectPath - project root of cap project
|
|
27
|
+
* @returns - paths to app, db, and srv for CAP project
|
|
28
|
+
*/
|
|
29
|
+
export declare function getCapCustomPaths(capProjectPath: string): Promise<CapCustomPaths>;
|
|
30
|
+
/**
|
|
31
|
+
* Return the CAP model and all services.
|
|
32
|
+
*
|
|
33
|
+
* @param projectRoot - CAP project root where package.json resides
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCapModelAndServices(projectRoot: string): Promise<{
|
|
36
|
+
model: csn;
|
|
37
|
+
services: {
|
|
38
|
+
name: string;
|
|
39
|
+
urlPath: string;
|
|
40
|
+
}[];
|
|
41
|
+
}>;
|
|
42
|
+
//# sourceMappingURL=cap.d.ts.map
|