prodex 1.4.11 → 2.0.1
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/LICENSE +20 -20
- package/README.md +240 -234
- package/bin/prodex.js +0 -0
- package/dist/app/execute-run.d.ts +2 -0
- package/dist/app/execute-run.js +74 -0
- package/dist/app/project-context.d.ts +12 -0
- package/dist/app/project-context.js +48 -0
- package/dist/app/run-plans.d.ts +11 -0
- package/dist/app/run-plans.js +61 -0
- package/dist/cache/cache-keys.d.ts +9 -0
- package/dist/cache/cache-manager.d.ts +9 -0
- package/dist/{core/managers/cache.js → cache/cache-manager.js} +5 -18
- package/dist/cli/cli-input.d.ts +2 -0
- package/dist/cli/cli-input.js +138 -124
- package/dist/cli/flag-specs.d.ts +12 -0
- package/dist/cli/flag-specs.js +28 -0
- package/dist/cli/help.d.ts +2 -0
- package/dist/cli/help.js +83 -0
- package/dist/cli/report-command.d.ts +2 -0
- package/dist/cli/report-command.js +101 -0
- package/dist/cli/reporter.d.ts +2 -0
- package/dist/cli/reporter.js +8 -0
- package/dist/commands/init-command.d.ts +1 -0
- package/dist/commands/init-command.js +9 -0
- package/dist/commands/migrate-command.d.ts +7 -0
- package/dist/commands/migrate-command.js +76 -0
- package/dist/commands/profiles-command.d.ts +6 -0
- package/dist/commands/profiles-command.js +16 -0
- package/dist/commands/run-command.d.ts +11 -0
- package/dist/commands/run-command.js +17 -0
- package/dist/config/build-config.d.ts +13 -0
- package/dist/config/build-config.js +127 -0
- package/dist/config/create-default-config.d.ts +9 -0
- package/dist/config/create-default-config.js +25 -0
- package/dist/config/default-config.d.ts +2 -0
- package/dist/config/default-config.js +23 -0
- package/dist/config/json.d.ts +2 -0
- package/dist/config/json.js +10 -0
- package/dist/config/load.d.ts +9 -0
- package/dist/config/load.js +48 -0
- package/dist/config/migration/detect.d.ts +4 -0
- package/dist/config/migration/detect.js +22 -0
- package/dist/config/migration/index.d.ts +4 -0
- package/dist/{shared → config/migration}/index.js +4 -3
- package/dist/config/migration/messages.d.ts +2 -0
- package/dist/config/migration/messages.js +35 -0
- package/dist/config/migration/transform.d.ts +2 -0
- package/dist/config/migration/transform.js +80 -0
- package/dist/config/migration/types.d.ts +16 -0
- package/dist/config/string-list.d.ts +2 -0
- package/dist/config/string-list.js +17 -0
- package/dist/diagnostics/logger.d.ts +3 -0
- package/dist/diagnostics/logger.js +33 -0
- package/dist/filesystem/glob-scan.d.ts +4 -0
- package/dist/filesystem/glob-scan.js +26 -0
- package/dist/filesystem/inspect.d.ts +1 -0
- package/dist/filesystem/inspect.js +15 -0
- package/dist/filesystem/path.d.ts +2 -0
- package/dist/filesystem/path.js +11 -0
- package/dist/filesystem/read-file.d.ts +8 -0
- package/dist/{shared/io.js → filesystem/read-file.js} +0 -25
- package/dist/filesystem/stat-cache.d.ts +1 -0
- package/dist/filesystem/stat-cache.js +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +76 -83
- package/dist/output/markdown.d.ts +12 -0
- package/dist/output/markdown.js +150 -0
- package/dist/output/naming.d.ts +2 -0
- package/dist/output/naming.js +30 -0
- package/dist/output/produce-output.d.ts +2 -0
- package/dist/output/produce-output.js +35 -0
- package/dist/output/render-constants.d.ts +21 -0
- package/dist/{constants → output}/render-constants.js +2 -1
- package/dist/output/text.d.ts +2 -0
- package/dist/output/text.js +14 -0
- package/dist/resolvers/js/extract-imports.d.ts +1 -0
- package/dist/resolvers/js/js-resolver.d.ts +2 -0
- package/dist/resolvers/js/js-resolver.js +45 -89
- package/dist/resolvers/js/resolve-alias.d.ts +2 -0
- package/dist/resolvers/js/resolve-alias.js +12 -20
- package/dist/resolvers/php/bindings.d.ts +8 -0
- package/dist/resolvers/php/bindings.js +8 -9
- package/dist/resolvers/php/extract-imports.d.ts +13 -0
- package/dist/resolvers/php/extract-imports.js +1 -1
- package/dist/resolvers/php/php-resolver.d.ts +2 -0
- package/dist/resolvers/php/php-resolver.js +61 -90
- package/dist/resolvers/php/psr4.d.ts +5 -0
- package/dist/resolvers/php/psr4.js +7 -7
- package/dist/resolvers/resolver-constants.d.ts +4 -0
- package/dist/resolvers/resolver-constants.js +7 -0
- package/dist/resolvers/resolver-result.d.ts +5 -0
- package/dist/resolvers/resolver-result.js +18 -0
- package/dist/tracing/exclude.d.ts +6 -0
- package/dist/{shared/patterns.js → tracing/exclude.js} +4 -4
- package/dist/tracing/follow-chain.d.ts +5 -0
- package/dist/tracing/follow-chain.js +63 -0
- package/dist/tracing/include-files.d.ts +2 -0
- package/dist/tracing/include-files.js +36 -0
- package/dist/tracing/resolver-registry.d.ts +5 -0
- package/dist/tracing/resolver-registry.js +20 -0
- package/dist/tracing/trace-run.d.ts +2 -0
- package/dist/tracing/trace-run.js +21 -0
- package/dist/tracing/trace-stats.d.ts +4 -0
- package/dist/tracing/trace-stats.js +16 -0
- package/dist/types/app.types.d.ts +62 -0
- package/dist/types/app.types.js +2 -0
- package/dist/types/cli.types.d.ts +22 -0
- package/dist/types/cli.types.js +0 -10
- package/dist/types/config.types.d.ts +34 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +3 -1
- package/dist/types/output.types.d.ts +6 -0
- package/dist/types/output.types.js +2 -0
- package/dist/types/resolver.types.d.ts +23 -0
- package/dist/types/tracing.types.d.ts +23 -0
- package/dist/types/tracing.types.js +2 -0
- package/dist/types/utils.types.d.ts +10 -0
- package/package.json +35 -12
- package/schema/prodex.schema.json +122 -0
- package/dist/cli/init.js +0 -21
- package/dist/cli/picker.js +0 -83
- package/dist/cli/summary.js +0 -32
- package/dist/constants/config.js +0 -27
- package/dist/constants/default-config.js +0 -43
- package/dist/constants/flags.js +0 -79
- package/dist/constants/index.js +0 -20
- package/dist/core/combine.js +0 -56
- package/dist/core/dependency.js +0 -98
- package/dist/core/helpers.js +0 -85
- package/dist/core/managers/config.js +0 -140
- package/dist/core/output.js +0 -49
- package/dist/core/renderers.js +0 -210
- package/dist/debug.js +0 -15
- package/dist/lib/logger.js +0 -42
- package/dist/lib/polyfills.js +0 -17
- package/dist/lib/prompt.js +0 -34
- package/dist/lib/questions.js +0 -28
- package/dist/lib/utils.js +0 -46
- package/dist/shared/collections.js +0 -33
- package/dist/store.js +0 -15
- /package/dist/{constants → cache}/cache-keys.js +0 -0
- /package/dist/{types/core.types.js → config/migration/types.js} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateConfig = migrateConfig;
|
|
4
|
+
const default_config_1 = require("../default-config");
|
|
5
|
+
const detect_1 = require("./detect");
|
|
6
|
+
const string_list_1 = require("../string-list");
|
|
7
|
+
function migrateConfig(input) {
|
|
8
|
+
if (!(0, detect_1.requiresConfigMigration)(input)) {
|
|
9
|
+
return {
|
|
10
|
+
needed: false,
|
|
11
|
+
fromVersion: typeof input?.version === "number" ? input.version : undefined,
|
|
12
|
+
toVersion: detect_1.REQUIRED_CONFIG_VERSION,
|
|
13
|
+
changes: [],
|
|
14
|
+
config: input,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const changes = [];
|
|
18
|
+
const output = {
|
|
19
|
+
...default_config_1.DEFAULT_PRODEX_CONFIG.output,
|
|
20
|
+
...(input.output ?? {}),
|
|
21
|
+
};
|
|
22
|
+
delete output.prefix;
|
|
23
|
+
if (input.output?.prefix !== undefined) {
|
|
24
|
+
changes.push("output.prefix removed; use --name or profile.name when you need to override the profile key.");
|
|
25
|
+
}
|
|
26
|
+
const resolve = {
|
|
27
|
+
aliases: input.resolve?.aliases ?? default_config_1.DEFAULT_PRODEX_CONFIG.resolve.aliases,
|
|
28
|
+
maxDepth: input.resolve?.maxDepth ?? input.resolve?.depth ?? default_config_1.DEFAULT_PRODEX_CONFIG.resolve.maxDepth,
|
|
29
|
+
maxFiles: input.resolve?.maxFiles ?? input.resolve?.limit ?? default_config_1.DEFAULT_PRODEX_CONFIG.resolve.maxFiles,
|
|
30
|
+
};
|
|
31
|
+
const config = {
|
|
32
|
+
version: detect_1.REQUIRED_CONFIG_VERSION,
|
|
33
|
+
$schema: input.$schema ?? default_config_1.DEFAULT_PRODEX_CONFIG.$schema,
|
|
34
|
+
output,
|
|
35
|
+
entry: (0, string_list_1.toStringList)(input.entry?.files ?? input.entry),
|
|
36
|
+
include: (0, string_list_1.toStringList)(input.include ?? input.resolve?.include),
|
|
37
|
+
exclude: (0, string_list_1.toStringList)(input.exclude ?? input.resolve?.exclude ?? default_config_1.DEFAULT_PRODEX_CONFIG.exclude),
|
|
38
|
+
resolve,
|
|
39
|
+
profiles: migrateProfiles(input.profiles ?? input.shortcuts ?? {}, changes),
|
|
40
|
+
};
|
|
41
|
+
if (input.entry?.files !== undefined)
|
|
42
|
+
changes.push("entry.files -> entry");
|
|
43
|
+
if (input.resolve?.include !== undefined)
|
|
44
|
+
changes.push("resolve.include -> include");
|
|
45
|
+
if (input.resolve?.exclude !== undefined)
|
|
46
|
+
changes.push("resolve.exclude -> exclude");
|
|
47
|
+
if (input.resolve?.depth !== undefined)
|
|
48
|
+
changes.push("resolve.depth -> resolve.maxDepth");
|
|
49
|
+
if (input.resolve?.limit !== undefined)
|
|
50
|
+
changes.push("resolve.limit -> resolve.maxFiles");
|
|
51
|
+
if (input.shortcuts !== undefined)
|
|
52
|
+
changes.push("shortcuts -> profiles");
|
|
53
|
+
return {
|
|
54
|
+
needed: true,
|
|
55
|
+
fromVersion: typeof input?.version === "number" ? input.version : undefined,
|
|
56
|
+
toVersion: detect_1.REQUIRED_CONFIG_VERSION,
|
|
57
|
+
changes: unique(changes),
|
|
58
|
+
config,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function migrateProfiles(input, changes) {
|
|
62
|
+
const profiles = {};
|
|
63
|
+
for (const [key, value] of Object.entries(input || {})) {
|
|
64
|
+
profiles[key] = {
|
|
65
|
+
...(value?.prefix ? { name: value.prefix } : {}),
|
|
66
|
+
...(value?.name ? { name: value.name } : {}),
|
|
67
|
+
...(value?.files || value?.entry ? { entry: (0, string_list_1.toStringList)(value.entry ?? value.files) } : {}),
|
|
68
|
+
...(value?.include ? { include: (0, string_list_1.toStringList)(value.include) } : {}),
|
|
69
|
+
...(value?.exclude ? { exclude: (0, string_list_1.toStringList)(value.exclude) } : {}),
|
|
70
|
+
};
|
|
71
|
+
if (value?.prefix !== undefined)
|
|
72
|
+
changes.push("shortcuts.*.prefix -> profiles.*.name");
|
|
73
|
+
if (value?.files !== undefined)
|
|
74
|
+
changes.push("shortcuts.*.files -> profiles.*.entry");
|
|
75
|
+
}
|
|
76
|
+
return profiles;
|
|
77
|
+
}
|
|
78
|
+
function unique(items) {
|
|
79
|
+
return [...new Set(items)];
|
|
80
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProdexConfigFile } from "../../types";
|
|
2
|
+
export interface MigrationPreview {
|
|
3
|
+
needed: boolean;
|
|
4
|
+
fromVersion?: number;
|
|
5
|
+
toVersion: number;
|
|
6
|
+
changes: string[];
|
|
7
|
+
config?: ProdexConfigFile;
|
|
8
|
+
}
|
|
9
|
+
export interface MigrationCommandResult extends MigrationPreview {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
written: boolean;
|
|
12
|
+
backupPath?: string;
|
|
13
|
+
path: string;
|
|
14
|
+
warnings: string[];
|
|
15
|
+
errors: string[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toStringList = toStringList;
|
|
4
|
+
exports.splitStringList = splitStringList;
|
|
5
|
+
function toStringList(value) {
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return value
|
|
8
|
+
.map((item) => (typeof item === "string" ? item.trim() : ""))
|
|
9
|
+
.filter(Boolean);
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === "string")
|
|
12
|
+
return splitStringList(value);
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
function splitStringList(value) {
|
|
16
|
+
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logger = void 0;
|
|
4
|
+
exports.setLoggerOptions = setLoggerOptions;
|
|
5
|
+
let DEBUG = false;
|
|
6
|
+
let SILENT = false;
|
|
7
|
+
function setLoggerOptions(flags = {}) {
|
|
8
|
+
DEBUG = !!flags.debug;
|
|
9
|
+
SILENT = !!flags.silent;
|
|
10
|
+
}
|
|
11
|
+
exports.logger = {
|
|
12
|
+
debug: (...args) => {
|
|
13
|
+
if (DEBUG && !SILENT)
|
|
14
|
+
console.log("\n[debug]", ...args);
|
|
15
|
+
},
|
|
16
|
+
info: (...args) => {
|
|
17
|
+
if (!SILENT)
|
|
18
|
+
console.log("\n[info]", ...args);
|
|
19
|
+
},
|
|
20
|
+
warn: (...args) => {
|
|
21
|
+
if (!SILENT)
|
|
22
|
+
console.warn("\n[warn]", ...args);
|
|
23
|
+
},
|
|
24
|
+
error: (...args) => {
|
|
25
|
+
if (!SILENT)
|
|
26
|
+
console.error("\n[error]", ...args);
|
|
27
|
+
},
|
|
28
|
+
log: (...args) => {
|
|
29
|
+
if (!SILENT)
|
|
30
|
+
console.log("\n", ...args);
|
|
31
|
+
},
|
|
32
|
+
clear: () => console.clear(),
|
|
33
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.globScan = globScan;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
9
|
+
const logger_1 = require("../diagnostics/logger");
|
|
10
|
+
const inspect_1 = require("./inspect");
|
|
11
|
+
const GLOBAL_IGNORE = ["**/node_modules/**", "**/vendor/**", "**/dist/**"];
|
|
12
|
+
async function globScan(patterns, opts) {
|
|
13
|
+
const { absolute = true, cwd = process.cwd() } = opts;
|
|
14
|
+
if (!patterns?.length)
|
|
15
|
+
return { files: [] };
|
|
16
|
+
const files = (await (0, fast_glob_1.default)(patterns, {
|
|
17
|
+
cwd,
|
|
18
|
+
extglob: true,
|
|
19
|
+
dot: true,
|
|
20
|
+
onlyFiles: true,
|
|
21
|
+
ignore: GLOBAL_IGNORE,
|
|
22
|
+
absolute,
|
|
23
|
+
})).map((file) => path_1.default.resolve(file));
|
|
24
|
+
logger_1.logger.debug("globScan ->", (0, inspect_1.inspectValue)(files));
|
|
25
|
+
return { files };
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function inspectValue(value: unknown): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.inspectValue = inspectValue;
|
|
7
|
+
const util_1 = __importDefault(require("util"));
|
|
8
|
+
function inspectValue(value) {
|
|
9
|
+
return util_1.default.inspect(value, {
|
|
10
|
+
colors: true,
|
|
11
|
+
depth: null,
|
|
12
|
+
breakLength: 150,
|
|
13
|
+
compact: 3,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePath = normalizePath;
|
|
4
|
+
exports.sanitizeFileName = sanitizeFileName;
|
|
5
|
+
function normalizePath(value) {
|
|
6
|
+
return value.replace(/\\/g, "/");
|
|
7
|
+
}
|
|
8
|
+
function sanitizeFileName(value, fallback = "combined") {
|
|
9
|
+
const cleaned = value.trim().replace(/[<>:"/\\|?*]+/g, "_");
|
|
10
|
+
return cleaned || fallback;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a file safely. Returns "" if the file cannot be read.
|
|
3
|
+
*/
|
|
4
|
+
export declare function readFileSafe(p: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Return a path relative to a root, normalized for forward slashes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rel(p: string, root?: string): string;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// File: src/shared/io.ts
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.readFileSafe = readFileSafe;
|
|
8
|
-
exports.safeStatCached = safeStatCached;
|
|
9
7
|
exports.rel = rel;
|
|
10
|
-
const cache_1 = require("../core/managers/cache");
|
|
11
8
|
const path_1 = __importDefault(require("path"));
|
|
12
9
|
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
14
10
|
/**
|
|
15
11
|
* Read a file safely. Returns "" if the file cannot be read.
|
|
16
12
|
*/
|
|
@@ -22,30 +18,9 @@ function readFileSafe(p) {
|
|
|
22
18
|
return "";
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Cached version of fs.stat().
|
|
27
|
-
* Takes a cache namespace to preserve behavior across resolvers.
|
|
28
|
-
*/
|
|
29
|
-
async function safeStatCached(ns, p) {
|
|
30
|
-
const cached = cache_1.CacheManager.get(ns, p);
|
|
31
|
-
if (cached !== undefined)
|
|
32
|
-
return cached;
|
|
33
|
-
try {
|
|
34
|
-
const st = await promises_1.default.stat(p);
|
|
35
|
-
cache_1.CacheManager.set(ns, p, st);
|
|
36
|
-
return st;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
cache_1.CacheManager.set(ns, p, null);
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
21
|
/**
|
|
44
22
|
* Return a path relative to a root, normalized for forward slashes.
|
|
45
23
|
*/
|
|
46
24
|
function rel(p, root = process.cwd()) {
|
|
47
25
|
return path_1.default.relative(root, p).replaceAll("\\", "/");
|
|
48
26
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Get a root-relative version of a path.
|
|
51
|
-
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeStatCached(namespace: string, filePath: string): Promise<import("fs").Stats | null>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.safeStatCached = safeStatCached;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const cache_manager_1 = require("../cache/cache-manager");
|
|
9
|
+
async function safeStatCached(namespace, filePath) {
|
|
10
|
+
const cached = cache_manager_1.CacheManager.get(namespace, filePath);
|
|
11
|
+
if (cached !== undefined)
|
|
12
|
+
return cached;
|
|
13
|
+
try {
|
|
14
|
+
const stats = await promises_1.default.stat(filePath);
|
|
15
|
+
cache_manager_1.CacheManager.set(namespace, filePath, stats);
|
|
16
|
+
return stats;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
cache_manager_1.CacheManager.set(namespace, filePath, null);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,94 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.default = startProdex;
|
|
37
|
-
|
|
4
|
+
exports.runProdexCommand = runProdexCommand;
|
|
5
|
+
const init_command_1 = require("./commands/init-command");
|
|
6
|
+
const migrate_command_1 = require("./commands/migrate-command");
|
|
7
|
+
const profiles_command_1 = require("./commands/profiles-command");
|
|
8
|
+
const run_command_1 = require("./commands/run-command");
|
|
38
9
|
const cli_input_1 = require("./cli/cli-input");
|
|
39
|
-
const
|
|
40
|
-
const store_1 = require("./store");
|
|
41
|
-
const combine_1 = require("./core/combine");
|
|
10
|
+
const reporter_1 = require("./cli/reporter");
|
|
42
11
|
async function startProdex(args = process.argv) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
12
|
+
const result = await runProdexCommand(args, process.cwd());
|
|
13
|
+
(0, reporter_1.reportCommandResult)(result);
|
|
14
|
+
process.exitCode = result.exitCode;
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
async function runProdexCommand(args = process.argv, cwd = process.cwd()) {
|
|
18
|
+
const parsed = (0, cli_input_1.parseCliInput)(args);
|
|
19
|
+
const warnings = [...parsed.warnings];
|
|
20
|
+
const errors = [...parsed.errors];
|
|
21
|
+
if (errors.length || !parsed.command) {
|
|
22
|
+
return { ok: false, exitCode: 1, warnings, errors, runs: [] };
|
|
51
23
|
}
|
|
52
|
-
|
|
53
|
-
|
|
24
|
+
if (parsed.command.kind === "help") {
|
|
25
|
+
return { ok: true, exitCode: 0, message: (0, reporter_1.renderHelp)(parsed.command.topic), warnings, errors, runs: [] };
|
|
54
26
|
}
|
|
55
|
-
|
|
56
|
-
|
|
27
|
+
if (parsed.command.kind === "version") {
|
|
28
|
+
return { ok: true, exitCode: 0, message: (0, reporter_1.renderVersion)(), warnings, errors, runs: [] };
|
|
57
29
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
30
|
+
if (parsed.command.kind === "init") {
|
|
31
|
+
const init = (0, init_command_1.initCommand)(parsed.command.rootArg, cwd, parsed.command.force);
|
|
32
|
+
return {
|
|
33
|
+
ok: init.ok,
|
|
34
|
+
exitCode: init.ok ? 0 : 1,
|
|
35
|
+
message: init.message,
|
|
36
|
+
warnings,
|
|
37
|
+
errors: init.error ? [...errors, init.error] : errors,
|
|
38
|
+
runs: [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (parsed.command.kind === "profiles") {
|
|
42
|
+
const listed = (0, profiles_command_1.profilesCommand)(parsed.command.rootArg, cwd);
|
|
43
|
+
warnings.push(...listed.warnings);
|
|
44
|
+
errors.push(...listed.errors);
|
|
45
|
+
return {
|
|
46
|
+
ok: !errors.length,
|
|
47
|
+
exitCode: errors.length ? 1 : 0,
|
|
48
|
+
profiles: errors.length ? undefined : listed.profiles,
|
|
49
|
+
warnings,
|
|
50
|
+
errors,
|
|
51
|
+
runs: [],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (parsed.command.kind === "migrate") {
|
|
55
|
+
const migration = (0, migrate_command_1.migrateCommand)({
|
|
56
|
+
rootArg: parsed.command.rootArg,
|
|
57
|
+
cwd,
|
|
58
|
+
write: parsed.command.write,
|
|
59
|
+
check: parsed.command.check,
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
ok: migration.ok,
|
|
63
|
+
exitCode: migration.ok ? 0 : 1,
|
|
64
|
+
migration,
|
|
65
|
+
warnings: [...warnings, ...migration.warnings],
|
|
66
|
+
errors: [...errors, ...migration.errors],
|
|
67
|
+
runs: [],
|
|
68
|
+
};
|
|
79
69
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
const run = await (0, run_command_1.runCommand)({
|
|
71
|
+
rootArg: parsed.command.rootArg,
|
|
72
|
+
flags: parsed.command.flags,
|
|
73
|
+
cwd,
|
|
74
|
+
});
|
|
75
|
+
warnings.push(...run.warnings);
|
|
76
|
+
errors.push(...run.errors);
|
|
77
|
+
if (errors.length)
|
|
78
|
+
return { ok: false, exitCode: 1, warnings, errors, runs: [] };
|
|
79
|
+
const ok = run.runs.every((item) => item.ok);
|
|
80
|
+
return {
|
|
81
|
+
ok,
|
|
82
|
+
exitCode: ok ? 0 : 1,
|
|
83
|
+
warnings,
|
|
84
|
+
errors,
|
|
85
|
+
runs: run.runs,
|
|
92
86
|
};
|
|
93
|
-
await (0, combine_1.runCombine)({ cfg: config, opts });
|
|
94
87
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MdTraceEntry {
|
|
2
|
+
file: string;
|
|
3
|
+
anchor: number;
|
|
4
|
+
startLine: number;
|
|
5
|
+
endLine: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function renderTraceMd(files: string[], root?: string): {
|
|
8
|
+
content: string;
|
|
9
|
+
trace: MdTraceEntry[];
|
|
10
|
+
listingStart: number;
|
|
11
|
+
listingEnd: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderTraceMd = renderTraceMd;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const render_constants_1 = require("./render-constants");
|
|
9
|
+
const read_file_1 = require("../filesystem/read-file");
|
|
10
|
+
function renderTraceMd(files, root = process.cwd()) {
|
|
11
|
+
const sections = files.map((file, index) => renderMdSection(file, index, root));
|
|
12
|
+
const firstPassToc = buildToc({
|
|
13
|
+
files,
|
|
14
|
+
root,
|
|
15
|
+
count: files.length,
|
|
16
|
+
listingStart: 0,
|
|
17
|
+
listingEnd: 0,
|
|
18
|
+
trace: null,
|
|
19
|
+
withRanges: false,
|
|
20
|
+
});
|
|
21
|
+
const firstPassContent = [firstPassToc, ...sections, render_constants_1.MD_FOOTER].join("\n");
|
|
22
|
+
const firstPassAnalysis = analyzeTrace(firstPassContent, files.length);
|
|
23
|
+
const finalToc = buildToc({
|
|
24
|
+
files,
|
|
25
|
+
root,
|
|
26
|
+
count: files.length,
|
|
27
|
+
listingStart: firstPassAnalysis.listingStart,
|
|
28
|
+
listingEnd: firstPassAnalysis.listingEnd,
|
|
29
|
+
trace: firstPassAnalysis.trace,
|
|
30
|
+
withRanges: true,
|
|
31
|
+
});
|
|
32
|
+
const content = [finalToc, ...sections, render_constants_1.MD_FOOTER].join("\n");
|
|
33
|
+
const analysis = analyzeTrace(content, files.length);
|
|
34
|
+
return {
|
|
35
|
+
content,
|
|
36
|
+
trace: analysis.trace,
|
|
37
|
+
listingStart: analysis.listingStart,
|
|
38
|
+
listingEnd: analysis.listingEnd,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function buildToc(opts) {
|
|
42
|
+
const indexRange = opts.withRanges && opts.listingStart && opts.listingEnd
|
|
43
|
+
? `L${opts.listingStart}-L${opts.listingEnd}`
|
|
44
|
+
: render_constants_1.INDEX_RANGE_PLACEHOLDER;
|
|
45
|
+
const items = opts.files.map((file, index) => {
|
|
46
|
+
const relativePath = (0, read_file_1.rel)(file, opts.root);
|
|
47
|
+
if (!opts.withRanges || !opts.trace)
|
|
48
|
+
return `- [${relativePath}](#${index + 1})`;
|
|
49
|
+
const trace = opts.trace[index];
|
|
50
|
+
return `- [${relativePath}](#${index + 1}) L${trace.startLine}-L${trace.endLine}`;
|
|
51
|
+
});
|
|
52
|
+
return [
|
|
53
|
+
render_constants_1.MD_HEADER,
|
|
54
|
+
render_constants_1.LLM_NOTE,
|
|
55
|
+
"",
|
|
56
|
+
"# Index",
|
|
57
|
+
`<!-- PRODEX_INDEX_RANGE: ${indexRange} -->`,
|
|
58
|
+
`<!-- PRODEX_FILE_COUNT: ${opts.count} -->`,
|
|
59
|
+
"<!-- PRODEX_INDEX_LIST_START -->",
|
|
60
|
+
...items,
|
|
61
|
+
"<!-- PRODEX_INDEX_LIST_END -->",
|
|
62
|
+
"",
|
|
63
|
+
"---",
|
|
64
|
+
].join("\n");
|
|
65
|
+
}
|
|
66
|
+
function analyzeTrace(content, count) {
|
|
67
|
+
const lines = content.split("\n");
|
|
68
|
+
const startMarkerIndex = lines.findIndex((line) => line.trim() === "<!-- PRODEX_INDEX_LIST_START -->");
|
|
69
|
+
const endMarkerIndex = lines.findIndex((line) => line.trim() === "<!-- PRODEX_INDEX_LIST_END -->");
|
|
70
|
+
const { listingStart, listingEnd } = analyzeListingRange(lines, startMarkerIndex, endMarkerIndex, count);
|
|
71
|
+
const footerStartIndex = findFooterStartIndex(lines);
|
|
72
|
+
const sectionStarts = findSectionStartIndexes(lines, count, footerStartIndex);
|
|
73
|
+
return {
|
|
74
|
+
listingStart,
|
|
75
|
+
listingEnd,
|
|
76
|
+
trace: sectionStarts.map((startIndex, index) => {
|
|
77
|
+
const nextStart = index < count - 1 ? sectionStarts[index + 1] : footerStartIndex;
|
|
78
|
+
const endIndex = Math.max(startIndex, nextStart - 1);
|
|
79
|
+
return {
|
|
80
|
+
file: "",
|
|
81
|
+
anchor: index + 1,
|
|
82
|
+
startLine: startIndex + 1,
|
|
83
|
+
endLine: endIndex + 1,
|
|
84
|
+
};
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function analyzeListingRange(lines, startMarkerIndex, endMarkerIndex, count) {
|
|
89
|
+
if (startMarkerIndex < 0 || endMarkerIndex <= startMarkerIndex)
|
|
90
|
+
return { listingStart: 0, listingEnd: 0 };
|
|
91
|
+
const itemIndexes = [];
|
|
92
|
+
for (let index = startMarkerIndex + 1; index < endMarkerIndex; index++) {
|
|
93
|
+
if (lines[index].trim().startsWith("- "))
|
|
94
|
+
itemIndexes.push(index);
|
|
95
|
+
}
|
|
96
|
+
if (!itemIndexes.length) {
|
|
97
|
+
const markerLine = startMarkerIndex + 2;
|
|
98
|
+
return { listingStart: markerLine, listingEnd: markerLine };
|
|
99
|
+
}
|
|
100
|
+
const cappedCount = count > 0 ? Math.min(itemIndexes.length, count) : itemIndexes.length;
|
|
101
|
+
return {
|
|
102
|
+
listingStart: itemIndexes[0] + 1,
|
|
103
|
+
listingEnd: itemIndexes[cappedCount - 1] + 1,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function findFooterStartIndex(lines) {
|
|
107
|
+
const footerMarker = lines.findIndex((line) => line.includes("<!-- PRODEx v") || line.includes("*Generated with [Prodex]"));
|
|
108
|
+
let footerStart = footerMarker >= 0 ? footerMarker : lines.length;
|
|
109
|
+
if (footerStart > 0 && lines[footerStart - 1].trim() === "---")
|
|
110
|
+
footerStart--;
|
|
111
|
+
return footerStart;
|
|
112
|
+
}
|
|
113
|
+
function findSectionStartIndexes(lines, count, fallbackIndex) {
|
|
114
|
+
const markerByAnchor = new Map();
|
|
115
|
+
for (let index = 0; index < lines.length; index++) {
|
|
116
|
+
const match = lines[index].trim().match(/^####\s+(\d+)\s*$/);
|
|
117
|
+
if (!match)
|
|
118
|
+
continue;
|
|
119
|
+
const anchor = Number(match[1]);
|
|
120
|
+
if (Number.isFinite(anchor) && anchor >= 1 && anchor <= count && !markerByAnchor.has(anchor)) {
|
|
121
|
+
markerByAnchor.set(anchor, index);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const starts = [];
|
|
125
|
+
for (let anchor = 1; anchor <= count; anchor++) {
|
|
126
|
+
const markerIndex = markerByAnchor.get(anchor);
|
|
127
|
+
if (markerIndex == null) {
|
|
128
|
+
starts.push(fallbackIndex);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
starts.push(markerIndex > 0 && lines[markerIndex - 1].trim() === "---" ? markerIndex - 1 : markerIndex);
|
|
132
|
+
}
|
|
133
|
+
return starts;
|
|
134
|
+
}
|
|
135
|
+
function renderMdSection(filePath, index, root) {
|
|
136
|
+
const relativePath = (0, read_file_1.rel)(filePath, root);
|
|
137
|
+
const ext = path_1.default.extname(filePath).toLowerCase();
|
|
138
|
+
const lang = render_constants_1.LANG_MAP[ext] || "txt";
|
|
139
|
+
const code = (0, read_file_1.readFileSafe)(filePath).trimEnd();
|
|
140
|
+
return [
|
|
141
|
+
`---\n#### ${index + 1}`,
|
|
142
|
+
"\n",
|
|
143
|
+
"` File: " + relativePath + "` [Back to top](#index)",
|
|
144
|
+
"",
|
|
145
|
+
"```" + lang,
|
|
146
|
+
code,
|
|
147
|
+
"```",
|
|
148
|
+
"",
|
|
149
|
+
].join("\n");
|
|
150
|
+
}
|