@meteorjs/rspack 1.1.0-beta.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const semver = require('semver');
7
+
8
+ const VALID_LEVELS = ['major', 'minor', 'patch'];
9
+
10
+ function usage() {
11
+ console.log(`Usage: node ${path.basename(__filename)} <major|minor|patch> [--beta]`);
12
+ console.log('');
13
+ console.log('Examples:');
14
+ console.log(' patch # 1.0.1 -> 1.0.2');
15
+ console.log(' minor # 1.0.1 -> 1.1.0');
16
+ console.log(' major # 1.0.1 -> 2.0.0');
17
+ console.log(' patch --beta # 1.0.1 -> 1.0.2-beta.0');
18
+ console.log(' patch --beta # 1.0.2-beta.0 -> 1.0.2-beta.1 (already beta, bumps beta number)');
19
+ console.log(' minor --beta # 1.0.2-beta.1 -> 1.1.0-beta.0 (different bump level resets)');
20
+ process.exit(1);
21
+ }
22
+
23
+ const args = process.argv.slice(2);
24
+ const level = args[0];
25
+ const beta = args.includes('--beta');
26
+
27
+ if (!level || !VALID_LEVELS.includes(level)) {
28
+ if (level) console.error(`Error: first argument must be major, minor, or patch`);
29
+ usage();
30
+ }
31
+
32
+ const pkgPath = path.resolve(__dirname, '..', 'package.json');
33
+ const raw = fs.readFileSync(pkgPath, 'utf8');
34
+ const pkg = JSON.parse(raw);
35
+ const current = pkg.version;
36
+ const parsed = semver.parse(current);
37
+
38
+ if (!parsed) {
39
+ console.error(`Error: invalid current version "${current}"`);
40
+ process.exit(1);
41
+ }
42
+
43
+ let newVersion;
44
+
45
+ if (beta) {
46
+ const isBeta = parsed.prerelease.length > 0 && parsed.prerelease[0] === 'beta';
47
+
48
+ if (isBeta) {
49
+ // Already a beta. The base version already has a prior bump applied.
50
+ // Check if the same bump level is being requested by inspecting which
51
+ // components are zeroed out (major resets minor+patch, minor resets patch).
52
+ // If the same level, just increment the beta number.
53
+ const { major, minor, patch } = parsed;
54
+ const betaNum = typeof parsed.prerelease[1] === 'number' ? parsed.prerelease[1] : 0;
55
+ let sameLevel = false;
56
+
57
+ if (level === 'patch') {
58
+ sameLevel = true;
59
+ } else if (level === 'minor') {
60
+ sameLevel = patch === 0 && minor > 0;
61
+ } else if (level === 'major') {
62
+ sameLevel = minor === 0 && patch === 0;
63
+ }
64
+
65
+ if (sameLevel) {
66
+ newVersion = `${major}.${minor}.${patch}-beta.${betaNum + 1}`;
67
+ } else {
68
+ const bumped = semver.inc(`${major}.${minor}.${patch}`, level);
69
+ newVersion = `${bumped}-beta.0`;
70
+ }
71
+ } else {
72
+ // Not a beta yet: bump the base and start at beta.0
73
+ const bumped = semver.inc(current, level);
74
+ newVersion = `${bumped}-beta.0`;
75
+ }
76
+ } else {
77
+ if (parsed.prerelease.length > 0) {
78
+ // Currently a prerelease: bump base version from the clean base
79
+ const cleanBase = `${parsed.major}.${parsed.minor}.${parsed.patch}`;
80
+ newVersion = semver.inc(cleanBase, level);
81
+ } else {
82
+ newVersion = semver.inc(current, level);
83
+ }
84
+ }
85
+
86
+ pkg.version = newVersion;
87
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
88
+
89
+ console.log(`Bumped version: ${current} -> ${newVersion}`);
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ npm publish --tag beta "$@"