Skip to content

feat: build custom documentation website with next.js #18

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

Merged
merged 52 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bd6d37e
fix: read me image
sarthakjdev Apr 24, 2024
e9f862a
feat: add docs with nextjs
sarthakjdev Apr 27, 2024
3833d6f
feat: WIP
sarthakjdev Apr 27, 2024
187be61
feat: WIP
sarthakjdev Apr 27, 2024
9aa826a
feat: WIP
sarthakjdev Apr 27, 2024
6177c97
feat: WIP
sarthakjdev Apr 27, 2024
21bd6fa
feat: landing page ready
sarthakjdev Apr 27, 2024
655e50d
feat: wip
sarthakjdev Apr 27, 2024
83b4cf2
feat: wip
sarthakjdev Apr 27, 2024
1668893
feat: wip
sarthakjdev Apr 27, 2024
69fbaa5
feat: wip
sarthakjdev Apr 28, 2024
9273483
feat: wip
sarthakjdev Apr 28, 2024
1b8075e
feat: wip
sarthakjdev Apr 28, 2024
33c3875
feat: wip
sarthakjdev Apr 28, 2024
912abb9
feat: wip
sarthakjdev Apr 28, 2024
c5c7d0e
feat: wip
sarthakjdev Apr 28, 2024
49b0db8
feat: wip
sarthakjdev Apr 28, 2024
df4bd08
feat: wip
sarthakjdev Apr 28, 2024
1c3bcfe
feat: wip
sarthakjdev Apr 28, 2024
0752648
feat: wip
sarthakjdev Apr 28, 2024
d99b4d3
feat: wip
sarthakjdev Apr 28, 2024
8df1f25
feat: wip
sarthakjdev Apr 28, 2024
9ede57b
feat: wip
sarthakjdev Apr 28, 2024
f5c6ce6
feat: wip
sarthakjdev Apr 28, 2024
fe42814
feat: wip
sarthakjdev Apr 28, 2024
8a36ada
feat: wip
sarthakjdev Apr 28, 2024
80d50a0
feat: wip
sarthakjdev Apr 28, 2024
8a51978
feat: wip
sarthakjdev Apr 28, 2024
213e9a7
feat: wip
sarthakjdev Apr 28, 2024
2efc481
test: workflow
sarthakjdev Apr 28, 2024
910213b
feat: add favicon data
sarthakjdev Apr 29, 2024
745a2d3
feat: docs WIP
sarthakjdev Apr 29, 2024
64ead9f
feat: docs WIP
sarthakjdev Apr 29, 2024
12ec4fc
feat: basic documentation rendering is okay, UI needs to done only
sarthakjdev May 2, 2024
633b9a1
feat: documentation for class fix
sarthakjdev May 4, 2024
afecd9f
fix: lint
sarthakjdev May 5, 2024
0026c10
feat: add jsdoc
sarthakjdev May 7, 2024
eb3318e
feat: add jsdoc
sarthakjdev May 7, 2024
0480d57
feat: wip docs
sarthakjdev May 8, 2024
c60a4cd
feat: wip docs
sarthakjdev May 8, 2024
8fd96f0
doc: read me and prose and pre class fix
sarthakjdev May 9, 2024
e742fdc
feat: add create wapi bot utility package
sarthakjdev May 9, 2024
18e386f
fix: package name should be unscoped in case of wapi.js as we will be…
sarthakjdev May 9, 2024
32ff44d
fix: minor fixes
sarthakjdev May 9, 2024
c14f1ce
chore: pretty
sarthakjdev May 9, 2024
036e399
chore: pretty & lint
sarthakjdev May 9, 2024
7df2f23
chore: pretty & lint
sarthakjdev May 9, 2024
940f7a4
fix: linter warning
sarthakjdev May 9, 2024
f49a380
fix: linter warning
sarthakjdev May 9, 2024
2f2579e
fix: build
sarthakjdev May 9, 2024
9b88140
fix: add release workflow and cliff jumper
sarthakjdev May 9, 2024
4dd2771
fix: add release script
sarthakjdev May 9, 2024
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dist/cjs/**
dist/esm/**
errors.log
.eslintrc.js
packages/**
apps/**
106 changes: 2 additions & 104 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,106 +1,4 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "import"],
parserOptions: {
project: ["./tsconfig.json", "./packages/**/tsconfig.json"],
// eslint-disable-next-line no-undef
tsconfigRootDir: __dirname,
sourceType: "module",
ecmaVersion: 2022,
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
project: ["./tsconfig.json", "./packages/**/tsconfig.json"],
},
node: true,
},
},
root: true,
rules: {
"no-restricted-globals": [
"error",
"closed",
"event",
"fdescribe",
"name",
"length",
"location",
"parent",
"top",
],
"no-empty-pattern": "off",
"no-inner-declarations": "off",
"no-console": "off",
"no-debugger": "error",
"no-alert": "error",
"no-useless-escape": "error",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/naming-convention": [
"error",
{
selector: ["variableLike"],
format: ["UPPER_CASE", "StrictPascalCase", "strictCamelCase"],
leadingUnderscore: "allow",
},
{
selector: ["typeLike"],
format: ["StrictPascalCase"],
},
],
"@typescript-eslint/consistent-type-imports": [
"error",
{
fixStyle: "inline-type-imports",
},
],
"import/default": "error",
"import/no-self-import": "error",
"import/no-cycle": [
"error",
{
maxDepth: 10,
ignoreExternal: true,
},
],
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"no-multi-assign": "error",
"max-statements-per-line": [
"error",
{
max: 1,
},
],
"no-case-declarations": "error",
"no-extra-boolean-cast": "error",
"prefer-const": "error",
"no-constant-condition": "error",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unsafe-argument": "off",
"import/no-named-as-default-member": "warn",
"import/no-named-as-default": "warn",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/restrict-template-expressions": "error",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
},
extends: ["@wapijs/eslint-config/config.node.js"],
};
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord server
url: https://discord.gg/PytnZqWpeQ
about: Please visit our Discord server for questions and support requests.
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Please describe the changes this PR makes and why it should be merged:**

