Skip to content

Commit 1116d3b

Browse files
authored
[OSD][Build] nvm use (#1905)
* [OSD][Build] nvm use Within OSD we have a .nvmrc file that is used when `nvm use` is executing. So we can use the right node version for the build. Issue: n/a Signed-off-by: Kawika Avilla <kavilla414@gmail.com> * source it Signed-off-by: Kawika Avilla <kavilla414@gmail.com> * update dev doc Signed-off-by: Kawika Avilla <kavilla414@gmail.com> * source in shell Signed-off-by: Kawika Avilla <kavilla414@gmail.com> * plugin builder Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
1 parent 7c4cb71 commit 1116d3b

File tree

11 files changed

+24
-16
lines changed

11 files changed

+24
-16
lines changed

DEVELOPER_GUIDE.md

+6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
7979
nvm install v14.18.2
8080
```
8181

82+
Add the lines below to the correct profile file (`~/.zshrc`, `~/.bashrc`, etc.).
83+
```
84+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
85+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
86+
```
87+
8288
#### Yarn
8389

8490
[Yarn](https://classic.yarnpkg.com/en/docs/install) is required for building and running the OpenSearch Dashboards and plugins

manifests/1.3.1/opensearch-dashboards-1.3.1.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ build:
66
ci:
77
image:
88
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v1
9-
args: -e NODE_VERSION=10.24.1
109
components:
1110
- name: OpenSearch-Dashboards
1211
repository: https://github.com/opensearch-project/OpenSearch-Dashboards.git

manifests/2.0.0/opensearch-dashboards-2.0.0.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ build:
77
ci:
88
image:
99
name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v1
10-
args: -e NODE_VERSION=14.18.2
1110
components:
1211
- name: OpenSearch-Dashboards
1312
ref: main

scripts/components/OpenSearch-Dashboards/build.sh

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
109109
;;
110110
esac
111111

112+
echo "Setting node version"
113+
source $NVM_DIR/nvm.sh
114+
nvm use
115+
112116
echo "Building node modules for core with $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
113117
yarn osd bootstrap
114118

scripts/components/ganttChartDashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
7474
# This makes it so there is a dependency on having Dashboards pulled already.
7575
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
7676
echo "BUILD MODULES FOR $PLUGIN_NAME"
77-
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
77+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
7878
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
79-
(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
79+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
8080
echo "COPY $PLUGIN_NAME.zip"
8181
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
8282
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER

scripts/components/notebooksDashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
7474
# This makes it so there is a dependency on having Dashboards pulled already.
7575
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
7676
echo "BUILD MODULES FOR $PLUGIN_NAME"
77-
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
77+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
7878
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
79-
(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
79+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
8080
echo "COPY $PLUGIN_NAME.zip"
8181
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
8282
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER

scripts/components/notificationsDashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
7474
# This makes it so there is a dependency on having Dashboards pulled already.
7575
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
7676
echo "BUILD MODULES FOR $PLUGIN_NAME"
77-
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
77+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
7878
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
79-
(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
79+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
8080
echo "COPY $PLUGIN_NAME.zip"
8181
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
8282
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER

scripts/components/observabilityDashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
7474
# This makes it so there is a dependency on having Dashboards pulled already.
7575
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
7676
echo "BUILD MODULES FOR $PLUGIN_NAME"
77-
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
77+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
7878
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
79-
(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
79+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
8080
echo "COPY $PLUGIN_NAME.zip"
8181
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
8282
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER

scripts/components/queryWorkbenchDashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
7474
# This makes it so there is a dependency on having Dashboards pulled already.
7575
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
7676
echo "BUILD MODULES FOR $PLUGIN_NAME"
77-
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
77+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
7878
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
79-
(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
79+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
8080
echo "COPY $PLUGIN_NAME.zip"
8181
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
8282
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER

scripts/components/reportsDashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD"))
102102
# This makes it so there is a dependency on having Dashboards pulled already.
103103
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
104104
echo "BUILD MODULES FOR $PLUGIN_NAME"
105-
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
105+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
106106
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
107-
(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
107+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
108108
ZIP_NAME=`ls ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build | grep .zip`
109109
unzip ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$ZIP_NAME -d ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/
110110
# Reporting uses headless chromium to generate reports, which needs to be included in its artifact

scripts/default/opensearch-dashboards/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ PLUGIN_NAME=$(basename "$PWD")
7272
# This makes it so there is a dependency on having Dashboards pulled already.
7373
cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins
7474
echo "BUILD MODULES FOR $PLUGIN_NAME"
75-
(cd ../OpenSearch-Dashboards && yarn osd bootstrap)
75+
(cd ../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap)
7676
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
77-
(cd ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
77+
(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd plugins/$PLUGIN_NAME && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER)
7878
echo "COPY $PLUGIN_NAME.zip"
7979
cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/
8080
rm -rf ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME

0 commit comments

Comments
 (0)