From 9e845b5c1dc8c300cc1093e8b7543be10bff8174 Mon Sep 17 00:00:00 2001 From: seveibar Date: Mon, 18 Mar 2024 18:09:51 -0700 Subject: [PATCH] automatically set package.json version if one isn't defined --- lib/cmd-fns/publish/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cmd-fns/publish/index.ts b/lib/cmd-fns/publish/index.ts index 5ae4cb61..912c12f8 100644 --- a/lib/cmd-fns/publish/index.ts +++ b/lib/cmd-fns/publish/index.ts @@ -34,6 +34,16 @@ export const publish = async (ctx: AppContext, args: any) => { await readFileSync(Path.join(ctx.cwd, "package.json"), "utf-8") ) + if (!packageJson.version) { + console.log(kleur.yellow("No version found in package.json")) + console.log(kleur.green("Setting package.json version to 0.0.1")) + packageJson.version = "0.0.1" + await fs.writeFile( + Path.join(ctx.cwd, "package.json"), + JSON.stringify(packageJson, null, 2) + ) + } + await esbuild.build({ entryPoints: ["index.ts"], // TODO dynamically determine entrypoint bundle: true,