diff --git a/packages/bio-parsers/project.json b/packages/bio-parsers/project.json index dd54e9df..8de1ef96 100644 --- a/packages/bio-parsers/project.json +++ b/packages/bio-parsers/project.json @@ -19,7 +19,11 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs bio-parsers {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs bio-parsers latest", + "dependsOn": ["test", "build"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs bio-parsers beta", "dependsOn": ["test", "build"] }, "test": { diff --git a/packages/bounce-loader/project.json b/packages/bounce-loader/project.json index ad256032..ea073808 100644 --- a/packages/bounce-loader/project.json +++ b/packages/bounce-loader/project.json @@ -45,7 +45,11 @@ "command": "cd packages/bounce-loader && yarn vitest run --changed --config vite.config.ts" }, "publish": { - "command": "node tools/scripts/publish.mjs bounce-loader {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs bounce-loader latest", + "dependsOn": ["e2e", "build"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs bounce-loader beta", "dependsOn": ["e2e", "build"] } } diff --git a/packages/file-utils/project.json b/packages/file-utils/project.json index 90a741be..159dacfb 100644 --- a/packages/file-utils/project.json +++ b/packages/file-utils/project.json @@ -19,7 +19,11 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs file-utils {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs file-utils latest", + "dependsOn": ["test", "build"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs file-utils beta", "dependsOn": ["test", "build"] }, "test": { diff --git a/packages/ove/project.json b/packages/ove/project.json index 47751c0e..f5259f7e 100644 --- a/packages/ove/project.json +++ b/packages/ove/project.json @@ -24,7 +24,11 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs ove {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs ove latest", + "dependsOn": ["test", "build", "build_umd"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs ove beta", "dependsOn": ["test", "build", "build_umd"] }, "build_umd": { diff --git a/packages/range-utils/project.json b/packages/range-utils/project.json index 7d098018..72bfb5fb 100644 --- a/packages/range-utils/project.json +++ b/packages/range-utils/project.json @@ -19,7 +19,11 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs range-utils {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs range-utils latest", + "dependsOn": ["test", "build"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs range-utils beta", "dependsOn": ["test", "build"] }, "test": { diff --git a/packages/sequence-utils/project.json b/packages/sequence-utils/project.json index 5f3a44e5..d75b87e2 100644 --- a/packages/sequence-utils/project.json +++ b/packages/sequence-utils/project.json @@ -19,7 +19,11 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs sequence-utils {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs sequence-utils latest", + "dependsOn": ["test", "build"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs sequence-utils beta", "dependsOn": ["test", "build"] }, "test": { diff --git a/packages/ui/project.json b/packages/ui/project.json index ffb5a2c7..e3ddbdc5 100644 --- a/packages/ui/project.json +++ b/packages/ui/project.json @@ -13,7 +13,11 @@ } }, "publish": { - "command": "node tools/scripts/publish.mjs ui {args.ver} {args.tag}", + "command": "node tools/scripts/publish.mjs ui latest", + "dependsOn": ["test", "build"] + }, + "publish-beta": { + "command": "node tools/scripts/publish.mjs ui beta", "dependsOn": ["test", "build"] }, "build_simple": { diff --git a/tools/scripts/publish.mjs b/tools/scripts/publish.mjs index 727d109b..14871877 100644 --- a/tools/scripts/publish.mjs +++ b/tools/scripts/publish.mjs @@ -22,9 +22,10 @@ function invariant(condition, message) { } } -// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag} +// Executing publish script: node path/to/publish.mjs {name} --tag {tag} +// tag by default is "next". Manually set to beta for beta versions or latest for stable versions. // Default "tag" to "next" so we won't publish the "latest" tag by accident. -let [, , name, version, tag = "latest"] = process.argv; +let [, , name, tag = "next"] = process.argv; execSync(`git pull`); execSync(`yarn auto-changelog -p`); @@ -58,51 +59,58 @@ invariant( project, `Could not find project "${name}" in the workspace. Is the project.json configured correctly?` ); -const outputPath = project.data?.targets?.build?.options?.outputPath; +// const outputPath = project.data?.targets?.build?.options?.outputPath; const packagePath = project.data?.root; -if (!tag || tag === "undefined") { - tag = "latest"; -} -if (!version || version === "undefined") { - process.chdir(packagePath); - let json = JSON.parse(readFileSync(`package.json`).toString()); - version = json.version; +process.chdir(packagePath); +let json = JSON.parse(readFileSync(`package.json`).toString()); +let version = json.version; - // Bump the version +if (version.includes("-beta")) { + // If its not a beta version, remove beta version (version was already bumped when creating beta version) + if (tag !== "beta") { + const versionParts = version.split("-beta"); + version = versionParts[0]; + } else { + // Bump beta version only + const versionParts = version.split("."); + versionParts[3] = Number(versionParts[3]) + 1; // increase beta version + version = versionParts.join("."); + } +} else { + // Update the version const versionParts = version.split("."); versionParts[2] = Number(versionParts[2]) + 1; // increase patch version version = versionParts.join("."); - // Updating the version in "package.json" before publishing - try { - json.version = version; - writeFileSync(`package.json`, JSON.stringify(json, null, 2)); - } catch (e) { - console.error( - chalk.bold.red( - `Error writing package.json file from library build output.` - ) - ); - } - process.chdir(path.resolve(`../../dist/${name}`)); - json = JSON.parse(readFileSync(`package.json`).toString()); - try { - json.version = version; - // json.type = "commonjs"; - delete json.type; - json.license = "MIT"; - json.dependencies = { ...deps, ...json.dependencies }; - writeFileSync(`package.json`, JSON.stringify(json, null, 2)); - } catch (e) { - console.error( - chalk.bold.red( - `Error writing package.json file from library build output.` - ) - ); + // If its beta, add beta version + if (tag === "beta") { + version = `${version}-beta.1`; } -} else { - process.chdir(path.resolve("../../", `dist/${name}`)); +} + +// Updating the version in "package.json" before publishing +try { + json.version = version; + writeFileSync(`package.json`, JSON.stringify(json, null, 2)); +} catch (e) { + console.error( + chalk.bold.red(`Error writing package.json file from library build output.`) + ); +} +process.chdir(path.resolve(`../../dist/${name}`)); +json = JSON.parse(readFileSync(`package.json`).toString()); +try { + json.version = version; + // json.type = "commonjs"; + delete json.type; + json.license = "MIT"; + json.dependencies = { ...deps, ...json.dependencies }; + writeFileSync(`package.json`, JSON.stringify(json, null, 2)); +} catch (e) { + console.error( + chalk.bold.red(`Error writing package.json file from library build output.`) + ); } invariant(