Skip to content

Commit 84ddc25

Browse files
committed
Merge branch 'main' into add-cli-docs
2 parents 08f6550 + 229698f commit 84ddc25

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

apps/svelte.dev/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"@types/node": "^20.14.2",
7575
"@vercel/speed-insights": "^1.0.0",
7676
"browserslist": "^4.23.1",
77+
"chokidar": "^4.0.1",
7778
"degit": "^2.8.4",
7879
"dotenv": "^16.4.5",
7980
"esbuild": "^0.21.5",

apps/svelte.dev/scripts/sync-docs/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import path from 'node:path';
33
import fs from 'node:fs';
44
import ts from 'typescript';
55
import glob from 'tiny-glob/sync';
6+
import chokidar from 'chokidar';
67
import { fileURLToPath } from 'node:url';
7-
import { clone_repo, migrate_meta_json, replace_strings, strip_origin } from './utils';
8+
import { clone_repo, migrate_meta_json, strip_origin } from './utils';
89
import { get_types, read_d_ts_file, read_types } from './types';
910
import type { Modules } from '@sveltejs/site-kit/markdown';
1011

@@ -131,7 +132,7 @@ if (process.env.USE_GIT === 'true') {
131132
);
132133
}
133134

134-
for (const pkg of packages) {
135+
async function sync(pkg: Package) {
135136
const dest = `${DOCS}/${pkg.name}`;
136137

137138
fs.rmSync(dest, { force: true, recursive: true });
@@ -151,3 +152,17 @@ for (const pkg of packages) {
151152
fs.writeFileSync(file, content);
152153
}
153154
}
155+
156+
for (const pkg of packages) {
157+
await sync(pkg);
158+
}
159+
160+
if (process.argv.includes('-w') || process.argv.includes('--watch')) {
161+
for (const pkg of packages) {
162+
chokidar
163+
.watch(`${REPOS}/${pkg.name}/${pkg.docs}`, { ignoreInitial: true })
164+
.on('all', (event) => {
165+
sync(pkg);
166+
});
167+
}
168+
}

apps/svelte.dev/scripts/sync-docs/utils.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ export function invoke(cmd: string, args: string[], opts: SpawnOptions) {
3434
});
3535
}
3636

37-
export function replace_strings(obj: any, replace: (str: string) => string) {
38-
for (let key in obj) {
39-
if (typeof obj[key] === 'object') {
40-
replace_strings(obj[key], replace);
41-
} else if (typeof obj[key] === 'string') {
42-
obj[key] = replace(obj[key]);
43-
}
44-
}
45-
}
46-
4737
/** Older versions of the documentation did use meta.json instead of index.md */
4838
export function migrate_meta_json(path: string) {
4939
const files = glob(`${path}/**/meta.json`);

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)