From dedf13f0a704f8248ee4f8e1a9f7584a4fb1a909 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Wed, 26 Mar 2025 11:22:31 -0500 Subject: [PATCH] Removes prebuild script (which creates src/version.ts) and replace with direct reference to pull the value from package.json Signed-off-by: Whit Waldo --- package.json | 17 ++++----- scripts/prebuild.sh | 38 ------------------- scripts/test-e2e-common.sh | 2 - .../Client/GRPCClient/GRPCClient.ts | 3 +- .../Client/HTTPClient/HTTPClient.ts | 3 +- 5 files changed, 12 insertions(+), 51 deletions(-) delete mode 100755 scripts/prebuild.sh diff --git a/package.json b/package.json index 86920ee6..f197c98e 100644 --- a/package.json +++ b/package.json @@ -10,17 +10,17 @@ "test:e2e": "jest --runInBand --detectOpenHandles", "test:e2e:all": "npm run test:e2e:http && npm run test:e2e:grpc && npm run test:e2e:common && npm run test:e2e:workflow", "test:e2e:grpc": "npm run test:e2e:grpc:client && npm run test:e2e:grpc:server && npm run test:e2e:grpc:clientWithApiToken", - "test:e2e:grpc:client": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/*client.test.ts' ]", - "test:e2e:grpc:clientWithApiToken": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 DAPR_API_TOKEN=test dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/clientWithApiToken.test.ts' ]", - "test:e2e:grpc:server": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --max-body-size 10Mi --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/*server.test.ts' ]", + "test:e2e:grpc:client": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/*client.test.ts' ]", + "test:e2e:grpc:clientWithApiToken": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 DAPR_API_TOKEN=test dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/clientWithApiToken.test.ts' ]", + "test:e2e:grpc:server": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --max-body-size 10Mi --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/*server.test.ts' ]", "test:e2e:http": "npm run test:e2e:http:client && npm run test:e2e:http:server && npm run test:e2e:http:actors", - "test:e2e:http:client": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/http/(client).test.ts' ]", - "test:e2e:http:server": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --max-body-size 10Mi --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/http/(server).test.ts' ]", - "test:e2e:http:actors": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/http/actors.test.ts' ]", + "test:e2e:http:client": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/http/(client).test.ts' ]", + "test:e2e:http:server": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --max-body-size 10Mi --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/http/(server).test.ts' ]", + "test:e2e:http:actors": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --resources-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/http/actors.test.ts' ]", "test:e2e:common": "npm run test:e2e:common:client && npm run test:e2e:common:server", "test:e2e:common:client": "./scripts/test-e2e-common.sh client", "test:e2e:common:server": "./scripts/test-e2e-common.sh server", - "test:e2e:workflow": "npm run prebuild && dapr run --app-id workflow-test-suite --app-protocol grpc --dapr-grpc-port 4001 --resources-path ./test/components/workflow -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/workflow/workflow.test.ts' ]", + "test:e2e:workflow": "dapr run --app-id workflow-test-suite --app-protocol grpc --dapr-grpc-port 4001 --resources-path ./test/components/workflow -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/workflow/workflow.test.ts' ]", "test:e2e:workflow:internal": "jest test/e2e/workflow --runInBand --detectOpenHandles", "test:e2e:workflow:durabletask": "./scripts/test-e2e-workflow.sh", "test:unit": "jest --runInBand --detectOpenHandles", @@ -35,8 +35,7 @@ "test:unit:errors": "NODE_ENV=test npm run test:unit 'test/unit/errors/.*\\.test\\.ts'", "test:unit:workflow": "NODE_ENV=test npm run test:unit 'test/unit/workflow/.*\\.test\\.ts'", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", - "prebuild": "./scripts/prebuild.sh", - "build-ci": "npm run prebuild && ./scripts/build.sh", + "build-ci": "./scripts/build.sh", "build": "npm install && npm run lint && ./scripts/build.sh", "start:dev": "npm run build && nodemon --ext \".ts,.js\" --watch \"./src\" --exec \"npm run build\"", "pretty": "prettier --list-different \"**/*.{ts,tsx,js,jsx,json,md}\"", diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh deleted file mode 100755 index caff75a5..00000000 --- a/scripts/prebuild.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright 2022 The Dapr Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script generates a typescript file with constants -# for the SDK version and the SDK package name. - -FILENAME="src/version.ts" -HEADER="/* -Copyright 2022 The Dapr Authors -Licensed under the Apache License, Version 2.0 (the \"License\"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an \"AS IS\" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This file is auto-generated by the prebuild script from package.json. -// It is not checked in to the git repository. -" - -echo "$HEADER" > $FILENAME - -node -p "'export const SDK_VERSION = ' + JSON.stringify(require('./package.json').version) + ';\n\ -export const SDK_PACKAGE_NAME = ' + JSON.stringify(require('./package.json').name) + ';'" >> $FILENAME diff --git a/scripts/test-e2e-common.sh b/scripts/test-e2e-common.sh index b0a2360d..afd301ce 100755 --- a/scripts/test-e2e-common.sh +++ b/scripts/test-e2e-common.sh @@ -49,8 +49,6 @@ stop_dapr() { trap stop_dapr ERR -npm run prebuild - echo "[SCRIPT] Starting Dapr instances..." # Run Dapr with gRPC diff --git a/src/implementation/Client/GRPCClient/GRPCClient.ts b/src/implementation/Client/GRPCClient/GRPCClient.ts index a73b51f2..79c2ef10 100644 --- a/src/implementation/Client/GRPCClient/GRPCClient.ts +++ b/src/implementation/Client/GRPCClient/GRPCClient.ts @@ -19,7 +19,8 @@ import { Settings } from "../../../utils/Settings.util"; import { Logger } from "../../../logger/Logger"; import GRPCClientSidecar from "./sidecar"; import DaprClient from "../DaprClient"; -import { SDK_VERSION } from "../../../version"; +// @ts-ignore +import { version as SDK_VERSION } from "../../../../package.json"; import communicationProtocolEnum from "../../../enum/CommunicationProtocol.enum"; import { GrpcEndpoint } from "../../../network/GrpcEndpoint"; diff --git a/src/implementation/Client/HTTPClient/HTTPClient.ts b/src/implementation/Client/HTTPClient/HTTPClient.ts index eb08d83f..5c1557b2 100644 --- a/src/implementation/Client/HTTPClient/HTTPClient.ts +++ b/src/implementation/Client/HTTPClient/HTTPClient.ts @@ -21,7 +21,8 @@ import { Settings } from "../../../utils/Settings.util"; import { THTTPExecuteParams } from "../../../types/http/THTTPExecuteParams.type"; import { Logger } from "../../../logger/Logger"; import HTTPClientSidecar from "./sidecar"; -import { SDK_VERSION } from "../../../version"; +// @ts-ignore +import { version as SDK_VERSION } from "../../../../package.json"; import * as SerializerUtil from "../../../utils/Serializer.util"; import communicationProtocolEnum from "../../../enum/CommunicationProtocol.enum"; import { HttpEndpoint } from "../../../network/HttpEndpoint";