@packmind/cli 0.2.12 → 0.3.2
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 +100 -18
- package/package.json +2 -1
package/main.cjs
CHANGED
|
@@ -1177,6 +1177,15 @@ var stringToProgrammingLanguage = (input) => {
|
|
|
1177
1177
|
);
|
|
1178
1178
|
};
|
|
1179
1179
|
|
|
1180
|
+
// packages/shared/src/types/linter/ActiveDetectionProgram.ts
|
|
1181
|
+
var createActiveDetectionProgramId = brandedIdFactory();
|
|
1182
|
+
|
|
1183
|
+
// packages/shared/src/types/linter/DetectionProgram.ts
|
|
1184
|
+
var createDetectionProgramId = brandedIdFactory();
|
|
1185
|
+
|
|
1186
|
+
// packages/shared/src/types/linter/RuleDetectionAssessment.ts
|
|
1187
|
+
var createRuleDetectionAssessmentId = brandedIdFactory();
|
|
1188
|
+
|
|
1180
1189
|
// packages/shared/src/mail/SmtpMailService.ts
|
|
1181
1190
|
var import_nodemailer = __toESM(require("nodemailer"));
|
|
1182
1191
|
|
|
@@ -1239,21 +1248,21 @@ var GitService = class {
|
|
|
1239
1248
|
constructor(logger = new PackmindLogger(origin6)) {
|
|
1240
1249
|
this.logger = logger;
|
|
1241
1250
|
}
|
|
1242
|
-
async getGitRepositoryRoot(
|
|
1251
|
+
async getGitRepositoryRoot(path3) {
|
|
1243
1252
|
try {
|
|
1244
1253
|
const { stdout } = await execAsync("git rev-parse --show-toplevel", {
|
|
1245
|
-
cwd:
|
|
1254
|
+
cwd: path3
|
|
1246
1255
|
});
|
|
1247
1256
|
const gitRoot = stdout.trim();
|
|
1248
1257
|
this.logger.debug("Resolved git repository root", {
|
|
1249
|
-
inputPath:
|
|
1258
|
+
inputPath: path3,
|
|
1250
1259
|
gitRoot
|
|
1251
1260
|
});
|
|
1252
1261
|
return gitRoot;
|
|
1253
1262
|
} catch (error) {
|
|
1254
1263
|
if (error instanceof Error) {
|
|
1255
1264
|
throw new Error(
|
|
1256
|
-
`Failed to get Git repository root. The path '${
|
|
1265
|
+
`Failed to get Git repository root. The path '${path3}' does not appear to be inside a Git repository.
|
|
1257
1266
|
${error.message}`
|
|
1258
1267
|
);
|
|
1259
1268
|
}
|
|
@@ -1360,14 +1369,14 @@ ${error.message}`
|
|
|
1360
1369
|
normalizeGitUrl(url) {
|
|
1361
1370
|
const sshMatch = url.match(/^git@([^:]+):(.+)$/);
|
|
1362
1371
|
if (sshMatch) {
|
|
1363
|
-
const [, host,
|
|
1364
|
-
const cleanPath =
|
|
1372
|
+
const [, host, path3] = sshMatch;
|
|
1373
|
+
const cleanPath = path3.replace(/\.git$/, "");
|
|
1365
1374
|
return `${host}/${cleanPath}`;
|
|
1366
1375
|
}
|
|
1367
1376
|
const httpsMatch = url.match(/^https?:\/\/([^/]+)\/(.+)$/);
|
|
1368
1377
|
if (httpsMatch) {
|
|
1369
|
-
const [, host,
|
|
1370
|
-
const cleanPath =
|
|
1378
|
+
const [, host, path3] = httpsMatch;
|
|
1379
|
+
const cleanPath = path3.replace(/\.git$/, "");
|
|
1371
1380
|
return `${host}/${cleanPath}`;
|
|
1372
1381
|
}
|
|
1373
1382
|
return url;
|
|
@@ -1505,6 +1514,7 @@ var ListFilesInDirectoryUseCase = class {
|
|
|
1505
1514
|
|
|
1506
1515
|
// apps/cli/src/application/useCases/LintFilesInDirectoryUseCase.ts
|
|
1507
1516
|
var import_minimatch = require("minimatch");
|
|
1517
|
+
var path2 = __toESM(require("path"));
|
|
1508
1518
|
var origin7 = "LintFilesInDirectoryUseCase";
|
|
1509
1519
|
var LintFilesInDirectoryUseCase = class {
|
|
1510
1520
|
constructor(services, repositories, logger = new PackmindLogger(origin7)) {
|
|
@@ -1565,13 +1575,28 @@ var LintFilesInDirectoryUseCase = class {
|
|
|
1565
1575
|
return pattern;
|
|
1566
1576
|
}
|
|
1567
1577
|
async execute(command2) {
|
|
1568
|
-
const {
|
|
1578
|
+
const {
|
|
1579
|
+
path: userPath,
|
|
1580
|
+
draftMode,
|
|
1581
|
+
standardSlug,
|
|
1582
|
+
ruleId,
|
|
1583
|
+
language
|
|
1584
|
+
} = command2;
|
|
1569
1585
|
this.logger.debug(
|
|
1570
|
-
`Starting linting: path="${
|
|
1586
|
+
`Starting linting: path="${userPath}", draftMode=${!!draftMode}, standardSlug="${standardSlug || "N/A"}", ruleId="${ruleId || "N/A"}", language="${language || "N/A"}"`
|
|
1587
|
+
);
|
|
1588
|
+
const gitRepoRoot = await this.services.gitRemoteUrlService.getGitRepositoryRoot(userPath);
|
|
1589
|
+
const absoluteLintPath = path2.isAbsolute(userPath) ? userPath : path2.resolve(process.cwd(), userPath);
|
|
1590
|
+
if (!absoluteLintPath.startsWith(gitRepoRoot)) {
|
|
1591
|
+
throw new Error(
|
|
1592
|
+
`The path "${absoluteLintPath}" is not within the git repository at "${gitRepoRoot}"`
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
this.logger.debug(
|
|
1596
|
+
`Resolved paths: gitRoot="${gitRepoRoot}", lintPath="${absoluteLintPath}"`
|
|
1571
1597
|
);
|
|
1572
|
-
const gitRepoRoot = await this.services.gitRemoteUrlService.getGitRepositoryRoot(path2);
|
|
1573
1598
|
const files = await this.services.listFiles.listFilesInDirectory(
|
|
1574
|
-
|
|
1599
|
+
absoluteLintPath,
|
|
1575
1600
|
[],
|
|
1576
1601
|
["node_modules", "dist", ".min.", ".map.", ".git"]
|
|
1577
1602
|
);
|
|
@@ -2059,13 +2084,27 @@ var BaseParser = class _BaseParser {
|
|
|
2059
2084
|
constructor() {
|
|
2060
2085
|
this.initialized = false;
|
|
2061
2086
|
}
|
|
2087
|
+
static {
|
|
2088
|
+
this.externalWasmDirectory = null;
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Set an external directory where WASM files are located
|
|
2092
|
+
* This is useful for CLI executables that extract WASM files at runtime
|
|
2093
|
+
*/
|
|
2094
|
+
static setWasmDirectory(directory) {
|
|
2095
|
+
_BaseParser.externalWasmDirectory = directory;
|
|
2096
|
+
}
|
|
2062
2097
|
/**
|
|
2063
2098
|
* Helper to locate tree-sitter WASM files for CLI executable
|
|
2064
2099
|
*/
|
|
2065
2100
|
static getTreeSitterWasmPaths() {
|
|
2101
|
+
const paths = [];
|
|
2102
|
+
if (_BaseParser.externalWasmDirectory) {
|
|
2103
|
+
paths.push(_BaseParser.externalWasmDirectory);
|
|
2104
|
+
}
|
|
2066
2105
|
const execDir = process.argv[0] ? (0, import_path.dirname)(process.argv[0]) : process.cwd();
|
|
2067
2106
|
const scriptDir = require.main?.filename ? (0, import_path.dirname)(require.main.filename) : process.cwd();
|
|
2068
|
-
|
|
2107
|
+
paths.push(
|
|
2069
2108
|
// Next to the main script (for npm packages like @packmind/scan)
|
|
2070
2109
|
scriptDir,
|
|
2071
2110
|
(0, import_path.join)(scriptDir, "tree-sitter"),
|
|
@@ -2077,7 +2116,8 @@ var BaseParser = class _BaseParser {
|
|
|
2077
2116
|
(0, import_path.resolve)(__dirname, "tree-sitter"),
|
|
2078
2117
|
(0, import_path.resolve)(__dirname, "../../res"),
|
|
2079
2118
|
(0, import_path.resolve)(__dirname, "../../../packages/linter-ast/res")
|
|
2080
|
-
|
|
2119
|
+
);
|
|
2120
|
+
return paths;
|
|
2081
2121
|
}
|
|
2082
2122
|
/**
|
|
2083
2123
|
* Get the locateFile function for TreeSitter Parser initialization
|
|
@@ -4021,8 +4061,8 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
4021
4061
|
args: {
|
|
4022
4062
|
path: (0, import_cmd_ts.positional)({
|
|
4023
4063
|
displayName: "path",
|
|
4024
|
-
description: "Path to lint (e.g., . for current directory)",
|
|
4025
|
-
type: import_cmd_ts.string
|
|
4064
|
+
description: "Path to lint (e.g., . for current directory. Default is current directory)",
|
|
4065
|
+
type: (0, import_cmd_ts.optional)(import_cmd_ts.string)
|
|
4026
4066
|
}),
|
|
4027
4067
|
logger: (0, import_cmd_ts.option)({
|
|
4028
4068
|
long: "logger",
|
|
@@ -4050,7 +4090,7 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
4050
4090
|
description: "Enable debug logging"
|
|
4051
4091
|
})
|
|
4052
4092
|
},
|
|
4053
|
-
handler: async ({ path:
|
|
4093
|
+
handler: async ({ path: path3, draft, rule, debug, language, logger }) => {
|
|
4054
4094
|
if (draft && !rule) {
|
|
4055
4095
|
throw new Error("option --rule is required to use --draft mode");
|
|
4056
4096
|
}
|
|
@@ -4061,7 +4101,7 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
4061
4101
|
);
|
|
4062
4102
|
const packmindCliHexa = new PackmindCliHexa(packmindLogger);
|
|
4063
4103
|
const { violations } = await packmindCliHexa.lintFilesInDirectory({
|
|
4064
|
-
path:
|
|
4104
|
+
path: path3 ?? ".",
|
|
4065
4105
|
draftMode: draft,
|
|
4066
4106
|
standardSlug: rule?.standardSlug,
|
|
4067
4107
|
ruleId: rule?.ruleId,
|
|
@@ -4078,7 +4118,49 @@ var lintCommand = (0, import_cmd_ts.command)({
|
|
|
4078
4118
|
}
|
|
4079
4119
|
});
|
|
4080
4120
|
|
|
4121
|
+
// apps/cli/src/wasm-runtime.ts
|
|
4122
|
+
var import_fs18 = require("fs");
|
|
4123
|
+
var import_path2 = require("path");
|
|
4124
|
+
var import_os = require("os");
|
|
4125
|
+
|
|
4126
|
+
// apps/cli/src/embedded-wasm.ts
|
|
4127
|
+
var EMBEDDED_WASM_FILES = {};
|
|
4128
|
+
|
|
4129
|
+
// apps/cli/src/wasm-runtime.ts
|
|
4130
|
+
var wasmExtractedDir = null;
|
|
4131
|
+
function hasEmbeddedWasmFiles() {
|
|
4132
|
+
return Object.keys(EMBEDDED_WASM_FILES).length > 0;
|
|
4133
|
+
}
|
|
4134
|
+
function extractWasmFiles() {
|
|
4135
|
+
if (wasmExtractedDir && (0, import_fs18.existsSync)(wasmExtractedDir)) {
|
|
4136
|
+
return wasmExtractedDir;
|
|
4137
|
+
}
|
|
4138
|
+
const tempDir = (0, import_path2.join)((0, import_os.tmpdir)(), `packmind-wasm-${process.pid}`);
|
|
4139
|
+
if (!(0, import_fs18.existsSync)(tempDir)) {
|
|
4140
|
+
(0, import_fs18.mkdirSync)(tempDir, { recursive: true });
|
|
4141
|
+
}
|
|
4142
|
+
for (const [filename, base64Data] of Object.entries(EMBEDDED_WASM_FILES)) {
|
|
4143
|
+
const wasmPath = (0, import_path2.join)(tempDir, filename);
|
|
4144
|
+
if ((0, import_fs18.existsSync)(wasmPath)) {
|
|
4145
|
+
continue;
|
|
4146
|
+
}
|
|
4147
|
+
const wasmBuffer = Buffer.from(base64Data, "base64");
|
|
4148
|
+
(0, import_fs18.writeFileSync)(wasmPath, wasmBuffer);
|
|
4149
|
+
}
|
|
4150
|
+
wasmExtractedDir = tempDir;
|
|
4151
|
+
process.on("exit", () => {
|
|
4152
|
+
});
|
|
4153
|
+
return tempDir;
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4081
4156
|
// apps/cli/src/main.ts
|
|
4157
|
+
if (hasEmbeddedWasmFiles()) {
|
|
4158
|
+
try {
|
|
4159
|
+
const wasmDir = extractWasmFiles();
|
|
4160
|
+
BaseParser.setWasmDirectory(wasmDir);
|
|
4161
|
+
} catch {
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4082
4164
|
var app = (0, import_cmd_ts2.subcommands)({
|
|
4083
4165
|
name: "packmind-cli",
|
|
4084
4166
|
description: "Packmind CLI tool",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@packmind/cli",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A command-line interface for Packmind linting and code quality checks",
|
|
5
5
|
"private": false,
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"main.cjs",
|
|
12
12
|
"*.wasm",
|
|
13
13
|
"stubs",
|
|
14
|
+
"CHANGELOG.MD",
|
|
14
15
|
"node_modules"
|
|
15
16
|
],
|
|
16
17
|
"keywords": [
|