Skip to content

Commit

Permalink
Manifest and Fragmenter Upgrade (#47)
Browse files Browse the repository at this point in the history
* Manifest and Fragmenter Upgrade

* oops
  • Loading branch information
Lucky38i authored Oct 15, 2022
1 parent 19b0be3 commit 409cb05
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
14 changes: 14 additions & 0 deletions manifest-base.json
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"
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build": "npm run build:server && npm run build:mcdu",
"build:mcdu": "webpack --config apps/mcdu/webpack.config.js",
"build:server": "nest build server",
"build:exec": "npm run build && npx pkg-exe-build build && npm run copy:deps",
"build:exec": "npm run build && npx pkg-exe-build build && npm run copy:deps && npm run build:manifest",
"build:manifest": "node scripts/manifest.js",
"copy:deps": "npm run copy:resources && npm run copy:modules && copyfiles -s -f LICENSE build && npm run fetch:terrain",
"copy:resources": "copyfiles -s -f apps/server/src/config/properties.json ./node_modules/pdf-to-printer/dist/SumatraPDF.exe build/resources",
"copy:modules": "npm run copy:traybin && npm run copy:pdfjs && npm run copy:nodehide && npm run copy:sharp && npm run copy:open",
Expand Down Expand Up @@ -98,7 +99,7 @@
"@babel/preset-react": "^7.16.7",
"@babel/runtime": "^7.17.2",
"@flybywiresim/eslint-config": "^0.2.3",
"@flybywiresim/fragmenter": "^0.6.1",
"@flybywiresim/fragmenter": "^0.7.1",
"@nestjs/cli": "^8.0.0",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
Expand Down
43 changes: 43 additions & 0 deletions scripts/manifest.js
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()

0 comments on commit 409cb05

Please sign in to comment.