-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
/.builder/node_modules | ||
.builder/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// |