formalconf 2.0.17 → 2.0.18
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/formalconf.js +119 -1
- package/package.json +1 -1
package/dist/formalconf.js
CHANGED
|
@@ -470,7 +470,7 @@ function StatusIndicator({
|
|
|
470
470
|
// package.json
|
|
471
471
|
var package_default = {
|
|
472
472
|
name: "formalconf",
|
|
473
|
-
version: "2.0.
|
|
473
|
+
version: "2.0.18",
|
|
474
474
|
description: "Dotfiles management TUI for macOS and Linux - config management, package sync, and theme switching",
|
|
475
475
|
type: "module",
|
|
476
476
|
main: "./dist/formalconf.js",
|
|
@@ -2189,6 +2189,9 @@ async function detectAvailablePackageManagers() {
|
|
|
2189
2189
|
managers.push("flatpak");
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
|
+
if (await commandExists("cargo")) {
|
|
2193
|
+
managers.push("cargo");
|
|
2194
|
+
}
|
|
2192
2195
|
return managers;
|
|
2193
2196
|
}
|
|
2194
2197
|
async function getPlatformInfo() {
|
|
@@ -3116,6 +3119,98 @@ class Flatpak {
|
|
|
3116
3119
|
}
|
|
3117
3120
|
}
|
|
3118
3121
|
|
|
3122
|
+
// src/lib/package-managers/cargo.ts
|
|
3123
|
+
init_runtime();
|
|
3124
|
+
init_runtime();
|
|
3125
|
+
async function runCargoCommand(args, callbacks) {
|
|
3126
|
+
const cmd = ["cargo", ...args];
|
|
3127
|
+
if (callbacks?.onLog) {
|
|
3128
|
+
const exitCode = await execStreaming(cmd, callbacks.onLog);
|
|
3129
|
+
return exitCode === 0;
|
|
3130
|
+
}
|
|
3131
|
+
const result = await exec(cmd);
|
|
3132
|
+
return result.success;
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
class Cargo {
|
|
3136
|
+
type = "cargo";
|
|
3137
|
+
displayName = "Cargo";
|
|
3138
|
+
async isAvailable() {
|
|
3139
|
+
return commandExists("cargo");
|
|
3140
|
+
}
|
|
3141
|
+
async update(callbacks) {
|
|
3142
|
+
return true;
|
|
3143
|
+
}
|
|
3144
|
+
async install(packages, callbacks) {
|
|
3145
|
+
if (packages.length === 0)
|
|
3146
|
+
return true;
|
|
3147
|
+
for (const pkg of packages) {
|
|
3148
|
+
const success = await runCargoCommand(["install", pkg], callbacks);
|
|
3149
|
+
if (!success)
|
|
3150
|
+
return false;
|
|
3151
|
+
}
|
|
3152
|
+
return true;
|
|
3153
|
+
}
|
|
3154
|
+
async uninstall(packages, callbacks) {
|
|
3155
|
+
if (packages.length === 0)
|
|
3156
|
+
return true;
|
|
3157
|
+
for (const pkg of packages) {
|
|
3158
|
+
const success = await runCargoCommand(["uninstall", pkg], callbacks);
|
|
3159
|
+
if (!success)
|
|
3160
|
+
return false;
|
|
3161
|
+
}
|
|
3162
|
+
return true;
|
|
3163
|
+
}
|
|
3164
|
+
async upgrade(packages, callbacks) {
|
|
3165
|
+
if (packages && packages.length > 0) {
|
|
3166
|
+
for (const pkg of packages) {
|
|
3167
|
+
const success = await runCargoCommand(["install", "--force", pkg], callbacks);
|
|
3168
|
+
if (!success)
|
|
3169
|
+
return false;
|
|
3170
|
+
}
|
|
3171
|
+
return true;
|
|
3172
|
+
}
|
|
3173
|
+
const installed = await this.listInstalled();
|
|
3174
|
+
for (const pkg of installed) {
|
|
3175
|
+
await runCargoCommand(["install", "--force", pkg.name], callbacks);
|
|
3176
|
+
}
|
|
3177
|
+
return true;
|
|
3178
|
+
}
|
|
3179
|
+
async listInstalled() {
|
|
3180
|
+
const result = await exec(["cargo", "install", "--list"]);
|
|
3181
|
+
if (!result.success)
|
|
3182
|
+
return [];
|
|
3183
|
+
const packages = [];
|
|
3184
|
+
const lines = result.stdout.split(`
|
|
3185
|
+
`);
|
|
3186
|
+
for (const line of lines) {
|
|
3187
|
+
const match = line.match(/^(\S+)\s+v([\d.]+(?:-[\w.]+)?)/);
|
|
3188
|
+
if (match) {
|
|
3189
|
+
packages.push({
|
|
3190
|
+
name: match[1],
|
|
3191
|
+
version: match[2]
|
|
3192
|
+
});
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
return packages;
|
|
3196
|
+
}
|
|
3197
|
+
async listOutdated() {
|
|
3198
|
+
return [];
|
|
3199
|
+
}
|
|
3200
|
+
async cleanup(callbacks) {
|
|
3201
|
+
return true;
|
|
3202
|
+
}
|
|
3203
|
+
async isInstalled(packages) {
|
|
3204
|
+
const result = new Map;
|
|
3205
|
+
const installed = await this.listInstalled();
|
|
3206
|
+
const installedSet = new Set(installed.map((p) => p.name));
|
|
3207
|
+
for (const pkg of packages) {
|
|
3208
|
+
result.set(pkg, installedSet.has(pkg));
|
|
3209
|
+
}
|
|
3210
|
+
return result;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3119
3214
|
// src/lib/package-managers/index.ts
|
|
3120
3215
|
var managerInstances = new Map;
|
|
3121
3216
|
function getPackageManager(type) {
|
|
@@ -3148,6 +3243,9 @@ function getPackageManager(type) {
|
|
|
3148
3243
|
case "flatpak":
|
|
3149
3244
|
manager = new Flatpak;
|
|
3150
3245
|
break;
|
|
3246
|
+
case "cargo":
|
|
3247
|
+
manager = new Cargo;
|
|
3248
|
+
break;
|
|
3151
3249
|
default:
|
|
3152
3250
|
throw new Error(`Unknown package manager type: ${type}`);
|
|
3153
3251
|
}
|
|
@@ -3449,6 +3547,16 @@ async function getPackageSetsForPlatform(config, platform) {
|
|
|
3449
3547
|
packages: masIds
|
|
3450
3548
|
});
|
|
3451
3549
|
}
|
|
3550
|
+
const cargo = getPackageManager("cargo");
|
|
3551
|
+
const globalCargo = config.global?.cargo || [];
|
|
3552
|
+
const macosCargo = config.macos?.cargo || [];
|
|
3553
|
+
const allMacosCargo = [...globalCargo, ...macosCargo];
|
|
3554
|
+
if (allMacosCargo.length > 0 && await cargo.isAvailable()) {
|
|
3555
|
+
sets.push({
|
|
3556
|
+
manager: cargo,
|
|
3557
|
+
packages: allMacosCargo
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3452
3560
|
} else {
|
|
3453
3561
|
const distro = platform.distro;
|
|
3454
3562
|
const globalPkgs = config.global?.packages || [];
|
|
@@ -3514,6 +3622,16 @@ async function getPackageSetsForPlatform(config, platform) {
|
|
|
3514
3622
|
packages: flatpakApps
|
|
3515
3623
|
});
|
|
3516
3624
|
}
|
|
3625
|
+
const cargo = getPackageManager("cargo");
|
|
3626
|
+
const globalCargo = config.global?.cargo || [];
|
|
3627
|
+
const linuxCargo = config.linux?.cargo || [];
|
|
3628
|
+
const allLinuxCargo = [...globalCargo, ...linuxCargo];
|
|
3629
|
+
if (allLinuxCargo.length > 0 && await cargo.isAvailable()) {
|
|
3630
|
+
sets.push({
|
|
3631
|
+
manager: cargo,
|
|
3632
|
+
packages: allLinuxCargo
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3517
3635
|
}
|
|
3518
3636
|
return sets;
|
|
3519
3637
|
}
|
package/package.json
CHANGED