@sap/cds-dk 4.8.2 → 4.9.2
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 +54 -0
- package/bin/activate.js +8 -7
- package/bin/bind.js +12 -12
- package/bin/build/all.js +3 -5
- package/bin/build/index.js +1 -1
- package/bin/cds.js +1 -1
- package/bin/deploy/index.js +7 -1
- package/bin/deploy/to-hana.js +5 -4
- package/bin/deploy/to-sqlite.js +2 -1
- package/bin/extend.js +5 -5
- package/bin/help.js +1 -0
- package/bin/import.js +45 -31
- package/bin/login.js +5 -6
- package/bin/logout.js +2 -2
- package/bin/parse.js +19 -0
- package/lib/bind/bindingUtil.js +41 -49
- package/lib/bind/cfKeyProvider.js +9 -17
- package/lib/bind/userCdsrcJsonStorageProvider.js +1 -0
- package/lib/client/activate.js +3 -2
- package/lib/client/extend.js +5 -6
- package/lib/client/helper/fs_helper.js +8 -8
- package/lib/client/settings_manager.js +12 -9
- package/lib/compile/openapi/csdl2openapi.js +213 -165
- package/lib/compile/openapi/index.js +1 -2
- package/lib/compile/to-xsuaa.js +1 -1
- package/lib/import/index.js +22 -15
- package/lib/import/message.js +3 -1
- package/lib/import/utils/MetadataConverter.js +1 -1
- package/lib/import/v2parser.js +112 -56
- package/lib/import/v4parser.js +149 -98
- package/lib/init/constants.js +6 -2
- package/lib/init/index.js +3 -2
- package/lib/init/template/_merging/existences.js +80 -4
- package/lib/init/template/approuter/files/cds.cdsrc.json +7 -0
- package/lib/init/template/approuter/files/cds.cdsrc.json.hbs +9 -0
- package/lib/init/template/approuter/files/cds.package.json +9 -0
- package/lib/init/template/approuter/files/cds.package.json.hbs +11 -0
- package/lib/init/template/approuter/files/index.html +1 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +35 -21
- package/lib/init/template/approuter/files/package.json +3 -0
- package/lib/init/template/approuter/files/xs-app.json.hbs +19 -0
- package/lib/init/template/approuter/index.js +47 -18
- package/lib/init/template/auditlog/index.js +5 -5
- package/lib/init/template/hana/files/java/cdsrc.json.hbs +7 -0
- package/lib/init/template/hana/files/java/{package.json → db/package.json} +0 -0
- package/lib/init/template/hana/files/java/profile.cdsrc.json.hbs +12 -0
- package/lib/init/template/hana/files/mta.yaml.hbs +10 -17
- package/lib/init/template/hana/files/nodejs/cds.package.json.hbs +9 -0
- package/lib/init/template/hana/files/nodejs/cds.profile.package.json.hbs +14 -0
- package/lib/init/template/hana/files/nodejs/dependencies.package.json +1 -1
- package/lib/init/template/hana/index.js +60 -86
- package/lib/init/template/java/index.js +5 -2
- package/lib/init/template/kibana-logging/files/cds.package.json +7 -0
- package/lib/init/template/kibana-logging/files/cds.profile.package.json.hbs +9 -0
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +13 -0
- package/lib/init/template/kibana-logging/index.js +64 -0
- package/lib/init/template/mta/files/mta.yaml.hbs +3 -8
- package/lib/init/template/mta/index.js +8 -2
- package/lib/init/template/mtx/files/cds.package.json +0 -12
- package/lib/init/template/mtx/files/cds.package.json.hbs +14 -0
- package/lib/init/template/mtx/files/java/.cdsrc.json +17 -0
- package/lib/init/template/mtx/files/java/package.json +43 -0
- package/lib/init/template/mtx/files/java/server.js +30 -0
- package/lib/init/template/mtx/files/mta.yaml.hbs +6 -6
- package/lib/init/template/mtx/index.js +41 -22
- package/lib/init/template/templateBase.js +4 -1
- package/lib/init/template/xsuaa/files/cds.cdsrc.json +7 -0
- package/lib/init/template/xsuaa/files/cds.cdsrc.json.hbs +9 -0
- package/lib/init/template/xsuaa/files/cds.package.json +1 -1
- package/lib/init/template/xsuaa/files/cds.package.json.hbs +11 -0
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +2 -2
- package/lib/init/template/xsuaa/index.js +43 -27
- package/lib/init/types.d.ts +43 -19
- package/lib/init/util/fsUtil.js +15 -4
- package/lib/init/util/projectReader.js +21 -18
- package/lib/init/util/templateUtil.js +78 -28
- package/lib/util/exec.js +2 -2
- package/lib/watch/livereload-server.js +3 -0
- package/lib/watch/node-watch.js +8 -1
- package/npm-shrinkwrap.json +170 -148
- package/package.json +3 -3
- package/lib/init/template/approuter/files/xs-app.json +0 -8
- package/lib/init/template/nodejs/files/.vscode/settings.json +0 -7
|
@@ -39,29 +39,21 @@ class CFKeyProvider {
|
|
|
39
39
|
return result.data;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
extract(string, pattern,
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (match) {
|
|
47
|
-
return match[1];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (typeof defaultValue === 'undefined') {
|
|
52
|
-
throw Error(`Pattern not found: ${pattern}`);
|
|
53
|
-
} else {
|
|
54
|
-
return defaultValue;
|
|
42
|
+
extract(string, pattern, errorMsg) {
|
|
43
|
+
const match = string.match(pattern);
|
|
44
|
+
if (!match || !match[1]) {
|
|
45
|
+
throw new Error(errorMsg);
|
|
55
46
|
}
|
|
47
|
+
return match[1];
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
async getCfTargetFromCli() {
|
|
59
51
|
const result = await this._cfRead('target');
|
|
60
52
|
return {
|
|
61
|
-
apiEndpoint: this.extract(result,
|
|
62
|
-
user: this.extract(result,
|
|
63
|
-
org: this.extract(result,
|
|
64
|
-
space: this.extract(result,
|
|
53
|
+
apiEndpoint: this.extract(result, /api endpoint\s*:\s*(.*)/i, `CF API endpoint is missing. Use 'cf login' to login.`),
|
|
54
|
+
user: this.extract(result, /user\s*:\s*(.*)/i, `CF user is missing. Use 'cf login' to login.`),
|
|
55
|
+
org: this.extract(result, /org\s*:\s*(.*)/i, `CF org is missing. Use 'cf target -o <ORG> to specify.`),
|
|
56
|
+
space: this.extract(result, /space\s*:\s*(.*)/i, `CF space is missing. Use 'cf target -s <SPACE>' to specify.`),
|
|
65
57
|
};
|
|
66
58
|
}
|
|
67
59
|
|
|
@@ -2,6 +2,7 @@ const os = require('os');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const readline = require('readline');
|
|
4
4
|
|
|
5
|
+
// TODO transition to fs → need to mock fs and fse in test (cf. MTX client)
|
|
5
6
|
const { fse } = require('@sap/cds-foss');
|
|
6
7
|
const { highlight } = require('../util/term');
|
|
7
8
|
|
package/lib/client/activate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
const fs = require('fs').promises;
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const axios = require('axios');
|
|
3
|
-
const { fse } = require('@sap/cds-foss');
|
|
4
4
|
|
|
5
5
|
const AuthManager = require('./auth_manager');
|
|
6
6
|
const BaseCommand = require('./base_command');
|
|
@@ -122,6 +122,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
122
122
|
return !(/.*node_modules\/_base\/.*/.test(unixFilename));
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
+
// FIXME remove async
|
|
125
126
|
i18nFolders.forEach(async(folder) => {
|
|
126
127
|
const i18nFiles = collectFiles(projectFolder, folder, entry => {
|
|
127
128
|
const ext = path.extname(entry);
|
|
@@ -131,7 +132,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
131
132
|
});
|
|
132
133
|
|
|
133
134
|
try {
|
|
134
|
-
const pkgJson = await
|
|
135
|
+
const pkgJson = await fs.readFile(path.join(absoluteFolder, 'package.json'), 'utf-8');
|
|
135
136
|
allFiles.set('package.json', pkgJson);
|
|
136
137
|
} catch(e) {
|
|
137
138
|
Logger.log('No package.json file found');
|
package/lib/client/extend.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const axios = require('axios');
|
|
3
4
|
const { fse } = require('@sap/cds-foss');
|
|
4
5
|
|
|
5
6
|
const AuthManager = require('./auth_manager');
|
|
@@ -24,10 +25,8 @@ module.exports = class Extend extends BaseCommand {
|
|
|
24
25
|
static get COMMAND_URL_SUFFIX() { return COMMAND_URL_SUFFIX; }
|
|
25
26
|
|
|
26
27
|
static async storeFiles(content, targetDirectory, filter) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
targetDirectory = fse.realpathSync(targetDirectory)
|
|
28
|
+
fse.mkdirpSync(targetDirectory);
|
|
29
|
+
targetDirectory = fs.realpathSync(targetDirectory)
|
|
31
30
|
const writtenFiles = new Set();
|
|
32
31
|
const filesToWrite = new Map();
|
|
33
32
|
for (const [filename, filecontent] of content) {
|
|
@@ -39,7 +38,7 @@ module.exports = class Extend extends BaseCommand {
|
|
|
39
38
|
for (const [filepath, content] of [...filesToWrite.entries()]) {
|
|
40
39
|
const normalizedFilepath = normalizePath(filepath);
|
|
41
40
|
fse.mkdirpSync(path.dirname(normalizedFilepath));
|
|
42
|
-
|
|
41
|
+
fs.writeFileSync(normalizedFilepath, content);
|
|
43
42
|
writtenFiles.add(path.relative(process.cwd(), normalizedFilepath));
|
|
44
43
|
Extend._logWrittenFile(normalizedFilepath);
|
|
45
44
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const path = require('path');
|
|
2
|
-
const { fse } = require('@sap/cds-foss');
|
|
3
3
|
|
|
4
4
|
async function collectFileContent(filePaths, root) {
|
|
5
5
|
const resultMap = new Map();
|
|
6
6
|
filePaths.forEach((filePath) => {
|
|
7
|
-
const fileContent =
|
|
7
|
+
const fileContent = fs.readFileSync(filePath);
|
|
8
8
|
resultMap.set(toUnixPath(path.relative(root, filePath)), fileContent.toString('utf-8'));
|
|
9
9
|
});
|
|
10
10
|
return resultMap;
|
|
@@ -26,20 +26,20 @@ function collectFiles(root, sourceDir, filter) {
|
|
|
26
26
|
|
|
27
27
|
function _traverseFileSystem(root, sourceDir, files, filter) {
|
|
28
28
|
let absoluteDir = path.resolve(root, sourceDir);
|
|
29
|
-
if (!
|
|
29
|
+
if (!fs.existsSync(absoluteDir)) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
absoluteDir =
|
|
33
|
-
if (
|
|
34
|
-
|
|
32
|
+
absoluteDir = fs.realpathSync(absoluteDir);
|
|
33
|
+
if (fs.statSync(absoluteDir)) {
|
|
34
|
+
fs.readdirSync(absoluteDir)
|
|
35
35
|
.map(subDirEntry => path.join(absoluteDir, subDirEntry))
|
|
36
36
|
.forEach(entry => {
|
|
37
|
-
const stats =
|
|
37
|
+
const stats = fs.statSync(entry)
|
|
38
38
|
if (stats.isDirectory()) {
|
|
39
39
|
_traverseFileSystem(root, entry, files, filter);
|
|
40
40
|
}
|
|
41
41
|
if (stats.isFile() && (!filter || filter.call(this, entry))) {
|
|
42
|
-
const fileContent =
|
|
42
|
+
const fileContent = fs.readFileSync(entry);
|
|
43
43
|
files.set(toUnixPath(path.relative(root, entry)), fileContent.toString('utf-8'));
|
|
44
44
|
}
|
|
45
45
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const os = require('os');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
const { fse } = require('@sap/cds-foss');
|
|
@@ -54,12 +55,14 @@ function other(tokenStorage) {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
function getProjectFolder(params) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
58
|
+
if (params.has('projectFolder')) {
|
|
59
|
+
const maybeExistentPath = path.resolve(params.get('projectFolder'));
|
|
60
|
+
return maybeExistentPath;
|
|
61
|
+
}
|
|
62
|
+
const existentPath = params.has('subdomain') && fs.existsSync(params.get('subdomain'))
|
|
63
|
+
? params.get('subdomain')
|
|
64
|
+
: '.';
|
|
65
|
+
return fs.realpathSync(existentPath);
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
async function getAppUrlAndSubdomainFromSuggestions(params) {
|
|
@@ -348,7 +351,7 @@ class SettingsManager {
|
|
|
348
351
|
const deletionUrlsAndSubdomains = new Set();
|
|
349
352
|
|
|
350
353
|
Object.entries(settingsByFolder)
|
|
351
|
-
.filter(entry => !
|
|
354
|
+
.filter(entry => ! fs.existsSync(entry[0]))
|
|
352
355
|
.forEach(entry => {
|
|
353
356
|
delete settingsByFolder[entry[0]];
|
|
354
357
|
deletionFolders.push(entry[0]);
|
|
@@ -433,7 +436,7 @@ class SettingsManager {
|
|
|
433
436
|
static async _loadFromFile(projectFolder) {
|
|
434
437
|
const all = !projectFolder;
|
|
435
438
|
|
|
436
|
-
if (!
|
|
439
|
+
if (!fs.existsSync(CONFIG.paths.settings)) {
|
|
437
440
|
Logger.debug('Settings file absent');
|
|
438
441
|
return emptyData(all);
|
|
439
442
|
}
|
|
@@ -461,7 +464,7 @@ class SettingsManager {
|
|
|
461
464
|
static async _loadAuthFromFile(appUrl, subdomain) {
|
|
462
465
|
const all = !appUrl;
|
|
463
466
|
|
|
464
|
-
if (!
|
|
467
|
+
if (!fs.existsSync(CONFIG.paths.auth)) {
|
|
465
468
|
Logger.debug('Authentication-data file absent');
|
|
466
469
|
return emptyData(all);
|
|
467
470
|
}
|