aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLibravatar Balaji Vijayakumar <kuttibalaji.v6@gmail.com>2022-12-09 12:59:26 +0530
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-12-09 13:51:05 +0530
commitacb0a6f117987e44b91eda1be9ad44d70238b8fc (patch)
treec2a1fff569df611ddfd2310bdefe45f912e4b736 /scripts
parentFix logic used to check if there were local changes in docker builds (diff)
downloadferdium-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-xscripts/build-unix.sh31
-rw-r--r--scripts/build-windows.ps129
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
60else 60else
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
73fi 67fi
@@ -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
89command_exists asdf && asdf reshim nodejs 83command_exists asdf && asdf reshim nodejs
90 84
91# Ensure that the system dependencies are at the correct version
92# Check npm version
93EXPECTED_NPM_VERSION=$(node -p 'require("./package.json").engines.npm')
94ACTUAL_NPM_VERSION=$(npm --version)
95if [[ "$ACTUAL_NPM_VERSION" != "$EXPECTED_NPM_VERSION" ]]; then
96 npm i -gf npm@$EXPECTED_NPM_VERSION
97fi
98
99# Check pnpm version 85# Check pnpm version
100EXPECTED_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm') 86EXPECTED_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm')
101ACTUAL_PNPM_VERSION=$(pnpm --version || true) # in case the pnpm executable itself is not present 87ACTUAL_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
107command_exists asdf && asdf reshim nodejs 93command_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
111if [[ -s 'pnpm-lock.yaml' ]]; then
112 BASE_CMD=pnpm
113else
114 BASE_CMD=npm
115fi
116
117ENV_FILE=".env" 95ENV_FILE=".env"
118if [[ ! -s $ENV_FILE ]]; then 96if [[ ! -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# -----------------------------------------------------------------------------
127printf "\n*************** Building recipes ***************\n" 105printf "\n*************** Building recipes ***************\n"
128# Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm
129pushd recipes 106pushd recipes
130pnpm i 107pnpm i
131pnpm package 108pnpm package
132popd 109popd
133 110
134# Now the meat..... 111# Now the meat.....
135$BASE_CMD i 112pnpm i
136node ace migration:refresh 113node ace migration:refresh
137 114
138# ----------------------------------------------------------------------------- 115# -----------------------------------------------------------------------------
139printf "\n*************** Building app ***************\n" 116printf "\n*************** Building app ***************\n"
140$BASE_CMD start --dev 117pnpm start --dev
141 118
142printf "\n*************** App successfully stopped! ***************\n" 119printf "\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)
140if ($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
157if ((Test-Path -Path ".\pnpm-lock.yaml") -and (Get-Command -ErrorAction Ignore -Type Application pnpm))
158{
159 $BASE_CMD="pnpm"
160}
161else
162{
163 $BASE_CMD="npm"
164}
165
166$ENV_FILE = ".env" 142$ENV_FILE = ".env"
167if (-not (Test-Path -Path $ENV_FILE)) { 143if (-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# -----------------------------------------------------------------------------
179Write-Host "*************** Building recipes ***************" 155Write-Host "*************** Building recipes ***************"
180# Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm
181Push-Location recipes 156Push-Location recipes
182pnpm i 157pnpm i
183pnpm package 158pnpm package
184Pop-Location 159Pop-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# -----------------------------------------------------------------------------
191Write-Host "*************** Starting app ***************" 166Write-Host "*************** Starting app ***************"
192& $BASE_CMD start --dev 167& pnpm start --dev
193 168
194Write-Host "*************** App successfully stopped! ***************" 169Write-Host "*************** App successfully stopped! ***************"