@tamagui/cli 2.0.0-rc.4 → 2.0.0-rc.40

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.
package/dist/upgrade.cjs CHANGED
@@ -2,112 +2,137 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var upgrade_exports = {};
33
35
  __export(upgrade_exports, {
34
36
  upgrade: () => upgrade
35
37
  });
36
38
  module.exports = __toCommonJS(upgrade_exports);
37
- var import_chalk = __toESM(require("chalk")),
38
- import_node_child_process = require("node:child_process"),
39
- import_node_fs = require("node:fs"),
40
- import_node_path = require("node:path");
41
- const TAMAGUI_PACKAGES_PATTERN = /^(@tamagui\/|tamagui$)/,
42
- COMMIT_TYPE_ORDER = ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci"];
39
+ var import_chalk = __toESM(require("chalk"));
40
+ var import_node_child_process = require("node:child_process");
41
+ var import_node_fs = require("node:fs");
42
+ var import_node_path = require("node:path");
43
+ const TAMAGUI_PACKAGES_PATTERN = /^(@tamagui\/|tamagui$)/;
44
+ const COMMIT_TYPE_ORDER = ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci"];
43
45
  function parseVersionSpecifier(version) {
44
- return version.startsWith(">=") ? {
45
- specifier: ">=",
46
- cleanVersion: version.slice(2)
47
- } : version.startsWith(">") ? {
48
- specifier: ">",
49
- cleanVersion: version.slice(1)
50
- } : version.startsWith("^") ? {
51
- specifier: "^",
52
- cleanVersion: version.slice(1)
53
- } : version.startsWith("~") ? {
54
- specifier: "~",
55
- cleanVersion: version.slice(1)
56
- } : version.startsWith("workspace:") ? {
57
- specifier: "",
58
- cleanVersion: version
59
- } : {
46
+ if (version.startsWith(">=")) {
47
+ return {
48
+ specifier: ">=",
49
+ cleanVersion: version.slice(2)
50
+ };
51
+ }
52
+ if (version.startsWith(">")) {
53
+ return {
54
+ specifier: ">",
55
+ cleanVersion: version.slice(1)
56
+ };
57
+ }
58
+ if (version.startsWith("^")) {
59
+ return {
60
+ specifier: "^",
61
+ cleanVersion: version.slice(1)
62
+ };
63
+ }
64
+ if (version.startsWith("~")) {
65
+ return {
66
+ specifier: "~",
67
+ cleanVersion: version.slice(1)
68
+ };
69
+ }
70
+ if (version.startsWith("workspace:")) {
71
+ return {
72
+ specifier: "",
73
+ cleanVersion: version
74
+ };
75
+ }
76
+ return {
60
77
  specifier: "",
61
78
  cleanVersion: version
62
79
  };
63
80
  }
64
81
  function findPackageJsonFiles(root) {
65
- const files = [],
66
- rootPkgPath = (0, import_node_path.join)(root, "package.json");
67
- (0, import_node_fs.existsSync)(rootPkgPath) && files.push(rootPkgPath);
82
+ const files = [];
83
+ const rootPkgPath = (0, import_node_path.join)(root, "package.json");
84
+ if ((0, import_node_fs.existsSync)(rootPkgPath)) {
85
+ files.push(rootPkgPath);
86
+ }
68
87
  try {
69
- const foundFiles = (0, import_node_child_process.execSync)(`find "${root}" -name "package.json" -not -path "*/node_modules/*" -not -path "*/.git/*" 2>/dev/null`, {
88
+ const result = (0, import_node_child_process.execSync)(`find "${root}" -name "package.json" -not -path "*/node_modules/*" -not -path "*/.git/*" 2>/dev/null`, {
70
89
  encoding: "utf-8",
71
- maxBuffer: 10485760
72
- }).trim().split(`
73
- `).filter(Boolean);
90
+ maxBuffer: 10 * 1024 * 1024
91
+ });
92
+ const foundFiles = result.trim().split("\n").filter(Boolean);
74
93
  files.push(...foundFiles.filter(f => !files.includes(f)));
75
94
  } catch {}
76
95
  return files;
77
96
  }
78
97
  function findTamaguiPackages(root) {
79
- const packageJsonFiles = findPackageJsonFiles(root),
80
- packages = [];
81
- for (const filePath of packageJsonFiles) try {
82
- const content = (0, import_node_fs.readFileSync)(filePath, "utf-8"),
83
- pkg = JSON.parse(content),
84
- depTypes = ["dependencies", "devDependencies", "peerDependencies"];
85
- for (const depType of depTypes) {
86
- const deps = pkg[depType];
87
- if (deps) for (const [name, version] of Object.entries(deps)) {
88
- if (typeof version != "string" || !TAMAGUI_PACKAGES_PATTERN.test(name) || version.startsWith("workspace:")) continue;
89
- const {
90
- specifier,
91
- cleanVersion
92
- } = parseVersionSpecifier(version);
93
- packages.push({
94
- name,
95
- version: cleanVersion,
96
- versionSpecifier: specifier,
97
- filePath,
98
- depType
99
- });
98
+ const packageJsonFiles = findPackageJsonFiles(root);
99
+ const packages = [];
100
+ for (const filePath of packageJsonFiles) {
101
+ try {
102
+ const content = (0, import_node_fs.readFileSync)(filePath, "utf-8");
103
+ const pkg = JSON.parse(content);
104
+ const depTypes = ["dependencies", "devDependencies", "peerDependencies"];
105
+ for (const depType of depTypes) {
106
+ const deps = pkg[depType];
107
+ if (!deps) continue;
108
+ for (const [name, version] of Object.entries(deps)) {
109
+ if (typeof version !== "string") continue;
110
+ if (!TAMAGUI_PACKAGES_PATTERN.test(name)) continue;
111
+ if (version.startsWith("workspace:")) continue;
112
+ const {
113
+ specifier,
114
+ cleanVersion
115
+ } = parseVersionSpecifier(version);
116
+ packages.push({
117
+ name,
118
+ version: cleanVersion,
119
+ versionSpecifier: specifier,
120
+ filePath,
121
+ depType
122
+ });
123
+ }
100
124
  }
101
- }
102
- } catch {}
125
+ } catch {}
126
+ }
103
127
  return packages;
104
128
  }
105
129
  async function getLatestVersion() {
106
130
  try {
107
- return (0, import_node_child_process.execSync)("npm view tamagui version", {
131
+ const result = (0, import_node_child_process.execSync)("npm view tamagui version", {
108
132
  encoding: "utf-8"
109
- }).trim();
110
- } catch {
133
+ });
134
+ return result.trim();
135
+ } catch (err) {
111
136
  throw new Error("Failed to fetch latest tamagui version from npm");
112
137
  }
113
138
  }
@@ -115,22 +140,31 @@ function getCurrentVersion(packages) {
115
140
  const versions = packages.map(p => p.version);
116
141
  if (versions.length === 0) return null;
117
142
  const counts = /* @__PURE__ */new Map();
118
- for (const v of versions) counts.set(v, (counts.get(v) || 0) + 1);
119
- let maxCount = 0,
120
- mostCommon = versions[0];
121
- for (const [v, count] of counts) count > maxCount && (maxCount = count, mostCommon = v);
143
+ for (const v of versions) {
144
+ counts.set(v, (counts.get(v) || 0) + 1);
145
+ }
146
+ let maxCount = 0;
147
+ let mostCommon = versions[0];
148
+ for (const [v, count] of counts) {
149
+ if (count > maxCount) {
150
+ maxCount = count;
151
+ mostCommon = v;
152
+ }
153
+ }
122
154
  return mostCommon;
123
155
  }
124
156
  function parseConventionalCommit(message) {
125
157
  const match = message.match(/^(\w+)(?:\(([^)]+)\))?(!)?: (.+)$/);
126
158
  if (!match) return null;
127
159
  const [, type, scope, breaking, msg] = match;
128
- return ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci", "build", "style"].includes(type) ? {
160
+ const validTypes = ["feat", "fix", "perf", "refactor", "docs", "chore", "test", "ci", "build", "style"];
161
+ if (!validTypes.includes(type)) return null;
162
+ return {
129
163
  type,
130
164
  scope,
131
165
  message: msg,
132
166
  breaking: !!breaking || message.toLowerCase().includes("breaking")
133
- } : null;
167
+ };
134
168
  }
