Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #19 from keraf/build
Browse files Browse the repository at this point in the history
Added build step.
  • Loading branch information
keraf authored Sep 20, 2017
2 parents 6b433db + 095d1b3 commit 1476279
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/*
certs/*
node_modules/*
103 changes: 103 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const fs = require('fs');
const gulp = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const cleanCSS = require('gulp-clean-css');
const jeditor = require('gulp-json-editor');
const crx = require('gulp-crx-pack');
const zip = require('gulp-zip');
const del = require('del');
const runSequence = require('run-sequence');

const package = JSON.parse(fs.readFileSync('./package.json'));
const srcFolder = './src';
const buildFolder = './dist/tmp';
const babelConfig = {
presets: ['env'],
plugins: ['transform-object-rest-spread'],
}

// Clean old files
gulp.task('build:clean', () => {
return del(`${buildFolder}/**/*`);
});

// Copy files to build folder
gulp.task('build:copy', () => {
return gulp.src([
`${srcFolder}/**/*`,
`!${srcFolder}/**/*.js`,
`!${srcFolder}/**/*.css`,
`!${srcFolder}/manifest.json`])
.pipe(gulp.dest(buildFolder));
});

// Transform the manifest
gulp.task('build:manifest', () => {
return gulp.src(`${srcFolder}/manifest.json`)
.pipe(jeditor({
'version': package.version,
}))
.pipe(gulp.dest(buildFolder));
});

// Transform the JS files
gulp.task('build:js', () => {
gulp.src([`${srcFolder}/js/background.js`, `${srcFolder}/js/popup.js`])
.pipe(babel(babelConfig))
.pipe(uglify())
.pipe(gulp.dest(`${buildFolder}/js`));

return gulp.src(`${srcFolder}/js/jquery.min.js`)
.pipe(gulp.dest(`${buildFolder}/js`));
});

// Transform the CSS file
gulp.task('build:css', () => {
return gulp.src(`${srcFolder}/styles/popup.css`)
.pipe(cleanCSS())
.pipe(gulp.dest(`${buildFolder}/styles`));
});

// Zip it for FF
gulp.task('pack:firefox', () => {
return gulp.src(`${buildFolder}/**/*`)
.pipe(zip(`nocoin-${package.version}.xpi`))
.pipe(gulp.dest('./dist/firefox'));
});

// Zip it for Chrome
gulp.task('pack:chrome', () => {
return gulp.src(`${buildFolder}/**/*`)
.pipe(zip(`nocoin-${package.version}.zip`))
.pipe(gulp.dest('./dist/chrome'));
});

// Make CRX
gulp.task('pack:chromium', () => {
return gulp.src(`${buildFolder}`)
.pipe(crx({
privateKey: fs.readFileSync('./certs/key.pem', 'utf8'),
filename: `nocoin-${package.version}.crx`,
codebase: 'https://nocoin.ker.af/',
updateXmlFilename: 'update.xml'
}))
.pipe(gulp.dest('./dist/chromium'));
});

gulp.task('default', () => {
runSequence(
'build:clean',
'build:copy',
[
'build:manifest',
'build:js',
'build:css',
],
[
'pack:firefox',
'pack:chrome',
'pack:chromium',
]
);
});
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "no-coin",
"version": "0.3.1",
"description": "Stop coin miners on the web!",
"repository": {
"type": "git",
"url": "git+https://github.com/keraf/NoCoin.git"
},
"author": "Rafael Keramidas",
"license": "MIT",
"bugs": {
"url": "https://github.com/keraf/NoCoin/issues"
},
"homepage": "https://github.com/keraf/NoCoin#readme",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.0",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-babel": "^7.0.0",
"gulp-clean-css": "^3.9.0",
"gulp-crx-pack": "^1.0.1",
"gulp-json-editor": "^2.2.1",
"gulp-uglify": "^3.0.0",
"gulp-zip": "^4.0.0",
"run-sequence": "^2.2.0"
}
}
File renamed without changes.
File renamed without changes
File renamed without changes
1 change: 0 additions & 1 deletion js/background.js → src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* No Coin - Stop coin miners in your browser
**
* @author Rafael Keramidas <ker.af>
* @version 0.3
* @license MIT
* @source https://github.com/keraf/NoCoin
*/
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion js/popup.js → src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* No Coin - Stop coin miners in your browser
**
* @author Rafael Keramidas <ker.af>
* @version 0.3
* @license MIT
* @source https://github.com/keraf/NoCoin
*/
Expand Down
9 changes: 7 additions & 2 deletions manifest.json → src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "No Coin",
"description": "Stop coin miners on the web!",
"version": "0.3",
"version": "dev",
"permissions": [
"activeTab",
"tabs",
Expand All @@ -23,5 +23,10 @@
},
"manifest_version": 2,
"minimum_chrome_version": "55",
"author": "Rafael Keramidas"
"author": "Rafael Keramidas",
"applications": {
"gecko": {
"id": "{5657c026-efc3-4860-b43b-16e4eaa8a9aa}"
}
}
}
1 change: 0 additions & 1 deletion styles/popup.css → src/styles/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* No Coin - Stop coin miners in your browser
**
* @author Rafael Keramidas <ker.af>
* @version 0.3
* @license MIT
* @source https://github.com/keraf/NoCoin
*/
Expand Down
4 changes: 4 additions & 0 deletions src/view/jquery.min.js

Large diffs are not rendered by default.

File renamed without changes.

0 comments on commit 1476279

Please sign in to comment.