-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: postgres build plugin w
--production
(#1018)
as reported in the issue, with default `cds build --production` no postgres build artifacts have been generated. this was due to a misconfiguration in our `postgres/package.json` --- ```shell cds init reproduce --add tiny-sample cd reproduce cds add postgres ``` you can now observe the malformed `cds env` ```shell ❯ cds env requires.db --profile production { impl: '@cap-js/postgres', credentials: { url: 'db.sqlite' }, kind: 'sqlite', dialect: 'postgres', vcap: { label: 'postgresql-db' }, schema_evolution: 'auto' } ``` and the broken build (missing postgres build task): ``` ❯ cds build --production building project [/Users/patricebender/SAPDevelop/dev/cds-dbs/postgres/test/tiny-sample], clean [true] cds-dk [8.7.1], cds [8.8.0], compiler [5.7.5], home [/Users/patricebender/SAPDevelop/dev/cds] { build: { target: 'gen', tasks: [ { for: 'nodejs', src: 'srv', options: { model: ['db', 'srv'] }} ] } } ```
- Loading branch information
1 parent
4bc0af2
commit aafffc9
Showing
7 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict' | ||
|
||
// make sure the build plugin works | ||
|
||
const path = require('path') | ||
const fs = require('fs') | ||
const { execSync } = require('child_process') | ||
const cds = require('../../test/cds.js') | ||
|
||
const workDir = path.join(__dirname, 'tiny-sample') | ||
const genDir = path.join(workDir, 'gen') | ||
const dbDest = path.join(genDir, 'pg/db') | ||
|
||
// delete the generated folder after each test | ||
afterEach(() => { | ||
if (fs.existsSync(genDir)) fs.rmSync(genDir, { recursive: true }) | ||
}) | ||
|
||
describe('cds build plugin', () => { | ||
const { expect } = cds.test | ||
test('should run pg build with explicit build task', () => { | ||
execSync('npx cds build --for postgres', { cwd: workDir }) | ||
expect(fs.existsSync(path.join(dbDest, 'csn.json'))).to.be.true | ||
}) | ||
|
||
test('should run pg build with production profile', () => { | ||
execSync('npx cds build --production', { cwd: workDir }) | ||
expect(fs.existsSync(path.join(dbDest, 'csn.json'))).to.be.true | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ID,title,stock | ||
1,Wuthering Heights,100 | ||
2,Jane Eyre,500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace my.bookshop; | ||
|
||
entity Books { | ||
key ID : Integer; | ||
title : String; | ||
stock : Integer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "tiny-sample", | ||
"version": "1.0.0", | ||
"description": "A simple CAP project, to test the build plugin", | ||
"dependencies": { | ||
"@cap-js/postgres": "../../." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using my.bookshop as my from '../db/schema'; | ||
|
||
service CatalogService { | ||
@readonly entity Books as projection on my.Books; | ||
} |