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 /assets
# Nitro # 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 ## 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. 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 | | 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 | Will download and convert assets as set in the config |
| yarn start:bundle | Will bundle decompressed `.nitro` assets (json / png) | | yarn start:bundle | Will bundle decompressed `.nitro` assets (json / png) |
| yarn start:extract | Will extract `.nitro` assets which can be used for editing | | yarn start:extract | Will extract `.nitro` assets which can be used for editing |

View File

@ -17,7 +17,7 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"start:dev": "ts-node-dev --respawn --transpile-only src/Main.ts", "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:bundle": "yarn start --bundle",
"start:extract": "yarn start --extract", "start:extract": "yarn start --extract",
"start:convert-swf": "yarn start --convert-swf" "start:convert-swf": "yarn start --convert-swf"

View File

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

View File

@ -1,5 +1,4 @@
import { singleton } from 'tsyringe'; import { singleton } from 'tsyringe';
import * as configuration from '../../configuration.json';
import { FileUtilities } from '../utils'; import { FileUtilities } from '../utils';
@singleton() @singleton()
@ -12,7 +11,7 @@ export class Configuration
this._config = new Map<string, string>(); this._config = new Map<string, string>();
} }
public async init(): Promise<void> public async init(configuration: Object): Promise<void>
{ {
this.parseConfiguration(configuration); this.parseConfiguration(configuration);
@ -47,14 +46,14 @@ export class Configuration
{ {
const regex = new RegExp(/\${(.*?)}/g); 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 (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; return true;

View File

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