Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: cds command executed outside the root of application cause undefined error #88

Open
zongqichen opened this issue Oct 30, 2024 · 0 comments
Assignees
Labels
bug Something isn't working external todos good first issue Good for newcomers

Comments

@zongqichen
Copy link
Contributor

zongqichen commented Oct 30, 2024

I want to output ord document as static file and validate it in github action workflow:

    steps:
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "18"

      - name: Install dependencies and prepare documents
        run: |
          npm install -g @sap/cds-dk
          npm install @sap/cds
          npm install https://github.com/cap-js/ord#fix_undefined
          cds compile ./ariba/srv --to ord -o ./tmp_documents/ariba.json
          cds compile ./cloud/srv --to ord -o ./tmp_documents/cloud.json
          cds compile ./erp/srv --to ord -o ./tmp_documents/erp.json

I create a debug branch and add two logger info, which prints out package name value.
The error shows:

packageName: undefined
[ord-plugin] - logger packageName undefined
TypeError: Cannot read properties of undefined (reading 'replace')
    at initializeAppConfig (/opt/actions-runner/_work/oid-cap-reference-app/oid-cap-reference-app/node_modules/@cap-js/ord/lib/ord.js:26:38)
    at module.exports (/opt/actions-runner/_work/oid-cap-reference-app/oid-cap-reference-app/node_modules/@cap-js/ord/lib/ord.js:151:23)
    at /opt/actions-runner/_work/_tool/node/18.20.3/x64/lib/node_modules/@sap/cds-dk/bin/compile/index.js:315:36
    at Generator.next (<anonymous>)
    at _write (/opt/actions-runner/_work/_tool/node/18.20.3/x64/lib/node_modules/@sap/cds-dk/lib/util/write.js:65:[28](https://github.tools.sap/CPA/oid-cap-reference-app/actions/runs/8966939/job/36012553?pr=49#step:6:29))
    at Object.to (/opt/actions-runner/_work/_tool/node/18.20.3/x64/lib/node_modules/@sap/cds-dk/lib/util/write.js:40:42)
    at /opt/actions-runner/_work/_tool/node/18.20.3/x64/lib/node_modules/@sap/cds-dk/lib/util/write.js:53:49
    at async Object.exec (/opt/actions-runner/_work/_tool/node/18.20.3/x64/lib/node_modules/@sap/cds-dk/bin/cds.js:91:16)
Error: Process completed with exit code 1.

Diagnose:

I think the problem is how do we define the packageJsonPath. The current implementation is:

    let packagejsonPath = path.join(cds.root, 'package.json')

which we use cds.root as base path. However, when we want to use cds command line to output ord static file, the cds command could be executed in anywhere.

Propose:

We need to stick to the path where srv folder is.

@zongqichen zongqichen added the bug Something isn't working label Oct 30, 2024
@zongqichen zongqichen changed the title Fix: packageName is undefined on github action Fix: cds command executed outside the root of application cause undefined error Oct 30, 2024
@zongqichen zongqichen added the good first issue Good for newcomers label Nov 27, 2024
@nirooxx nirooxx self-assigned this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external todos good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants