Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
LouieK22 committed Feb 21, 2024
1 parent 24c2b50 commit b0b4d3b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
27 changes: 17 additions & 10 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InitOptions>, initMode: InitMode) {
Expand Down Expand Up @@ -229,29 +237,28 @@ async function init(argv: yargs.Arguments<InitOptions>, 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;
}

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/luau-package/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"declaration": false,

// configurable
"rootDir": "lib"
"rootDir": "src"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"target": "ES2019",
"lib": ["ES2019"],
"strict": true,
"noFallthroughCasesInSwitch": true,
"noFallthroughCasesInSwitch": false,
"strictNullChecks": true,
"esModuleInterop": true,
"removeComments": true,
Expand Down

0 comments on commit b0b4d3b

Please sign in to comment.