@tenphi/cookbook 0.4.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/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +78 -0
- package/dist/cli.js.map +1 -0
- package/dist/components.d.ts +3 -0
- package/dist/components.js +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrey Yamanov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @tenphi/cookbook
|
|
2
|
+
|
|
3
|
+
Install the complete integration with `npx astro add @tenphi/cookbook`:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { defineConfig } from "astro/config";
|
|
7
|
+
import cookbook from "@tenphi/cookbook";
|
|
8
|
+
|
|
9
|
+
export default defineConfig({ integrations: [cookbook()] });
|
|
10
|
+
```
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createDocsGraph, defaultLock, formatDiagnostics, readDocsLock, resolvePackageLock, writeDocsLock } from "@tenphi/docs";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
import { createJiti } from "jiti";
|
|
7
|
+
//#region src/cli.ts
|
|
8
|
+
const { positionals, values } = parseArgs({
|
|
9
|
+
allowPositionals: true,
|
|
10
|
+
options: {
|
|
11
|
+
json: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
root: { type: "string" },
|
|
16
|
+
help: {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
short: "h",
|
|
19
|
+
default: false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
if (values.help || positionals.length === 0) printHelp();
|
|
24
|
+
else {
|
|
25
|
+
const command = positionals[0];
|
|
26
|
+
const root = resolve(values.root ?? process.cwd());
|
|
27
|
+
if (command === "doctor") await doctor(root, values.json);
|
|
28
|
+
else if (command === "update") await update(root, values.json);
|
|
29
|
+
else {
|
|
30
|
+
console.error(`Unknown command: ${command ?? ""}`);
|
|
31
|
+
printHelp(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function doctor(root, json) {
|
|
35
|
+
const config = await loadConfig(root);
|
|
36
|
+
const graph = await createDocsGraph({
|
|
37
|
+
root,
|
|
38
|
+
...config ? { config } : {}
|
|
39
|
+
});
|
|
40
|
+
if (graph.diagnostics.length > 0) console.log(formatDiagnostics(graph.diagnostics, json));
|
|
41
|
+
else if (json) console.log(JSON.stringify({
|
|
42
|
+
ok: true,
|
|
43
|
+
pages: graph.entries.length
|
|
44
|
+
}));
|
|
45
|
+
else console.log(`Cookbook is healthy: ${graph.entries.length} pages, ${graph.assets.length} assets.`);
|
|
46
|
+
if (graph.diagnostics.some((diagnostic) => diagnostic.severity === "error")) process.exitCode = 1;
|
|
47
|
+
}
|
|
48
|
+
async function update(root, json) {
|
|
49
|
+
const existing = await readDocsLock(root);
|
|
50
|
+
if (!existing || existing.sources.length === 0) throw new Error("No package sources are present in cookbook.lock.json.");
|
|
51
|
+
const sources = [];
|
|
52
|
+
for (const current of existing.sources) sources.push(await resolvePackageLock(current.requested, { registry: current.registry }));
|
|
53
|
+
const next = defaultLock(sources);
|
|
54
|
+
await writeDocsLock(root, next);
|
|
55
|
+
if (json) console.log(JSON.stringify(next, null, 2));
|
|
56
|
+
else {
|
|
57
|
+
for (const source of next.sources) console.log(`${source.requested} -> ${source.resolved}`);
|
|
58
|
+
console.log("Updated cookbook.lock.json.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function loadConfig(root) {
|
|
62
|
+
const path = [
|
|
63
|
+
"docs.config.ts",
|
|
64
|
+
"docs.config.mts",
|
|
65
|
+
"docs.config.js",
|
|
66
|
+
"docs.config.mjs"
|
|
67
|
+
].map((name) => resolve(root, name)).find(existsSync);
|
|
68
|
+
if (!path) return void 0;
|
|
69
|
+
return await createJiti(import.meta.url, { interopDefault: true }).import(path, { default: true });
|
|
70
|
+
}
|
|
71
|
+
function printHelp(code = 0) {
|
|
72
|
+
console.log(`Usage: cookbook <command> [options]\n\nCommands:\n doctor Validate sources, routes, links, assets, and theme\n update Resolve package sources and refresh the integrity lock\n\nOptions:\n --root <directory>\n --json\n -h, --help`);
|
|
73
|
+
process.exit(code);
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export {};
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport {\n createDocsGraph,\n defaultLock,\n formatDiagnostics,\n readDocsLock,\n resolvePackageLock,\n writeDocsLock,\n type DocsConfig,\n} from \"@tenphi/docs\";\nimport { createJiti } from \"jiti\";\n\nconst { positionals, values } = parseArgs({\n allowPositionals: true,\n options: {\n json: { type: \"boolean\", default: false },\n root: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n});\n\nif (values.help || positionals.length === 0) {\n printHelp();\n} else {\n const command = positionals[0];\n const root = resolve(values.root ?? process.cwd());\n if (command === \"doctor\") await doctor(root, values.json);\n else if (command === \"update\") await update(root, values.json);\n else {\n console.error(`Unknown command: ${command ?? \"\"}`);\n printHelp(1);\n }\n}\n\nasync function doctor(root: string, json: boolean): Promise<void> {\n const config = await loadConfig(root);\n const graph = await createDocsGraph({ root, ...(config ? { config } : {}) });\n if (graph.diagnostics.length > 0)\n console.log(formatDiagnostics(graph.diagnostics, json));\n else if (json)\n console.log(JSON.stringify({ ok: true, pages: graph.entries.length }));\n else\n console.log(\n `Cookbook is healthy: ${graph.entries.length} pages, ${graph.assets.length} assets.`,\n );\n if (graph.diagnostics.some((diagnostic) => diagnostic.severity === \"error\"))\n process.exitCode = 1;\n}\n\nasync function update(root: string, json: boolean): Promise<void> {\n const existing = await readDocsLock(root);\n if (!existing || existing.sources.length === 0) {\n throw new Error(\"No package sources are present in cookbook.lock.json.\");\n }\n const sources = [];\n for (const current of existing.sources) {\n sources.push(\n await resolvePackageLock(current.requested, {\n registry: current.registry,\n }),\n );\n }\n const next = defaultLock(sources);\n await writeDocsLock(root, next);\n if (json) console.log(JSON.stringify(next, null, 2));\n else {\n for (const source of next.sources)\n console.log(`${source.requested} -> ${source.resolved}`);\n console.log(\"Updated cookbook.lock.json.\");\n }\n}\n\nasync function loadConfig(root: string): Promise<DocsConfig | undefined> {\n const path = [\n \"docs.config.ts\",\n \"docs.config.mts\",\n \"docs.config.js\",\n \"docs.config.mjs\",\n ]\n .map((name) => resolve(root, name))\n .find(existsSync);\n if (!path) return undefined;\n const jiti = createJiti(import.meta.url, { interopDefault: true });\n return (await jiti.import(path, { default: true })) as DocsConfig;\n}\n\nfunction printHelp(code = 0): never {\n console.log(\n `Usage: cookbook <command> [options]\\n\\nCommands:\\n doctor Validate sources, routes, links, assets, and theme\\n update Resolve package sources and refresh the integrity lock\\n\\nOptions:\\n --root <directory>\\n --json\\n -h, --help`,\n );\n process.exit(code);\n}\n"],"mappings":";;;;;;;AAcA,MAAM,EAAE,aAAa,WAAW,UAAU;CACxC,kBAAkB;CAClB,SAAS;EACP,MAAM;GAAE,MAAM;GAAW,SAAS;EAAM;EACxC,MAAM,EAAE,MAAM,SAAS;EACvB,MAAM;GAAE,MAAM;GAAW,OAAO;GAAK,SAAS;EAAM;CACtD;AACF,CAAC;AAED,IAAI,OAAO,QAAQ,YAAY,WAAW,GACxC,UAAU;KACL;CACL,MAAM,UAAU,YAAY;CAC5B,MAAM,OAAO,QAAQ,OAAO,QAAQ,QAAQ,IAAI,CAAC;CACjD,IAAI,YAAY,UAAU,MAAM,OAAO,MAAM,OAAO,IAAI;MACnD,IAAI,YAAY,UAAU,MAAM,OAAO,MAAM,OAAO,IAAI;MACxD;EACH,QAAQ,MAAM,oBAAoB,WAAW,IAAI;EACjD,UAAU,CAAC;CACb;AACF;AAEA,eAAe,OAAO,MAAc,MAA8B;CAChE,MAAM,SAAS,MAAM,WAAW,IAAI;CACpC,MAAM,QAAQ,MAAM,gBAAgB;EAAE;EAAM,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAAG,CAAC;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,QAAQ,KAAK,IAAI;AACnB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
|
|
2
|
+
import starlight_default, { CookbookOptions, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS } from "@tenphi/starlight";
|
|
3
|
+
import { BrandConfig, BuildConfig, ComponentsConfig, ContentConfig, DocsAsset, DocsConfig, DocsDiagnostic, DocsEntry, DocsFrontmatter, DocsGraph, DocsRoute, DocsSource, MarkdownConfig, NavigationConfig, NavigationItem, NavigationTab, SearchConfig, SiteConfig, ThemeConfig, ThemePaletteConfig, ThemeTokenValue, ThemeTokens, TypographyPreset, TypographyPresets, defineDocsConfig } from "@tenphi/docs";
|
|
4
|
+
export { type BrandConfig, type BuildConfig, type ComponentsConfig, type ContentConfig, type CookbookOptions, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, type DocsAsset, type DocsConfig, type DocsDiagnostic, type DocsEntry, type DocsFrontmatter, type DocsGraph, type DocsRoute, type DocsSource, type MarkdownConfig, type NavigationConfig, type NavigationItem, type NavigationTab, type SearchConfig, type SiteConfig, type ThemeConfig, type ThemePaletteConfig, type ThemeTokenValue, type ThemeTokens, type TypographyPreset, type TypographyPresets, starlight_default as default, defineDocsConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import starlight_default, { DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS } from "@tenphi/starlight";
|
|
3
|
+
import { defineDocsConfig } from "@tenphi/docs";
|
|
4
|
+
export { DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, starlight_default as default, defineDocsConfig };
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tenphi/cookbook",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Repository-native static documentation for Astro",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"astro-integration",
|
|
8
|
+
"astro",
|
|
9
|
+
"documentation",
|
|
10
|
+
"starlight",
|
|
11
|
+
"static-site"
|
|
12
|
+
],
|
|
13
|
+
"bin": {
|
|
14
|
+
"cookbook": "./dist/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./components": {
|
|
22
|
+
"types": "./dist/components.d.ts",
|
|
23
|
+
"import": "./dist/components.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22.14"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/tenphi/cookbook.git",
|
|
40
|
+
"directory": "packages/facade"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/tenphi/cookbook#readme",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/tenphi/cookbook/issues"
|
|
45
|
+
},
|
|
46
|
+
"author": "Andrey Yamanov",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@tenphi/docs": "0.4.0",
|
|
50
|
+
"@tenphi/starlight": "0.4.0",
|
|
51
|
+
"jiti": "^2.6.1"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"astro": "^7.2.9"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"astro": "^7.2.9",
|
|
58
|
+
"@types/node": "^22.15.2",
|
|
59
|
+
"tsdown": "^0.22.14",
|
|
60
|
+
"typescript": "^7.0.2",
|
|
61
|
+
"vitest": "^4.1.11"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsdown --config tsdown.config.ts",
|
|
65
|
+
"clean": "rm -rf dist",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"test": "vitest run"
|
|
68
|
+
}
|
|
69
|
+
}
|