@auraindustry/aurajs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,322 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { ConformanceSuiteError, runConformanceSuite } from './conformance.mjs';
7
+
8
+ const VALID_MODES = new Set(['shim', 'native', 'both']);
9
+
10
+ function printUsage() {
11
+ console.log('');
12
+ console.log(' Usage: aura conformance [--mode shim|native|both] [--json] [--inspector-snapshot] [--runtime-inspector-snapshot-path <path>] [--workspace-root <path>] [--report-path <path>] [--runtime-observability-report-path <path>] [--phaser-vertical-slice-evidence-report-path <path>]');
13
+ console.log('');
14
+ }
15
+
16
+ function parseArgs(argv) {
17
+ const parsed = {
18
+ mode: 'shim',
19
+ help: false,
20
+ json: false,
21
+ inspectorSnapshot: false,
22
+ runtimeInspectorSnapshotPath: null,
23
+ workspaceRoot: null,
24
+ reportPath: null,
25
+ runtimeObservabilityReportPath: null,
26
+ phaserVerticalSliceEvidenceReportPath: null,
27
+ };
28
+
29
+ for (let i = 0; i < argv.length; i += 1) {
30
+ const token = argv[i];
31
+
32
+ if (token === '--help' || token === '-h') {
33
+ parsed.help = true;
34
+ continue;
35
+ }
36
+
37
+ if (token === '--json') {
38
+ parsed.json = true;
39
+ continue;
40
+ }
41
+
42
+ if (token === '--inspector-snapshot') {
43
+ parsed.inspectorSnapshot = true;
44
+ continue;
45
+ }
46
+
47
+ if (token === '--runtime-inspector-snapshot-path') {
48
+ const nextValue = argv[i + 1];
49
+ if (!nextValue) {
50
+ throw new ConformanceSuiteError('Missing value for --runtime-inspector-snapshot-path.', {});
51
+ }
52
+ parsed.runtimeInspectorSnapshotPath = nextValue;
53
+ i += 1;
54
+ continue;
55
+ }
56
+
57
+ if (token === '--workspace-root') {
58
+ const nextValue = argv[i + 1];
59
+ if (!nextValue) {
60
+ throw new ConformanceSuiteError('Missing value for --workspace-root.', {});
61
+ }
62
+ parsed.workspaceRoot = nextValue;
63
+ i += 1;
64
+ continue;
65
+ }
66
+
67
+ if (token === '--report-path') {
68
+ const nextValue = argv[i + 1];
69
+ if (!nextValue) {
70
+ throw new ConformanceSuiteError('Missing value for --report-path.', {});
71
+ }
72
+ parsed.reportPath = nextValue;
73
+ i += 1;
74
+ continue;
75
+ }
76
+
77
+ if (token === '--runtime-observability-report-path') {
78
+ const nextValue = argv[i + 1];
79
+ if (!nextValue) {
80
+ throw new ConformanceSuiteError('Missing value for --runtime-observability-report-path.', {});
81
+ }
82
+ parsed.runtimeObservabilityReportPath = nextValue;
83
+ i += 1;
84
+ continue;
85
+ }
86
+
87
+ if (token === '--phaser-vertical-slice-evidence-report-path') {
88
+ const nextValue = argv[i + 1];
89
+ if (!nextValue) {
90
+ throw new ConformanceSuiteError('Missing value for --phaser-vertical-slice-evidence-report-path.', {});
91
+ }
92
+ parsed.phaserVerticalSliceEvidenceReportPath = nextValue;
93
+ i += 1;
94
+ continue;
95
+ }
96
+
97
+ if (token === '--mode') {
98
+ const nextValue = argv[i + 1];
99
+ if (!nextValue) {
100
+ throw new ConformanceSuiteError('Missing value for --mode.', {
101
+ validModes: [...VALID_MODES],
102
+ });
103
+ }
104
+
105
+ const normalized = String(nextValue).toLowerCase();
106
+ if (!VALID_MODES.has(normalized)) {
107
+ throw new ConformanceSuiteError(`Unknown conformance mode: ${nextValue}`, {
108
+ validModes: [...VALID_MODES],
109
+ });
110
+ }
111
+
112
+ parsed.mode = normalized;
113
+ i += 1;
114
+ continue;
115
+ }
116
+
117
+ throw new ConformanceSuiteError(`Unknown conformance option: ${token}`, {
118
+ validModes: [...VALID_MODES],
119
+ });
120
+ }
121
+
122
+ return parsed;
123
+ }
124
+
125
+ function formatJsonResult({
126
+ ok,
127
+ mode,
128
+ reportPath,
129
+ optionalModuleReadiness = null,
130
+ runtimeObservabilityReportPath = null,
131
+ runtimeInspectorSnapshotReportPath = null,
132
+ phaserVerticalSliceEvidenceReportPath = null,
133
+ phaserVerticalSliceEvidence = null,
134
+ summary,
135
+ runtimeCacheDiagnostics = null,
136
+ runtimeInspectorSnapshot = null,
137
+ failedCases = [],
138
+ hostBinary = null,
139
+ error = null,
140
+ }) {
141
+ return {
142
+ ok,
143
+ mode,
144
+ reportPath,
145
+ optionalModuleReadiness,
146
+ runtimeObservabilityReportPath,
147
+ runtimeInspectorSnapshotReportPath,
148
+ phaserVerticalSliceEvidenceReportPath,
149
+ phaserVerticalSliceEvidence,
150
+ summary,
151
+ runtimeCacheDiagnostics,
152
+ runtimeInspectorSnapshot,
153
+ timings: summary?.byMode || {},
154
+ failedCases,
155
+ hostBinary,
156
+ error,
157
+ };
158
+ }
159
+
160
+ export function formatHostBinaryLine(hostBinary) {
161
+ if (!hostBinary || typeof hostBinary !== 'object') return null;
162
+ const path = typeof hostBinary.path === 'string' ? hostBinary.path : null;
163
+ const source = typeof hostBinary.source === 'string' ? hostBinary.source : null;
164
+ if (!path && !source) return null;
165
+ if (path && source) return ` Host binary: ${source} (${path})`;
166
+ if (path) return ` Host binary: ${path}`;
167
+ return ` Host binary source: ${source}`;
168
+ }
169
+
170
+ export async function runConformanceCommand(argv, io = console) {
171
+ const args = parseArgs(argv);
172
+
173
+ if (args.help) {
174
+ printUsage();
175
+ return 0;
176
+ }
177
+
178
+ try {
179
+ const report = await runConformanceSuite({
180
+ projectRoot: process.cwd(),
181
+ mode: args.mode,
182
+ workspaceRoot: args.workspaceRoot,
183
+ reportPath: args.reportPath,
184
+ runtimeObservabilityReportPath: args.runtimeObservabilityReportPath,
185
+ runtimeInspectorSnapshotEnabled: args.inspectorSnapshot,
186
+ runtimeInspectorSnapshotReportPath: args.runtimeInspectorSnapshotPath,
187
+ phaserVerticalSliceEvidenceReportPath: args.phaserVerticalSliceEvidenceReportPath,
188
+ });
189
+
190
+ if (args.json) {
191
+ io.log(JSON.stringify(formatJsonResult({
192
+ ok: true,
193
+ mode: report.mode,
194
+ reportPath: report.reportPath,
195
+ optionalModuleReadiness: report.optionalModuleReadiness || null,
196
+ runtimeObservabilityReportPath: report.runtimeObservabilityReportPath || null,
197
+ runtimeInspectorSnapshotReportPath: report.runtimeInspectorSnapshotReportPath || null,
198
+ phaserVerticalSliceEvidenceReportPath: report.phaserVerticalSliceEvidenceReportPath || null,
199
+ phaserVerticalSliceEvidence: report.phaserVerticalSliceEvidence || null,
200
+ summary: report.summary,
201
+ runtimeCacheDiagnostics: report.runtimeCacheDiagnostics || null,
202
+ runtimeInspectorSnapshot: report.runtimeInspectorSnapshot || null,
203
+ hostBinary: report.hostBinary || null,
204
+ }), null, 2));
205
+ return 0;
206
+ }
207
+
208
+ io.log('');
209
+ io.log(' aura conformance: PASS');
210
+ io.log(` Mode: ${report.mode}`);
211
+ for (const [modeName, modeSummary] of Object.entries(report.summary.byMode || {})) {
212
+ io.log(` ${modeName}: ${modeSummary.passed}/${modeSummary.total} (${modeSummary.durationMs}ms)`);
213
+ }
214
+ io.log(` Cases: ${report.summary.passed}/${report.summary.total}`);
215
+ const hostBinaryLine = formatHostBinaryLine(report.hostBinary);
216
+ if (hostBinaryLine) {
217
+ io.log(hostBinaryLine);
218
+ }
219
+ io.log(` Report: ${report.reportPath}`);
220
+ if (report.runtimeInspectorSnapshotReport?.enabled) {
221
+ io.log(` Runtime inspector snapshot: ${report.runtimeInspectorSnapshotReportPath}`);
222
+ }
223
+ io.log('');
224
+ return 0;
225
+ } catch (error) {
226
+ if (error instanceof ConformanceSuiteError) {
227
+ const reportPath = error.details?.reportPath ? resolve(error.details.reportPath) : null;
228
+ const failedCases = Array.isArray(error.details?.failedCases) ? error.details.failedCases : [];
229
+ let summary = null;
230
+ let hostBinary = null;
231
+ let runtimeCacheDiagnostics = null;
232
+ let runtimeObservabilityReportPath = null;
233
+ let runtimeInspectorSnapshotReportPath = null;
234
+ let phaserVerticalSliceEvidenceReportPath = null;
235
+ let phaserVerticalSliceEvidence = null;
236
+ let runtimeInspectorSnapshot = null;
237
+ let optionalModuleReadiness = null;
238
+
239
+ if (reportPath && existsSync(reportPath)) {
240
+ try {
241
+ const report = JSON.parse(readFileSync(reportPath, 'utf8'));
242
+ summary = report.summary || null;
243
+ hostBinary = report.hostBinary || null;
244
+ runtimeCacheDiagnostics = report.runtimeCacheDiagnostics || null;
245
+ runtimeObservabilityReportPath = report.runtimeObservability?.reportPath || null;
246
+ runtimeInspectorSnapshotReportPath = report.runtimeInspectorSnapshotReport?.reportPath || null;
247
+ phaserVerticalSliceEvidenceReportPath = report.phaserVerticalSliceEvidence?.reportPath || null;
248
+ phaserVerticalSliceEvidence = report.phaserVerticalSliceEvidence || null;
249
+ runtimeInspectorSnapshot = report.runtimeInspectorSnapshot || null;
250
+ optionalModuleReadiness = report.optionalModuleReadiness || null;
251
+ } catch {
252
+ summary = null;
253
+ }
254
+ }
255
+
256
+ if (args.json) {
257
+ io.log(JSON.stringify(formatJsonResult({
258
+ ok: false,
259
+ mode: args.mode,
260
+ reportPath,
261
+ optionalModuleReadiness,
262
+ runtimeObservabilityReportPath,
263
+ runtimeInspectorSnapshotReportPath,
264
+ phaserVerticalSliceEvidenceReportPath,
265
+ phaserVerticalSliceEvidence,
266
+ summary,
267
+ runtimeCacheDiagnostics,
268
+ runtimeInspectorSnapshot,
269
+ failedCases,
270
+ hostBinary,
271
+ error: error.message,
272
+ }), null, 2));
273
+ } else {
274
+ io.error('');
275
+ io.error(' aura conformance: FAIL');
276
+ io.error(` ${error.message}`);
277
+ const hostBinaryLine = formatHostBinaryLine(hostBinary);
278
+ if (hostBinaryLine) {
279
+ io.error(hostBinaryLine);
280
+ }
281
+ if (reportPath) {
282
+ io.error(` Report: ${reportPath}`);
283
+ }
284
+ io.error('');
285
+ }
286
+ return 1;
287
+ }
288
+
289
+ if (args.json) {
290
+ io.log(JSON.stringify(formatJsonResult({
291
+ ok: false,
292
+ mode: args.mode,
293
+ reportPath: null,
294
+ optionalModuleReadiness: null,
295
+ runtimeObservabilityReportPath: null,
296
+ runtimeInspectorSnapshotReportPath: null,
297
+ phaserVerticalSliceEvidenceReportPath: null,
298
+ phaserVerticalSliceEvidence: null,
299
+ summary: null,
300
+ runtimeCacheDiagnostics: null,
301
+ runtimeInspectorSnapshot: null,
302
+ failedCases: [],
303
+ error: error.message,
304
+ }), null, 2));
305
+ } else {
306
+ io.error('');
307
+ io.error(` aura conformance error: ${error.message}`);
308
+ io.error('');
309
+ }
310
+ return 1;
311
+ }
312
+ }
313
+
314
+ async function main() {
315
+ const exitCode = await runConformanceCommand(process.argv.slice(2));
316
+ process.exitCode = exitCode;
317
+ }
318
+
319
+ const executedAsEntrypoint = process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1]);
320
+ if (executedAsEntrypoint) {
321
+ void main();
322
+ }