@cap-js/cds-types 0.6.4 → 0.6.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-types",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Type definitions for main packages of CAP, like `@sap/cds`",
5
5
  "repository": "github:cap-js/cds-types",
6
6
  "homepage": "https://cap.cloud.sap/",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "test": "jest --silent",
23
- "test:integration": "jest --silent --testMatch \"**/test/**/*.integrationtest.js\"",
23
+ "test:integration": "jest --testMatch \"**/test/**/*.integrationtest.js\"",
24
24
  "test:rollup": "npm run rollup; npm run rollup:on; npm run test; npm run rollup:off",
25
25
  "rollup": "rm -rf dist/ && mkdir -p etc/ && npx -y @microsoft/api-extractor run --local --verbose && .github/rollup-patch.js",
26
26
  "rollup:on": "npm pkg set typings=dist/cds-types.d.ts && [ -d 'apis' ] && mv -- apis -apis || true",
@@ -43,7 +43,7 @@
43
43
  "@stylistic/eslint-plugin-js": "^2.1.0",
44
44
  "@stylistic/eslint-plugin-ts": "^2.1.0",
45
45
  "@types/jest": "^29.5.11",
46
- "@types/node": "^20",
46
+ "@types/node": "^22",
47
47
  "axios": "^1.6.2",
48
48
  "chai": "^4.3.10",
49
49
  "eslint": "^9.2.0",
@@ -3,19 +3,20 @@
3
3
  /* eslint-disable no-undef */
4
4
  /* eslint-disable @typescript-eslint/no-require-imports */
5
5
  const fs = require('node:fs')
6
- const { join, relative, dirname } = require('node:path')
6
+ const { join, relative, dirname, resolve } = require('node:path')
7
7
 
8
8
  if (!process.env.INIT_CWD) return
9
- // TODO: check if were in a local install
9
+
10
10
  const nodeModules = join(process.env.INIT_CWD, 'node_modules')
11
- if (!fs.existsSync(nodeModules)) return
12
11
  const typesDir = join(nodeModules, '@types')
13
- if (!fs.existsSync(typesDir)) fs.mkdirSync(typesDir)
12
+ // we may have to create node_modules altogether in case of a mono repo
13
+ if (!fs.existsSync(typesDir)) fs.mkdirSync(typesDir, {recursive: true})
14
14
 
15
15
  // use a relative target, in case the user moves the project
16
16
  const target = join(typesDir, 'sap__cds')
17
- const src = join(nodeModules, '@cap-js/cds-types')
17
+ const src = resolvePkg('@cap-js/cds-types') ?? join(nodeModules, '@cap-js/cds-types')
18
18
  const rel = relative(dirname(target), src) // need dirname or we'd land one level above node_modules (one too many "../")
19
+ console.log(`Creating symlink ${target} -> ${rel}`)
19
20
 
20
21
  // remove the existing symlink
21
22
  try {
@@ -31,3 +32,12 @@ try {
31
32
  if (e.code !== 'EEXIST') throw e
32
33
  // else: symlink exists (the previous unlink hasn't worked), ignore
33
34
  }
35
+
36
+ function resolvePkg(pkg) {
37
+ try {
38
+ const pjson = require.resolve(join(pkg, 'package.json'), { paths: [process.env.INIT_CWD] })
39
+ return resolve(pjson, '..')
40
+ } catch {
41
+ return null
42
+ }
43
+ }