faf-cli 3.0.6 → 3.1.0
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/README.md +200 -18
- package/assets/screenshots/package-json+project-faf.png +0 -0
- package/dist/big-orange/compare.d.ts.map +1 -1
- package/dist/big-orange/compare.js +14 -16
- package/dist/big-orange/compare.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +137 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/auto.d.ts.map +1 -1
- package/dist/commands/auto.js +69 -12
- package/dist/commands/auto.js.map +1 -1
- package/dist/commands/bi-sync.d.ts.map +1 -1
- package/dist/commands/bi-sync.js +10 -3
- package/dist/commands/bi-sync.js.map +1 -1
- package/dist/commands/drift.d.ts +16 -0
- package/dist/commands/drift.d.ts.map +1 -0
- package/dist/commands/drift.js +517 -0
- package/dist/commands/drift.js.map +1 -0
- package/dist/commands/git.d.ts +25 -0
- package/dist/commands/git.d.ts.map +1 -0
- package/dist/commands/git.js +355 -0
- package/dist/commands/git.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +5 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.d.ts +11 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +85 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/rename.d.ts +18 -0
- package/dist/commands/rename.d.ts.map +1 -0
- package/dist/commands/rename.js +211 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/taf-init.d.ts +14 -0
- package/dist/commands/taf-init.d.ts.map +1 -0
- package/dist/commands/taf-init.js +138 -0
- package/dist/commands/taf-init.js.map +1 -0
- package/dist/commands/taf-log.d.ts +27 -0
- package/dist/commands/taf-log.d.ts.map +1 -0
- package/dist/commands/taf-log.js +241 -0
- package/dist/commands/taf-log.js.map +1 -0
- package/dist/commands/taf-stats.d.ts +8 -0
- package/dist/commands/taf-stats.d.ts.map +1 -0
- package/dist/commands/taf-stats.js +133 -0
- package/dist/commands/taf-stats.js.map +1 -0
- package/dist/commands/taf-validate.d.ts +8 -0
- package/dist/commands/taf-validate.d.ts.map +1 -0
- package/dist/commands/taf-validate.js +108 -0
- package/dist/commands/taf-validate.js.map +1 -0
- package/dist/commands/taf.d.ts +13 -0
- package/dist/commands/taf.d.ts.map +1 -0
- package/dist/commands/taf.js +85 -0
- package/dist/commands/taf.js.map +1 -0
- package/dist/compiler/faf-compiler.d.ts.map +1 -1
- package/dist/compiler/faf-compiler.js +18 -0
- package/dist/compiler/faf-compiler.js.map +1 -1
- package/dist/generators/faf-generator-championship.d.ts.map +1 -1
- package/dist/generators/faf-generator-championship.js +1 -0
- package/dist/generators/faf-generator-championship.js.map +1 -1
- package/dist/github/github-extractor.d.ts +56 -0
- package/dist/github/github-extractor.d.ts.map +1 -0
- package/dist/github/github-extractor.js +328 -0
- package/dist/github/github-extractor.js.map +1 -0
- package/dist/github/popular-repos.d.ts +43 -0
- package/dist/github/popular-repos.d.ts.map +1 -0
- package/dist/github/popular-repos.js +205 -0
- package/dist/github/popular-repos.js.map +1 -0
- package/dist/github/repo-selector.d.ts +48 -0
- package/dist/github/repo-selector.d.ts.map +1 -0
- package/dist/github/repo-selector.js +277 -0
- package/dist/github/repo-selector.js.map +1 -0
- package/dist/taf/index.d.ts +17 -0
- package/dist/taf/index.d.ts.map +1 -0
- package/dist/taf/index.js +57 -0
- package/dist/taf/index.js.map +1 -0
- package/dist/taf/logger.d.ts +86 -0
- package/dist/taf/logger.d.ts.map +1 -0
- package/dist/taf/logger.js +135 -0
- package/dist/taf/logger.js.map +1 -0
- package/dist/taf/parser.d.ts +32 -0
- package/dist/taf/parser.d.ts.map +1 -0
- package/dist/taf/parser.js +161 -0
- package/dist/taf/parser.js.map +1 -0
- package/dist/taf/stats.d.ts +31 -0
- package/dist/taf/stats.d.ts.map +1 -0
- package/dist/taf/stats.js +182 -0
- package/dist/taf/stats.js.map +1 -0
- package/dist/taf/types.d.ts +66 -0
- package/dist/taf/types.d.ts.map +1 -0
- package/dist/taf/types.js +9 -0
- package/dist/taf/types.js.map +1 -0
- package/dist/taf/validator.d.ts +18 -0
- package/dist/taf/validator.d.ts.map +1 -0
- package/dist/taf/validator.js +148 -0
- package/dist/taf/validator.js.map +1 -0
- package/dist/utils/file-utils.d.ts +10 -0
- package/dist/utils/file-utils.d.ts.map +1 -1
- package/dist/utils/file-utils.js +196 -33
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/utils/native-file-finder.js +1 -1
- package/dist/utils/native-file-finder.js.map +1 -1
- package/dist/utils/yaml-generator.d.ts +1 -0
- package/dist/utils/yaml-generator.d.ts.map +1 -1
- package/dist/utils/yaml-generator.js +1 -0
- package/dist/utils/yaml-generator.js.map +1 -1
- package/package.json +9 -4
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 🔄 faf rename - Bulk Migration Command
|
|
4
|
+
* Find and migrate all .faf files to project.faf (v1.2.0 standard)
|
|
5
|
+
*
|
|
6
|
+
* Use case: "faf rename ~/Projects" migrates entire system in one command
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.renameCommand = renameCommand;
|
|
13
|
+
const colors_1 = require("../fix-once/colors");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const championship_style_1 = require("../utils/championship-style");
|
|
17
|
+
const file_utils_1 = require("../utils/file-utils");
|
|
18
|
+
/**
|
|
19
|
+
* Recursively find all .faf files
|
|
20
|
+
*/
|
|
21
|
+
async function findAllFafFiles(searchPath, currentDepth = 0, maxDepth = 10) {
|
|
22
|
+
const fafFiles = [];
|
|
23
|
+
if (currentDepth > maxDepth) {
|
|
24
|
+
return fafFiles;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const entries = await fs_1.promises.readdir(searchPath, { withFileTypes: true });
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const fullPath = path_1.default.join(searchPath, entry.name);
|
|
30
|
+
// Skip node_modules, .git, etc.
|
|
31
|
+
if (entry.isDirectory()) {
|
|
32
|
+
const skipDirs = ['node_modules', '.git', 'dist', 'build', '.next', '.nuxt', '.svelte-kit', 'target', 'venv', '__pycache__'];
|
|
33
|
+
if (skipDirs.includes(entry.name)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Recurse into subdirectories
|
|
37
|
+
const subFiles = await findAllFafFiles(fullPath, currentDepth + 1, maxDepth);
|
|
38
|
+
fafFiles.push(...subFiles);
|
|
39
|
+
}
|
|
40
|
+
else if (entry.isFile() && entry.name === '.faf') {
|
|
41
|
+
// Found a .faf file!
|
|
42
|
+
fafFiles.push(fullPath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// Skip directories we can't read (permission errors, etc.)
|
|
48
|
+
if (error.code !== 'EACCES' && error.code !== 'EPERM') {
|
|
49
|
+
// Log other errors but continue
|
|
50
|
+
console.error(colors_1.chalk.gray(` Warning: Could not read ${searchPath}`));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return fafFiles;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Migrate a single .faf file to project.faf
|
|
57
|
+
*/
|
|
58
|
+
async function migrateSingleFile(fafPath, force) {
|
|
59
|
+
const dir = path_1.default.dirname(fafPath);
|
|
60
|
+
const projectFafPath = path_1.default.join(dir, 'project.faf');
|
|
61
|
+
try {
|
|
62
|
+
// Check if project.faf already exists
|
|
63
|
+
const projectFafExists = await (0, file_utils_1.fileExists)(projectFafPath);
|
|
64
|
+
if (projectFafExists && !force) {
|
|
65
|
+
return {
|
|
66
|
+
path: fafPath,
|
|
67
|
+
success: false,
|
|
68
|
+
reason: 'project.faf already exists'
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Perform the rename
|
|
72
|
+
await fs_1.promises.rename(fafPath, projectFafPath);
|
|
73
|
+
return {
|
|
74
|
+
path: fafPath,
|
|
75
|
+
success: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return {
|
|
80
|
+
path: fafPath,
|
|
81
|
+
success: false,
|
|
82
|
+
reason: error.message
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Main rename command
|
|
88
|
+
*/
|
|
89
|
+
async function renameCommand(searchPath, options = {}) {
|
|
90
|
+
const startTime = Date.now();
|
|
91
|
+
const rootPath = searchPath ? path_1.default.resolve(searchPath) : process.cwd();
|
|
92
|
+
console.log();
|
|
93
|
+
console.log(championship_style_1.FAF_COLORS.fafCyan(`${championship_style_1.FAF_ICONS.rocket} Searching for .faf files to migrate...`));
|
|
94
|
+
console.log(colors_1.chalk.gray(` Searching in: ${rootPath}`));
|
|
95
|
+
console.log();
|
|
96
|
+
// Check if search path exists
|
|
97
|
+
try {
|
|
98
|
+
const stats = await fs_1.promises.stat(rootPath);
|
|
99
|
+
if (!stats.isDirectory()) {
|
|
100
|
+
console.log(colors_1.chalk.red('❌ Search path must be a directory'));
|
|
101
|
+
console.log();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.log(colors_1.chalk.red(`❌ Path not found: ${rootPath}`));
|
|
107
|
+
console.log();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Find all .faf files
|
|
111
|
+
const fafFiles = await findAllFafFiles(rootPath, 0, options.maxDepth || 10);
|
|
112
|
+
if (fafFiles.length === 0) {
|
|
113
|
+
console.log(colors_1.chalk.yellow('⚠️ No .faf files found'));
|
|
114
|
+
console.log();
|
|
115
|
+
console.log(colors_1.chalk.cyan('💡 Already using project.faf? Great! Nothing to migrate.'));
|
|
116
|
+
console.log();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
console.log(colors_1.chalk.green(`Found ${fafFiles.length} .faf file${fafFiles.length !== 1 ? 's' : ''}`));
|
|
120
|
+
console.log();
|
|
121
|
+
// Dry run mode
|
|
122
|
+
if (options.dryRun) {
|
|
123
|
+
console.log(colors_1.chalk.gray('🔍 Dry run mode - no files will be changed'));
|
|
124
|
+
console.log();
|
|
125
|
+
console.log(colors_1.chalk.green('Would migrate:'));
|
|
126
|
+
for (const fafPath of fafFiles) {
|
|
127
|
+
const dir = path_1.default.dirname(fafPath);
|
|
128
|
+
const relPath = path_1.default.relative(rootPath, dir);
|
|
129
|
+
console.log(colors_1.chalk.gray(` ${relPath || '.'}/`) + colors_1.chalk.red('.faf') + colors_1.chalk.gray(' → ') + colors_1.chalk.cyan('project.faf'));
|
|
130
|
+
}
|
|
131
|
+
console.log();
|
|
132
|
+
console.log(colors_1.chalk.cyan(`Run without --dry-run to perform migration`));
|
|
133
|
+
console.log();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Confirmation for large migrations
|
|
137
|
+
if (fafFiles.length > 10 && !options.noConfirm) {
|
|
138
|
+
console.log(colors_1.chalk.yellow(`⚠️ About to migrate ${fafFiles.length} files`));
|
|
139
|
+
console.log();
|
|
140
|
+
console.log(colors_1.chalk.gray('This will rename:'));
|
|
141
|
+
console.log(colors_1.chalk.gray(' .faf → project.faf'));
|
|
142
|
+
console.log();
|
|
143
|
+
console.log(colors_1.chalk.cyan('Continue? (Use --no-confirm to skip this)'));
|
|
144
|
+
console.log(colors_1.chalk.gray('Press Ctrl+C to cancel, or wait 5 seconds to continue...'));
|
|
145
|
+
console.log();
|
|
146
|
+
// Wait 5 seconds
|
|
147
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
148
|
+
}
|
|
149
|
+
// Perform migrations
|
|
150
|
+
console.log(championship_style_1.FAF_COLORS.fafOrange('🚀 Migrating...'));
|
|
151
|
+
console.log();
|
|
152
|
+
const results = [];
|
|
153
|
+
let successCount = 0;
|
|
154
|
+
let skipCount = 0;
|
|
155
|
+
let errorCount = 0;
|
|
156
|
+
for (const fafPath of fafFiles) {
|
|
157
|
+
const result = await migrateSingleFile(fafPath, options.force || false);
|
|
158
|
+
results.push(result);
|
|
159
|
+
const dir = path_1.default.dirname(fafPath);
|
|
160
|
+
const relPath = path_1.default.relative(rootPath, dir);
|
|
161
|
+
if (result.success) {
|
|
162
|
+
successCount++;
|
|
163
|
+
console.log(colors_1.chalk.green('☑️ ') + colors_1.chalk.gray(`${relPath || '.'}/`) + colors_1.chalk.cyan('project.faf'));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
if (result.reason?.includes('already exists')) {
|
|
167
|
+
skipCount++;
|
|
168
|
+
console.log(colors_1.chalk.gray('⊘ ') + colors_1.chalk.gray(`${relPath || '.'}/ (project.faf exists)`));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
errorCount++;
|
|
172
|
+
console.log(colors_1.chalk.red('✖ ') + colors_1.chalk.gray(`${relPath || '.'}/ - ${result.reason}`));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const elapsedTime = Date.now() - startTime;
|
|
177
|
+
// Summary
|
|
178
|
+
console.log();
|
|
179
|
+
console.log(championship_style_1.FAF_COLORS.fafOrange('━'.repeat(50)));
|
|
180
|
+
console.log();
|
|
181
|
+
console.log(colors_1.chalk.green.bold(`✅ Migration complete!`));
|
|
182
|
+
console.log();
|
|
183
|
+
console.log(colors_1.chalk.gray('Results:'));
|
|
184
|
+
console.log(colors_1.chalk.green(` ☑️ Migrated: ${successCount}`));
|
|
185
|
+
if (skipCount > 0) {
|
|
186
|
+
console.log(colors_1.chalk.gray(` ⊘ Skipped: ${skipCount} (already using project.faf)`));
|
|
187
|
+
}
|
|
188
|
+
if (errorCount > 0) {
|
|
189
|
+
console.log(colors_1.chalk.red(` ✖ Errors: ${errorCount}`));
|
|
190
|
+
}
|
|
191
|
+
console.log(colors_1.chalk.gray(` ⚡ Time: ${elapsedTime}ms`));
|
|
192
|
+
console.log();
|
|
193
|
+
if (successCount > 0) {
|
|
194
|
+
console.log(championship_style_1.FAF_COLORS.fafOrange('🎉 Your projects are now using the v1.2.0 standard!'));
|
|
195
|
+
console.log();
|
|
196
|
+
console.log(colors_1.chalk.gray('Why project.faf?'));
|
|
197
|
+
console.log(colors_1.chalk.gray(' • Visible in file explorers (not hidden)'));
|
|
198
|
+
console.log(colors_1.chalk.gray(' • Easier to discover and share'));
|
|
199
|
+
console.log(colors_1.chalk.gray(' • Universal like package.json'));
|
|
200
|
+
console.log();
|
|
201
|
+
}
|
|
202
|
+
if (skipCount > 0 && successCount === 0) {
|
|
203
|
+
console.log(colors_1.chalk.cyan('💡 All projects already using project.faf - you\'re all set!'));
|
|
204
|
+
console.log();
|
|
205
|
+
}
|
|
206
|
+
if (errorCount > 0) {
|
|
207
|
+
console.log(colors_1.chalk.yellow('⚠️ Some migrations failed. Run with --force to overwrite existing files.'));
|
|
208
|
+
console.log();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=rename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/commands/rename.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AA4GH,sCA2IC;AArPD,+CAA2C;AAC3C,2BAAoC;AACpC,gDAAwB;AACxB,oEAAoE;AACpE,oDAAiD;AAejD;;GAEG;AACH,KAAK,UAAU,eAAe,CAC5B,UAAkB,EAClB,eAAuB,CAAC,EACxB,WAAmB,EAAE;IAErB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,YAAY,GAAG,QAAQ,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI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IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* faf taf init - Initialize .taf file
|
|
3
|
+
*
|
|
4
|
+
* Creates a new .taf (Testing Activity Feed) file in the current directory
|
|
5
|
+
* Detects .faf file for native reference integration
|
|
6
|
+
*/
|
|
7
|
+
interface TAFInitOptions {
|
|
8
|
+
project?: string;
|
|
9
|
+
force?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function tafInit(options?: TAFInitOptions): Promise<void>;
|
|
12
|
+
export declare function runTAFInit(args: string[]): Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=taf-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taf-init.d.ts","sourceRoot":"","sources":["../../src/commands/taf-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFzE;AAGD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAY9D"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* faf taf init - Initialize .taf file
|
|
4
|
+
*
|
|
5
|
+
* Creates a new .taf (Testing Activity Feed) file in the current directory
|
|
6
|
+
* Detects .faf file for native reference integration
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.tafInit = tafInit;
|
|
43
|
+
exports.runTAFInit = runTAFInit;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const taf_1 = require("../taf");
|
|
47
|
+
const yaml = __importStar(require("yaml"));
|
|
48
|
+
async function tafInit(options = {}) {
|
|
49
|
+
const tafPath = path.join(process.cwd(), '.taf');
|
|
50
|
+
// Check if .taf already exists
|
|
51
|
+
if (fs.existsSync(tafPath) && !options.force) {
|
|
52
|
+
console.error('❌ .taf file already exists');
|
|
53
|
+
console.log('\nUse --force to overwrite');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
// Get project name
|
|
57
|
+
let projectName = options.project;
|
|
58
|
+
if (!projectName) {
|
|
59
|
+
// Try to get from package.json
|
|
60
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
61
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
62
|
+
try {
|
|
63
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
64
|
+
projectName = pkg.name;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Ignore errors
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!projectName) {
|
|
72
|
+
// Use directory name as fallback
|
|
73
|
+
projectName = path.basename(process.cwd());
|
|
74
|
+
}
|
|
75
|
+
// Check for .faf file (Native Reference)
|
|
76
|
+
const fafPath = path.join(process.cwd(), '.faf');
|
|
77
|
+
const hasFAF = fs.existsSync(fafPath);
|
|
78
|
+
let fafScore;
|
|
79
|
+
if (hasFAF) {
|
|
80
|
+
try {
|
|
81
|
+
const fafContent = fs.readFileSync(fafPath, 'utf-8');
|
|
82
|
+
const faf = yaml.parse(fafContent);
|
|
83
|
+
// Try to extract score from various possible fields
|
|
84
|
+
if (faf.ai_score) {
|
|
85
|
+
const scoreStr = String(faf.ai_score).replace('%', '');
|
|
86
|
+
fafScore = parseInt(scoreStr);
|
|
87
|
+
}
|
|
88
|
+
else if (faf.score) {
|
|
89
|
+
fafScore = parseInt(String(faf.score));
|
|
90
|
+
}
|
|
91
|
+
else if (faf.faf_dna?.current_score) {
|
|
92
|
+
fafScore = parseInt(String(faf.faf_dna.current_score));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Ignore parsing errors
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Create .taf file
|
|
100
|
+
const taf = (0, taf_1.createTAF)(projectName, {
|
|
101
|
+
faf_associated: hasFAF,
|
|
102
|
+
faf_location: hasFAF ? '.faf' : undefined,
|
|
103
|
+
faf_score: fafScore,
|
|
104
|
+
});
|
|
105
|
+
// Serialize and format
|
|
106
|
+
const content = (0, taf_1.formatTAF)((0, taf_1.serializeTAF)(taf));
|
|
107
|
+
// Write file
|
|
108
|
+
fs.writeFileSync(tafPath, content, 'utf-8');
|
|
109
|
+
// Success message
|
|
110
|
+
console.log('✅ Created .taf file');
|
|
111
|
+
console.log(`\nProject: ${projectName}`);
|
|
112
|
+
if (hasFAF) {
|
|
113
|
+
console.log('🔗 Native Reference: .faf detected');
|
|
114
|
+
if (fafScore) {
|
|
115
|
+
console.log(` FAF Score: ${fafScore}/100`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
console.log('ℹ️ No .faf file found (optional)');
|
|
120
|
+
}
|
|
121
|
+
console.log('\nNext steps:');
|
|
122
|
+
console.log(' faf taf log # Log a test run');
|
|
123
|
+
console.log(' faf taf stats # View statistics');
|
|
124
|
+
console.log(' faf taf validate # Validate format');
|
|
125
|
+
}
|
|
126
|
+
// CLI wrapper
|
|
127
|
+
async function runTAFInit(args) {
|
|
128
|
+
const options = {
|
|
129
|
+
force: args.includes('--force') || args.includes('-f'),
|
|
130
|
+
};
|
|
131
|
+
// Extract project name if provided
|
|
132
|
+
const projectIndex = args.findIndex(arg => arg === '--project' || arg === '-p');
|
|
133
|
+
if (projectIndex !== -1 && args[projectIndex + 1]) {
|
|
134
|
+
options.project = args[projectIndex + 1];
|
|
135
|
+
}
|
|
136
|
+
await tafInit(options);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=taf-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taf-init.js","sourceRoot":"","sources":["../../src/commands/taf-init.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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ACzB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* faf taf log - Log a test run
|
|
3
|
+
*
|
|
4
|
+
* Appends a test run entry to .taf file
|
|
5
|
+
* Supports both minimal and detailed modes
|
|
6
|
+
*/
|
|
7
|
+
import { TestResult } from '../taf';
|
|
8
|
+
interface TAFLogOptions {
|
|
9
|
+
minimal?: boolean;
|
|
10
|
+
result?: TestResult;
|
|
11
|
+
passed?: number;
|
|
12
|
+
failed?: number;
|
|
13
|
+
total?: number;
|
|
14
|
+
skipped?: number;
|
|
15
|
+
command?: string;
|
|
16
|
+
trigger?: string;
|
|
17
|
+
issues?: string[];
|
|
18
|
+
root_cause?: string;
|
|
19
|
+
resolution?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function tafLog(options?: TAFLogOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* CLI wrapper - parse arguments
|
|
24
|
+
*/
|
|
25
|
+
export declare function runTAFLog(args: string[]): Promise<void>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=taf-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taf-log.d.ts","sourceRoot":"","sources":["../../src/commands/taf-log.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAQL,UAAU,EACX,MAAM,QAAQ,CAAC;AAEhB,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiJvE;AAiBD;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+D7D"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* faf taf log - Log a test run
|
|
4
|
+
*
|
|
5
|
+
* Appends a test run entry to .taf file
|
|
6
|
+
* Supports both minimal and detailed modes
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.tafLog = tafLog;
|
|
43
|
+
exports.runTAFLog = runTAFLog;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const taf_1 = require("../taf");
|
|
47
|
+
async function tafLog(options = {}) {
|
|
48
|
+
const tafPath = path.join(process.cwd(), '.taf');
|
|
49
|
+
// Check if .taf exists
|
|
50
|
+
if (!fs.existsSync(tafPath)) {
|
|
51
|
+
console.error('❌ No .taf file found');
|
|
52
|
+
console.log('\nRun: faf taf init');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
// Read and parse
|
|
56
|
+
let taf;
|
|
57
|
+
try {
|
|
58
|
+
const content = fs.readFileSync(tafPath, 'utf-8');
|
|
59
|
+
taf = (0, taf_1.parseTAF)(content);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('❌ Failed to parse .taf file');
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
console.error(`\n${error.message}`);
|
|
65
|
+
}
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
// Validate required fields
|
|
69
|
+
if (options.total === undefined || options.passed === undefined || options.failed === undefined) {
|
|
70
|
+
console.error('❌ Missing required test counts');
|
|
71
|
+
console.log('\nRequired: --total, --passed, --failed');
|
|
72
|
+
console.log('Example: faf taf log --total 173 --passed 173 --failed 0');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
// Validate input types and values
|
|
76
|
+
const total = options.total;
|
|
77
|
+
const passed = options.passed;
|
|
78
|
+
const failed = options.failed;
|
|
79
|
+
const skipped = options.skipped || 0;
|
|
80
|
+
// Check for NaN
|
|
81
|
+
if (isNaN(total) || isNaN(passed) || isNaN(failed) || isNaN(skipped)) {
|
|
82
|
+
console.error('❌ Invalid input: test counts must be numbers');
|
|
83
|
+
console.log('\nExample: faf taf log --total 173 --passed 173 --failed 0');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
// Check for negative numbers
|
|
87
|
+
if (total < 0 || passed < 0 || failed < 0 || skipped < 0) {
|
|
88
|
+
console.error('❌ Invalid input: test counts cannot be negative');
|
|
89
|
+
console.log(`\nReceived: total=${total}, passed=${passed}, failed=${failed}, skipped=${skipped}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
// Check for integers
|
|
93
|
+
if (!Number.isInteger(total) || !Number.isInteger(passed) || !Number.isInteger(failed) || !Number.isInteger(skipped)) {
|
|
94
|
+
console.error('❌ Invalid input: test counts must be integers');
|
|
95
|
+
console.log(`\nReceived: total=${total}, passed=${passed}, failed=${failed}, skipped=${skipped}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
// Check math: passed + failed + skipped should equal total
|
|
99
|
+
const sum = passed + failed + skipped;
|
|
100
|
+
if (sum !== total) {
|
|
101
|
+
console.error('❌ Invalid input: test counts do not add up');
|
|
102
|
+
console.log(`\nPassed (${passed}) + Failed (${failed}) + Skipped (${skipped}) = ${sum}`);
|
|
103
|
+
console.log(`But total is ${total}`);
|
|
104
|
+
console.log('\nThe numbers must add up correctly.');
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
// Check logical constraints
|
|
108
|
+
if (passed > total) {
|
|
109
|
+
console.error('❌ Invalid input: passed tests cannot exceed total tests');
|
|
110
|
+
console.log(`\nPassed: ${passed}, Total: ${total}`);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
if (failed > total) {
|
|
114
|
+
console.error('❌ Invalid input: failed tests cannot exceed total tests');
|
|
115
|
+
console.log(`\nFailed: ${failed}, Total: ${total}`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
// Detect result if not provided
|
|
119
|
+
const previousRun = taf.test_history[taf.test_history.length - 1];
|
|
120
|
+
const result = options.result || (0, taf_1.detectResult)({ passed: options.passed, total: options.total }, previousRun ? { passed: previousRun.tests.passed, total: previousRun.tests.total } : undefined);
|
|
121
|
+
// Create test run entry
|
|
122
|
+
const run = options.minimal
|
|
123
|
+
? (0, taf_1.createMinimalRun)({
|
|
124
|
+
result,
|
|
125
|
+
total: options.total,
|
|
126
|
+
passed: options.passed,
|
|
127
|
+
failed: options.failed,
|
|
128
|
+
skipped: options.skipped,
|
|
129
|
+
})
|
|
130
|
+
: (0, taf_1.createDetailedRun)({
|
|
131
|
+
result,
|
|
132
|
+
command: options.command,
|
|
133
|
+
trigger: options.trigger,
|
|
134
|
+
tests: {
|
|
135
|
+
total: options.total,
|
|
136
|
+
passed: options.passed,
|
|
137
|
+
failed: options.failed,
|
|
138
|
+
skipped: options.skipped,
|
|
139
|
+
},
|
|
140
|
+
issues: options.issues,
|
|
141
|
+
root_cause: options.root_cause,
|
|
142
|
+
resolution: options.resolution,
|
|
143
|
+
});
|
|
144
|
+
// Append to TAF
|
|
145
|
+
const updatedTAF = (0, taf_1.appendTestRun)(taf, run);
|
|
146
|
+
// Serialize and format
|
|
147
|
+
const content = (0, taf_1.formatTAF)((0, taf_1.serializeTAF)(updatedTAF));
|
|
148
|
+
// Write back
|
|
149
|
+
fs.writeFileSync(tafPath, content, 'utf-8');
|
|
150
|
+
// Success message
|
|
151
|
+
const resultEmoji = result === 'PASSED' ? '✅' :
|
|
152
|
+
result === 'IMPROVED' ? '📈' :
|
|
153
|
+
result === 'DEGRADED' ? '📉' : '❌';
|
|
154
|
+
console.log(`${resultEmoji} Logged test run: ${result}`);
|
|
155
|
+
console.log(`\n Tests: ${options.passed}/${options.total} passing`);
|
|
156
|
+
if (result === 'PASSED') {
|
|
157
|
+
const streak = countCurrentStreak(updatedTAF.test_history);
|
|
158
|
+
if (streak > 1) {
|
|
159
|
+
console.log(` 🔥 Streak: ${streak} passing runs`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (options.root_cause) {
|
|
163
|
+
console.log(` Root cause: ${options.root_cause}`);
|
|
164
|
+
}
|
|
165
|
+
if (options.resolution) {
|
|
166
|
+
console.log(` Resolution: ${options.resolution}`);
|
|
167
|
+
}
|
|
168
|
+
console.log(`\nTotal runs: ${updatedTAF.test_history.length}`);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Count current passing streak
|
|
172
|
+
*/
|
|
173
|
+
function countCurrentStreak(history) {
|
|
174
|
+
let streak = 0;
|
|
175
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
176
|
+
if (history[i].result === 'PASSED') {
|
|
177
|
+
streak++;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return streak;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* CLI wrapper - parse arguments
|
|
187
|
+
*/
|
|
188
|
+
async function runTAFLog(args) {
|
|
189
|
+
const options = {
|
|
190
|
+
minimal: args.includes('--minimal') || args.includes('-m'),
|
|
191
|
+
};
|
|
192
|
+
// Parse test counts
|
|
193
|
+
const totalIndex = args.findIndex(arg => arg === '--total' || arg === '-t');
|
|
194
|
+
if (totalIndex !== -1 && args[totalIndex + 1]) {
|
|
195
|
+
options.total = parseInt(args[totalIndex + 1]);
|
|
196
|
+
}
|
|
197
|
+
const passedIndex = args.findIndex(arg => arg === '--passed' || arg === '-p');
|
|
198
|
+
if (passedIndex !== -1 && args[passedIndex + 1]) {
|
|
199
|
+
options.passed = parseInt(args[passedIndex + 1]);
|
|
200
|
+
}
|
|
201
|
+
const failedIndex = args.findIndex(arg => arg === '--failed' || arg === '-f');
|
|
202
|
+
if (failedIndex !== -1 && args[failedIndex + 1]) {
|
|
203
|
+
options.failed = parseInt(args[failedIndex + 1]);
|
|
204
|
+
}
|
|
205
|
+
const skippedIndex = args.findIndex(arg => arg === '--skipped' || arg === '-s');
|
|
206
|
+
if (skippedIndex !== -1 && args[skippedIndex + 1]) {
|
|
207
|
+
options.skipped = parseInt(args[skippedIndex + 1]);
|
|
208
|
+
}
|
|
209
|
+
// Parse result (optional)
|
|
210
|
+
const resultIndex = args.findIndex(arg => arg === '--result' || arg === '-r');
|
|
211
|
+
if (resultIndex !== -1 && args[resultIndex + 1]) {
|
|
212
|
+
const resultStr = args[resultIndex + 1].toUpperCase();
|
|
213
|
+
if (['PASSED', 'FAILED', 'IMPROVED', 'DEGRADED'].includes(resultStr)) {
|
|
214
|
+
options.result = resultStr;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Parse detailed fields
|
|
218
|
+
const commandIndex = args.findIndex(arg => arg === '--command' || arg === '-c');
|
|
219
|
+
if (commandIndex !== -1 && args[commandIndex + 1]) {
|
|
220
|
+
options.command = args[commandIndex + 1];
|
|
221
|
+
}
|
|
222
|
+
const triggerIndex = args.findIndex(arg => arg === '--trigger');
|
|
223
|
+
if (triggerIndex !== -1 && args[triggerIndex + 1]) {
|
|
224
|
+
options.trigger = args[triggerIndex + 1];
|
|
225
|
+
}
|
|
226
|
+
const rootCauseIndex = args.findIndex(arg => arg === '--root-cause');
|
|
227
|
+
if (rootCauseIndex !== -1 && args[rootCauseIndex + 1]) {
|
|
228
|
+
options.root_cause = args[rootCauseIndex + 1];
|
|
229
|
+
}
|
|
230
|
+
const resolutionIndex = args.findIndex(arg => arg === '--resolution');
|
|
231
|
+
if (resolutionIndex !== -1 && args[resolutionIndex + 1]) {
|
|
232
|
+
options.resolution = args[resolutionIndex + 1];
|
|
233
|
+
}
|
|
234
|
+
// Parse issues (comma-separated)
|
|
235
|
+
const issuesIndex = args.findIndex(arg => arg === '--issues' || arg === '-i');
|
|
236
|
+
if (issuesIndex !== -1 && args[issuesIndex + 1]) {
|
|
237
|
+
options.issues = args[issuesIndex + 1].split(',').map(s => s.trim());
|
|
238
|
+
}
|
|
239
|
+
await tafLog(options);
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=taf-log.js.map
|