@reliverse/dler 1.7.111 → 1.7.113

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.
@@ -1,23 +0,0 @@
1
- declare const _default: import("@reliverse/rempts").Command<{
2
- "to-catalog": {
3
- type: "boolean";
4
- description: string;
5
- };
6
- "from-catalog": {
7
- type: "boolean";
8
- description: string;
9
- };
10
- "remove-catalog": {
11
- type: "boolean";
12
- description: string;
13
- };
14
- "dry-run": {
15
- type: "boolean";
16
- description: string;
17
- };
18
- interactive: {
19
- type: "boolean";
20
- description: string;
21
- };
22
- }>;
23
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("@reliverse/rempts").Command<import("@reliverse/rempts").EmptyArgs>;
2
- export default _default;
@@ -1,50 +0,0 @@
1
- import { relinka } from "@reliverse/relinka";
2
- import { defineCommand, selectPrompt } from "@reliverse/rempts";
3
- import { execaCommand } from "execa";
4
- import { cliName } from "../config/constants.js";
5
- import { getAllPkgManagers } from "../utils/dependencies/getUserPkgManager.js";
6
- import { getCurrentWorkingDirectory } from "../utils/terminalHelpers.js";
7
- async function getPmOptions() {
8
- const projectPath = getCurrentWorkingDirectory();
9
- const detectedPMs = await getAllPkgManagers(projectPath);
10
- const detectedPMMap = new Map(detectedPMs.map((pm) => [pm.packageManager, pm.source]));
11
- const pmOptions = ["bun", "pnpm", "npm", "yarn"].map((pm) => {
12
- const option = {
13
- label: pm,
14
- value: pm
15
- };
16
- const source = detectedPMMap.get(pm);
17
- if (source && source !== "default") {
18
- option.hint = "detected";
19
- }
20
- return option;
21
- });
22
- const defaultValue = [...detectedPMMap.keys()][0] ?? "npm";
23
- return { pmOptions, defaultValue };
24
- }
25
- export default defineCommand({
26
- meta: {
27
- name: "update",
28
- description: "Updates the CLI to the latest version",
29
- hidden: false
30
- },
31
- run: async () => {
32
- try {
33
- const { pmOptions, defaultValue } = await getPmOptions();
34
- const pm = await selectPrompt({
35
- title: `Select a package manager to update the ${cliName}`,
36
- options: pmOptions,
37
- defaultValue
38
- });
39
- await execaCommand(`${pm} -g update --latest`, { stdio: "inherit" });
40
- relinka("success", "Updated successfully!", "You can now use the latest `rse cli` version.");
41
- } catch (error) {
42
- relinka(
43
- "error",
44
- "Failed to update @rse",
45
- error instanceof Error ? error.message : "Unknown error"
46
- );
47
- }
48
- process.exit(0);
49
- }
50
- });
@@ -1,8 +0,0 @@
1
- declare const _default: import("@reliverse/rempts").Command<{
2
- interactive: {
3
- type: "boolean";
4
- description: string;
5
- default: true;
6
- };
7
- }>;
8
- export default _default;
@@ -1,302 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { relinka } from "@reliverse/relinka";
3
- import { defineArgs, defineCommand, multiselectPrompt } from "@reliverse/rempts";
4
- import { lookpath } from "lookpath";
5
- import { readPackageJSON } from "pkg-types";
6
- import { x } from "../utils/exec/exec-mod.js";
7
- import { detectPackageManager } from "../utils/pm/pm-detect.js";
8
- export default defineCommand({
9
- meta: {
10
- name: "upgrade",
11
- version: "1.0.0",
12
- description: "Upgrade system development tools"
13
- },
14
- args: defineArgs({
15
- interactive: {
16
- type: "boolean",
17
- description: "Interactively select which tools to upgrade",
18
- default: true
19
- }
20
- }),
21
- async run({ args }) {
22
- const toolUpgradeFunctions = [
23
- { name: "dler (local)", fn: upgradeDlerLocal },
24
- { name: "dler (global)", fn: upgradeDlerGlobal },
25
- { name: "git", fn: upgradeGit },
26
- { name: "node.js", fn: upgradeNode },
27
- { name: "npm", fn: upgradeNpm },
28
- { name: "bun", fn: upgradeBun },
29
- { name: "yarn", fn: upgradeYarn },
30
- { name: "pnpm", fn: upgradePnpm }
31
- ];
32
- let results = [];
33
- if (args.interactive) {
34
- const preliminaryResults = await Promise.all(
35
- toolUpgradeFunctions.map(async ({ fn }) => await fn())
36
- );
37
- const availableTools = toolUpgradeFunctions.map((tool, index) => ({
38
- ...tool,
39
- result: preliminaryResults[index]
40
- })).filter(({ result }) => result && result.status !== "not-found");
41
- if (availableTools.length === 0) {
42
- relinka("warn", "No tools available for upgrade");
43
- return;
44
- }
45
- const selectedTools = await multiselectPrompt({
46
- title: "Select tools to upgrade",
47
- displayInstructions: true,
48
- options: [
49
- { label: "Exit", value: "exit" },
50
- ...availableTools.map(({ name, result }) => {
51
- const isUpToDate = result && result.status === "up-to-date";
52
- const hasErrors = result && result.status === "error";
53
- const canUpgrade = result && result.status === "upgraded";
54
- let label = name;
55
- if (isUpToDate) {
56
- label += " (up-to-date)";
57
- } else if (hasErrors) {
58
- label += " (has errors)";
59
- } else if (canUpgrade) {
60
- label += " (can be upgraded)";
61
- }
62
- return {
63
- label: isUpToDate || hasErrors ? re.gray(label) : label,
64
- value: name,
65
- disabled: isUpToDate || hasErrors,
66
- hint: hasErrors ? result.message : void 0
67
- };
68
- })
69
- ]
70
- });
71
- if (selectedTools.length === 0 || selectedTools.includes("exit")) {
72
- relinka("info", "Exiting upgrade process");
73
- return;
74
- }
75
- const actualSelectedTools = selectedTools.filter((tool) => tool !== "exit");
76
- relinka("info", `Upgrading ${actualSelectedTools.length} selected tools...`);
77
- for (const toolName of actualSelectedTools) {
78
- const tool = availableTools.find((t) => t.name === toolName);
79
- if (tool) {
80
- const result = await tool.fn();
81
- results.push(result);
82
- }
83
- }
84
- } else {
85
- results = await Promise.all(toolUpgradeFunctions.map(async ({ fn }) => await fn()));
86
- }
87
- const upgraded = results.filter((r) => r.status === "upgraded");
88
- const upToDate = results.filter((r) => r.status === "up-to-date");
89
- const notFound = results.filter((r) => r.status === "not-found");
90
- const errors = results.filter((r) => r.status === "error");
91
- if (upgraded.length > 0) {
92
- relinka("success", `Upgraded ${upgraded.length} tools:`);
93
- upgraded.forEach(
94
- (r) => relinka("verbose", ` \u2713 ${r.tool}${r.message ? ` - ${r.message}` : ""}`)
95
- );
96
- }
97
- if (upToDate.length > 0) {
98
- relinka("info", `${upToDate.length} tools already up-to-date:`);
99
- upToDate.forEach(
100
- (r) => relinka("verbose", ` \u2022 ${r.tool}${r.message ? ` - ${r.message}` : ""}`)
101
- );
102
- }
103
- if (notFound.length > 0) {
104
- relinka("warn", `${notFound.length} tools not installed (skipped):`);
105
- notFound.forEach((r) => relinka("verbose", ` - ${r.tool}`));
106
- }
107
- if (errors.length > 0) {
108
- relinka("error", `${errors.length} tools had errors:`);
109
- errors.forEach(
110
- (r) => relinka("verbose", ` \u2717 ${r.tool}${r.message ? ` - ${r.message}` : ""}`)
111
- );
112
- }
113
- relinka("success", "Upgrade check completed!");
114
- }
115
- });
116
- async function upgradeDlerLocal() {
117
- try {
118
- const pkg = await readPackageJSON();
119
- const hasDler = pkg.dependencies && "@reliverse/dler" in pkg.dependencies || pkg.devDependencies && "@reliverse/dler" in pkg.devDependencies;
120
- if (!hasDler) {
121
- return { tool: "dler (local)", status: "not-found" };
122
- }
123
- const packageManager = await detectPackageManager(process.cwd());
124
- if (!packageManager) {
125
- return { tool: "dler (local)", status: "error", message: "No package manager detected" };
126
- }
127
- const { exitCode } = await x(packageManager.command, ["update", "@reliverse/dler"], {
128
- nodeOptions: { stdio: "pipe" }
129
- });
130
- return exitCode === 0 ? { tool: "dler (local)", status: "upgraded", message: `via ${packageManager.command}` } : { tool: "dler (local)", status: "error", message: "Upgrade failed" };
131
- } catch (error) {
132
- return {
133
- tool: "dler (local)",
134
- status: "not-found"
135
- };
136
- }
137
- }
138
- async function upgradeDlerGlobal() {
139
- try {
140
- const dlerPath = await lookpath("dler");
141
- if (!dlerPath) {
142
- return { tool: "dler (global)", status: "not-found" };
143
- }
144
- const packageManagers = ["bun", "npm", "yarn", "pnpm"];
145
- for (const pm of packageManagers) {
146
- const pmPath = await lookpath(pm);
147
- if (pmPath) {
148
- try {
149
- const args = pm === "npm" ? ["install", "-g", "@reliverse/dler@latest"] : pm === "yarn" ? ["global", "add", "@reliverse/dler@latest"] : ["install", "-g", "@reliverse/dler@latest"];
150
- const { exitCode } = await x(pm, args, {
151
- nodeOptions: { stdio: "pipe" }
152
- });
153
- if (exitCode === 0) {
154
- return { tool: "dler (global)", status: "upgraded", message: `via ${pm}` };
155
- }
156
- } catch {
157
- }
158
- }
159
- }
160
- return { tool: "dler (global)", status: "error", message: "No suitable package manager found" };
161
- } catch (error) {
162
- return { tool: "dler (global)", status: "error", message: String(error) };
163
- }
164
- }
165
- async function upgradeGit() {
166
- try {
167
- const gitPath = await lookpath("git");
168
- if (!gitPath) {
169
- return { tool: "git", status: "not-found" };
170
- }
171
- const { stdout } = await x("git", ["--version"], {
172
- nodeOptions: { stdio: "pipe" }
173
- });
174
- return {
175
- tool: "git",
176
- status: "up-to-date",
177
- message: `${stdout.trim()} - manual upgrade required`
178
- };
179
- } catch (error) {
180
- return { tool: "git", status: "error", message: String(error) };
181
- }
182
- }
183
- async function upgradeNode() {
184
- try {
185
- const nodePath = await lookpath("node");
186
- if (!nodePath) {
187
- return { tool: "node.js", status: "not-found" };
188
- }
189
- const { stdout } = await x("node", ["--version"], {
190
- nodeOptions: { stdio: "pipe" }
191
- });
192
- return {
193
- tool: "node.js",
194
- status: "up-to-date",
195
- message: `${stdout.trim()} - manual upgrade required`
196
- };
197
- } catch (error) {
198
- return { tool: "node.js", status: "error", message: String(error) };
199
- }
200
- }
201
- async function upgradeNpm() {
202
- try {
203
- const npmPath = await lookpath("npm");
204
- if (!npmPath) {
205
- return { tool: "npm", status: "not-found" };
206
- }
207
- try {
208
- const { exitCode, stdout, stderr } = await x("npm", ["install", "-g", "npm@latest"], {
209
- nodeOptions: { stdio: "pipe" }
210
- });
211
- if (exitCode === 0) {
212
- const output = (stdout + stderr).toLowerCase();
213
- if (output.includes("unchanged") || output.includes("up-to-date") || output.includes("already")) {
214
- return { tool: "npm", status: "up-to-date" };
215
- }
216
- return { tool: "npm", status: "upgraded" };
217
- } else {
218
- return { tool: "npm", status: "error", message: "Upgrade failed" };
219
- }
220
- } catch (pipeError) {
221
- const { exitCode } = await x("npm", ["install", "-g", "npm@latest"], {
222
- nodeOptions: { stdio: "inherit" }
223
- });
224
- return exitCode === 0 ? { tool: "npm", status: "upgraded" } : { tool: "npm", status: "error", message: "Upgrade failed" };
225
- }
226
- } catch (error) {
227
- return { tool: "npm", status: "error", message: String(error) };
228
- }
229
- }
230
- async function upgradeBun() {
231
- try {
232
- const bunPath = await lookpath("bun");
233
- if (!bunPath) {
234
- return { tool: "bun", status: "not-found" };
235
- }
236
- const { exitCode, stdout, stderr } = await x("bun", ["upgrade"], {
237
- nodeOptions: { stdio: "pipe" }
238
- });
239
- if (exitCode !== 0) {
240
- return { tool: "bun", status: "error", message: "Upgrade failed" };
241
- }
242
- const output = (stdout + stderr).toLowerCase();
243
- if (output.includes("already") || output.includes("up-to-date") || output.includes("latest")) {
244
- return { tool: "bun", status: "up-to-date" };
245
- }
246
- return { tool: "bun", status: "upgraded" };
247
- } catch (error) {
248
- return { tool: "bun", status: "error", message: String(error) };
249
- }
250
- }
251
- async function upgradeYarn() {
252
- try {
253
- const yarnPath = await lookpath("yarn");
254
- if (!yarnPath) {
255
- return { tool: "yarn", status: "not-found" };
256
- }
257
- try {
258
- const { exitCode: upgradeResult } = await x("yarn", ["self-update"], {
259
- nodeOptions: { stdio: "pipe" }
260
- });
261
- if (upgradeResult === 0) {
262
- return { tool: "yarn", status: "upgraded", message: "self-update" };
263
- }
264
- } catch {
265
- }
266
- const npmPath = await lookpath("npm");
267
- if (npmPath) {
268
- const { exitCode } = await x("npm", ["install", "-g", "yarn@latest"], {
269
- nodeOptions: { stdio: "pipe" }
270
- });
271
- return exitCode === 0 ? { tool: "yarn", status: "upgraded", message: "via npm" } : { tool: "yarn", status: "error", message: "Upgrade failed" };
272
- }
273
- return { tool: "yarn", status: "error", message: "No upgrade method available" };
274
- } catch (error) {
275
- return { tool: "yarn", status: "error", message: String(error) };
276
- }
277
- }
278
- async function upgradePnpm() {
279
- try {
280
- const pnpmPath = await lookpath("pnpm");
281
- if (!pnpmPath) {
282
- return { tool: "pnpm", status: "not-found" };
283
- }
284
- try {
285
- const { exitCode } = await x("pnpm", ["add", "-g", "pnpm@latest"], {
286
- nodeOptions: { stdio: "pipe" }
287
- });
288
- return exitCode === 0 ? { tool: "pnpm", status: "upgraded" } : { tool: "pnpm", status: "error", message: "Upgrade failed" };
289
- } catch {
290
- const npmPath = await lookpath("npm");
291
- if (npmPath) {
292
- const { exitCode } = await x("npm", ["install", "-g", "pnpm@latest"], {
293
- nodeOptions: { stdio: "pipe" }
294
- });
295
- return exitCode === 0 ? { tool: "pnpm", status: "upgraded", message: "via npm" } : { tool: "pnpm", status: "error", message: "Upgrade failed" };
296
- }
297
- return { tool: "pnpm", status: "error", message: "No upgrade method available" };
298
- }
299
- } catch (error) {
300
- return { tool: "pnpm", status: "error", message: String(error) };
301
- }
302
- }