Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of Grunt #1093

Merged
merged 3 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ cache:

before_install:
- nvm install 6
- npm install -g grunt-cli
- npm install
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi
- utils/install-phars.sh
Expand All @@ -39,9 +38,9 @@ before_script:
- composer install --prefer-dist --no-interaction

script:
- if [ "$LINT_JS" = true ]; then grunt lint:client; fi
- grunt lint:server
- if [ "$CS_FIXER" = true ]; then grunt cs:server; fi
- if [ "$LINT_JS" = true ]; then npm run lint:client; fi
- npm run lint:server
- if [ "$CS_FIXER" = true ]; then npm run cs:server; fi

before_deploy:
- source utils/package.sh
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- More of user interface is now translatable ([#1054](https://github.com/SSilence/selfoss/pull/1054))
- Open Sans font is no longer bundled, resulting in smaller installations. Additionally, `use_system_font` option was removed. The typeface is still set as the default font family, so if you want to use it, install it to your devices. If you want to use a different typeface, add `body { font-family: 'Foo Face'; }` to your `user.css`. ([#1072](https://github.com/SSilence/selfoss/pull/1072))
- The file name of exported sources now includes a timestamp ([#1078](https://github.com/SSilence/selfoss/pull/1078))
- Developers, we no longer use Grunt. Build the package using `npm run dist` and check the code using `npm run check`; see the `scripts` section in top-level `package.json`. ([#1093](https://github.com/SSilence/selfoss/pull/1093))


## 2.18 – 2018-03-05
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ DEVELOPMENT

Selfoss uses [composer](https://getcomposer.org/) for installing external libraries. When you clone the repository you have to issue `composer install` to retrieve the external sources.

For the client side, you will also need JavaScript dependencies installed by calling `npm install` in the `public` directory.
For the client side, you will also need JavaScript dependencies installed by calling `npm install` in the `public` directory. You can use `npm run install-dependencies` as a shortcut for installing both dependencies.

If you want to create a package with all the dependencies bundled, you will additionally require [grunt](https://gruntjs.com/). After installing it, execute `npm install` in the selfoss directory to obtain the required tasks. Then you can run `grunt` command to produce a zipball. As a bonus, you can also use `grunt install` as a shortcut for installing the selfoss dependencies described above.
If you want to create a package with all the dependencies bundled, you can run `npm run dist` command to produce a zipball.

Every patch is expected to adhere to our coding style, which is checked automatically by Travis. You can install the checkers locally either with your package manager or by calling `utils/install-phars.sh`, and then run the checks using `grunt check` before submitting a pull request.
Every patch is expected to adhere to our coding style, which is checked automatically by Travis. You can install the checkers locally either with your package manager or by calling `utils/install-phars.sh`, and then run the checks using `npm run check` before submitting a pull request.

CREDITS
-------
Expand Down
4 changes: 2 additions & 2 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Release checklist
1. Update `NEWS.md` with highlights of changes. Set a release date.
2. Prepare a [draft of release](https://github.com/SSilence/selfoss/releases/new) on GitHub with the most recent part of the changelog as the body. Set the tag name to the expected version of the release.
3. Update the version strings throughout the code base to the new release using `grunt version --newversion 2.18`.
3. Update the version strings throughout the code base to the new release using `npm run bump-version 2.18`.
4. Create a tag using `git tag 2.18`.
5. Push the tag to GitHub `git push origin master --tags`, draft will be automatically published and release tarball will be built.
6. After the tarball is available, update the website.
7. Change the versions to new snapshot `grunt version --newversion 2.19-SNAPSHOT`.
7. Change the versions to new snapshot `npm run bump-version 2.19-SNAPSHOT`.
177 changes: 0 additions & 177 deletions gruntfile.js

This file was deleted.

18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
"url": "https://github.com/SSilence/selfoss.git"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-auto-install": "^0.3.1",
"grunt-cli": "^1.2.0",
"grunt-composer": "^0.4.5",
"grunt-contrib-compress": "^0.10.0",
"grunt-eslint": "^20.0.0",
"grunt-text-replace": "~0.3"
"archiver": "^3.0.0",
"eslint": "^5.14.1"
},
"engines": {
"npm": ">=5"
},
"scripts": {
"bump-version": "node utils/bump-version.js",
"check": "npm run check:client && npm run check:server",
"check:client": "npm run lint:client",
"check:server": "npm run lint:server && npm run cs:server",
"cs:server": "composer run-script cs",
"dist": "npm install && npm run install-dependencies && node utils/create-zipball.js",
"install-dependencies": "composer install --no-dev --optimize-autoloader --prefer-dist && cd public && npm install --production",
"lint:client": "eslint public/js/selfoss-*.js",
"lint:server": "composer run-script lint",
"postinstall": "npm install --prefix public/"
}
}
73 changes: 73 additions & 0 deletions utils/bump-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const fs = require('fs');

if (process.argv.length <= 2) {
console.error('Usage: bump-version.js <newVersion>');
process.exit(1);
}

const newVersion = process.argv[2];

if (newVersion.search(/^\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?$/) === -1) {
console.error('newVersion argument must have the format n.m or n.m-SNAPSHOT or n.m-hash (n and m are whole numbers, hash is hex number)');
process.exit(1);
}

const sources = [
'package.json',
'README.md',
'common.php',
'docs/api-description.json',
'_docs/website/index.html'
];

const replacements = [
// rule for package.json
{
from: /"ver": "\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?"/,
to: '"ver": "' + newVersion + '"'
},

// rule for README.md
{
from: /'version', '\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?'/,
to: "'version', '" + newVersion + "'"
},

// rule for common.php
{
from: /Version \d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?/,
to: "Version " + newVersion
},

// rule for docs/api-description.json
{
from: /"version": "\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?"/,
to: '"version": "' + newVersion + '"'
},

// rule for website/index.html
{
from: /selfoss( |\-)\d+\.\d+(\-SNAPSHOT|\-[0-9a-f]+)?/g,
to: "selfoss$1" + newVersion
},
];

console.log(`Replacing version with ${newVersion}.`);

for (const source of sources) {
fs.readFile(source, 'utf-8', (err, data) => {
if (err) {
throw err;
}

const newData = replacements.reduce((data, {from, to}) => data.replace(from, to), data);

fs.writeFile(source, newData, 'utf-8', (err) => {
if (err) {
throw err;
}

console.log(`- ${source}${data === newData ? ' (not changed)' : ''}`);
});
});
}
Loading