@sun-asterisk/sungen 2.4.3 ā 2.4.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/dist/cli/commands/add.d.ts.map +1 -1
- package/dist/cli/commands/add.js +8 -2
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/delivery.d.ts +7 -0
- package/dist/cli/commands/delivery.d.ts.map +1 -0
- package/dist/cli/commands/delivery.js +348 -0
- package/dist/cli/commands/delivery.js.map +1 -0
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +64 -1
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +4 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/exporters/csv-exporter.d.ts +32 -0
- package/dist/exporters/csv-exporter.d.ts.map +1 -0
- package/dist/exporters/csv-exporter.js +311 -0
- package/dist/exporters/csv-exporter.js.map +1 -0
- package/dist/exporters/feature-parser.d.ts +48 -0
- package/dist/exporters/feature-parser.d.ts.map +1 -0
- package/dist/exporters/feature-parser.js +178 -0
- package/dist/exporters/feature-parser.js.map +1 -0
- package/dist/exporters/package-info.d.ts +9 -0
- package/dist/exporters/package-info.d.ts.map +1 -0
- package/dist/exporters/package-info.js +73 -0
- package/dist/exporters/package-info.js.map +1 -0
- package/dist/exporters/playwright-report-parser.d.ts +21 -0
- package/dist/exporters/playwright-report-parser.d.ts.map +1 -0
- package/dist/exporters/playwright-report-parser.js +184 -0
- package/dist/exporters/playwright-report-parser.js.map +1 -0
- package/dist/exporters/scenario-merger.d.ts +21 -0
- package/dist/exporters/scenario-merger.d.ts.map +1 -0
- package/dist/exporters/scenario-merger.js +51 -0
- package/dist/exporters/scenario-merger.js.map +1 -0
- package/dist/exporters/spec-parser.d.ts +20 -0
- package/dist/exporters/spec-parser.d.ts.map +1 -0
- package/dist/exporters/spec-parser.js +259 -0
- package/dist/exporters/spec-parser.js.map +1 -0
- package/dist/exporters/step-formatter.d.ts +32 -0
- package/dist/exporters/step-formatter.d.ts.map +1 -0
- package/dist/exporters/step-formatter.js +76 -0
- package/dist/exporters/step-formatter.js.map +1 -0
- package/dist/exporters/test-data-resolver.d.ts +20 -0
- package/dist/exporters/test-data-resolver.d.ts.map +1 -0
- package/dist/exporters/test-data-resolver.js +96 -0
- package/dist/exporters/test-data-resolver.js.map +1 -0
- package/dist/exporters/types.d.ts +104 -0
- package/dist/exporters/types.d.ts.map +1 -0
- package/dist/exporters/types.js +6 -0
- package/dist/exporters/types.js.map +1 -0
- package/dist/exporters/xlsx-exporter.d.ts +19 -0
- package/dist/exporters/xlsx-exporter.d.ts.map +1 -0
- package/dist/exporters/xlsx-exporter.js +309 -0
- package/dist/exporters/xlsx-exporter.js.map +1 -0
- package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
- package/dist/generators/test-generator/utils/selector-resolver.js +26 -0
- package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
- package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
- package/dist/orchestrator/ai-rules-updater.js +12 -0
- package/dist/orchestrator/ai-rules-updater.js.map +1 -1
- package/dist/orchestrator/project-initializer.d.ts +12 -1
- package/dist/orchestrator/project-initializer.d.ts.map +1 -1
- package/dist/orchestrator/project-initializer.js +84 -64
- package/dist/orchestrator/project-initializer.js.map +1 -1
- package/dist/orchestrator/screen-manager.d.ts +1 -0
- package/dist/orchestrator/screen-manager.d.ts.map +1 -1
- package/dist/orchestrator/screen-manager.js +4 -2
- package/dist/orchestrator/screen-manager.js.map +1 -1
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +18 -9
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +7 -5
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-delivery.md +71 -0
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +38 -10
- package/dist/orchestrator/templates/ai-instructions/claude-config.md +12 -2
- package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-figma.md +142 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +100 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-local.md +73 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-delivery.md +103 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +2 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -4
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +22 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +18 -9
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +6 -4
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +71 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +45 -20
- package/dist/orchestrator/templates/ai-instructions/copilot-config.md +12 -2
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-figma.md +142 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +100 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-local.md +73 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +103 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +2 -0
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -4
- package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +22 -0
- package/dist/orchestrator/templates/playwright.config.d.ts.map +1 -1
- package/dist/orchestrator/templates/playwright.config.js +6 -1
- package/dist/orchestrator/templates/playwright.config.js.map +1 -1
- package/dist/orchestrator/templates/playwright.config.ts +6 -1
- package/package.json +2 -1
- package/src/cli/commands/add.ts +9 -2
- package/src/cli/commands/delivery.ts +348 -0
- package/src/cli/commands/update.ts +84 -2
- package/src/cli/index.ts +4 -2
- package/src/exporters/csv-exporter.ts +304 -0
- package/src/exporters/feature-parser.ts +168 -0
- package/src/exporters/package-info.ts +35 -0
- package/src/exporters/playwright-report-parser.ts +168 -0
- package/src/exporters/scenario-merger.ts +63 -0
- package/src/exporters/spec-parser.ts +247 -0
- package/src/exporters/step-formatter.ts +80 -0
- package/src/exporters/test-data-resolver.ts +59 -0
- package/src/exporters/types.ts +112 -0
- package/src/exporters/xlsx-exporter.ts +301 -0
- package/src/generators/test-generator/utils/selector-resolver.ts +26 -0
- package/src/orchestrator/ai-rules-updater.ts +12 -0
- package/src/orchestrator/project-initializer.ts +103 -70
- package/src/orchestrator/screen-manager.ts +5 -2
- package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +18 -9
- package/src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +7 -5
- package/src/orchestrator/templates/ai-instructions/claude-cmd-delivery.md +71 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +38 -10
- package/src/orchestrator/templates/ai-instructions/claude-config.md +12 -2
- package/src/orchestrator/templates/ai-instructions/claude-skill-capture-figma.md +142 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +100 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-capture-local.md +73 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-delivery.md +103 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +2 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -4
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +22 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +18 -9
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +6 -4
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +71 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +45 -20
- package/src/orchestrator/templates/ai-instructions/copilot-config.md +12 -2
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-figma.md +142 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +100 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-local.md +73 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +103 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +2 -0
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -4
- package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +22 -0
- package/src/orchestrator/templates/playwright.config.ts +6 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sungen delivery` CLI command.
|
|
3
|
+
* Exports Gherkin scenarios + Playwright results ā CSV test case file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
import { parseFeatureMetadata } from '../../exporters/feature-parser';
|
|
11
|
+
import { parseSpecFile } from '../../exporters/spec-parser';
|
|
12
|
+
import { loadTestData, resolveTestDataPath } from '../../exporters/test-data-resolver';
|
|
13
|
+
import { loadPlaywrightReport } from '../../exporters/playwright-report-parser';
|
|
14
|
+
import { mergeFeatureAndSpec } from '../../exporters/scenario-merger';
|
|
15
|
+
import {
|
|
16
|
+
buildTestCaseRows,
|
|
17
|
+
buildSummary,
|
|
18
|
+
renderCsv,
|
|
19
|
+
writeCsv,
|
|
20
|
+
} from '../../exporters/csv-exporter';
|
|
21
|
+
import { renderXlsx, writeXlsx } from '../../exporters/xlsx-exporter';
|
|
22
|
+
import { EnvironmentInfo, PreflightCheck, ScreenSummary } from '../../exporters/types';
|
|
23
|
+
|
|
24
|
+
const COLOR = {
|
|
25
|
+
reset: '\x1b[0m',
|
|
26
|
+
gray: '\x1b[90m',
|
|
27
|
+
green: '\x1b[32m',
|
|
28
|
+
red: '\x1b[31m',
|
|
29
|
+
yellow: '\x1b[33m',
|
|
30
|
+
cyan: '\x1b[36m',
|
|
31
|
+
bold: '\x1b[1m',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function log(msg: string): void {
|
|
35
|
+
console.log(msg);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ----------------------------------------------------------------------------
|
|
39
|
+
// Discovery
|
|
40
|
+
// ----------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
function listAllScreens(cwd: string): string[] {
|
|
43
|
+
const screensDir = path.join(cwd, 'qa', 'screens');
|
|
44
|
+
if (!fs.existsSync(screensDir)) return [];
|
|
45
|
+
return fs
|
|
46
|
+
.readdirSync(screensDir, { withFileTypes: true })
|
|
47
|
+
.filter((d) => d.isDirectory())
|
|
48
|
+
.map((d) => d.name)
|
|
49
|
+
.sort();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
// Pre-flight checks
|
|
54
|
+
// ----------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the results file path for a screen.
|
|
58
|
+
* Prefer the per-screen co-located file, fall back to the global `test-results/results.json`.
|
|
59
|
+
*/
|
|
60
|
+
function resolveResultsPath(cwd: string, screen: string): string | null {
|
|
61
|
+
const perScreen = path.join(cwd, 'specs', 'generated', screen, `${screen}-test-result.json`);
|
|
62
|
+
if (fs.existsSync(perScreen)) return perScreen;
|
|
63
|
+
const global = path.join(cwd, 'test-results', 'results.json');
|
|
64
|
+
if (fs.existsSync(global)) return global;
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function runPreflight(cwd: string, screen: string): PreflightCheck {
|
|
69
|
+
const featureFile = path.join(cwd, 'qa', 'screens', screen, 'features', `${screen}.feature`);
|
|
70
|
+
const testDataFile = resolveTestDataPath(cwd, screen);
|
|
71
|
+
const selectorsFile = path.join(cwd, 'qa', 'screens', screen, 'selectors', `${screen}.yaml`);
|
|
72
|
+
const specFile = path.join(cwd, 'specs', 'generated', screen, `${screen}.spec.ts`);
|
|
73
|
+
const resultsFile = resolveResultsPath(cwd, screen);
|
|
74
|
+
|
|
75
|
+
const featureOk = checkFeatureReal(featureFile);
|
|
76
|
+
const testDataOk = checkTestDataHasVars(testDataFile);
|
|
77
|
+
const selectorsOk = checkSelectorsHasEntries(selectorsFile, screen);
|
|
78
|
+
const specOk = fs.existsSync(specFile);
|
|
79
|
+
const resultsOk = resultsFile !== null;
|
|
80
|
+
|
|
81
|
+
const missing: string[] = [];
|
|
82
|
+
const suggestions: string[] = [];
|
|
83
|
+
|
|
84
|
+
if (!featureOk) {
|
|
85
|
+
missing.push(`feature file missing/empty: ${path.relative(cwd, featureFile)}`);
|
|
86
|
+
suggestions.push(`/sungen:create-test ${screen}`);
|
|
87
|
+
}
|
|
88
|
+
if (!testDataOk) {
|
|
89
|
+
missing.push(`test-data.yaml has no variables: ${path.relative(cwd, testDataFile)}`);
|
|
90
|
+
suggestions.push(`/sungen:create-test ${screen}`);
|
|
91
|
+
}
|
|
92
|
+
if (!selectorsOk) {
|
|
93
|
+
missing.push(`selectors.yaml missing entries: ${path.relative(cwd, selectorsFile)}`);
|
|
94
|
+
suggestions.push(`/sungen:run-test ${screen}`);
|
|
95
|
+
}
|
|
96
|
+
if (!specOk) {
|
|
97
|
+
missing.push(`compiled .spec.ts missing: ${path.relative(cwd, specFile)}`);
|
|
98
|
+
suggestions.push(`sungen generate --screen ${screen}`);
|
|
99
|
+
}
|
|
100
|
+
if (!resultsOk) {
|
|
101
|
+
missing.push(`test-result.json missing (optional)`);
|
|
102
|
+
suggestions.push(`PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/${screen}/${screen}-test-result.json npx playwright test specs/generated/${screen}/${screen}.spec.ts`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
screen,
|
|
107
|
+
featureOk,
|
|
108
|
+
testDataOk,
|
|
109
|
+
selectorsOk,
|
|
110
|
+
specOk,
|
|
111
|
+
resultsOk,
|
|
112
|
+
missing,
|
|
113
|
+
suggestions: Array.from(new Set(suggestions)),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function checkFeatureReal(featureFile: string): boolean {
|
|
118
|
+
if (!fs.existsSync(featureFile)) return false;
|
|
119
|
+
const content = fs.readFileSync(featureFile, 'utf-8');
|
|
120
|
+
if (!/Feature:/i.test(content)) return false;
|
|
121
|
+
// Treat as empty if only the sample scaffold scenario is present
|
|
122
|
+
const sample = /Scenario:\s*Sample scenario for /.test(content);
|
|
123
|
+
const realScenarios = (content.match(/\n\s*Scenario:/g) || []).length;
|
|
124
|
+
// If sample present and only 1 scenario ā it's the scaffold only
|
|
125
|
+
if (sample && realScenarios <= 1) return false;
|
|
126
|
+
return realScenarios >= 1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function checkTestDataHasVars(testDataFile: string): boolean {
|
|
130
|
+
if (!fs.existsSync(testDataFile)) return false;
|
|
131
|
+
const content = fs.readFileSync(testDataFile, 'utf-8');
|
|
132
|
+
// Any non-comment line with `key: value`
|
|
133
|
+
const lines = content.split('\n').filter((l) => !l.trim().startsWith('#') && l.includes(':'));
|
|
134
|
+
return lines.length > 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function checkSelectorsHasEntries(selectorsFile: string, screen: string): boolean {
|
|
138
|
+
if (!fs.existsSync(selectorsFile)) return false;
|
|
139
|
+
const content = fs.readFileSync(selectorsFile, 'utf-8');
|
|
140
|
+
// Very small check: YAML has more than just a single `<screen>: page` entry
|
|
141
|
+
const topLevelKeys = (content.match(/^[a-zA-Z_][^\s:]*:\s*$/gm) || []).length +
|
|
142
|
+
(content.match(/^[a-zA-Z_][^\s:]*:\s/gm) || []).length;
|
|
143
|
+
return topLevelKeys > 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function hasBlockingMissing(p: PreflightCheck): boolean {
|
|
147
|
+
return !p.featureOk || !p.testDataOk || !p.selectorsOk || !p.specOk;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ----------------------------------------------------------------------------
|
|
151
|
+
// Environment
|
|
152
|
+
// ----------------------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
function getEnvironment(cwd: string): EnvironmentInfo {
|
|
155
|
+
let baseURL = '';
|
|
156
|
+
let projectName = 'chromium';
|
|
157
|
+
const configPath = path.join(cwd, 'playwright.config.ts');
|
|
158
|
+
if (fs.existsSync(configPath)) {
|
|
159
|
+
const c = fs.readFileSync(configPath, 'utf-8');
|
|
160
|
+
const baseMatch = c.match(/baseURL:\s*['"]([^'"]+)['"]/);
|
|
161
|
+
if (baseMatch) baseURL = baseMatch[1];
|
|
162
|
+
const projMatch = c.match(/name:\s*['"]([^'"]+)['"]/);
|
|
163
|
+
if (projMatch) projectName = projMatch[1];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let executor = process.env.CI_USER || process.env.USER || '';
|
|
167
|
+
try {
|
|
168
|
+
const gitUser = execSync('git config user.name', { cwd, encoding: 'utf-8' }).trim();
|
|
169
|
+
if (gitUser) executor = gitUser;
|
|
170
|
+
} catch {
|
|
171
|
+
// ignore
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return { baseURL, projectName, executor };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ----------------------------------------------------------------------------
|
|
178
|
+
// Per-screen export
|
|
179
|
+
// ----------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
async function exportScreen(
|
|
182
|
+
cwd: string,
|
|
183
|
+
screen: string,
|
|
184
|
+
env: EnvironmentInfo
|
|
185
|
+
): Promise<ScreenSummary | null> {
|
|
186
|
+
const featureFile = path.join(cwd, 'qa', 'screens', screen, 'features', `${screen}.feature`);
|
|
187
|
+
const testDataFile = resolveTestDataPath(cwd, screen);
|
|
188
|
+
const specFile = path.join(cwd, 'specs', 'generated', screen, `${screen}.spec.ts`);
|
|
189
|
+
const resultsFile = resolveResultsPath(cwd, screen);
|
|
190
|
+
const specMdFile = path.join(cwd, 'qa', 'screens', screen, 'requirements', 'spec.md');
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
const feature = parseFeatureMetadata(featureFile);
|
|
194
|
+
const spec = parseSpecFile(specFile);
|
|
195
|
+
const testData = loadTestData(testDataFile);
|
|
196
|
+
const results = resultsFile ? loadPlaywrightReport(resultsFile) : null;
|
|
197
|
+
|
|
198
|
+
const merged = mergeFeatureAndSpec(feature, spec);
|
|
199
|
+
const rows = buildTestCaseRows({
|
|
200
|
+
screen,
|
|
201
|
+
featureName: feature.featureName,
|
|
202
|
+
merged,
|
|
203
|
+
testData,
|
|
204
|
+
results,
|
|
205
|
+
env,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const specLink = fs.existsSync(specMdFile) ? path.relative(cwd, specMdFile) : '';
|
|
209
|
+
const tempSummary = buildSummary(screen, rows, '');
|
|
210
|
+
const csv = renderCsv(tempSummary, rows, specLink);
|
|
211
|
+
const csvPath = writeCsv(cwd, screen, csv);
|
|
212
|
+
const wb = renderXlsx(tempSummary, rows, specLink);
|
|
213
|
+
await writeXlsx(cwd, screen, wb);
|
|
214
|
+
return buildSummary(screen, rows, path.relative(cwd, csvPath));
|
|
215
|
+
} catch (err) {
|
|
216
|
+
console.error(`${COLOR.red}Error exporting ${screen}:${COLOR.reset} ${err instanceof Error ? err.message : err}`);
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ----------------------------------------------------------------------------
|
|
222
|
+
// Reporter
|
|
223
|
+
// ----------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
function printPreflightTable(checks: PreflightCheck[]): void {
|
|
226
|
+
log(`\n${COLOR.bold}Pre-flight source check${COLOR.reset}`);
|
|
227
|
+
log(`${COLOR.gray}Columns: feature | test-data | selectors | .spec.ts | test-result.json${COLOR.reset}\n`);
|
|
228
|
+
|
|
229
|
+
const ok = (b: boolean) => (b ? `${COLOR.green}ā${COLOR.reset}` : `${COLOR.red}ā${COLOR.reset}`);
|
|
230
|
+
|
|
231
|
+
for (const c of checks) {
|
|
232
|
+
log(
|
|
233
|
+
` ${c.screen.padEnd(20)} ${ok(c.featureOk)} ${ok(c.testDataOk)} ${ok(c.selectorsOk)} ${ok(c.specOk)} ${ok(c.resultsOk)}`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
log('');
|
|
237
|
+
|
|
238
|
+
// Show suggestions for any blocking misses
|
|
239
|
+
const blockers = checks.filter(hasBlockingMissing);
|
|
240
|
+
if (blockers.length > 0) {
|
|
241
|
+
log(`${COLOR.yellow}Blocking issues:${COLOR.reset}`);
|
|
242
|
+
for (const b of blockers) {
|
|
243
|
+
log(` ${COLOR.bold}${b.screen}${COLOR.reset}`);
|
|
244
|
+
for (const m of b.missing) log(` - ${COLOR.red}ā${COLOR.reset} ${m}`);
|
|
245
|
+
for (const s of b.suggestions) log(` ${COLOR.cyan}ā ${s}${COLOR.reset}`);
|
|
246
|
+
}
|
|
247
|
+
log('');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Warn about optional misses (results.json)
|
|
251
|
+
const warnings = checks.filter((c) => !hasBlockingMissing(c) && !c.resultsOk);
|
|
252
|
+
if (warnings.length > 0) {
|
|
253
|
+
log(`${COLOR.yellow}Warnings (optional missing):${COLOR.reset}`);
|
|
254
|
+
for (const w of warnings) {
|
|
255
|
+
log(` ${w.screen}: test-result.json missing ā execution columns will be empty`);
|
|
256
|
+
}
|
|
257
|
+
log('');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function printSummaryTable(summaries: ScreenSummary[]): void {
|
|
262
|
+
log(`\n${COLOR.bold}Delivery export complete${COLOR.reset}`);
|
|
263
|
+
log('');
|
|
264
|
+
log(' Screen TCs Passed Failed Pending N/A File');
|
|
265
|
+
log(' ' + '-'.repeat(80));
|
|
266
|
+
for (const s of summaries) {
|
|
267
|
+
log(
|
|
268
|
+
` ${s.screen.padEnd(20)} ${String(s.total).padStart(3)} ${String(s.passed).padStart(6)} ${String(s.failed).padStart(6)} ${String(s.pending).padStart(7)} ${String(s.na).padStart(3)} ${s.outputFile}`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
log('');
|
|
272
|
+
|
|
273
|
+
const totalNotCompiled = summaries.reduce((a, s) => a + s.notCompiled, 0);
|
|
274
|
+
if (totalNotCompiled > 0) {
|
|
275
|
+
log(`${COLOR.yellow}Note: ${totalNotCompiled} scenario(s) flagged "Not compiled" in CSV. Re-run \`sungen generate\` to compile them.${COLOR.reset}\n`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ----------------------------------------------------------------------------
|
|
280
|
+
// Command registration
|
|
281
|
+
// ----------------------------------------------------------------------------
|
|
282
|
+
|
|
283
|
+
export function registerDeliveryCommand(program: Command): void {
|
|
284
|
+
program
|
|
285
|
+
.command('delivery')
|
|
286
|
+
.description('Export Gherkin + Playwright results ā CSV test case deliverable')
|
|
287
|
+
.argument('[screens...]', 'Specific screen names. Omit to process all screens.')
|
|
288
|
+
.option('--skip-preflight', 'Skip pre-flight checks (not recommended)')
|
|
289
|
+
.option('--continue-on-missing', 'Skip screens with blocking misses instead of aborting')
|
|
290
|
+
.action(async (screens: string[], options: { skipPreflight?: boolean; continueOnMissing?: boolean }) => {
|
|
291
|
+
try {
|
|
292
|
+
const cwd = process.cwd();
|
|
293
|
+
|
|
294
|
+
// 1. Scope detection
|
|
295
|
+
let targetScreens: string[];
|
|
296
|
+
if (screens && screens.length > 0) {
|
|
297
|
+
targetScreens = screens;
|
|
298
|
+
} else {
|
|
299
|
+
targetScreens = listAllScreens(cwd);
|
|
300
|
+
if (targetScreens.length === 0) {
|
|
301
|
+
console.error(`${COLOR.red}No screens found in qa/screens/${COLOR.reset}`);
|
|
302
|
+
process.exit(1);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
log(`${COLOR.bold}sungen delivery${COLOR.reset} ā exporting ${targetScreens.length} screen(s): ${targetScreens.join(', ')}\n`);
|
|
307
|
+
|
|
308
|
+
// 2. Pre-flight
|
|
309
|
+
let toExport: string[];
|
|
310
|
+
if (options.skipPreflight) {
|
|
311
|
+
toExport = targetScreens;
|
|
312
|
+
} else {
|
|
313
|
+
const checks = targetScreens.map((s) => runPreflight(cwd, s));
|
|
314
|
+
printPreflightTable(checks);
|
|
315
|
+
|
|
316
|
+
const blockers = checks.filter(hasBlockingMissing);
|
|
317
|
+
if (blockers.length > 0) {
|
|
318
|
+
if (options.continueOnMissing) {
|
|
319
|
+
toExport = checks.filter((c) => !hasBlockingMissing(c)).map((c) => c.screen);
|
|
320
|
+
log(`${COLOR.yellow}Continuing with ${toExport.length} ready screen(s).${COLOR.reset}\n`);
|
|
321
|
+
} else {
|
|
322
|
+
console.error(
|
|
323
|
+
`${COLOR.red}Aborted:${COLOR.reset} ${blockers.length} screen(s) have blocking issues.\n` +
|
|
324
|
+
`Run the suggested commands above, or use ${COLOR.cyan}--continue-on-missing${COLOR.reset} to skip them.`
|
|
325
|
+
);
|
|
326
|
+
process.exit(1);
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
toExport = checks.map((c) => c.screen);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 3. Export
|
|
334
|
+
const env = getEnvironment(cwd);
|
|
335
|
+
const summaries: ScreenSummary[] = [];
|
|
336
|
+
for (const screen of toExport) {
|
|
337
|
+
const s = await exportScreen(cwd, screen, env);
|
|
338
|
+
if (s) summaries.push(s);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 4. Summary
|
|
342
|
+
printSummaryTable(summaries);
|
|
343
|
+
} catch (err) {
|
|
344
|
+
console.error(`${COLOR.red}Fatal:${COLOR.reset} ${err instanceof Error ? err.message : err}`);
|
|
345
|
+
process.exit(1);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { spawnSync } from 'child_process';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `sungen update` does two jobs in sequence:
|
|
6
|
+
*
|
|
7
|
+
* 1. Reinstall `@sun-asterisk/sungen@latest` globally via npm so the bundled
|
|
8
|
+
* AI templates are refreshed.
|
|
9
|
+
* 2. Re-execute `sungen update` with the env var `SUNGEN_UPDATE_SKIP_NPM=1`
|
|
10
|
+
* so the AI rules / commands / skills inside the project get overwritten
|
|
11
|
+
* from the *new* templates.
|
|
12
|
+
*
|
|
13
|
+
* We use an environment variable (not a CLI flag) for the internal hand-off
|
|
14
|
+
* because Commander throws "unknown option" if the currently-installed
|
|
15
|
+
* published version doesn't recognise the flag yet. Env vars are silently
|
|
16
|
+
* ignored by older versions ā the worst case is one extra (idempotent) npm
|
|
17
|
+
* install, never a crash.
|
|
18
|
+
*
|
|
19
|
+
* The public `--skip-npm-install` flag is still available for users who
|
|
20
|
+
* already installed the binary by other means (CI pipelines, corporate
|
|
21
|
+
* mirror, manual download) and only want to refresh the project AI assets.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const SKIP_NPM_ENV = 'SUNGEN_UPDATE_SKIP_NPM';
|
|
2
25
|
|
|
3
26
|
export function registerUpdateCommand(program: Command): void {
|
|
4
27
|
program
|
|
5
28
|
.command('update')
|
|
6
|
-
.description(
|
|
29
|
+
.description(
|
|
30
|
+
'Reinstall @sun-asterisk/sungen@latest + refresh AI rules, commands, and skills',
|
|
31
|
+
)
|
|
7
32
|
.option('--dry-run', 'Show what would be updated without making changes')
|
|
8
|
-
.
|
|
33
|
+
.option(
|
|
34
|
+
'--skip-npm-install',
|
|
35
|
+
'Skip the `npm install -g @sun-asterisk/sungen@latest` step (refresh project AI assets only)',
|
|
36
|
+
false,
|
|
37
|
+
)
|
|
38
|
+
.action(async (options: { dryRun?: boolean; skipNpmInstall?: boolean }) => {
|
|
9
39
|
try {
|
|
40
|
+
const skipNpm =
|
|
41
|
+
Boolean(options.skipNpmInstall) || process.env[SKIP_NPM_ENV] === '1';
|
|
42
|
+
|
|
43
|
+
if (!skipNpm) {
|
|
44
|
+
reinstallLatestSungen();
|
|
45
|
+
printCurrentVersion();
|
|
46
|
+
reExecUpdateForAIAssets(options.dryRun ?? false);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
10
50
|
const { AIRulesUpdater } = require('../../orchestrator/ai-rules-updater');
|
|
11
51
|
const updater = new AIRulesUpdater(process.cwd());
|
|
12
52
|
await updater.update(options.dryRun ?? false);
|
|
@@ -16,3 +56,45 @@ export function registerUpdateCommand(program: Command): void {
|
|
|
16
56
|
}
|
|
17
57
|
});
|
|
18
58
|
}
|
|
59
|
+
|
|
60
|
+
function reinstallLatestSungen(): void {
|
|
61
|
+
console.log('š¦ Installing @sun-asterisk/sungen@latest...');
|
|
62
|
+
const result = spawnSync('npm', ['install', '-g', '@sun-asterisk/sungen@latest'], {
|
|
63
|
+
stdio: 'inherit',
|
|
64
|
+
shell: true,
|
|
65
|
+
});
|
|
66
|
+
if (result.status !== 0) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
'npm install -g @sun-asterisk/sungen@latest failed. Run it manually or check your npm setup.',
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function printCurrentVersion(): void {
|
|
74
|
+
console.log('\nš Installed version:');
|
|
75
|
+
spawnSync('sungen', ['--version'], { stdio: 'inherit', shell: true });
|
|
76
|
+
console.log('');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function reExecUpdateForAIAssets(dryRun: boolean): void {
|
|
80
|
+
const args = ['update'];
|
|
81
|
+
if (dryRun) args.push('--dry-run');
|
|
82
|
+
|
|
83
|
+
const result = spawnSync('sungen', args, {
|
|
84
|
+
stdio: 'inherit',
|
|
85
|
+
shell: true,
|
|
86
|
+
env: { ...process.env, [SKIP_NPM_ENV]: '1' },
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (result.status !== 0) {
|
|
90
|
+
console.error(
|
|
91
|
+
'\nā ļø AI-rules refresh step returned a non-zero exit code.\n' +
|
|
92
|
+
` If the newly installed version is older and didn't recognise this flow,\n` +
|
|
93
|
+
' run the refresh manually:\n\n' +
|
|
94
|
+
' sungen update --skip-npm-install' +
|
|
95
|
+
(dryRun ? ' --dry-run' : '') +
|
|
96
|
+
'\n',
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
process.exit(result.status ?? 0);
|
|
100
|
+
}
|
package/src/cli/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { registerAddCommand } from './commands/add';
|
|
|
10
10
|
import { registerGenerateCommand } from './commands/generate';
|
|
11
11
|
import { registerMakeauthCommand } from './commands/makeauth';
|
|
12
12
|
import { registerUpdateCommand } from './commands/update';
|
|
13
|
+
import { registerDeliveryCommand } from './commands/delivery';
|
|
13
14
|
|
|
14
15
|
async function main() {
|
|
15
16
|
const program = new Command();
|
|
@@ -17,18 +18,19 @@ async function main() {
|
|
|
17
18
|
program
|
|
18
19
|
.name('sungen')
|
|
19
20
|
.description('Deterministic E2E Test Compiler ā Gherkin + Selectors ā Playwright')
|
|
20
|
-
.version('2.4.
|
|
21
|
+
.version('2.4.6');
|
|
21
22
|
|
|
22
23
|
// Global options
|
|
23
24
|
program
|
|
24
25
|
.option('-v, --verbose', 'Enable verbose logging');
|
|
25
26
|
|
|
26
|
-
// Register commands (
|
|
27
|
+
// Register commands (6)
|
|
27
28
|
registerInitCommand(program);
|
|
28
29
|
registerAddCommand(program);
|
|
29
30
|
registerGenerateCommand(program);
|
|
30
31
|
registerMakeauthCommand(program);
|
|
31
32
|
registerUpdateCommand(program);
|
|
33
|
+
registerDeliveryCommand(program);
|
|
32
34
|
|
|
33
35
|
await program.parseAsync(process.argv);
|
|
34
36
|
}
|