@playcraft/build 0.1.88 → 0.1.89
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/validation/html-validator.d.ts +0 -3
- package/dist/validation/html-validator.js +3 -3
- package/dist/validation/index.d.ts +0 -4
- package/dist/validation/index.js +0 -4
- package/dist/validation/package-validator.js +51 -3
- package/dist/validation/source-scanner.d.ts +0 -11
- package/dist/validation/source-scanner.js +2 -32
- package/dist/validation/types.d.ts +2 -150
- package/dist/validation/types.js +1 -1
- package/dist/validation/validation-runner.d.ts +1 -11
- package/dist/validation/validation-runner.js +1 -31
- package/dist/validation/zip-reader.d.ts +0 -1
- package/dist/validation/zip-reader.js +3 -11
- package/package.json +1 -1
- package/dist/validation/artifact-qa.d.ts +0 -44
- package/dist/validation/artifact-qa.js +0 -170
- package/dist/validation/artifact-rules.d.ts +0 -28
- package/dist/validation/artifact-rules.js +0 -440
- package/dist/validation/artifact.d.ts +0 -14
- package/dist/validation/artifact.js +0 -188
- package/dist/validation/runtime-load.d.ts +0 -89
- package/dist/validation/runtime-load.js +0 -654
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { ChannelRuleProfile, ValidationContext, ValidationResult } from './types.js';
|
|
2
2
|
export declare function validateHtmlArtifact(context: ValidationContext, profile?: ChannelRuleProfile): Promise<ValidationResult[]>;
|
|
3
|
-
export declare function collectExternalResources(html: string): string[];
|
|
4
|
-
export declare function collectLocalResourceReferences(html: string): string[];
|
|
5
|
-
export declare function isAllowedExternalResource(url: string, allowedPatterns?: string[]): boolean;
|
|
@@ -87,10 +87,10 @@ function resultFromBoolean(rule, passed, file, evidence) {
|
|
|
87
87
|
confidence: rule.confidence,
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
function collectExternalResources(html) {
|
|
91
91
|
return collectUrls(html).filter((url) => /^https?:\/\//i.test(url) || /^\/\//.test(url));
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
function collectLocalResourceReferences(html) {
|
|
94
94
|
return collectUrls(html).filter((url) => {
|
|
95
95
|
if (isInlineOrSpecialUrl(url))
|
|
96
96
|
return false;
|
|
@@ -114,7 +114,7 @@ function collectUrls(html) {
|
|
|
114
114
|
function isInlineOrSpecialUrl(url) {
|
|
115
115
|
return /^(data:|blob:|javascript:|mailto:|tel:|about:)/i.test(url);
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
function isAllowedExternalResource(url, allowedPatterns) {
|
|
118
118
|
if (!allowedPatterns || allowedPatterns.length === 0) {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './artifact.js';
|
|
3
|
-
export * from './artifact-rules.js';
|
|
4
|
-
export * from './artifact-qa.js';
|
|
5
|
-
export * from './runtime-load.js';
|
|
6
2
|
export * from './profiles.js';
|
|
7
3
|
export * from './html-validator.js';
|
|
8
4
|
export * from './package-validator.js';
|
package/dist/validation/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './artifact.js';
|
|
3
|
-
export * from './artifact-rules.js';
|
|
4
|
-
export * from './artifact-qa.js';
|
|
5
|
-
export * from './runtime-load.js';
|
|
6
2
|
export * from './profiles.js';
|
|
7
3
|
export * from './html-validator.js';
|
|
8
4
|
export * from './package-validator.js';
|
|
@@ -2,7 +2,6 @@ import fs from 'fs/promises';
|
|
|
2
2
|
import fsSync from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { getChannelRuleProfile } from './profiles.js';
|
|
5
|
-
import { directorySize, listDirectoryEntries } from './artifact.js';
|
|
6
5
|
import { SimpleZipReader } from './zip-reader.js';
|
|
7
6
|
const FIVE_MB = 5 * 1024 * 1024;
|
|
8
7
|
export async function validateDeliveryPackage(context, profile = getChannelRuleProfile(context.channel)) {
|
|
@@ -66,12 +65,12 @@ export async function validateDeliveryPackage(context, profile = getChannelRuleP
|
|
|
66
65
|
async function readPackageInventory(packagePath) {
|
|
67
66
|
const stat = await fs.stat(packagePath);
|
|
68
67
|
if (stat.isDirectory()) {
|
|
69
|
-
const entries = await
|
|
68
|
+
const entries = await readDirectoryEntries(packagePath);
|
|
70
69
|
return {
|
|
71
70
|
packagePath,
|
|
72
71
|
entries,
|
|
73
72
|
readText: (entryPath) => readTextFromDirectorySyncUnsupported(packagePath, entryPath),
|
|
74
|
-
size: await
|
|
73
|
+
size: await calculateDirectorySize(packagePath),
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
76
|
const buffer = await fs.readFile(packagePath);
|
|
@@ -83,6 +82,38 @@ async function readPackageInventory(packagePath) {
|
|
|
83
82
|
size: buffer.length,
|
|
84
83
|
};
|
|
85
84
|
}
|
|
85
|
+
async function readDirectoryEntries(dir) {
|
|
86
|
+
const entries = [];
|
|
87
|
+
const walk = async (current) => {
|
|
88
|
+
const dirEntries = await fs.readdir(current, { withFileTypes: true });
|
|
89
|
+
for (const entry of dirEntries) {
|
|
90
|
+
const fullPath = path.join(current, entry.name);
|
|
91
|
+
const relative = path.relative(dir, fullPath).replace(/\\/g, '/');
|
|
92
|
+
if (entry.isDirectory()) {
|
|
93
|
+
entries.push({
|
|
94
|
+
path: `${relative}/`,
|
|
95
|
+
compressedSize: 0,
|
|
96
|
+
uncompressedSize: 0,
|
|
97
|
+
compressionMethod: 0,
|
|
98
|
+
isDirectory: true,
|
|
99
|
+
});
|
|
100
|
+
await walk(fullPath);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const stat = await fs.stat(fullPath);
|
|
104
|
+
entries.push({
|
|
105
|
+
path: relative,
|
|
106
|
+
compressedSize: stat.size,
|
|
107
|
+
uncompressedSize: stat.size,
|
|
108
|
+
compressionMethod: 0,
|
|
109
|
+
isDirectory: false,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
await walk(dir);
|
|
115
|
+
return entries;
|
|
116
|
+
}
|
|
86
117
|
function readTextFromDirectorySyncUnsupported(_packagePath, _entryPath) {
|
|
87
118
|
const filePath = path.join(_packagePath, _entryPath);
|
|
88
119
|
try {
|
|
@@ -92,6 +123,23 @@ function readTextFromDirectorySyncUnsupported(_packagePath, _entryPath) {
|
|
|
92
123
|
return null;
|
|
93
124
|
}
|
|
94
125
|
}
|
|
126
|
+
async function calculateDirectorySize(dir) {
|
|
127
|
+
let total = 0;
|
|
128
|
+
const walk = async (current) => {
|
|
129
|
+
const entries = await fs.readdir(current, { withFileTypes: true });
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
const fullPath = path.join(current, entry.name);
|
|
132
|
+
if (entry.isDirectory()) {
|
|
133
|
+
await walk(fullPath);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
total += (await fs.stat(fullPath)).size;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
await walk(dir);
|
|
141
|
+
return total;
|
|
142
|
+
}
|
|
95
143
|
function validateZipLikePackage(channel, inventory) {
|
|
96
144
|
const paths = new Set(inventory.entries.map((entry) => entry.path));
|
|
97
145
|
return [
|
|
@@ -2,14 +2,3 @@ import type { Platform } from '../types.js';
|
|
|
2
2
|
import type { ValidationContext, ValidationResult } from './types.js';
|
|
3
3
|
export declare function scanSourceForCompliance(context: ValidationContext): Promise<ValidationResult[]>;
|
|
4
4
|
export declare function scanSourceForChannels(context: Omit<ValidationContext, 'channel'>, channels: Platform[]): Promise<ValidationResult[]>;
|
|
5
|
-
export type SourcePatternPresence = {
|
|
6
|
-
/** Absolute path of the first source file where the pattern occurs in executable code. */
|
|
7
|
-
file: string;
|
|
8
|
-
line: number;
|
|
9
|
-
evidence: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Finds where each pattern first occurs in executable project source (comments and strings in
|
|
13
|
-
* JavaScript-like files are ignored, as in the compliance scan). Absent patterns are left out.
|
|
14
|
-
*/
|
|
15
|
-
export declare function findSourcePatterns(projectRoot: string, patterns: Record<string, RegExp>, sourceGlobs?: string[]): Promise<Map<string, SourcePatternPresence>>;
|
|
@@ -99,37 +99,6 @@ export async function scanSourceForChannels(context, channels) {
|
|
|
99
99
|
}
|
|
100
100
|
return results;
|
|
101
101
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Finds where each pattern first occurs in executable project source (comments and strings in
|
|
104
|
-
* JavaScript-like files are ignored, as in the compliance scan). Absent patterns are left out.
|
|
105
|
-
*/
|
|
106
|
-
export async function findSourcePatterns(projectRoot, patterns, sourceGlobs) {
|
|
107
|
-
const found = new Map();
|
|
108
|
-
const ids = Object.keys(patterns);
|
|
109
|
-
for (const filePath of await collectSourceFiles(projectRoot, sourceGlobs)) {
|
|
110
|
-
if (found.size === ids.length)
|
|
111
|
-
break;
|
|
112
|
-
let content;
|
|
113
|
-
try {
|
|
114
|
-
content = await fs.readFile(filePath, 'utf-8');
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
for (const id of ids) {
|
|
120
|
-
if (found.has(id))
|
|
121
|
-
continue;
|
|
122
|
-
const match = findExecutableSourcePattern(filePath, content, patterns[id]);
|
|
123
|
-
if (match)
|
|
124
|
-
found.set(id, {
|
|
125
|
-
file: filePath,
|
|
126
|
-
line: lineOfIndex(content, match.index),
|
|
127
|
-
evidence: trimEvidence(match.evidence),
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return found;
|
|
132
|
-
}
|
|
133
102
|
async function scanSourceFilesForChannel(context, sourceFiles, includeCommonPatterns) {
|
|
134
103
|
const results = [];
|
|
135
104
|
const requiredPatterns = CHANNEL_SOURCE_PATTERNS[context.channel] ?? [];
|
|
@@ -364,6 +333,7 @@ function maskJavaScriptLikeSource(content) {
|
|
|
364
333
|
maskRange(start, index);
|
|
365
334
|
return index;
|
|
366
335
|
};
|
|
336
|
+
let scanCode;
|
|
367
337
|
const scanTemplate = (start) => {
|
|
368
338
|
maskAt(start);
|
|
369
339
|
let index = start + 1;
|
|
@@ -391,7 +361,7 @@ function maskJavaScriptLikeSource(content) {
|
|
|
391
361
|
}
|
|
392
362
|
return index;
|
|
393
363
|
};
|
|
394
|
-
|
|
364
|
+
scanCode = (start, interpolation) => {
|
|
395
365
|
let index = start;
|
|
396
366
|
let braceDepth = interpolation ? 1 : 0;
|
|
397
367
|
while (index < content.length) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuildTool, EngineType, OutputFormat, Platform } from '../types.js';
|
|
2
|
-
export type ValidationStage = 'prebuild-source' | 'base-output' | 'html-artifact' | 'delivery-package' | 'runtime-
|
|
2
|
+
export type ValidationStage = 'prebuild-source' | 'base-output' | 'html-artifact' | 'delivery-package' | 'runtime-manual' | 'external-validator';
|
|
3
3
|
export type RuleSeverity = 'error' | 'warning' | 'info';
|
|
4
|
-
export type RuleStatus = 'pass' | 'fail' | 'warning' | 'manual' | 'external' | 'not-applicable'
|
|
4
|
+
export type RuleStatus = 'pass' | 'fail' | 'warning' | 'manual' | 'external' | 'not-applicable';
|
|
5
5
|
export type RuleConfidence = 'high' | 'medium' | 'low';
|
|
6
6
|
export type RuleOwner = 'playcraft-build' | 'playcraft-delivery' | 'devkit' | 'manual' | 'external';
|
|
7
7
|
export type DeliveryMode = 'single-html' | 'zip' | 'html-backed-zip' | 'fragment-assets' | 'mixed';
|
|
@@ -110,151 +110,3 @@ export interface ValidationReport {
|
|
|
110
110
|
manualChecklist: ManualChecklistItem[];
|
|
111
111
|
externalChecklist: ExternalChecklistItem[];
|
|
112
112
|
}
|
|
113
|
-
/** How a built artifact is stored on disk. */
|
|
114
|
-
export type ArtifactContainer = 'html' | 'zip' | 'directory';
|
|
115
|
-
/**
|
|
116
|
-
* How the playable is laid out inside its container: one self-contained HTML file,
|
|
117
|
-
* or an HTML entry with separate files (scripts, styles, assets).
|
|
118
|
-
*/
|
|
119
|
-
export type ArtifactLayout = 'single-html' | 'multi-file';
|
|
120
|
-
export interface ArtifactFile {
|
|
121
|
-
/** Path inside the artifact, `/`-separated, without a leading slash. */
|
|
122
|
-
path: string;
|
|
123
|
-
/** Uncompressed size in bytes. */
|
|
124
|
-
size: number;
|
|
125
|
-
}
|
|
126
|
-
export interface PlayableArtifact {
|
|
127
|
-
/** Absolute path of the file or directory that was read. */
|
|
128
|
-
sourcePath: string;
|
|
129
|
-
container: ArtifactContainer;
|
|
130
|
-
layout: ArtifactLayout;
|
|
131
|
-
/** Entry HTML path inside the artifact. */
|
|
132
|
-
entry: string;
|
|
133
|
-
files: ArtifactFile[];
|
|
134
|
-
/** Bytes on disk: the HTML or ZIP file size, or the sum of the directory's files. */
|
|
135
|
-
totalSize: number;
|
|
136
|
-
/** `sha256:<hex>`; stable for the same content regardless of where it is stored. */
|
|
137
|
-
digest: string;
|
|
138
|
-
readText(filePath: string): Promise<string | null>;
|
|
139
|
-
readBuffer(filePath: string): Promise<Buffer | null>;
|
|
140
|
-
}
|
|
141
|
-
export type ArtifactReadErrorCode = 'artifact_not_found' | 'artifact_unsupported' | 'artifact_zip_invalid' | 'artifact_entry_missing' | 'artifact_entry_ambiguous' | 'artifact_entry_invalid';
|
|
142
|
-
/**
|
|
143
|
-
* Artifact QA stages. Each stage runs on its own: it depends only on the artifact and its own
|
|
144
|
-
* options, never on another stage's results, and produces its own report.
|
|
145
|
-
* - `base`: static checks of the artifact files.
|
|
146
|
-
* - `channel`: the channel's existing `html-artifact` / `delivery-package` rules.
|
|
147
|
-
* - `runtime-load`: opens the artifact in a headless browser.
|
|
148
|
-
* - `source-hints`: scans project source; advisory only.
|
|
149
|
-
*/
|
|
150
|
-
export type QaStageId = 'base' | 'channel' | 'runtime-load' | 'source-hints';
|
|
151
|
-
export declare const QA_STAGES: readonly QaStageId[];
|
|
152
|
-
/**
|
|
153
|
-
* - `ran`: the stage ran; see its results.
|
|
154
|
-
* - `skipped`: the stage applies but could not run (e.g. no browser); the QA is incomplete.
|
|
155
|
-
* - `not-applicable`: the stage does not apply (e.g. channel rules for the `playcraft` profile).
|
|
156
|
-
*/
|
|
157
|
-
export type QaStageStatus = 'ran' | 'skipped' | 'not-applicable';
|
|
158
|
-
export interface QaStageReport {
|
|
159
|
-
stage: QaStageId;
|
|
160
|
-
status: QaStageStatus;
|
|
161
|
-
/** Why the stage did not run. */
|
|
162
|
-
reason?: string;
|
|
163
|
-
/** Advisory stages never affect the overall summary or exit code. */
|
|
164
|
-
advisory: boolean;
|
|
165
|
-
durationMs: number;
|
|
166
|
-
summary: ValidationSummary;
|
|
167
|
-
results: ValidationResult[];
|
|
168
|
-
manualChecklist: ManualChecklistItem[];
|
|
169
|
-
externalChecklist: ExternalChecklistItem[];
|
|
170
|
-
/** Stage-specific facts, e.g. the size limit used by `base`. */
|
|
171
|
-
details?: Record<string, unknown>;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Report of `runArtifactQa`: one report per stage, and an overall summary of the non-advisory
|
|
175
|
-
* stages that ran. Kept apart from `ValidationReport` so the existing delivery validation output,
|
|
176
|
-
* which is checked against strict schemas, stays unchanged.
|
|
177
|
-
*/
|
|
178
|
-
export interface ArtifactQaReport {
|
|
179
|
-
version: string;
|
|
180
|
-
rulesVersion: string;
|
|
181
|
-
profile: Platform;
|
|
182
|
-
artifact: {
|
|
183
|
-
sourcePath: string;
|
|
184
|
-
container: ArtifactContainer;
|
|
185
|
-
layout: ArtifactLayout;
|
|
186
|
-
entry: string;
|
|
187
|
-
digest: string;
|
|
188
|
-
totalSize: number;
|
|
189
|
-
fileCount: number;
|
|
190
|
-
};
|
|
191
|
-
summary: ValidationSummary;
|
|
192
|
-
/** A requested stage was skipped, so passing does not cover it. */
|
|
193
|
-
incomplete: boolean;
|
|
194
|
-
stages: QaStageReport[];
|
|
195
|
-
}
|
|
196
|
-
export interface ReadArtifactOptions {
|
|
197
|
-
/** Entry HTML path inside a ZIP or directory; defaults to `index.html`, then the only HTML file. */
|
|
198
|
-
entry?: string;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Browser access for runtime QA. `@playcraft/build` only defines this contract; hosts provide the
|
|
202
|
-
* implementation (the CLI uses playwright-core), so the build package does not depend on a browser.
|
|
203
|
-
*/
|
|
204
|
-
export interface RuntimeViewport {
|
|
205
|
-
width: number;
|
|
206
|
-
height: number;
|
|
207
|
-
deviceScaleFactor: number;
|
|
208
|
-
isMobile: boolean;
|
|
209
|
-
hasTouch: boolean;
|
|
210
|
-
}
|
|
211
|
-
export interface RuntimeResource {
|
|
212
|
-
body: Buffer;
|
|
213
|
-
contentType: string;
|
|
214
|
-
}
|
|
215
|
-
export interface RuntimePageOptions {
|
|
216
|
-
/** Origin the artifact is served from, e.g. `http://artifact.playcraft-qa.test`. */
|
|
217
|
-
origin: string;
|
|
218
|
-
/** Entry path inside the artifact, served at `${origin}/${entryPath}`. */
|
|
219
|
-
entryPath: string;
|
|
220
|
-
viewport: RuntimeViewport;
|
|
221
|
-
userAgent: string;
|
|
222
|
-
/** Runs before any page script. */
|
|
223
|
-
initScript: string;
|
|
224
|
-
/** Content-Security-Policy header sent with HTML responses. */
|
|
225
|
-
contentSecurityPolicy: string;
|
|
226
|
-
/** Serves a path inside the artifact; null means the file does not exist (404). */
|
|
227
|
-
resolve(pathname: string): Promise<RuntimeResource | null>;
|
|
228
|
-
/** Navigation timeout in milliseconds. */
|
|
229
|
-
timeoutMs: number;
|
|
230
|
-
}
|
|
231
|
-
export interface RuntimePageEvents {
|
|
232
|
-
consoleErrors: string[];
|
|
233
|
-
pageErrors: string[];
|
|
234
|
-
/** Requests for artifact files that do not exist, or that failed to load. */
|
|
235
|
-
failedRequests: Array<{
|
|
236
|
-
url: string;
|
|
237
|
-
reason: string;
|
|
238
|
-
}>;
|
|
239
|
-
/** Requests to any host other than the artifact origin; they are blocked, never sent. */
|
|
240
|
-
blockedRequests: string[];
|
|
241
|
-
/** Top-level navigations away from the entry; they are blocked, never followed. */
|
|
242
|
-
navigationAttempts: string[];
|
|
243
|
-
}
|
|
244
|
-
export interface RuntimePage {
|
|
245
|
-
/** Whether the entry document loaded. */
|
|
246
|
-
loaded: boolean;
|
|
247
|
-
loadError?: string;
|
|
248
|
-
events(): RuntimePageEvents;
|
|
249
|
-
/** Evaluates a JavaScript expression in the page and returns its JSON-serializable result. */
|
|
250
|
-
evaluate<T>(expression: string): Promise<T>;
|
|
251
|
-
/** Dispatches a real pointer click at viewport coordinates. */
|
|
252
|
-
click(x: number, y: number): Promise<void>;
|
|
253
|
-
/** PNG screenshot of the viewport. */
|
|
254
|
-
screenshot(): Promise<Buffer>;
|
|
255
|
-
wait(ms: number): Promise<void>;
|
|
256
|
-
close(): Promise<void>;
|
|
257
|
-
}
|
|
258
|
-
export interface BrowserDriver {
|
|
259
|
-
open(options: RuntimePageOptions): Promise<RuntimePage>;
|
|
260
|
-
}
|
package/dist/validation/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { Platform } from '../types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ValidationContext, ValidationReport, ValidationStage } from './types.js';
|
|
3
3
|
export declare const VALIDATION_REPORT_VERSION = "0.1.0";
|
|
4
4
|
export declare function runPlayableValidation(context: ValidationContext, stages?: ValidationStage[]): Promise<ValidationReport>;
|
|
5
5
|
export declare function runPlayableSourceValidationForChannels(context: Omit<ValidationContext, 'channel'>, channels: Platform[]): Promise<ValidationReport>;
|
|
6
|
-
export declare function summarize(results: ValidationResult[], manualChecklist: ManualChecklistItem[], externalChecklist: ExternalChecklistItem[]): ValidationSummary;
|
|
7
|
-
/** Builds the report of a QA stage that ran. */
|
|
8
|
-
export declare function ranStageReport(stage: QaStageId, startedAt: number, results: ValidationResult[], extra?: {
|
|
9
|
-
advisory?: boolean;
|
|
10
|
-
manualChecklist?: ManualChecklistItem[];
|
|
11
|
-
externalChecklist?: ExternalChecklistItem[];
|
|
12
|
-
details?: Record<string, unknown>;
|
|
13
|
-
}): QaStageReport;
|
|
14
|
-
/** Builds the report of a QA stage that did not run. */
|
|
15
|
-
export declare function idleStageReport(stage: QaStageId, status: 'skipped' | 'not-applicable', reason: string, advisory?: boolean): QaStageReport;
|
|
@@ -71,7 +71,7 @@ function buildExternalChecklist(rules, enabledStages) {
|
|
|
71
71
|
owner: rule.owner,
|
|
72
72
|
}));
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
function summarize(results, manualChecklist, externalChecklist) {
|
|
75
75
|
const errorCount = results.filter((result) => result.status === 'fail').length;
|
|
76
76
|
const warningCount = results.filter((result) => result.status === 'warning').length;
|
|
77
77
|
const manualCount = manualChecklist.length;
|
|
@@ -94,33 +94,3 @@ export function summarize(results, manualChecklist, externalChecklist) {
|
|
|
94
94
|
externalCount,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
/** Builds the report of a QA stage that ran. */
|
|
98
|
-
export function ranStageReport(stage, startedAt, results, extra = {}) {
|
|
99
|
-
const manualChecklist = extra.manualChecklist ?? [];
|
|
100
|
-
const externalChecklist = extra.externalChecklist ?? [];
|
|
101
|
-
return {
|
|
102
|
-
stage,
|
|
103
|
-
status: 'ran',
|
|
104
|
-
advisory: extra.advisory ?? false,
|
|
105
|
-
durationMs: Date.now() - startedAt,
|
|
106
|
-
summary: summarize(results, manualChecklist, externalChecklist),
|
|
107
|
-
results,
|
|
108
|
-
manualChecklist,
|
|
109
|
-
externalChecklist,
|
|
110
|
-
...(extra.details ? { details: extra.details } : {}),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/** Builds the report of a QA stage that did not run. */
|
|
114
|
-
export function idleStageReport(stage, status, reason, advisory = false) {
|
|
115
|
-
return {
|
|
116
|
-
stage,
|
|
117
|
-
status,
|
|
118
|
-
reason,
|
|
119
|
-
advisory,
|
|
120
|
-
durationMs: 0,
|
|
121
|
-
summary: summarize([], [], []),
|
|
122
|
-
results: [],
|
|
123
|
-
manualChecklist: [],
|
|
124
|
-
externalChecklist: [],
|
|
125
|
-
};
|
|
126
|
-
}
|
|
@@ -11,7 +11,6 @@ export declare class SimpleZipReader {
|
|
|
11
11
|
constructor(buffer: Buffer);
|
|
12
12
|
listEntries(): ZipEntryInfo[];
|
|
13
13
|
readEntryText(entryPath: string): string | null;
|
|
14
|
-
readEntryBuffer(entryPath: string): Buffer | null;
|
|
15
14
|
private readCentralDirectory;
|
|
16
15
|
private readEntryData;
|
|
17
16
|
private findEndOfCentralDirectory;
|
|
@@ -4,22 +4,14 @@ export class SimpleZipReader {
|
|
|
4
4
|
this.buffer = buffer;
|
|
5
5
|
}
|
|
6
6
|
listEntries() {
|
|
7
|
-
return this.readCentralDirectory().map((entry) =>
|
|
8
|
-
path: entry.path,
|
|
9
|
-
compressedSize: entry.compressedSize,
|
|
10
|
-
uncompressedSize: entry.uncompressedSize,
|
|
11
|
-
compressionMethod: entry.compressionMethod,
|
|
12
|
-
isDirectory: entry.isDirectory,
|
|
13
|
-
}));
|
|
7
|
+
return this.readCentralDirectory().map(({ localHeaderOffset: _offset, ...entry }) => entry);
|
|
14
8
|
}
|
|
15
9
|
readEntryText(entryPath) {
|
|
16
|
-
return this.readEntryBuffer(entryPath)?.toString('utf-8') ?? null;
|
|
17
|
-
}
|
|
18
|
-
readEntryBuffer(entryPath) {
|
|
19
10
|
const entry = this.readCentralDirectory().find((item) => item.path === entryPath);
|
|
20
11
|
if (!entry || entry.isDirectory)
|
|
21
12
|
return null;
|
|
22
|
-
|
|
13
|
+
const data = this.readEntryData(entry);
|
|
14
|
+
return data.toString('utf-8');
|
|
23
15
|
}
|
|
24
16
|
readCentralDirectory() {
|
|
25
17
|
if (this.entriesCache)
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Platform } from '../types.js';
|
|
2
|
-
import { type RuntimeLoadOptions } from './runtime-load.js';
|
|
3
|
-
import { type ArtifactQaReport, type BrowserDriver, type PlayableArtifact, type QaStageId, type QaStageReport } from './types.js';
|
|
4
|
-
export declare const ARTIFACT_QA_REPORT_VERSION = "0.2.0";
|
|
5
|
-
/** Bump when an artifact rule, its severity or its matching changes. */
|
|
6
|
-
export declare const ARTIFACT_QA_RULES_VERSION = "2026-11-10.1";
|
|
7
|
-
export interface RunArtifactQaOptions {
|
|
8
|
-
/** Rules to judge by: `playcraft` (default) checks the playable itself; a channel adds its rules. */
|
|
9
|
-
profile?: Platform;
|
|
10
|
-
/** Stages to run, in this order; default all of `QA_STAGES`. */
|
|
11
|
-
stages?: QaStageId[];
|
|
12
|
-
/** Size limit of the profile, e.g. from the channel's platform adapter (`base` stage). */
|
|
13
|
-
sizeLimitBytes?: number;
|
|
14
|
-
/** Project source root (`source-hints` stage). */
|
|
15
|
-
projectRoot?: string;
|
|
16
|
-
sourceGlobs?: string[];
|
|
17
|
-
/** Headless browser (`runtime-load` stage); without it the stage is reported as skipped. */
|
|
18
|
-
driver?: BrowserDriver;
|
|
19
|
-
/** Why no driver was provided, e.g. Chromium is missing; becomes the runtime-load skip reason. */
|
|
20
|
-
driverUnavailableReason?: string;
|
|
21
|
-
runtime?: Pick<RuntimeLoadOptions, 'viewports' | 'settleMs' | 'timeoutMs'>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Judges a built artifact by running each requested stage independently and collecting their
|
|
25
|
-
* reports. Stages never read each other's results, so any stage can also be called on its own.
|
|
26
|
-
* Results depend only on the artifact and the options, never on how the artifact was built.
|
|
27
|
-
*/
|
|
28
|
-
export declare function runArtifactQa(artifact: PlayableArtifact, options?: RunArtifactQaOptions): Promise<ArtifactQaReport>;
|
|
29
|
-
/**
|
|
30
|
-
* `channel` stage: the channel's existing `html-artifact` / `delivery-package` rules, the same
|
|
31
|
-
* rules export validation uses. Needs only the artifact and a channel profile.
|
|
32
|
-
*/
|
|
33
|
-
export declare function runChannelStage(artifact: PlayableArtifact, options: {
|
|
34
|
-
profile: Platform;
|
|
35
|
-
}): Promise<QaStageReport>;
|
|
36
|
-
/**
|
|
37
|
-
* `source-hints` stage: scans project source to help locate problems. Advisory: it never affects
|
|
38
|
-
* the overall result. Needs only the project root.
|
|
39
|
-
*/
|
|
40
|
-
export declare function runSourceHintsStage(options: {
|
|
41
|
-
projectRoot: string;
|
|
42
|
-
profile?: Platform;
|
|
43
|
-
sourceGlobs?: string[];
|
|
44
|
-
}): Promise<QaStageReport>;
|