@sap/cds-dk 4.4.2 → 4.5.4
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/CHANGELOG.md +60 -0
- package/bin/activate.js +1 -2
- package/bin/deploy/index.js +3 -2
- package/bin/deploy/to-sqlite.js +2 -2
- package/bin/extend.js +2 -4
- package/bin/help.js +1 -1
- package/bin/import.js +105 -23
- package/bin/login.js +7 -8
- package/bin/logout.js +1 -2
- package/bin/repl.js +1 -1
- package/bin/watch.js +30 -11
- package/lib/client/activate.js +243 -0
- package/lib/client/auth_manager.js +115 -0
- package/lib/client/base_command.js +55 -0
- package/lib/client/extend.js +179 -0
- package/lib/client/helper/cf_helper.js +186 -0
- package/lib/client/helper/dependency_helper.js +26 -0
- package/lib/client/helper/env_helper.js +4 -0
- package/lib/client/helper/fs_helper.js +83 -0
- package/lib/client/helper/logging.js +37 -0
- package/lib/client/helper/question.js +50 -0
- package/lib/client/helper/string_helper.js +53 -0
- package/lib/client/helper/url_helper.js +17 -0
- package/lib/client/index.js +14 -0
- package/lib/client/params.js +435 -0
- package/lib/client/settings_manager.js +526 -0
- package/lib/import/common.js +24 -1
- package/lib/import/importapi.js +1 -1
- package/lib/import/index.js +25 -41
- package/lib/import/message.js +10 -6
- package/lib/import/v2parser.js +301 -47
- package/lib/import/v4parser.js +391 -71
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +15 -10
- package/lib/init/template/data/index.js +38 -46
- package/lib/init/template/hana/index.js +2 -2
- package/lib/init/template/lint/index.js +8 -6
- package/lib/init/template/mta/projectReader.js +8 -5
- package/lib/init/template/nodejs/files/.vscode/extensions.json +1 -1
- package/lib/init/template/nodejs/index.js +1 -8
- package/lib/lint/Linter.js +62 -60
- package/lib/lint/generators.js +1 -1
- package/lib/lint/io.js +9 -33
- package/npm-shrinkwrap.json +5179 -10848
- package/package.json +5 -5
package/lib/import/index.js
CHANGED
|
@@ -35,45 +35,42 @@ async function isValidInputFile(inputFileLoc) {
|
|
|
35
35
|
}
|
|
36
36
|
else if (inputFileLoc.endsWith(".edmx") || inputFileLoc.endsWith(".xml")) {
|
|
37
37
|
file = fileResolved;
|
|
38
|
+
defaultFileName = file;
|
|
38
39
|
} else {
|
|
39
40
|
throw new Error(messages.INVALID_INPUT_FILE);
|
|
40
41
|
}
|
|
41
42
|
return file;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
function validateAndComputeOutputFilePath(outputFileLoc) {
|
|
45
|
-
let
|
|
45
|
+
function validateAndComputeOutputFilePath(outputFileLoc, as) {
|
|
46
|
+
let index, extension, expectedExtension, supportedExtension;
|
|
46
47
|
if (typeof(outputFileLoc) !== 'boolean') {
|
|
47
48
|
index = outputFileLoc.lastIndexOf(".");
|
|
48
49
|
extension = outputFileLoc.substring(index + 1);
|
|
50
|
+
expectedExtension = (as) ? common.getSuffix(as) : "csn";
|
|
51
|
+
supportedExtension = (index > 0) ? common.supportedFormats().includes(extension) : false;
|
|
49
52
|
}
|
|
53
|
+
|
|
50
54
|
if (outputFileLoc === true || // if output file is not mentioned
|
|
55
|
+
outputFileLoc[0] === "-" || // if output file is missing and "--as" is considered as output file
|
|
51
56
|
outputFileLoc.trim() === "") {
|
|
52
57
|
throw new Error(messages.SPECIFY_OUTPUT_FILE);
|
|
53
|
-
} else if (
|
|
54
|
-
|
|
55
|
-
} else if (index > 0 &&
|
|
56
|
-
!extension.endsWith("/") && // to ignore "../test/lib/import/output/tempOutput/"
|
|
57
|
-
!extension.endsWith("\\") && // to ignore "c:\windows\output\test\"
|
|
58
|
-
extension !== 'json' &&
|
|
59
|
-
extension !== 'csn') {
|
|
60
|
-
// Output file extension is not either .json or .csn ("test.abcde", "./srv/external/test.abcde")
|
|
58
|
+
} else if (index > 0 && !supportedExtension) {
|
|
59
|
+
// extension not supported, eg., "test.abs", "./sv/external.test.abcs", "./a."
|
|
61
60
|
throw new Error(messages.INVALID_OUTPUT_FILE);
|
|
62
|
-
} else if (!
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
} else
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
} else if (index > 0 && !as && extension != "json" && extension != "csn") {
|
|
62
|
+
// --as option is not provided but output file is like: "test.cds", "./srv/external/test.cds"
|
|
63
|
+
throw new Error(messages.INCORRECT_EXTENSION);
|
|
64
|
+
} else if (index > 0 && as && extension != expectedExtension){
|
|
65
|
+
// extension not supported by --as option, e.g., "cds import <file> --out test.yml --as cds"
|
|
66
|
+
throw new Error(messages.OUTPUT_FILE_MISMATCH);
|
|
67
|
+
} else if (supportedExtension || (!outputFileLoc.endsWith("\\") && !outputFileLoc.endsWith("/"))) {
|
|
68
|
+
// eg., "./a.csn", "tst.cds", "./srv/external/test", "test", "c:\windows\output\test"
|
|
69
|
+
return outputFileLoc;
|
|
70
|
+
} else if (outputFileLoc.endsWith("/") || outputFileLoc.endsWith("\\")){
|
|
71
|
+
// File name not specified ("./srv/external/", "c:\windows\output\test\")
|
|
72
|
+
return outputFileLoc + path.parse(defaultFileName).name;
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
return filePath;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
async function getMetadataFromFile(path) {
|
|
@@ -135,9 +132,9 @@ async function edmx2csn(edmx, filename, context) {
|
|
|
135
132
|
if (multipleSchemas.test(edmx)) {
|
|
136
133
|
edmx = _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace);
|
|
137
134
|
}
|
|
138
|
-
let csn = await generateCSN(edmx,
|
|
135
|
+
let csn = await generateCSN(edmx, true, context);
|
|
139
136
|
if (filename) {
|
|
140
|
-
|
|
137
|
+
// Replace namespace by given filename in the csn file instead of edmx file
|
|
141
138
|
const re = RegExp(`([("/])${namespace}([/").])`, 'g');
|
|
142
139
|
const fn = `$1${path.parse(filename).name}$2`;
|
|
143
140
|
csn = csn.replace(re, fn);
|
|
@@ -154,7 +151,7 @@ async function _generateEDMX2JSON(edmx) {
|
|
|
154
151
|
return JSON.parse(cjson);
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
async function generateCSN(edmx,
|
|
154
|
+
async function generateCSN(edmx, mockServerUc, context) {
|
|
158
155
|
let csn;
|
|
159
156
|
let odataVersion;
|
|
160
157
|
let edmx2jsonModel;
|
|
@@ -167,7 +164,6 @@ async function generateCSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
|
|
|
167
164
|
return new Promise(function getCsn(resolve, reject) {
|
|
168
165
|
csn = edmxv2CSN.getEdmxv2CSN(
|
|
169
166
|
edmx2jsonModel,
|
|
170
|
-
ignorePersistenceSkip,
|
|
171
167
|
mockServerUc
|
|
172
168
|
);
|
|
173
169
|
if (csn) {
|
|
@@ -181,24 +177,12 @@ async function generateCSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
|
|
|
181
177
|
if(context){
|
|
182
178
|
context.oDataVersion = "V4";
|
|
183
179
|
}
|
|
184
|
-
return edmxv4CSN.getEdmxv4CSN(edmx,
|
|
180
|
+
return edmxv4CSN.getEdmxv4CSN(edmx, mockServerUc);
|
|
185
181
|
}
|
|
186
182
|
return new Promise(function invalidFile(resolve, reject) {
|
|
187
183
|
reject(new Error(messages.INVALID_EDMX_METADATA));
|
|
188
184
|
});
|
|
189
185
|
}
|
|
190
|
-
|
|
191
|
-
function _getDefaultFileName() {
|
|
192
|
-
let nameSpace;
|
|
193
|
-
if (defaultFileName === undefined) {
|
|
194
|
-
nameSpace = edmxv2CSN.getNamespace();
|
|
195
|
-
if (nameSpace) {
|
|
196
|
-
defaultFileName = nameSpace + ".csn"; //".json";
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return defaultFileName;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
186
|
async function saveCSNModel(csnDataModel, fileLoc) {
|
|
203
187
|
await fs.write(fileLoc, csnDataModel, "utf-8");
|
|
204
188
|
}
|
package/lib/import/message.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const messages = {
|
|
4
|
-
INVALID_EDMX_METADATA:
|
|
5
|
-
INVALID_OUTPUT_FILE:
|
|
6
|
-
MISSING_ENTITIES:
|
|
7
|
-
SPECIFY_INPUT_FILE:
|
|
8
|
-
SPECIFY_OUTPUT_FILE:
|
|
4
|
+
INVALID_EDMX_METADATA: 'The OData model is not valid. Specify the correct OData model.',
|
|
5
|
+
INVALID_OUTPUT_FILE: 'Please provide an output file with one of these [cds, csn, json] file extension.',
|
|
6
|
+
MISSING_ENTITIES: 'There are no entities in the OData model. Specify the correct OData model in the provided file.',
|
|
7
|
+
SPECIFY_INPUT_FILE: 'Specify an input file that exists.',
|
|
8
|
+
SPECIFY_OUTPUT_FILE: 'Specify an output file or correct the output file path provided.',
|
|
9
9
|
MISSING_ENTITY_CONTAINER: 'There is no entity container in the OData model. Specify the correct OData model.',
|
|
10
10
|
MISSING_ENTITY_SETS: 'There are no entity sets in the OData model. Specify the correct OData model.',
|
|
11
|
-
INVALID_INPUT_FILE: 'Input file provided is not valid. Please provide a file with either .edmx or .xml extension.'
|
|
11
|
+
INVALID_INPUT_FILE: 'Input file provided is not valid. Please provide a file with either .edmx or .xml extension.',
|
|
12
|
+
FILE_MODIFIED: 'The file with the same name exists and is been modified. Use --force flag to forcefully overwrite the file.',
|
|
13
|
+
OUTPUT_FILE_MISMATCH: 'Specify the file extension that --as option supports.',
|
|
14
|
+
INVALID_AS_OPTION: 'For --as option, please specify one of these output file format [cds, csn, json].',
|
|
15
|
+
INCORRECT_EXTENSION: 'If --as option is not provided, then please provide either .json or .csn output file extension.',
|
|
12
16
|
};
|
|
13
17
|
|
|
14
18
|
function getMessages() {
|