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

Commit

Permalink
Merge pull request #11 from vlaex/dev-1.0.1
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
vlaex authored Apr 10, 2022
2 parents 1cffaed + 5c117bc commit cc348ad
Show file tree
Hide file tree
Showing 92 changed files with 4,425 additions and 738 deletions.
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
src/_locales/*
src/assets/*
src/locales/*
src/assets/*
src/typings/*.d.ts
scripts/*.js
scripts/gulp/*.js
24 changes: 17 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,25 @@
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": ["warn", {
"argsIgnorePattern": "^_$"
}],
"object-curly-spacing": [2, "always"],
"indent": ["error", 2],
"no-alert": "error",
"keyword-spacing": "error",
"no-empty": "error",
"prefer-const": "off",
"indent": "off",
"linebreak-style": ["error", "windows"],
"semi": ["error", "always"],
"no-console": [
"warn", {
"allow": ["info", "error"]
"allow": ["debug", "error"]
}
],
"max-len": ["error", {
"code": 100,
"ignorePattern": "^\\s*<[A-Za-z].+>" // Ignores JSX
"ignorePattern": "^\\s*<[A-Za-z].+>"
}],
"no-multi-spaces": "error",
"space-infix-ops": "error",
Expand All @@ -60,9 +64,15 @@

// React
"react/react-in-jsx-scope": "off",

// TypeScript
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/quotes": "off"
"react/jsx-tag-spacing": "error",
"react/jsx-boolean-value": "error",
"react/jsx-wrap-multilines": ["error", {
"return": "parens",
"arrow": "ignore"
}],
"react/self-closing-comp": "error",
"react/jsx-no-bind": ["error", {
"allowArrowFunctions": true
}]
}
}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/
package-lock.json
.vscode/
.idea/
build/
dist/
dist/
debug.log
3 changes: 2 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"selector-class-pattern": null,
"block-opening-brace-space-before": "always",
"declaration-no-important": true
}
},
"ignoreFiles": ["./build"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.exclude": {
"**/.git": true,
"**/debug.log": true
}
}
73 changes: 10 additions & 63 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,10 @@
const { src, task, dest, series, watch } = require("gulp");

const gulpChange = require("gulp-change");
const mergeDeep = require("merge-deep");
const sass = require("gulp-dart-sass");
const zip = require("gulp-zip");

const { GetFiles, ExtractFolder } = require("./scripts/files");

const BUILD_FOLDER = "./build";

task("manifest", () => {
const manifestData = { version: process.env.npm_package_version };

return src("./manifest.json")
.pipe(
gulpChange(content => {
let json = JSON.parse(content);
return JSON.stringify(mergeDeep(json, manifestData));
})
)
.pipe(dest(BUILD_FOLDER));
});

task("assets", () => {
const assets = [{
src: "./src/icons/**/*",
buildDir: "icons"
}, {
src: "./src/_locales/**/*",
buildDir: "_locales"
}];

assets.forEach(asset => {
src(asset.src).pipe(dest(`${BUILD_FOLDER}/${asset.buildDir}`));
});

return src(".");
});

task("sass", () => {
let files = GetFiles("./src/styles/*/styles.scss");

for (let file of files) {
src(file)
.pipe(sass({ outputStyle: "compressed" }))
.pipe(dest(`${BUILD_FOLDER}/styles/${ExtractFolder(file)}`));
}

return src(".");
});

task("watch", () => {
watch(["./src/styles/*/*.scss"], series("sass"));
});

task("zip", () => {
return src(`${BUILD_FOLDER}/**`)
.pipe(zip("build.zip"))
.pipe(dest("./dist"));
});

exports.default = series("manifest", "assets", "sass", "watch", "zip");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const tasks = require("./scripts/gulp");

