Skip to content

Commit

Permalink
chore: Add cjs check (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfrenken authored Aug 22, 2024
1 parent 44c24df commit 350e836
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- run: pnpm i --frozen-lockfile
# - run: pnpm build # might be needed in the future
- run: pnpm lint
- run: pnpm compile:cjs

build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: "Check Sample App Starts Up"
working-directory: ./sample-code
run: |
pnpm run local &
pnpm local &
timeout=15
while ! nc -z localhost 8080; do
sleep 1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
dist-cjs
node_modules
coverage

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"type": "module",
"scripts": {
"postinstall": "pnpm compile",
"compile": "pnpm -r -w=false run compile",
"compile": "pnpm -r compile",
"compile:cjs": "pnpm -r -F=./packages/** compile:cjs",
"test:unit": "pnpm -r -F=./packages/** test",
"test:type": "pnpm -F=@sap-ai-sdk/type-tests test",
"test:e2e": "pnpm -F=@sap-ai-sdk/e2e-tests test",
Expand Down
1 change: 1 addition & 0 deletions packages/ai-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"scripts": {
"compile": "tsc",
"compile:cjs": "tsc -p tsconfig.cjs.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"lint": "eslint . && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c",
"lint:fix": "eslint . --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error",
Expand Down
7 changes: 7 additions & 0 deletions packages/ai-core/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist-cjs"
}
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"scripts": {
"compile": "tsc",
"compile:cjs": "tsc -p tsconfig.cjs.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"lint": "eslint . && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c",
"lint:fix": "eslint . --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error"
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export {
executeRequest,
BaseLlmParametersWithDeploymentId,
BaseLlmParameters,
CustomRequestConfig
CustomRequestConfig,
EndpointOptions
} from './http-client.js';
export { getAiCoreDestination } from './context.js';
export { OpenApiRequestBuilder } from './openapi-request-builder.js';
7 changes: 7 additions & 0 deletions packages/core/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist-cjs"
}
}
1 change: 1 addition & 0 deletions packages/gen-ai-hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],
"scripts": {
"compile": "tsc",
"compile:cjs": "tsc -p tsconfig.cjs.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"lint": "eslint . && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c",
"lint:fix": "eslint . --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error",
Expand Down
7 changes: 7 additions & 0 deletions packages/gen-ai-hub/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist-cjs"
}
}
2 changes: 1 addition & 1 deletion sample-code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Build the project with:
2. Download a service key for your AI Core service instance
3. Create a `.env` file in the sample-code directory
4. Add an entry `AICORE_SERVICE_KEY='<content-of-service-key>'`
5. `pnpm run local`
5. `pnpm local`

Call the test endpoints:

Expand Down
5 changes: 2 additions & 3 deletions test-util/mock-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { DestinationAuthToken, HttpDestination, ServiceCredentials } from '@sap-
import nock from 'nock';
import {
BaseLlmParameters,
CustomRequestConfig
} from '@sap-ai-sdk/core';
import { EndpointOptions } from '@sap-ai-sdk/core/src/http-client.js';
CustomRequestConfig,
EndpointOptions } from '@sap-ai-sdk/core';
import { dummyToken } from './mock-jwt.js';

// Get the directory of this file
Expand Down

0 comments on commit 350e836

Please sign in to comment.