@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/add.cjs +96 -71
- package/dist/build.cjs +226 -133
- package/dist/cli.cjs +318 -268
- package/dist/generate-prompt.cjs +310 -261
- package/dist/generate.cjs +51 -38
- package/dist/update-template.cjs +43 -31
- package/dist/update.cjs +12 -10
- package/dist/upgrade.cjs +274 -162
- package/dist/utils.cjs +69 -44
- package/package.json +9 -8
- package/src/build.ts +190 -56
- package/src/cli.ts +20 -73
- package/src/generate-prompt.ts +1 -1
- package/src/utils.ts +13 -8
- package/types/build.d.ts +3 -0
- package/types/build.d.ts.map +1 -1
- package/types/generate-prompt.d.ts.map +1 -1
- package/types/utils.d.ts.map +1 -1
- package/dist/add.js +0 -91
- package/dist/add.js.map +0 -6
- package/dist/build.js +0 -188
- package/dist/build.js.map +0 -6
- package/dist/cli.js +0 -266
- package/dist/cli.js.map +0 -6
- package/dist/generate-prompt.js +0 -392
- package/dist/generate-prompt.js.map +0 -6
- package/dist/generate.js +0 -62
- package/dist/generate.js.map +0 -6
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -6
- package/dist/update-template.js +0 -57
- package/dist/update-template.js.map +0 -6
- package/dist/update.js +0 -22
- package/dist/update.js.map +0 -6
- package/dist/upgrade.js +0 -319
- package/dist/upgrade.js.map +0 -6
- package/dist/utils.js +0 -92
- package/dist/utils.js.map +0 -6
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
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const TAMAGUI_PACKAGES_PATTERN = /^(@tamagui\/|tamagui$)
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
67
|
-
(0, import_node_fs.existsSync)(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
|
|
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:
|
|
72
|
-
})
|
|
73
|
-
|
|
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
|
-
|
|
81
|
-
for (const filePath of packageJsonFiles)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
const {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
}
|
|
125
|
+
} catch {}
|
|
126
|
+
}
|
|
103
127
|
return packages;
|
|
104
128
|
}
|
|
105
129
|
async function getLatestVersion() {
|
|
106
130
|
try {
|
|
107
|
-
|
|
131
|
+
const result = (0, import_node_child_process.execSync)("npm view tamagui version", {
|
|
108
132
|
encoding: "utf-8"
|
|
109
|
-
})
|
|
110
|
-
|
|
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)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
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)
|
|
248
|
+
existing.push(commit);
|
|
249
|
+
grouped.set(commit.type, existing);
|
|
195
250
|
}
|
|
196
251
|
const sortedTypes = Array.from(grouped.keys()).sort((a, b) => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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("")
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
235
|
-
lines.push("")
|
|
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("")
|
|
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)
|
|
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
|
-
|
|
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!"))
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
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
|
-
|
|
307
|
-
if (!fromVersion && packages.length > 0
|
|
308
|
-
|
|
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)
|
|
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("")
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
for (const line of lines)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
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
|
}
|