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

Upgrade Dependencies to fix vulnerabilities #36

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b33db2b
attempt to upgrade gulp etc. to fix broken build
GenieTim May 5, 2019
e358d5a
upgrade dependencies
GenieTim May 12, 2019
4470171
Upgrade Dependencies
GenieTim Dec 25, 2019
c969ab8
Upgrade Dependencies to latest version
GenieTim Aug 24, 2021
e6cbfb7
Upgrade Dependencies to latest version
GenieTim Sep 21, 2021
a356375
Upgrade Dependencies to latest version
GenieTim Nov 2, 2021
9d11e84
Upgrade Dependencies to latest version
GenieTim Nov 24, 2021
c44b237
Upgrade Dependencies to latest version
GenieTim Jan 11, 2022
c9c7ab4
Upgrade Dependencies to latest version
GenieTim Jan 28, 2022
0fcb9f6
Upgrade Dependencies to latest version
GenieTim Feb 11, 2022
a8b9a1d
Upgrade Dependencies to latest version
GenieTim Mar 1, 2022
0298eb5
Upgrade Dependencies to latest version
GenieTim Mar 19, 2022
b6c4e62
Upgrade Dependencies to latest version
GenieTim Mar 24, 2022
2a20695
Upgrade Dependencies to latest version
GenieTim Apr 19, 2022
09264bc
Upgrade Dependencies to latest version
GenieTim May 17, 2022
668531d
Upgrade Dependencies to latest version
GenieTim May 21, 2022
42a926d
Upgrade Dependencies to latest version
GenieTim Jun 17, 2022
3cca4ee
Upgrade Dependencies to latest version
GenieTim Jul 15, 2022
8a4b635
Upgrade Dependencies to latest version
GenieTim Aug 9, 2022
2692aea
Upgrade Dependencies to latest version
GenieTim Oct 1, 2022
ef248b5
Upgrade Dependencies to latest version
GenieTim Oct 18, 2022
7b19e12
Upgrade Dependencies to latest version
GenieTim Nov 23, 2022
69a5f8a
Upgrade Dependencies to latest version
GenieTim Dec 9, 2022
3afe249
Upgrade Dependencies to latest version
GenieTim May 3, 2023
f897eed
Upgrade Dependencies to latest version
GenieTim Jul 12, 2023
abc1abe
Upgrade Dependencies to latest version
GenieTim Oct 19, 2023
f966a17
Upgrade Dependencies to latest version
GenieTim Nov 10, 2023
68ec5af
Upgrade Dependencies to latest version
GenieTim May 2, 2024
5eb3dc6
Upgrade Dependencies to latest version
GenieTim Sep 17, 2024
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
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"presets": ["es2015"]
"presets": [
[
"@babel/preset-env"
]
]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ temp
dist
.sass-cache
.DS_Store
build
build
yarn.lock
225 changes: 105 additions & 120 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,162 +1,147 @@
import fs from "fs";
import gulp from 'gulp';
import {merge} from 'event-stream'
import browserify from 'browserify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import {merge} from 'event-stream'
import fs from 'fs';
import gulp from 'gulp';
import gulpif from 'gulp-if';
import preprocessify from 'preprocessify';
import gulpif from "gulp-if";
import buffer from 'vinyl-buffer';
import source from 'vinyl-source-stream';

const $ = require('gulp-load-plugins')();

var production = process.env.NODE_ENV === "production";
var target = process.env.TARGET || "chrome";
var environment = process.env.NODE_ENV || "development";
var production = process.env.NODE_ENV === 'production';
var target = process.env.TARGET || 'chrome';
var environment = process.env.NODE_ENV || 'development';

var generic = JSON.parse(fs.readFileSync(`./config/${environment}.json`));
var specific = JSON.parse(fs.readFileSync(`./config/${target}.json`));
var context = Object.assign({}, generic, specific);

