-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fxupdater fix/change, added ability for local builds with .zip output * Added option for unzip local release * Added pretty logs
- Loading branch information
Showing
8 changed files
with
437 additions
and
40 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 |
---|---|---|
|
@@ -28,4 +28,7 @@ ui/*.suo | |
ui/*.ntvs* | ||
ui/*.njsproj | ||
ui/*.sln | ||
ui/*.sw? | ||
ui/*.sw? | ||
|
||
temp | ||
releases |
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
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
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 |
---|---|---|
@@ -1,15 +1,33 @@ | ||
var fs = require('fs') | ||
var fs = require('fs'); | ||
var colors = require('colors'); | ||
colors.enable() | ||
|
||
fs.readFile('../fxmanifest.lua', 'utf8', function (err, data) { | ||
if (err) throw err; | ||
|
||
console.info('>'.blue, 'Updating fxmanifest file...') | ||
|
||
let expr = /files \{([^}]*)\}/g | ||
let replace = | ||
`files { | ||
"ui/index.html", | ||
"ui/js/*.*", | ||
"ui/css/*.*", | ||
"ui/fonts/*.*", | ||
"ui/img/*.*" | ||
}` | ||
|
||
if (process.env.NODE_ENV === 'development') { | ||
data = data.replaceAll("ui/index.html", "ui/shim.html") | ||
} else { | ||
data = data.replaceAll("ui/shim.html", "ui/index.html") | ||
replace = | ||
`files { | ||
"ui/shim.html" | ||
}` | ||
} | ||
|
||
data = data.replaceAll(expr, replace) | ||
|
||
fs.writeFile ('../fxmanifest.lua', data, function(err) { | ||
if (err) throw err; | ||
console.log('fxmanifest file updated'); | ||
console.info('fxmanifest file updated!'.green); | ||
}); | ||
}); |
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,55 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var archiver = require('archiver'); | ||
var colors = require('colors'); | ||
colors.enable() | ||
|
||
var { version } = require('../package.json') | ||
|
||
function zipDirectory(sourceDir, outFolder, outPath) { | ||
const archive = archiver('zip', { zlib: { level: 9 }}); | ||
|
||
fs.mkdirSync(outFolder, { recursive: true }); | ||
const stream = fs.createWriteStream(`${outFolder}/${outPath}`); | ||
|
||
return new Promise((resolve, reject) => { | ||
archive | ||
.directory(sourceDir, false) | ||
.on('error', err => reject(err)) | ||
.pipe(stream) | ||
; | ||
|
||
stream.on('close', () => resolve()); | ||
archive.finalize(); | ||
}); | ||
} | ||
|
||
(async () => { | ||
console.info(">".blue, "Cloning project into release...") | ||
fs.readdirSync('../').forEach(path => { | ||
if (path !== 'ui' && path !=='releases') { | ||
fs.cpSync(`../${path}`, `../temp/${path}`, {recursive: true}); | ||
} | ||
}) | ||
|
||
console.info(">".blue, "Cloning UI build into release..."); | ||
fs.cpSync('./dist', '../temp/ui', {recursive: true}); | ||
|
||
let name = path.basename(path.resolve('../')); | ||
let output_file = `releases/${version}/${name}` | ||
|
||
if (process.env.ZIP === 'true') { | ||
console.info(">".blue, "Creating your release zip..."); | ||
await zipDirectory('../temp', `../releases/${version}`, `${name}.zip`); | ||
output_file = output_file+'.zip'; | ||
} else { | ||
console.info(">".blue, "Creating your release file..."); | ||
fs.cpSync('../temp', `../${output_file}`, {recursive: true}); | ||
} | ||
|
||
console.info(">".blue, "Cleaning up temp build folders..."); | ||
fs.rmSync('../temp', {force: true, recursive: true}); | ||
fs.rmSync('./dist', {force: true, recursive: true}); | ||
|
||
console.info(`Release is done!`.green, `${output_file}`.underline.yellow); | ||
})() |
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
Oops, something went wrong.