Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add multiple doc projects support when generating JsDocs #468

Merged
merged 8 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading