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

[IMPROVE] Update tasks and metadata #1344

Merged
merged 12 commits into from
Oct 10, 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
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"extends": [
"@rocket.chat/eslint-config"
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2018
}
"parser": "babel-eslint"
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ Thumbs.db
/package-lock.json

/app
/coverage
/dist
/Development.provisionprofile
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ install:

script:
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export CSC_IDENTITY_AUTO_DISCOVERY=false; fi
- yarn release
- NODE_ENV=production yarn release
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ yarn test
Using [electron-mocha](https://github.com/jprichardson/electron-mocha) test runner with the [chai](http://chaijs.com/api/assert/) assertion library. This task searches for all files in `src` directory which respect pattern `*.spec.js`.


### Code coverage

```
yarn coverage
```

Using [istanbul](http://gotwarlost.github.io/istanbul/) code coverage tool.

You can set the reporter(s) by setting `ISTANBUL_REPORTERS` environment variable (defaults to `text-summary` and `html`). The report directory can be set with `ISTANBUL_REPORT_DIR` (defaults to `coverage`).


## Making a release

To package your app into an installer use command:
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ build_script:
$env:CSC_LINK = ($tmp.FullName + ".p12")
}
- yarn test
- set NODE_ENV=production
- yarn release

# on_finish:
Expand Down
17 changes: 17 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
exclude: 'node_modules/**',
presets: [
[
'@babel/preset-env',
{
targets: {
electron: 6,
},
},
],
],
plugins: [
'@babel/plugin-proposal-function-bind',
'@babel/plugin-proposal-class-properties',
],
};
220 changes: 219 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1 +1,219 @@
require('./tasks');
const icnsConvert = require('@fiahfy/icns-convert');
const { convert } = require('convert-svg-to-png');
const { build } = require('electron-builder');
const { readAsync, removeAsync, writeAsync } = require('fs-jetpack');
const { dest, parallel, series, src, task, watch } = require('gulp');
const execa = require('gulp-execa');
const less = require('gulp-less');
const toIco = require('to-ico');

const NODE_ENV = process.env.NODE_ENV || 'development';

task('clean', () => removeAsync('app'));

task('build:public', () => src('src/public/**/*')
.pipe(dest('app/public')));

task('build:i18n', () => src('src/i18n/lang/**/*')
.pipe(dest('app/i18n/lang')));

task('build:bundle', execa.task('rollup -c', { env: { NODE_ENV } }));

task('build:less', () => src('src/stylesheets/main.less')
.pipe(less())
.pipe(dest('app/stylesheets')));

task('build', parallel('build:public', 'build:i18n', 'build:bundle', 'build:less'));

task('watch', () => {
watch('src/public/**/*', task('build:public'));
watch('src/i18n/lang/**/*', task('build:i18n'));
watch('src/**/*.js', task('build:bundle'));
watch('src/**/*.less', task('build:less'));
});

task('test:build', execa.task('rollup -c', { env: { NODE_ENV: 'test' } }));

task('test:main',
execa.task('xvfb-maybe electron-mocha --require source-map-support/register app/main.specs/*.js'));

task('test:renderer',
execa.task('xvfb-maybe electron-mocha --require source-map-support/register --renderer app/renderer.specs/*.js'));

task('test', series('clean', 'test:build', 'test:main', 'test:renderer'));

task('start:electron', execa.task('electron .'));

task('start', series('build', parallel('watch', 'start:electron')));

task('release:darwin', () => build({
publish: NODE_ENV === 'production' ? 'onTagOrDraft' : 'never',
x64: true,
mac: [],
}));

task('release:linux', () => build({
publish: NODE_ENV === 'production' ? 'onTagOrDraft' : 'never',
x64: true,
linux: [],
c: { productName: 'rocketchat' },
}));

task('release:win32', () => build({
publish: NODE_ENV === 'production' ? 'onTagOrDraft' : 'never',
x64: true,
ia32: true,
win: [],
}));

task('release', series('build', `release:${ process.platform }`));

task('icons:clean', async () => {
await removeAsync('src/public/images/tray/darwin');
await removeAsync('src/public/images/tray/darwin-dark');
await removeAsync('src/public/images/tray/linux');
await removeAsync('src/public/images/tray/win32');
});

const createDarwinTrayIcon = ({ src, dest, dark = false }) => async () => {
const svg = (await readAsync(`src/icons/${ dark ? 'white' : 'black' }/${ src }.svg`))
.replace('viewBox="0 0 64 64"', 'viewBox="0 0 64 64" transform="scale(0.8)"');

const png24 = await convert(svg, { width: 24, height: 24 });
const png48 = await convert(svg, { width: 24, height: 24, scale: 2 });

await writeAsync(`src/public/images/tray/${ dark ? 'darwin-dark' : 'darwin' }/${ dest }.png`, png24);
await writeAsync(`src/public/images/tray/${ dark ? 'darwin-dark' : 'darwin' }/${ dest }@2x.png`, png48);
};

task('icons:darwin:default', createDarwinTrayIcon({ src: 'default', dest: 'default' }));
task('icons:darwin:notification', createDarwinTrayIcon({ src: 'notification-dot', dest: 'notification' }));
task('icons:darwin', series('icons:darwin:default', 'icons:darwin:notification'));

task('icons:darwin-dark:default', createDarwinTrayIcon({ src: 'default', dest: 'default', dark: true }));
task('icons:darwin-dark:notification', createDarwinTrayIcon({ src: 'notification-dot', dest: 'notification', dark: true }));
task('icons:darwin-dark', series('icons:darwin-dark:default', 'icons:darwin-dark:notification'));

const createLinuxTrayIcon = ({ src, dest }) => async () => {
const svg = await readAsync(`src/icons/grey/${ src }.svg`);

const png24 = await convert(svg, { width: 64, height: 64 });
const png48 = await convert(svg, { width: 64, height: 64, scale: 2 });

await writeAsync(`src/public/images/tray/linux/${ dest }.png`, png24);
await writeAsync(`src/public/images/tray/linux/${ dest }@2x.png`, png48);
};

task('icons:linux:default', createLinuxTrayIcon({ src: 'default', dest: 'default' }));
task('icons:linux:notification-dot', createLinuxTrayIcon({ src: 'notification-dot', dest: 'notification-dot' }));
task('icons:linux:notification-1', createLinuxTrayIcon({ src: 'notification-1', dest: 'notification-1' }));
task('icons:linux:notification-2', createLinuxTrayIcon({ src: 'notification-2', dest: 'notification-2' }));
task('icons:linux:notification-3', createLinuxTrayIcon({ src: 'notification-3', dest: 'notification-3' }));
task('icons:linux:notification-4', createLinuxTrayIcon({ src: 'notification-4', dest: 'notification-4' }));
task('icons:linux:notification-5', createLinuxTrayIcon({ src: 'notification-5', dest: 'notification-5' }));
task('icons:linux:notification-6', createLinuxTrayIcon({ src: 'notification-6', dest: 'notification-6' }));
task('icons:linux:notification-7', createLinuxTrayIcon({ src: 'notification-7', dest: 'notification-7' }));
task('icons:linux:notification-8', createLinuxTrayIcon({ src: 'notification-8', dest: 'notification-8' }));
task('icons:linux:notification-9', createLinuxTrayIcon({ src: 'notification-9', dest: 'notification-9' }));
task('icons:linux:notification-plus-9', createLinuxTrayIcon({ src: 'notification-plus-9', dest: 'notification-plus-9' }));
task('icons:linux', series(
'icons:linux:default',
'icons:linux:notification-dot',
'icons:linux:notification-1',
'icons:linux:notification-2',
'icons:linux:notification-3',
'icons:linux:notification-4',
'icons:linux:notification-5',
'icons:linux:notification-6',
'icons:linux:notification-7',
'icons:linux:notification-8',
'icons:linux:notification-9',
'icons:linux:notification-plus-9',
));

const createWindowsTrayIcon = ({ src, dest }) => async () => {
const smallSrc = src.startsWith('notification-') ? 'notification-dot' : src;
const smallSvg = await readAsync(`src/icons/grey/${ smallSrc }.svg`);
const svg = await readAsync(`src/icons/grey/${ src }.svg`);

const png16 = await convert(smallSvg, { width: 16, height: 16 });
const png24 = await convert(smallSvg, { width: 24, height: 24 });
const png32 = await convert(svg, { width: 32, height: 32 });
const png48 = await convert(svg, { width: 48, height: 48 });
const png64 = await convert(svg, { width: 64, height: 64 });
const png128 = await convert(svg, { width: 128, height: 128 });
const png256 = await convert(svg, { width: 256, height: 256 });
const ico = await toIco([png16, png24, png32, png48, png64, png128, png256]);

await writeAsync(`src/public/images/tray/win32/${ dest }.ico`, ico);
};

task('icons:win32:default', createWindowsTrayIcon({ src: 'default', dest: 'default' }));
task('icons:win32:notification-dot', createWindowsTrayIcon({ src: 'notification-dot', dest: 'notification-dot' }));
task('icons:win32:notification-1', createWindowsTrayIcon({ src: 'notification-1', dest: 'notification-1' }));
task('icons:win32:notification-2', createWindowsTrayIcon({ src: 'notification-2', dest: 'notification-2' }));
task('icons:win32:notification-3', createWindowsTrayIcon({ src: 'notification-3', dest: 'notification-3' }));
task('icons:win32:notification-4', createWindowsTrayIcon({ src: 'notification-4', dest: 'notification-4' }));
task('icons:win32:notification-5', createWindowsTrayIcon({ src: 'notification-5', dest: 'notification-5' }));
task('icons:win32:notification-6', createWindowsTrayIcon({ src: 'notification-6', dest: 'notification-6' }));
task('icons:win32:notification-7', createWindowsTrayIcon({ src: 'notification-7', dest: 'notification-7' }));
task('icons:win32:notification-8', createWindowsTrayIcon({ src: 'notification-8', dest: 'notification-8' }));
task('icons:win32:notification-9', createWindowsTrayIcon({ src: 'notification-9', dest: 'notification-9' }));
task('icons:win32:notification-plus-9', createWindowsTrayIcon({ src: 'notification-plus-9', dest: 'notification-plus-9' }));
task('icons:win32', series(
'icons:win32:default',
'icons:win32:notification-dot',
'icons:win32:notification-1',
'icons:win32:notification-2',
'icons:win32:notification-3',
'icons:win32:notification-4',
'icons:win32:notification-5',
'icons:win32:notification-6',
'icons:win32:notification-7',
'icons:win32:notification-8',
'icons:win32:notification-9',
'icons:win32:notification-plus-9',
));

task('icons:app', async () => {
const svg = await readAsync('src/icons/icon.svg');

const png16 = await convert(svg, { width: 16, height: 16 });
const png24 = await convert(svg, { width: 24, height: 24 });
const png32 = await convert(svg, { width: 32, height: 32 });
const png44 = await convert(svg, { width: 44, height: 44 });
const png48 = await convert(svg, { width: 48, height: 48 });
const png50 = await convert(svg, { width: 50, height: 50 });
const png64 = await convert(svg, { width: 64, height: 64 });
const png128 = await convert(svg, { width: 128, height: 128 });
const png150 = await convert(svg, { width: 150, height: 150 });
const png310v150 = await convert(svg, { width: 310, height: 150 });
const png256 = await convert(svg, { width: 256, height: 256 });
const png512 = await convert(svg, { width: 512, height: 512 });
const png1024 = await convert(svg, { width: 1024, height: 1024 });
const ico = await toIco([png16, png24, png32, png48, png64, png128, png256]);
const icns = await icnsConvert([png1024, png512, png256, png128, png64, png32, png16]);

await writeAsync('src/public/images/icon.png', png64);
await writeAsync('src/public/images/[email protected]', png128);
await writeAsync('build/icon.ico', ico);
await writeAsync('build/icon.icns', icns);
await writeAsync('build/installerIcon.ico', ico);
await writeAsync('build/uninstallerIcon.ico', ico);
await writeAsync('build/appx/Square44x44Logo.png', png44);
await writeAsync('build/appx/Square150x150Logo.png', png150);
await writeAsync('build/appx/StoreLogo.png', png50);
await writeAsync('build/appx/Wide310x150Logo.png', png310v150);
await writeAsync('build/icons/512x512.png', png512);
});

