Skip to content

Commit 08b4ef7

Browse files
committed
[TASK] Migrate from yarn to npm
Yarn has been added to TYPO3 back in 2017 because npm shrinkwrap files were not stable and package-lock.json and `npm ci` not yet established. By now the yarn version in TYPO3 (v1) got outdated and an update to yarn v3 would be required sooner or later. The update to yarn v3 brings quite some problems for the TYPO3 codebase: - Yarn v3 is executed/proxied through yarn v1 (installed on the developer machine) – therefore the yarn v3 executable needs to be tracked within git. See https://yarnpkg.com/cli/set/version#details - Yarn v3 pulls in @types/node (through the "got" package) for unknown reasons, causing clashes with TypeScript declarations for requirejs (window.require vs node's require()) As package-lock.json is solid thesedays, there is no real need to depend on yarn anymore. We basically switch to npm because that switch is way more straightforward than migrating to yarn v3 and it removes one dependency. We also raise the required npm verson to v8 in order to use package-lock.json v2 format and .nvmrc is updated to suggest the recent nodejs v16 LTS release. Note that node v14 and npm v6 may still be used to install dependencies and to run grunt build (package-lock.json v2 is backwards compatible), but npm v8 is required for updating packages. Note that `npm install` properly honors `package-lock.json` these days (no implicit version upgrades due to the lock file), but is faster than `npm ci`, therefore it is used in `grunt build` and runTests.sh for all developer oriented build-targets. All CI checks use `npm ci` to enfore a clean install. Executed Commands: cd Build/ # be sure the node_modules folder dir and is updated yarn install sed -i 's/"yarn": "^1.22.0"/"npm": ">=7.0.0 <9.0.0"/' package.json rm -f package-lock.json # npm install >= v7 can read yarn.lock and will create # package-lock.json as a result npm install git add package-lock.json git rm -f yarn.lock npm remove "jquery-ui" # The use of `git@` in the HTTPS URLs is a workaround for NPM's # auto-rewrite that results in an SSH URL being used instead, # which fails to install in CI. # See npm/cli#2610 for more information. npm install "git+https://[email protected]/jquery/jquery-ui#1.11.4" # Fix fsevents not being installed npm install rollup@~2.32.0 # Let npm build a new, fully clean tree, without old yarn cruft rm -rf node_modules/ npm install grunt default Resolves: #96355 Related. #83038 Releases: main Change-Id: I88c1ecb1b12dcd117ac4200307af72d330c76d27
1 parent 242735f commit 08b4ef7

File tree

10 files changed

+33164
-9031
lines changed

10 files changed

+33164
-9031
lines changed

.cache/.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Required for Docker builds on CI (Gitlab)
2+
# https://github.com/ds300/patch-package/issues/185
3+
unsafe-perm = true

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ nbproject
2525
.webprj
2626
#
2727
# Temporary files and folders
28-
.cache
28+
/.cache/*
29+
!/.cache/.npmrc
2930
.php_cs.cache
3031
.php-cs-fixer.cache
3132
.sass-cache
@@ -34,6 +35,7 @@ nbproject
3435
#
3536
# Ignore build stuff
3637
/.ddev/*
38+
/Build/.cache
3739
/Build/phpunit/FunctionalTests-Job-*
3840
/Build/bower_components/*
3941
/Build/node_modules/*

Build/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.10
1+
v16.15

Build/Gruntfile.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ module.exports = function (grunt) {
185185
},
186186
exec: {
187187
ts: ((process.platform === 'win32') ? 'node_modules\\.bin\\tsc.cmd' : './node_modules/.bin/tsc') + ' --project tsconfig.json',
188-
'yarn-install': 'yarn install'
188+
'npm-install': 'npm install'
189189
},
190190
eslint: {
191191
options: {
@@ -357,7 +357,7 @@ module.exports = function (grunt) {
357357
expand: true,
358358
cwd: '<%= paths.node_modules %>codemirror',
359359
dest: '<%= paths.t3editor %>Public/JavaScript/Contrib/codemirror',
360-
src: ['**/*', '!**/src/**', '!rollup.config.js']
360+
src: ['**/*', '!**/src/**', '!rollup.config.js', '!package.json']
361361
}
362362
]
363363
}
@@ -777,15 +777,6 @@ module.exports = function (grunt) {
777777
grunt.loadNpmTasks('grunt-newer');
778778
grunt.loadNpmTasks('grunt-concurrent');
779779

780-
/**
781-
* grunt default task
782-
*
783-
* call "$ grunt"
784-
*
785-
* this will trigger the CSS build
786-
*/
787-
grunt.registerTask('default', ['css']);
788-
789780
/**
790781
* grunt lint
791782
*
@@ -816,10 +807,9 @@ module.exports = function (grunt) {
816807
* call "$ grunt update"
817808
*
818809
* this task does the following things:
819-
* - yarn install
820810
* - copy some components to a specific destinations because they need to be included via PHP
821811
*/
822-
grunt.registerTask('update', ['exec:yarn-install', 'rollup', 'concurrent:npmcopy']);
812+
grunt.registerTask('update', ['rollup', 'concurrent:npmcopy']);
823813

824814
/**
825815
* grunt compile-typescript task
@@ -877,9 +867,9 @@ module.exports = function (grunt) {
877867
});
878868

879869
/**
880-
* grunt build task
870+
* grunt default task
881871
*
882-
* call "$ grunt build"
872+
* call "$ grunt default"
883873
*
884874
* this task does the following things:
885875
* - execute update task
@@ -889,5 +879,16 @@ module.exports = function (grunt) {
889879
* - minifies svg files
890880
* - compiles TypeScript files
891881
*/
892-
grunt.registerTask('build', ['clear-build', 'update', 'concurrent:copy_static', 'concurrent:compile_assets', 'concurrent:minify_assets', 'imagemin']);
882+
grunt.registerTask('default', ['clear-build', 'update', 'concurrent:copy_static', 'concurrent:compile_assets', 'concurrent:minify_assets', 'imagemin']);
883+
884+
/**
885+
* grunt build task (legacy, for those used to it). Use `grunt default` instead.
886+
*
887+
* call "$ grunt build"
888+
*
889+
* this task does the following things:
890+
* - execute exec:npm-install task
891+
* - execute all task
892+
*/
893+
grunt.registerTask('build', ['exec:npm-install', 'default']);
893894
};

Build/gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cache:
3131
# it is more important that single jobs don't unpack too much every time.
3232
# The default key is: "Cache everything created by a 'composer install' for main branch.
3333
# This means jobs using this default key should not create additional stuff in .cache
34-
# directory, for instance by calling a 'yarn install' or 'composer min' or similar.
34+
# directory, for instance by calling a 'npm ci' or 'composer min' or similar.
3535
key: main-composer
3636
paths:
3737
- .cache

0 commit comments

Comments
 (0)