diff options
author | Balaji Vijayakumar <kuttibalaji.v6@gmail.com> | 2022-12-09 12:59:26 +0530 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-12-09 13:51:05 +0530 |
commit | acb0a6f117987e44b91eda1be9ad44d70238b8fc (patch) | |
tree | c2a1fff569df611ddfd2310bdefe45f912e4b736 /scripts | |
parent | Fix logic used to check if there were local changes in docker builds (diff) | |
download | ferdium-server-acb0a6f117987e44b91eda1be9ad44d70238b8fc.tar.gz ferdium-server-acb0a6f117987e44b91eda1be9ad44d70238b8fc.tar.zst ferdium-server-acb0a6f117987e44b91eda1be9ad44d70238b8fc.zip |
migrate npm to pnpm for build
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-unix.sh | 31 | ||||
-rw-r--r-- | scripts/build-windows.ps1 | 29 |
2 files changed, 6 insertions, 54 deletions
diff --git a/scripts/build-unix.sh b/scripts/build-unix.sh index 24ab0f7..28d0e7c 100755 --- a/scripts/build-unix.sh +++ b/scripts/build-unix.sh | |||
@@ -60,14 +60,8 @@ if [ "$CLEAN" != "true" ]; then | |||
60 | else | 60 | else |
61 | printf "\n*************** Cleaning!!!!!! ***************\n" | 61 | printf "\n*************** Cleaning!!!!!! ***************\n" |
62 | 62 | ||
63 | if [[ -s 'pnpm-lock.yaml' ]]; then | 63 | pnpm store prune || true # in case the pnpm executable itself is not present |
64 | pnpm store prune || true # in case the pnpm executable itself is not present | 64 | rm -rf ~/.pnpm-store ~/.pnpm-state |
65 | rm -rf ~/.pnpm-store ~/.pnpm-state | ||
66 | fi | ||
67 | |||
68 | npm cache clean --force | ||
69 | rm -rf ~/.npm ~/.node-gyp ~/.asdf/installs/nodejs/*/.npm/ | ||
70 | |||
71 | git -C recipes clean -fxd # Clean recipes folder/submodule | 65 | git -C recipes clean -fxd # Clean recipes folder/submodule |
72 | git clean -fxd # Note: This will blast away the 'recipes' folder if you have symlinked it | 66 | git clean -fxd # Note: This will blast away the 'recipes' folder if you have symlinked it |
73 | fi | 67 | fi |
@@ -88,14 +82,6 @@ fi | |||
88 | # If 'asdf' is installed, reshim for new nodejs if necessary | 82 | # If 'asdf' is installed, reshim for new nodejs if necessary |
89 | command_exists asdf && asdf reshim nodejs | 83 | command_exists asdf && asdf reshim nodejs |
90 | 84 | ||
91 | # Ensure that the system dependencies are at the correct version | ||
92 | # Check npm version | ||
93 | EXPECTED_NPM_VERSION=$(node -p 'require("./package.json").engines.npm') | ||
94 | ACTUAL_NPM_VERSION=$(npm --version) | ||
95 | if [[ "$ACTUAL_NPM_VERSION" != "$EXPECTED_NPM_VERSION" ]]; then | ||
96 | npm i -gf npm@$EXPECTED_NPM_VERSION | ||
97 | fi | ||
98 | |||
99 | # Check pnpm version | 85 | # Check pnpm version |
100 | EXPECTED_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm') | 86 | EXPECTED_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm') |
101 | ACTUAL_PNPM_VERSION=$(pnpm --version || true) # in case the pnpm executable itself is not present | 87 | ACTUAL_PNPM_VERSION=$(pnpm --version || true) # in case the pnpm executable itself is not present |
@@ -106,14 +92,6 @@ fi | |||
106 | # If 'asdf' is installed, reshim for new nodejs if necessary | 92 | # If 'asdf' is installed, reshim for new nodejs if necessary |
107 | command_exists asdf && asdf reshim nodejs | 93 | command_exists asdf && asdf reshim nodejs |
108 | 94 | ||
109 | # ----------------------------------------------------------------------------- | ||
110 | # This is useful if we move from 'npm' to 'pnpm' for the main repo as well | ||
111 | if [[ -s 'pnpm-lock.yaml' ]]; then | ||
112 | BASE_CMD=pnpm | ||
113 | else | ||
114 | BASE_CMD=npm | ||
115 | fi | ||
116 | |||
117 | ENV_FILE=".env" | 95 | ENV_FILE=".env" |
118 | if [[ ! -s $ENV_FILE ]]; then | 96 | if [[ ! -s $ENV_FILE ]]; then |
119 | APP_KEY=`cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w ${1:-32} | head -n 1` | 97 | APP_KEY=`cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w ${1:-32} | head -n 1` |
@@ -125,18 +103,17 @@ mkdir -p data | |||
125 | 103 | ||
126 | # ----------------------------------------------------------------------------- | 104 | # ----------------------------------------------------------------------------- |
127 | printf "\n*************** Building recipes ***************\n" | 105 | printf "\n*************** Building recipes ***************\n" |
128 | # Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm | ||
129 | pushd recipes | 106 | pushd recipes |
130 | pnpm i | 107 | pnpm i |
131 | pnpm package | 108 | pnpm package |
132 | popd | 109 | popd |
133 | 110 | ||
134 | # Now the meat..... | 111 | # Now the meat..... |
135 | $BASE_CMD i | 112 | pnpm i |
136 | node ace migration:refresh | 113 | node ace migration:refresh |
137 | 114 | ||
138 | # ----------------------------------------------------------------------------- | 115 | # ----------------------------------------------------------------------------- |
139 | printf "\n*************** Building app ***************\n" | 116 | printf "\n*************** Building app ***************\n" |
140 | $BASE_CMD start --dev | 117 | pnpm start --dev |
141 | 118 | ||
142 | printf "\n*************** App successfully stopped! ***************\n" | 119 | printf "\n*************** App successfully stopped! ***************\n" |
diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1 index 4026aa5..5af7392 100644 --- a/scripts/build-windows.ps1 +++ b/scripts/build-windows.ps1 | |||
@@ -132,19 +132,6 @@ if((-not $NPM_CONFIG_MSVS_VERSION) -or -not ($EXPECTED_MSVST_VERSION -contains $ | |||
132 | npm config set msvs_version $ACTUAL_MSVST_VERSION | 132 | npm config set msvs_version $ACTUAL_MSVST_VERSION |
133 | } | 133 | } |
134 | 134 | ||
135 | # ----------------------------------------------------------------------------- | ||
136 | # Ensure that the system dependencies are at the correct version - recover if not | ||
137 | # Check npm version | ||
138 | $EXPECTED_NPM_VERSION = (Get-Content package.json | ConvertFrom-Json).engines.npm | ||
139 | $ACTUAL_NPM_VERSION = (npm -v) | ||
140 | if ($EXPECTED_NPM_VERSION -ne $ACTUAL_NPM_VERSION) { | ||
141 | Write-Host "You are not running the expected version of npm! | ||
142 | expected: [$EXPECTED_NPM_VERSION] | ||
143 | actual : [$ACTUAL_NPM_VERSION]" | ||
144 | Write-Host "Changing version of npm to [$EXPECTED_NPM_VERSION]" | ||
145 | npm i -gf npm@$EXPECTED_NPM_VERSION | ||
146 | } | ||
147 | |||
148 | # Check pnpm version | 135 | # Check pnpm version |
149 | $EXPECTED_PNPM_VERSION = (Get-Content .\recipes\package.json | ConvertFrom-Json).engines.pnpm | 136 | $EXPECTED_PNPM_VERSION = (Get-Content .\recipes\package.json | ConvertFrom-Json).engines.pnpm |
150 | $ACTUAL_PNPM_VERSION = Get-Command pnpm --version -ErrorAction SilentlyContinue # in case the pnpm executable itself is not present | 137 | $ACTUAL_PNPM_VERSION = Get-Command pnpm --version -ErrorAction SilentlyContinue # in case the pnpm executable itself is not present |
@@ -152,17 +139,6 @@ if ($ACTUAL_PNPM_VERSION -ne $EXPECTED_PNPM_VERSION) { | |||
152 | npm i -gf pnpm@$EXPECTED_PNPM_VERSION | 139 | npm i -gf pnpm@$EXPECTED_PNPM_VERSION |
153 | } | 140 | } |
154 | 141 | ||
155 | # ----------------------------------------------------------------------------- | ||
156 | # This is useful if we move from 'npm' to 'pnpm' for the main repo as well | ||
157 | if ((Test-Path -Path ".\pnpm-lock.yaml") -and (Get-Command -ErrorAction Ignore -Type Application pnpm)) | ||
158 | { | ||
159 | $BASE_CMD="pnpm" | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | $BASE_CMD="npm" | ||
164 | } | ||
165 | |||
166 | $ENV_FILE = ".env" | 142 | $ENV_FILE = ".env" |
167 | if (-not (Test-Path -Path $ENV_FILE)) { | 143 | if (-not (Test-Path -Path $ENV_FILE)) { |
168 | Copy-Item .env.example -Destination $ENV_FILE | 144 | Copy-Item .env.example -Destination $ENV_FILE |
@@ -177,18 +153,17 @@ if (-not (Test-Path -Path "data")) { | |||
177 | 153 | ||
178 | # ----------------------------------------------------------------------------- | 154 | # ----------------------------------------------------------------------------- |
179 | Write-Host "*************** Building recipes ***************" | 155 | Write-Host "*************** Building recipes ***************" |
180 | # Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm | ||
181 | Push-Location recipes | 156 | Push-Location recipes |
182 | pnpm i | 157 | pnpm i |
183 | pnpm package | 158 | pnpm package |
184 | Pop-Location | 159 | Pop-Location |
185 | 160 | ||
186 | # Now the meat..... | 161 | # Now the meat..... |
187 | & $BASE_CMD i | 162 | & pnpm i |
188 | & node ace migration:refresh | 163 | & node ace migration:refresh |
189 | 164 | ||
190 | # ----------------------------------------------------------------------------- | 165 | # ----------------------------------------------------------------------------- |
191 | Write-Host "*************** Starting app ***************" | 166 | Write-Host "*************** Starting app ***************" |
192 | & $BASE_CMD start --dev | 167 | & pnpm start --dev |
193 | 168 | ||
194 | Write-Host "*************** App successfully stopped! ***************" | 169 | Write-Host "*************** App successfully stopped! ***************" |