task('icons', series(
'icons:clean',
parallel(
'icons:darwin',
'icons:darwin-dark',
'icons:linux',
'icons:win32',
'icons:app'
)
));
59 changes: 35 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
{
"name": "rocketchat",
"productName": "Rocket.Chat",
"description": "Rocket.Chat Native Cross-Platform Desktop Application via Electron.",
"name": "@rocket.chat/electron",
"description": "Official OSX, Windows, and Linux Desktop Clients for Rocket.Chat",
"version": "2.16.0-develop",
"author": "Rocket.Chat Support <[email protected]>",
"copyright": "© 2019, Rocket.Chat",
"homepage": "https://rocket.chat",
"license": "MIT",
"main": "app/main.js",
"keywords": [
"rocketchat",
"desktop",
"electron"
],
"repository": {
"type": "git",
"url": "https://github.com/RocketChat/Rocket.Chat.Electron.git"
"url": "git+https://github.com/RocketChat/Rocket.Chat.Electron.git"
},
"bugs": {
"url": "https://github.com/RocketChat/Rocket.Chat.Electron/issues"
},
"main": "app/main.js",
"scripts": {
"postinstall": "electron-builder install-app-deps",
"gulp": "gulp",
"start": "gulp start",
"test": "gulp test",
"release": "gulp release",
"icons": "gulp icons",
"changelog": "conventional-changelog --config .github/changelog.js -i HISTORY.md -s",
"release": "gulp release --env=production",
"release-dev": "gulp release --env=development",
"eslint": "eslint src",
"stylelint": "stylelint 'src/**/*.css' 'src/**/*.less'",
"test": "gulp test",
"coverage": "gulp coverage"
"eslint": "eslint src gulpfile.js",
"stylelint": "stylelint 'src/**/*.css' 'src/**/*.less'"
},
"dependencies": {
"@bugsnag/js": "^6.3.2",
Expand All @@ -36,42 +40,49 @@
"spellchecker": "^3.5.0"
},
"devDependencies": {
"@babel/core": "^7.6.3",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-function-bind": "^7.2.0",
"@babel/preset-env": "^7.6.3",
"@babel/traverse": "^7.6.3",
"@babel/types": "^7.6.3",
"@fiahfy/icns-convert": "^0.0.6",
"@rocket.chat/eslint-config": "^0.4.0",
"babel-eslint": "^10.0.3",
"builtin-modules": "^3.0.0",
"chai": "^4.2.0",
"conventional-changelog-cli": "^2.0.11",
"convert-svg-to-png": "^0.5.0",
"electron": "^6.0.12",
"electron-builder": "^21.2.0",
"electron-mocha": "^8.0.1",
"electron-reload": "^1.5.0",
"eslint": "^6.5.1",
"eslint-plugin-import": "^2.17.2",
"gulp": "^4.0.0",
"gulp-cli": "^2.0.1",
"gulp-execa": "^1.0.1",
"gulp-less": "^4.0.1",
"gulp-plumber": "^1.2.0",
"gulp-rename": "^1.4.0",
"gulp-util": "^3.0.8",
"minimist": "^1.2.0",
"mocha": "^6.0.1",
"npm-run-all": "^4.1.3",
"nyc": "^14.0.0",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-istanbul": "^2.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.1.0",
"run-sequence": "^2.2.1",
"sinon": "^7.2.2",
"stylelint": "^11.0.0",
"stylelint-order": "^3.1.1",
"to-ico": "^1.1.5",
"xvfb-maybe": "^0.2.1"
},
"engines": {
"node": ">=10.16.x"
},
"devEngines": {
"node": ">=8.12.x",
"npm": ">=4.x",
"yarn": ">=0.21.3"
}
"node": ">=10.16.x",
"npm": ">=6.9.x",
"yarn": ">=1.17.x"
},
"productName": "Rocket.Chat"
}
Loading