@sap/cds-dk 7.1.1 → 7.3.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/bin/activate.js +2 -2
- package/bin/build.js +5 -2
- package/bin/compile/index.js +13 -5
- package/bin/env.js +0 -3
- package/bin/extend.js +25 -3
- package/bin/gen.js +27 -0
- package/bin/help.js +2 -1
- package/bin/import.js +7 -3
- package/bin/push.js +10 -6
- package/bin/watch.js +3 -4
- package/bin/watched.js +2 -3
- package/lib/bind/bindingUtil.js +1 -0
- package/lib/build/{buildTaskHandler.js → buildPlugin.js} +25 -30
- package/lib/build/buildTaskEngine.js +84 -89
- package/lib/build/buildTaskFactory.js +23 -44
- package/lib/build/buildTaskProvider.js +24 -19
- package/lib/build/buildTaskProviderFactory.js +176 -66
- package/lib/build/constants.js +6 -5
- package/lib/build/index.js +4 -3
- package/lib/build/provider/{buildTaskHandlerEdmx.js → edmxBuildPlugin.js} +6 -6
- package/lib/build/provider/{buildTaskHandlerFeatureToggles.js → featureToggleBuildPlugin.js} +3 -3
- package/lib/build/provider/fiori/index.js +5 -6
- package/lib/build/provider/hana/index.js +67 -36
- package/lib/build/provider/{buildTaskHandlerInternal.js → internalBuildPlugin.js} +11 -11
- package/lib/build/provider/{buildTaskProviderInternal.js → internalBuildTaskProvider.js} +42 -53
- package/lib/build/provider/java/index.js +24 -24
- package/lib/build/provider/mtx/index.js +4 -4
- package/lib/build/provider/mtx/resourcesTarBuilder.js +8 -8
- package/lib/build/provider/mtx-extension/index.js +17 -9
- package/lib/build/provider/mtx-sidecar/index.js +17 -11
- package/lib/build/provider/nodejs/index.js +63 -29
- package/lib/build/util.js +11 -19
- package/lib/client/auth_manager.js +6 -12
- package/lib/client/base_command.js +1 -1
- package/lib/client/download_legacy.js +48 -0
- package/lib/client/params.js +5 -0
- package/lib/client/push.js +41 -1
- package/lib/client/settings_manager.js +12 -3
- package/lib/compile/openapi/csdl2openapi.js +30 -21
- package/lib/compile/openapi/index.js +7 -3
- package/lib/env/schema.js +36 -0
- package/lib/env/schemas/cds-rc.json +101 -0
- package/lib/import/common.js +24 -11
- package/lib/import/importapi.js +2 -2
- package/lib/import/message.js +3 -1
- package/lib/import/odata/v4parser.js +23 -7
- package/lib/index.js +5 -0
- package/lib/init/constants.js +9 -12
- package/lib/init/index.js +86 -74
- package/lib/init/template/_merging/registry-mta.js +21 -12
- package/lib/init/template/approuter/files/mta.yaml.hbs +1 -1
- package/lib/init/template/approuter/index.js +3 -2
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +0 -5
- package/lib/init/template/cf-manifest/index.js +2 -2
- package/lib/init/template/connectivity/index.js +5 -4
- package/lib/init/template/destination/index.js +2 -5
- package/lib/init/template/h2/index.js +16 -0
- package/lib/init/template/hana/index.js +2 -3
- package/lib/init/template/helm/chart/values.root.schema.json +0 -5
- package/lib/init/template/helm/chart/values.schema.json +0 -4
- package/lib/init/template/helm/index.js +1 -1
- package/lib/init/template/html5-repo/index.js +27 -3
- package/lib/init/template/lint/index.js +3 -7
- package/lib/init/template/mta/index.js +9 -3
- package/lib/init/template/multitenancy/files/package.json.hbs +0 -3
- package/lib/init/template/multitenancy/index.js +2 -0
- package/lib/init/template/nodejs/index.js +3 -3
- package/lib/init/template/pipeline/index.js +2 -4
- package/lib/init/template/postgres/files/mta.yaml.hbs +27 -0
- package/lib/init/template/postgres/files/package.json.hbs +5 -0
- package/lib/init/template/postgres/index.js +52 -0
- package/lib/init/template/sample/index.js +5 -7
- package/lib/init/template/sqlite/index.js +8 -3
- package/lib/init/template/tiny-sample/index.js +16 -30
- package/lib/init/util/mvn.js +25 -1
- package/lib/init/util/projectReader.js +2 -7
- package/lib/init/util/template.js +7 -6
- package/lib/util/pruneAxiosErrors.js +22 -8
- package/lib/watch/node-watch.js +6 -1
- package/npm-shrinkwrap.json +2207 -384
- package/package.json +3 -3
- package/lib/init/template/auditlog/files/mta.yaml.hbs +0 -14
- package/lib/init/template/auditlog/files/package.json.hbs +0 -27
- package/lib/init/template/auditlog/index.js +0 -74
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const { join } = require('path')
|
|
2
|
+
const cds = require('../../../cds')
|
|
3
|
+
const { read } = cds.utils
|
|
4
|
+
const { readProject } = require('../../util/projectReader')
|
|
5
|
+
const { mergeJSON, mergeYAML } = require('../../util/merge')
|
|
6
|
+
const { srvNode4, srvJava4, postgres, postgresDeployer } = require('../_merging/registry-mta')
|
|
7
|
+
|
|
8
|
+
module.exports = class PostgresTemplate extends require('../templateBase') {
|
|
9
|
+
|
|
10
|
+
async canRun() {
|
|
11
|
+
const { hasMta, hasHelm, isJava } = await readProject(this.options)
|
|
12
|
+
if (isJava) throw `'cds add postgres' is not available for Java yet`
|
|
13
|
+
if (hasHelm && !hasMta) throw `'cds add postgres' is not available for Kyma yet`
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static hasFacet(env) {
|
|
18
|
+
return env.requires?.db?.kind === 'postgres'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async run() {
|
|
22
|
+
const project = await readProject(this.options)
|
|
23
|
+
const { configFile } = project
|
|
24
|
+
project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
|
|
25
|
+
await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
|
|
26
|
+
await this.runDependentMerging()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async runDependentMerging() {
|
|
30
|
+
const project = await readProject(this.options)
|
|
31
|
+
const { hasMta, isNodejs, srvPath } = project
|
|
32
|
+
|
|
33
|
+
if (hasMta) {
|
|
34
|
+
const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
|
|
35
|
+
await mergeYAML(
|
|
36
|
+
'mta.yaml',
|
|
37
|
+
join(__dirname, 'files', 'mta.yaml.hbs'),
|
|
38
|
+
project,
|
|
39
|
+
{
|
|
40
|
+
additions: [srv, postgres, postgresDeployer],
|
|
41
|
+
relationships: [{
|
|
42
|
+
insert: [postgres, 'name'],
|
|
43
|
+
into: [srv, 'requires', 'name']
|
|
44
|
+
}, {
|
|
45
|
+
insert: [postgres, 'name'],
|
|
46
|
+
into: [postgresDeployer, 'requires', 'name']
|
|
47
|
+
}]
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
|
-
const cds = require('../../../cds'), { exists } = cds.utils
|
|
2
|
+
const cds = require('../../../cds'), { exists, copy } = cds.utils
|
|
3
3
|
const { readProject } = require('../../util/projectReader')
|
|
4
|
-
const { copyFiles } = require('../../util/template')
|
|
5
4
|
|
|
6
5
|
module.exports = class SampleTemplate extends require('../templateBase') {
|
|
7
6
|
|
|
@@ -14,12 +13,11 @@ module.exports = class SampleTemplate extends require('../templateBase') {
|
|
|
14
13
|
async run() {
|
|
15
14
|
const { db, srv, app } = (await this.getEnv()).folders
|
|
16
15
|
const language = exists('pom.xml') ? 'java' : 'nodejs'
|
|
17
|
-
const { force } = cds.cli.options
|
|
18
16
|
await Promise.all([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
copy(join(__dirname, 'files', 'db')).to(db),
|
|
18
|
+
copy(join(__dirname, 'files', 'app')).to(app),
|
|
19
|
+
copy(join(__dirname, 'files', 'srv')).to(srv),
|
|
20
|
+
copy(join(__dirname, 'files', language)).to(srv)
|
|
23
21
|
])
|
|
24
22
|
}
|
|
25
23
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
3
|
const { read } = cds.utils
|
|
4
|
+
const mvn = require('../../util/mvn')
|
|
4
5
|
const { readProject } = require('../../util/projectReader')
|
|
5
6
|
const { mergeJSON } = require('../../util/merge')
|
|
6
7
|
|
|
@@ -8,8 +9,12 @@ module.exports = class SQLiteTemplate extends require('../templateBase') {
|
|
|
8
9
|
|
|
9
10
|
async run() {
|
|
10
11
|
const project = await readProject()
|
|
11
|
-
const { configFile } = project
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const { isNodejs, isJava, configFile } = project
|
|
13
|
+
if (isNodejs) {
|
|
14
|
+
project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
|
|
15
|
+
await mergeJSON(configFile, join(__dirname, 'files', `package.json.hbs`), project)
|
|
16
|
+
} else if (isJava) {
|
|
17
|
+
await mvn.add('sqlite')
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
}
|
|
@@ -1,39 +1,25 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
|
-
const cds = require('
|
|
3
|
-
const {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const { PROJECT_TYPE: { java, nodejs }, OPTIONS: { JAVA }, URLS } = require('../../constants')
|
|
2
|
+
const cds = require('../../../../lib/cds'), { copy } = cds.utils
|
|
3
|
+
const { renderAndCopy } = require('../../util/template')
|
|
4
|
+
const mvn = require('../../util/mvn')
|
|
5
|
+
const { readProject } = require('../../util/projectReader')
|
|
6
|
+
const { JAVA } = require('../../constants')
|
|
8
7
|
|
|
9
8
|
module.exports = class TinySampleTemplate extends require('../templateBase') {
|
|
10
9
|
|
|
11
10
|
async run() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
async _addJavaSamples() {
|
|
19
|
-
if (!cds.cli.options.add.has(JAVA)) {
|
|
20
|
-
const mvnAddSamplesArgs = mvnArchetypes.getAddSamplesCmdArgs()
|
|
21
|
-
try {
|
|
22
|
-
await commandUtil.spawnCommand('mvn', mvnAddSamplesArgs, { cwd: cds.root })
|
|
23
|
-
const mvnAddTestsArgs = mvnArchetypes.getAddTestsCmdArgs()
|
|
24
|
-
await commandUtil.spawnCommand('mvn', mvnAddTestsArgs, { cwd: cds.root })
|
|
25
|
-
} catch (err) {
|
|
26
|
-
if (err.code === 'ENOENT' && err.path === 'mvn') {
|
|
27
|
-
throw `Maven executable 'mvn' not found, follow ${term.info(URLS.MAVEN_INSTALL_HELP)} and install Maven on your machine.`
|
|
28
|
-
}
|
|
29
|
-
throw err
|
|
11
|
+
const { isJava } = await readProject()
|
|
12
|
+
if (isJava) {
|
|
13
|
+
if (!cds.cli.options.add.has(JAVA)) {
|
|
14
|
+
await mvn.execMvn(mvn.getAddSamplesCmdArgs())
|
|
15
|
+
await mvn.execMvn(mvn.getAddTestsCmdArgs())
|
|
30
16
|
}
|
|
17
|
+
} else {
|
|
18
|
+
const { db, srv } = (await this.getEnv()).folders
|
|
19
|
+
await Promise.all([
|
|
20
|
+
copy(join(__dirname, 'files', 'nodejs', 'db')).to(db),
|
|
21
|
+
renderAndCopy(join(__dirname, 'files', 'nodejs', 'srv'), srv, { dbFolder: db.replace(/[\\/]+$/, '') })
|
|
22
|
+
])
|
|
31
23
|
}
|
|
32
24
|
}
|
|
33
|
-
|
|
34
|
-
async _addNodejsSamples() {
|
|
35
|
-
const { db, srv } = (await this.getEnv()).folders
|
|
36
|
-
await copyFiles(join(__dirname, 'files', 'nodejs', 'db'), db, {}, cds.cli.options.force)
|
|
37
|
-
await copyFiles(join(__dirname, 'files', 'nodejs', 'srv'), srv, { dbFolder: db.replace(/[\\/]+$/, '') }, cds.cli.options.force)
|
|
38
|
-
}
|
|
39
25
|
}
|
package/lib/init/util/mvn.js
CHANGED
|
@@ -33,7 +33,6 @@ class MvnArchetypeUtil {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
_finalize(params) {
|
|
36
|
-
// `-DcdsVersion=3.0.0`,
|
|
37
36
|
params.set(`-Dstyle.color`, `always`);
|
|
38
37
|
|
|
39
38
|
params.set('-B');
|
|
@@ -48,6 +47,31 @@ class MvnArchetypeUtil {
|
|
|
48
47
|
return Array.from(params, ([arg, val]) => val !== null && val !== undefined ? `${arg}=${val}` : arg)
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
// REVISIT: make this only public API once mvn:addSample etc. have been moved to generic mvn:add
|
|
51
|
+
async add(feature) {
|
|
52
|
+
return this.execMvn(this.getAddArgs(feature))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getAddArgs(feature) {
|
|
56
|
+
const params = new Map();
|
|
57
|
+
|
|
58
|
+
params.set(`com.sap.cds:cds-maven-plugin:${MAVEN_ARCHETYPE_VERSION}:add`);
|
|
59
|
+
params.set(`-Dfeature`, feature)
|
|
60
|
+
const profile = cds.cli.options.for
|
|
61
|
+
params.set(`-Dprofile`, profile === 'production' ? 'cloud' : profile)
|
|
62
|
+
|
|
63
|
+
const { options } = cds.cli
|
|
64
|
+
if (options[JAVA_MVN]) {
|
|
65
|
+
this._scanMvnParams(options[JAVA_MVN], params);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (options.force) {
|
|
69
|
+
params.set(`-Doverwrite`, true);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this._finalize(params);
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
getAddSamplesCmdArgs() {
|
|
52
76
|
const params = new Map();
|
|
53
77
|
|
|
@@ -2,6 +2,7 @@ const cds = require('../../cds')
|
|
|
2
2
|
const { join, resolve, basename } = require('path')
|
|
3
3
|
const { fs, exists } = cds.utils
|
|
4
4
|
const { parseXml } = require('./xml')
|
|
5
|
+
const { REGEX_JAVA_VERSION } = require('../constants')
|
|
5
6
|
const DEBUG = cds.debug('cli')
|
|
6
7
|
|
|
7
8
|
module.exports = new class ProjectReader {
|
|
@@ -18,12 +19,7 @@ module.exports = new class ProjectReader {
|
|
|
18
19
|
if (exists('pom.xml')) {
|
|
19
20
|
const { artifactId = [], description = [], version = [], properties = [] } = parseXml(resolve(cds.root, 'pom.xml')) ?? {}
|
|
20
21
|
const v = version[0] === '${revision}' ? properties[0]?.revision[0] : version[0]
|
|
21
|
-
if (v)
|
|
22
|
-
// check compliance with mta version format - copied from mbt error message
|
|
23
|
-
if (/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/.test(v)) {
|
|
24
|
-
this.appVersion = v
|
|
25
|
-
}
|
|
26
|
-
}
|
|
22
|
+
if (v && REGEX_JAVA_VERSION.test(v)) this.appVersion = v
|
|
27
23
|
if (artifactId[0]) this.appName = this.appId = artifactId[0].split(/-parent/)[0]
|
|
28
24
|
if (description[0]) this.appDescription = description[0]
|
|
29
25
|
}
|
|
@@ -79,7 +75,6 @@ module.exports = new class ProjectReader {
|
|
|
79
75
|
get isExtensible() { return _hasFacet('extensibility') },
|
|
80
76
|
get hasHana() { return _hasFacet('hana') },
|
|
81
77
|
get hasXsuaa() { return _hasFacet('xsuaa') },
|
|
82
|
-
get hasAuditlog() { return _hasFacet('auditlog') },
|
|
83
78
|
get hasApprouter() { return _hasFacet('approuter') },
|
|
84
79
|
get hasDestination() { return _hasFacet('destination') },
|
|
85
80
|
get hasHtml5Repo() { return _hasFacet('html5-repo') },
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const Mustache = require('mustache')
|
|
2
|
-
const
|
|
2
|
+
const cds = require('../../cds')
|
|
3
|
+
const { copy, read, write, exists, readdir, path, isdir } = cds.utils
|
|
3
4
|
|
|
4
|
-
async function
|
|
5
|
+
async function renderAndCopy(from, into, replacements, overwrite = cds.cli.options.force) {
|
|
5
6
|
const dirents = await readdir(from)
|
|
6
7
|
await Promise.all(dirents.map(async dirent => {
|
|
7
8
|
const fileNew = Mustache.render(dirent, replacements)
|
|
@@ -9,7 +10,7 @@ async function copyFiles(from, into, replacements, overwrite = false) {
|
|
|
9
10
|
const dest = path.join(into, fileNew)
|
|
10
11
|
|
|
11
12
|
if (isdir(src)) {
|
|
12
|
-
return
|
|
13
|
+
return renderAndCopy(path.join(from, dirent), dest, replacements, overwrite)
|
|
13
14
|
} else if (path.extname(dirent) === '.hbs') {
|
|
14
15
|
const destinationPath = dest.replace('.hbs', '')
|
|
15
16
|
if (overwrite || !exists(destinationPath)) {
|
|
@@ -23,11 +24,11 @@ async function copyFiles(from, into, replacements, overwrite = false) {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
async function render(src, templateValues) {
|
|
26
|
-
const content = await read(src, 'utf-8')
|
|
27
|
-
return Mustache.render(content, templateValues)
|
|
27
|
+
const content = await read(src, 'utf-8')
|
|
28
|
+
return Mustache.render(content, templateValues)
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
module.exports = {
|
|
31
32
|
render,
|
|
32
|
-
|
|
33
|
+
renderAndCopy
|
|
33
34
|
}
|
|
@@ -1,19 +1,33 @@
|
|
|
1
|
+
function stacklessError(message) {
|
|
2
|
+
const { stackTraceLimit } = Error;
|
|
3
|
+
Error.stackTraceLimit = 0;
|
|
4
|
+
const error = new Error(message);
|
|
5
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
6
|
+
return error;
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
require('axios').interceptors.response.use(
|
|
2
10
|
response => response,
|
|
3
11
|
axError => {
|
|
12
|
+
const { inspect } = require('util');
|
|
4
13
|
const { url, method } = axError.config ?? {};
|
|
5
|
-
const {
|
|
6
|
-
const { status,
|
|
7
|
-
|
|
14
|
+
const { response = {} } = axError;
|
|
15
|
+
const { status, statusText } = response;
|
|
16
|
+
let { data } = response;
|
|
17
|
+
if (Buffer.isBuffer(data)) {
|
|
18
|
+
data = JSON.parse(data.toString());
|
|
19
|
+
}
|
|
20
|
+
const reason = data?.error /* RFC 6749 */ && (typeof data.error === 'string' ? data.error : inspect(data.error));
|
|
8
21
|
const message = (url && method ? `${method.toUpperCase()} ${url} ` : '') +
|
|
9
22
|
'failed' +
|
|
10
|
-
(status ||
|
|
23
|
+
(status || statusText ? ':' : '') +
|
|
11
24
|
(status ? ` ${status}` : '') +
|
|
12
|
-
(
|
|
13
|
-
`. ${reason}
|
|
14
|
-
(data ?
|
|
25
|
+
(statusText ? ` ${statusText}` : '') +
|
|
26
|
+
(reason ? `. ${reason}` : '') +
|
|
27
|
+
(data ? `. Details: '${data.error_description /* RFC 6749 */ || inspect(data)}'` : '');
|
|
15
28
|
|
|
16
|
-
const error =
|
|
29
|
+
const error = stacklessError(message);
|
|
30
|
+
error.status = status;
|
|
17
31
|
if (require('../').debug('req')) {
|
|
18
32
|
error.cause = axError;
|
|
19
33
|
}
|
package/lib/watch/node-watch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const cds = require ('../cds')
|
|
2
2
|
const DEBUG = cds.debug('cli|watch')
|
|
3
|
+
const { relative } = require('path')
|
|
3
4
|
|
|
4
5
|
module.exports = ({ cwd, script, ext, includes=RegExp(), ignore=RegExp(), env={}, delay=200, options={} })=>{
|
|
5
6
|
|
|
@@ -52,7 +53,11 @@ module.exports = ({ cwd, script, ext, includes=RegExp(), ignore=RegExp(), env={}
|
|
|
52
53
|
// Watching for touched files...
|
|
53
54
|
const watch = require('node-watch')
|
|
54
55
|
const include = RegExp(`\\.(${ext.replace(/,/g,'|')})$|${includes.source}`)
|
|
55
|
-
const filter = f =>
|
|
56
|
+
const filter = f => {
|
|
57
|
+
const isIn = !ignore.test(f) && include.test(f)
|
|
58
|
+
if (!isIn) DEBUG?. (`ignored: ${relative(cwd||process.cwd(), f)}`)
|
|
59
|
+
return isIn
|
|
60
|
+
}
|
|
56
61
|
const watcher = watch (cwd||process.cwd(),{ recursive:true, filter, delay:0 })
|
|
57
62
|
if (DEBUG) watcher.on('close', ()=> DEBUG('⚡️', 'cds watch - file watcher closed'))
|
|
58
63
|
watcher.on('change', restart)
|