ddd
This commit is contained in:
parent
0a343ecbc5
commit
c3a6f5ff37
80 changed files with 2512 additions and 1625 deletions
14
scripts/generate-build-meta.js
Normal file
14
scripts/generate-build-meta.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
const fs=require('fs');
|
||||
const path=require('path');
|
||||
|
||||
const root=path.resolve(__dirname,'..');
|
||||
const packageJson=JSON.parse(fs.readFileSync(path.join(root,'package.json'),'utf8'));
|
||||
const config=JSON.parse(fs.readFileSync(path.join(root,'build-config.json'),'utf8'));
|
||||
if(!/^[0-9]+\.[0-9]+\.[0-9]+$/.test(packageJson.version))throw new Error('package.json version must use major.minor.patch');
|
||||
const appVersion=packageJson.version.split('.').slice(0,2).join('.');
|
||||
for(const key of['SAVE_SCHEMA','STORAGE_SCHEMA','IDB_LAYOUT_VERSION','FIELD_STORAGE_FORMAT','GAMEPLAY_DATA_VERSION','GENERATOR_VERSION'])if(!Number.isSafeInteger(config[key])||config[key]<1)throw new Error(`Invalid ${key}`);
|
||||
if(typeof config.WORLD_GENERATION!=='string'||!config.WORLD_GENERATION)throw new Error('Invalid WORLD_GENERATION');
|
||||
const meta={APP_VERSION:appVersion,PACKAGE_VERSION:packageJson.version,...config};
|
||||
const source=`'use strict';\n// Generated from package.json and build-config.json. Do not edit.\n(function attachBuildMeta(root,factory){\n const api=factory();\n if(typeof module==='object'&&module.exports)module.exports=api;\n if(root)root.BendBuildMeta=api;\n})(typeof globalThis!=='undefined'?globalThis:this,()=>Object.freeze(${JSON.stringify(meta,null,2)}));\n`;
|
||||
fs.writeFileSync(path.join(root,'build-meta.js'),source);
|
||||
Loading…
Add table
Add a link
Reference in a new issue