135
169
  function getChangelogFromGit(fromVersion, toVersion, debug) {
136
170
  const commits = [];
@@ -141,9 +175,11 @@ function getChangelogFromGit(fromVersion, toVersion, debug) {
141
175
  stdio: "pipe"
142
176
  });
143
177
  } catch {}
144
- const fromTag = `v${fromVersion}`,
145
- toTag = `v${toVersion}`;
146
- debug && console.log(import_chalk.default.gray(` Looking for commits between ${fromTag} and ${toTag}...`));
178
+ const fromTag = `v${fromVersion}`;
179
+ const toTag = `v${toVersion}`;
180
+ if (debug) {
181
+ console.log(import_chalk.default.gray(` Looking for commits between ${fromTag} and ${toTag}...`));
182
+ }
147
183
  let result;
148
184
  try {
149
185
  result = (0, import_node_child_process.execSync)(`git log ${fromTag}..${toTag} --pretty=format:"%H|%ad|%s" --date=short 2>/dev/null`, {
@@ -151,25 +187,31 @@ function getChangelogFromGit(fromVersion, toVersion, debug) {
151
187
  maxBuffer: 10 * 1024 * 1024
152
188
  });
153
189
  } catch {
154
- return debug && console.log(import_chalk.default.gray(" Tags not found, trying alternative approach...")), commits;
190
+ if (debug) {
191
+ console.log(import_chalk.default.gray(` Tags not found, trying alternative approach...`));
192
+ }
193
+ return commits;
155
194
  }
156
- const lines = result.trim().split(`
157
- `).filter(Boolean);
195
+ const lines = result.trim().split("\n").filter(Boolean);
158
196
  for (const line of lines) {
159
- const [hash, date, ...messageParts] = line.split("|"),
160
- message = messageParts.join("|"),
161
- parsed = parseConventionalCommit(message);
162
- parsed && (["docs", "ci", "test", "build", "style"].includes(parsed.type) || commits.push({
197
+ const [hash, date, ...messageParts] = line.split("|");
198
+ const message = messageParts.join("|");
199
+ const parsed = parseConventionalCommit(message);
200
+ if (!parsed) continue;
201
+ if (["docs", "ci", "test", "build", "style"].includes(parsed.type)) continue;
202
+ commits.push({
163
203
  hash: hash.slice(0, 7),
164
204
  type: parsed.type,
165
205
  scope: parsed.scope,
166
206
  message: parsed.message,
167
207
  breaking: parsed.breaking,
168
208
  date
169
- }));
209
+ });
170
210
  }
171
211
  } catch (err) {
172
- debug && console.log(import_chalk.default.gray(` Could not fetch git history: ${err}`));
212
+ if (debug) {
213
+ console.log(import_chalk.default.gray(` Could not fetch git history: ${err}`));
214
+ }
173
215
  }
