Skip to content

Commit

Permalink
Adding Theme Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Bizarrus committed Sep 25, 2024
1 parent cdb1f11 commit 13b4cb5
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .builder/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import Archiver from 'archiver';
import FS from 'fs';
import OS from 'os';

const exclude = [ 'themes.packages' ];

let themes = [];
let count = 0;

FS.readdirSync('../').forEach(file => {
/* Ignoring hidden files */
if(file.substr(0, 1) === '.') {
return;
}

/* Ignoring other files */
if(!exclude.indexOf(file)) {
return;
}

/* Only use Directorys */
if(FS.statSync('../' + file).isDirectory()) {
++count;
console.log('[INFO] Found Theme:', file);

const archive= Archiver('zip', {
zlib: {
level: 9
},
comment: 'Automatic packed by ThemePacker | fruithost'
});

const stream = FS.createWriteStream('../themes.packages/' + file + '.zip');

archive.directory('../' + file, true).on('finish', () => {
console.info('[INFO] Packed: ', file, '~> themes.packages/' + file + '.zip');
themes.push(file);
}).on('error', error => {
console.error('[ERROR]', error);
}).on('warning', warning => {
console.warn('[WARNING]', warning);
}).pipe(stream);

archive.finalize();
}
});

let _watcher = setInterval(() => {
if(themes.length == count) {
clearInterval(_watcher);
console.info('[INFO] Update themes.list');
themes.sort();

FS.writeFile('../themes.list', themes.join(OS.EOL), error => {
if (error) {
console.error('[ERROR]', error);
} else {
console.info('[INFO] themes.list updated with ', themes.length, ' Themes');
}
});
}
});
15 changes: 15 additions & 0 deletions .builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "builder",
"version": "1.0.0",
"type": "module",
"description": "Build themebased packages as installation package",
"main": "build.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Adrian Preuß",
"license": "MIT",
"dependencies": {
"archiver": "^7.0.1"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
/.builder/node_modules
.builder/package-lock.json
1 change: 1 addition & 0 deletions themes.packages/powerpanel.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//

0 comments on commit 13b4cb5

Please sign in to comment.