updating assets and rendering

This commit is contained in:
Jonas Pfalzgraf 2022-08-15 17:58:47 +02:00
parent 977831157f
commit 60bc8c71e9
17 changed files with 106 additions and 104 deletions

1
.gitignore vendored
View file

@ -689,3 +689,4 @@ dist
tools/syncConfig.js tools/syncConfig.js
tools/deploy.js tools/deploy.js
tools/v2.js

63
package-lock.json generated
View file

@ -1,46 +1,27 @@
{ {
"name": "browser_extension_template", "name": "browser_extension_template",
"version": "0.0.1", "version": "1.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "browser_extension_template", "name": "browser_extension_template",
"version": "0.0.1", "version": "1.0.0",
"license": "MIT",
"dependencies": { "dependencies": {
"bootstrap": "^5.2.0",
"friendly-helper": "^1.7.1" "friendly-helper": "^1.7.1"
}, },
"devDependencies": { "devDependencies": {
"@types/bootstrap": "^5.1.6",
"@types/node": "^18.7.4", "@types/node": "^18.7.4",
"sass": "^1.39.0", "sass": "^1.39.0",
"typescript": "^4.2.4" "typescript": "^4.2.4"
} }
}, },
"node_modules/@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@types/aes-js": { "node_modules/@types/aes-js": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/@types/aes-js/-/aes-js-3.1.1.tgz", "resolved": "https://registry.npmjs.org/@types/aes-js/-/aes-js-3.1.1.tgz",
"integrity": "sha512-SDSGgXT3LRCH6qMWk8OHT1vLSVNuHNvCpKCx2/TYtQMbMGGgxJC9fspwSkQjqzRagrWnCrxuLL3jMNXLXHHvSw==" "integrity": "sha512-SDSGgXT3LRCH6qMWk8OHT1vLSVNuHNvCpKCx2/TYtQMbMGGgxJC9fspwSkQjqzRagrWnCrxuLL3jMNXLXHHvSw=="
}, },
"node_modules/@types/bootstrap": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/@types/bootstrap/-/bootstrap-5.2.1.tgz",
"integrity": "sha512-jPdLpDnBTHeocqelEz+ZVP2eY12hIBXgJLV/n0URiQiiNLdCgHwDqaI0chijjn1qwvDNbjzhKDeYAHxsnIGtIA==",
"dev": true,
"dependencies": {
"@popperjs/core": "^2.9.2"
}
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.7.4", "version": "18.7.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.4.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.4.tgz",
@ -74,24 +55,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/bootstrap": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0.tgz",
"integrity": "sha512-qlnS9GL6YZE6Wnef46GxGv1UpGGzAwO0aPL1yOjzDIJpeApeMvqV24iL+pjr2kU4dduoBA9fINKWKgMToobx9A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/twbs"
},
{
"type": "opencollective",
"url": "https://opencollective.com/bootstrap"
}
],
"peerDependencies": {
"@popperjs/core": "^2.11.5"
}
},
"node_modules/braces": { "node_modules/braces": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
@ -312,25 +275,11 @@
} }
}, },
"dependencies": { "dependencies": {
"@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw=="
},
"@types/aes-js": { "@types/aes-js": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/@types/aes-js/-/aes-js-3.1.1.tgz", "resolved": "https://registry.npmjs.org/@types/aes-js/-/aes-js-3.1.1.tgz",
"integrity": "sha512-SDSGgXT3LRCH6qMWk8OHT1vLSVNuHNvCpKCx2/TYtQMbMGGgxJC9fspwSkQjqzRagrWnCrxuLL3jMNXLXHHvSw==" "integrity": "sha512-SDSGgXT3LRCH6qMWk8OHT1vLSVNuHNvCpKCx2/TYtQMbMGGgxJC9fspwSkQjqzRagrWnCrxuLL3jMNXLXHHvSw=="
}, },
"@types/bootstrap": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/@types/bootstrap/-/bootstrap-5.2.1.tgz",
"integrity": "sha512-jPdLpDnBTHeocqelEz+ZVP2eY12hIBXgJLV/n0URiQiiNLdCgHwDqaI0chijjn1qwvDNbjzhKDeYAHxsnIGtIA==",
"dev": true,
"requires": {
"@popperjs/core": "^2.9.2"
}
},
"@types/node": { "@types/node": {
"version": "18.7.4", "version": "18.7.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.4.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.4.tgz",
@ -358,12 +307,6 @@
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"dev": true "dev": true
}, },
"bootstrap": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0.tgz",
"integrity": "sha512-qlnS9GL6YZE6Wnef46GxGv1UpGGzAwO0aPL1yOjzDIJpeApeMvqV24iL+pjr2kU4dduoBA9fINKWKgMToobx9A==",
"requires": {}
},
"braces": { "braces": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",

View file

@ -2,14 +2,16 @@
"name": "browser_extension_template", "name": "browser_extension_template",
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"deploy": "tsc ./tools/deploy.ts --target esnext --module esnext && node ./tools/deploy.js && npm run build-js && npm run build-css", "deploy-v3": "npm run build-tooling && npm run sync && node ./tools/deploy.js && npm run build-js && npm run build-css",
"deploy-v2": "npm run deploy-v3 && node ./tools/v2.js",
"build-js": "tsc -p tsconfig.json", "build-js": "tsc -p tsconfig.json",
"build-css": "sass ./src/sass/:./dist/css/", "build-css": "sass ./src/sass/:./dist/css/",
"sync": "tsc ./tools/syncConfig.ts --target esnext --module esnext && node ./tools/syncConfig.js" "build-tooling": "tsc ./tools/v2.ts --target esnext --module esnext && tsc ./tools/syncConfig.ts --target esnext --module esnext && tsc ./tools/deploy.ts --target esnext --module esnext",
"sync": "npm run build-tooling && node ./tools/syncConfig.js"
}, },
"devDependencies": { "devDependencies": {
"@types/bootstrap": "^5.1.6",
"@types/node": "^18.7.4", "@types/node": "^18.7.4",
"sass": "^1.39.0", "sass": "^1.39.0",
"typescript": "^4.2.4" "typescript": "^4.2.4"
@ -20,7 +22,22 @@
"not dead" "not dead"
], ],
"dependencies": { "dependencies": {
"bootstrap": "^5.2.0",
"friendly-helper": "^1.7.1" "friendly-helper": "^1.7.1"
},
"authors": [
{
"name": "Jonas Pfalzgraf",
"email": "info@josunlp.de"
}
],
"description": "A basic template based on SASS and TypeScript to create browser extensions without directly relying on a larger framework.",
"homepage": "https://github.com/JosunLP/BrowserExtensionTemplate",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:JosunLP/BrowserExtensionTemplate.git"
},
"bugs": {
"url": "https://github.com/JosunLP/BrowserExtensionTemplate/issues"
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -1,8 +1,8 @@
{ {
"name": "BrowserExtensionTemplate", "name": "Browser Extension Template",
"version": "2.2.5", "version": "0.0.1",
"manifest_version": 3, "manifest_version": 3,
"description": "A Extension created for the FearNixx Community to monitor the uptime status.", "description": "A basic template based on SASS and TypeScript to create browser extensions without directly relying on a larger framework.",
"homepage_url": "https://github.com/JosunLP/BrowserExtensionTemplate", "homepage_url": "https://github.com/JosunLP/BrowserExtensionTemplate",
"icons": { "icons": {
"16": "icons/icon16.png", "16": "icons/icon16.png",

View file

@ -13,8 +13,8 @@ class App {
async drawData(): Promise<void> { async drawData(): Promise<void> {
const contentRoot = <HTMLDivElement>document.getElementById(App.contentEntry) const contentRoot = <HTMLDivElement>document.getElementById(App.contentEntry)
const body = new HTMLDivElement() const body = document.createElement("div")
const title = new HTMLHeadingElement() const title = document.createElement("h1")
title.innerText = "Hello World" title.innerText = "Hello World"
body.appendChild(title) body.appendChild(title)
contentRoot.appendChild(body) contentRoot.appendChild(body)

BIN
src/assets/logo.afdesign Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -1,7 +1,6 @@
@import 'root' @import 'root'
@import 'mixin' @import 'mixin'
@import 'content' @import 'content'
@import '../../node_modules/bootstrap/scss/bootstrap'
body body
height: 30rem height: 30rem

View file

@ -1,7 +1,8 @@
var fs = require('fs'); import * as fs from 'fs';
var path = require('path'); import * as path from 'path';
var DEPLOY_ENTRY = "./public"; const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8'));
var DEPLOY_TARGET = "./dist"; var DEPLOY_ENTRY = "./public/";
var DEPLOY_TARGET = "./dist/";
function deleteFolderRecursive(path: string) { function deleteFolderRecursive(path: string) {
if (fs.existsSync(path)) { if (fs.existsSync(path)) {
@ -17,6 +18,39 @@ function deleteFolderRecursive(path: string) {
} }
} }
function findHtmlFilesRecursive(source: string): string[] {
var files: string[] = [];
var dir = fs.readdirSync(source);
dir.forEach(function(file: any) {
var sourceFile = path.join(source, file);
var stat = fs.lstatSync(sourceFile);
if (stat.isDirectory()) {
files = files.concat(findHtmlFilesRecursive(sourceFile));
} else {
if (path.extname(sourceFile) == '.html') {
files.push(sourceFile);
}
}
});
return files;
}
function replaceKeywordsInHtmlFile(file: string, keywords: string[], values: string[]) {
var content = fs.readFileSync(file, 'utf8');
for (var i = 0; i < keywords.length; i++) {
content = content.replace(new RegExp(keywords[i], 'g'), values[i]);
}
file = file.replace("public\\", DEPLOY_TARGET);
fs.writeFileSync(file, content);
}
function buildHtmlFiles(source: string, keywords: string[], values: string[]) {
var files = findHtmlFilesRecursive(source);
files.forEach(function(file: string) {
replaceKeywordsInHtmlFile(file, keywords, values);
});
}
function mkdirSync(path: string) { function mkdirSync(path: string) {
try { try {
fs.mkdirSync(path); fs.mkdirSync(path);
@ -43,5 +77,6 @@ function copyFiles(source: string, target: string) {
deleteFolderRecursive(DEPLOY_TARGET); deleteFolderRecursive(DEPLOY_TARGET);
mkdirSync(DEPLOY_TARGET); mkdirSync(DEPLOY_TARGET);
copyFiles(DEPLOY_ENTRY, DEPLOY_TARGET); copyFiles(DEPLOY_ENTRY, DEPLOY_TARGET);
buildHtmlFiles(DEPLOY_ENTRY, ["{{BET}}"], [appConfig.AppData.name]);
console.log("Deployed to " + DEPLOY_TARGET); console.log("Deployed to " + DEPLOY_TARGET);

View file

@ -1,4 +1,4 @@
import fs from 'fs'; import * as fs from 'fs';
const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8')); const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8'));
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));

7
tools/v2.ts Normal file
View file

@ -0,0 +1,7 @@
import * as fs from 'fs';
const manifest = JSON.parse(fs.readFileSync('./dist/manifest.json', 'utf8'));
manifest.manifest_version = 2;
fs.writeFileSync('./dist/manifest.json', JSON.stringify(manifest, null, 2));

View file

@ -5,7 +5,7 @@
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
// "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ "module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */ // "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
@ -23,7 +23,7 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"moduleResolution": "node",
/* Strict Type-Checking Options */ /* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */