Skip to content

Commit a1aca2a

Browse files
committed
Migrate from yarn to pnpm #11465
Because yarn 1 has been obsolete for a long time. Yarn 4 workflow differs too much. pnpm offers delayed dependency update to protect against supply chain attack. pnpm is way more popular than Yarn. And Angular adopted pnpm themselves. See: - https://socket.dev/blog/pnpm-10-16-adds-new-setting-for-delayed-dependency-updates - https://npmtrends.com/@yarnpkg/cli-vs-@yarnpkg/cli-dist-vs-pnpm-vs-yarn - angular/angular@e7ac7f6
1 parent 63b8105 commit a1aca2a

9 files changed

Lines changed: 9124 additions & 7182 deletions

File tree

.github/workflows/main.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ jobs:
2424
with:
2525
fetch-depth: 2
2626

27+
- uses: pnpm/action-setup@v5
2728
- uses: actions/setup-node@v4
2829
with:
2930
node-version: '22'
31+
cache: 'pnpm'
3032

3133
- uses: shivammathur/setup-php@v2
3234
with:
@@ -41,12 +43,6 @@ jobs:
4143
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
4244
restore-keys: ${{ runner.os }}-composer-
4345

44-
- uses: actions/cache@v4
45-
with:
46-
path: ~/.cache/yarn
47-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
48-
restore-keys: ${{ runner.os }}-yarn-
49-
5046
- name: Setup problem matchers for PHP
5147
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
5248

@@ -63,6 +59,6 @@ jobs:
6359
- run: ./vendor/bin/php-cs-fixer fix --format=checkstyle | cs2pr
6460
- run: ./vendor/bin/phpstan analyse
6561
- run: ./vendor/bin/phpunit
66-
- run: yarn lint
62+
- run: pnpm lint
6763
- run: ./node_modules/.bin/prettier --experimental-cli --check .
6864
- run: ./node_modules/.bin/ng test --progress false --watch=false --browsers ChromeHeadlessCustom

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/htdocs/
1313
/logs/
1414
/node_modules/
15+
/pnpm-lock.yaml
1516
/server/
1617
/tests/
1718
/vendor/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ $ composer clear-config-cache
4646

4747
### Client
4848

49-
Run `yarn dev` for a dev server. Navigate to `http://artisans.lan:4210/`. The app will
49+
Run `pnpm dev` for a dev server. Navigate to `http://artisans.lan:4210/`. The app will
5050
automatically reload if you change any of the source files.
5151

5252
## Testing

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
},
146146
"cli": {
147147
"schematicCollections": ["@angular-eslint/schematics"],
148-
"packageManager": "yarn",
148+
"packageManager": "pnpm",
149149
"analytics": false
150150
},
151151
"schematics": {

bin/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ echo "Installing git hooks..."
6767
ln -fs ../../bin/pre-commit.sh .git/hooks/pre-commit
6868

6969
echo "Updating Node.js packages..."
70-
yarn install $NO_PROGRESS
70+
pnpm install
7171

7272
echo "Updating all PHP dependencies via composer..."
7373
$COMPOSER install --classmap-authoritative $NO_PROGRESS
@@ -84,8 +84,8 @@ $PHP ./bin/delete-old-log.php
8484

8585
if [ $IS_PRODUCTION -eq 1 ]; then
8686
echo "Building Angular application..."
87-
yarn run prod
87+
pnpm run prod
8888
else
8989
echo "Running Angular dev server..."
90-
yarn run dev
90+
pnpm run dev
9191
fi

bin/test-nginx-rules.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ function run(string $cmd): string
1313
return shell_exec($cmd);
1414
}
1515

16-
function test(string $url): void
17-
{
18-
$pattern = '<img src="assets/logo-artisans-de-la-transition.svg"';
19-
$message = 'logged in user should get raw Angular';
20-
16+
function test(
17+
string $url,
18+
string $pattern = '<img class="boot-logo" src="assets/logo-artisans-de-la-transition.svg"',
19+
string $message = 'should get raw Angular',
20+
): void {
2121
// Assert HTTP status code
2222
$status = run("curl --insecure --silent --output /dev/null --write-out '%{http_code}' '$url'");
2323
if ($status !== '200') {
@@ -40,6 +40,6 @@ function test(string $url): void
4040
test('https://artisans.lan');
4141
test('https://artisans.lan/larevuedurable/numeros');
4242
test('https://artisans.lan/mon-compte');
43-
test('https://artisans.lan/sitemap.xml');
43+
test('https://artisans.lan/sitemap.xml', '<loc>https://artisans.lan/association/nos-convictions</loc>', 'should get sitemap');
4444

4545
echo '❤️ All tests OK' . PHP_EOL;

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"ng": "ng",
77
"postinstall": "playwright install chromium",
88
"client-config": "`which php8.4 || which php` ./bin/generate-client-configuration.php",
9-
"prerequisite": "mkdir -p htdocs/ && cp -v server/index.php htdocs/ && yarn client-config && yarn codegen",
10-
"dev": "yarn prerequisite && ng serve",
11-
"prod": "yarn prerequisite && ng build && find data/tmp/build/browser -type f -not -name '*.gz' -exec gzip --keep --best {} \\; && rm -rf htdocs/ && mv -v data/tmp/build/browser htdocs",
12-
"test": "yarn prerequisite && ng test",
9+
"prerequisite": "mkdir -p htdocs/ && cp -v server/index.php htdocs/ && pnpm client-config && pnpm codegen",
10+
"dev": "pnpm prerequisite && ng serve",
11+
"prod": "pnpm prerequisite && ng build && find data/tmp/build/browser -type f -not -name '*.gz' -exec gzip --keep --best {} \\; && rm -rf htdocs/ && mv -v data/tmp/build/browser htdocs",
12+
"test": "pnpm prerequisite && ng test",
1313
"lint": "ng lint --max-warnings 0",
1414
"e2e": "playwright test",
1515
"codegen": "./bin/dump-schema && graphql-codegen --config codegen.ts"
1616
},
17+
"packageManager": "pnpm@10.33.0",
1718
"dependencies": {
1819
"@angular/cdk": "^21.2.0",
1920
"@angular/common": "^21.2.0",

0 commit comments

Comments
 (0)