@outcomeeng/spx 0.3.1 → 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/dist/cli.js +33 -19
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5004,6 +5004,8 @@ function formatSummary(options) {
|
|
|
5004
5004
|
|
|
5005
5005
|
// src/validation/steps/eslint.ts
|
|
5006
5006
|
import { spawn } from "child_process";
|
|
5007
|
+
import { existsSync as existsSync3 } from "fs";
|
|
5008
|
+
import { join as join15 } from "path";
|
|
5007
5009
|
|
|
5008
5010
|
// src/validation/types.ts
|
|
5009
5011
|
var VALIDATION_SCOPES = {
|
|
@@ -5053,7 +5055,10 @@ async function validateESLint(context, runner = defaultEslintProcessRunner) {
|
|
|
5053
5055
|
cacheFile: CACHE_PATHS.ESLINT,
|
|
5054
5056
|
configFile: eslintConfigFile
|
|
5055
5057
|
});
|
|
5056
|
-
const
|
|
5058
|
+
const localBin = join15(projectRoot, "node_modules", ".bin", "eslint");
|
|
5059
|
+
const binary = existsSync3(localBin) ? localBin : "npx";
|
|
5060
|
+
const spawnArgs = binary === "npx" ? eslintArgs : eslintArgs.slice(1);
|
|
5061
|
+
const eslintProcess = runner.spawn(binary, spawnArgs, {
|
|
5057
5062
|
cwd: projectRoot,
|
|
5058
5063
|
stdio: "inherit"
|
|
5059
5064
|
});
|
|
@@ -5082,6 +5087,8 @@ function validationEnabled(envVarKey, defaults2 = {}) {
|
|
|
5082
5087
|
|
|
5083
5088
|
// src/validation/steps/knip.ts
|
|
5084
5089
|
import { spawn as spawn2 } from "child_process";
|
|
5090
|
+
import { existsSync as existsSync4 } from "fs";
|
|
5091
|
+
import { join as join16 } from "path";
|
|
5085
5092
|
var defaultKnipProcessRunner = { spawn: spawn2 };
|
|
5086
5093
|
async function validateKnip(typescriptScope, runner = defaultKnipProcessRunner) {
|
|
5087
5094
|
try {
|
|
@@ -5090,7 +5097,9 @@ async function validateKnip(typescriptScope, runner = defaultKnipProcessRunner)
|
|
|
5090
5097
|
return { success: true };
|
|
5091
5098
|
}
|
|
5092
5099
|
return new Promise((resolve6) => {
|
|
5093
|
-
const
|
|
5100
|
+
const localBin = join16(process.cwd(), "node_modules", ".bin", "knip");
|
|
5101
|
+
const binary = existsSync4(localBin) ? localBin : "npx";
|
|
5102
|
+
const knipProcess = runner.spawn(binary, binary === "npx" ? ["knip"] : [], {
|
|
5094
5103
|
cwd: process.cwd(),
|
|
5095
5104
|
stdio: "pipe"
|
|
5096
5105
|
});
|
|
@@ -5263,8 +5272,8 @@ function formatLoc(loc) {
|
|
|
5263
5272
|
}
|
|
5264
5273
|
|
|
5265
5274
|
// src/validation/steps/markdown.ts
|
|
5266
|
-
import { existsSync as
|
|
5267
|
-
import { basename, join as
|
|
5275
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
|
|
5276
|
+
import { basename, join as join17 } from "path";
|
|
5268
5277
|
import { main as markdownlintMain } from "markdownlint-cli2";
|
|
5269
5278
|
import relativeLinksRule from "markdownlint-rule-relative-links";
|
|
5270
5279
|
var DEFAULT_DIRECTORY_NAMES = ["spx", "docs"];
|
|
@@ -5290,11 +5299,11 @@ function buildMarkdownlintConfig(directoryName) {
|
|
|
5290
5299
|
};
|
|
5291
5300
|
}
|
|
5292
5301
|
function getDefaultDirectories(projectRoot) {
|
|
5293
|
-
return DEFAULT_DIRECTORY_NAMES.map((name) =>
|
|
5302
|
+
return DEFAULT_DIRECTORY_NAMES.map((name) => join17(projectRoot, name)).filter((dir) => existsSync5(dir));
|
|
5294
5303
|
}
|
|
5295
5304
|
function getExcludeGlobs(spxDir) {
|
|
5296
|
-
const excludePath =
|
|
5297
|
-
if (!
|
|
5305
|
+
const excludePath = join17(spxDir, EXCLUDE_FILENAME);
|
|
5306
|
+
if (!existsSync5(excludePath)) {
|
|
5298
5307
|
return [];
|
|
5299
5308
|
}
|
|
5300
5309
|
const content = readFileSync2(excludePath, "utf-8");
|
|
@@ -5357,7 +5366,7 @@ async function validateDirectory(directory, config, projectRoot, ignoreGlobs = [
|
|
|
5357
5366
|
if (parsed) {
|
|
5358
5367
|
errors.push({
|
|
5359
5368
|
...parsed,
|
|
5360
|
-
file:
|
|
5369
|
+
file: join17(directory, parsed.file)
|
|
5361
5370
|
});
|
|
5362
5371
|
}
|
|
5363
5372
|
}
|
|
@@ -5402,16 +5411,16 @@ async function markdownCommand(options) {
|
|
|
5402
5411
|
|
|
5403
5412
|
// src/validation/steps/typescript.ts
|
|
5404
5413
|
import { spawn as spawn3 } from "child_process";
|
|
5405
|
-
import { existsSync as
|
|
5414
|
+
import { existsSync as existsSync6, mkdirSync, rmSync, writeFileSync } from "fs";
|
|
5406
5415
|
import { mkdtemp } from "fs/promises";
|
|
5407
5416
|
import { tmpdir } from "os";
|
|
5408
|
-
import { isAbsolute as isAbsolute3, join as
|
|
5417
|
+
import { isAbsolute as isAbsolute3, join as join18 } from "path";
|
|
5409
5418
|
var defaultTypeScriptProcessRunner = { spawn: spawn3 };
|
|
5410
5419
|
var defaultTypeScriptDeps = {
|
|
5411
5420
|
mkdtemp,
|
|
5412
5421
|
writeFileSync,
|
|
5413
5422
|
rmSync,
|
|
5414
|
-
existsSync:
|
|
5423
|
+
existsSync: existsSync6,
|
|
5415
5424
|
mkdirSync
|
|
5416
5425
|
};
|
|
5417
5426
|
function buildTypeScriptArgs(context) {
|
|
@@ -5419,19 +5428,19 @@ function buildTypeScriptArgs(context) {
|
|
|
5419
5428
|
return scope === VALIDATION_SCOPES.FULL ? ["tsc", "--noEmit"] : ["tsc", "--project", configFile];
|
|
5420
5429
|
}
|
|
5421
5430
|
async function createFileSpecificTsconfig(scope, files, deps = defaultTypeScriptDeps) {
|
|
5422
|
-
const tempDir = await deps.mkdtemp(
|
|
5423
|
-
const configPath =
|
|
5431
|
+
const tempDir = await deps.mkdtemp(join18(tmpdir(), "validate-ts-"));
|
|
5432
|
+
const configPath = join18(tempDir, "tsconfig.json");
|
|
5424
5433
|
const baseConfigFile = TSCONFIG_FILES[scope];
|
|
5425
5434
|
const projectRoot = process.cwd();
|
|
5426
|
-
const absoluteFiles = files.map((file) => isAbsolute3(file) ? file :
|
|
5435
|
+
const absoluteFiles = files.map((file) => isAbsolute3(file) ? file : join18(projectRoot, file));
|
|
5427
5436
|
const tempConfig = {
|
|
5428
|
-
extends:
|
|
5437
|
+
extends: join18(projectRoot, baseConfigFile),
|
|
5429
5438
|
files: absoluteFiles,
|
|
5430
5439
|
include: [],
|
|
5431
5440
|
exclude: [],
|
|
5432
5441
|
compilerOptions: {
|
|
5433
5442
|
noEmit: true,
|
|
5434
|
-
typeRoots: [
|
|
5443
|
+
typeRoots: [join18(projectRoot, "node_modules", "@types")],
|
|
5435
5444
|
types: ["node"]
|
|
5436
5445
|
}
|
|
5437
5446
|
};
|
|
@@ -5452,7 +5461,10 @@ async function validateTypeScript(scope, typescriptScope, files, runner = defaul
|
|
|
5452
5461
|
const { configPath, cleanup } = await createFileSpecificTsconfig(scope, files, deps);
|
|
5453
5462
|
try {
|
|
5454
5463
|
return await new Promise((resolve6) => {
|
|
5455
|
-
const
|
|
5464
|
+
const tscBin = join18(process.cwd(), "node_modules", ".bin", "tsc");
|
|
5465
|
+
const tscBinary = existsSync6(tscBin) ? tscBin : "npx";
|
|
5466
|
+
const tscArgs2 = tscBinary === "npx" ? ["tsc", "--project", configPath] : ["--project", configPath];
|
|
5467
|
+
const tscProcess = runner.spawn(tscBinary, tscArgs2, {
|
|
5456
5468
|
cwd: process.cwd(),
|
|
5457
5469
|
stdio: "inherit"
|
|
5458
5470
|
});
|
|
@@ -5475,8 +5487,10 @@ async function validateTypeScript(scope, typescriptScope, files, runner = defaul
|
|
|
5475
5487
|
return { success: false, error: `Failed to create temporary config: ${errorMessage}` };
|
|
5476
5488
|
}
|
|
5477
5489
|
} else {
|
|
5478
|
-
|
|
5479
|
-
|
|
5490
|
+
const tscBin = join18(process.cwd(), "node_modules", ".bin", "tsc");
|
|
5491
|
+
tool = existsSync6(tscBin) ? tscBin : "npx";
|
|
5492
|
+
const rawArgs = buildTypeScriptArgs({ scope, configFile });
|
|
5493
|
+
tscArgs = tool === "npx" ? rawArgs : rawArgs.slice(1);
|
|
5480
5494
|
}
|
|
5481
5495
|
return new Promise((resolve6) => {
|
|
5482
5496
|
const tscProcess = runner.spawn(tool, tscArgs, {
|