From b0b4d3b2ec500464c225e9136b68799721446acc Mon Sep 17 00:00:00 2001 From: LouieK22 Date: Wed, 21 Feb 2024 14:26:10 -0600 Subject: [PATCH] Address review --- src/commands/init.ts | 27 ++++++++++++------- .../luau-package/{lib => src}/index.d.ts | 0 templates/luau-package/{lib => src}/init.lua | 0 templates/luau-package/tsconfig.json | 2 +- tsconfig.json | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) rename templates/luau-package/{lib => src}/index.d.ts (100%) rename templates/luau-package/{lib => src}/init.lua (100%) diff --git a/src/commands/init.ts b/src/commands/init.ts index 6196618..96c56d5 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -80,6 +80,14 @@ function cmd(cmdStr: string, cwd: string) { }); } +function shouldHaveDefaultScripts(template: InitMode) { + return template !== InitMode.LuauPackage; +} + +function isPackageTemplate(template: InitMode): template is InitMode.Package | InitMode.LuauPackage { + return template === InitMode.Package || template === InitMode.LuauPackage; +} + const GIT_IGNORE = ["/node_modules", "/out", "/include", "*.tsbuildinfo"]; async function init(argv: yargs.Arguments, initMode: InitMode) { @@ -229,29 +237,28 @@ async function init(argv: yargs.Arguments, initMode: InitMode) { await cmd(selectedPackageManager.init, cwd); const pkgJson = await fs.readJson(paths.packageJson); - if (template === InitMode.LuauPackage) { - pkgJson.scripts = undefined; - } else { + if (shouldHaveDefaultScripts(template)) { pkgJson.scripts = { build: "rbxtsc", watch: "rbxtsc -w", }; + } else { + pkgJson.scripts = undefined; } - if (template === InitMode.LuauPackage) { + if (isPackageTemplate(template)) { pkgJson.name = RBXTS_SCOPE + "/" + pkgJson.name; - pkgJson.main = "lib/init.lua"; - pkgJson.types = "lib/index.d.ts"; - pkgJson.files = ["lib/init.lua", "lib/index.d.ts"]; pkgJson.publishConfig = { access: "public" }; } - if (template === InitMode.Package) { - pkgJson.name = RBXTS_SCOPE + "/" + pkgJson.name; + if (template === InitMode.LuauPackage) { + pkgJson.main = "src/init.lua"; + pkgJson.types = "src/index.d.ts"; + pkgJson.files = ["src/*"]; + } else if (template === InitMode.Package) { pkgJson.main = "out/init.lua"; pkgJson.types = "out/index.d.ts"; pkgJson.files = ["out", "!**/*.tsbuildinfo"]; - pkgJson.publishConfig = { access: "public" }; pkgJson.scripts.prepublishOnly = selectedPackageManager.build; } diff --git a/templates/luau-package/lib/index.d.ts b/templates/luau-package/src/index.d.ts similarity index 100% rename from templates/luau-package/lib/index.d.ts rename to templates/luau-package/src/index.d.ts diff --git a/templates/luau-package/lib/init.lua b/templates/luau-package/src/init.lua similarity index 100% rename from templates/luau-package/lib/init.lua rename to templates/luau-package/src/init.lua diff --git a/templates/luau-package/tsconfig.json b/templates/luau-package/tsconfig.json index 656e3ad..f94bdfa 100644 --- a/templates/luau-package/tsconfig.json +++ b/templates/luau-package/tsconfig.json @@ -18,6 +18,6 @@ "declaration": false, // configurable - "rootDir": "lib" + "rootDir": "src" } } diff --git a/tsconfig.json b/tsconfig.json index b5309c4..904f861 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "target": "ES2019", "lib": ["ES2019"], "strict": true, - "noFallthroughCasesInSwitch": true, + "noFallthroughCasesInSwitch": false, "strictNullChecks": true, "esModuleInterop": true, "removeComments": true,