aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLibravatar Balaji Vijayakumar <kuttibalaji.v6@gmail.com>2022-11-25 05:31:46 +0530
committerLibravatar GitHub <noreply@github.com>2022-11-25 00:01:46 +0000
commitc04b71b2c79bdc5b1612ef0e98f351d1193bdec9 (patch)
treeb46106d37f6d4ecc2bb366fcf5418ac3f478fe42 /scripts
parentPull in new version of 'recipes' submodule (diff)
downloadferdium-app-c04b71b2c79bdc5b1612ef0e98f351d1193bdec9.tar.gz
ferdium-app-c04b71b2c79bdc5b1612ef0e98f351d1193bdec9.tar.zst
ferdium-app-c04b71b2c79bdc5b1612ef0e98f351d1193bdec9.zip
Switch npm to pnpm (#714)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/add-crowdin-contributors.ts2
-rwxr-xr-xscripts/build-unix.sh33
-rw-r--r--scripts/build-windows.ps146
3 files changed, 31 insertions, 50 deletions
diff --git a/scripts/add-crowdin-contributors.ts b/scripts/add-crowdin-contributors.ts
index d6f36b06d..eadedbcc4 100644
--- a/scripts/add-crowdin-contributors.ts
+++ b/scripts/add-crowdin-contributors.ts
@@ -49,7 +49,7 @@ console.clear();
49console.log(JSON.stringify(members)); 49console.log(JSON.stringify(members));
50 50
51 * 3. Paste the output of the script (JSON Array) below to set 'list' to that value 51 * 3. Paste the output of the script (JSON Array) below to set 'list' to that value
52 * 4. Execute this script using 'npm run add-crowdin-contributors' 52 * 4. Execute this script using 'pnpm add-crowdin-contributors'
53 * 5. Regenerate the README table using the CLI ('all-contributors generate') 53 * 5. Regenerate the README table using the CLI ('all-contributors generate')
54 * Please check if the generated data is ok and no data is lost. 54 * Please check if the generated data is ok and no data is lost.
55*/ 55*/
diff --git a/scripts/build-unix.sh b/scripts/build-unix.sh
index 15e9f26c8..42de96a1a 100755
--- a/scripts/build-unix.sh
+++ b/scripts/build-unix.sh
@@ -83,38 +83,33 @@ fi
83command_exists asdf && asdf reshim nodejs 83command_exists asdf && asdf reshim nodejs
84 84
85# Ensure that the system dependencies are at the correct version 85# Ensure that the system dependencies are at the correct version
86# Check npm version
87EXPECTED_NPM_VERSION=$(node -p 'require("./package.json").engines.npm')
88ACTUAL_NPM_VERSION=$(npm --version)
89if [[ "$ACTUAL_NPM_VERSION" != "$EXPECTED_NPM_VERSION" ]]; then
90 npm i -gf npm@$EXPECTED_NPM_VERSION
91fi
92
93# Check pnpm version 86# Check pnpm version
94EXPECTED_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm') 87EXPECTED_PNPM_VERSION=$(node -p 'require("./package.json").engines.pnpm')
95ACTUAL_PNPM_VERSION=$(pnpm --version || true) # in case the pnpm executable itself is not present 88ACTUAL_PNPM_VERSION=$(pnpm --version || true) # in case the pnpm executable itself is not present
96if [[ "$ACTUAL_PNPM_VERSION" != "$EXPECTED_PNPM_VERSION" ]]; then 89if [[ "$ACTUAL_PNPM_VERSION" != "$EXPECTED_PNPM_VERSION" ]]; then
97 npm i -gf pnpm@$EXPECTED_PNPM_VERSION 90 npm i -gf pnpm@$EXPECTED_PNPM_VERSION
98fi 91fi
99 92
93# Check pnpm version of the recipes submodule
94EXPECTED_RECIPES_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm')
95if [[ "$EXPECTED_PNPM_VERSION" != "$EXPECTED_RECIPES_PNPM_VERSION" ]]; then
96 fail_with_docs "The expected versions of pnpm are not the same in the main repo and in the recipes submodule, please sync them.
97 expected in recipes : [$EXPECTED_RECIPES_PNPM_VERSION]
98 expected in main repo: [$EXPECTED_PNPM_VERSION]
99 actual : [$EXPECTED_PNPM_VERSION]"
100fi
101
100# If 'asdf' is installed, reshim for new nodejs if necessary 102# If 'asdf' is installed, reshim for new nodejs if necessary
101command_exists asdf && asdf reshim nodejs 103command_exists asdf && asdf reshim nodejs
102 104
103# ----------------------------------------------------------------------------- 105# -----------------------------------------------------------------------------
104# This is useful if we move from 'npm' to 'pnpm' for the main repo as well
105if [[ -s 'pnpm-lock.yaml' ]]; then
106 BASE_CMD=pnpm
107else
108 BASE_CMD=npm
109fi
110
111# Now the meat..... 106# Now the meat.....
112$BASE_CMD i 107pnpm i
113$BASE_CMD run prepare-code 108pnpm prepare-code
109pnpm test
114 110
115# ----------------------------------------------------------------------------- 111# -----------------------------------------------------------------------------
116printf "\n*************** Building recipes ***************\n" 112printf "\n*************** Building recipes ***************\n"
117# Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm
118pushd recipes 113pushd recipes
119pnpm i && pnpm lint && pnpm reformat-files && pnpm package 114pnpm i && pnpm lint && pnpm reformat-files && pnpm package
120popd 115popd
@@ -133,7 +128,7 @@ else
133 TARGET_OS="linux" 128 TARGET_OS="linux"
134fi 129fi
135 130
136$BASE_CMD run build -- --$TARGET_ARCH --$TARGET_OS --dir 131pnpm build --$TARGET_ARCH --$TARGET_OS --dir
137 132
138printf "\n*************** App successfully built! ***************\n" 133printf "\n*************** App successfully built! ***************\n"
139 134
diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1
index d0c394647..1c2b175b2 100644
--- a/scripts/build-windows.ps1
+++ b/scripts/build-windows.ps1
@@ -131,44 +131,30 @@ if((-not $NPM_CONFIG_MSVS_VERSION) -or -not ($EXPECTED_MSVST_VERSION -contains $
131 131
132# ----------------------------------------------------------------------------- 132# -----------------------------------------------------------------------------
133# Ensure that the system dependencies are at the correct version - recover if not 133# Ensure that the system dependencies are at the correct version - recover if not
134# Check npm version
135$EXPECTED_NPM_VERSION = (Get-Content package.json | ConvertFrom-Json).engines.npm
136$ACTUAL_NPM_VERSION = (npm -v)
137if ($EXPECTED_NPM_VERSION -ne $ACTUAL_NPM_VERSION) {
138 Write-Host "You are not running the expected version of npm!
139 expected: [$EXPECTED_NPM_VERSION]
140 actual : [$ACTUAL_NPM_VERSION]"
141 Write-Host "Changing version of npm to [$EXPECTED_NPM_VERSION]"
142 npm i -gf npm@$EXPECTED_NPM_VERSION
143}
144
145# Check pnpm version 134# Check pnpm version
146$EXPECTED_PNPM_VERSION = (Get-Content recipes\package.json | ConvertFrom-Json).engines.pnpm 135$EXPECTED_PNPM_VERSION = (Get-Content package.json | ConvertFrom-Json).engines.pnpm
147$ACTUAL_PNPM_VERSION = Get-Command pnpm --version -ErrorAction SilentlyContinue # in case the pnpm executable itself is not present 136$ACTUAL_PNPM_VERSION = pnpm --version -ErrorAction SilentlyContinue # in case the pnpm executable itself is not present
148if ($ACTUAL_PNPM_VERSION -ne $EXPECTED_PNPM_VERSION) { 137if ($ACTUAL_PNPM_VERSION -ne $EXPECTED_PNPM_VERSION) {
149 npm i -gf pnpm@$EXPECTED_PNPM_VERSION 138 npm i -gf pnpm@$EXPECTED_PNPM_VERSION
150} 139}
151 140
152# ----------------------------------------------------------------------------- 141# Check pnpm version of the recipes submodule
153# This is useful if we move from 'npm' to 'pnpm' for the main repo as well 142$EXPECTED_RECIPES_PNPM_VERSION = (Get-Content .\recipes\package.json | ConvertFrom-Json).engines.pnpm
154if ((Test-Path -Path ".\pnpm-lock.yaml") -and (Get-Command -ErrorAction Ignore -Type Application pnpm)) 143if ($ACTUAL_PNPM_VERSION -ne $EXPECTED_RECIPES_PNPM_VERSION) {
155{ 144 fail_with_docs "The expected versions of pnpm are not the same in the main repo and in the recipes submodule, please sync them.
156 $BASE_CMD="pnpm" 145 expected in recipes : [$EXPECTED_RECIPES_PNPM_VERSION]
157 $env:EXEC_CMD="pnpm dlx" 146 expected in main repo: [$EXPECTED_RECIPES_PNPM_VERSION]
158} 147 actual : [$EXPECTED_PNPM_VERSION]"
159else
160{
161 $BASE_CMD="npm"
162 $env:EXEC_CMD="npx"
163} 148}
164 149
150# -----------------------------------------------------------------------------
165# Now the meat..... 151# Now the meat.....
166& $BASE_CMD i 152& pnpm i
167& $BASE_CMD run prepare-code 153& pnpm prepare-code
154& pnpm test
168 155
169# ----------------------------------------------------------------------------- 156# -----------------------------------------------------------------------------
170Write-Host "*************** Building recipes ***************" 157Write-Host "*************** Building recipes ***************"
171# Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm
172Push-Location recipes 158Push-Location recipes
173pnpm i && pnpm lint && pnpm reformat-files && pnpm package 159pnpm i && pnpm lint && pnpm reformat-files && pnpm package
174Pop-Location 160Pop-Location
@@ -176,13 +162,13 @@ Pop-Location
176# ----------------------------------------------------------------------------- 162# -----------------------------------------------------------------------------
177Write-Host "*************** Building app ***************" 163Write-Host "*************** Building app ***************"
178if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { 164if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
179 $TARGET_ARCH="arm64" 165 $TARGET_ARCH="arm64"
180} 166}
181else 167else
182{ 168{
183 $TARGET_ARCH="x64" 169 $TARGET_ARCH="x64"
184} 170}
185& $BASE_CMD run build -- --$TARGET_ARCH --dir 171& pnpm build -- --$TARGET_ARCH --dir
186 172
187Write-Host "*************** App successfully built! ***************" 173Write-Host "*************** App successfully built! ***************"
188 174