**Status and versioning classification:**
96 changes: 96 additions & 0 deletions .github/workflows/documentation-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Documentation
on:
push:
branches:
- "master"
paths:
- "packages/wapi.js/**"
tags:
- "**"
workflow_dispatch:
inputs:
ref:
description: "The branch, tag or SHA to checkout"
required: true
ref_type:
type: choice
description: "Branch or tag"
options:
- branch
- tag
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build:
environment: Production
name: Build & upload documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: User Node.js LTS
uses: actions/setup-node@v2

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
with:
run_install: false

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Generate docs
run: pnpm run doc:gen

- name: Checkout docs repository
uses: actions/checkout@v3
with:
repository: "sarthakjdev/wapijs-docs-json"
token: ${{ secrets.WAPIJS_DOCS_ACCESS_TOKEN }}
path: "out"

- name: Extract package and semver from tag
if: ${{ github.ref_type == 'tag' }}
id: extract-tag
uses: ./format-tag
with:
tag: ${{ github.ref_name }}

- name: Move docs to correct directory
if: ${{ github.ref_type == 'tag' }}
env:
PACKAGE: ${{ steps.extract-tag.outputs.package }}
SEMVER: ${{ steps.extract-tag.outputs.semver }}
run: |
mkdir -p "out/wapi.js"
mv "packages/wapi.js/docs/docs.json" "out/wapi.js/${SEMVER}.json"

- name: Move docs to correct directory
if: ${{ github.ref_type == 'branch' }}
run: |
input_string="$GITHUB_REF_NAME"
if [[ "$input_string" == *"/"* ]]; then
documentation_file_name=$(echo "$input_string" | cut -d'/' -f2)
echo "Extracted: $documentation_file_name"
else
documentation_file_name="$GITHUB_REF_NAME"
echo "No slash in the string, nothing to extract."
fi
mkdir -p "out/wapi.js"
mv "packages/wapi.js/docs/docs.json" "out/wapi.js/${documentation_file_name}.json"

- name: Commit and push
run: |
cd out
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true
git push
18 changes: 18 additions & 0 deletions .github/workflows/format-tag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export function formatTag(tag: string) {
const parsed = /(?:^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
const parsedPackage = /(?<package>.*)@v?-?.*/.exec(tag);

if (parsed?.groups) {
const isSubpackage = typeof parsed.groups.package === 'string';
const pkg = isSubpackage ? parsed.groups.package : parsedPackage?.groups?.package ?? 'wapi.js';
const semver = parsed.groups.semver;

return {
isSubpackage,
package: pkg,
semver,
};
}

return null;
}
97 changes: 25 additions & 72 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,84 +1,37 @@
name: Build

name: Publish Release
on:
release:

types: [released]
jobs:
lint:
timeout-minutes: 10
npm-publish:
name: npm publish
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v2

- name: User Node.js LTS
uses: actions/setup-node@v2

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
with:
run_install: false

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm run lint
- name: Checkout repository
uses: actions/checkout@v3

- name: Linter Failed
if: ${{ failure() }}
uses: actions/github-script@v5
- name: Install node.js v18
uses: actions/setup-node@v3
with:
script: |
const { pullRequestData: data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.payload.after
})

if(pullRequestData[0]){
await github.rest.issues.createComment({
issue_number: pullRequestData[0].number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### 🚨 Linter failed`
})
} else {
throw new Error('Pull request data not found')
}
build:
runs-on: ubuntu-latest
needs: [lint]
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Install dependencies
uses: pnpm i --prod --frozen-lockfile --ignore-scripts

- name: Build the packages
run: pnpm build
- name: Build dependencies
run: pnpm run build

- name: Build Failed
if: ${{ failure() }}
uses: actions/github-script@v6
- name: Extract package and semver from tag
id: extract-tag
uses: ./format-tag
with:
script: |
const { data: pullRequestData } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.payload.after
})
tag: ${{ github.ref_name }}

if(pullRequestData[0]){
await github.rest.issues.createComment({
issue_number: pullRequestData[0].number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `#### ❌ Build failed:
`
})
} else {
throw new Error('Pull request data not found')
}
- name: Publish package
run: |
pnpm --filter=${{ steps.extract-tag.outputs.subpackage == 'true' && '@wapijs/' || '' }}${{ steps.extract-tag.outputs.package }} publish --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
Loading
Loading