-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manifest and Fragmenter Upgrade (#47)
* Manifest and Fragmenter Upgrade * oops
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 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,14 @@ | ||
{ | ||
"creator": "FlyByWire Simulations", | ||
"release_notes": { | ||
"neutral": { | ||
"LastUpdate": "", | ||
"OlderHistory": "" | ||
} | ||
}, | ||
"title": "SimBridge", | ||
"dependencies": [], | ||
"content_type": "TOOL", | ||
"minimum_game_version": "1.27.21.0", | ||
"manufacturer": "FlyByWire Simulations" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const child_process = require('child_process') | ||
|
||
const executeGitCommand = (command) => { | ||
return child_process.execSync(command) | ||
.toString('utf8') | ||
.replace(/[\n\r]+$/, ''); | ||
} | ||
|
||
const BASE_DIR = './build'; | ||
const MANIFEST_PATH = 'manifest.json'; | ||
const MANIFEST_BASE = require('../manifest-base.json') | ||
const GIT_COMMIT_SHA = process.env.GITHUB_SHA | ||
? process.env.GITHUB_SHA.substring(0, 9) | ||
: executeGitCommand('git rev-parse --short HEAD'); | ||
|
||
const generatePackageSize = () => { | ||
console.log("Generating Package Size") | ||
let totalPackageSize = 0; | ||
|
||
for (const filename of fs.readdirSync(BASE_DIR)) { | ||
const stat = fs.statSync(path.join(BASE_DIR,filename), { bigint: true }); | ||
totalPackageSize += Number(stat.size); | ||
} | ||
|
||
return totalPackageSize | ||
} | ||
|
||
const build_manifest = () => { | ||
try { | ||
console.log('Building manifest') | ||
fs.writeFileSync(path.join(BASE_DIR, MANIFEST_PATH), JSON.stringify({ | ||
...MANIFEST_BASE, | ||
package_version: require('../package.json').version + `-${GIT_COMMIT_SHA}`, | ||
total_package_size: generatePackageSize().toString().padStart(20, '0'), | ||
}, null, 2)) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
|
||
build_manifest() |