nitro-converter/src/Main.ts

67 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-02-17 06:14:07 +01:00
import 'reflect-metadata';
import { container } from 'tsyringe';
2022-07-27 18:46:23 +02:00
import { FileUtilities } from './common';
2021-02-17 06:14:07 +01:00
import { Configuration } from './common/config/Configuration';
2021-02-22 06:39:02 +01:00
import { IConverter } from './common/converters/IConverter';
2021-12-23 08:43:32 +01:00
import { ConverterUtilities } from './converters/ConverterUtilities';
2021-08-19 10:02:25 +02:00
import { EffectMapConverter } from './converters/EffectMapConverter';
import { ExternalTextsConverter } from './converters/ExternalTextsConverter';
import { FigureDataConverter } from './converters/FigureDataConverter';
import { FigureMapConverter } from './converters/FigureMapConverter';
import { FurnitureDataConverter } from './converters/FurnitureDataConverter';
import { ProductDataConverter } from './converters/ProductDataConverter';
2021-02-17 06:14:07 +01:00
(async () =>
{
2022-07-27 18:46:23 +02:00
try
2021-12-23 08:43:32 +01:00
{
2022-07-27 18:46:23 +02:00
const configurationContent = await FileUtilities.readFileAsString('./configuration.json');
const config = container.resolve(Configuration);
2021-12-23 08:43:32 +01:00
2022-07-27 18:46:23 +02:00
await config.init(JSON.parse(configurationContent));
2021-12-23 08:43:32 +01:00
2022-07-27 18:46:23 +02:00
const converters = [
FurnitureDataConverter,
FigureDataConverter,
ProductDataConverter,
ExternalTextsConverter,
EffectMapConverter,
FigureMapConverter
];
2021-12-23 08:43:32 +01:00
2022-07-27 18:46:23 +02:00
const bundle = (process.argv.indexOf('--bundle') >= 0);
const extract = (process.argv.indexOf('--extract') >= 0);
const convertSwf = (process.argv.indexOf('--convert-swf') >= 0);
const skip = (bundle || extract || convertSwf);
2021-02-21 06:27:46 +01:00
2022-07-27 18:46:23 +02:00
if (skip)
{
const extractor = container.resolve(ConverterUtilities);
bundle && await extractor.bundleExtractedFromFolder();
extract && await extractor.extractNitroFromFolder();
convertSwf && await extractor.convertSwfFromFolder();
process.exit();
}
for (const converterClass of converters)
{
const converter = (container.resolve<any>(converterClass) as IConverter);
2021-02-25 00:24:09 +01:00
2022-07-27 18:46:23 +02:00
await converter.convertAsync();
}
2022-01-18 16:17:38 +01:00
2022-07-27 18:46:23 +02:00
const utilities = container.resolve(ConverterUtilities);
2022-01-18 16:17:38 +01:00
2022-07-27 18:46:23 +02:00
await utilities.downloadSwfTypes();
process.exit();
}
catch (e)
{
console.error(e);
}
2021-12-22 09:45:09 +01:00
})();