tiagobento commented on code in PR #3181:
URL:
https://github.com/apache/incubator-kie-tools/pull/3181#discussion_r2150134138
##########
packages/kogito-base-builder-image/install.js:
##########
@@ -17,48 +17,18 @@
* 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.kogitoBaseBuilderImage.buildTag} --source-folder ./resources`,
- { stdio: "inherit" }
-);
-
-// Find and read the -image.yaml file
-const resourcesPath = path.resolve(__dirname, "./resources");
-const files = fs.readdirSync(resourcesPath);
-const imageYamlFiles = files.filter((fileName) =>
fileName.endsWith("-image.yaml"));
-if (imageYamlFiles.length !== 1) {
- throw new Error("There should only be one -image.yaml file on ./resources!");
-}
-const originalYamlPath = path.join(resourcesPath, imageYamlFiles[0]);
-let imageYaml = fs.readFileSync(originalYamlPath, "utf8");
+// import the function you exported
+const { runKogitoImageInstall } = require("@kie/kogito-images-install-helper");
-const imageUrl =
`${env.kogitoBaseBuilderImage.registry}/${env.kogitoBaseBuilderImage.account}/${env.kogitoBaseBuilderImage.name}`;
-
-// Replace the whole string between quotes ("") with the image name
-imageYaml = imageYaml.replace(/(?<=")(.*kogito-base-builder.*)(?=")/gm,
imageUrl);
-
-// Write file and then rename it to match the image name
-fs.writeFileSync(originalYamlPath, imageYaml);
-fs.renameSync(originalYamlPath, path.join(resourcesPath,
`${env.kogitoBaseBuilderImage.name}-image.yaml`));
-
-// Replace image URL in .feature files
-replaceInFile.sync({
- files: ["**/*.feature"],
- from: /@docker.io\/apache\/.*/g,
- to: `@${imageUrl}`,
+// grab your package's env object
Review Comment:
Leftover comment? They are in other files too.
##########
packages/kogito-base-builder-image/install.js:
##########
@@ -17,48 +17,18 @@
* 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.kogitoBaseBuilderImage.buildTag} --source-folder ./resources`,
- { stdio: "inherit" }
-);
-
-// Find and read the -image.yaml file
-const resourcesPath = path.resolve(__dirname, "./resources");
-const files = fs.readdirSync(resourcesPath);
-const imageYamlFiles = files.filter((fileName) =>
fileName.endsWith("-image.yaml"));
-if (imageYamlFiles.length !== 1) {
- throw new Error("There should only be one -image.yaml file on ./resources!");
-}
-const originalYamlPath = path.join(resourcesPath, imageYamlFiles[0]);
-let imageYaml = fs.readFileSync(originalYamlPath, "utf8");
+// import the function you exported
Review Comment:
Leftover comment?
##########
packages/kogito-base-builder-image/install.js:
##########
@@ -17,48 +17,18 @@
* 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.kogitoBaseBuilderImage.buildTag} --source-folder ./resources`,
- { stdio: "inherit" }
-);
-
-// Find and read the -image.yaml file
-const resourcesPath = path.resolve(__dirname, "./resources");
-const files = fs.readdirSync(resourcesPath);
-const imageYamlFiles = files.filter((fileName) =>
fileName.endsWith("-image.yaml"));
-if (imageYamlFiles.length !== 1) {
- throw new Error("There should only be one -image.yaml file on ./resources!");
-}
-const originalYamlPath = path.join(resourcesPath, imageYamlFiles[0]);
-let imageYaml = fs.readFileSync(originalYamlPath, "utf8");
+// import the function you exported
+const { runKogitoImageInstall } = require("@kie/kogito-images-install-helper");
-const imageUrl =
`${env.kogitoBaseBuilderImage.registry}/${env.kogitoBaseBuilderImage.account}/${env.kogitoBaseBuilderImage.name}`;
-
-// Replace the whole string between quotes ("") with the image name
-imageYaml = imageYaml.replace(/(?<=")(.*kogito-base-builder.*)(?=")/gm,
imageUrl);
-
-// Write file and then rename it to match the image name
-fs.writeFileSync(originalYamlPath, imageYaml);
-fs.renameSync(originalYamlPath, path.join(resourcesPath,
`${env.kogitoBaseBuilderImage.name}-image.yaml`));
-
-// Replace image URL in .feature files
-replaceInFile.sync({
- files: ["**/*.feature"],
- from: /@docker.io\/apache\/.*/g,
- to: `@${imageUrl}`,
+// grab your package's env object
+const { env } = require("./env");
+const { buildTag, registry, account, name: imageName } =
env.kogitoBaseBuilderImage;
Review Comment:
😍
--
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]