174
216
  return commits;
175
217
  }
@@ -181,86 +223,104 @@ async function getChangelogFromGitHub(fromVersion, toVersion, debug) {
181
223
  "User-Agent": "tamagui-cli"
182
224
  }
183
225
  });
184
- return response.ok ? (await response.json()).body || null : (debug && console.log(import_chalk.default.gray(` GitHub API returned ${response.status}`)), null);
226
+ if (!response.ok) {
227
+ if (debug) {
228
+ console.log(import_chalk.default.gray(` GitHub API returned ${response.status}`));
229
+ }
230
+ return null;
231
+ }
232
+ const data = await response.json();
233
+ return data.body || null;
185
234
  } catch (err) {
186
- return debug && console.log(import_chalk.default.gray(` Could not fetch from GitHub: ${err}`)), null;
235
+ if (debug) {
236
+ console.log(import_chalk.default.gray(` Could not fetch from GitHub: ${err}`));
237
+ }
238
+ return null;
187
239
  }
188
240
  }
189
241
  function formatChangelog(commits) {
190
- if (commits.length === 0) return import_chalk.default.gray(" No changes found");
242
+ if (commits.length === 0) {
243
+ return import_chalk.default.gray(" No changes found");
244
+ }
191
245
  const grouped = /* @__PURE__ */new Map();
192
246
  for (const commit of commits) {
193
247
  const existing = grouped.get(commit.type) || [];
194
- existing.push(commit), grouped.set(commit.type, existing);
248
+ existing.push(commit);
249
+ grouped.set(commit.type, existing);
195
250
  }
196
251
  const sortedTypes = Array.from(grouped.keys()).sort((a, b) => {
197
- const aIdx = COMMIT_TYPE_ORDER.indexOf(a),
198
- bIdx = COMMIT_TYPE_ORDER.indexOf(b);
199
- return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx);
200
- }),
201
- lines = [],
202
- breakingChanges = commits.filter(c => c.breaking);
252
+ const aIdx = COMMIT_TYPE_ORDER.indexOf(a);
253
+ const bIdx = COMMIT_TYPE_ORDER.indexOf(b);
254
+ return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx);
255
+ });
256
+ const lines = [];
257
+ const breakingChanges = commits.filter(c => c.breaking);
203
258
  if (breakingChanges.length > 0) {
204
- lines.push(""), lines.push(import_chalk.default.red.bold(" BREAKING CHANGES"));
259
+ lines.push("");
260
+ lines.push(import_chalk.default.red.bold(" BREAKING CHANGES"));
205
261
  for (const commit of breakingChanges) {
206
262
  const scope = commit.scope ? import_chalk.default.cyan(`(${commit.scope})`) : "";
207
263
  lines.push(` ${import_chalk.default.red("!")} ${scope} ${commit.message} ${import_chalk.default.gray(`(${commit.hash})`)}`);
208
264
  }
209
265
  }
