✨(tokens) add JS generator and re-organize the repo
Added JsGenerator which to implied to reorganize a bit the repo in order to extract generator-specific test into specific standalone files.
This commit is contained in:
@@ -1,19 +1,27 @@
|
||||
import { program } from "commander";
|
||||
import chalk from "chalk";
|
||||
import figlet from "figlet";
|
||||
import { cssGenerator } from "Generators/CssGenerator";
|
||||
import { getConfig } from "ConfigLoader";
|
||||
import { tokensGenerator } from "TokensGenerator";
|
||||
import { workPath } from "Paths";
|
||||
import { Generators } from "Generators";
|
||||
|
||||
export const buildTheme = async () => {
|
||||
const options = program.opts();
|
||||
const config = await getConfig();
|
||||
const tokens = tokensGenerator(config);
|
||||
await cssGenerator(tokens, {
|
||||
path: options.output,
|
||||
selector: options.selector,
|
||||
});
|
||||
const { generators } = options;
|
||||
await Promise.allSettled(
|
||||
generators.map((generator: string) => {
|
||||
if (!Generators[generator]) {
|
||||
throw new Error('The generator "' + generator + '" does not exist.');
|
||||
}
|
||||
return Generators[generator](tokens, {
|
||||
path: options.output,
|
||||
selector: options.selector,
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const run = async (args: string[]) => {
|
||||
@@ -21,6 +29,10 @@ export const run = async (args: string[]) => {
|
||||
chalk.red(figlet.textSync("Cunningham", { horizontalLayout: "full" }))
|
||||
);
|
||||
|
||||
const commaSeparatedList = (value: string) => {
|
||||
return value.split(",");
|
||||
};
|
||||
|
||||
program
|
||||
.description("Cunningham's CLI tool.")
|
||||
.option(
|
||||
@@ -33,6 +45,11 @@ export const run = async (args: string[]) => {
|
||||
"Specify the css root selector element.",
|
||||
":root"
|
||||
)
|
||||
.requiredOption(
|
||||
"-g, --generators <generators>",
|
||||
"Specify the generators to use.",
|
||||
commaSeparatedList
|
||||
)
|
||||
.parse(args);
|
||||
|
||||
await buildTheme();
|
||||
|
||||
Reference in New Issue
Block a user