Skip to content

Commit 5bc8eee

Browse files
authored
docs: Add warning message to dapr-client builds (#313)
* Add warning message on using dapr-client Signed-off-by: Shubham Sharma <[email protected]> * Fix script Signed-off-by: Shubham Sharma <[email protected]> * Update build step Signed-off-by: Shubham Sharma <[email protected]> * Typecast to prevent TS2367 Signed-off-by: Shubham Sharma <[email protected]> * Check-in version file to version control Signed-off-by: Shubham Sharma <[email protected]> * Remove unused linter comment Signed-off-by: Shubham Sharma <[email protected]> * Do not track version file Signed-off-by: Shubham Sharma <[email protected]> * Updates Signed-off-by: Shubham Sharma <[email protected]>
1 parent 8bbfdbd commit 5bc8eee

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
registry-url: 'https://registry.npmjs.org'
4444

4545
- name: Build Package
46-
run: ./scripts/build.sh
46+
run: npm run build
4747

4848
# @TODO: add a depend on the test-e2e pipeline?
4949
- name: Run unit tests
@@ -70,7 +70,7 @@ jobs:
7070

7171
- name: "[dapr-client] Build Package"
7272
if: env.DEPLOY_PACKAGE == 'true'
73-
run: ./scripts/build.sh
73+
run: npm run build
7474

7575
# note: package.json gets updated here for the new package name
7676
- name: "[dapr-client] Publish to npm (dapr-client)"

.github/workflows/test-e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ jobs:
121121
node-version: ${{ env.NODE_VER }}
122122
registry-url: 'https://registry.npmjs.org'
123123

124-
- name: Install NPM Dependencies
125-
run: npm i
124+
- name: Build Package
125+
run: npm run build
126126

127127
- name: Run E2E tests
128128
id: tests

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,7 @@ tmp/
141141
temp/
142142

143143
# dapr-js-sdk
144-
build/
144+
build/
145+
146+
# version file is auto-generated
147+
src/version.ts

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test:unit:logger": "NODE_ENV=test npm run test:unit 'test/unit/logger/.*\\.test\\.ts'",
2020
"test:unit:utils": "NODE_ENV=test npm run test:unit 'test/unit/utils/.*\\.test\\.ts'",
2121
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
22+
"prebuild": "./scripts/prebuild.sh",
2223
"build": "./scripts/build.sh",
2324
"start:dev": "npm run build && nodemon --ext \".ts,.js\" --watch \"./src\" --exec \"npm run build\""
2425
},

scripts/prebuild.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2022 The Dapr Authors
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# This script generates a typescript file with constants
15+
# for the SDK version and the SDK package name.
16+
17+
FILENAME="src/version.ts"
18+
HEADER="/*
19+
Copyright 2022 The Dapr Authors
20+
Licensed under the Apache License, Version 2.0 (the \"License\");
21+
you may not use this file except in compliance with the License.
22+
You may obtain a copy of the License at
23+
http://www.apache.org/licenses/LICENSE-2.0
24+
Unless required by applicable law or agreed to in writing, software
25+
distributed under the License is distributed on an \"AS IS\" BASIS,
26+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
See the License for the specific language governing permissions and
28+
limitations under the License.
29+
*/
30+
31+
// This file is auto-generated by the prebuild script from package.json.
32+
// It is not checked in to the git repository.
33+
34+
"
35+
36+
echo "$HEADER" > $FILENAME
37+
38+
node -p "'export const SDK_VERSION = ' + JSON.stringify(require('./package.json').version) + ';\n\
39+
export const SDK_PACKAGE_NAME = ' + JSON.stringify(require('./package.json').name) + ';'" >> $FILENAME

src/implementation/Client/DaprClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { DaprClientOptions } from '../../types/DaprClientOptions';
5656
import { Settings } from '../../utils/Settings.util';
5757
import { Logger } from '../../logger/Logger';
5858
import GRPCClientProxy from "./GRPCClient/proxy";
59+
import { SDK_PACKAGE_NAME } from "../../version";
5960

6061
export default class DaprClient {
6162
readonly daprHost: string;
@@ -95,6 +96,10 @@ export default class DaprClient {
9596
throw new Error('DAPR_INCORRECT_SIDECAR_PORT');
9697
}
9798

99+
if (String(SDK_PACKAGE_NAME) === "dapr-client") {
100+
this.logger.warn("dapr-client is deprecated. Please use @dapr/dapr instead. For more information, see https://github.com/dapr/js-sdk/issues/259")
101+
}
102+
98103
// Builder
99104
switch (communicationProtocol) {
100105
case CommunicationProtocolEnum.GRPC: {

0 commit comments

Comments
 (0)