var manifest = {
var defaultManifest = {
dev: {
"background": {
"scripts": [
"scripts/livereload.js",
"scripts/background.js"
]
}
'background':
{'scripts': ['scripts/livereload.js', 'scripts/background.js']}
},

firefox: {
"applications": {
"gecko": {
"id": "[email protected]"
}
}
}
}

// Tasks
gulp.task('clean', () => {
return pipe(`./build/${target}`, $.clean())
})

gulp.task('build', (cb) => {
$.runSequence('clean', 'styles', 'ext', cb)
});

gulp.task('watch', ['build'], () => {
$.livereload.listen();

gulp.watch(['./src/**/*']).on("change", () => {
$.runSequence('build', $.livereload.reload);
});
});

gulp.task('default', ['build']);

gulp.task('ext', ['manifest', 'js'], () => {
return mergeAll(target)
});
firefox: {'applications': {'gecko': {'id': '[email protected]'}}}
};


// -----------------
// COMMON
// -----------------
gulp.task('js', () => {
return buildJS(target)
})

gulp.task('styles', () => {
function styles() {
return gulp.src('src/styles/**/*.scss')
.pipe($.plumber())
.pipe($.sass.sync({
outputStyle: 'expanded',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe(gulp.dest(`build/${target}/styles`));
});

gulp.task("manifest", () => {
return gulp.src('./manifest.json')
.pipe(gulpif(!production, $.mergeJson({
fileName: "manifest.json",
jsonSpace: " ".repeat(4),
endObj: manifest.dev
})))
.pipe(gulpif(target === "firefox", $.mergeJson({
fileName: "manifest.json",
jsonSpace: " ".repeat(4),
endObj: manifest.firefox
})))
.pipe(gulp.dest(`./build/${target}`))
});

.pipe($.plumber())
.pipe(
$.sass
.sync(
{outputStyle: 'expanded', precision: 10, includePaths: ['.']})
.on('error', $.sass.logError))
.pipe(gulp.dest(`build/${target}/styles`));
}
exports.styles = styles;

function manifest() {
return gulp.src('./manifest.json')
.pipe(gulpif(!production, $.mergeJson({
fileName: 'manifest.json',
jsonSpace: ' '.repeat(4),
endObj: defaultManifest.dev
})))
.pipe(gulpif(target === 'firefox', $.mergeJson({
fileName: 'manifest.json',
jsonSpace: ' '.repeat(4),
endObj: defaultManifest.firefox
})))
.pipe(dest(`./build/${target}`))
}
exports.manifest = manifest;

// -----------------
// DIST
// -----------------
gulp.task('dist', (cb) => {
$.runSequence('build', 'zip', cb)
});

gulp.task('zip', () => {
function zip() {
return pipe(`./build/${target}/**/*`, $.zip(`${target}.zip`), './dist')
})

}

// Helpers
function pipe(src, ...transforms) {
return transforms.reduce((stream, transform) => {
const isDest = typeof transform === 'string'
return stream.pipe(isDest ? gulp.dest(transform) : transform)
}, gulp.src(src))
}, gulp.src(src, { allowEmpty: true }))
}

function mergeAll(dest) {
return merge(
pipe('./src/icons/**/*', `./build/${dest}/icons`),
pipe(['./src/_locales/**/*'], `./build/${dest}/_locales`),
pipe([`./src/images/${target}/**/*`], `./build/${dest}/images`),
pipe(['./src/images/shared/**/*'], `./build/${dest}/images`),
pipe(['./src/**/*.html'], `./build/${dest}`)
)
pipe('./src/icons/**/*', `./build/${dest}/icons`),
pipe(['./src/_locales/**/*'], `./build/${dest}/_locales`),
pipe([`./src/images/${target}/**/*`], `./build/${dest}/images`),
pipe(['./src/images/shared/**/*'], `./build/${dest}/images`),
pipe(['./src/**/*.html'], `./build/${dest}`))
}

