tiagobento commented on code in PR #3181:
URL:
https://github.com/apache/incubator-kie-tools/pull/3181#discussion_r2143437687
##########
packages/kogito-images-install-helper/package.json:
##########
@@ -0,0 +1,33 @@
+{
+ "private": true,
+ "name": "@kie/kogito-images-install-helper",
+ "version": "0.0.0",
+ "description": "Shared install helper for Kogito images",
Review Comment:
```suggestion
"description": "Install helper for Kogito images",
```
##########
packages/kogito-images-install-helper/index.js:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+const { execSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+const replaceInFile = require("replace-in-file");
+const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } =
require("@kie-tools/maven-base");
+
+// Constants for dependent packages
+const PYTHON_VENV_PKG = "@kie-tools/python-venv";
+const IMAGE_COMMON_PKG = "@kie-tools/sonataflow-image-common";
+
+/**
+ * Shared install routine for bumping versions, configuring Maven and updating
YAMLs/features.
Review Comment:
```suggestion
* Install routine for Kogito images. Helps with bumping versions,
configuring Maven, and updating YAMLs/features.
```
##########
packages/kogito-images-install-helper/index.js:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+const { execSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+const replaceInFile = require("replace-in-file");
+const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } =
require("@kie-tools/maven-base");
+
+// Constants for dependent packages
+const PYTHON_VENV_PKG = "@kie-tools/python-venv";
+const IMAGE_COMMON_PKG = "@kie-tools/sonataflow-image-common";
Review Comment:
Why extract to constants?
##########
packages/kogito-jit-runner-image/install.js:
##########
@@ -17,48 +17,15 @@
* under the License.
*/
-const { execSync } = require("child_process");
-const fs = require("fs");
-
-const { env } = require("./env");
const path = require("path");
-const pythonVenvDir =
path.dirname(require.resolve("@kie-tools/python-venv/package.json"));
-const sonataflowImageCommonDir =
path.dirname(require.resolve("@kie-tools/sonataflow-image-common/package.json"));
-const replaceInFile = require("replace-in-file");
-
-const activateCmd =
- process.platform === "win32"
- ? `${pythonVenvDir}\\venv\\Scripts\\Activate.bat`
- : `. ${pythonVenvDir}/venv/bin/activate`;
-
-execSync(
- `${activateCmd} && \
- python3 ${sonataflowImageCommonDir}/resources/scripts/versions_manager.py
--bump-to ${env.kogitoJitRunnerImage.buildTag} --source-folder ./resources`,
- { stdio: "inherit" }
-);
+// import the function you exported
Review Comment:
Not sure I understand this comment.
##########
packages/kogito-images-install-helper/index.js:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+const { execSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+const replaceInFile = require("replace-in-file");
+const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } =
require("@kie-tools/maven-base");
+
+// Constants for dependent packages
+const PYTHON_VENV_PKG = "@kie-tools/python-venv";
+const IMAGE_COMMON_PKG = "@kie-tools/sonataflow-image-common";
+
+/**
+ * Shared install routine for bumping versions, configuring Maven and updating
YAMLs/features.
+ * @param {{ imageEnv: { buildTag:string, registry:string, account:string,
name:string }, resourceDir?: string, finalImageName: string, requiresMvn:
boolean }} options
+ */
+function runSharedInstall({ imageEnv, resourceDir = "./resources",
finalImageName, requiresMvn = true }) {
+ if (!finalImageName) {
+ throw new Error("'finalImageName' parameter is required");
+ }
+ if (!imageEnv) {
+ throw new Error("'imageEnv' parameter is required");
+ }
+
+ // 1) Maven revision and tail
+ if (requiresMvn) {
+ const { version } = require(path.resolve(__dirname, "package.json"));
+ setupMavenConfigFile(
+ `
+ -Drevision=${version}
+ -Dmaven.repo.local.tail=${buildTailFromPackageJsonDependencies()}
Review Comment:
Gotta double-check if this will use the current package's `package.json` to
build the tail, or the directory where it was ran.
##########
packages/kogito-images-install-helper/index.js:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+const { execSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+const replaceInFile = require("replace-in-file");
+const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } =
require("@kie-tools/maven-base");
+
+// Constants for dependent packages
+const PYTHON_VENV_PKG = "@kie-tools/python-venv";
+const IMAGE_COMMON_PKG = "@kie-tools/sonataflow-image-common";
+
+/**
+ * Shared install routine for bumping versions, configuring Maven and updating
YAMLs/features.
+ * @param {{ imageEnv: { buildTag:string, registry:string, account:string,
name:string }, resourceDir?: string, finalImageName: string, requiresMvn:
boolean }} options
+ */
+function runSharedInstall({ imageEnv, resourceDir = "./resources",
finalImageName, requiresMvn = true }) {
+ if (!finalImageName) {
+ throw new Error("'finalImageName' parameter is required");
+ }
+ if (!imageEnv) {
+ throw new Error("'imageEnv' parameter is required");
+ }
Review Comment:
I think it's not a good idea to pass the `env` object around like this. It
hurts the grep test, creates indirection, and start a "meta framework" around
envs. I guess I'd prefer if you'd transform the env in four separate arguments
so that we don't create too many abstractions on top of envs.
##########
packages/kogito-images-install-helper/index.js:
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+const { execSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+const replaceInFile = require("replace-in-file");
+const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } =
require("@kie-tools/maven-base");
+
+// Constants for dependent packages
+const PYTHON_VENV_PKG = "@kie-tools/python-venv";
+const IMAGE_COMMON_PKG = "@kie-tools/sonataflow-image-common";
+
+/**
+ * Shared install routine for bumping versions, configuring Maven and updating
YAMLs/features.
+ * @param {{ imageEnv: { buildTag:string, registry:string, account:string,
name:string }, resourceDir?: string, finalImageName: string, requiresMvn:
boolean }} options
+ */
+function runSharedInstall({ imageEnv, resourceDir = "./resources",
finalImageName, requiresMvn = true }) {
Review Comment:
```suggestion
function runKogitoImageInstall({ imageEnv, resourceDir = "./resources",
finalImageName, requiresMvn = true }) {
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]