@scribe-platform/cli 0.7.0 → 0.9.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 +28 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +15 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/proof.d.ts +5 -0
- package/dist/commands/proof.d.ts.map +1 -0
- package/dist/commands/proof.js +440 -0
- package/dist/commands/proof.js.map +1 -0
- package/dist/commands/prospect.d.ts +27 -0
- package/dist/commands/prospect.d.ts.map +1 -0
- package/dist/commands/prospect.js +222 -0
- package/dist/commands/prospect.js.map +1 -0
- package/dist/commands/request.d.ts +38 -0
- package/dist/commands/request.d.ts.map +1 -0
- package/dist/commands/request.js +214 -0
- package/dist/commands/request.js.map +1 -0
- package/dist/commands/site.d.ts +11 -0
- package/dist/commands/site.d.ts.map +1 -1
- package/dist/commands/site.js +41 -3
- package/dist/commands/site.js.map +1 -1
- package/dist/commands/update.d.ts +10 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +128 -31
- package/dist/commands/update.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/claude-hook.d.ts +74 -0
- package/dist/lib/claude-hook.d.ts.map +1 -0
- package/dist/lib/claude-hook.js +108 -0
- package/dist/lib/claude-hook.js.map +1 -0
- package/dist/lib/client.d.ts +351 -0
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +159 -0
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/proof-folder.d.ts +86 -0
- package/dist/lib/proof-folder.d.ts.map +1 -0
- package/dist/lib/proof-folder.js +226 -0
- package/dist/lib/proof-folder.js.map +1 -0
- package/dist/lib/proof-preview.d.ts +39 -0
- package/dist/lib/proof-preview.d.ts.map +1 -0
- package/dist/lib/proof-preview.js +318 -0
- package/dist/lib/proof-preview.js.map +1 -0
- package/dist/lib/proof-push.d.ts +42 -0
- package/dist/lib/proof-push.d.ts.map +1 -0
- package/dist/lib/proof-push.js +91 -0
- package/dist/lib/proof-push.js.map +1 -0
- package/dist/lib/skill.d.ts +13 -0
- package/dist/lib/skill.d.ts.map +1 -1
- package/dist/lib/skill.js +33 -2
- package/dist/lib/skill.js.map +1 -1
- package/dist/lib/update-check.d.ts +46 -0
- package/dist/lib/update-check.d.ts.map +1 -0
- package/dist/lib/update-check.js +103 -0
- package/dist/lib/update-check.js.map +1 -0
- package/package.json +5 -3
- package/runtime/proof.js +139 -0
- package/skills/scribe-site-builder/SKILL.md +175 -33
- package/skills/scribe-site-builder/recipes/README.md +11 -3
- package/skills/scribe-site-builder/recipes/domains.md +151 -0
- package/skills/scribe-site-builder/recipes/forms.md +5 -2
- package/skills/scribe-site-builder/recipes/proofs.md +311 -0
- package/skills/scribe-site-builder/recipes/prospects.md +192 -0
- package/skills/scribe-site-builder/recipes/requests.md +145 -0
- package/skills/scribe-site-builder/recipes/schema.md +24 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 0029 — a Proof folder on Ashley's machine: `proofs/<name>/` inside the
|
|
3
|
+
* client folder, holding the current version's files plus `.scribe-proof.json`,
|
|
4
|
+
* which says which Proof the folder belongs to so commands run inside it need
|
|
5
|
+
* no argument.
|
|
6
|
+
*
|
|
7
|
+
* The rules below mirror the server's (`@scribe-cms/core/proofs`'s
|
|
8
|
+
* `validateManifest`), so `scribe proof check` can say what a push would
|
|
9
|
+
* refuse before anything is uploaded. **The server is the authority**: if the
|
|
10
|
+
* two ever disagree, the push fails with the server's reason, which is the
|
|
11
|
+
* safe direction to drift.
|
|
12
|
+
*/
|
|
13
|
+
export declare const PROOF_CONFIG_FILE = ".scribe-proof.json";
|
|
14
|
+
export declare const ENTRY_PATH = "index.html";
|
|
15
|
+
export declare const MAX_FILE_BYTES: number;
|
|
16
|
+
export declare const MAX_VERSION_BYTES: number;
|
|
17
|
+
/** File types a Proof may contain, by lowercase extension — the server's table. */
|
|
18
|
+
export declare const PROOF_CONTENT_TYPES: Readonly<Record<string, string>>;
|
|
19
|
+
export declare const PROOF_EXTENSIONS: readonly string[];
|
|
20
|
+
/** Same rule as the server and the runtime: ids appear in URLs, event rows and CLI output. */
|
|
21
|
+
export declare const OPTION_ID: RegExp;
|
|
22
|
+
export interface ProofRef {
|
|
23
|
+
client: string;
|
|
24
|
+
proof: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ProofFile {
|
|
27
|
+
/** Relative, `/`-separated — the path the server and the Proof's own links use. */
|
|
28
|
+
path: string;
|
|
29
|
+
absolute: string;
|
|
30
|
+
bytes: number;
|
|
31
|
+
sha256: string;
|
|
32
|
+
}
|
|
33
|
+
/** `acme-bakery/logo-concepts` → `{ client, proof }`, or null if it isn't one. */
|
|
34
|
+
export declare function parseProofRef(value: string): ProofRef | null;
|
|
35
|
+
export declare function readProofConfig(dir: string): ProofRef | null;
|
|
36
|
+
export declare function writeProofConfig(dir: string, ref: ProofRef): void;
|
|
37
|
+
export type ResolvedRef = {
|
|
38
|
+
ok: true;
|
|
39
|
+
ref: ProofRef;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
error: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Which Proof a command means: the `<client>/<proof>` argument if given,
|
|
46
|
+
* otherwise the folder's `.scribe-proof.json`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveProofRef(arg: string | undefined, dir: string): ResolvedRef;
|
|
49
|
+
/** Every file a push would send, sorted by path so manifests are stable. */
|
|
50
|
+
export declare function scanFolder(dir: string): ProofFile[];
|
|
51
|
+
export declare function extensionOf(path: string): string | null;
|
|
52
|
+
export interface ProofOptionFound {
|
|
53
|
+
id: string;
|
|
54
|
+
label: string | null;
|
|
55
|
+
}
|
|
56
|
+
/** `data-proof-option` elements in one HTML file — a lighter read than the server's, for warnings only. */
|
|
57
|
+
export declare function findOptions(html: string): {
|
|
58
|
+
options: ProofOptionFound[];
|
|
59
|
+
duplicates: string[];
|
|
60
|
+
invalid: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Links that start with `/`. A Proof is served under `/c/<token>/`, so a
|
|
64
|
+
* root-absolute `/images/logo.png` points outside it and 404s for the Client —
|
|
65
|
+
* while working fine in a local dev server, which is what makes it worth
|
|
66
|
+
* catching before a push. Protocol-relative `//cdn…` links are fine.
|
|
67
|
+
*/
|
|
68
|
+
export declare function findRootAbsoluteLinks(text: string): {
|
|
69
|
+
line: number;
|
|
70
|
+
link: string;
|
|
71
|
+
}[];
|
|
72
|
+
export interface CheckResult {
|
|
73
|
+
files: ProofFile[];
|
|
74
|
+
totalBytes: number;
|
|
75
|
+
/** The push would be refused. */
|
|
76
|
+
errors: string[];
|
|
77
|
+
/** Root-absolute links: the push refuses these unless forced, because they'd 404 for the Client. */
|
|
78
|
+
brokenLinks: string[];
|
|
79
|
+
/** Worth knowing; nothing is refused for them. */
|
|
80
|
+
warnings: string[];
|
|
81
|
+
options: ProofOptionFound[];
|
|
82
|
+
/** No page of its own: the server will build one and name an Option per file. */
|
|
83
|
+
gallery: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare function checkFolder(dir: string, previousOptions?: string[]): CheckResult;
|
|
86
|
+
//# sourceMappingURL=proof-folder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-folder.d.ts","sourceRoot":"","sources":["../../src/lib/proof-folder.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,cAAc,QAAmB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,QAAoB,CAAC;AAGnD,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuBh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AE,MAAM,GAAG;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAqBlH;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CASpF;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,oGAAoG;IACpG,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;CAClB;AAYD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,GAAE,MAAM,EAAO,GAAG,WAAW,CAoDpF"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join, relative, sep } from 'node:path';
|
|
4
|
+
/**
|
|
5
|
+
* RFC 0029 — a Proof folder on Ashley's machine: `proofs/<name>/` inside the
|
|
6
|
+
* client folder, holding the current version's files plus `.scribe-proof.json`,
|
|
7
|
+
* which says which Proof the folder belongs to so commands run inside it need
|
|
8
|
+
* no argument.
|
|
9
|
+
*
|
|
10
|
+
* The rules below mirror the server's (`@scribe-cms/core/proofs`'s
|
|
11
|
+
* `validateManifest`), so `scribe proof check` can say what a push would
|
|
12
|
+
* refuse before anything is uploaded. **The server is the authority**: if the
|
|
13
|
+
* two ever disagree, the push fails with the server's reason, which is the
|
|
14
|
+
* safe direction to drift.
|
|
15
|
+
*/
|
|
16
|
+
export const PROOF_CONFIG_FILE = '.scribe-proof.json';
|
|
17
|
+
export const ENTRY_PATH = 'index.html';
|
|
18
|
+
export const MAX_FILE_BYTES = 25 * 1024 * 1024;
|
|
19
|
+
export const MAX_VERSION_BYTES = 100 * 1024 * 1024;
|
|
20
|
+
const RESERVED_PREFIX = '_scribe/';
|
|
21
|
+
/** File types a Proof may contain, by lowercase extension — the server's table. */
|
|
22
|
+
export const PROOF_CONTENT_TYPES = {
|
|
23
|
+
html: 'text/html; charset=utf-8',
|
|
24
|
+
htm: 'text/html; charset=utf-8',
|
|
25
|
+
css: 'text/css; charset=utf-8',
|
|
26
|
+
js: 'text/javascript; charset=utf-8',
|
|
27
|
+
mjs: 'text/javascript; charset=utf-8',
|
|
28
|
+
json: 'application/json; charset=utf-8',
|
|
29
|
+
txt: 'text/plain; charset=utf-8',
|
|
30
|
+
svg: 'image/svg+xml',
|
|
31
|
+
png: 'image/png',
|
|
32
|
+
jpg: 'image/jpeg',
|
|
33
|
+
jpeg: 'image/jpeg',
|
|
34
|
+
gif: 'image/gif',
|
|
35
|
+
webp: 'image/webp',
|
|
36
|
+
avif: 'image/avif',
|
|
37
|
+
ico: 'image/x-icon',
|
|
38
|
+
woff: 'font/woff',
|
|
39
|
+
woff2: 'font/woff2',
|
|
40
|
+
ttf: 'font/ttf',
|
|
41
|
+
otf: 'font/otf',
|
|
42
|
+
mp4: 'video/mp4',
|
|
43
|
+
webm: 'video/webm',
|
|
44
|
+
pdf: 'application/pdf',
|
|
45
|
+
};
|
|
46
|
+
export const PROOF_EXTENSIONS = Object.keys(PROOF_CONTENT_TYPES);
|
|
47
|
+
/** Same rule as the server and the runtime: ids appear in URLs, event rows and CLI output. */
|
|
48
|
+
export const OPTION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
49
|
+
/** `acme-bakery/logo-concepts` → `{ client, proof }`, or null if it isn't one. */
|
|
50
|
+
export function parseProofRef(value) {
|
|
51
|
+
const match = /^([a-z0-9][a-z0-9-]*)\/([a-z0-9][a-z0-9-]*)$/.exec(value.trim());
|
|
52
|
+
return match ? { client: match[1], proof: match[2] } : null;
|
|
53
|
+
}
|
|
54
|
+
export function readProofConfig(dir) {
|
|
55
|
+
const file = join(dir, PROOF_CONFIG_FILE);
|
|
56
|
+
if (!existsSync(file))
|
|
57
|
+
return null;
|
|
58
|
+
try {
|
|
59
|
+
const data = JSON.parse(readFileSync(file, 'utf8'));
|
|
60
|
+
return typeof data.client === 'string' && typeof data.proof === 'string' ? { client: data.client, proof: data.proof } : null;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function writeProofConfig(dir, ref) {
|
|
67
|
+
writeFileSync(join(dir, PROOF_CONFIG_FILE), `${JSON.stringify(ref, null, 2)}\n`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Which Proof a command means: the `<client>/<proof>` argument if given,
|
|
71
|
+
* otherwise the folder's `.scribe-proof.json`.
|
|
72
|
+
*/
|
|
73
|
+
export function resolveProofRef(arg, dir) {
|
|
74
|
+
if (arg) {
|
|
75
|
+
const ref = parseProofRef(arg);
|
|
76
|
+
return ref ? { ok: true, ref } : { ok: false, error: `"${arg}" isn't a Proof — expected <client>/<proof>, e.g. acme-bakery/logo-concepts` };
|
|
77
|
+
}
|
|
78
|
+
const ref = readProofConfig(dir);
|
|
79
|
+
if (ref)
|
|
80
|
+
return { ok: true, ref };
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
error: `No ${PROOF_CONFIG_FILE} in ${dir}. Run this inside a Proof folder, or name the Proof as <client>/<proof>.`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** Hidden files and folders never ship: `.scribe-proof.json`, `.DS_Store`, `.git`. */
|
|
87
|
+
function isHidden(name) {
|
|
88
|
+
return name.startsWith('.');
|
|
89
|
+
}
|
|
90
|
+
/** Every file a push would send, sorted by path so manifests are stable. */
|
|
91
|
+
export function scanFolder(dir) {
|
|
92
|
+
const files = [];
|
|
93
|
+
const walk = (current) => {
|
|
94
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
95
|
+
if (isHidden(entry.name) || entry.name === 'node_modules')
|
|
96
|
+
continue;
|
|
97
|
+
const absolute = join(current, entry.name);
|
|
98
|
+
if (entry.isDirectory())
|
|
99
|
+
walk(absolute);
|
|
100
|
+
else if (entry.isFile()) {
|
|
101
|
+
const content = readFileSync(absolute);
|
|
102
|
+
files.push({
|
|
103
|
+
path: relative(dir, absolute).split(sep).join('/'),
|
|
104
|
+
absolute,
|
|
105
|
+
bytes: statSync(absolute).size,
|
|
106
|
+
sha256: createHash('sha256').update(content).digest('hex'),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
walk(dir);
|
|
112
|
+
return files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
113
|
+
}
|
|
114
|
+
export function extensionOf(path) {
|
|
115
|
+
const name = path.slice(path.lastIndexOf('/') + 1);
|
|
116
|
+
const dot = name.lastIndexOf('.');
|
|
117
|
+
return dot > 0 ? name.slice(dot + 1).toLowerCase() : null;
|
|
118
|
+
}
|
|
119
|
+
function mb(bytes) {
|
|
120
|
+
return `${Math.round((bytes / (1024 * 1024)) * 10) / 10} MB`;
|
|
121
|
+
}
|
|
122
|
+
/** `data-proof-option` elements in one HTML file — a lighter read than the server's, for warnings only. */
|
|
123
|
+
export function findOptions(html) {
|
|
124
|
+
const visible = html.replace(/<!--[\s\S]*?-->/g, '').replace(/<script\b[\s\S]*?<\/script\s*>/gi, '');
|
|
125
|
+
const options = [];
|
|
126
|
+
const duplicates = [];
|
|
127
|
+
const invalid = [];
|
|
128
|
+
const seen = new Set();
|
|
129
|
+
for (const tag of visible.matchAll(/<[A-Za-z][^>]*\sdata-proof-option\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))[^>]*>/g)) {
|
|
130
|
+
const id = (tag[2] ?? tag[3] ?? tag[4] ?? '').trim();
|
|
131
|
+
if (!OPTION_ID.test(id)) {
|
|
132
|
+
invalid.push(id);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (seen.has(id)) {
|
|
136
|
+
duplicates.push(id);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
seen.add(id);
|
|
140
|
+
const label = /\sdata-proof-label\s*=\s*("([^"]*)"|'([^']*)')/.exec(tag[0]);
|
|
141
|
+
options.push({ id, label: label ? (label[2] ?? label[3] ?? '').trim() || null : null });
|
|
142
|
+
}
|
|
143
|
+
return { options, duplicates, invalid };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Links that start with `/`. A Proof is served under `/c/<token>/`, so a
|
|
147
|
+
* root-absolute `/images/logo.png` points outside it and 404s for the Client —
|
|
148
|
+
* while working fine in a local dev server, which is what makes it worth
|
|
149
|
+
* catching before a push. Protocol-relative `//cdn…` links are fine.
|
|
150
|
+
*/
|
|
151
|
+
export function findRootAbsoluteLinks(text) {
|
|
152
|
+
const found = [];
|
|
153
|
+
const patterns = [/\s(?:src|href|poster|action)\s*=\s*["'](\/(?!\/)[^"']*)["']/gi, /url\(\s*["']?(\/(?!\/)[^"')]*)["']?\s*\)/gi];
|
|
154
|
+
text.split('\n').forEach((lineText, index) => {
|
|
155
|
+
for (const pattern of patterns) {
|
|
156
|
+
for (const match of lineText.matchAll(pattern))
|
|
157
|
+
found.push({ line: index + 1, link: match[1] });
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return found;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Everything `scribe proof check` reports. `previousOptions` — the last pushed
|
|
164
|
+
* version's Option ids — lets it say which Options a revision dropped.
|
|
165
|
+
*/
|
|
166
|
+
/** Mirrors core's `isGalleryManifest`: images and PDFs are what a generated page can be built from. */
|
|
167
|
+
function isGalleryType(path) {
|
|
168
|
+
const type = PROOF_CONTENT_TYPES[extensionOf(path) ?? ''];
|
|
169
|
+
return Boolean(type) && (type.startsWith('image/') || type === 'application/pdf');
|
|
170
|
+
}
|
|
171
|
+
export function checkFolder(dir, previousOptions = []) {
|
|
172
|
+
const files = scanFolder(dir);
|
|
173
|
+
const errors = [];
|
|
174
|
+
const brokenLinks = [];
|
|
175
|
+
const warnings = [];
|
|
176
|
+
let totalBytes = 0;
|
|
177
|
+
let options = [];
|
|
178
|
+
if (files.length === 0)
|
|
179
|
+
errors.push('The folder is empty.');
|
|
180
|
+
// A folder of images and nothing else is allowed to arrive with no page:
|
|
181
|
+
// the server generates one and makes each file an Option, which is what
|
|
182
|
+
// makes "send them these four PNGs" work with no HTML at all (RFC 0029).
|
|
183
|
+
const gallery = files.length > 0 && files.every((f) => isGalleryType(f.path));
|
|
184
|
+
if (files.length > 0 && !gallery && !files.some((f) => f.path === ENTRY_PATH)) {
|
|
185
|
+
errors.push(`${ENTRY_PATH} is missing — it's the page the Proof opens on.`);
|
|
186
|
+
}
|
|
187
|
+
for (const file of files) {
|
|
188
|
+
totalBytes += file.bytes;
|
|
189
|
+
const ext = extensionOf(file.path);
|
|
190
|
+
if (!ext || !PROOF_EXTENSIONS.includes(ext))
|
|
191
|
+
errors.push(`${file.path}: not a file type a Proof may contain.`);
|
|
192
|
+
if (file.bytes > MAX_FILE_BYTES)
|
|
193
|
+
errors.push(`${file.path}: ${mb(file.bytes)} is over the ${mb(MAX_FILE_BYTES)} per-file limit.`);
|
|
194
|
+
if (file.path.startsWith(RESERVED_PREFIX))
|
|
195
|
+
errors.push(`${file.path}: ${RESERVED_PREFIX} is reserved for Scribe's own files.`);
|
|
196
|
+
if (/[?#]/.test(file.path))
|
|
197
|
+
errors.push(`${file.path}: file names can't contain ? or #.`);
|
|
198
|
+
if (ext === 'html' || ext === 'htm' || ext === 'css') {
|
|
199
|
+
const text = readFileSync(file.absolute, 'utf8');
|
|
200
|
+
for (const { line, link } of findRootAbsoluteLinks(text)) {
|
|
201
|
+
brokenLinks.push(`${file.path}:${line}: "${link}" starts with / — make it relative ("${link.slice(1)}")`);
|
|
202
|
+
}
|
|
203
|
+
if (ext !== 'css') {
|
|
204
|
+
const found = findOptions(text);
|
|
205
|
+
if (file.path === ENTRY_PATH)
|
|
206
|
+
options = found.options;
|
|
207
|
+
for (const id of found.duplicates)
|
|
208
|
+
warnings.push(`${file.path}: Option "${id}" appears more than once; only the first counts.`);
|
|
209
|
+
for (const id of found.invalid) {
|
|
210
|
+
warnings.push(`${file.path}: "${id}" isn't a usable Option id (letters, numbers, - and _ only, up to 64).`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (totalBytes > MAX_VERSION_BYTES)
|
|
216
|
+
errors.push(`${mb(totalBytes)} in total is over the ${mb(MAX_VERSION_BYTES)} per-version limit.`);
|
|
217
|
+
// Often deliberate — the revision workflow drops the Options nobody liked —
|
|
218
|
+
// so it's one line of information, not a warning per Option.
|
|
219
|
+
const current = new Set(options.map((o) => o.id));
|
|
220
|
+
const dropped = previousOptions.filter((id) => !current.has(id));
|
|
221
|
+
if (dropped.length > 0) {
|
|
222
|
+
warnings.push(`Dropped since the last version: ${dropped.join(', ')}. Feedback on those stays on the older version.`);
|
|
223
|
+
}
|
|
224
|
+
return { files, totalBytes, errors, brokenLinks, warnings, options, gallery };
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=proof-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-folder.js","sourceRoot":"","sources":["../../src/lib/proof-folder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,IAAI,EAAE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,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACjE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,mCAAmC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACxH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 0029 — `scribe proof preview`: a Proof folder served the way a Client
|
|
3
|
+
* will see it, before anything is pushed.
|
|
4
|
+
*
|
|
5
|
+
* Same sandbox CSP, same runtime injected the same way, same iframe sandbox
|
|
6
|
+
* attribute — so a Proof that works here works for the Client, and one that
|
|
7
|
+
* breaks under the sandbox (a script reading `localStorage`, say) breaks here
|
|
8
|
+
* first. The panel around it is a stand-in for the real review page: it keeps
|
|
9
|
+
* hearts, comments and pins in memory so they show up on the page as they
|
|
10
|
+
* would, and prints each one to the terminal. Nothing is saved anywhere.
|
|
11
|
+
*/
|
|
12
|
+
/** Mirrors the admin's `PROOF_CONTENT_CSP`. No `allow-same-origin`, ever. */
|
|
13
|
+
export declare const PREVIEW_CSP = "sandbox allow-scripts allow-forms allow-popups allow-modals";
|
|
14
|
+
/**
|
|
15
|
+
* The runtime bundle, copied in from `@scribe-cms/proof-runtime` at build time
|
|
16
|
+
* by scripts/bundle-runtime.mjs — the CLI is published to npm and can't depend
|
|
17
|
+
* on the private workspace package at install time. `../../runtime/` resolves
|
|
18
|
+
* to the package root from both `src/lib/` (tests) and `dist/lib/` (published).
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadRuntimeSource(): string;
|
|
21
|
+
/** Same placement rule as the admin's `injectRuntime`: first thing in `<head>`, src relative to the file's depth. */
|
|
22
|
+
export declare function injectRuntime(html: string, path: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* The file a request path names inside the folder, or null. Hidden files and
|
|
25
|
+
* anything outside the folder are never served — the same files a push would
|
|
26
|
+
* leave out.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolvePreviewFile(dir: string, requestPath: string): string | null;
|
|
29
|
+
export interface PreviewServer {
|
|
30
|
+
url: string;
|
|
31
|
+
close(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare function startPreview(args: {
|
|
34
|
+
dir: string;
|
|
35
|
+
port?: number;
|
|
36
|
+
log?: (line: string) => void;
|
|
37
|
+
runtimeSource?: string;
|
|
38
|
+
}): Promise<PreviewServer>;
|
|
39
|
+
//# sourceMappingURL=proof-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-preview.d.ts","sourceRoot":"","sources":["../../src/lib/proof-preview.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,WAAW,gEAAgE,CAAC;AAWzF;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED,qHAAqH;AACrH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWhE;AAaD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAalF;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,aAAa,CAAC,CA6DzB"}
|