@tamagui/cli 2.7.7 → 3.0.0-beta.643.1

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