-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: split docs.api.json into multiple json files
- Loading branch information
Showing
28 changed files
with
1,144 additions
and
62 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", | ||
"formatter": { | ||
"enabled": true, | ||
"formatWithErrors": false, | ||
"indentStyle": "tab", | ||
"indentWidth": 2, | ||
"lineWidth": 120, | ||
"lineEnding": "lf", | ||
"ignore": [ | ||
".turbo", | ||
".vercel", | ||
".contentlayer", | ||
".next", | ||
"coverage", | ||
"dist", | ||
"dist-docs", | ||
"docs", | ||
"CHANGELOG.md", | ||
"tsup.config.bundled*" | ||
] | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"enabled": true, | ||
"quoteStyle": "single", | ||
"quoteProperties": "asNeeded", | ||
"trailingComma": "all", | ||
"semicolons": "always" | ||
} | ||
}, | ||
"files": { | ||
"ignoreUnknown": true, | ||
"maxSize": 1000000 | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: 'Upload split documentation' | ||
description: 'Splits and uploads the docs.api.json file into more fine-grained [item].api.json files' | ||
inputs: | ||
package: | ||
description: 'The package string' | ||
version: | ||
description: 'The semver string' | ||
runs: | ||
using: node20 | ||
main: ../../dist/uploadSplitDocumentation/index.js |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { readFile } from 'node:fs/promises'; | ||
import { basename } from 'node:path'; | ||
import process from 'node:process'; | ||
import { getInput, setFailed } from '@actions/core'; | ||
import { create } from '@actions/glob'; | ||
import { put } from '@vercel/blob'; | ||
import { createPool } from '@vercel/postgres'; | ||
|
||
if (!process.env.DATABASE_URL) { | ||
setFailed('DATABASE_URL is not set'); | ||
} | ||
|
||
const pkg = getInput('package') || '*'; | ||
const version = getInput('version') || 'main'; | ||
|
||
const pool = createPool({ | ||
connectionString: process.env.DATABASE_URL, | ||
}); | ||
|
||
const globber = await create(`packages/${pkg}/docs/split/main.*.*.api.json`); | ||
for await (const file of globber.globGenerator()) { | ||
const data = await readFile(file, 'utf8'); | ||
try { | ||
console.log(`Uploading ${file} with ${version}...`); | ||
const name = basename(file).replace('main.', ''); | ||
const { url } = await put(`${version}.${name}`, data, { | ||
access: 'public', | ||
addRandomSuffix: false, | ||
}); | ||
await pool.sql`insert into documentation (name, version, url) values (${name}, ${version}, ${url}) on conflict (name, version) do update set url = EXCLUDED.url`; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} |
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"lib": "src" | ||
}, | ||
"files": [ | ||
"bin/index.js", | ||
"dist" | ||
], | ||
"contributors": [ | ||
|
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env node | ||
require('../dist/bin/generateSplitDocumentation.js'); |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable n/shebang */ | ||
import { readFile } from 'node:fs/promises'; | ||
import process from 'node:process'; | ||
import { createCommand } from 'commander'; | ||
import packageFile from '../package.json'; | ||
import { generateSplitDocumentation } from '../src/index.js'; | ||
|
||
export interface CLIOptions { | ||
custom: string; | ||
input: string[]; | ||
newOutput: string; | ||
output: string; | ||
root: string; | ||
typescript: boolean; | ||
} | ||
|
||
const command = createCommand().version(packageFile.version); | ||
|
||
const program = command.parse(process.argv); | ||
program.opts<CLIOptions>(); | ||
|
||
console.log('Generating split documentation...'); | ||
void generateSplitDocumentation({ | ||
fetchPackageVersions: async (_) => { | ||
return ['main']; | ||
}, | ||
fetchPackageVersionDocs: async (_, __) => { | ||
return JSON.parse(await readFile(`${process.cwd()}/docs/docs.api.json`, 'utf8')); | ||
}, | ||
}).then(() => console.log('Generated split documentation.')); |
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
Oops, something went wrong.