210
266
  const typeLabels = {
211
- feat: "Features",
212
- fix: "Bug Fixes",
213
- perf: "Performance",
214
- refactor: "Refactoring",
215
- docs: "Documentation",
216
- chore: "Maintenance",
217
- test: "Tests",
218
- ci: "CI"
219
- },
220
- typeColors = {
221
- feat: import_chalk.default.green,
222
- fix: import_chalk.default.yellow,
223
- perf: import_chalk.default.magenta,
224
- refactor: import_chalk.default.blue,
225
- docs: import_chalk.default.gray,
226
- chore: import_chalk.default.gray,
227
- test: import_chalk.default.gray,
228
- ci: import_chalk.default.gray
229
- };
267
+ feat: "Features",
268
+ fix: "Bug Fixes",
269
+ perf: "Performance",
270
+ refactor: "Refactoring",
271
+ docs: "Documentation",
272
+ chore: "Maintenance",
273
+ test: "Tests",
274
+ ci: "CI"
275
+ };
276
+ const typeColors = {
277
+ feat: import_chalk.default.green,
278
+ fix: import_chalk.default.yellow,
279
+ perf: import_chalk.default.magenta,
280
+ refactor: import_chalk.default.blue,
281
+ docs: import_chalk.default.gray,
282
+ chore: import_chalk.default.gray,
283
+ test: import_chalk.default.gray,
284
+ ci: import_chalk.default.gray
285
+ };
230
286
  for (const type of sortedTypes) {
231
287
  const typeCommits = grouped.get(type).filter(c => !c.breaking);
232
288
  if (typeCommits.length === 0) continue;
233
- const label = typeLabels[type] || type,
234
- color = typeColors[type] || import_chalk.default.white;
235
- lines.push(""), lines.push(color.bold(` ${label}`));
289
+ const label = typeLabels[type] || type;
290
+ const color = typeColors[type] || import_chalk.default.white;
291
+ lines.push("");
292
+ lines.push(color.bold(` ${label}`));
236
293
  for (const commit of typeCommits) {
237
294
  const scope = commit.scope ? import_chalk.default.cyan(`(${commit.scope})`) : "";
238
295
  lines.push(` ${import_chalk.default.gray("-")} ${scope} ${commit.message} ${import_chalk.default.gray(`(${commit.hash})`)}`);
239
296
  }
240
297
  }
241
- return lines.join(`
242
- `);
298
+ return lines.join("\n");
243
299
  }
244
300
  function displayPackageSummary(packages) {
245
- console.log(""), console.log(import_chalk.default.bold("Found Tamagui packages:")), console.log("");
301
+ console.log("");
302
+ console.log(import_chalk.default.bold("Found Tamagui packages:"));
303
+ console.log("");
246
304
  const byFile = /* @__PURE__ */new Map();
247
305
  for (const pkg of packages) {
248
306
  const existing = byFile.get(pkg.filePath) || [];
249
- existing.push(pkg), byFile.set(pkg.filePath, existing);
307
+ existing.push(pkg);
308
+ byFile.set(pkg.filePath, existing);
250
309
  }
251
310
  const allVersions = new Set(packages.map(p => p.version));
252
311
  for (const [filePath, pkgs] of byFile) {
253
312
  const relativePath = filePath.replace(process.cwd(), ".").replace(/^\.\//, "");
254
313
  console.log(import_chalk.default.cyan(` ${relativePath}`));
255
314
  for (const pkg of pkgs) {
256
- const versionDisplay = `${pkg.versionSpecifier}${pkg.version}`,
257
- depTypeLabel = pkg.depType === "devDependencies" ? import_chalk.default.gray(" (dev)") : pkg.depType === "peerDependencies" ? import_chalk.default.gray(" (peer)") : "";
315
+ const versionDisplay = `${pkg.versionSpecifier}${pkg.version}`;
316
+ const depTypeLabel = pkg.depType === "devDependencies" ? import_chalk.default.gray(" (dev)") : pkg.depType === "peerDependencies" ? import_chalk.default.gray(" (peer)") : "";
258
317
  console.log(` ${import_chalk.default.white(pkg.name)} ${import_chalk.default.yellow(versionDisplay)}${depTypeLabel}`);
259
318
  }
260
319
  console.log("");
261
320
  }
262
321
  if (allVersions.size > 1) {
263
- console.log(import_chalk.default.yellow.bold("Warning: Version mismatch detected!")), console.log(import_chalk.default.yellow(" Found multiple versions:"));
322
+ console.log(import_chalk.default.yellow.bold("Warning: Version mismatch detected!"));
323
+ console.log(import_chalk.default.yellow(" Found multiple versions:"));
264
324
  for (const v of allVersions) {
265
325
  const count = packages.filter(p => p.version === v).length;
266
326
  console.log(import_chalk.default.yellow(` - ${v} (${count} packages)`));
@@ -272,56 +332,108 @@ function updatePackages(packages, newVersion, dryRun) {
272
332
  const byFile = /* @__PURE__ */new Map();
273
333
  for (const pkg of packages) {
274
334
  const existing = byFile.get(pkg.filePath) || [];
275
- existing.push(pkg), byFile.set(pkg.filePath, existing);
335
+ existing.push(pkg);
336
+ byFile.set(pkg.filePath, existing);
276
337
  }
277
338
  for (const [filePath, pkgs] of byFile) {
278
- const content = (0, import_node_fs.readFileSync)(filePath, "utf-8"),
279
- pkgJson = JSON.parse(content);
339
+ const content = (0, import_node_fs.readFileSync)(filePath, "utf-8");
340
+ const pkgJson = JSON.parse(content);
280
341
  for (const pkg of pkgs) {
281
342
  const newVersionStr = `${pkg.versionSpecifier}${newVersion}`;
282
- pkgJson[pkg.depType] && pkgJson[pkg.depType][pkg.name] && (pkgJson[pkg.depType][pkg.name] = newVersionStr);
343
+ if (pkgJson[pkg.depType] && pkgJson[pkg.depType][pkg.name]) {
344
+ pkgJson[pkg.depType][pkg.name] = newVersionStr;
345
+ }
346
+ }
347
+ if (!dryRun) {
348
+ (0, import_node_fs.writeFileSync)(filePath, JSON.stringify(pkgJson, null, 2) + "\n");
283
349
  }
284
- dryRun || (0, import_node_fs.writeFileSync)(filePath, JSON.stringify(pkgJson, null, 2) + `
285
- `);
286
350
  const relativePath = filePath.replace(process.cwd(), ".").replace(/^\.\//, "");
287
351
  console.log(import_chalk.default.green(` ${dryRun ? "[dry-run] " : ""}Updated ${relativePath}`));
288
352
  }
289
353
  }
290
354
  async function upgrade(options = {}) {
291
355
  const {
292
- from,
293
- to,
294
- changelogOnly,
295
- dryRun,
296
- debug
297
- } = options,
298
- root = process.cwd();
299
- console.log(""), console.log(import_chalk.default.bold.blue("Tamagui Upgrade")), console.log("");
356
+ from,
357
+ to,
358
+ changelogOnly,
359
+ dryRun,
360
+ debug
361
+ } = options;
362
+ const root = process.cwd();
363
+ console.log("");
364
+ console.log(import_chalk.default.bold.blue("Tamagui Upgrade"));
365
+ console.log("");
300
366
  const packages = findTamaguiPackages(root);
301
367
  if (packages.length === 0 && !changelogOnly) {
302
368
  console.log(import_chalk.default.yellow("No Tamagui packages found in this workspace."));
303
369
  return;
304
370
  }
305
- let fromVersion = from,
306
- toVersion = to;
307
- if (!fromVersion && packages.length > 0 && (fromVersion = getCurrentVersion(packages) || void 0), toVersion || (console.log(import_chalk.default.gray("Fetching latest version from npm...")), toVersion = await getLatestVersion()), fromVersion || (changelogOnly && (console.log(import_chalk.default.red("Error: --from version is required when using --changelog-only without packages")), process.exit(1)), fromVersion = toVersion), console.log(import_chalk.default.gray(` Current version: ${import_chalk.default.white(fromVersion)}`)), console.log(import_chalk.default.gray(` Target version: ${import_chalk.default.white(toVersion)}`)), console.log(""), packages.length > 0 && !changelogOnly && displayPackageSummary(packages), fromVersion !== toVersion) {
308
- console.log(import_chalk.default.bold("Changelog:")), console.log(import_chalk.default.gray(` (${fromVersion} -> ${toVersion})`));
371
+ let fromVersion = from;
372
+ let toVersion = to;
373
+ if (!fromVersion && packages.length > 0) {
374
+ fromVersion = getCurrentVersion(packages) || void 0;
375
+ }
376
+ if (!toVersion) {
377
+ console.log(import_chalk.default.gray("Fetching latest version from npm..."));
378
+ toVersion = await getLatestVersion();
379
+ }
380
+ if (!fromVersion) {
381
+ if (changelogOnly) {
382
+ console.log(import_chalk.default.red("Error: --from version is required when using --changelog-only without packages"));
383
+ process.exit(1);
384
+ }
385
+ fromVersion = toVersion;
386
+ }
387
+ console.log(import_chalk.default.gray(` Current version: ${import_chalk.default.white(fromVersion)}`));
388
+ console.log(import_chalk.default.gray(` Target version: ${import_chalk.default.white(toVersion)}`));
389
+ console.log("");
390
+ if (packages.length > 0 && !changelogOnly) {
391
+ displayPackageSummary(packages);
392
+ }
393
+ if (fromVersion !== toVersion) {
394
+ console.log(import_chalk.default.bold("Changelog:"));
395
+ console.log(import_chalk.default.gray(` (${fromVersion} -> ${toVersion})`));
309
396
  const commits = getChangelogFromGit(fromVersion, toVersion, debug);
310
- if (commits.length > 0) console.log(formatChangelog(commits));else {
397
+ if (commits.length > 0) {
398
+ console.log(formatChangelog(commits));
399
+ } else {
311
400
  const githubChangelog = await getChangelogFromGitHub(fromVersion, toVersion, debug);
312
401
  if (githubChangelog) {
313
- console.log(""), console.log(import_chalk.default.gray(" (from GitHub release notes)"));
314
- const lines = githubChangelog.split(`
315
- `).slice(0, 50);
316
- for (const line of lines) console.log(` ${line}`);
317
- githubChangelog.split(`
318
- `).length > 50 && console.log(import_chalk.default.gray(" ... (truncated, see full release notes on GitHub)"));
319
- } else console.log(import_chalk.default.gray(" No changelog available. Check https://github.com/tamagui/tamagui/releases"));
402
+ console.log("");
403
+ console.log(import_chalk.default.gray(" (from GitHub release notes)"));
404
+ const lines = githubChangelog.split("\n").slice(0, 50);
405
+ for (const line of lines) {
406
+ console.log(` ${line}`);
407
+ }
408
+ if (githubChangelog.split("\n").length > 50) {
409
+ console.log(import_chalk.default.gray(" ... (truncated, see full release notes on GitHub)"));
410
+ }
411
+ } else {
412
+ console.log(import_chalk.default.gray(" No changelog available. Check https://github.com/tamagui/tamagui/releases"));
413
+ }
320
414
  }
321
415
  console.log("");
322
416
  } else {
323
417
  console.log(import_chalk.default.green("Already on the latest version!"));
324
418
  return;
325
419
  }
326
- changelogOnly || (console.log(import_chalk.default.bold(`Upgrading to ${toVersion}${dryRun ? " (dry run)" : ""}:`)), console.log(""), updatePackages(packages, toVersion, dryRun), console.log(""), dryRun ? (console.log(import_chalk.default.yellow("Dry run complete. No files were modified.")), console.log(import_chalk.default.gray("Remove --dry-run to perform the actual upgrade."))) : (console.log(import_chalk.default.green.bold("Upgrade complete!")), console.log(""), console.log(import_chalk.default.gray("Next steps:")), console.log(import_chalk.default.gray(" 1. Run your package manager install (npm install, yarn, pnpm install)")), console.log(import_chalk.default.gray(" 2. Review the changelog above for any breaking changes")), console.log(import_chalk.default.gray(" 3. Test your application"))), console.log(""));
420
+ if (changelogOnly) {
421
+ return;
422
+ }
423
+ console.log(import_chalk.default.bold(`Upgrading to ${toVersion}${dryRun ? " (dry run)" : ""}:`));
424
+ console.log("");
425
+ updatePackages(packages, toVersion, dryRun);
426
+ console.log("");
427
+ if (!dryRun) {
428
+ console.log(import_chalk.default.green.bold("Upgrade complete!"));
429
+ console.log("");
430
+ console.log(import_chalk.default.gray("Next steps:"));
431
+ console.log(import_chalk.default.gray(" 1. Run your package manager install (npm install, yarn, pnpm install)"));
432
+ console.log(import_chalk.default.gray(" 2. Review the changelog above for any breaking changes"));
433
+ console.log(import_chalk.default.gray(" 3. Test your application"));
434
+ } else {
435
+ console.log(import_chalk.default.yellow("Dry run complete. No files were modified."));
436
+ console.log(import_chalk.default.gray("Remove --dry-run to perform the actual upgrade."));
437
+ }
438
+ console.log("");
327
439
  }