mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-26 02:11:04 -05:00
Implemented action's entry point
This commit is contained in:
parent
f73c20d76f
commit
9101916d52
1 changed files with 34 additions and 0 deletions
34
src/index.ts
Normal file
34
src/index.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import PublisherFactory from "./publishing/publisher-factory";
|
||||||
|
import PublisherTarget from "./publishing/publisher-target";
|
||||||
|
import { getInputAsObject } from "./utils/input-utils";
|
||||||
|
import { getDefaultLogger } from "./utils/logger-utils";
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const commonOptions = getInputAsObject();
|
||||||
|
const publisherFactory = new PublisherFactory();
|
||||||
|
const logger = getDefaultLogger();
|
||||||
|
const publishedTo = new Array<string>();
|
||||||
|
|
||||||
|
for (const target of PublisherTarget.getValues()) {
|
||||||
|
const targetName = PublisherTarget.toString(target);
|
||||||
|
const publisherOptions = commonOptions[targetName.toLowerCase()];
|
||||||
|
if (!publisherOptions) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const publisher = publisherFactory.create(target, { ...commonOptions, ...publisherOptions }, logger);
|
||||||
|
logger.info(`Publishing assets to ${targetName}...`);
|
||||||
|
const start = new Date();
|
||||||
|
await publisher.publish();
|
||||||
|
logger.info(`Successfully published assets to ${targetName} (in ${new Date().getTime() - start.getTime()}ms)`);
|
||||||
|
publishedTo.push(targetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publishedTo.length) {
|
||||||
|
logger.info(`Your assets have been successfully published to: ${publishedTo.join(", ")}`);
|
||||||
|
} else {
|
||||||
|
logger.warn("You didn't specify any targets, your assets have not been published");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(error => getDefaultLogger().fatal(error instanceof Error ? error.message : `Something went horribly wrong: ${error}`));
|
Loading…
Reference in a new issue