Update things

This commit is contained in:
Bill 2022-07-27 12:46:23 -04:00
parent 3deddc713f
commit 4863141073
7 changed files with 65 additions and 53 deletions

2
.gitignore vendored
View File

@ -54,4 +54,4 @@ Thumbs.db
/assets
# Nitro
/src/configuration.json
configuration.json

View File

@ -35,7 +35,7 @@ You may set any of the urls to a local path on your system or a remote url. A lo
## Running the converter
**Make sure you run `yarn install` before first use.**
**Make sure you run `yarn install && yarn build` before first use.**
To run the converter open a new terminal / console window in the main converter directory.
@ -43,6 +43,7 @@ The converter has a few different start commands:
| key | value |
| ---------------------- | ---------------------------------------------------------- |
| yarn build | Will run `tsc` and build .js from .ts |
| yarn start | Will download and convert assets as set in the config |
| yarn start:bundle | Will bundle decompressed `.nitro` assets (json / png) |
| yarn start:extract | Will extract `.nitro` assets which can be used for editing |

View File

@ -17,7 +17,7 @@
"scripts": {
"build": "tsc",
"start:dev": "ts-node-dev --respawn --transpile-only src/Main.ts",
"start": "yarn build && node ./dist/Main.js",
"start": "node ./dist/Main.js",
"start:bundle": "yarn start --bundle",
"start:extract": "yarn start --extract",
"start:convert-swf": "yarn start --convert-swf"

View File

@ -1,5 +1,6 @@
import 'reflect-metadata';
import { container } from 'tsyringe';
import { FileUtilities } from './common';
import { Configuration } from './common/config/Configuration';
import { IConverter } from './common/converters/IConverter';
import { ConverterUtilities } from './converters/ConverterUtilities';
@ -12,8 +13,12 @@ import { ProductDataConverter } from './converters/ProductDataConverter';
(async () =>
{
try
{
const configurationContent = await FileUtilities.readFileAsString('./configuration.json');
const config = container.resolve(Configuration);
await config.init();
await config.init(JSON.parse(configurationContent));
const converters = [
FurnitureDataConverter,
@ -52,4 +57,10 @@ import { ProductDataConverter } from './converters/ProductDataConverter';
await utilities.downloadSwfTypes();
process.exit();
}
catch (e)
{
console.error(e);
}
})();

View File

@ -1,5 +1,4 @@
import { singleton } from 'tsyringe';
import * as configuration from '../../configuration.json';
import { FileUtilities } from '../utils';
@singleton()
@ -12,7 +11,7 @@ export class Configuration
this._config = new Map<string, string>();
}
public async init(): Promise<void>
public async init(configuration: Object): Promise<void>
{
this.parseConfiguration(configuration);
@ -47,14 +46,14 @@ export class Configuration
{
const regex = new RegExp(/\${(.*?)}/g);
for(const key of Object.keys(configuration))
for (const key of Object.keys(content))
{
if (this._config.get(key))
{
if(!configuration[key].length) continue;
if (!content[key].length) continue;
}
this._config.set(key, this.interpolate(configuration[key], regex));
this._config.set(key, this.interpolate(content[key], regex));
}
return true;

View File

@ -22,6 +22,7 @@
],
"exclude": [
"node_modules",
"dist"
"dist",
"src/configuration.json"
]
}