-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
316 additions
and
234 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { getFiles, getRoot } from "../utils.ts"; | ||
import { docsPattern, getFiles, getRoot } from "../utils.ts"; | ||
|
||
for await (const dir of await getFiles("**/{apps,scripts,docs}/**/{docs,doc}", { | ||
for await ( | ||
const dir of await getFiles(docsPattern, { | ||
root: getRoot(), | ||
exclude: ["_site"], | ||
includeDirs: true | ||
})) { | ||
await Deno.remove(dir.path, { recursive: true }); | ||
exclude: ["_site", "scripts/doc"], | ||
includeDirs: true, | ||
}) | ||
) { | ||
await Deno.remove(dir.path, { recursive: true }); | ||
} | ||
|
||
console.log("\n%c>> Deleted all docs folders", "color:#C68FE6") | ||
console.log("\n%c>> Deleted all docs folders", "color:#C68FE6"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,61 @@ | ||
import { join } from "@std/path"; | ||
import { existsSync } from "@std/fs/exists"; | ||
import { parse } from "@std/path/parse"; | ||
import remarkFrontmatter from 'npm:remark-frontmatter' | ||
import remarkParse from 'npm:remark-parse' | ||
import remarkStringify from 'npm:remark-stringify' | ||
import remarkToc from 'npm:remark-toc' | ||
import { unified } from 'npm:unified' | ||
import { read } from 'npm:to-vfile' | ||
import { visit } from 'npm:unist-util-visit' | ||
import { getFiles, globMdPattern, getRoot, appsNS, docPath } from "../utils.ts"; | ||
import remarkFrontmatter from "npm:remark-frontmatter"; | ||
import remarkParse from "npm:remark-parse"; | ||
import remarkStringify from "npm:remark-stringify"; | ||
import remarkToc from "npm:remark-toc"; | ||
import { unified } from "npm:unified"; | ||
import { read } from "npm:to-vfile"; | ||
import { visit } from "npm:unist-util-visit"; | ||
import { appsNS, docPath, getFiles, getRoot, globMdPattern } from "../utils.ts"; | ||
|
||
const root = getRoot() | ||
const root = getRoot(); | ||
|
||
for await (const file of await getFiles(globMdPattern, { | ||
for await ( | ||
const file of await getFiles(globMdPattern, { | ||
root, | ||
includeDirs: false, | ||
exclude: ['**/docs/doc'] | ||
})) { | ||
const { path } = file; | ||
exclude: ["**/docs/doc"], | ||
}) | ||
) { | ||
const { path } = file; | ||
|
||
// Copy readme to docs | ||
const { dir } = parse(path) | ||
const distDir = !dir.includes(appsNS) ? join(root, docPath) : dir.replace(appsNS, join(docPath, appsNS)) | ||
if (!existsSync(distDir)) await Deno.mkdir(distDir, { recursive: true }) | ||
await Deno.copyFile(path, join(distDir, 'index.md')) | ||
// Copy readme to docs | ||
const { dir } = parse(path); | ||
const distDir = !dir.includes(appsNS) | ||
? join(root, docPath) | ||
: dir.replace(appsNS, join(docPath, appsNS)); | ||
if (!existsSync(distDir)) await Deno.mkdir(distDir, { recursive: true }); | ||
await Deno.copyFile(path, join(distDir, "index.md")); | ||
|
||
// Refactor | ||
const mdfile = await unified() | ||
.use(remarkParse) | ||
.use(remarkToc) | ||
.use(remarkStringify) | ||
.use(remarkFrontmatter, ['yaml']) | ||
.use(() => { | ||
// deno-lint-ignore no-explicit-any | ||
return (tree: any) => { | ||
visit(tree, 'yaml', (node) => { | ||
node.value = node.value.replace('layout: \'\'', 'layout: \'layouts/apps.vto\'') | ||
return node | ||
}) | ||
return tree | ||
} | ||
}) | ||
.process(await read(join(distDir, 'index.md'))) | ||
// Refactor | ||
const mdfile = await unified() | ||
.use(remarkParse) | ||
.use(remarkToc) | ||
.use(remarkStringify) | ||
.use(remarkFrontmatter, ["yaml"]) | ||
.use(() => { | ||
// deno-lint-ignore no-explicit-any | ||
return (tree: any) => { | ||
visit(tree, "yaml", (node) => { | ||
node.value = node.value.replace( | ||
"layout: ''", | ||
"layout: 'layouts/apps.vto'", | ||
); | ||
return node; | ||
}); | ||
return tree; | ||
}; | ||
}) | ||
.process(await read(join(distDir, "index.md"))); | ||
|
||
const encoder = new TextEncoder(); | ||
const data = encoder.encode(String(mdfile)); | ||
await Deno.writeFile(join(distDir, 'index.md'), data, { create: false, append: false }) | ||
const encoder = new TextEncoder(); | ||
const data = encoder.encode(String(mdfile)); | ||
await Deno.writeFile(join(distDir, "index.md"), data, { | ||
create: false, | ||
append: false, | ||
}); | ||
} | ||
|
||
console.log("\n%c>> Readme for docs", "color:#C68FE6") | ||
console.log("\n%c>> Readme for docs", "color:#C68FE6"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,71 @@ | ||
import { dirname } from "jsr:@std/path/dirname"; | ||
import { exec } from "node:child_process"; | ||
import { promisify } from "node:util"; | ||
import { getFiles, denoDocsPattern, runtimeMapper, isYarn, isPnpm, getRoot } from "../utils.ts"; | ||
import { | ||
denoDocsPattern, | ||
getFiles, | ||
getRoot, | ||
isPnpm, | ||
isYarn, | ||
runtimeMapper, | ||
} from "../utils.ts"; | ||
import { Output } from "../types.ts"; | ||
import { Agent } from "../types.ts"; | ||
|
||
const exca = promisify(exec); | ||
const getCmd = async (agent: Agent, cwd: string, cmd: { doc: string }) => `${agent === 'node' ? await isPnpm(cwd) ? 'pnpm run' : await isYarn(cwd) ? 'yarn run' : 'npm run' : agent} ${cmd?.doc || 'doc'}` | ||
const getCmd = async (agent: Agent, cwd: string, cmd: { doc: string }) => | ||
`${ | ||
agent === "node" | ||
? await isPnpm(cwd) | ||
? "pnpm run" | ||
: await isYarn(cwd) | ||
? "yarn run" | ||
: "npm run" | ||
: agent | ||
} ${cmd?.doc || "doc"}`; | ||
|
||
for await (const file of await getFiles(denoDocsPattern, { | ||
root: getRoot() | ||
})) { | ||
const { name, path } = file; | ||
const { agent, cmd = { doc: 'doc' } } = runtimeMapper[name] | ||
const cwd = dirname(path) | ||
for await ( | ||
const file of await getFiles(denoDocsPattern, { | ||
root: getRoot(), | ||
}) | ||
) { | ||
const { name, path } = file; | ||
const { agent, cmd = { doc: "doc" } } = runtimeMapper[name]; | ||
const cwd = dirname(path); | ||
|
||
let outputs: Output[] = [] | ||
if (typeof agent === 'string') { | ||
const $cmd = await getCmd(agent, cwd, cmd) | ||
let outputs: Output[] = []; | ||
if (typeof agent === "string") { | ||
const $cmd = await getCmd(agent, cwd, cmd); | ||
const { stderr, stdout } = await exca($cmd, { | ||
cwd, | ||
}); | ||
outputs.push({ | ||
stderr, | ||
stdout, | ||
}); | ||
} else { | ||
outputs = await Promise.all(agent.map(async (ag) => { | ||
const $cmd = await getCmd(ag, cwd, cmd); | ||
if (path.includes(ag)) { | ||
const { stderr, stdout } = await exca($cmd, { | ||
cwd, | ||
cwd, | ||
}); | ||
outputs.push({ | ||
stderr, | ||
stdout | ||
}) | ||
} else { | ||
outputs = await Promise.all(agent.map(async (ag) => { | ||
const $cmd = await getCmd(ag, cwd, cmd) | ||
if (path.includes(ag)) { | ||
const { stderr, stdout } = await exca($cmd, { | ||
cwd, | ||
}); | ||
return { stderr, stdout } | ||
} else { | ||
return { | ||
stderr: '', | ||
stdout: '' | ||
} | ||
} | ||
})) | ||
} | ||
return { stderr, stdout }; | ||
} else { | ||
return { | ||
stderr: "", | ||
stdout: "", | ||
}; | ||
} | ||
})); | ||
} | ||
|
||
outputs | ||
.filter(i => i.stderr && i.stdout) | ||
.map(({ stdout, stderr }) => { | ||
if (stdout) console.log("stdout:", stdout); | ||
if (stderr && !stderr.includes('$')) console.error("stderr:", stderr); | ||
}) | ||
outputs | ||
.filter((i) => i.stderr && i.stdout) | ||
.map(({ stdout, stderr }) => { | ||
if (stdout) console.log("stdout:", stdout); | ||
if (stderr && !stderr.includes("$")) console.error("stderr:", stderr); | ||
}); | ||
} | ||
|
||
console.log("\n%c>> Generated docs", "color:#C68FE6") | ||
console.log("\n%c>> Generated docs", "color:#C68FE6"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,66 @@ | ||
import { dirname } from "jsr:@std/path/dirname"; | ||
import { exec } from "node:child_process"; | ||
import { promisify } from "node:util"; | ||
import { getFiles, configPattern, runtimeMapper, isYarn, isPnpm } from "../utils.ts"; | ||
import { | ||
configPattern, | ||
getFiles, | ||
isPnpm, | ||
isYarn, | ||
runtimeMapper, | ||
} from "../utils.ts"; | ||
import { Output } from "../types.ts"; | ||
import { Agent } from "../types.ts"; | ||
|
||
const exca = promisify(exec); | ||
const getCmd = async (agent: Agent, cwd: string, cmd: { check: string }) => `${agent === 'node' ? await isPnpm(cwd) ? 'pnpm run' : await isYarn(cwd) ? 'yarn run' : 'npm run' : agent} ${cmd?.check || 'check'}` | ||
const getCmd = async (agent: Agent, cwd: string, cmd: { check: string }) => | ||
`${ | ||
agent === "node" | ||
? await isPnpm(cwd) | ||
? "pnpm run" | ||
: await isYarn(cwd) | ||
? "yarn run" | ||
: "npm run" | ||
: agent | ||
} ${cmd?.check || "check"}`; | ||
|
||
for await (const file of await getFiles(configPattern)) { | ||
const { name, path } = file; | ||
const { agent, cmd = { check: 'check' } } = runtimeMapper[name] | ||
const cwd = dirname(path) | ||
const { name, path } = file; | ||
const { agent, cmd = { check: "check" } } = runtimeMapper[name]; | ||
const cwd = dirname(path); | ||
|
||
let outputs: Output[] = [] | ||
if (typeof agent === 'string') { | ||
const $cmd = await getCmd(agent, cwd, cmd) | ||
let outputs: Output[] = []; | ||
if (typeof agent === "string") { | ||
const $cmd = await getCmd(agent, cwd, cmd); | ||
const { stderr, stdout } = await exca($cmd, { | ||
cwd, | ||
}); | ||
outputs.push({ | ||
stderr, | ||
stdout, | ||
}); | ||
} else { | ||
outputs = await Promise.all(agent.map(async (ag) => { | ||
const $cmd = await getCmd(ag, cwd, cmd); | ||
if (path.includes(ag)) { | ||
console.log(path); | ||
const { stderr, stdout } = await exca($cmd, { | ||
cwd, | ||
cwd, | ||
}); | ||
outputs.push({ | ||
stderr, | ||
stdout | ||
}) | ||
} else { | ||
outputs = await Promise.all(agent.map(async (ag) => { | ||
const $cmd = await getCmd(ag, cwd, cmd) | ||
if (path.includes(ag)) { | ||
console.log(path); | ||
const { stderr, stdout } = await exca($cmd, { | ||
cwd, | ||
}); | ||
return { stderr, stdout } | ||
} else { | ||
return { | ||
stderr: '', | ||
stdout: '' | ||
} | ||
} | ||
})) | ||
} | ||
return { stderr, stdout }; | ||
} else { | ||
return { | ||
stderr: "", | ||
stdout: "", | ||
}; | ||
} | ||
})); | ||
} | ||
|
||
outputs | ||
.filter(i => i.stderr && i.stdout) | ||
.map(({ stdout, stderr }) => { | ||
if (stdout) console.log("stdout:", stdout); | ||
if (stderr && !stderr.includes('$')) console.error("stderr:", stderr); | ||
}) | ||
outputs | ||
.filter((i) => i.stderr && i.stdout) | ||
.map(({ stdout, stderr }) => { | ||
if (stdout) console.log("stdout:", stdout); | ||
if (stderr && !stderr.includes("$")) console.error("stderr:", stderr); | ||
}); | ||
} | ||
console.log("\n%c>> Complement all checking", "color:#C68FE6") | ||
console.log("\n%c>> Complement all checking", "color:#C68FE6"); |
Oops, something went wrong.