@packmind/cli 0.8.0 → 0.9.0
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/main.cjs +95 -31
- package/package.json +1 -1
package/main.cjs
CHANGED
|
@@ -3852,7 +3852,7 @@ var require_package = __commonJS({
|
|
|
3852
3852
|
"apps/cli/package.json"(exports2, module2) {
|
|
3853
3853
|
module2.exports = {
|
|
3854
3854
|
name: "@packmind/cli",
|
|
3855
|
-
version: "0.
|
|
3855
|
+
version: "0.9.0",
|
|
3856
3856
|
description: "A command-line interface for Packmind linting and code quality checks",
|
|
3857
3857
|
private: false,
|
|
3858
3858
|
bin: {
|
|
@@ -4076,7 +4076,8 @@ var RENDER_MODE_ORDER = [
|
|
|
4076
4076
|
"GH_COPILOT" /* GH_COPILOT */,
|
|
4077
4077
|
"CLAUDE" /* CLAUDE */,
|
|
4078
4078
|
"CURSOR" /* CURSOR */,
|
|
4079
|
-
"GITLAB_DUO" /* GITLAB_DUO
|
|
4079
|
+
"GITLAB_DUO" /* GITLAB_DUO */,
|
|
4080
|
+
"CONTINUE" /* CONTINUE */
|
|
4080
4081
|
];
|
|
4081
4082
|
var normalizeRenderModes = (modes) => {
|
|
4082
4083
|
const uniqueModes = new Set(modes);
|
|
@@ -10135,6 +10136,15 @@ var ConfigFileRepository = class {
|
|
|
10135
10136
|
const configContent = JSON.stringify(config, null, 2) + "\n";
|
|
10136
10137
|
await fs8.writeFile(configPath, configContent, "utf-8");
|
|
10137
10138
|
}
|
|
10139
|
+
async configExists(baseDirectory) {
|
|
10140
|
+
const configPath = path8.join(baseDirectory, this.CONFIG_FILENAME);
|
|
10141
|
+
try {
|
|
10142
|
+
await fs8.access(configPath);
|
|
10143
|
+
return true;
|
|
10144
|
+
} catch {
|
|
10145
|
+
return false;
|
|
10146
|
+
}
|
|
10147
|
+
}
|
|
10138
10148
|
async readConfig(baseDirectory) {
|
|
10139
10149
|
const configPath = path8.join(baseDirectory, this.CONFIG_FILENAME);
|
|
10140
10150
|
try {
|
|
@@ -10406,6 +10416,11 @@ var PackmindCliHexa = class {
|
|
|
10406
10416
|
async getPackageBySlug(command8) {
|
|
10407
10417
|
return this.hexa.useCases.getPackageBySlug.execute(command8);
|
|
10408
10418
|
}
|
|
10419
|
+
async configExists(baseDirectory) {
|
|
10420
|
+
return await this.hexa.repositories.configFileRepository.configExists(
|
|
10421
|
+
baseDirectory
|
|
10422
|
+
);
|
|
10423
|
+
}
|
|
10409
10424
|
async readConfig(baseDirectory) {
|
|
10410
10425
|
const config = await this.hexa.repositories.configFileRepository.readConfig(
|
|
10411
10426
|
baseDirectory
|
|
@@ -11058,10 +11073,10 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11058
11073
|
const { packagesSlugs } = args2;
|
|
11059
11074
|
const cwd = getCwd();
|
|
11060
11075
|
let configPackages;
|
|
11061
|
-
let
|
|
11076
|
+
let configFileExists = false;
|
|
11062
11077
|
try {
|
|
11078
|
+
configFileExists = await packmindCliHexa.configExists(cwd);
|
|
11063
11079
|
configPackages = await packmindCliHexa.readConfig(cwd);
|
|
11064
|
-
configExists = configPackages.length > 0;
|
|
11065
11080
|
} catch (err) {
|
|
11066
11081
|
error("ERROR Failed to parse packmind.json");
|
|
11067
11082
|
if (err instanceof Error) {
|
|
@@ -11080,7 +11095,13 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11080
11095
|
}
|
|
11081
11096
|
const allPackages = [.../* @__PURE__ */ new Set([...configPackages, ...packagesSlugs])];
|
|
11082
11097
|
if (allPackages.length === 0) {
|
|
11083
|
-
|
|
11098
|
+
if (configFileExists) {
|
|
11099
|
+
logWarningConsole(
|
|
11100
|
+
"config packmind.json is empty, no packages to install"
|
|
11101
|
+
);
|
|
11102
|
+
} else {
|
|
11103
|
+
logWarningConsole("config packmind.json not found");
|
|
11104
|
+
}
|
|
11084
11105
|
log("Usage: packmind-cli install <package-slug> [package-slug...]");
|
|
11085
11106
|
log(" packmind-cli install --list");
|
|
11086
11107
|
log("");
|
|
@@ -11098,7 +11119,7 @@ async function installPackagesHandler(args2, deps) {
|
|
|
11098
11119
|
notificationSent: false
|
|
11099
11120
|
};
|
|
11100
11121
|
}
|
|
11101
|
-
if (!
|
|
11122
|
+
if (!configFileExists && packagesSlugs.length > 0) {
|
|
11102
11123
|
log("INFO initializing packmind.json");
|
|
11103
11124
|
}
|
|
11104
11125
|
try {
|
|
@@ -11169,9 +11190,15 @@ added ${result.filesCreated} files, changed ${result.filesUpdated} files, remove
|
|
|
11169
11190
|
error("\n\u274C Failed to install content:");
|
|
11170
11191
|
if (err instanceof Error) {
|
|
11171
11192
|
const errorObj = err;
|
|
11172
|
-
if (errorObj.statusCode ===
|
|
11193
|
+
if (errorObj.statusCode === 400) {
|
|
11173
11194
|
error(` ${errorObj.message}`);
|
|
11174
|
-
|
|
11195
|
+
error("\n\u{1F4A1} This is a validation error. Please check:");
|
|
11196
|
+
error(" - The command syntax is correct");
|
|
11197
|
+
error(" - You have provided at least one package slug");
|
|
11198
|
+
error(" - Your packmind.json file contains valid package slugs");
|
|
11199
|
+
} else if (errorObj.statusCode === 404) {
|
|
11200
|
+
error(` ${errorObj.message}`);
|
|
11201
|
+
if (configFileExists && configPackages.length > 0) {
|
|
11175
11202
|
const missingPackages = allPackages.filter(
|
|
11176
11203
|
(pkg) => configPackages.includes(pkg)
|
|
11177
11204
|
);
|
|
@@ -11246,7 +11273,9 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11246
11273
|
};
|
|
11247
11274
|
}
|
|
11248
11275
|
let configPackages;
|
|
11276
|
+
let configFileExists = false;
|
|
11249
11277
|
try {
|
|
11278
|
+
configFileExists = await packmindCliHexa.configExists(cwd);
|
|
11250
11279
|
configPackages = await packmindCliHexa.readConfig(cwd);
|
|
11251
11280
|
} catch (err) {
|
|
11252
11281
|
error("\u274C Failed to read packmind.json");
|
|
@@ -11263,7 +11292,11 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11263
11292
|
};
|
|
11264
11293
|
}
|
|
11265
11294
|
if (configPackages.length === 0) {
|
|
11266
|
-
|
|
11295
|
+
if (configFileExists) {
|
|
11296
|
+
error("\u274C packmind.json is empty.");
|
|
11297
|
+
} else {
|
|
11298
|
+
error("\u274C No packmind.json found in current directory.");
|
|
11299
|
+
}
|
|
11267
11300
|
log("");
|
|
11268
11301
|
log("\u{1F4A1} There are no packages to uninstall.");
|
|
11269
11302
|
log(" To install packages, run: packmind-cli install <package-slug>");
|
|
@@ -11306,28 +11339,59 @@ async function uninstallPackagesHandler(args2, deps) {
|
|
|
11306
11339
|
const remainingPackages = configPackages.filter(
|
|
11307
11340
|
(pkg) => !packagesToUninstall.includes(pkg)
|
|
11308
11341
|
);
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11342
|
+
let filesDeleted = 0;
|
|
11343
|
+
if (remainingPackages.length === 0) {
|
|
11344
|
+
log("Removing all packages and cleaning up .packmind directory...");
|
|
11345
|
+
const packmindDir = `${cwd}/.packmind`;
|
|
11346
|
+
try {
|
|
11347
|
+
const fs12 = await import("fs/promises");
|
|
11348
|
+
const dirExists = await fs12.access(packmindDir).then(() => true).catch(() => false);
|
|
11349
|
+
if (dirExists) {
|
|
11350
|
+
const files = await fs12.readdir(packmindDir, { recursive: true });
|
|
11351
|
+
filesDeleted = files.filter(
|
|
11352
|
+
(f) => typeof f === "string" ? !f.endsWith("/") : true
|
|
11353
|
+
).length;
|
|
11354
|
+
await fs12.rm(packmindDir, { recursive: true, force: true });
|
|
11355
|
+
}
|
|
11356
|
+
const agentsMdPath = `${cwd}/AGENTS.md`;
|
|
11357
|
+
const agentsMdExists = await fs12.access(agentsMdPath).then(() => true).catch(() => false);
|
|
11358
|
+
if (agentsMdExists) {
|
|
11359
|
+
await fs12.unlink(agentsMdPath);
|
|
11360
|
+
filesDeleted++;
|
|
11361
|
+
}
|
|
11362
|
+
} catch (err) {
|
|
11363
|
+
error("\n\u26A0\uFE0F Warning: Failed to clean up some files:");
|
|
11364
|
+
if (err instanceof Error) {
|
|
11365
|
+
error(` ${err.message}`);
|
|
11366
|
+
}
|
|
11367
|
+
}
|
|
11368
|
+
log(`
|
|
11369
|
+
removed ${filesDeleted} files`);
|
|
11370
|
+
} else {
|
|
11371
|
+
const result = await packmindCliHexa.installPackages({
|
|
11372
|
+
baseDirectory: cwd,
|
|
11373
|
+
packagesSlugs: remainingPackages,
|
|
11374
|
+
previousPackagesSlugs: configPackages
|
|
11325
11375
|
});
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
}
|
|
11376
|
+
if (result.recipesCount > 0 || result.standardsCount > 0) {
|
|
11377
|
+
log(
|
|
11378
|
+
`Removing ${result.recipesCount} recipes and ${result.standardsCount} standards...`
|
|
11379
|
+
);
|
|
11380
|
+
}
|
|
11381
|
+
log(`
|
|
11382
|
+
removed ${result.filesDeleted} files`);
|
|
11383
|
+
if (result.errors.length > 0) {
|
|
11384
|
+
log("\n\u26A0\uFE0F Errors encountered:");
|
|
11385
|
+
result.errors.forEach((err) => {
|
|
11386
|
+
log(` - ${err}`);
|
|
11387
|
+
});
|
|
11388
|
+
exit(1);
|
|
11389
|
+
return {
|
|
11390
|
+
filesDeleted: result.filesDeleted,
|
|
11391
|
+
packagesUninstalled: packagesToUninstall
|
|
11392
|
+
};
|
|
11393
|
+
}
|
|
11394
|
+
filesDeleted = result.filesDeleted;
|
|
11331
11395
|
}
|
|
11332
11396
|
await packmindCliHexa.writeConfig(cwd, remainingPackages);
|
|
11333
11397
|
log("");
|
|
@@ -11342,7 +11406,7 @@ removed ${result.filesDeleted} files`);
|
|
|
11342
11406
|
log(" Your packmind.json still exists but contains no packages.");
|
|
11343
11407
|
}
|
|
11344
11408
|
return {
|
|
11345
|
-
filesDeleted
|
|
11409
|
+
filesDeleted,
|
|
11346
11410
|
packagesUninstalled: packagesToUninstall
|
|
11347
11411
|
};
|
|
11348
11412
|
} catch (err) {
|