exports.assets = tasks.assets;
exports.manifest = tasks.manifest;
exports.scss = tasks.scss;
exports.watch = tasks.watch;
exports.zip = tasks.zip;
exports.clean = tasks.clean;
exports.build = tasks.build;
16 changes: 9 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@
},
"host_permissions": [
"*://znanija.com/*",
"*://brainly.com/*"
"*://brainly.com/*",
"*://nosdevoirs.fr/*"
],
"permissions": ["storage"],
"permissions": ["storage", "scripting"],
"web_accessible_resources": [{
"matches": ["<all_urls>"],
"resources": ["styles/*"]
}, {
"matches": ["<all_urls>"],
"resources": ["content-scripts/*"]
"resources": ["styles/*", "content-scripts/*", "icons/*"]
}],
"content_scripts": [{
"matches": ["*://znanija.com/*", "*://brainly.com/*"],
"matches": [
"*://znanija.com/*",
"*://brainly.com/*",
"*://nosdevoirs.fr/*"
],
"js": ["content-scripts/contentScript.js"],
"run_at": "document_start"
}],
Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,37 @@
"version": "3.0.0",
"description": "A toolbox for Brainly mentors to make their life and work easier",
"scripts": {
"production": "npm run gulp:common && npm run webpack:build && gulp zip",
"watch": "concurrently -n w: npm:watch:* npm:gulp:common",
"production": "gulp clean && gulp build && npm run webpack:build && gulp zip",
"watch": "gulp clean && concurrently -n w: npm:watch:* \"gulp build\" && gulp watch",
"watch:webpack": "webpack -w --mode=development",
"watch:gulp": "gulp watch",
"webpack:build": "webpack build --mode=production",
"gulp:common": "gulp manifest assets sass",
"lint:ts": "eslint ./src --ext .ts,.tsx",
"lint:scss": "stylelint ./src/**/*.scss"
},
"author": "andrewss",
"license": "MIT",
"devDependencies": {
"@babel/register": "^7.17.0",
"@types/md5": "^2.3.2",
"@types/react-dom": "^17.0.11",
"@types/webextension-polyfill": "^0.8.2",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"babel-loader": "^8.2.3",
"del": "^6.0.0",
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.29.3",
"glob": "^7.2.0",
"gulp": "^4.0.2",
"gulp-change": "^1.0.2",
"gulp-dart-sass": "^1.0.2",
"gulp-uglify": "^3.0.2",
"gulp-zip": "^5.1.0",
"merge-deep": "^3.0.3",
"sass": "^1.49.8",
"sass-loader": "^12.6.0",
"stylelint": "^14.5.1",
"stylelint": "^14.6.0",
"stylelint-config-standard": "^25.0.0",
"stylelint-config-standard-scss": "^3.0.0",
"stylelint-scss": "^4.1.0",
Expand All @@ -44,10 +46,14 @@
"webpack-cli": "^4.9.2"
},
"dependencies": {
"brainly-style-guide": "<=208.2.3",
"brainly-style-guide": "^210.0.0",
"browser-polyfill": "^3.20.2",
"chart.js": "^3.7.1",
"md5": "^2.3.0",
"moment": "^2.29.1",
"moment-timezone": "^0.5.34",
"react": "^17.0.2",
"react-chartjs-2": "^4.0.1",
"react-dom": "^17.0.2",
"react-scripts": "^5.0.0"
}
Expand Down
10 changes: 10 additions & 0 deletions scripts/gulp/assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { src, dest } = require("gulp");

module.exports = function moveAssets(done) {
["icons", "_locales", "assets"].forEach(folder => {
src(`src/${folder}/**/*`)
.pipe(dest(`build/${folder}`));
});

done();
}
7 changes: 7 additions & 0 deletions scripts/gulp/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const del = require("del");

module.exports = async function clean(done) {
await del(["build", "dist"]);

done();
}
14 changes: 14 additions & 0 deletions scripts/gulp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { parallel } = require("gulp");

exports.assets = require("./assets");
exports.manifest = require("./manifest");
exports.scss = require("./scss");
exports.watch = require("./watch");
exports.zip = require("./zip");
exports.clean = require("./clean");

exports.build = parallel(
exports.manifest,
exports.assets,
exports.scss
);
18 changes: 18 additions & 0 deletions scripts/gulp/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { src, dest } = require("gulp");
const gulpChange = require("gulp-change");
const mergeDeep = require("merge-deep");

module.exports = function moveManifest() {
const manifestData = {
version: process.env.npm_package_version
};

return src("manifest.json")
.pipe(
gulpChange(content => {
let json = JSON.parse(content);
return JSON.stringify(mergeDeep(json, manifestData));
})
)
.pipe(dest("build"));
}
10 changes: 10 additions & 0 deletions scripts/gulp/scss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { src, dest } = require("gulp");
const sass = require("gulp-dart-sass");

module.exports = function compileScss() {
return src(["src/styles/*/styles.scss"])
.pipe(sass({
outputStyle: "compressed"
}))
.pipe(dest("build/styles"));
}
7 changes: 7 additions & 0 deletions scripts/gulp/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { watch, series } = require("gulp");

module.exports = function watchFiles() {
watch([
"src/styles/**/*.scss"
], series("scss"));
}
12 changes: 12 additions & 0 deletions scripts/gulp/zip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { src, dest, pipe } = require("gulp");
const zip = require("gulp-zip");

const { version } = require("../../package.json");

module.exports = function zipExtension() {
return src("build/**")
.pipe(zip(
`build__${version.replace(/\./g, "_")}.zip`
))
.pipe(dest("./dist"));
}
10 changes: 10 additions & 0 deletions src/_locales/ru/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": {
"message": "Znanija Наставник",
"description": "The name of the extension"
},
"description": {
"message": "Расширение для наставников znanija.com с полезными функциями и возможностями",
"description": "The description"
}
}
File renamed without changes.
Loading

0 comments on commit cc348ad

Please sign in to comment.