thachvd-kit 1.0.4 → 1.0.6
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/bin/cli.js +32 -12
- package/package.json +1 -1
- package/scripts/init.py +12 -2
package/bin/cli.js
CHANGED
|
@@ -398,7 +398,12 @@ const FRAMEWORK_DETECTORS = [
|
|
|
398
398
|
detect: ctx => buildDetection('cakephp', [
|
|
399
399
|
evidenceIf(hasComposerDependency(ctx.composerDepNames, 'cakephp/cakephp'), 'composer.json -> cakephp/cakephp', 4),
|
|
400
400
|
evidenceIf(ctx.fileExists('bin', 'cake'), 'found bin/cake', 3),
|
|
401
|
-
evidenceIf(ctx.fileExists('config', 'app.php'), 'found config/app.php',
|
|
401
|
+
evidenceIf(ctx.fileExists('config', 'app.php'), 'found config/app.php', 2),
|
|
402
|
+
evidenceIf(ctx.fileExists('app', 'Config', 'core.php'), 'found app/Config/core.php (CakePHP legacy)', 3),
|
|
403
|
+
evidenceIf(ctx.fileExists('app', 'Controller', 'AppController.php'), 'found app/Controller/AppController.php', 2),
|
|
404
|
+
evidenceIf(ctx.fileExists('app', 'Model', 'AppModel.php'), 'found app/Model/AppModel.php', 2),
|
|
405
|
+
evidenceIf(ctx.fileExists('lib', 'Cake'), 'found lib/Cake', 3),
|
|
406
|
+
evidenceIf(ctx.fileExists('cake', 'console', 'cake'), 'found cake/console/cake', 3)
|
|
402
407
|
])
|
|
403
408
|
},
|
|
404
409
|
{
|
|
@@ -919,6 +924,7 @@ async function main() {
|
|
|
919
924
|
}
|
|
920
925
|
|
|
921
926
|
const scanned = useScan ? scanProject() : null;
|
|
927
|
+
let reviewScannedFields = !useScan;
|
|
922
928
|
|
|
923
929
|
if (useScan) {
|
|
924
930
|
console.log(`${pc.bold(' Scan result:')} ${scanned.primary_language} | ${scanned.frameworks.join(', ') || 'no framework'}`);
|
|
@@ -928,20 +934,34 @@ async function main() {
|
|
|
928
934
|
scanned.scan_evidence.forEach(line => console.log(` · ${line}`));
|
|
929
935
|
console.log('');
|
|
930
936
|
}
|
|
937
|
+
|
|
938
|
+
if (!assumeYes) {
|
|
939
|
+
const scanAction = await askQuestions({
|
|
940
|
+
type: 'select',
|
|
941
|
+
name: 'scan_action',
|
|
942
|
+
message: 'Use detected context as-is or review fields manually?',
|
|
943
|
+
choices: [
|
|
944
|
+
{ title: 'Use detected context', value: 'accept' },
|
|
945
|
+
{ title: 'Review detected fields', value: 'review' }
|
|
946
|
+
],
|
|
947
|
+
initial: 0
|
|
948
|
+
});
|
|
949
|
+
reviewScannedFields = scanAction.scan_action === 'review';
|
|
950
|
+
}
|
|
931
951
|
}
|
|
932
952
|
|
|
933
953
|
const { project_name, description, project_type } = await askQuestions([
|
|
934
|
-
{ type: assumeYes ? null : 'text', name: 'project_name', message: 'Project name:', initial: scanned?.project_name || path.basename(targetDir) },
|
|
935
|
-
{ type: assumeYes ? null : 'text', name: 'description', message: 'Short description:', initial: scanned?.description || 'A software project' },
|
|
954
|
+
{ type: assumeYes || !reviewScannedFields ? null : 'text', name: 'project_name', message: 'Project name:', initial: scanned?.project_name || path.basename(targetDir) },
|
|
955
|
+
{ type: assumeYes || !reviewScannedFields ? null : 'text', name: 'description', message: 'Short description:', initial: scanned?.description || 'A software project' },
|
|
936
956
|
{
|
|
937
|
-
type: assumeYes ? null : 'select', name: 'project_type', message: 'Project type:',
|
|
957
|
+
type: assumeYes || !reviewScannedFields ? null : 'select', name: 'project_type', message: 'Project type:',
|
|
938
958
|
choices: PROJECT_TYPE_CHOICES.map(value => ({ title: value, value })),
|
|
939
959
|
initial: Math.max(PROJECT_TYPE_CHOICES.indexOf(scanned?.project_type || 'web-app'), 0)
|
|
940
960
|
}
|
|
941
961
|
]);
|
|
942
962
|
|
|
943
963
|
const { primary_language } = await askQuestions({
|
|
944
|
-
type: assumeYes ? null : 'select',
|
|
964
|
+
type: assumeYes || !reviewScannedFields ? null : 'select',
|
|
945
965
|
name: 'primary_language',
|
|
946
966
|
message: 'Primary language:',
|
|
947
967
|
choices: LANGUAGE_CHOICES.map(l => ({ title: l, value: l })),
|
|
@@ -949,7 +969,7 @@ async function main() {
|
|
|
949
969
|
});
|
|
950
970
|
|
|
951
971
|
const { frameworks } = await askQuestions({
|
|
952
|
-
type: assumeYes ? null : 'multiselect',
|
|
972
|
+
type: assumeYes || !reviewScannedFields ? null : 'multiselect',
|
|
953
973
|
name: 'frameworks',
|
|
954
974
|
message: 'Frameworks (Space to select, Enter to confirm):',
|
|
955
975
|
choices: FRAMEWORK_CHOICES.map(f => ({ title: f, value: f, selected: (scanned?.frameworks || []).includes(f) })),
|
|
@@ -958,13 +978,13 @@ async function main() {
|
|
|
958
978
|
|
|
959
979
|
const dbAndInfra = await askQuestions([
|
|
960
980
|
{
|
|
961
|
-
type: assumeYes ? null : 'select', name: 'database', message: 'Database / ORM:',
|
|
981
|
+
type: assumeYes || !reviewScannedFields ? null : 'select', name: 'database', message: 'Database / ORM:',
|
|
962
982
|
choices: DATABASE_CHOICES.map(d => ({ title: d, value: d })),
|
|
963
983
|
initial: Math.max(DATABASE_CHOICES.indexOf(scanned?.database || 'none'), 0)
|
|
964
984
|
},
|
|
965
|
-
{ type: assumeYes ? null : 'confirm', name: 'uses_docker', message: 'Uses Docker / Docker Compose?', initial: scanned?.uses_docker ?? true },
|
|
985
|
+
{ type: assumeYes || !reviewScannedFields ? null : 'confirm', name: 'uses_docker', message: 'Uses Docker / Docker Compose?', initial: scanned?.uses_docker ?? true },
|
|
966
986
|
{
|
|
967
|
-
type: assumeYes ? null : 'select', name: 'cloud', message: 'Cloud Provider:',
|
|
987
|
+
type: assumeYes || !reviewScannedFields ? null : 'select', name: 'cloud', message: 'Cloud Provider:',
|
|
968
988
|
choices: CLOUD_CHOICES.map(c => ({ title: c, value: c })),
|
|
969
989
|
initial: Math.max(CLOUD_CHOICES.indexOf(scanned?.cloud || 'none'), 0)
|
|
970
990
|
}
|
|
@@ -972,12 +992,12 @@ async function main() {
|
|
|
972
992
|
|
|
973
993
|
const { package_manager, test_framework, max_file_lines } = await askQuestions([
|
|
974
994
|
{
|
|
975
|
-
type: assumeYes ? null : 'select', name: 'package_manager', message: 'Package Manager:',
|
|
995
|
+
type: assumeYes || !reviewScannedFields ? null : 'select', name: 'package_manager', message: 'Package Manager:',
|
|
976
996
|
choices: PACKAGE_MANAGER_CHOICES.map(p => ({ title: p, value: p })),
|
|
977
997
|
initial: Math.max(PACKAGE_MANAGER_CHOICES.indexOf(scanned?.package_manager || 'auto-detect'), 0)
|
|
978
998
|
},
|
|
979
|
-
{ type: assumeYes ? null : 'text', name: 'test_framework', message: 'Test Framework (jest, phpunit, etc):', initial: scanned?.test_framework || 'auto-detect' },
|
|
980
|
-
{ type: assumeYes ? null : 'text', name: 'max_file_lines', message: 'Max lines per file:', initial: scanned?.max_file_lines || '300' }
|
|
999
|
+
{ type: assumeYes || !reviewScannedFields ? null : 'text', name: 'test_framework', message: 'Test Framework (jest, phpunit, etc):', initial: scanned?.test_framework || 'auto-detect' },
|
|
1000
|
+
{ type: assumeYes || !reviewScannedFields ? null : 'text', name: 'max_file_lines', message: 'Max lines per file:', initial: scanned?.max_file_lines || '300' }
|
|
981
1001
|
]);
|
|
982
1002
|
|
|
983
1003
|
// Combine data
|
package/package.json
CHANGED
package/scripts/init.py
CHANGED
|
@@ -327,7 +327,12 @@ def scan_project():
|
|
|
327
327
|
{**build_detection("cakephp", [
|
|
328
328
|
evidence_if(has_composer_dependency(composer_dep_names, "cakephp/cakephp"), "composer.json -> cakephp/cakephp", 4),
|
|
329
329
|
evidence_if(Path("bin/cake").exists(), "found bin/cake", 3),
|
|
330
|
-
evidence_if(Path("config/app.php").exists(), "found config/app.php",
|
|
330
|
+
evidence_if(Path("config/app.php").exists(), "found config/app.php", 2),
|
|
331
|
+
evidence_if(Path("app/Config/core.php").exists(), "found app/Config/core.php (CakePHP legacy)", 3),
|
|
332
|
+
evidence_if(Path("app/Controller/AppController.php").exists(), "found app/Controller/AppController.php", 2),
|
|
333
|
+
evidence_if(Path("app/Model/AppModel.php").exists(), "found app/Model/AppModel.php", 2),
|
|
334
|
+
evidence_if(Path("lib/Cake").exists(), "found lib/Cake", 3),
|
|
335
|
+
evidence_if(Path("cake/console/cake").exists(), "found cake/console/cake", 3),
|
|
331
336
|
]), "kind": "backend", "project_type": "api", "language": "php"},
|
|
332
337
|
{**build_detection("symfony", [
|
|
333
338
|
evidence_if(has_composer_dependency(composer_dep_names, "symfony/framework-bundle"), "composer.json -> symfony/framework-bundle", 4),
|
|
@@ -670,6 +675,7 @@ def main():
|
|
|
670
675
|
use_scan = existing_mode == "scan"
|
|
671
676
|
|
|
672
677
|
scanned = scan_project() if use_scan else None
|
|
678
|
+
review_scanned_fields = not use_scan
|
|
673
679
|
if use_scan:
|
|
674
680
|
print(f" {dim('Scan mode: detecting stack from current project files...')}")
|
|
675
681
|
print(f" {bold('Scan result:')} {scanned['primary_language']} | {', '.join(scanned['frameworks']) or 'no framework'}")
|
|
@@ -679,6 +685,10 @@ def main():
|
|
|
679
685
|
for line in scanned["scan_evidence"]:
|
|
680
686
|
print(f" · {line}")
|
|
681
687
|
print()
|
|
688
|
+
if not args.yes:
|
|
689
|
+
scan_action = ask_select("Use detected context as-is or review fields manually",
|
|
690
|
+
["accept", "review"], default="accept")
|
|
691
|
+
review_scanned_fields = scan_action == "review"
|
|
682
692
|
elif not args.yes:
|
|
683
693
|
print(f" {dim('Manual mode: asking for project context explicitly.')}\n")
|
|
684
694
|
|
|
@@ -687,7 +697,7 @@ def main():
|
|
|
687
697
|
else:
|
|
688
698
|
data = {}
|
|
689
699
|
|
|
690
|
-
if not args.yes:
|
|
700
|
+
if not args.yes and review_scanned_fields:
|
|
691
701
|
# ── Project Info ──────────────────────────────────────────────────────
|
|
692
702
|
section("Project Info")
|
|
693
703
|
data["project_name"] = ask("Project name", default=(scanned or {}).get("project_name", Path.cwd().name))
|