@forumulate/cli 0.8.0 → 0.10.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 +11 -3
- package/dist/api/args.d.ts.map +1 -1
- package/dist/api/args.js +1 -0
- package/dist/api/args.js.map +1 -1
- package/dist/api/command.d.ts +1 -1
- package/dist/api/command.d.ts.map +1 -1
- package/dist/api/command.js +86 -11
- package/dist/api/command.js.map +1 -1
- package/dist/api/http.d.ts +8 -0
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +3 -2
- package/dist/api/http.js.map +1 -1
- package/dist/api/live-spec.d.ts +48 -0
- package/dist/api/live-spec.d.ts.map +1 -0
- package/dist/api/live-spec.js +72 -0
- package/dist/api/live-spec.js.map +1 -0
- package/dist/api/operations.json +1 -1
- package/dist/api/request.d.ts.map +1 -1
- package/dist/api/request.js +25 -1
- package/dist/api/request.js.map +1 -1
- package/dist/api/send.d.ts +10 -1
- package/dist/api/send.d.ts.map +1 -1
- package/dist/api/send.js +14 -3
- package/dist/api/send.js.map +1 -1
- package/dist/api/slim.d.ts +14 -0
- package/dist/api/slim.d.ts.map +1 -0
- package/dist/api/slim.js +174 -0
- package/dist/api/slim.js.map +1 -0
- package/dist/cache-command.d.ts +12 -0
- package/dist/cache-command.d.ts.map +1 -0
- package/dist/cache-command.js +93 -0
- package/dist/cache-command.js.map +1 -0
- package/dist/check/command.d.ts +48 -0
- package/dist/check/command.d.ts.map +1 -0
- package/dist/check/command.js +256 -0
- package/dist/check/command.js.map +1 -0
- package/dist/check/external.d.ts +66 -0
- package/dist/check/external.d.ts.map +1 -0
- package/dist/check/external.js +177 -0
- package/dist/check/external.js.map +1 -0
- package/dist/check/markdown-links.d.ts +38 -0
- package/dist/check/markdown-links.d.ts.map +1 -0
- package/dist/check/markdown-links.js +166 -0
- package/dist/check/markdown-links.js.map +1 -0
- package/dist/cli.js +42 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +17 -0
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +6 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/groups-api.d.ts.map +1 -1
- package/dist/commands/groups-api.js +20 -2
- package/dist/commands/groups-api.js.map +1 -1
- package/dist/commands/groups-docs.d.ts.map +1 -1
- package/dist/commands/groups-docs.js +8 -2
- package/dist/commands/groups-docs.js.map +1 -1
- package/dist/commands/groups-jobs.d.ts +10 -0
- package/dist/commands/groups-jobs.d.ts.map +1 -0
- package/dist/commands/groups-jobs.js +89 -0
- package/dist/commands/groups-jobs.js.map +1 -0
- package/dist/commands/groups-org.d.ts.map +1 -1
- package/dist/commands/groups-org.js +59 -2
- package/dist/commands/groups-org.js.map +1 -1
- package/dist/commands/groups-site.d.ts.map +1 -1
- package/dist/commands/groups-site.js +47 -10
- package/dist/commands/groups-site.js.map +1 -1
- package/dist/commands/groups-spaces.d.ts.map +1 -1
- package/dist/commands/groups-spaces.js +11 -5
- package/dist/commands/groups-spaces.js.map +1 -1
- package/dist/commands/groups-types.d.ts.map +1 -1
- package/dist/commands/groups-types.js +74 -0
- package/dist/commands/groups-types.js.map +1 -1
- package/dist/commands/groups.d.ts.map +1 -1
- package/dist/commands/groups.js +2 -0
- package/dist/commands/groups.js.map +1 -1
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +18 -3
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/job-wait.d.ts +64 -0
- package/dist/commands/job-wait.d.ts.map +1 -0
- package/dist/commands/job-wait.js +91 -0
- package/dist/commands/job-wait.js.map +1 -0
- package/dist/commands/resource.d.ts +19 -0
- package/dist/commands/resource.d.ts.map +1 -1
- package/dist/commands/resource.js +65 -3
- package/dist/commands/resource.js.map +1 -1
- package/dist/content/library.d.ts +8 -0
- package/dist/content/library.d.ts.map +1 -1
- package/dist/content/library.js +10 -2
- package/dist/content/library.js.map +1 -1
- package/dist/credentials.d.ts +43 -4
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +67 -4
- package/dist/credentials.js.map +1 -1
- package/dist/dev/command.d.ts +41 -0
- package/dist/dev/command.d.ts.map +1 -0
- package/dist/dev/command.js +158 -0
- package/dist/dev/command.js.map +1 -0
- package/dist/doctor/address-checks.d.ts +56 -0
- package/dist/doctor/address-checks.d.ts.map +1 -0
- package/dist/doctor/address-checks.js +183 -0
- package/dist/doctor/address-checks.js.map +1 -0
- package/dist/doctor/boilerplate.d.ts +33 -0
- package/dist/doctor/boilerplate.d.ts.map +1 -0
- package/dist/doctor/boilerplate.js +78 -0
- package/dist/doctor/boilerplate.js.map +1 -0
- package/dist/doctor/command.d.ts +18 -0
- package/dist/doctor/command.d.ts.map +1 -0
- package/dist/doctor/command.js +234 -0
- package/dist/doctor/command.js.map +1 -0
- package/dist/doctor/crawl.d.ts +49 -0
- package/dist/doctor/crawl.d.ts.map +1 -0
- package/dist/doctor/crawl.js +210 -0
- package/dist/doctor/crawl.js.map +1 -0
- package/dist/doctor/extended.d.ts +52 -0
- package/dist/doctor/extended.d.ts.map +1 -0
- package/dist/doctor/extended.js +150 -0
- package/dist/doctor/extended.js.map +1 -0
- package/dist/doctor/page-checks.d.ts +42 -0
- package/dist/doctor/page-checks.d.ts.map +1 -0
- package/dist/doctor/page-checks.js +200 -0
- package/dist/doctor/page-checks.js.map +1 -0
- package/dist/doctor/probe.d.ts +63 -0
- package/dist/doctor/probe.d.ts.map +1 -0
- package/dist/doctor/probe.js +170 -0
- package/dist/doctor/probe.js.map +1 -0
- package/dist/doctor/reader-auth-atlas.d.ts +18 -0
- package/dist/doctor/reader-auth-atlas.d.ts.map +1 -0
- package/dist/doctor/reader-auth-atlas.js +50 -0
- package/dist/doctor/reader-auth-atlas.js.map +1 -0
- package/dist/doctor/robots-params.d.ts +36 -0
- package/dist/doctor/robots-params.d.ts.map +1 -0
- package/dist/doctor/robots-params.js +97 -0
- package/dist/doctor/robots-params.js.map +1 -0
- package/dist/doctor/site.d.ts +42 -0
- package/dist/doctor/site.d.ts.map +1 -0
- package/dist/doctor/site.js +82 -0
- package/dist/doctor/site.js.map +1 -0
- package/dist/doctor.d.ts +21 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +94 -3
- package/dist/doctor.js.map +1 -1
- package/dist/exit-codes.d.ts +40 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +66 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/help-commands.d.ts +13 -0
- package/dist/help-commands.d.ts.map +1 -0
- package/dist/help-commands.js +215 -0
- package/dist/help-commands.js.map +1 -0
- package/dist/help.d.ts +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +74 -11
- package/dist/help.js.map +1 -1
- package/dist/io.d.ts +33 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +81 -0
- package/dist/io.js.map +1 -0
- package/dist/preview-comment.d.ts +20 -0
- package/dist/preview-comment.d.ts.map +1 -0
- package/dist/preview-comment.js +88 -0
- package/dist/preview-comment.js.map +1 -0
- package/dist/publish/about.d.ts +23 -0
- package/dist/publish/about.d.ts.map +1 -0
- package/dist/publish/about.js +66 -0
- package/dist/publish/about.js.map +1 -0
- package/dist/publish/api.d.ts +30 -12
- package/dist/publish/api.d.ts.map +1 -1
- package/dist/publish/api.js +62 -10
- package/dist/publish/api.js.map +1 -1
- package/dist/publish/client.d.ts +19 -0
- package/dist/publish/client.d.ts.map +1 -0
- package/dist/publish/client.js +3 -0
- package/dist/publish/client.js.map +1 -0
- package/dist/publish/command.d.ts +51 -2
- package/dist/publish/command.d.ts.map +1 -1
- package/dist/publish/command.js +157 -17
- package/dist/publish/command.js.map +1 -1
- package/dist/publish/context.d.ts +12 -1
- package/dist/publish/context.d.ts.map +1 -1
- package/dist/publish/context.js.map +1 -1
- package/dist/publish/diff.d.ts +21 -0
- package/dist/publish/diff.d.ts.map +1 -0
- package/dist/publish/diff.js +96 -0
- package/dist/publish/diff.js.map +1 -0
- package/dist/publish/docs-apply.d.ts +8 -1
- package/dist/publish/docs-apply.d.ts.map +1 -1
- package/dist/publish/docs-apply.js +49 -10
- package/dist/publish/docs-apply.js.map +1 -1
- package/dist/publish/docs-plan.d.ts +16 -3
- package/dist/publish/docs-plan.d.ts.map +1 -1
- package/dist/publish/docs-plan.js +57 -6
- package/dist/publish/docs-plan.js.map +1 -1
- package/dist/publish/extras.d.ts +10 -0
- package/dist/publish/extras.d.ts.map +1 -1
- package/dist/publish/extras.js +54 -2
- package/dist/publish/extras.js.map +1 -1
- package/dist/publish/frontmatter.d.ts +1 -1
- package/dist/publish/frontmatter.d.ts.map +1 -1
- package/dist/publish/frontmatter.js +1 -0
- package/dist/publish/frontmatter.js.map +1 -1
- package/dist/publish/index.d.ts +12 -0
- package/dist/publish/index.d.ts.map +1 -0
- package/dist/publish/index.js +17 -0
- package/dist/publish/index.js.map +1 -0
- package/dist/publish/manifest.d.ts.map +1 -1
- package/dist/publish/manifest.js +48 -3
- package/dist/publish/manifest.js.map +1 -1
- package/dist/publish/names.d.ts +28 -0
- package/dist/publish/names.d.ts.map +1 -0
- package/dist/publish/names.js +80 -0
- package/dist/publish/names.js.map +1 -0
- package/dist/publish/posts.d.ts.map +1 -1
- package/dist/publish/posts.js +46 -13
- package/dist/publish/posts.js.map +1 -1
- package/dist/publish/preview.d.ts +56 -0
- package/dist/publish/preview.d.ts.map +1 -0
- package/dist/publish/preview.js +133 -0
- package/dist/publish/preview.js.map +1 -0
- package/dist/publish/redirects.d.ts +13 -0
- package/dist/publish/redirects.d.ts.map +1 -0
- package/dist/publish/redirects.js +154 -0
- package/dist/publish/redirects.js.map +1 -0
- package/dist/publish/reserved.d.ts +49 -0
- package/dist/publish/reserved.d.ts.map +1 -0
- package/dist/publish/reserved.js +118 -0
- package/dist/publish/reserved.js.map +1 -0
- package/dist/publish/rewrite.d.ts +12 -0
- package/dist/publish/rewrite.d.ts.map +1 -1
- package/dist/publish/rewrite.js +22 -0
- package/dist/publish/rewrite.js.map +1 -1
- package/dist/publish/scan-docs.d.ts +10 -0
- package/dist/publish/scan-docs.d.ts.map +1 -0
- package/dist/publish/scan-docs.js +160 -0
- package/dist/publish/scan-docs.js.map +1 -0
- package/dist/publish/scan.d.ts +21 -17
- package/dist/publish/scan.d.ts.map +1 -1
- package/dist/publish/scan.js +99 -232
- package/dist/publish/scan.js.map +1 -1
- package/dist/publish/slots.d.ts +39 -0
- package/dist/publish/slots.d.ts.map +1 -0
- package/dist/publish/slots.js +64 -0
- package/dist/publish/slots.js.map +1 -0
- package/dist/publish/studio-edits.d.ts +25 -0
- package/dist/publish/studio-edits.d.ts.map +1 -0
- package/dist/publish/studio-edits.js +53 -0
- package/dist/publish/studio-edits.js.map +1 -0
- package/dist/publish/tags.d.ts +9 -0
- package/dist/publish/tags.d.ts.map +1 -0
- package/dist/publish/tags.js +194 -0
- package/dist/publish/tags.js.map +1 -0
- package/dist/publish/types.d.ts +84 -1
- package/dist/publish/types.d.ts.map +1 -1
- package/dist/publish/types.js +0 -10
- package/dist/publish/types.js.map +1 -1
- package/dist/publish-command.d.ts +55 -0
- package/dist/publish-command.d.ts.map +1 -0
- package/dist/publish-command.js +197 -0
- package/dist/publish-command.js.map +1 -0
- package/dist/run.d.ts +3 -10
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +171 -112
- package/dist/run.js.map +1 -1
- package/dist/translations/target.d.ts.map +1 -1
- package/dist/translations/target.js +2 -2
- package/dist/translations/target.js.map +1 -1
- package/dist/validate.d.ts +39 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +166 -0
- package/dist/validate.js.map +1 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/dist/whoami.d.ts +41 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +161 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +2 -2
- package/dist/publish-dir.d.ts +0 -54
- package/dist/publish-dir.d.ts.map +0 -1
- package/dist/publish-dir.js +0 -119
- package/dist/publish-dir.js.map +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PREVIEW_NAME = void 0;
|
|
4
|
+
exports.ciSource = ciSource;
|
|
5
|
+
exports.sendPreview = sendPreview;
|
|
6
|
+
const api_1 = require("./api");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
const docs_apply_1 = require("./docs-apply");
|
|
9
|
+
/** The name a preview may have — the API's rule (`pr-123`, `mr-45`, `feature-x`). */
|
|
10
|
+
exports.PREVIEW_NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
|
|
11
|
+
/**
|
|
12
|
+
* The pull request this run is for, from the CI's own variables — GitHub
|
|
13
|
+
* Actions, GitLab CI, Bitbucket Pipelines, Gitea/Forgejo Actions, Azure
|
|
14
|
+
* Pipelines — or `FORUMULATE_PREVIEW_*` for anything else. Every field is
|
|
15
|
+
* optional: a preview made from a laptop simply has no source.
|
|
16
|
+
*/
|
|
17
|
+
function ciSource(env) {
|
|
18
|
+
const pick = (...vals) => vals.find((v) => v && v.trim())?.trim();
|
|
19
|
+
if (env.FORUMULATE_PREVIEW_PROVIDER || env.FORUMULATE_PREVIEW_URL)
|
|
20
|
+
return clean({
|
|
21
|
+
provider: env.FORUMULATE_PREVIEW_PROVIDER,
|
|
22
|
+
repository: env.FORUMULATE_PREVIEW_REPOSITORY,
|
|
23
|
+
number: env.FORUMULATE_PREVIEW_NUMBER,
|
|
24
|
+
ref: env.FORUMULATE_PREVIEW_REF,
|
|
25
|
+
sha: env.FORUMULATE_PREVIEW_SHA,
|
|
26
|
+
url: env.FORUMULATE_PREVIEW_URL,
|
|
27
|
+
});
|
|
28
|
+
if (env.GITLAB_CI)
|
|
29
|
+
return clean({
|
|
30
|
+
provider: 'gitlab',
|
|
31
|
+
repository: env.CI_PROJECT_PATH,
|
|
32
|
+
number: env.CI_MERGE_REQUEST_IID,
|
|
33
|
+
ref: pick(env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME, env.CI_COMMIT_REF_NAME),
|
|
34
|
+
sha: env.CI_COMMIT_SHA,
|
|
35
|
+
url: env.CI_PROJECT_URL && env.CI_MERGE_REQUEST_IID
|
|
36
|
+
? `${env.CI_PROJECT_URL}/-/merge_requests/${env.CI_MERGE_REQUEST_IID}`
|
|
37
|
+
: undefined,
|
|
38
|
+
});
|
|
39
|
+
if (env.BITBUCKET_REPO_FULL_NAME)
|
|
40
|
+
return clean({
|
|
41
|
+
provider: 'bitbucket',
|
|
42
|
+
repository: env.BITBUCKET_REPO_FULL_NAME,
|
|
43
|
+
number: env.BITBUCKET_PR_ID,
|
|
44
|
+
ref: env.BITBUCKET_BRANCH,
|
|
45
|
+
sha: env.BITBUCKET_COMMIT,
|
|
46
|
+
url: env.BITBUCKET_PR_ID
|
|
47
|
+
? `https://bitbucket.org/${env.BITBUCKET_REPO_FULL_NAME}/pull-requests/${env.BITBUCKET_PR_ID}`
|
|
48
|
+
: undefined,
|
|
49
|
+
});
|
|
50
|
+
if (env.GITHUB_ACTIONS || env.GITEA_ACTIONS) {
|
|
51
|
+
const number = /^refs\/pull\/(\d+)\//.exec(env.GITHUB_REF ?? '')?.[1];
|
|
52
|
+
const server = (env.GITHUB_SERVER_URL ?? 'https://github.com').replace(/\/$/, '');
|
|
53
|
+
return clean({
|
|
54
|
+
provider: env.GITEA_ACTIONS ? 'gitea' : 'github',
|
|
55
|
+
repository: env.GITHUB_REPOSITORY,
|
|
56
|
+
number,
|
|
57
|
+
ref: pick(env.GITHUB_HEAD_REF, env.GITHUB_REF_NAME),
|
|
58
|
+
sha: env.GITHUB_SHA,
|
|
59
|
+
url: number && env.GITHUB_REPOSITORY ? `${server}/${env.GITHUB_REPOSITORY}/pull/${number}` : undefined,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (env.TF_BUILD)
|
|
63
|
+
return clean({
|
|
64
|
+
provider: 'azure',
|
|
65
|
+
repository: env.BUILD_REPOSITORY_NAME,
|
|
66
|
+
number: env.SYSTEM_PULLREQUEST_PULLREQUESTID,
|
|
67
|
+
ref: env.SYSTEM_PULLREQUEST_SOURCEBRANCH,
|
|
68
|
+
sha: env.BUILD_SOURCEVERSION,
|
|
69
|
+
});
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
function clean(s) {
|
|
73
|
+
return Object.fromEntries(Object.entries(s).filter(([, v]) => v));
|
|
74
|
+
}
|
|
75
|
+
/** Bytes per request: comfortably under the API's body limit. */
|
|
76
|
+
const BATCH_BYTES = 3_000_000;
|
|
77
|
+
/** Send this space's planned pages to the preview; returns what the API answered. */
|
|
78
|
+
async function sendPreview(ctx, plan, existingAssets, opts) {
|
|
79
|
+
const sends = [...plan.sends.values()].flat();
|
|
80
|
+
const removed = plan.prunePages.map((p) => p.slug);
|
|
81
|
+
if (!sends.length && !removed.length) {
|
|
82
|
+
ctx.line({ verb: 'same', what: `preview ${opts.name}`, detail: 'nothing differs from what is published' });
|
|
83
|
+
}
|
|
84
|
+
// A preview writes no page, but it does upload the pictures those pages use.
|
|
85
|
+
const writer = new api_1.PublishApi({ ...ctx.api.opts, readOnly: false });
|
|
86
|
+
const wctx = { ...ctx, api: writer };
|
|
87
|
+
const urls = await (0, docs_apply_1.uploadAssetsFor)(wctx, sends.map((s) => s.page.file), existingAssets);
|
|
88
|
+
const pages = sends.map((s) => ({
|
|
89
|
+
slug: s.page.slug,
|
|
90
|
+
title: s.page.title,
|
|
91
|
+
file: s.page.file,
|
|
92
|
+
markdown: (0, docs_apply_1.payloadOf)(wctx, s.page, urls.get(s.page.file) ?? new Map()),
|
|
93
|
+
}));
|
|
94
|
+
const batches = [[]];
|
|
95
|
+
let size = 0;
|
|
96
|
+
for (const p of pages) {
|
|
97
|
+
if (size + p.markdown.length > BATCH_BYTES && batches[batches.length - 1].length) {
|
|
98
|
+
batches.push([]);
|
|
99
|
+
size = 0;
|
|
100
|
+
}
|
|
101
|
+
batches[batches.length - 1].push(p);
|
|
102
|
+
size += p.markdown.length;
|
|
103
|
+
}
|
|
104
|
+
let answer = null;
|
|
105
|
+
for (const [i, batch] of batches.entries()) {
|
|
106
|
+
answer = await writer.post((0, context_1.spacePath)(ctx, '/previews'), {
|
|
107
|
+
name: opts.name,
|
|
108
|
+
pages: batch,
|
|
109
|
+
// Removals ride on the first request; later ones only add pages.
|
|
110
|
+
...(i === 0 && removed.length ? { removed } : {}),
|
|
111
|
+
...(i > 0 ? { append: true } : {}),
|
|
112
|
+
...(Object.keys(opts.source).length ? { source: opts.source } : {}),
|
|
113
|
+
...(opts.ttlDays ? { ttlDays: opts.ttlDays } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (!answer)
|
|
117
|
+
return null;
|
|
118
|
+
for (const s of sends)
|
|
119
|
+
ctx.line({ verb: 'preview', what: `page ${s.page.slug}`, detail: `${s.why} — in preview ${opts.name}` });
|
|
120
|
+
for (const slug of removed)
|
|
121
|
+
ctx.line({ verb: 'preview', what: `page ${slug}`, detail: `removed — in preview ${opts.name}` });
|
|
122
|
+
return {
|
|
123
|
+
space: ctx.spec.space ?? ctx.spaceId,
|
|
124
|
+
id: answer.preview.id,
|
|
125
|
+
name: answer.preview.name,
|
|
126
|
+
token: answer.token,
|
|
127
|
+
urls: answer.urls,
|
|
128
|
+
expiresAt: answer.preview.expiresAt,
|
|
129
|
+
summary: answer.preview.summary,
|
|
130
|
+
comment: answer.comment,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/publish/preview.ts"],"names":[],"mappings":";;;AAkDA,4BAuDC;AAUD,kCAgEC;AAnLD,+BAAmC;AACnC,uCAAqD;AAErD,6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QACrB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;QACnC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SpaceCtx } from './context';
|
|
2
|
+
import type { ManifestRedirect } from './types';
|
|
3
|
+
/** The rules a CSV file declares, by column name when it has a header. */
|
|
4
|
+
export declare function rulesFromCsv(text: string): ManifestRedirect[];
|
|
5
|
+
/** The rules as CSV in the import's columns — what the API is sent. */
|
|
6
|
+
export declare function rulesToCsv(rules: ManifestRedirect[]): string;
|
|
7
|
+
/** What the manifest declares for this space, read from the list or the file. */
|
|
8
|
+
export declare function declaredRedirects(spec: {
|
|
9
|
+
redirects?: ManifestRedirect[] | string;
|
|
10
|
+
}, manifestFile: string | null, root: string): ManifestRedirect[];
|
|
11
|
+
/** Plan or apply this space's declared redirects. */
|
|
12
|
+
export declare function syncRedirects(ctx: SpaceCtx, apply: boolean, manifestFile: string | null): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=redirects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.d.ts","sourceRoot":"","sources":["../../src/publish/redirects.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAwDhD,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAqB7D;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAM5D;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAA;CAAE,EACjD,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,IAAI,EAAE,MAAM,GACX,gBAAgB,EAAE,CAMpB;AAMD,qDAAqD;AACrD,wBAAsB,aAAa,CACjC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rulesFromCsv = rulesFromCsv;
|
|
4
|
+
exports.rulesToCsv = rulesToCsv;
|
|
5
|
+
exports.declaredRedirects = declaredRedirects;
|
|
6
|
+
exports.syncRedirects = syncRedirects;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const context_1 = require("./context");
|
|
10
|
+
/**
|
|
11
|
+
* `redirects:` in forumulate.yaml, applied by `publish` (FMU-F09).
|
|
12
|
+
*
|
|
13
|
+
* A docs repository moves pages, and the redirects that keep the old addresses
|
|
14
|
+
* working belong in the same pull request as the move — not in a console
|
|
15
|
+
* someone has to remember to visit after the merge. So a space in the manifest
|
|
16
|
+
* may list them:
|
|
17
|
+
*
|
|
18
|
+
* redirects:
|
|
19
|
+
* - { from: /getting-started, to: /quickstart }
|
|
20
|
+
* - { from: /v1/*, to: /*, status: 301 }
|
|
21
|
+
*
|
|
22
|
+
* or name a CSV file in the redirect manager's columns
|
|
23
|
+
* (`redirects: redirects.csv`, `from,to,status,type,passQuery`).
|
|
24
|
+
*
|
|
25
|
+
* Merged, never replaced: a rule the file does not name is left alone (the
|
|
26
|
+
* console's rules, the platform's rename rules), so declaring three redirects
|
|
27
|
+
* cannot delete three hundred. The write is the redirect manager's own import
|
|
28
|
+
* (`POST …/redirects/import`, mode `merge`), which validates every rule,
|
|
29
|
+
* refuses loops and duplicates, and keeps the platform's rules — one door,
|
|
30
|
+
* whichever way a rule arrives.
|
|
31
|
+
*/
|
|
32
|
+
/** A minimal CSV split — quoted fields and doubled quotes — for a manifest's CSV file. */
|
|
33
|
+
function records(text) {
|
|
34
|
+
const out = [];
|
|
35
|
+
let row = [];
|
|
36
|
+
let cell = '';
|
|
37
|
+
let quoted = false;
|
|
38
|
+
const src = text.replace(/^/, '');
|
|
39
|
+
for (let i = 0; i < src.length; i++) {
|
|
40
|
+
const c = src[i];
|
|
41
|
+
if (quoted) {
|
|
42
|
+
if (c === '"' && src[i + 1] === '"') {
|
|
43
|
+
cell += '"';
|
|
44
|
+
i++;
|
|
45
|
+
}
|
|
46
|
+
else if (c === '"')
|
|
47
|
+
quoted = false;
|
|
48
|
+
else
|
|
49
|
+
cell += c;
|
|
50
|
+
}
|
|
51
|
+
else if (c === '"' && cell === '')
|
|
52
|
+
quoted = true;
|
|
53
|
+
else if (c === ',') {
|
|
54
|
+
row.push(cell);
|
|
55
|
+
cell = '';
|
|
56
|
+
}
|
|
57
|
+
else if (c === '\n' || c === '\r') {
|
|
58
|
+
if (c === '\r' && src[i + 1] === '\n')
|
|
59
|
+
i++;
|
|
60
|
+
row.push(cell);
|
|
61
|
+
out.push(row);
|
|
62
|
+
row = [];
|
|
63
|
+
cell = '';
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
cell += c;
|
|
67
|
+
}
|
|
68
|
+
if (cell || row.length)
|
|
69
|
+
out.push([...row, cell]);
|
|
70
|
+
return out.filter((r) => r.some((c) => c.trim()));
|
|
71
|
+
}
|
|
72
|
+
/** The rules a CSV file declares, by column name when it has a header. */
|
|
73
|
+
function rulesFromCsv(text) {
|
|
74
|
+
const rows = records(text);
|
|
75
|
+
let cols = { from: 0, to: 1, status: 2, type: 3, passquery: 4 };
|
|
76
|
+
if (rows[0]?.some((c) => c.trim().toLowerCase() === 'from')) {
|
|
77
|
+
cols = {};
|
|
78
|
+
rows[0].forEach((c, i) => (cols[c.trim().toLowerCase()] = i));
|
|
79
|
+
rows.shift();
|
|
80
|
+
}
|
|
81
|
+
const get = (r, k) => (cols[k] === undefined ? '' : (r[cols[k]] ?? '').trim());
|
|
82
|
+
return rows
|
|
83
|
+
.filter((r) => !r[0].trim().startsWith('#'))
|
|
84
|
+
.map((r) => {
|
|
85
|
+
const rule = { from: get(r, 'from'), to: get(r, 'to') };
|
|
86
|
+
const status = Number(get(r, 'status'));
|
|
87
|
+
if ([301, 302, 307, 308].includes(status))
|
|
88
|
+
rule.status = status;
|
|
89
|
+
const type = get(r, 'type');
|
|
90
|
+
if (type === 'redirect' || type === 'rewrite')
|
|
91
|
+
rule.type = type;
|
|
92
|
+
const pass = get(r, 'passquery').toLowerCase();
|
|
93
|
+
if (pass)
|
|
94
|
+
rule.passQuery = ['true', '1', 'yes'].includes(pass);
|
|
95
|
+
return rule;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** The rules as CSV in the import's columns — what the API is sent. */
|
|
99
|
+
function rulesToCsv(rules) {
|
|
100
|
+
const q = (v) => `"${String(v ?? '').replace(/"/g, '""')}"`;
|
|
101
|
+
return [
|
|
102
|
+
'from,to,status,type,passQuery',
|
|
103
|
+
...rules.map((r) => [r.from, r.to, r.status ?? '', r.type ?? '', r.passQuery ?? ''].map(q).join(',')),
|
|
104
|
+
].join('\n');
|
|
105
|
+
}
|
|
106
|
+
/** What the manifest declares for this space, read from the list or the file. */
|
|
107
|
+
function declaredRedirects(spec, manifestFile, root) {
|
|
108
|
+
if (!spec.redirects)
|
|
109
|
+
return [];
|
|
110
|
+
if (Array.isArray(spec.redirects))
|
|
111
|
+
return spec.redirects;
|
|
112
|
+
const file = (0, node_path_1.resolve)(manifestFile ? (0, node_path_1.dirname)(manifestFile) : root, spec.redirects);
|
|
113
|
+
if (!(0, node_fs_1.existsSync)(file))
|
|
114
|
+
throw new Error(`redirects: no file at ${file}`);
|
|
115
|
+
return rulesFromCsv((0, node_fs_1.readFileSync)(file, 'utf8'));
|
|
116
|
+
}
|
|
117
|
+
/** The match key a stored rule and a declared one share (path + query condition). */
|
|
118
|
+
const keyOf = (r) => `${r.from}${r.match?.query && r.match.query !== 'ignore' ? `?${JSON.stringify(r.match.query)}` : ''}`;
|
|
119
|
+
/** Plan or apply this space's declared redirects. */
|
|
120
|
+
async function syncRedirects(ctx, apply, manifestFile) {
|
|
121
|
+
const declared = declaredRedirects(ctx.spec, manifestFile, ctx.root);
|
|
122
|
+
if (!declared.length)
|
|
123
|
+
return;
|
|
124
|
+
const live = await ctx.api
|
|
125
|
+
.get((0, context_1.spacePath)(ctx, '/redirects'))
|
|
126
|
+
.then((r) => r.redirects ?? [])
|
|
127
|
+
.catch(() => []);
|
|
128
|
+
const byKey = new Map(live.map((r) => [keyOf(r), r]));
|
|
129
|
+
const changes = declared.filter((d) => {
|
|
130
|
+
const had = byKey.get(keyOf(d));
|
|
131
|
+
return (!had ||
|
|
132
|
+
had.auto === true ||
|
|
133
|
+
had.to !== d.to ||
|
|
134
|
+
(had.status ?? 308) !== (d.status ?? 308) ||
|
|
135
|
+
(had.type ?? 'redirect') !== (d.type ?? 'redirect'));
|
|
136
|
+
});
|
|
137
|
+
if (!changes.length) {
|
|
138
|
+
ctx.line({ verb: 'same', what: 'redirects', detail: `${declared.length} declared, all in place` });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
for (const r of changes)
|
|
142
|
+
ctx.line({
|
|
143
|
+
verb: byKey.has(keyOf(r)) ? 'update' : 'create',
|
|
144
|
+
what: `redirect ${r.from}`,
|
|
145
|
+
detail: `→ ${r.to}${r.status ? ` (${r.status})` : ''}`,
|
|
146
|
+
});
|
|
147
|
+
if (!apply)
|
|
148
|
+
return;
|
|
149
|
+
await ctx.api.post((0, context_1.spacePath)(ctx, '/redirects/import'), {
|
|
150
|
+
csv: rulesToCsv(changes),
|
|
151
|
+
mode: 'merge',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.js","sourceRoot":"","sources":["../../src/publish/redirects.ts"],"names":[],"mappings":";;AA4DA,oCAqBC;AAGD,gCAMC;AAGD,8CAUC;AAOD,sCAuCC;AArJD,qCAAmD;AACnD,yCAA6C;AAC7C,uCAAqD;AAGrD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,0FAA0F;AAC1F,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,GAAG,GAAe,EAAE,CAAC;IAC3B,IAAI,GAAG,GAAa,EAAE,CAAC;IACvB,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAE,CAAC;QAClB,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACpC,IAAI,IAAI,GAAG,CAAC;gBACZ,CAAC,EAAE,CAAC;YACN,CAAC;iBAAM,IAAI,CAAC,KAAK,GAAG;gBAAE,MAAM,GAAG,KAAK,CAAC;;gBAChC,IAAI,IAAI,CAAC,CAAC;QACjB,CAAC;aAAM,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM,GAAG,IAAI,CAAC;aAC9C,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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
2
|
+
* Names in a content folder that are never content (R-N11).
|
|
3
|
+
*
|
|
4
|
+
* A repository that holds a blog also holds a README that explains the
|
|
5
|
+
* repository, a LICENSE, editor folders and a `_drafts` folder of posts nobody
|
|
6
|
+
* has finished. Every customer publisher we were shown carried its own list of
|
|
7
|
+
* these, and the first version of each list was the one that published the
|
|
8
|
+
* README as a post — readers met "How to run this repo locally" at the top of
|
|
9
|
+
* a newsroom. The list lives here, once, and the guide prints it
|
|
10
|
+
* (docs/guides/content-as-code.md, "Reserved names").
|
|
11
|
+
*
|
|
12
|
+
* Three groups, each for its own reason:
|
|
13
|
+
*
|
|
14
|
+
* - Hidden and private: anything starting with `.` (`.git`, `.github`,
|
|
15
|
+
* `.DS_Store`) or `_` (`_drafts`, `_templates`, and the metadata files this
|
|
16
|
+
* tool reads itself: `_collection.yml`, `_tags.yml`). `node_modules`.
|
|
17
|
+
* - The manifest: `forumulate.yaml`, `.yml`, `.json`.
|
|
18
|
+
* - Repository paperwork, in any case and with any Markdown extension:
|
|
19
|
+
* README, LICENSE/LICENCE, CONTRIBUTING, CODE_OF_CONDUCT, SECURITY,
|
|
20
|
+
* CODEOWNERS, and GitBook's SUMMARY (a table of contents, not a page).
|
|
21
|
+
*
|
|
22
|
+
* README is the one with a second meaning. In a DOCS tree it is GitBook's way
|
|
23
|
+
* of naming a folder's own page, and existing docs repositories rely on that,
|
|
24
|
+
* so a page-backed space keeps it as the folder's index unless its manifest
|
|
25
|
+
* says `readme: skip`. A posts space has no folder pages, so there a README is
|
|
26
|
+
* always paperwork.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MANIFEST_NAMES: string[];
|
|
29
|
+
/** Repository paperwork, by file stem (lower-cased, extension dropped). */
|
|
30
|
+
export declare const PAPERWORK: readonly ["readme", "license", "licence", "contributing", "code_of_conduct", "code-of-conduct", "security", "codeowners", "summary"];
|
|
31
|
+
/** Folders that are never content, beyond the `.` and `_` prefixes. */
|
|
32
|
+
export declare const RESERVED_FOLDERS: readonly ["node_modules"];
|
|
33
|
+
/** Is this README-shaped (`README.md`, `readme.mdx`, `Readme.markdown`)? */
|
|
34
|
+
export declare const isReadme: (name: string) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Why `name` is skipped, or null when it is content.
|
|
37
|
+
*
|
|
38
|
+
* `readmeIsIndex`: a docs space keeps README as a folder's page (see above).
|
|
39
|
+
*/
|
|
40
|
+
export declare function reservedReason(name: string, isDir: boolean, readmeIsIndex: boolean): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* The manifest's `ignore:` patterns, as a matcher over paths relative to the
|
|
43
|
+
* space folder. A small glob: `*` is any run within one segment, `**` any run
|
|
44
|
+
* of segments, `?` one character; a pattern without a `/` matches a name at
|
|
45
|
+
* any depth (`*.draft.md`), one with a `/` matches from the space folder
|
|
46
|
+
* (`archive/**`). A folder that matches is skipped with everything under it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ignoreMatcher(patterns: readonly string[] | undefined): (rel: string) => boolean;
|
|
49
|
+
//# sourceMappingURL=reserved.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/publish/reserved.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,UAA2D,CAAC;AAEvF,2EAA2E;AAC3E,eAAO,MAAM,SAAS,sIAUZ,CAAC;AAEX,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,2BAA4B,CAAC;AAI1D,4EAA4E;AAC5E,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,YAA8C,CAAC;AAEpF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,aAAa,EAAE,OAAO,GACrB,MAAM,GAAG,IAAI,CASf;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CA6B/F"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isReadme = exports.RESERVED_FOLDERS = exports.PAPERWORK = exports.MANIFEST_NAMES = void 0;
|
|
4
|
+
exports.reservedReason = reservedReason;
|
|
5
|
+
exports.ignoreMatcher = ignoreMatcher;
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
/**
|
|
8
|
+
* Names in a content folder that are never content (R-N11).
|
|
9
|
+
*
|
|
10
|
+
* A repository that holds a blog also holds a README that explains the
|
|
11
|
+
* repository, a LICENSE, editor folders and a `_drafts` folder of posts nobody
|
|
12
|
+
* has finished. Every customer publisher we were shown carried its own list of
|
|
13
|
+
* these, and the first version of each list was the one that published the
|
|
14
|
+
* README as a post — readers met "How to run this repo locally" at the top of
|
|
15
|
+
* a newsroom. The list lives here, once, and the guide prints it
|
|
16
|
+
* (docs/guides/content-as-code.md, "Reserved names").
|
|
17
|
+
*
|
|
18
|
+
* Three groups, each for its own reason:
|
|
19
|
+
*
|
|
20
|
+
* - Hidden and private: anything starting with `.` (`.git`, `.github`,
|
|
21
|
+
* `.DS_Store`) or `_` (`_drafts`, `_templates`, and the metadata files this
|
|
22
|
+
* tool reads itself: `_collection.yml`, `_tags.yml`). `node_modules`.
|
|
23
|
+
* - The manifest: `forumulate.yaml`, `.yml`, `.json`.
|
|
24
|
+
* - Repository paperwork, in any case and with any Markdown extension:
|
|
25
|
+
* README, LICENSE/LICENCE, CONTRIBUTING, CODE_OF_CONDUCT, SECURITY,
|
|
26
|
+
* CODEOWNERS, and GitBook's SUMMARY (a table of contents, not a page).
|
|
27
|
+
*
|
|
28
|
+
* README is the one with a second meaning. In a DOCS tree it is GitBook's way
|
|
29
|
+
* of naming a folder's own page, and existing docs repositories rely on that,
|
|
30
|
+
* so a page-backed space keeps it as the folder's index unless its manifest
|
|
31
|
+
* says `readme: skip`. A posts space has no folder pages, so there a README is
|
|
32
|
+
* always paperwork.
|
|
33
|
+
*/
|
|
34
|
+
exports.MANIFEST_NAMES = ['forumulate.yaml', 'forumulate.yml', 'forumulate.json'];
|
|
35
|
+
/** Repository paperwork, by file stem (lower-cased, extension dropped). */
|
|
36
|
+
exports.PAPERWORK = [
|
|
37
|
+
'readme',
|
|
38
|
+
'license',
|
|
39
|
+
'licence',
|
|
40
|
+
'contributing',
|
|
41
|
+
'code_of_conduct',
|
|
42
|
+
'code-of-conduct',
|
|
43
|
+
'security',
|
|
44
|
+
'codeowners',
|
|
45
|
+
'summary',
|
|
46
|
+
];
|
|
47
|
+
/** Folders that are never content, beyond the `.` and `_` prefixes. */
|
|
48
|
+
exports.RESERVED_FOLDERS = ['node_modules'];
|
|
49
|
+
const stemOf = (name) => name.replace(/\.[^.]*$/, '').toLowerCase();
|
|
50
|
+
/** Is this README-shaped (`README.md`, `readme.mdx`, `Readme.markdown`)? */
|
|
51
|
+
const isReadme = (name) => /^readme\.(md|mdx|markdown)$/i.test(name);
|
|
52
|
+
exports.isReadme = isReadme;
|
|
53
|
+
/**
|
|
54
|
+
* Why `name` is skipped, or null when it is content.
|
|
55
|
+
*
|
|
56
|
+
* `readmeIsIndex`: a docs space keeps README as a folder's page (see above).
|
|
57
|
+
*/
|
|
58
|
+
function reservedReason(name, isDir, readmeIsIndex) {
|
|
59
|
+
if (name.startsWith('.'))
|
|
60
|
+
return 'hidden';
|
|
61
|
+
if (name.startsWith('_'))
|
|
62
|
+
return isDir ? 'private folder' : 'private file';
|
|
63
|
+
if (exports.RESERVED_FOLDERS.includes(name))
|
|
64
|
+
return 'dependency folder';
|
|
65
|
+
if (exports.MANIFEST_NAMES.includes(name))
|
|
66
|
+
return 'the manifest';
|
|
67
|
+
if (isDir)
|
|
68
|
+
return null;
|
|
69
|
+
if ((0, exports.isReadme)(name) && readmeIsIndex)
|
|
70
|
+
return null;
|
|
71
|
+
if (exports.PAPERWORK.includes(stemOf(name)))
|
|
72
|
+
return 'repository paperwork';
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The manifest's `ignore:` patterns, as a matcher over paths relative to the
|
|
77
|
+
* space folder. A small glob: `*` is any run within one segment, `**` any run
|
|
78
|
+
* of segments, `?` one character; a pattern without a `/` matches a name at
|
|
79
|
+
* any depth (`*.draft.md`), one with a `/` matches from the space folder
|
|
80
|
+
* (`archive/**`). A folder that matches is skipped with everything under it.
|
|
81
|
+
*/
|
|
82
|
+
function ignoreMatcher(patterns) {
|
|
83
|
+
const res = (patterns ?? [])
|
|
84
|
+
.map((p) => p.trim().replace(/^\.\//, '').replace(/\/+$/, ''))
|
|
85
|
+
.filter(Boolean)
|
|
86
|
+
.map((p) => {
|
|
87
|
+
const anchored = p.includes('/');
|
|
88
|
+
let src = '';
|
|
89
|
+
for (let i = 0; i < p.length; i++) {
|
|
90
|
+
const c = p[i];
|
|
91
|
+
if (c === '*' && p[i + 1] === '*') {
|
|
92
|
+
// `**/` is "any folders, or none"; a bare `**` is "anything".
|
|
93
|
+
if (p[i + 2] === '/') {
|
|
94
|
+
src += '(?:.*/)?';
|
|
95
|
+
i += 2;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
src += '.*';
|
|
99
|
+
i += 1;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (c === '*')
|
|
103
|
+
src += '[^/]*';
|
|
104
|
+
else if (c === '?')
|
|
105
|
+
src += '[^/]';
|
|
106
|
+
else
|
|
107
|
+
src += c.replace(/[.+^${}()|[\]\\]/g, '\\$&');
|
|
108
|
+
}
|
|
109
|
+
return new RegExp(anchored ? `^${src}$` : `(?:^|/)${src}$`, 'i');
|
|
110
|
+
});
|
|
111
|
+
if (!res.length)
|
|
112
|
+
return () => false;
|
|
113
|
+
return (rel) => {
|
|
114
|
+
const path = node_path_1.posix.normalize(rel.split('\\').join('/'));
|
|
115
|
+
return res.some((re) => re.test(path));
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=reserved.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.js","sourceRoot":"","sources":["../../src/publish/reserved.ts"],"names":[],"mappings":";;;AAyDA,wCAaC;AASD,sCA6BC;AA5GD,yCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,cAAc,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAEvF,2EAA2E;AAC9D,QAAA,SAAS,GAAG;IACvB,QAAQ;IACR,SAAS;IACT,SAAS;IACT,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,UAAU;IACV,YAAY;IACZ,SAAS;CACD,CAAC;AAEX,uEAAuE;AAC1D,QAAA,gBAAgB,GAAG,CAAC,cAAc,CAAU,CAAC;AAE1D,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAE5E,4EAA4E;AACrE,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAvE,QAAA,QAAQ,YAA+D;AAEpF;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,IAAY,EACZ,KAAc,EACd,aAAsB;IAEtB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc,CAAC;IAC3E,IAAK,wBAAsC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,mBAAmB,CAAC;IACvF,IAAI,sBAAc,CAAC,QAAQ,CAA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CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,KAAK,GAAG;gBAAE,GAAG,IAAI,OAAO,CAAC;iBAChC,IAAI,CAAC,KAAK,GAAG;gBAAE,GAAG,IAAI,MAAM,CAAC;;gBAC7B,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IACL,IAAI,CAAC,GAAG,CAAC,MAAM;QAAE,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,IAAI,GAAG,iBAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -17,4 +17,16 @@ export declare function rewriteLinks(source: string, file: string, slugByFile: M
|
|
|
17
17
|
export declare function rewriteAssets(source: string, urlByRef: Map<string, string>): string;
|
|
18
18
|
/** The same substitution over a metadata patch (values that were local paths). */
|
|
19
19
|
export declare function rewriteValue<T>(value: T, urlByRef: Map<string, string>): T;
|
|
20
|
+
/**
|
|
21
|
+
* Does the live text still point at every picture the file's body uses?
|
|
22
|
+
*
|
|
23
|
+
* The word comparison (`compare.ts`) ignores link and image targets on
|
|
24
|
+
* purpose — the importer rewrites them, so they are never the same string
|
|
25
|
+
* twice. That left one change invisible: an image replaced by a new one under
|
|
26
|
+
* the same name uploads under a new content hash, and the post kept pointing
|
|
27
|
+
* at the old picture because its words had not changed. So the targets are
|
|
28
|
+
* checked here instead, by the URL each reference resolves to: one that is
|
|
29
|
+
* not uploaded yet, or not in the live text, means the body must be sent.
|
|
30
|
+
*/
|
|
31
|
+
export declare function mediaChanged(body: string, refs: Map<string, string> | undefined, urls: Map<string, string>, liveText: string): boolean;
|
|
20
32
|
//# sourceMappingURL=rewrite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../src/publish/rewrite.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CA0BR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAcnF;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ1E"}
|
|
1
|
+
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../src/publish/rewrite.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CA0BR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAcnF;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACrC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACzB,QAAQ,EAAE,MAAM,GACf,OAAO,CAOT"}
|
package/dist/publish/rewrite.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rewriteLinks = rewriteLinks;
|
|
4
4
|
exports.rewriteAssets = rewriteAssets;
|
|
5
5
|
exports.rewriteValue = rewriteValue;
|
|
6
|
+
exports.mediaChanged = mediaChanged;
|
|
6
7
|
const node_path_1 = require("node:path");
|
|
7
8
|
/**
|
|
8
9
|
* What changes between the file on disk and the text the API is sent.
|
|
@@ -79,4 +80,25 @@ function rewriteValue(value, urlByRef) {
|
|
|
79
80
|
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, rewriteValue(v, urlByRef)]));
|
|
80
81
|
return value;
|
|
81
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Does the live text still point at every picture the file's body uses?
|
|
85
|
+
*
|
|
86
|
+
* The word comparison (`compare.ts`) ignores link and image targets on
|
|
87
|
+
* purpose — the importer rewrites them, so they are never the same string
|
|
88
|
+
* twice. That left one change invisible: an image replaced by a new one under
|
|
89
|
+
* the same name uploads under a new content hash, and the post kept pointing
|
|
90
|
+
* at the old picture because its words had not changed. So the targets are
|
|
91
|
+
* checked here instead, by the URL each reference resolves to: one that is
|
|
92
|
+
* not uploaded yet, or not in the live text, means the body must be sent.
|
|
93
|
+
*/
|
|
94
|
+
function mediaChanged(body, refs, urls, liveText) {
|
|
95
|
+
for (const ref of refs?.keys() ?? []) {
|
|
96
|
+
if (!body.includes(ref))
|
|
97
|
+
continue; // a front-matter value: compared as a field
|
|
98
|
+
const url = urls.get(ref);
|
|
99
|
+
if (!url || !liveText.includes(url))
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
82
104
|
//# sourceMappingURL=rewrite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite.js","sourceRoot":"","sources":["../../src/publish/rewrite.ts"],"names":[],"mappings":";;AA2BA,oCA8BC;AAMD,sCAcC;AAGD,oCAQC;
|
|
1
|
+
{"version":3,"file":"rewrite.js","sourceRoot":"","sources":["../../src/publish/rewrite.ts"],"names":[],"mappings":";;AA2BA,oCA8BC;AAMD,sCAcC;AAGD,oCAQC;AAaD,oCAYC;AAjHD,yCAAkC;AAElC;;;;;;;;;GASG;AAEH,gEAAgE;AAChE,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAC1B,MAAc,EACd,IAAY,EACZ,UAA+B;IAE/B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,MAAM,GAAG,CAAC,GAAW,EAAiB,EAAE;QAC5C,MAAM,CAAC,GAAG,yEAAyE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9F,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpB,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,iBAAK,CAAC,SAAS,CAAC,iBAAK,CAAC,IAAI,CAAC,iBAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,CAA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,EACzB,QAAgB;IAEhB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,SAAS,CAAC,4CAA4C;QAC/E,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DocsWalk, Reader, ScanResult, SpaceSpec } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The docs half of reading a folder: one top-level folder per collection,
|
|
4
|
+
* files at the root in the root collection, nested folders as parent pages
|
|
5
|
+
* (the folder's `index.md` — or `README.md`, unless the space says
|
|
6
|
+
* `readme: skip` — is the parent; a folder without one gets a title-only stub
|
|
7
|
+
* so its children still have somewhere to hang).
|
|
8
|
+
*/
|
|
9
|
+
export declare function scanDocs(absDir: string, spec: SpaceSpec, out: ScanResult, read: Reader, w: DocsWalk): void;
|
|
10
|
+
//# sourceMappingURL=scan-docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-docs.d.ts","sourceRoot":"","sources":["../../src/publish/scan-docs.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAA8B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEnG;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,QAAQ,GACV,IAAI,CA8BN"}
|