You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "ljmotta (via GitHub)" <gi...@apache.org> on 2025/02/10 22:32:01 UTC

[PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

ljmotta opened a new pull request, #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901

   Closes: https://github.com/apache/incubator-kie-issues/issues/1566
   Closes: https://github.com/apache/incubator-kie-tools/issues/2578
   
   ## Description
   Fully rewrite using Golang to simplify generate native binaries.
   
   Obs: Some usages weren't updated to use the new Darwin and Windows binaries, since they are placed inside a Linux container. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901#discussion_r1956205719


##########
packages/image-env-to-json/package.json:
##########
@@ -14,32 +14,31 @@
   },
   "main": "dist/index.js",
   "scripts": {
-    "build:dev": "rimraf -rf dist && webpack --env dev && pnpm build:standalone:all",
-    "build:prod": "pnpm lint && rimraf -rf dist && webpack && pnpm build:standalone:all",
-    "build:standalone": "run-script-os",
-    "build:standalone:all": "pnpm build:standalone:darwin && pnpm build:standalone:linux && pnpm build:standalone:win32",
-    "build:standalone:darwin": "pkg dist/index.js -t node18-macos-x64 -o dist/macos/image-env-to-json-standalone",
-    "build:standalone:linux": "pkg dist/index.js -t node18-linux-x64 -o dist/linux/image-env-to-json-standalone",
-    "build:standalone:win32": "pkg dist/index.js -t node18-win-x64 -o dist/win/image-env-to-json-standalone",
-    "lint": "run-script-if --bool \"$(build-env linters.run)\" --then \"kie-tools--eslint ./src\""
-  },
-  "dependencies": {
-    "commander": "^8.3.0"
+    "build": "run-script-os",
+    "build:darwin": "pnpm setup:env make build-darwin",
+    "build:darwin:amd": "pnpm setup:env make build-darwin-amd64",
+    "build:darwin:arm": "pnpm setup:env make build-darwin-arm64",
+    "build:dev": "rimraf -rf dist && pnpm build",
+    "build:linux": "pnpm setup:env make build-linux",
+    "build:linux:amd": "pnpm setup:env make build-linux-amd64",
+    "build:linux:arm": "pnpm setup:env make build-linux-arm64",
+    "build:prod": "rimraf -rf dist && run-script-os && pnpm test",
+    "build:prod:darwin": "rimraf dist && pnpm setup:env make build-all",
+    "build:prod:linux": "rimraf dist && pnpm setup:env make build-all",
+    "build:prod:win32": "rimraf dist && pnpm setup:env:win32 make build-all",
+    "build:win32": "pnpm setup:env:win32 make build-win",
+    "build:win32:amd": "pnpm setup:env:win32 make build-win-amd64",
+    "build:win32:arm": "pnpm setup:env:win32 make build-win-arm64",
+    "install": "go mod tidy",
+    "powershell": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command",
+    "setup:env": "cross-env PLUGIN_VERSION=$(build-env imageEnvToJson.version)",
+    "setup:env:win32": "pnpm powershell \"cross-env PLUGIN_VERSION=$(build-env imageEnvToJson.version)\"",

Review Comment:
   Yes, we need to set the environment variables before the `make`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

Posted by "thiagoelg (via GitHub)" <gi...@apache.org>.
thiagoelg commented on code in PR #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901#discussion_r1951057809


##########
packages/image-env-to-json/package.json:
##########
@@ -14,32 +14,31 @@
   },
   "main": "dist/index.js",
   "scripts": {
-    "build:dev": "rimraf -rf dist && webpack --env dev && pnpm build:standalone:all",
-    "build:prod": "pnpm lint && rimraf -rf dist && webpack && pnpm build:standalone:all",
-    "build:standalone": "run-script-os",
-    "build:standalone:all": "pnpm build:standalone:darwin && pnpm build:standalone:linux && pnpm build:standalone:win32",
-    "build:standalone:darwin": "pkg dist/index.js -t node18-macos-x64 -o dist/macos/image-env-to-json-standalone",
-    "build:standalone:linux": "pkg dist/index.js -t node18-linux-x64 -o dist/linux/image-env-to-json-standalone",
-    "build:standalone:win32": "pkg dist/index.js -t node18-win-x64 -o dist/win/image-env-to-json-standalone",
-    "lint": "run-script-if --bool \"$(build-env linters.run)\" --then \"kie-tools--eslint ./src\""
-  },
-  "dependencies": {
-    "commander": "^8.3.0"
+    "build": "run-script-os",
+    "build:darwin": "pnpm setup:env make build-darwin",
+    "build:darwin:amd": "pnpm setup:env make build-darwin-amd64",
+    "build:darwin:arm": "pnpm setup:env make build-darwin-arm64",
+    "build:dev": "rimraf -rf dist && pnpm build",
+    "build:linux": "pnpm setup:env make build-linux",
+    "build:linux:amd": "pnpm setup:env make build-linux-amd64",
+    "build:linux:arm": "pnpm setup:env make build-linux-arm64",
+    "build:prod": "rimraf -rf dist && run-script-os && pnpm test",
+    "build:prod:darwin": "rimraf dist && pnpm setup:env make build-all",
+    "build:prod:linux": "rimraf dist && pnpm setup:env make build-all",
+    "build:prod:win32": "rimraf dist && pnpm setup:env:win32 make build-all",
+    "build:win32": "pnpm setup:env:win32 make build-win",
+    "build:win32:amd": "pnpm setup:env:win32 make build-win-amd64",
+    "build:win32:arm": "pnpm setup:env:win32 make build-win-arm64",
+    "install": "go mod tidy",
+    "powershell": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command",
+    "setup:env": "cross-env PLUGIN_VERSION=$(build-env imageEnvToJson.version)",
+    "setup:env:win32": "pnpm powershell \"cross-env PLUGIN_VERSION=$(build-env imageEnvToJson.version)\"",

Review Comment:
   Is powershell needed even with `cross-env`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on PR #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901#issuecomment-2660167574

   Please add tests for when env vars contain JSON strings too. Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

Posted by "thiagoelg (via GitHub)" <gi...@apache.org>.
thiagoelg commented on code in PR #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901#discussion_r1951057124


##########
packages/image-env-to-json/package.json:
##########
@@ -14,32 +14,31 @@
   },
   "main": "dist/index.js",
   "scripts": {
-    "build:dev": "rimraf -rf dist && webpack --env dev && pnpm build:standalone:all",
-    "build:prod": "pnpm lint && rimraf -rf dist && webpack && pnpm build:standalone:all",
-    "build:standalone": "run-script-os",
-    "build:standalone:all": "pnpm build:standalone:darwin && pnpm build:standalone:linux && pnpm build:standalone:win32",
-    "build:standalone:darwin": "pkg dist/index.js -t node18-macos-x64 -o dist/macos/image-env-to-json-standalone",
-    "build:standalone:linux": "pkg dist/index.js -t node18-linux-x64 -o dist/linux/image-env-to-json-standalone",
-    "build:standalone:win32": "pkg dist/index.js -t node18-win-x64 -o dist/win/image-env-to-json-standalone",
-    "lint": "run-script-if --bool \"$(build-env linters.run)\" --then \"kie-tools--eslint ./src\""
-  },
-  "dependencies": {
-    "commander": "^8.3.0"
+    "build": "run-script-os",
+    "build:darwin": "pnpm setup:env make build-darwin",
+    "build:darwin:amd": "pnpm setup:env make build-darwin-amd64",
+    "build:darwin:arm": "pnpm setup:env make build-darwin-arm64",
+    "build:dev": "rimraf -rf dist && pnpm build",
+    "build:linux": "pnpm setup:env make build-linux",
+    "build:linux:amd": "pnpm setup:env make build-linux-amd64",
+    "build:linux:arm": "pnpm setup:env make build-linux-arm64",
+    "build:prod": "rimraf -rf dist && run-script-os && pnpm test",
+    "build:prod:darwin": "rimraf dist && pnpm setup:env make build-all",
+    "build:prod:linux": "rimraf dist && pnpm setup:env make build-all",
+    "build:prod:win32": "rimraf dist && pnpm setup:env:win32 make build-all",
+    "build:win32": "pnpm setup:env:win32 make build-win",
+    "build:win32:amd": "pnpm setup:env:win32 make build-win-amd64",
+    "build:win32:arm": "pnpm setup:env:win32 make build-win-arm64",

Review Comment:
   I think we should build all binaries every time (on build:dev and build:prod). It should be quick, and we can avoid issues where, for example, we test the binary in a macOS ARM environment but then run it inside a Linux x64 container.
   
   It would also simplify this list of scripts in the package.json.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

Posted by "thiagoelg (via GitHub)" <gi...@apache.org>.
thiagoelg commented on code in PR #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901#discussion_r1951047401


##########
packages/image-env-to-json/Makefile:
##########
@@ -0,0 +1,84 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+SHELL := sh
+
+ifeq ($(OS),Windows_NT)
+    SHELL := powershell.exe
+    .SHELLFLAGS := -NoProfile -ExecutionPolicy Bypass -Command
+endif
+
+BIN              := image-env-to-json
+BIN_DARWIN_AMD   ?= $(BIN)-darwin-amd64
+BIN_DARWIN_ARM   ?= $(BIN)-darwin-arm64
+BIN_LINUX_AMD    ?= $(BIN)-linux-amd64
+BIN_LINUX_ARM    ?= $(BIN)-linux-arm64
+BIN_WINDOWS_AMD  ?= $(BIN)-windows-amd64.exe
+BIN_WINDOWS_ARM  ?= $(BIN)-windows-arm64.exe
+
+BIN_PATH         := dist
+MAIN_PATH        := main.go
+
+METADATA_PATH                 := github.com/apache/incubator-kie-tools/packages/image-env-to-json/internal
+SET_VERSION                   := $(METADATA_PATH).Version=$(PLUGIN_VERSION)
+LDFLAGS                       := "-X $(SET_VERSION)"
+
+ARCH := $(shell uname -m)
+ifeq ($(ARCH),arm64)
+	GOARCH = arm64
+	BIN_BUILD_DARWIN=$(BIN_DARWIN_ARM)
+	BIN_BUILD_LINUX=$(BIN_LINUX_ARM)
+	BIN_BUILD_WINDOWS=$(BIN_WINDOWS_ARM)
+else
+	GOARCH = amd64
+	BIN_BUILD_DARWIN=$(BIN_DARWIN_AMD)
+	BIN_BUILD_LINUX=$(BIN_LINUX_AMD)
+	BIN_BUILD_WINDOWS=$(BIN_WINDOWS_AMD)
+endif
+
+build-all: build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-linux-arm64 build-win-amd64 build-win-arm64
+
+build-darwin:
+	CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags $(LDFLAGS) -o $(BIN_PATH)/$(BIN_BUILD_DARWIN) $(MAIN_PATH)

Review Comment:
   I know it's not ideal, but in other packages, we use `cross-env` here to avoid OS-specific errors when cross-building.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1566: Remove `pkg` dependency from `image-env-to-json` on kie-tools, as it's deprecated [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento merged PR #2901:
URL: https://github.com/apache/incubator-kie-tools/pull/2901


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org