@sap/cds-dk 7.1.1 → 7.2.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/build.js +3 -3
- package/bin/compile/index.js +5 -1
- package/bin/gen.js +27 -0
- package/bin/help.js +2 -1
- package/bin/watch.js +3 -4
- package/bin/watched.js +2 -3
- package/lib/bind/bindingUtil.js +1 -0
- package/lib/build/buildTaskEngine.js +12 -17
- package/lib/build/buildTaskFactory.js +23 -27
- package/lib/build/buildTaskHandler.js +2 -5
- package/lib/build/buildTaskProviderFactory.js +9 -12
- package/lib/build/constants.js +2 -1
- package/lib/build/index.js +1 -1
- package/lib/build/provider/buildTaskHandlerInternal.js +2 -2
- package/lib/build/provider/buildTaskProviderInternal.js +15 -25
- package/lib/build/provider/hana/index.js +14 -7
- package/lib/build/provider/nodejs/index.js +51 -18
- package/lib/build/util.js +11 -19
- package/lib/compile/openapi/csdl2openapi.js +30 -21
- package/lib/compile/openapi/index.js +7 -3
- package/lib/import/common.js +1 -1
- package/lib/init/constants.js +6 -11
- package/lib/init/index.js +84 -71
- package/lib/init/template/_merging/registry-mta.js +0 -12
- package/lib/init/template/approuter/files/mta.yaml.hbs +1 -1
- package/lib/init/template/approuter/index.js +7 -6
- 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/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/lint/index.js +3 -7
- 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/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 +3 -7
- package/lib/init/util/template.js +7 -6
- package/lib/watch/node-watch.js +6 -1
- package/npm-shrinkwrap.json +324 -307
- 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
|
@@ -16,7 +16,8 @@ const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5')
|
|
|
16
16
|
module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
17
17
|
|
|
18
18
|
static hasFacet(env) {
|
|
19
|
-
return exists(join(env.folders.app, 'xs-app.json'))
|
|
19
|
+
return exists(join(env.folders.app, 'router', 'xs-app.json')) ||
|
|
20
|
+
exists(join(env.folders.app, 'xs-app.json'))
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
getDependencies() {
|
|
@@ -28,16 +29,16 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
async run() {
|
|
31
|
-
const {
|
|
32
|
-
const appPackageJSONPath = join(
|
|
32
|
+
const { approuterPath } = await readProject()
|
|
33
|
+
const appPackageJSONPath = join(approuterPath, 'package.json')
|
|
33
34
|
await mergeJSON(appPackageJSONPath, join(__dirname, 'files', 'package.json'))
|
|
34
35
|
await sort(appPackageJSONPath, 'dependencies')
|
|
35
|
-
await mergeJSON(join(
|
|
36
|
+
await mergeJSON(join(approuterPath, 'default-env.json'), join(__dirname, 'files', 'default-env.json'))
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
async runDependentMerging(context = {}) {
|
|
39
40
|
const project = await readProject()
|
|
40
|
-
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath,
|
|
41
|
+
const { isNodejs, isJava, isExtensible, isMultitenant, hasMta, hasHelm, srvPath, approuterPath } = project
|
|
41
42
|
|
|
42
43
|
if (hasMta) {
|
|
43
44
|
const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
|
|
@@ -116,7 +117,7 @@ module.exports = class ApprouterTemplate extends require('../templateBase') {
|
|
|
116
117
|
if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData);
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
const xsAppPath = join(
|
|
120
|
+
const xsAppPath = join(approuterPath, 'xs-app.json')
|
|
120
121
|
const additions = isExtensible ? [{ ...approuterExtensibility, at: 0 }] : []
|
|
121
122
|
await mergeJSON(xsAppPath, join(__dirname, 'files', 'xs-app.json.hbs'), project, { additions })
|
|
122
123
|
}
|
|
@@ -2,7 +2,7 @@ const { join } = require('path')
|
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
3
|
const { exists } = require('../../../cds').utils
|
|
4
4
|
const { readProject } = require('../../util/projectReader')
|
|
5
|
-
const {
|
|
5
|
+
const { renderAndCopy } = require('../../util/template')
|
|
6
6
|
const MANIFEST_FILE = 'manifest.yml'
|
|
7
7
|
const SERVICES_MANIFEST_FILE = 'services-manifest.yml'
|
|
8
8
|
|
|
@@ -20,6 +20,6 @@ module.exports = class CfManifestTemplate extends require('../templateBase') {
|
|
|
20
20
|
|
|
21
21
|
async run() {
|
|
22
22
|
const project = await readProject()
|
|
23
|
-
await
|
|
23
|
+
await renderAndCopy(join(__dirname, 'files'), cds.root, project)
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const mvn = require('../../util/mvn')
|
|
2
|
+
const { readProject } = require('../../util/projectReader')
|
|
3
|
+
const { H2 } = require('../../constants').OPTIONS
|
|
4
|
+
|
|
5
|
+
module.exports = class H2Template extends require('../templateBase') {
|
|
6
|
+
|
|
7
|
+
async canRun() {
|
|
8
|
+
const { isNodejs } = await readProject()
|
|
9
|
+
if (isNodejs) throw `'cds add ${H2}' is not available for Node.js`
|
|
10
|
+
return true
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async run() {
|
|
14
|
+
await mvn.add(H2)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const { join } = require('path')
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
|
-
const { read, write, exists, rmdir } = cds.utils
|
|
3
|
+
const { read, write, exists, rmdir, copy } = cds.utils
|
|
4
4
|
const { readProject } = require('../../util/projectReader')
|
|
5
5
|
const { mergeJSON, mergeYAML, removeFromYAML, removeFromYAMLArray } = require('../../util/merge')
|
|
6
6
|
const mvn = require('../../util/mvn')
|
|
7
7
|
const { parseMd5File, writeMd5File } = require('../../util/md5')
|
|
8
|
-
const { copyFiles } = require('../../util/template')
|
|
9
8
|
|
|
10
9
|
const { OPTIONS: { JAVA } } = require('../../constants')
|
|
11
10
|
|
|
@@ -33,7 +32,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
|
|
|
33
32
|
await mergeJSON(undeployJSONPath, undeployJSONTemplatePath)
|
|
34
33
|
|
|
35
34
|
if (isJava) {
|
|
36
|
-
await
|
|
35
|
+
await copy(join(__dirname, 'files', 'db')).to(db.folder)
|
|
37
36
|
// REVISIT: shouldn't behave differently during cds init
|
|
38
37
|
// if called during cds init the project generation call to AT will add settings
|
|
39
38
|
if (!cds.cli.options.add.has(JAVA)) await mvn.execMvn(mvn.getAddHanaCmdArgs())
|
|
@@ -37,11 +37,6 @@
|
|
|
37
37
|
"description": "Service Instance",
|
|
38
38
|
"$ref": "./charts/service-instance/values.schema.json"
|
|
39
39
|
},
|
|
40
|
-
"auditlog": {
|
|
41
|
-
"$id": "#/properties/auditlog",
|
|
42
|
-
"description": "Service Instance",
|
|
43
|
-
"$ref": "./charts/service-instance/values.schema.json"
|
|
44
|
-
},
|
|
45
40
|
"destination": {
|
|
46
41
|
"$id": "#/properties/destination",
|
|
47
42
|
"description": "Service Instance",
|
|
@@ -66,10 +66,6 @@
|
|
|
66
66
|
"$id": "#/properties/xsuaa",
|
|
67
67
|
"description": "Service Instance"
|
|
68
68
|
},
|
|
69
|
-
"auditlog": {
|
|
70
|
-
"$id": "#/properties/auditlog",
|
|
71
|
-
"description": "Service Instance"
|
|
72
|
-
},
|
|
73
69
|
"destination": {
|
|
74
70
|
"$id": "#/properties/destination",
|
|
75
71
|
"description": "Service Instance"
|
|
@@ -14,7 +14,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
getRelatedFacets() {
|
|
17
|
-
return ['hana', 'xsuaa', '
|
|
17
|
+
return ['hana', 'xsuaa', 'enterprise-messaging', 'destination' , 'multitenancy', 'extensibility', 'approuter', 'connectivity']
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
static hasFacet() {
|
|
@@ -5,7 +5,7 @@ const term = require("../../../util/term");
|
|
|
5
5
|
const checks = require("../../../lint/checks");
|
|
6
6
|
const io = require("../../../lint/io");
|
|
7
7
|
const readline = require("readline");
|
|
8
|
-
const {
|
|
8
|
+
const { renderAndCopy } = require('../../util/template')
|
|
9
9
|
const { LINT_DEV, LINT_GLOBAL } = require("../../constants").OPTIONS;
|
|
10
10
|
const { getConfigPath, getFileExtensions } = require("@sap/eslint-plugin-cds/lib/api");
|
|
11
11
|
const cds = require("../../../cds");
|
|
@@ -62,10 +62,10 @@ module.exports = class LintTemplate extends require('../templateBase') {
|
|
|
62
62
|
await this._generateEslintDirs();
|
|
63
63
|
|
|
64
64
|
if (!exists(".eslint/rules/no-entity-moo.js")) {
|
|
65
|
-
await
|
|
65
|
+
await renderAndCopy(".eslint/rules", this.rulesPath);
|
|
66
66
|
}
|
|
67
67
|
if (!exists(".eslint/tests/no-entity-moo.test.js")) {
|
|
68
|
-
await
|
|
68
|
+
await renderAndCopy(".eslint/tests", this.testsPath);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -150,10 +150,6 @@ module.exports = class LintTemplate extends require('../templateBase') {
|
|
|
150
150
|
await mkdirp(this.testsPath);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
async _copyFromTemplate(source, dest) {
|
|
154
|
-
await copyFiles(source, dest, {}, true);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
153
|
async _addEslintPluginConfig() {
|
|
158
154
|
let configPath = getConfigPath(cds.root);
|
|
159
155
|
if (!configPath) {
|
|
@@ -2,6 +2,7 @@ const { join } = require('path')
|
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
3
|
const { exists, read, write } = cds.utils
|
|
4
4
|
const { APPROUTER, HANA, KIBANA } = require('../../constants').OPTIONS
|
|
5
|
+
const mvn = require('../../util/mvn')
|
|
5
6
|
const { readProject } = require('../../util/projectReader')
|
|
6
7
|
const { mergeJSON, mergeYAML, sort } = require('../../util/merge')
|
|
7
8
|
const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5')
|
|
@@ -35,6 +36,7 @@ module.exports = class MultitenancyTemplate extends require('../templateBase') {
|
|
|
35
36
|
const packageJson = await read('package.json')
|
|
36
37
|
packageJson.workspaces = ['mtx/sidecar']
|
|
37
38
|
await write('package.json', packageJson, { spaces: 2 })
|
|
39
|
+
await mvn.execMvn(mvn.getAddArgs('mtx'))
|
|
38
40
|
}
|
|
39
41
|
if (isNodejs) await sort('package.json', 'dependencies')
|
|
40
42
|
await copyRenderedJSON(join(__dirname, 'files', 'package.sidecar.json.hbs'), join('mtx', 'sidecar', 'package.json'), project)
|
|
@@ -3,12 +3,12 @@ const cds = require('../../../cds')
|
|
|
3
3
|
const { exists, mkdirp, path } = cds.utils
|
|
4
4
|
const { URLS, OPTIONS: { NODEJS, JAVA }, COMMAND_ADD } = require('../../constants')
|
|
5
5
|
const term = require('../../../util/term')
|
|
6
|
-
const {
|
|
6
|
+
const { renderAndCopy } = require('../../util/template')
|
|
7
7
|
|
|
8
8
|
module.exports = class NodejsTemplate extends require('../templateBase') {
|
|
9
9
|
|
|
10
10
|
static hasFacet() {
|
|
11
|
-
return !exists('pom.xml')
|
|
11
|
+
return !exists('pom.xml') && !cds.cli.options?.add?.has(JAVA)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async canRun() {
|
|
@@ -23,7 +23,7 @@ module.exports = class NodejsTemplate extends require('../templateBase') {
|
|
|
23
23
|
|
|
24
24
|
async run() {
|
|
25
25
|
const { db, srv, app } = (await this.getEnv()).folders
|
|
26
|
-
await
|
|
26
|
+
await renderAndCopy(join(__dirname, 'files'), cds.root, { projectName: path.basename(cds.root) })
|
|
27
27
|
await Promise.all([db, srv, app].map(p => mkdirp(p)))
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const { join } = require('path');
|
|
2
2
|
const cds = require('../../../cds')
|
|
3
|
-
const { exists } = cds.utils
|
|
4
|
-
const { copyFiles } = require('../../util/template')
|
|
3
|
+
const { exists, copy } = cds.utils
|
|
5
4
|
const { URLS } = require('../../constants')
|
|
6
5
|
|
|
7
6
|
module.exports = class PipelineTemplate extends require('../templateBase') {
|
|
8
7
|
|
|
9
|
-
|
|
10
8
|
async canRun() {
|
|
11
9
|
if (cds.cli.options.force) {
|
|
12
10
|
return true;
|
|
@@ -20,7 +18,7 @@ module.exports = class PipelineTemplate extends require('../templateBase') {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
async run() {
|
|
23
|
-
await
|
|
21
|
+
await copy(join(__dirname, 'files')).to(cds.root)
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
async finalize() {
|
|
@@ -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,13 +75,13 @@ 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') },
|
|
86
81
|
get hasMta() { return _hasFacet('mta') },
|
|
87
82
|
get hasHelm() { return _hasFacet('helm') },
|
|
88
83
|
get appPath() { return env.folders.app ?? 'app' },
|
|
84
|
+
get approuterPath() { return join(env.folders.app ?? 'app', 'router') },
|
|
89
85
|
get appVersion() { return appVersion },
|
|
90
86
|
get appName() { return appName },
|
|
91
87
|
get appId() { return appId },
|
|
@@ -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
|
}
|
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)
|