@lakindu_perera/toren 1.0.7 → 1.0.9
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/CHANGELOG.md +26 -0
- package/README.md +120 -31
- package/dist/cli/toren.d.ts +24 -0
- package/dist/cli/toren.js +254 -0
- package/dist/cli/toren.js.map +1 -0
- package/dist/detectors/config-detector.d.ts +3 -0
- package/dist/detectors/config-detector.js +58 -0
- package/dist/detectors/config-detector.js.map +1 -0
- package/dist/detectors/health-detector.d.ts +12 -0
- package/dist/detectors/health-detector.js +53 -0
- package/dist/detectors/health-detector.js.map +1 -0
- package/dist/detectors/important-files-detector.d.ts +51 -0
- package/dist/detectors/important-files-detector.js +455 -0
- package/dist/detectors/important-files-detector.js.map +1 -0
- package/dist/detectors/package-manager-detector.d.ts +7 -0
- package/dist/detectors/package-manager-detector.js +35 -0
- package/dist/detectors/package-manager-detector.js.map +1 -0
- package/dist/detectors/project-info-detector.d.ts +13 -0
- package/dist/detectors/project-info-detector.js +97 -0
- package/dist/detectors/project-info-detector.js.map +1 -0
- package/dist/detectors/script-detector.d.ts +42 -0
- package/dist/detectors/script-detector.js +199 -0
- package/dist/detectors/script-detector.js.map +1 -0
- package/dist/focused-output.d.ts +27 -0
- package/dist/focused-output.js +201 -0
- package/dist/focused-output.js.map +1 -0
- package/dist/lifecycle.d.ts +2 -0
- package/dist/lifecycle.js +114 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/renderers/console-renderer.d.ts +19 -0
- package/dist/renderers/console-renderer.js +361 -0
- package/dist/renderers/console-renderer.js.map +1 -0
- package/dist/renderers/html-renderer.d.ts +14 -0
- package/{src → dist}/renderers/html-renderer.js +263 -201
- package/dist/renderers/html-renderer.js.map +1 -0
- package/dist/renderers/index.d.ts +6 -0
- package/dist/renderers/index.js +12 -0
- package/dist/renderers/index.js.map +1 -0
- package/dist/renderers/json-renderer.d.ts +10 -0
- package/dist/renderers/json-renderer.js +127 -0
- package/dist/renderers/json-renderer.js.map +1 -0
- package/dist/renderers/markdown-renderer.d.ts +13 -0
- package/dist/renderers/markdown-renderer.js +360 -0
- package/dist/renderers/markdown-renderer.js.map +1 -0
- package/dist/scanner/scan.d.ts +2 -0
- package/dist/scanner/scan.js +573 -0
- package/dist/scanner/scan.js.map +1 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +16 -7
- package/bin/toren.js +0 -308
- package/src/detectors/config-detector.js +0 -81
- package/src/detectors/script-detector.js +0 -32
- package/src/focused-output.js +0 -146
- package/src/lifecycle.js +0 -124
- package/src/renderers/console-renderer.js +0 -350
- package/src/renderers/index.js +0 -41
- package/src/renderers/json-renderer.js +0 -154
- package/src/renderers/markdown-renderer.js +0 -337
- package/src/scanner/scan.js +0 -532
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProjectInfo, PackageManager, ScriptInfo } from '../types/index.js';
|
|
2
|
+
interface DetectProjectInfoOptions {
|
|
3
|
+
rootPath: string;
|
|
4
|
+
projectType: string;
|
|
5
|
+
flatFiles: string[];
|
|
6
|
+
entryPoints: string[];
|
|
7
|
+
packageManager: PackageManager | null;
|
|
8
|
+
scripts: ScriptInfo[];
|
|
9
|
+
}
|
|
10
|
+
export declare function detectProjectInfo({ rootPath, projectType, flatFiles, entryPoints, packageManager, scripts }: DetectProjectInfoOptions): {
|
|
11
|
+
projectInfo: ProjectInfo;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export function detectProjectInfo({ rootPath, projectType, flatFiles, entryPoints, packageManager, scripts }) {
|
|
4
|
+
const fileSet = new Set(flatFiles);
|
|
5
|
+
let name = null;
|
|
6
|
+
const pkgPath = path.join(rootPath, 'package.json');
|
|
7
|
+
try {
|
|
8
|
+
if (fs.existsSync(pkgPath)) {
|
|
9
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
10
|
+
if (pkg && typeof pkg === 'object' && 'name' in pkg && typeof pkg.name === 'string') {
|
|
11
|
+
name = pkg.name;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch { }
|
|
16
|
+
if (!name) {
|
|
17
|
+
name = path.basename(rootPath) || null;
|
|
18
|
+
}
|
|
19
|
+
let runtime = null;
|
|
20
|
+
const pt = projectType.toLowerCase();
|
|
21
|
+
if (pt.includes('node') || fileSet.has('package.json'))
|
|
22
|
+
runtime = 'Node.js';
|
|
23
|
+
else if (pt.includes('python'))
|
|
24
|
+
runtime = 'Python';
|
|
25
|
+
else if (pt.includes('java') || pt.includes('spring'))
|
|
26
|
+
runtime = 'JVM / Java';
|
|
27
|
+
else if (pt.includes('go'))
|
|
28
|
+
runtime = 'Go';
|
|
29
|
+
else if (pt.includes('rust'))
|
|
30
|
+
runtime = 'Rust';
|
|
31
|
+
else if (pt.includes('ruby'))
|
|
32
|
+
runtime = 'Ruby';
|
|
33
|
+
else if (pt.includes('php') || pt.includes('composer'))
|
|
34
|
+
runtime = 'PHP';
|
|
35
|
+
else if (pt.includes('elixir') || pt.includes('phoenix'))
|
|
36
|
+
runtime = 'Erlang / BEAM';
|
|
37
|
+
let language = null;
|
|
38
|
+
if (fileSet.has('tsconfig.json') || pt.includes('angular')) {
|
|
39
|
+
language = 'TypeScript';
|
|
40
|
+
}
|
|
41
|
+
else if (fileSet.has('package.json') && !fileSet.has('tsconfig.json')) {
|
|
42
|
+
language = 'JavaScript';
|
|
43
|
+
}
|
|
44
|
+
else if (pt.includes('python'))
|
|
45
|
+
language = 'Python';
|
|
46
|
+
else if (pt.includes('java') || pt.includes('spring'))
|
|
47
|
+
language = 'Java';
|
|
48
|
+
else if (pt.includes('go'))
|
|
49
|
+
language = 'Go';
|
|
50
|
+
else if (pt.includes('rust'))
|
|
51
|
+
language = 'Rust';
|
|
52
|
+
else if (pt.includes('ruby'))
|
|
53
|
+
language = 'Ruby';
|
|
54
|
+
else if (pt.includes('php'))
|
|
55
|
+
language = 'PHP';
|
|
56
|
+
else if (pt.includes('elixir'))
|
|
57
|
+
language = 'Elixir';
|
|
58
|
+
let framework = null;
|
|
59
|
+
if (projectType && projectType !== 'Unknown') {
|
|
60
|
+
framework = projectType;
|
|
61
|
+
}
|
|
62
|
+
let architecture = null;
|
|
63
|
+
if (pt.includes('next')) {
|
|
64
|
+
const hasApp = Array.from(fileSet).some(f => f.startsWith('app/'));
|
|
65
|
+
const hasPages = Array.from(fileSet).some(f => f.startsWith('pages/'));
|
|
66
|
+
if (hasApp && hasPages)
|
|
67
|
+
architecture = 'Hybrid App/Pages Router';
|
|
68
|
+
else if (hasApp)
|
|
69
|
+
architecture = 'App Router';
|
|
70
|
+
else if (hasPages)
|
|
71
|
+
architecture = 'Pages Router';
|
|
72
|
+
}
|
|
73
|
+
const entryPoint = entryPoints.length > 0 ? entryPoints[0] : null;
|
|
74
|
+
let sourceDirectory = null;
|
|
75
|
+
if (entryPoint) {
|
|
76
|
+
if (entryPoint.startsWith('src/'))
|
|
77
|
+
sourceDirectory = 'src';
|
|
78
|
+
else if (entryPoint.startsWith('app/'))
|
|
79
|
+
sourceDirectory = 'app';
|
|
80
|
+
else if (entryPoint.startsWith('pages/'))
|
|
81
|
+
sourceDirectory = 'pages';
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
projectInfo: {
|
|
85
|
+
name,
|
|
86
|
+
projectType,
|
|
87
|
+
runtime,
|
|
88
|
+
language,
|
|
89
|
+
framework,
|
|
90
|
+
architecture,
|
|
91
|
+
packageManager,
|
|
92
|
+
entryPoint,
|
|
93
|
+
sourceDirectory
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=project-info-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-info-detector.js","sourceRoot":"","sources":["../../src/detectors/project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QACf,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,eAAe,GAAG,KAAK,CAAC;aACtD,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,eAAe,GAAG,KAAK,CAAC;aAC3D,IAAI,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,eAAe,GAAG,OAAO,CAAC;IACtE,CAAC;IAED,OAAO;QACL,WAAW,EAAE;YACX,IAAI;YACJ,WAAW;YACX,OAAO;YACP,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,cAAc;YACd,UAAU;YACV,eAAe;SAChB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Toren — Script Detector with Intelligence Layer
|
|
3
|
+
*
|
|
4
|
+
* Reads package.json scripts and enriches each entry with:
|
|
5
|
+
* - category — functional grouping (development, build, testing, etc.)
|
|
6
|
+
* - description — human-readable purpose string
|
|
7
|
+
* - usage — ready-to-run command string for the detected package manager
|
|
8
|
+
*
|
|
9
|
+
* Design contract:
|
|
10
|
+
* - Backward compatible: name and command are always present and unchanged.
|
|
11
|
+
* - category and description are null when no deterministic match exists.
|
|
12
|
+
* - usage is always a string — derived from packageManager or falls back to
|
|
13
|
+
* "npm run <name>" when packageManager is null.
|
|
14
|
+
* - Descriptions are never fabricated. Only canonical mappings and known
|
|
15
|
+
* command-keyword inferences are used.
|
|
16
|
+
* - Deterministic: same input always produces the same output.
|
|
17
|
+
* - Graceful: malformed or missing package.json returns an empty array.
|
|
18
|
+
*
|
|
19
|
+
* @module detectors/script-detector
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Object} ScriptItem
|
|
23
|
+
* @property {string} name - Script name as declared in package.json
|
|
24
|
+
* @property {string} command - Raw script command string
|
|
25
|
+
* @property {string|null} category - Functional category, or null when unknown
|
|
26
|
+
* @property {string|null} description - Human-readable purpose, or null when unknown
|
|
27
|
+
* @property {string} usage - Ready-to-run invocation string
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Detect and enrich npm/package scripts from package.json.
|
|
31
|
+
*
|
|
32
|
+
* The `packageManager` parameter is optional for backward compatibility.
|
|
33
|
+
* When omitted (or null), usage strings fall back to `npm run <name>`.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} rootPath - Absolute path of the scanned root
|
|
36
|
+
* @param {string|null} [packageManager=null] - Detected package manager name
|
|
37
|
+
* @returns {{ scripts: ScriptItem[] }}
|
|
38
|
+
*/
|
|
39
|
+
import type { ScriptInfo, PackageManager } from "../types/index.js";
|
|
40
|
+
export declare function detectScripts(rootPath: string, packageManager?: PackageManager | null): {
|
|
41
|
+
scripts: ScriptInfo[];
|
|
42
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Toren — Script Detector with Intelligence Layer
|
|
3
|
+
*
|
|
4
|
+
* Reads package.json scripts and enriches each entry with:
|
|
5
|
+
* - category — functional grouping (development, build, testing, etc.)
|
|
6
|
+
* - description — human-readable purpose string
|
|
7
|
+
* - usage — ready-to-run command string for the detected package manager
|
|
8
|
+
*
|
|
9
|
+
* Design contract:
|
|
10
|
+
* - Backward compatible: name and command are always present and unchanged.
|
|
11
|
+
* - category and description are null when no deterministic match exists.
|
|
12
|
+
* - usage is always a string — derived from packageManager or falls back to
|
|
13
|
+
* "npm run <name>" when packageManager is null.
|
|
14
|
+
* - Descriptions are never fabricated. Only canonical mappings and known
|
|
15
|
+
* command-keyword inferences are used.
|
|
16
|
+
* - Deterministic: same input always produces the same output.
|
|
17
|
+
* - Graceful: malformed or missing package.json returns an empty array.
|
|
18
|
+
*
|
|
19
|
+
* @module detectors/script-detector
|
|
20
|
+
*/
|
|
21
|
+
import fs from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Description and category tables — keyed by exact script name (lowercase)
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* Maps a known script name to its canonical human-readable description.
|
|
28
|
+
* @type {Map<string, string>}
|
|
29
|
+
*/
|
|
30
|
+
const NAME_DESCRIPTIONS = new Map([
|
|
31
|
+
['dev', 'Start the development server'],
|
|
32
|
+
['develop', 'Start the development server'],
|
|
33
|
+
['start', 'Start the application'],
|
|
34
|
+
['serve', 'Serve the application'],
|
|
35
|
+
['preview', 'Preview the production build'],
|
|
36
|
+
['build', 'Create a production build'],
|
|
37
|
+
['test', 'Run the test suite'],
|
|
38
|
+
['test:watch', 'Run tests in watch mode'],
|
|
39
|
+
['test:e2e', 'Run end-to-end tests'],
|
|
40
|
+
['lint', 'Run code-quality checks'],
|
|
41
|
+
['lint:fix', 'Run code-quality checks and fix supported issues'],
|
|
42
|
+
['format', 'Format the codebase'],
|
|
43
|
+
['typecheck', 'Run static type checks'],
|
|
44
|
+
['check', 'Run project checks'],
|
|
45
|
+
['clean', 'Remove generated build artifacts'],
|
|
46
|
+
['generate', 'Generate project files or code'],
|
|
47
|
+
['migrate', 'Run database migrations'],
|
|
48
|
+
['seed', 'Seed the database'],
|
|
49
|
+
['deploy', 'Deploy the application'],
|
|
50
|
+
]);
|
|
51
|
+
/**
|
|
52
|
+
* Maps a known script name to its functional category.
|
|
53
|
+
* @type {Map<string, string>}
|
|
54
|
+
*/
|
|
55
|
+
const NAME_CATEGORIES = new Map([
|
|
56
|
+
['dev', 'development'],
|
|
57
|
+
['develop', 'development'],
|
|
58
|
+
['start', 'development'],
|
|
59
|
+
['serve', 'development'],
|
|
60
|
+
['preview', 'development'],
|
|
61
|
+
['build', 'build'],
|
|
62
|
+
['test', 'testing'],
|
|
63
|
+
['test:watch', 'testing'],
|
|
64
|
+
['test:e2e', 'testing'],
|
|
65
|
+
['lint', 'quality'],
|
|
66
|
+
['lint:fix', 'quality'],
|
|
67
|
+
['format', 'quality'],
|
|
68
|
+
['typecheck', 'quality'],
|
|
69
|
+
['check', 'quality'],
|
|
70
|
+
['clean', 'utility'],
|
|
71
|
+
['generate', 'utility'],
|
|
72
|
+
['migrate', 'database'],
|
|
73
|
+
['seed', 'database'],
|
|
74
|
+
['deploy', 'deployment'],
|
|
75
|
+
]);
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Command-keyword inference — ordered most-specific first
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
/**
|
|
80
|
+
* Ordered list of command-keyword → { description, category } inferences.
|
|
81
|
+
* Evaluated only when a script name has no entry in NAME_DESCRIPTIONS.
|
|
82
|
+
* More specific patterns (e.g. "playwright test") must appear before broader
|
|
83
|
+
* ones (e.g. "jest") to prevent false matches.
|
|
84
|
+
*
|
|
85
|
+
* @type {Array<{ keyword: string, description: string, category: string }>}
|
|
86
|
+
*/
|
|
87
|
+
const COMMAND_INFERENCE = [
|
|
88
|
+
{ keyword: 'playwright test', description: 'Run end-to-end tests', category: 'testing' },
|
|
89
|
+
{ keyword: 'cypress run', description: 'Run end-to-end tests', category: 'testing' },
|
|
90
|
+
{ keyword: 'vitest', description: 'Run the test suite', category: 'testing' },
|
|
91
|
+
{ keyword: 'jest', description: 'Run the test suite', category: 'testing' },
|
|
92
|
+
{ keyword: 'tsc --noEmit', description: 'Run static type checks', category: 'quality' },
|
|
93
|
+
{ keyword: 'eslint', description: 'Run code-quality checks', category: 'quality' },
|
|
94
|
+
{ keyword: 'prettier', description: 'Format the codebase', category: 'quality' },
|
|
95
|
+
];
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Usage builder
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
/**
|
|
100
|
+
* Script names that npm treats as built-in lifecycle commands.
|
|
101
|
+
* These do NOT need the "run" subcommand: `npm test`, `npm start`, etc.
|
|
102
|
+
* @type {Set<string>}
|
|
103
|
+
*/
|
|
104
|
+
const NPM_LIFECYCLE = new Set(['test', 'start', 'stop', 'restart']);
|
|
105
|
+
/**
|
|
106
|
+
* Script names that bun exposes as direct subcommands (no "run" needed).
|
|
107
|
+
* @type {Set<string>}
|
|
108
|
+
*/
|
|
109
|
+
const BUN_LIFECYCLE = new Set(['test', 'start']);
|
|
110
|
+
/**
|
|
111
|
+
* Build the ready-to-run usage string for a script.
|
|
112
|
+
*
|
|
113
|
+
* Rules:
|
|
114
|
+
* npm: lifecycle commands (test, start…) → `npm <name>`
|
|
115
|
+
* all others → `npm run <name>`
|
|
116
|
+
* pnpm: all scripts → `pnpm <name>` (pnpm forwards directly)
|
|
117
|
+
* yarn: all scripts → `yarn <name>`
|
|
118
|
+
* bun: lifecycle commands (test, start) → `bun <name>`
|
|
119
|
+
* all others → `bun run <name>`
|
|
120
|
+
* null: conservative fallback → `npm run <name>` (always valid)
|
|
121
|
+
*
|
|
122
|
+
* @param {string} name - Script name
|
|
123
|
+
* @param {string|null} packageManager - Detected package manager or null
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
function buildUsage(name, packageManager) {
|
|
127
|
+
switch (packageManager) {
|
|
128
|
+
case 'npm':
|
|
129
|
+
return NPM_LIFECYCLE.has(name) ? `npm ${name}` : `npm run ${name}`;
|
|
130
|
+
case 'pnpm':
|
|
131
|
+
// pnpm forwards all script names without requiring the 'run' sub-command.
|
|
132
|
+
return `pnpm ${name}`;
|
|
133
|
+
case 'yarn':
|
|
134
|
+
// yarn similarly runs scripts directly without 'run'.
|
|
135
|
+
return `yarn ${name}`;
|
|
136
|
+
case 'bun':
|
|
137
|
+
return BUN_LIFECYCLE.has(name) ? `bun ${name}` : `bun run ${name}`;
|
|
138
|
+
default:
|
|
139
|
+
// null or unknown — conservative: `npm run <name>` is always valid even
|
|
140
|
+
// for lifecycle names, so we keep it unconditionally safe.
|
|
141
|
+
return `npm run ${name}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Description + category resolver
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
/**
|
|
148
|
+
* Resolve description and category for a single script entry.
|
|
149
|
+
* Priority: exact name match → command-keyword inference → null.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} name
|
|
152
|
+
* @param {string} command
|
|
153
|
+
* @returns {{ description: string|null, category: string|null }}
|
|
154
|
+
*/
|
|
155
|
+
function resolveIntelligence(name, command) {
|
|
156
|
+
// 1. Exact name match (canonical mapping — highest confidence).
|
|
157
|
+
const nameDescription = NAME_DESCRIPTIONS.get(name) ?? null;
|
|
158
|
+
const nameCategory = NAME_CATEGORIES.get(name) ?? null;
|
|
159
|
+
if (nameDescription !== null || nameCategory !== null) {
|
|
160
|
+
return { description: nameDescription, category: nameCategory };
|
|
161
|
+
}
|
|
162
|
+
// 2. Command-keyword inference (fallback — only for unknown names).
|
|
163
|
+
for (const { keyword, description, category } of COMMAND_INFERENCE) {
|
|
164
|
+
if (command.includes(keyword)) {
|
|
165
|
+
return { description, category };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// 3. Unknown — do not fabricate.
|
|
169
|
+
return { description: null, category: null };
|
|
170
|
+
}
|
|
171
|
+
export function detectScripts(rootPath, packageManager = null) {
|
|
172
|
+
const scripts = [];
|
|
173
|
+
const pkgPath = path.join(rootPath, 'package.json');
|
|
174
|
+
try {
|
|
175
|
+
if (fs.existsSync(pkgPath)) {
|
|
176
|
+
const content = fs.readFileSync(pkgPath, 'utf8');
|
|
177
|
+
const pkg = JSON.parse(content);
|
|
178
|
+
if (pkg.scripts && typeof pkg.scripts === 'object') {
|
|
179
|
+
for (const [name, command] of Object.entries(pkg.scripts)) {
|
|
180
|
+
if (typeof command !== 'string')
|
|
181
|
+
continue;
|
|
182
|
+
const { description, category } = resolveIntelligence(name, command);
|
|
183
|
+
scripts.push({
|
|
184
|
+
name,
|
|
185
|
+
command,
|
|
186
|
+
category,
|
|
187
|
+
description,
|
|
188
|
+
usage: buildUsage(name, packageManager),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// Return empty scripts on malformed or unreadable package.json
|
|
196
|
+
}
|
|
197
|
+
return { scripts };
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=script-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-detector.js","sourceRoot":"","sources":["../../src/detectors/script-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAQ,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAiB;IAChD,CAAC,KAAK,EAAS,8BAA8B,CAAC;IAC9C,CAAC,SAAS,EAAK,8BAA8B,CAAC;IAC9C,CAAC,OAAO,EAAO,uBAAuB,CAAC;IACvC,CAAC,OAAO,EAAO,uBAAuB,CAAC;IACvC,CAAC,SAAS,EAAK,8BAA8B,CAAC;IAC9C,CAAC,OAAO,EAAO,2BAA2B,CAAC;IAC3C,CAAC,MAAM,EAAQ,oBAAoB,CAAC;IACpC,CAAC,YAAY,EAAE,yBAAyB,CAAC;IACzC,CAAC,UAAU,EAAI,sBAAsB,CAAC;IACtC,CAAC,MAAM,EAAQ,yBAAyB,CAAC;IACzC,CAAC,UAAU,EAAI,kDAAkD,CAAC;IAClE,CAAC,QAAQ,EAAM,qBAAqB,CAAC;IACrC,CAAC,WAAW,EAAG,wBAAwB,CAAC;IACxC,CAAC,OAAO,EAAO,oBAAoB,CAAC;IACpC,CAAC,OAAO,EAAO,kCAAkC,CAAC;IAClD,CAAC,UAAU,EAAI,gCAAgC,CAAC;IAChD,CAAC,SAAS,EAAK,yBAAyB,CAAC;IACzC,CAAC,MAAM,EAAQ,mBAAmB,CAAC;IACnC,CAAC,QAAQ,EAAM,wBAAwB,C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,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC1D,IAAI,OAAO,OAAO,KAAK,QAAQ;wBAAE,SAAS;oBAE1C,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAErE,OAAO,CAAC,IAAI,CAAC;wBACX,IAAI;wBACJ,OAAO;wBACP,QAAQ;wBACR,WAAW;wBACX,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,cAAc,CAAC;qBACxC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;IACjE,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ScanResult } from "./types/index.js";
|
|
2
|
+
export declare const FOCUSED_FLAGS: string[];
|
|
3
|
+
/**
|
|
4
|
+
* Validates focused flags in the provided arguments.
|
|
5
|
+
*
|
|
6
|
+
* @param {string[]} args Process arguments
|
|
7
|
+
* @returns {{ error: boolean, message?: string, mode?: string|null }}
|
|
8
|
+
*/
|
|
9
|
+
type FocusedModeResult = {
|
|
10
|
+
error: true;
|
|
11
|
+
title: string;
|
|
12
|
+
message: string;
|
|
13
|
+
detailLabel: string;
|
|
14
|
+
detailValue: string;
|
|
15
|
+
} | {
|
|
16
|
+
error: false;
|
|
17
|
+
mode: string | null;
|
|
18
|
+
};
|
|
19
|
+
export declare function getFocusedModeInfo(args: string[]): FocusedModeResult;
|
|
20
|
+
/**
|
|
21
|
+
* Renders the scan result based on the active focused mode.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} mode Active focused mode flag
|
|
24
|
+
* @param {import('./scanner/scan.js').ScanResult} result
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderFocusedMode(mode: string, result: ScanResult): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Toren — Focused Output Mode Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles the six focused output flags:
|
|
5
|
+
* --project-type --frameworks --entry-points
|
|
6
|
+
* --structure --configs --scripts
|
|
7
|
+
*
|
|
8
|
+
* Design contract:
|
|
9
|
+
* - Each flag renders exactly one section to stdout using the console visual
|
|
10
|
+
* style (ANSI colours, section header + divider).
|
|
11
|
+
* - Empty-state messages are canonical strings declared in EMPTY below.
|
|
12
|
+
* They must end with a period and stay in sync with console-renderer.js.
|
|
13
|
+
* - No business logic. All data comes from the ScanResult passed in.
|
|
14
|
+
* - Stateless: renderFocusedMode() may be called multiple times safely.
|
|
15
|
+
*/
|
|
16
|
+
import { renderStructure } from './renderers/console-renderer.js';
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Canonical empty-state messages
|
|
19
|
+
// Keep these in sync with the equivalent strings in console-renderer.js.
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const EMPTY = {
|
|
22
|
+
frameworks: 'No frameworks detected.',
|
|
23
|
+
entryPoints: 'No entry points detected.',
|
|
24
|
+
configs: 'No configuration files detected.',
|
|
25
|
+
scripts: 'No package scripts detected.',
|
|
26
|
+
importantFiles: 'No important files detected.',
|
|
27
|
+
health: 'No project health observations available.',
|
|
28
|
+
};
|
|
29
|
+
export const FOCUSED_FLAGS = [
|
|
30
|
+
'--project-type',
|
|
31
|
+
'--frameworks',
|
|
32
|
+
'--entry-points',
|
|
33
|
+
'--structure',
|
|
34
|
+
'--configs',
|
|
35
|
+
'--scripts',
|
|
36
|
+
'--summary',
|
|
37
|
+
'--important-files',
|
|
38
|
+
'--health'
|
|
39
|
+
];
|
|
40
|
+
export function getFocusedModeInfo(args) {
|
|
41
|
+
const activeFlags = FOCUSED_FLAGS.filter(flag => args.includes(flag));
|
|
42
|
+
if (activeFlags.length > 1) {
|
|
43
|
+
return {
|
|
44
|
+
error: true,
|
|
45
|
+
title: 'Conflicting options',
|
|
46
|
+
message: 'Focused output flags are mutually exclusive.',
|
|
47
|
+
detailLabel: 'Provided flags',
|
|
48
|
+
detailValue: activeFlags.join(', ')
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
error: false,
|
|
53
|
+
mode: activeFlags[0] || null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Print a bold-white section title followed by a dim matched-length divider
|
|
58
|
+
* and a blank line — same visual pattern as console-renderer.js's section().
|
|
59
|
+
*
|
|
60
|
+
* @param {string} title
|
|
61
|
+
*/
|
|
62
|
+
function printSectionHeader(title) {
|
|
63
|
+
console.log(`\x1b[1m\x1b[97m${title}\x1b[0m`);
|
|
64
|
+
console.log(`\x1b[2m${'─'.repeat(title.length)}\x1b[0m`);
|
|
65
|
+
console.log('');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Print a focused section: header, then items or an empty-state message.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} title - Section heading
|
|
71
|
+
* @param {string[]} items - Pre-formatted lines to print
|
|
72
|
+
* @param {string} emptyMsg - Canonical empty-state message (ends with '.')
|
|
73
|
+
*/
|
|
74
|
+
function section(title, items, emptyMsg) {
|
|
75
|
+
printSectionHeader(title);
|
|
76
|
+
if (!items || items.length === 0) {
|
|
77
|
+
console.log(`\x1b[2m${emptyMsg}\x1b[0m`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
for (const item of items) {
|
|
81
|
+
console.log(item);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Renders the scan result based on the active focused mode.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} mode Active focused mode flag
|
|
89
|
+
* @param {import('./scanner/scan.js').ScanResult} result
|
|
90
|
+
*/
|
|
91
|
+
export function renderFocusedMode(mode, result) {
|
|
92
|
+
switch (mode) {
|
|
93
|
+
case '--project-type': {
|
|
94
|
+
// projectType is always a string; 'Unknown' when undetected.
|
|
95
|
+
section('Project Type', [result.projectType], 'Unknown');
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case '--frameworks': {
|
|
99
|
+
const frameworks = (!result.projectType || result.projectType === 'Unknown')
|
|
100
|
+
? []
|
|
101
|
+
: [result.projectType];
|
|
102
|
+
section('Frameworks', frameworks, EMPTY.frameworks);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case '--entry-points': {
|
|
106
|
+
section('Entry Points', result.entryPoints || [], EMPTY.entryPoints);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case '--structure': {
|
|
110
|
+
renderStructure(result);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case '--configs': {
|
|
114
|
+
section('Configuration Files', result.configs || [], EMPTY.configs);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case '--scripts': {
|
|
118
|
+
const scriptsList = [];
|
|
119
|
+
if (result.scripts && result.scripts.length > 0) {
|
|
120
|
+
for (const s of result.scripts) {
|
|
121
|
+
const usage = s.usage || `npm run ${s.name}`;
|
|
122
|
+
scriptsList.push(`\x1b[97m${usage}\x1b[0m`);
|
|
123
|
+
if (s.description) {
|
|
124
|
+
scriptsList.push(` \x1b[2m${s.description}\x1b[0m\n`);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
scriptsList.push(` \x1b[2m${s.command}\x1b[0m\n`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Remove trailing newline from last element if it exists
|
|
132
|
+
if (scriptsList.length > 0) {
|
|
133
|
+
scriptsList[scriptsList.length - 1] = scriptsList[scriptsList.length - 1].replace(/\n$/, '');
|
|
134
|
+
}
|
|
135
|
+
section('Package Scripts', scriptsList, EMPTY.scripts);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case '--summary': {
|
|
139
|
+
const p = result.projectInfo || {};
|
|
140
|
+
const lines = [
|
|
141
|
+
`Name ${p.name || 'Unknown'}`,
|
|
142
|
+
`Type ${result.projectType || 'Unknown'}`,
|
|
143
|
+
];
|
|
144
|
+
if (p.runtime)
|
|
145
|
+
lines.push(`Runtime ${p.runtime}`);
|
|
146
|
+
if (p.language)
|
|
147
|
+
lines.push(`Language ${p.language}`);
|
|
148
|
+
if (p.framework)
|
|
149
|
+
lines.push(`Framework ${p.framework}`);
|
|
150
|
+
if (p.architecture)
|
|
151
|
+
lines.push(`Architecture ${p.architecture}`);
|
|
152
|
+
if (result.packageManager)
|
|
153
|
+
lines.push(`Package Manager ${result.packageManager}`);
|
|
154
|
+
if (p.entryPoint)
|
|
155
|
+
lines.push(`Entry Point ${p.entryPoint}`);
|
|
156
|
+
if (p.sourceDirectory)
|
|
157
|
+
lines.push(`Source Directory ${p.sourceDirectory}`);
|
|
158
|
+
lines.push(`Files ${result.flatFiles ? result.flatFiles.length : 0}`);
|
|
159
|
+
lines.push(`Folders ${result.totalFolders || 0}`);
|
|
160
|
+
section('Project Summary', lines, 'No summary available.');
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case '--important-files': {
|
|
164
|
+
const items = [];
|
|
165
|
+
if (result.importantFiles && result.importantFiles.length > 0) {
|
|
166
|
+
const top10 = result.importantFiles.slice(0, 10);
|
|
167
|
+
top10.forEach((f, idx) => {
|
|
168
|
+
items.push(`${idx + 1}. \x1b[97m${f.path}\x1b[0m`);
|
|
169
|
+
items.push(` \x1b[2m${f.reason}\x1b[0m\n`);
|
|
170
|
+
});
|
|
171
|
+
// Remove trailing newline
|
|
172
|
+
if (items.length > 0) {
|
|
173
|
+
items[items.length - 1] = items[items.length - 1].replace(/\n$/, '');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
section('Important Files', items, EMPTY.importantFiles);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case '--health': {
|
|
180
|
+
const items = [];
|
|
181
|
+
if (result.health && result.health.length > 0) {
|
|
182
|
+
for (const h of result.health) {
|
|
183
|
+
let icon = 'ℹ';
|
|
184
|
+
if (h.status === 'pass')
|
|
185
|
+
icon = '✓';
|
|
186
|
+
else if (h.status === 'warning')
|
|
187
|
+
icon = '⚠';
|
|
188
|
+
let color = '\x1b[97m';
|
|
189
|
+
if (h.status === 'pass')
|
|
190
|
+
color = '\x1b[32m';
|
|
191
|
+
else if (h.status === 'warning')
|
|
192
|
+
color = '\x1b[33m';
|
|
193
|
+
items.push(`${color}${icon}\x1b[0m ${h.message}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
section('Project Health', items, EMPTY.health);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=focused-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focused-output.js","sourceRoot":"","sources":["../src/focused-output.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,8EAA8E;AAC9E,iCAAiC;AACjC,yEAAyE;AACzE,8EAA8E;AAE9E,MAAM,KAAK,GAAG;IACZ,UAAU,EAAM,yBAAyB;IACzC,WAAW,EAAK,2BAA2B;IAC3C,OAAO,EAAS,kCAAkC;IAClD,OAAO,EAAS,8BAA8B;IAC9C,cAAc,EAAE,8BAA8B;IAC9C,MAAM,EAAU,2CAA2C;CAC5D,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,WAAW;IACX,WAAW;IACX,mBAAmB;IACnB,UAAU;CACX,CAAC;AAYF,MAAM,UAAU,kBAAkB,CAAC,IAAc;IAC/C,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAA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