@sap/cds-dk 7.0.2 → 7.1.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/add.js +2 -2
- package/bin/bind.js +5 -7
- package/bin/build.js +2 -7
- package/bin/cds.js +6 -8
- package/bin/deploy/to-hana.js +1 -1
- package/bin/init.js +2 -2
- package/bin/subscribe.js +4 -4
- package/bin/unsubscribe.js +4 -4
- package/bin/upgrade.js +4 -4
- package/lib/bind/cfKeyProvider.js +10 -10
- package/lib/bind/index.js +4 -3
- package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
- package/lib/build/buildTaskEngine.js +9 -22
- package/lib/build/buildTaskFactory.js +18 -27
- package/lib/build/constants.js +16 -14
- package/lib/build/index.js +12 -3
- package/lib/build/provider/buildTaskProviderInternal.js +23 -15
- package/lib/build/provider/mtx/index.js +8 -2
- package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
- package/lib/build/provider/mtx-sidecar/index.js +13 -8
- package/lib/build/util.js +13 -0
- package/lib/client/activate.js +7 -7
- package/lib/client/auth_manager.js +5 -5
- package/lib/client/base_command.js +7 -10
- package/lib/client/extend.js +2 -2
- package/lib/client/helper/logging.js +7 -2
- package/lib/client/params.js +2 -3
- package/lib/client/pull.js +3 -3
- package/lib/client/push.js +3 -3
- package/lib/client/settings_manager.js +7 -8
- package/lib/client/tenant_action.js +3 -3
- package/lib/compile/asyncapi/components/messages/index.js +41 -18
- package/lib/compile/asyncapi/index.js +23 -2
- package/lib/deploy/to-hana/hana.js +1 -2
- package/lib/import/common.js +3 -0
- package/lib/import/message.js +2 -1
- package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
- package/lib/import/odata/v4parser.js +85 -95
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +78 -73
- package/lib/init/template/approuter/index.js +3 -4
- package/lib/init/template/auditlog/index.js +3 -4
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +15 -23
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +22 -17
- package/lib/init/template/cf-manifest/index.js +2 -2
- package/lib/init/template/connectivity/index.js +2 -3
- package/lib/init/template/data/index.js +7 -8
- package/lib/init/template/destination/index.js +3 -5
- package/lib/init/template/enterprise-messaging/index.js +4 -5
- package/lib/init/template/enterprise-messaging-shared/index.js +3 -4
- package/lib/init/template/extensibility/index.js +2 -3
- package/lib/init/template/file-based-messaging/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +1 -1
- package/lib/init/template/hana/index.js +39 -63
- package/lib/init/template/helm/index.js +15 -14
- package/lib/init/template/html5-repo/index.js +3 -7
- package/lib/init/template/java/index.js +3 -3
- package/lib/init/template/kibana/index.js +3 -4
- package/lib/init/template/lint/index.js +13 -13
- package/lib/init/template/mta/index.js +3 -2
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +16 -37
- package/lib/init/template/nodejs/index.js +4 -6
- package/lib/init/template/pipeline/index.js +3 -4
- package/lib/init/template/redis-messaging/index.js +3 -4
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +1 -1
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +1 -1
- package/lib/init/template/sample/files/srv/admin-service.cds +1 -1
- package/lib/init/template/sample/files/srv/cat-service.cds +1 -1
- package/lib/init/template/sample/index.js +6 -5
- package/lib/init/template/sqlite/index.js +1 -1
- package/lib/init/template/templateBase.js +9 -19
- package/lib/init/template/tiny-sample/index.js +5 -5
- package/lib/init/template/toggles/index.js +1 -2
- package/lib/init/template/typer/files/xsconfig.json +0 -1
- package/lib/init/template/typer/index.js +1 -1
- package/lib/init/template/xsuaa/index.js +3 -4
- package/lib/init/util/indent.js +57 -0
- package/lib/init/util/merge.js +72 -16
- package/lib/init/util/mvn.js +40 -31
- package/lib/init/util/projectReader.js +52 -168
- package/lib/init/util/template.js +12 -11
- package/lib/init/util/xml.js +6 -6
- package/lib/util/cfUtil.js +1 -2
- package/lib/util/pruneAxiosErrors.js +22 -0
- package/lib/watch/open.js +6 -3
- package/npm-shrinkwrap.json +356 -309
- package/package.json +1 -2
- package/lib/client/helper/errors.js +0 -26
- package/lib/util/version.js +0 -27
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
const cds = require('../../cds')
|
|
2
|
-
const {
|
|
2
|
+
const { join, resolve, basename } = require('path')
|
|
3
|
+
const { fs, exists } = cds.utils
|
|
3
4
|
const { parseXml } = require('./xml')
|
|
4
|
-
const
|
|
5
|
-
const P_LANGUAGE_NODEJS = 'nodejs'
|
|
6
|
-
const DEFAULT_P_LANGUAGE = P_LANGUAGE_NODEJS
|
|
7
|
-
const DEBUG = /\b(y|all|cli)\b/.test(process.env.DEBUG) && console.debug
|
|
5
|
+
const DEBUG = cds.debug('cli')
|
|
8
6
|
|
|
9
7
|
module.exports = new class ProjectReader {
|
|
10
8
|
|
|
11
9
|
constructor() {
|
|
12
10
|
this.readProject = this.readProject.bind(this)
|
|
11
|
+
|
|
12
|
+
// 1. Use project name and static default values
|
|
13
|
+
this.appVersion = cds.cli.options.add?.has('java') ? '1.0.0-SNAPSHOT' : '1.0.0'
|
|
14
|
+
this.appName = this.appId = basename(cds.root)
|
|
15
|
+
this.appDescription = 'A simple CAP project.'
|
|
16
|
+
|
|
17
|
+
// 2. Use either pom.xml or package.json
|
|
18
|
+
if (exists('pom.xml')) {
|
|
19
|
+
const { artifactId = [], description = [], version = [], properties = [] } = parseXml(resolve(cds.root, 'pom.xml')) ?? {}
|
|
20
|
+
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
|
+
}
|
|
27
|
+
if (artifactId[0]) this.appName = this.appId = artifactId[0].split(/-parent/)[0]
|
|
28
|
+
if (description[0]) this.appDescription = description[0]
|
|
29
|
+
}
|
|
30
|
+
else if (exists('package.json')) {
|
|
31
|
+
const { name, version, description } = JSON.parse(fs.readFileSync(join(cds.root, 'package.json')))
|
|
32
|
+
this.appVersion = version
|
|
33
|
+
const segments = name.trim().replace(/@/g, '').split('/').map(encodeURIComponent)
|
|
34
|
+
this.appName = segments[segments.length - 1]
|
|
35
|
+
this.appId = segments.join('.')
|
|
36
|
+
this.appDescription = description ?? this.appDescription
|
|
37
|
+
}
|
|
13
38
|
}
|
|
14
39
|
|
|
15
40
|
// REVISIT: There should be a better (and parallelizable) API provided by cds.env
|
|
@@ -27,25 +52,29 @@ module.exports = new class ProjectReader {
|
|
|
27
52
|
}
|
|
28
53
|
}
|
|
29
54
|
|
|
30
|
-
async readProject(
|
|
31
|
-
// if (options?.cwd) cds.root = options.cwd
|
|
32
|
-
|
|
55
|
+
async readProject() {
|
|
33
56
|
const env = this.getEnv()
|
|
34
|
-
|
|
57
|
+
const { appVersion, appName, appId, appDescription } = this
|
|
58
|
+
DEBUG?.({ env })
|
|
35
59
|
|
|
36
|
-
const _hasFacet = template => require(`../template/${template}`).hasFacet(env
|
|
60
|
+
const _hasFacet = template => require(`../template/${template}`).hasFacet(env)
|
|
37
61
|
const project = {
|
|
38
|
-
profile
|
|
39
|
-
language:
|
|
40
|
-
srv
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
get profile() { return cds.cli.options?.for },
|
|
63
|
+
get language() { return exists('pom.xml') ? 'java' : 'nodejs' },
|
|
64
|
+
get srvPath() { return join(env.build.target, env.folders.srv.replace(/\/$/, '')).replace(/\\/g, '/') },
|
|
65
|
+
get archiveName() {
|
|
66
|
+
const pom = parseXml(resolve(cds.root, env.folders.srv, 'pom.xml'))
|
|
67
|
+
return (pom?.artifactId?.[0] ?? basename(cds.root)) + '-exec.' + pom?.packaging?.[0]
|
|
68
|
+
},
|
|
69
|
+
get db() {
|
|
70
|
+
const folder = env.folders.db
|
|
71
|
+
const name = folder.replace(/\/$/, '')
|
|
72
|
+
const path = join(env.build.target, name).replace(/\\/g, '/')
|
|
73
|
+
return { folder, name, path }
|
|
74
|
+
},
|
|
45
75
|
get configFile() { return exists('pom.xml') ? '.cdsrc.json' : 'package.json' },
|
|
46
76
|
get isNodejs() { return _hasFacet('nodejs') },
|
|
47
77
|
get isJava() { return _hasFacet('java') },
|
|
48
|
-
get hasSidecar() { return exists('mtx', 'sidecar') },
|
|
49
78
|
get isMultitenant() { return _hasFacet('multitenancy') },
|
|
50
79
|
get isExtensible() { return _hasFacet('extensibility') },
|
|
51
80
|
get hasHana() { return _hasFacet('hana') },
|
|
@@ -57,158 +86,13 @@ module.exports = new class ProjectReader {
|
|
|
57
86
|
get hasMta() { return _hasFacet('mta') },
|
|
58
87
|
get hasHelm() { return _hasFacet('helm') },
|
|
59
88
|
get appPath() { return env.folders.app ?? 'app' },
|
|
89
|
+
get appVersion() { return appVersion },
|
|
90
|
+
get appName() { return appName },
|
|
91
|
+
get appId() { return appId },
|
|
92
|
+
get appDescription() { return appDescription },
|
|
60
93
|
}
|
|
61
94
|
|
|
62
|
-
|
|
63
|
-
const cds = require('../../cds')
|
|
64
|
-
cds.env // make sure env is initialized, otherwise we cannot set it (exotic case)
|
|
65
|
-
cds.env = env
|
|
66
|
-
|
|
67
|
-
// check whether we have a hana service binding defined as a hana build task is returned by default for compatibility reasons if neither hana, nor sqlite has been defined
|
|
68
|
-
if (env?.requires?.db?.kind === 'hana') {
|
|
69
|
-
const dbFolder = env.folders.db.replace(/\/$/, '')
|
|
70
|
-
const relDbDestPath = path.join(env.build.target, dbFolder).replace(/\\/g, '/')
|
|
71
|
-
project.db.push({ path: relDbDestPath, name: dbFolder })
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const srvFolder = env.folders.srv.replace(/\/$/, '')
|
|
75
|
-
const relSrvDestPath = path.join(env.build.target, srvFolder).replace(/\\/g, '/')
|
|
76
|
-
project.srvPath = relSrvDestPath
|
|
77
|
-
project.srvName = srvFolder
|
|
78
|
-
|
|
79
|
-
if (env['project-nature'] === 'java') {
|
|
80
|
-
project.language = P_LANGUAGE_JAVA
|
|
81
|
-
project.srvExt = await this._getJavaExtDescriptor(path.resolve(cds.root, srvFolder))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// setting app name, app description...
|
|
85
|
-
await this._setAppDetails(project)
|
|
86
|
-
|
|
87
|
-
// setting required resource information
|
|
88
|
-
this._setResourceDependencies(env, project)
|
|
89
|
-
|
|
90
|
-
DEBUG && DEBUG({ project })
|
|
95
|
+
DEBUG?.({ project })
|
|
91
96
|
return project
|
|
92
97
|
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Determines java specific properties for the given module source path.
|
|
96
|
-
* @param {object} srcPath
|
|
97
|
-
*/
|
|
98
|
-
async _getJavaExtDescriptor(srcPath) {
|
|
99
|
-
// by default spring-boot:repackage is used creating an executable jar archive
|
|
100
|
-
const pom = await parseXml(path.join(srcPath, 'pom.xml'))
|
|
101
|
-
if (pom) {
|
|
102
|
-
const dependencies = pom?.dependencies?.[0]?.dependency
|
|
103
|
-
const isOldJavaRuntime = [...dependencies].some(d => /com\.sap\.cloud\.servicesdk/.test(d?.groupId?.[0]))
|
|
104
|
-
if (isOldJavaRuntime) {
|
|
105
|
-
throw "Projects using the classic CAP Java SDK are not supported"
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const descriptor = { archiveName: path.basename(cds.root) + "-exec.jar" }
|
|
109
|
-
const archiveName = pom?.artifactId?.[0]
|
|
110
|
-
const suffix = pom?.packaging?.[0]
|
|
111
|
-
if (archiveName) descriptor.archiveName = archiveName + '-exec.' + suffix
|
|
112
|
-
return descriptor
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async _setAppDetails(cap) {
|
|
117
|
-
if (cap.language !== P_LANGUAGE_JAVA && cap.language !== P_LANGUAGE_NODEJS) {
|
|
118
|
-
throw Error(`${cap.language} not supported`)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Use either pom.xml or package.json
|
|
122
|
-
if (exists('pom.xml')) {
|
|
123
|
-
const pom = await parseXml('pom.xml')
|
|
124
|
-
const [artifactId] = pom?.artifactId ?? []
|
|
125
|
-
const [description] = pom?.description ?? []
|
|
126
|
-
let [version] = pom?.version ?? []
|
|
127
|
-
// might need to resolve <version>${revision}</version> property
|
|
128
|
-
if (version === '${revision}') {
|
|
129
|
-
version = pom?.properties?.[0].revision[0]
|
|
130
|
-
}
|
|
131
|
-
if (version) {
|
|
132
|
-
// check compliance with mta version format - copied from mbt build error message
|
|
133
|
-
// if not compliant we use a static default value, see below...
|
|
134
|
-
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(version)) {
|
|
135
|
-
cap.appVersion = version
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (artifactId) {
|
|
139
|
-
cap.appName = artifactId.split(/-parent/)[0]
|
|
140
|
-
}
|
|
141
|
-
if (description) {
|
|
142
|
-
cap.appDescription = description
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else if (exists('package.json')) {
|
|
146
|
-
const { name, version, description } = await read('package.json')
|
|
147
|
-
cap.appDescription = cap.appDescription ?? description
|
|
148
|
-
cap.appVersion = cap.appVersion ?? version
|
|
149
|
-
if (name) {
|
|
150
|
-
const segments = name.trim().replace(/@/g, '').split('/').map(encodeURIComponent)
|
|
151
|
-
cap.appName = cap.appName ?? segments[segments.length - 1]
|
|
152
|
-
cap.appId = cap.appId ?? segments.join('.')
|
|
153
|
-
cap.appDescription = cap.appDescription ?? cap.appName
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 2. use project name and static default values
|
|
158
|
-
cap.appName = cap.appName ?? path.basename(cds.root)
|
|
159
|
-
cap.appDescription = cap.appDescription ?? cap.appName + " application"
|
|
160
|
-
cap.appId = cap.appId ?? cap.appName
|
|
161
|
-
cap.appVersion = cap.appVersion ?? '1.0.0'
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// REVISIT: Only used for orphaned cds add cf-manifest. Still needed?
|
|
165
|
-
_setResourceDependencies(env, cap) {
|
|
166
|
-
for (const [key, require] of Object.entries(env.requires)) {
|
|
167
|
-
if (key === 'sql' || key === 'sqlite' || key === 'hana') continue // ignore abstract helper definitions like sql
|
|
168
|
-
const resource = this._getReqResource(key, require, cap)
|
|
169
|
-
if (resource) cap.requires.push({ resource }) // using production profile
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
_getReqResource(key, reqEntry, cap) {
|
|
174
|
-
const { kind, dialect, use, vcap = {}, multiTenant } = reqEntry
|
|
175
|
-
const { appName, isMultitenant } = cap
|
|
176
|
-
const resource = {
|
|
177
|
-
name: !key.includes(appName) ? `${appName}-${key}` : key,
|
|
178
|
-
service: '',
|
|
179
|
-
vcap,
|
|
180
|
-
get isMultitenant() { return isMultitenant || multiTenant || false },
|
|
181
|
-
get isManagedHana() { return this.vcap.label === 'service-manager' || this.service === 'service-manager' },
|
|
182
|
-
get isPlainHana() { return this.service === 'hana' && !this.isManagedHana },
|
|
183
|
-
get isHana() { return this.isPlainHana || this.isManagedHana },
|
|
184
|
-
get isXsuaa() { return this.service === 'xsuaa' },
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
switch (kind) {
|
|
188
|
-
case 'sql':
|
|
189
|
-
case 'hana':
|
|
190
|
-
if (kind === 'sql' && dialect !== 'hana' && use !== 'hana') {
|
|
191
|
-
break
|
|
192
|
-
}
|
|
193
|
-
// use different service name to avoid conflicts when switching from single tenant to multitenant
|
|
194
|
-
// otherwise we would enforce that users have to delete the db container first
|
|
195
|
-
if (resource.isMultitenant) {
|
|
196
|
-
resource.service = 'service-manager'
|
|
197
|
-
resource.vcap.plan = 'container'
|
|
198
|
-
} else {
|
|
199
|
-
resource.service = 'hana'
|
|
200
|
-
resource.vcap.plan = 'hdi-shared'
|
|
201
|
-
}
|
|
202
|
-
break
|
|
203
|
-
|
|
204
|
-
case 'xsuaa':
|
|
205
|
-
resource.service = kind
|
|
206
|
-
resource.vcap.plan = 'application'
|
|
207
|
-
break
|
|
208
|
-
default: {
|
|
209
|
-
vcap.plan ? resource.service = kind : DEBUG && DEBUG(`Skip resource ${key}`)
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return resource.service ? resource : null
|
|
213
|
-
}
|
|
214
98
|
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
const Mustache = require('mustache')
|
|
2
2
|
const { copy, read, write, exists, readdir, path, isdir } = require('../../cds').utils
|
|
3
3
|
|
|
4
|
-
async function copyFiles(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
async function copyFiles(from, into, replacements, overwrite = false) {
|
|
5
|
+
const dirents = await readdir(from)
|
|
6
|
+
await Promise.all(dirents.map(async dirent => {
|
|
7
|
+
const fileNew = Mustache.render(dirent, replacements)
|
|
8
|
+
const src = path.join(from, dirent)
|
|
9
|
+
const dest = path.join(into, fileNew)
|
|
9
10
|
|
|
10
11
|
if (isdir(src)) {
|
|
11
|
-
|
|
12
|
+
return copyFiles(path.join(from, dirent), dest, replacements, overwrite)
|
|
12
13
|
} else if (path.extname(dirent) === '.hbs') {
|
|
13
|
-
const destinationPath = dest.replace('.hbs', '')
|
|
14
|
+
const destinationPath = dest.replace('.hbs', '')
|
|
14
15
|
if (overwrite || !exists(destinationPath)) {
|
|
15
|
-
const content = await render(src,
|
|
16
|
-
await write(destinationPath, content, { spaces: 2 })
|
|
16
|
+
const content = await render(src, replacements)
|
|
17
|
+
await write(destinationPath, content, { spaces: 2 })
|
|
17
18
|
}
|
|
18
19
|
} else {
|
|
19
|
-
|
|
20
|
+
return copy(src, dest)
|
|
20
21
|
}
|
|
21
|
-
}
|
|
22
|
+
}))
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
async function render(src, templateValues) {
|
package/lib/init/util/xml.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { read } = cds.utils
|
|
1
|
+
const { readFileSync } = require('fs')
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
Remove the _text attributes and convert value it into array
|
|
@@ -17,6 +16,8 @@ function _removeTextAttributes(value, parentElement) {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
|
|
19
|
+
// REVISIT: Simplify config
|
|
20
|
+
// REVISIT: fast-xml-parser
|
|
20
21
|
/**
|
|
21
22
|
* Parse a given string containing xml
|
|
22
23
|
* used to remove the _text object from converted json i.e. from xml-js.
|
|
@@ -24,11 +25,10 @@ function _removeTextAttributes(value, parentElement) {
|
|
|
24
25
|
* and after removing textAttributes (using this function): "groupId":["customer"]
|
|
25
26
|
* @param xml string to parse
|
|
26
27
|
* @returns parsed json object
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
async function parseXml(pomXmlPath) {
|
|
28
|
+
*/
|
|
29
|
+
function parseXml(path) {
|
|
30
30
|
const xmljs = require('xml-js')
|
|
31
|
-
const xml =
|
|
31
|
+
const xml = readFileSync(path, { encoding: 'utf-8' })
|
|
32
32
|
return JSON.parse(xmljs.xml2json(xml, {
|
|
33
33
|
ignoreComment: true,
|
|
34
34
|
compact: true,
|
package/lib/util/cfUtil.js
CHANGED
|
@@ -15,7 +15,6 @@ const LOG = cds.log ? cds.log('deploy') : console;
|
|
|
15
15
|
const DEBUG = cds.debug('deploy');
|
|
16
16
|
|
|
17
17
|
const { bold, warn } = require('./term');
|
|
18
|
-
const { CliError } = require('../client/helper/errors');
|
|
19
18
|
|
|
20
19
|
const CF_COMMAND = 'cf';
|
|
21
20
|
|
|
@@ -143,7 +142,7 @@ class CfUtil {
|
|
|
143
142
|
try {
|
|
144
143
|
return (await this._cfRun('oauth-token')).stdout;
|
|
145
144
|
} catch (err) {
|
|
146
|
-
throw
|
|
145
|
+
throw err.message;
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require('axios').interceptors.response.use(
|
|
2
|
+
response => response,
|
|
3
|
+
axError => {
|
|
4
|
+
const { url, method } = axError.config ?? {};
|
|
5
|
+
const { code, response } = axError;
|
|
6
|
+
const { status, data } = response ?? {};
|
|
7
|
+
const reason = data?.error /* RFC 6749 */ ?? axError.message;
|
|
8
|
+
const message = (url && method ? `${method.toUpperCase()} ${url} ` : '') +
|
|
9
|
+
'failed' +
|
|
10
|
+
(status || code ? ':' : '') +
|
|
11
|
+
(status ? ` ${status}` : '') +
|
|
12
|
+
(code ? ` ${code}` : '') +
|
|
13
|
+
`. ${reason}.` +
|
|
14
|
+
(data ? ` Details: '${data.error_description /* RFC 6749 */ || require('util').inspect(data)}'.` : '');
|
|
15
|
+
|
|
16
|
+
const error = new Error(message);
|
|
17
|
+
if (require('../').debug('req')) {
|
|
18
|
+
error.cause = axError;
|
|
19
|
+
}
|
|
20
|
+
return Promise.reject(error);
|
|
21
|
+
}
|
|
22
|
+
);
|
package/lib/watch/open.js
CHANGED
|
@@ -50,7 +50,10 @@ function _open(args) {
|
|
|
50
50
|
args = ['/c', 'start'].concat(args)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const delay = parseInt(process.env.CDS_WATCH_OPEN_DELAY) || 1000
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
childProcess.execFile(command, args, null, err => {
|
|
56
|
+
err && console.error(`Error opening '${command} ${args}' : ${err.message}`)
|
|
57
|
+
})
|
|
58
|
+
}, delay);
|
|
56
59
|
}
|