Skip to content

Commit

Permalink
Merge pull request #468 from LIT-Protocol/feat/add-multi-doc-support
Browse files Browse the repository at this point in the history
feat: add multiple doc projects support when generating JsDocs
  • Loading branch information
joshLong145 committed Jun 3, 2024
2 parents 1e7ceb1 + b8d3313 commit 19b0bb3
Show file tree
Hide file tree
Showing 4 changed files with 1,962 additions and 1,786 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"eslint-plugin-react-hooks": "4.6.0",
"ethereum-abi-types-generator": "^1.3.2",
"express": "^4.18.2",
"inquirer": "^9.2.21",
"jest": "27.5.1",
"lerna": "^5.4.3",
"live-server": "^1.2.2",
Expand Down
31 changes: 27 additions & 4 deletions tools/scripts/gen-doc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,40 @@ import {
createDirs,
} from './utils.mjs';
import * as liveServer from 'live-server';
import inquirer from 'inquirer';

const VERCEL_PROJECT = {
V5: 'prj_Xq6tl0JfFOmWlCLlMkh0B5rzFHoK',
V6: 'prj_Ed96nvLrMCQgjVN252BmnHD1kRy4',
};

const args = getArgs();

const FLAG = args[0];
const VERCEL_PROJECT_ID = 'prj_Xq6tl0JfFOmWlCLlMkh0B5rzFHoK';
const VERCEL_ORG_ID = 'team_BYVnuWp5MA5ra1UCzHa2XsCD';

if (!FLAG) {
console.log('\n----- Available flags -----');
console.log('1. --open to open the docs in browser');
console.log('1. --preview to open the docs in browser');
console.log('2. --push to build & push the docs to vercel');
console.log('\n');
}

async function selectProject() {
const { project } = await inquirer.prompt([
{
type: 'list',
name: 'project',
message: 'Select the Vercel project to push to:',
choices: [
{ name: 'V5', value: VERCEL_PROJECT.V5 },
{ name: 'V6', value: VERCEL_PROJECT.V6 },
],
},
]);
return project;
}

const TARGET = 'typedoc.json';

const jsonFile = await readJsonFile(TARGET);
Expand All @@ -42,7 +63,7 @@ greenLog(`${TARGET} has been updated.`);
greenLog(`generating typedoc...`);
await runCommand(`yarn typedoc --options ${TARGET}`);

if (FLAG === '--open') {
if (FLAG === '--preview') {
// await runCommand(`open ./docs/index.html`);
liveServer.default.start({
port: 4004, // Set the server port. Defaults to 8080.
Expand All @@ -57,9 +78,11 @@ if (FLAG === '--open') {
// middleware: [function(req, res, next) { next(); }] // Takes an array of Connect-compatible middleware that are injected into the server middleware stack
});
} else if (FLAG === '--push') {
const projectId = await selectProject(); // Prompt user to select a project

createDirs('doc/.vercel');
writeJsonFile('doc/.vercel/project.json', {
projectId: VERCEL_PROJECT_ID,
projectId: projectId,
orgId: VERCEL_ORG_ID,
});

Expand Down
4 changes: 3 additions & 1 deletion tools/scripts/gen-readme.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { join } from 'path';
import { exit } from 'process';
import { greenLog, listDirsRecursive, redLog } from './utils.mjs';

const TAG = process.env.TAG ? `/${process.env.TAG}` : '';

const readmePath = join('README.md');
const readme = readFileSync(readmePath, 'utf8');

Expand Down Expand Up @@ -37,7 +39,7 @@ const getSize = (lib) => {
const getNpm = (lib) => {
// return `<a target="_blank" href="https://www.npmjs.com/package/${lib}">npm</a>`;
// return `<a href="https://www.npmjs.com/package/${lib}"><img src="https://img.shields.io/npm/dw/${lib}?label=NPM"/></a>`;
return `<a target="_blank" href="https://www.npmjs.com/package/${lib}"><img src="https://img.shields.io/npm/v/${lib}"/></a>`;
return `<a target="_blank" href="https://www.npmjs.com/package/${lib}"><img src="https://img.shields.io/npm/v/${lib}${TAG}"/></a>`;
};

const libs = (await listDirsRecursive('packages', false)).map((lib) =>
Expand Down
Loading

0 comments on commit 19b0bb3

Please sign in to comment.