diff --git a/.editorconfig b/.editorconfig index a54e93ad1e..ce5970c549 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,3 +12,6 @@ indent_size = 2 [*.{md}] indent_size = 2 trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/Build/Jenkins/update-neos-ui-compiled.sh b/Build/Jenkins/update-neos-ui-compiled.sh index f236fe3009..5cd7c662a9 100755 --- a/Build/Jenkins/update-neos-ui-compiled.sh +++ b/Build/Jenkins/update-neos-ui-compiled.sh @@ -13,8 +13,7 @@ npm install -g yarn GIT_SHA1=`git rev-parse HEAD` GIT_TAG=`git describe --exact-match HEAD 2>/dev/null || true` -yarn install -yarn build +make build-production rm -Rf tmp_compiled_pkg git clone git@github.com:neos/neos-ui-compiled.git tmp_compiled_pkg diff --git a/Build/TravisCi/InstallScripts/IntegrationTests.sh b/Build/TravisCi/InstallScripts/IntegrationTests.sh index 55a93e18c2..acb7a65e9b 100644 --- a/Build/TravisCi/InstallScripts/IntegrationTests.sh +++ b/Build/TravisCi/InstallScripts/IntegrationTests.sh @@ -58,8 +58,7 @@ cd Packages/Application/Neos.Neos.Ui # Since all environments depend on the node dependencies, install and # afterwards prune them to remove extranous packages from previous/cached runs. -yarn install -yarn build +make build-production # Deactivate the previous enabled handling of hidden files with the `mv` command. shopt -u dotglob diff --git a/Build/TravisCi/Scripts/CodeStyle.sh b/Build/TravisCi/Scripts/CodeStyle.sh index 10ead47920..ade32b936f 100644 --- a/Build/TravisCi/Scripts/CodeStyle.sh +++ b/Build/TravisCi/Scripts/CodeStyle.sh @@ -11,4 +11,4 @@ set -e # This file serves as the script for the TravisCI `CodeStyle` TEST_SUITE environment. # The script will be executed in the package working directory. # -yarn lint && yarn lint:editorconfig +make lint diff --git a/Build/TravisCi/Scripts/IntegrationTests.sh b/Build/TravisCi/Scripts/IntegrationTests.sh index 2ecfeb6aa6..05d9eb6981 100644 --- a/Build/TravisCi/Scripts/IntegrationTests.sh +++ b/Build/TravisCi/Scripts/IntegrationTests.sh @@ -7,4 +7,4 @@ set -e # The script will be executed in the package working directory. # -yarn test:e2e +make test-e2e diff --git a/Build/TravisCi/Scripts/UnitTests.sh b/Build/TravisCi/Scripts/UnitTests.sh index 6ab57f148d..ad39152ee1 100644 --- a/Build/TravisCi/Scripts/UnitTests.sh +++ b/Build/TravisCi/Scripts/UnitTests.sh @@ -13,4 +13,4 @@ set -e # # Execute the unit tests. -yarn test +make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..a851b174cb --- /dev/null +++ b/Makefile @@ -0,0 +1,160 @@ +################################################################################ +# +# 888b 88 88888888888 ,ad8888ba, ad88888ba +# 8888b 88 88 d8"' `"8b d8" "8b +# 88 `8b 88 88 d8' `8b y8, +# 88 `8b 88 88aaaaa 88 88 `y8aaaaa, +# 88 `8b 88 88""""" 88 88 `"""""8b, +# 88 `8b 88 88 y8, ,8p `8b +# 88 `8888 88 y8a. .a8p y8a a8p +# 88 `888 88888888888 `"Y8888Y"' "Y88888P" +# +# +# +# 88 88 88 +# 88 88 88 +# 88 88 88 +# 88 88 88 +# 88 88 88 +# 88 88 88 +# Y8a. .a8P 88 +# `"Y8888Y"' 88 +# +# +################################################################################ + + +################################################################################ +# Variables +################################################################################ + + +# Add node_modules and composer binaries to $PATH +export PATH := ./node_modules/.bin:./bin:$(PATH) + + +################################################################################ +# Setup +################################################################################ + + +check-requirements: + @which yarn &>/dev/null || \ + (echo yarn is not installed: https://github.com/yarnpkg/yarn && false) + +install: + yarn install + +setup: check-requirements install build + @echo Please remember to set frontendDevelopmentMode \ + to true in your Settings.yaml. + @echo + @echo 'Neos:' + @echo ' Neos:' + @echo ' Ui:' + @echo ' frontendDevelopmentMode: true' + + +################################################################################ +# Builds +################################################################################ + + +# TODO: figure out how to pass a parameter to other targets to reduce redundancy +build: + NEOS_BUILD_ROOT=$(shell pwd) webpack --progress --colors + +build-watch: + NEOS_BUILD_ROOT=$(shell pwd) webpack --progress --colors --watch + +build-watch-poll: + NEOS_BUILD_ROOT=$(shell pwd) webpack \ + --progress --colors --watch-poll --watch + +# clean anything before building for production just to be sure +build-production: clean install + cross-env NODE_ENV=production NEOS_BUILD_ROOT=$(shell pwd) \ + webpack --progress --colors + + +################################################################################ +# Code Quality +################################################################################ + + +storybook: + lerna run --scope @neos-project/react-ui-components start + +test: + lerna run test --concurrency 1 + +test-e2e: + yarn run testcafe chrome:headless Tests/IntegrationTests/* \ + --selector-timeout=30000 --assertion-timeout=30000 + +lint: lint-js lint-editorconfig + +lint-js: + lerna run lint --concurrency 1 + + +lint-editorconfig: + editorconfig-checker \ + --exclude-regexp 'LICENSE|\.vanilla\-css$$|banner\.js$$' \ + --exclude-pattern \ + './{README.md,**/*.snap,**/*{fontAwesome,Resources}/**/*}' + + +################################################################################ +# Releasing +################################################################################ + + +called-with-version: +ifeq ($(VERSION),) + @echo No version information given. + @echo Please run this command like this: + @echo VERSION=1.0.0 make release + @false +endif + +bump-version: called-with-version + lerna publish \ + --skip-git --exact --repo-version=$(VERSION) \ + --yes --force-publish --skip-npm + ./Build/createVersionFile.sh + +publish-npm: called-with-version + lerna publish --skip-git --exact --repo-version=$(VERSION) \ + --yes --force-publish + +tag: called-with-version + git tag $(VERSION) + +# make a clean build from scratch +# and make sure that every lint and test stage is running through +release: called-with-version check-requirements \ + build-production \ + lint lint-editorconfig \ + test test-e2e \ + bump-version publish-npm tag + @echo + @echo + @echo + @echo '####################################################################' + @echo + @echo You should look at the git diff carefully and commit your changes + @echo + @echo Then push your changes into the master and trigger the jenkins build. + + +################################################################################ +# Misc +################################################################################ + + +clean: + rm -Rf node_modules; rm -rf packages/*/node_modules + + +.PHONY: $@ diff --git a/README.md b/README.md index 89bac78a01..e390558954 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ In order to start contributing, follow the following steps: 1) Ensure you have the `dev-master` version installed (see above). -2) We require [Chrome](https://www.google.com/chrome/browser/desktop/index.html) as well as the `yarn`(` npm install -g yarn`, https://yarnpkg.com/en/) command to be installed on your system. +2) We require [Chrome](https://www.google.com/chrome/browser/desktop/index.html) as well as the `yarn`(https://yarnpkg.com/en/) command and GNU Make(https://www.gnu.org/software/make/) to be installed on your system. 3) Inside `Configuration/Settings.yaml`, set the following property for disabling the pre-compiled files: @@ -65,17 +65,7 @@ In order to start contributing, follow the following steps: 4) Run the initialization script: ``` - cd Packages/Application/Neos.Neos.Ui - source Build/init.sh # do NodeJS stuff ie. install npm deps, copy githooks - yarn build # build everything using webpack (you might see some webpack warnings, but you can ignore them) - ``` - - Alternatively, you can also run the initialization by hand; which will mean: - ``` - npm install -g yarn - yarn - - yarn run build:ui:watch + make setup ``` 5) Get an overview about the codebase. We've recorded [an introduction on YouTube](https://www.youtube.com/watch?v=RYBUS5Nxxxk) which @@ -85,22 +75,23 @@ In order to start contributing, follow the following steps: #### Development commands | Command | Description | | --------------- | ------------------------------ | -| `yarn clear` | delete all node_modules in every subdirectory. | -| `yarn build:ui` | Builds the ui via webpack. | -| `yarn build` | Runs `build:dev` optimised for production. | -| `yarn build:ui:watch` | Watches the source files for changes and runs a build:ui in case. | -| `yarn build:ui:watch-poll` | Watches (and polls) the source files on a file share. Should preferably be used when working an a VM for example. | -| `yarn start-storybook` | Starts the storybook server on port 9001. | -| `yarn lint` | Lints all source files. | -| `yarn test` | Executes `yarn lint` to trigger tests via ava. | -| `yarn test:e2e` | Executes integration tests. | +| `make clean` | delete all node_modules in every subdirectory. | +| `make build` | Runs the development build. | +| `make build-watch` | Watches the source files for changes and runs a build in case. | +| `make build-watch-poll` | Watches (and polls) the source files on a file share. Should preferably be used when working an a VM for example. | +| `make storybook` | Starts the storybook server on port 9001. | +| `make lint` | Executes `make lint-js` and `make lint-editorconfig`. | +| `make lint-js` | Runs test in all subpackages via lerna. | +| `make lint-editorconfig` | Tests if all files respect the `.editorconfig`. | +| `make test` | Executes the test on all source files. | +| `make test-e2e` | Executes integration tests. | #### Code style -Our code style is based upon `xo`, with one big difference - We use 4 spaces instead of tabs, to align our code style a bit with the PSR-2 standard for our PHP codebase. To lint the code, execute `yarn lint` in your shell. +Our code style is based upon `xo`, with one big difference - We use 4 spaces instead of tabs, to align our code style a bit with the PSR-2 standard for our PHP codebase. To lint the code, execute `make lint` in your shell. #### Writing unit tests The unit tests are executed with [jest](https://facebook.github.io/jest/). -To run the unit tests, execute `yarn test` in your shell. +To run the unit tests, execute `make test` in your shell. Adding unit tests is fairly simple, just create a file on the same tree level as your changed/new feature, named `[filename].spec.js` and karma will execute all tests found within the spec file, other than that, just orient yourself on the existing tests. @@ -111,6 +102,18 @@ Use `it.only(() => {})` and `describe.only(() => {})` if you want to run a speci For end to end testing we use the headless chrome. So it is mandatory to install the chrome browser for integration tests. Since Chrome 59 the headless mode is integrated. So please install a Chome 59 or higher to execute the end to end tests. +#### Releasing +Run `VERSION= make release` +e.g `VERSION=1.0.2 make release`. +This checks if you set the environment variable, reinstall all node_modules, +builds a production release runs `make lint`, `make test` and `make test-e2e`, +bumps the version locally via lerna and publish the version as a new npm tag. +After that you should carefully revisit your local changes, commit then and +open a pull request on Github. When travis runs through merge it an tag a new +release on Github. + +After that trigger jenkins with the new version. + ## License THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR diff --git a/package.json b/package.json index 78c59a66dd..084672955c 100644 --- a/package.json +++ b/package.json @@ -2,18 +2,6 @@ "description": "Root package + shared dev dependencies for @neos-project packages, managed by lernaJS", "license": "GNU GPLv3", "private": true, - "scripts": { - "clear": "rm -Rf node_modules; rm -rf packages/*/node_modules", - "build": "./Build/createVersionFile.sh && cross-env NODE_ENV=production yarn build:ui", - "build:ui": "NEOS_BUILD_ROOT=$(pwd) webpack --progress --colors", - "build:ui:watch": "yarn build:ui -- --watch", - "build:ui:watch-poll": "yarn run build:ui -- --watch-poll --watch", - "start-storybook": "lerna run --scope @neos-project/react-ui-components start", - "test": "lerna run test --concurrency 1", - "test:e2e": "yarn run testcafe chrome:headless Tests/IntegrationTests/* --selector-timeout=30000 --assertion-timeout=30000", - "lint": "lerna run lint --concurrency 1", - "lint:editorconfig": "editorconfig-checker --exclude-regexp 'LICENSE|\\.vanilla\\-css$|banner\\.js$' --exclude-pattern './{README.md,**/*.snap,**/*{fontAwesome,Resources}/**/*}'" - }, "resolutions": { "moment": "^2.20.1" },