function buildJS(target) {
const files = [
'background.js',
'contentscript.js',
'options.js',
'popup.js',
'livereload.js'
]

let tasks = files.map( file => {
return browserify({
entries: 'src/scripts/' + file,
debug: true
})
.transform('babelify', { presets: ['es2015'] })
.transform(preprocessify, {
includeExtensions: ['.js'],
context: context
})
.bundle()
.pipe(source(file))
.pipe(buffer())
.pipe(gulpif(!production, $.sourcemaps.init({ loadMaps: true }) ))
.pipe(gulpif(!production, $.sourcemaps.write('./') ))
.pipe(gulpif(production, $.uglify({
"mangle": false,
"output": {
"ascii_only": true
}
})))
.pipe(gulp.dest(`build/${target}/scripts`));
});
const files =
[
'background.js', 'contentscript.js', 'options.js', 'popup.js',
'livereload.js'
]

let tasks = files.map(file => {
return browserify({entries: 'src/scripts/' + file, debug: true})
.transform('babelify', {presets: ['@babel/preset-env']})
.transform(
preprocessify, {includeExtensions: ['.js'], context: context})
.bundle()
.pipe(source(file))
.pipe(buffer())
.pipe(gulpif(!production, $.sourcemaps.init({loadMaps: true})))
.pipe(gulpif(!production, $.sourcemaps.write('./')))
.pipe(gulpif(
production,
$.uglify({'mangle': false, 'output': {'ascii_only': true}})))
.pipe(gulp.dest(`build/${target}/scripts`));
});

return merge.apply(null, tasks);
}
}

function js(done) {
buildJS(target)
done()
}
exports.js = js;

// Overall

// Tasks
function clean() {
return pipe(`./build/${target}`, $.clean())
}
exports.clean = clean;

function watch() {
$.livereload.listen();

gulp.watch(['./src/**/*']).on('change', () => {
$.runSequence('build', $.livereload.reload);
});
}
exports.watch = watch;

function ext(done) {
mergeAll(target)
done()
}
exports.ext = ext

// exports.assets = gulp.parallel(exports.styles, exports.js);
exports.assets = gulp.series(exports.styles, exports.js);
exports.build = gulp.series(clean, exports.assets, ext);
exports.default = exports.build;
exports.dist = gulp.series(exports.build, zip);
exports.ext = gulp.series(manifest, exports.js, ext);
46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,31 @@
},
"homepage": "https://www.emailthis.me/extension-boilerplate",
"devDependencies": {
"babel-core": "^6.1.2",
"babel-preset-es2015": "^6.1.2",
"babelify": "^7.3.0",
"browserify": "^14.1.0",
"cross-env": "^3.2.4",
"event-stream": "^3.3.4",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.0",
"gulp-clean": "^0.3.1",
"gulp-eslint": "^2.0.0",
"gulp-if": "^2.0.2",
"gulp-livereload": "^3.8.1",
"gulp-load-plugins": "^0.5.3",
"gulp-merge-json": "^1.0.0",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/register": "^7.24.6",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"cross-env": "^7.0.3",
"event-stream": "^4.0.1",
"gulp": "^5.0.0",
"gulp-babel": "^8.0.0",
"gulp-clean": "^0.4.0",
"gulp-eslint": "^6.0.0",
"gulp-if": "^3.0.0",
"gulp-livereload": "^4.0.1",
"gulp-load-plugins": "^2.0.8",
"gulp-merge-json": "^2.2.1",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-run-sequence": "*",
"gulp-sass": "^2.2.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.4",
"gulp-zip": "^2.0.3",
"gulp-rename": "^2.0.0",
"gulp-sass": "^5.1.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-uglify": "^3.0.2",
"gulp-zip": "^6.0.0",
"preprocessify": "^1.0.1",
"run-sequence": "^2.2.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
"vinyl-source-stream": "^2.0.0"
},
"dependencies": {}
}