diff --git a/package.json b/package.json index 2f03dec..ffedd06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ttpg-scripts", - "version": "1.0.7", + "version": "1.1.0", "description": "", "bin": { "ttpg-scripts": "./bin/index.js" diff --git a/src/commands/build.ts b/src/commands/build.ts index fe4c296..c54d04d 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -32,7 +32,7 @@ export const runBuild = async () => { Logger.error("Could not create build directory"); throw e; } - if (config.project.template === "typescript") { + if (config.project.transpile || config.project.template === "typescript") { Logger.notice("Transpiling typescript"); try { await spawnTranspiler(`./build/`); diff --git a/src/commands/dev.ts b/src/commands/dev.ts index d4a20da..73ba97c 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -33,7 +33,7 @@ export const runDev = async () => { throw e; } } - if (config.project.template === "typescript") { + if (config.project.transpile || config.project.template === "typescript") { Logger.notice("Transpiling typescript"); try { await spawnTranspiler(`./dev/${config.project.slug}_dev/Scripts/`); diff --git a/src/common.ts b/src/common.ts index e531243..1a34296 100644 --- a/src/common.ts +++ b/src/common.ts @@ -22,7 +22,8 @@ export type Config = { name: string; slug: string; version: string; - template: "javascript" | "typescript"; + transpile: boolean; + template?: "javascript" | "typescript"; guid: { dev: string; prd: string; @@ -148,9 +149,19 @@ export const assertSetup = async (): Promise => { }; export const loadConfig = async (): Promise => { + const local: Config["local"] = JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.local.json"), "utf8")); + let project: Config["project"] = JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.project.json"), "utf8")); + + if (project.template && !("transpiler" in project)) { + project.transpile = project.template === "typescript"; + const { template, ...newProject } = project; + project = newProject; + await fs.writeFile(path.resolve("./ttpgcfg.project.json"), JSON.stringify(project), "utf-8"); + } + return { - local: JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.local.json"), "utf8")), - project: JSON.parse(await fs.readFile(path.resolve("./ttpgcfg.project.json"), "utf8")), + local, + project, }; };