mirror of
https://github.com/JosunLP/BrowserExtensionTemplate.git
synced 2025-12-06 05:50:05 +00:00
basic structure
This commit is contained in:
parent
455c62a936
commit
977831157f
22 changed files with 1363 additions and 1 deletions
47
tools/deploy.ts
Normal file
47
tools/deploy.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var DEPLOY_ENTRY = "./public";
|
||||
var DEPLOY_TARGET = "./dist";
|
||||
|
||||
function deleteFolderRecursive(path: string) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(function(file: string) {
|
||||
var curPath = path + "/" + file;
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
deleteFolderRecursive(curPath);
|
||||
} else {
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
}
|
||||
|
||||
function mkdirSync(path: string) {
|
||||
try {
|
||||
fs.mkdirSync(path);
|
||||
} catch(e: any) {
|
||||
if ( e.code != 'EEXIST' ) throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function copyFiles(source: string, target: string) {
|
||||
var files = fs.readdirSync(source);
|
||||
files.forEach(function(file: any) {
|
||||
var sourceFile = path.join(source, file);
|
||||
var targetFile = path.join(target, file);
|
||||
var stat = fs.lstatSync(sourceFile);
|
||||
if (stat.isDirectory()) {
|
||||
mkdirSync(targetFile);
|
||||
copyFiles(sourceFile, targetFile);
|
||||
} else {
|
||||
fs.writeFileSync(targetFile, fs.readFileSync(sourceFile));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteFolderRecursive(DEPLOY_TARGET);
|
||||
mkdirSync(DEPLOY_TARGET);
|
||||
copyFiles(DEPLOY_ENTRY, DEPLOY_TARGET);
|
||||
|
||||
console.log("Deployed to " + DEPLOY_TARGET);
|
||||
22
tools/syncConfig.ts
Normal file
22
tools/syncConfig.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import fs from 'fs';
|
||||
|
||||
const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8'));
|
||||
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
const manifest = JSON.parse(fs.readFileSync('./public/manifest.json', 'utf8'));
|
||||
|
||||
pkg.version = appConfig.AppData.version;
|
||||
pkg.name = appConfig.AppData.id;
|
||||
pkg.authors = appConfig.AppData.authors;
|
||||
pkg.description = appConfig.AppData.description;
|
||||
pkg.homepage = appConfig.AppData.homepage;
|
||||
pkg.license = appConfig.AppData.license;
|
||||
pkg.repository = appConfig.AppData.repository;
|
||||
pkg.bugs = appConfig.AppData.bugs;
|
||||
|
||||
manifest.version = appConfig.AppData.version;
|
||||
manifest.name = appConfig.AppData.name;
|
||||
manifest.description = appConfig.AppData.description;
|
||||
manifest.homepage_url = appConfig.AppData.homepage;
|
||||
|
||||
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
|
||||
fs.writeFileSync('./public/manifest.json', JSON.stringify(manifest, null, 2));
|
||||
Loading…
Add table
Add a link
Reference in a new issue