Use Yarn instead of NPM

This commit is contained in:
Raimund Schlüßler 2017-09-02 19:04:39 +02:00
parent c67cf0ab57
commit 878357ff7c
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178
3 changed files with 1968 additions and 22 deletions

View file

@ -7,7 +7,7 @@
# @author Raimund Schlüßler # @author Raimund Schlüßler
# @copyright 2017 Raimund Schlüßler <raimund.schluessler@googlemail.com> # @copyright 2017 Raimund Schlüßler <raimund.schluessler@googlemail.com>
# Generic Makefile for building and packaging a Nextcloud app which uses npm and # Generic Makefile for building and packaging a Nextcloud app which uses yarn and
# Composer. # Composer.
# #
# Dependencies: # Dependencies:
@ -15,31 +15,31 @@
# * which # * which
# * curl: used if phpunit and composer are not installed to fetch them from the web # * curl: used if phpunit and composer are not installed to fetch them from the web
# * tar: for building the archive # * tar: for building the archive
# * npm: for building and testing everything JS # * yarn: for building and testing everything JS
# #
# If no composer.json is in the app root directory, the Composer step # If no composer.json is in the app root directory, the Composer step
# will be skipped. The same goes for the package.json which can be located in # will be skipped. The same goes for the package.json which can be located in
# the app root or the js/ directory. # the app root or the js/ directory.
# #
# The npm command by launches the npm build script: # The yarn command by launches the yarn build script:
# #
# npm run build # yarn run build
# #
# The npm test command launches the npm test script: # The yarn test command launches the yarn test script:
# #
# npm run test # yarn run test
# #
# The idea behind this is to be completely testing and build tool agnostic. All # The idea behind this is to be completely testing and build tool agnostic. All
# build tools and additional package managers should be installed locally in # build tools and additional package managers should be installed locally in
# your project, since this won't pollute people's global namespace. # your project, since this won't pollute people's global namespace.
# #
# The following npm scripts in your package.json install and update the bower # The following yarn scripts in your package.json install and update the bower
# and npm dependencies and use gulp as build system (notice how everything is # and yarn dependencies and use gulp as build system (notice how everything is
# run from the node_modules folder): # run from the node_modules folder):
# #
# "scripts": { # "scripts": {
# "test": "node node_modules/gulp-cli/bin/gulp.js karma", # "test": "node node_modules/gulp-cli/bin/gulp.js karma",
# "prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update", # "prebuild": "yarn install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
# "build": "node node_modules/gulp-cli/bin/gulp.js" # "build": "node node_modules/gulp-cli/bin/gulp.js"
# }, # },
@ -51,7 +51,7 @@ source_package_name=$(source_artifact_directory)/$(app_name)
appstore_build_directory=$(CURDIR)/build/appstore/tasks appstore_build_directory=$(CURDIR)/build/appstore/tasks
appstore_artifact_directory=$(CURDIR)/build/artifacts/appstore appstore_artifact_directory=$(CURDIR)/build/artifacts/appstore
appstore_package_name=$(appstore_artifact_directory)/$(app_name) appstore_package_name=$(appstore_artifact_directory)/$(app_name)
npm=$(shell which npm 2> /dev/null) yarn=$(shell which yarn 2> /dev/null)
gcp=$(shell which gcp 2> /dev/null) gcp=$(shell which gcp 2> /dev/null)
ifeq (, $(gcp)) ifeq (, $(gcp))
@ -83,15 +83,15 @@ all: build
# Fetches the PHP and JS dependencies and compiles the JS. If no composer.json # Fetches the PHP and JS dependencies and compiles the JS. If no composer.json
# is present, the composer step is skipped, if no package.json or js/package.json # is present, the composer step is skipped, if no package.json or js/package.json
# is present, the npm step is skipped # is present, the yarn step is skipped
.PHONY: build .PHONY: build
build: build:
make npm make yarn
# Installs npm dependencies # Installs yarn dependencies
.PHONY: npm .PHONY: yarn
npm: yarn:
cd js && $(npm) run build cd js && $(yarn) run build
# Removes the appstore build # Removes the appstore build
.PHONY: clean .PHONY: clean
@ -99,7 +99,7 @@ clean:
rm -rf ./build rm -rf ./build
# Same as clean but also removes dependencies installed by composer, bower and # Same as clean but also removes dependencies installed by composer, bower and
# npm # yarn
.PHONY: distclean .PHONY: distclean
distclean: clean distclean: clean
rm -rf vendor rm -rf vendor
@ -218,7 +218,7 @@ endif
# from the internet # from the internet
.PHONY: test .PHONY: test
test: test:
cd js && $(npm) run test cd js && $(yarn) run test
ifeq (, $(shell which phpunit 2> /dev/null)) ifeq (, $(shell which phpunit 2> /dev/null))
@echo "No phpunit command available, downloading a copy from the web" @echo "No phpunit command available, downloading a copy from the web"
mkdir -p $(build_tools_directory) mkdir -p $(build_tools_directory)

View file

@ -10,7 +10,7 @@
"homepage": "", "homepage": "",
"scripts": { "scripts": {
"test": "node node_modules/grunt-cli/bin/grunt karma", "test": "node node_modules/grunt-cli/bin/grunt karma",
"prebuild": "npm install && npm update && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update", "prebuild": "yarn install && yarn upgrade && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
"build": "node node_modules/grunt-cli/bin/grunt build" "build": "node node_modules/grunt-cli/bin/grunt build"
}, },
"repository": { "repository": {
@ -24,14 +24,14 @@
"bower": "*", "bower": "*",
"grunt": "^1.0.1", "grunt": "^1.0.1",
"grunt-cli": "^1.2.0", "grunt-cli": "^1.2.0",
"grunt-contrib-jshint": "^1.0.0",
"jshint-stylish": "^2.2.1",
"grunt-concurrent": "^2.3.1", "grunt-concurrent": "^2.3.1",
"grunt-contrib-concat": "^1.0.1", "grunt-contrib-concat": "^1.0.1",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-watch": "^1.0.0", "grunt-contrib-watch": "^1.0.0",
"grunt-karma": "^2.0.0", "grunt-karma": "^2.0.0",
"grunt-svg-sprite": "1.3.7",
"grunt-wrap": "^0.3.0", "grunt-wrap": "^0.3.0",
"grunt-svg-sprite": "1.3.7" "jshint-stylish": "^2.2.1"
}, },
"engines": { "engines": {
"node": ">=6" "node": ">=6"

1946
js/yarn.lock Normal file

File diff suppressed because it is too large Load diff