Skip to content

Commit

Permalink
Finish grunt removal
Browse files Browse the repository at this point in the history
Zipball can now be created using `npm run dist`.
  • Loading branch information
jtojnar committed Feb 21, 2019
1 parent aeb77a7 commit 4ff722e
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 120 deletions.
1 change: 0 additions & 1 deletion .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 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ 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 `npm run check` before submitting a pull request.

Expand Down
110 changes: 0 additions & 110 deletions gruntfile.js

This file was deleted.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
"url": "https://github.com/SSilence/selfoss.git"
},
"devDependencies": {
"eslint": "^5.14.1",
"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"
"archiver": "^3.0.0",
"eslint": "^5.14.1"
},
"engines": {
"npm": ">=5"
Expand All @@ -23,6 +19,8 @@
"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/"
Expand Down
102 changes: 102 additions & 0 deletions utils/create-zipball.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const fs = require('fs');
const path = require('path');
const archiver = require('archiver');

function filterEntry(fn) {
return (entry) => {
const obj = path.join(entry.prefix, entry.name).replace(/^\//, '');

return fn(obj) ? entry : false;
}
}

function isNotUnimportant(dest) {
const filename = path.basename(dest);

const filenameDisallowed = [
/^\.git(ignore|attributes|keep)$/,
/^\.travis\.yml$/,
/^\.editorconfig$/,
/^changelog/i,
/^contributing/i,
/^upgrading/i,
/^copying/i,
/^readme/i,
/^licen[cs]e/i,
/^version/i,
/^phpunit/,
/^l?gpl\.txt$/,
/^composer\.(json|lock)$/,
/^Makefile$/,
/^build\.xml$/,
/^phpcs-ruleset\.xml$/,
/^\.php_cs$/,
/^phpmd\.xml$/
].some(expr => expr.test(filename));

const destDisallowed = [
/^vendor\/htmlawed\/htmlawed\/htmLawed(Test\.php|(.*\.(htm|txt)))$/,
/^vendor\/smalot\/pdfparser\/\.atoum\.php$/,
/^vendor\/smottt\/wideimage\/demo/,
/^vendor\/simplepie\/simplepie\/(db\.sql|autoload\.php)$/,
/^vendor\/composer\/installed\.json$/,
/^vendor\/[^/]+\/[^/]+\/(test|doc)s?/i,
/^vendor\/[^/]+\/[^/]+\/\.git(\/|$)/,
/^vendor\/smalot\/pdfparser\/samples/,
/^vendor\/smalot\/pdfparser\/src\/Smalot\/PdfParser\/Tests/,
].some(expr => expr.test(dest));

const allowed = !(filenameDisallowed || destDisallowed);

return allowed;
}

const requiredAssets = (function() {
const files = JSON.parse(fs.readFileSync('public/package.json', 'utf-8')).extra.requiredFiles;

return files.css.concat(files.js);
})();


const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));

var output = fs.createWriteStream(`selfoss-${pkg.ver}.zip`);
var archive = archiver('zip');
archive.pipe(output);


// fill archive with data

archive.directory('controllers/', '/controllers');
archive.directory('daos/', '/daos');
archive.directory('helpers/', '/helpers');
archive.directory('vendor/', '/vendor', filterEntry(isNotUnimportant));

// do not pack bundled assets and assets not listed in index.php
archive.directory('public/', '/public', filterEntry(file => {
const bundle = file === 'public/all.js' || file === 'public/all.css';
const thirdPartyRubbish = file.startsWith('public/node_modules/') && requiredAssets.indexOf(file) === -1;
const allowed = !bundle && !thirdPartyRubbish;

return allowed;
}));

// copy data: only directory structure and .htaccess for deny
archive.directory('data/', '/data', filterEntry(file => fs.lstatSync(file).isDirectory()));
archive.file('data/cache/.htaccess');
archive.file('data/logs/.htaccess');
archive.file('data/sqlite/.htaccess');
archive.directory('data/fulltextrss', '/data/fulltextrss');

archive.directory('spouts/', '/spouts');
archive.directory('templates/', '/templates');

archive.file('.htaccess');
archive.file('README.md');
archive.file('defaults.ini');
archive.file('index.php');
archive.file('common.php');
archive.file('run.php');
archive.file('cliupdate.php');

archive.finalize();
2 changes: 1 addition & 1 deletion utils/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if [ -z "$TRAVIS_TAG" ]; then
npm run bump-version $NEW_VERSION
fi

grunt
npm run dist

0 comments on commit 4ff722e

Please sign in to comment.