Skip to content

Commit 9bab437

Browse files
committed
feat: docs + CI/CD
1 parent 5c19c04 commit 9bab437

File tree

8 files changed

+7476
-720
lines changed

8 files changed

+7476
-720
lines changed

.github/workflows/deploy.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Review gh actions docs if you want to further define triggers, paths, etc
8+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
9+
10+
jobs:
11+
deploy:
12+
name: Deploy to GitHub Pages
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
cache: yarn
20+
21+
- name: Install dependencies
22+
run: yarn install --frozen-lockfile
23+
- name: Build website
24+
run: yarn build
25+
26+
# Popular action to deploy to GitHub Pages:
27+
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
28+
- name: Deploy to GitHub Pages
29+
uses: peaceiris/actions-gh-pages@v3
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
# Build output to publish to the `gh-pages` branch:
33+
publish_dir: ./build
34+
# The following lines assign commit authorship to the official
35+
# GH-Actions bot for deploys to `gh-pages` branch:
36+
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
37+
# The GH actions bot is used by default if you didn't specify the two fields.
38+
# You can swap them out with your own user credentials.
39+
user_name: github-actions[bot]
40+
user_email: 41898282+github-actions[bot]@users.noreply.github.com

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
docs/
2+
build/
3+
.docusaurus/
24
# Logs
35
logs
46
*.log
@@ -106,4 +108,4 @@ typings/
106108

107109
# TernJS port file
108110
.tern-port
109-
.DS_Store
111+
.DS_Store

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
[![npm downloads][npm-downloads-src]][npm-downloads-href]
33

44
<h1 align="center">Missing Native
5-
<img width="24" src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/javascript/javascript.png">
5+
<img width="24" src="https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/javascript/javascript.png" />
66
Functions</h1>
77
<p align="center">A zero-dependecy JavaScript utility library delivering <b>missing</b> native functions 💼</p>
88

99
## Why use mnjsf?
1010

1111
mnjsf delivers functions missing from JavaScript
1212

13-
❯ 💼 **Zero-Dependency** Built without a dependency hell<br>
14-
❯ 📐 **Lightweight** 2.5KB<br>
15-
❯ 🌐 **NodeJS/Browser Support** use mnjsf in a browser or a Node.js application <br>
16-
❯ ✨ **Direct Call** of utility functions on variables (`[].last()`) <br>
13+
❯ 💼 **Zero-Dependency** Built without a dependency hell<br />
14+
❯ 📐 **Lightweight** 2.5KB<br />
15+
❯ 🌐 **NodeJS/Browser Support** use mnjsf in a browser or a Node.js application <br />
16+
❯ ✨ **Direct Call** of utility functions on variables (`[].last()`) <br />
1717

1818
This library extends the properties of `Array`, `Object`, `Promise`, `Global`, `Math`, `Number` and `String`
1919

@@ -46,10 +46,9 @@ use in Browser
4646
<script src="https://cdn.jsdelivr.net/npm/missing-native-js-functions/dist/mnjsf.min.js"></script>
4747
```
4848

49-
5049
## License
5150

52-
Made with 💚 Published under [MIT](./LICENSE).
51+
Made with 💚 Published under MIT License.
5352

5453
<!-- Badges -->
5554

docusaurus.config.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// @ts-nocheck
2+
3+
try {
4+
require("fs").mkdirSync(__dirname + "/docs", { recursive: true });
5+
} catch (error) {}
6+
7+
const entryPoints = require("fs")
8+
.readdirSync(__dirname + "/src")
9+
.map((x) => __dirname + "/src/" + x);
10+
11+
const organizationName = "trantlabs";
12+
const projectName = "missing-native-js-functions";
13+
const githubUrl = `https://github.com/${organizationName}/${projectName}`;
14+
15+
/** @type {import('typedoc').TypeDocOptions} */
16+
const typedoc = {
17+
tsconfig: __dirname + "/tsconfig.json",
18+
entryPoints: entryPoints,
19+
out: __dirname + "/docs/",
20+
watch: process.env.TYPEDOC_WATCH,
21+
};
22+
23+
/** @type {import('@docusaurus/types').Config} */
24+
const config = {
25+
title: "Missing Native JS Functions",
26+
tagline: "A zero-dependecy JavaScript utility library delivering missing native functions 💼",
27+
url: `https://${organizationName}.github.io/`,
28+
organizationName,
29+
projectName,
30+
deploymentBranch: "gh-pages",
31+
baseUrl: `/${projectName}/`,
32+
onBrokenLinks: "throw",
33+
onBrokenMarkdownLinks: "warn",
34+
organizationName: "trantlabs",
35+
projectName: "missing-native-js-functions",
36+
presets: [
37+
[
38+
"@docusaurus/preset-classic",
39+
{
40+
docs: {
41+
path: "./docs/",
42+
routeBasePath: "/",
43+
editUrl: `${githubUrl}/edit/master/website`,
44+
},
45+
},
46+
],
47+
],
48+
plugins: [["docusaurus-plugin-typedoc", typedoc]],
49+
themeConfig: {
50+
navbar: {},
51+
},
52+
};
53+
54+
module.exports = config;

package.json

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"build": "tsc -b .",
1212
"rollup": "rollup -c",
1313
"release": "yarn build && yarn rollup && changelogen --bump --output=CHANGELOG.md && git push --follow-tags && yarn publish",
14-
"lint": "eslint --ext .js,.ts"
14+
"lint": "eslint --ext .js,.ts",
15+
"docs": "TYPEDOC_WATCH=true docusaurus start",
16+
"docs:build": "docusaurus build"
1517
},
1618
"repository": {
1719
"type": "git",
@@ -39,14 +41,26 @@
3941
},
4042
"homepage": "https://trantlabs.github.io/missing-native-js-functions/",
4143
"devDependencies": {
44+
"@docusaurus/core": "2.2.0",
45+
"@docusaurus/module-type-aliases": "2.2.0",
46+
"@docusaurus/preset-classic": "2.2.0",
47+
"@mdx-js/react": "^1.6.22",
4248
"@trantlabs/eslint-config-typescript": "^0.0.0",
4349
"@types/node": "^14.14.14",
4450
"changelogen": "^0.4.0",
51+
"clsx": "^1.2.1",
52+
"docusaurus-plugin-typedoc": "^0.18.0",
4553
"eslint": "^8.30.0",
54+
"patch-package": "^6.5.0",
55+
"prism-react-renderer": "^1.3.5",
56+
"react": "^17.0.2",
57+
"react-dom": "^17.0.2",
4658
"rollup": "^2.36.1",
4759
"rollup-plugin-babel-minify": "^10.0.0",
4860
"rollup-plugin-commonjs": "^10.1.0",
4961
"rollup-plugin-node-resolve": "^5.2.0",
62+
"typedoc": "^0.23.23",
63+
"typedoc-plugin-markdown": "^3.14.0",
5064
"typescript": "^4.4.3"
5165
}
5266
}

src/Date.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { define } from "./Util";
22

33
define(Date, {
4-
nowSeconds: function () {
5-
return Math.floor(Date.now() / 1000);
6-
},
4+
nowSeconds: function () {
5+
return Math.floor(Date.now() / 1000);
6+
},
77
});
88

99
define(Date.prototype, {
@@ -22,15 +22,15 @@ define(Date.prototype, {
2222
});
2323

2424
declare global {
25-
interface DateConstructor {
25+
interface DateConstructor {
2626
/**
2727
* Returns the current timestamp as its representation in seconds
2828
* @returns {number} date in seconds
2929
* @example
30-
* new Date().nowSeconds() // 1671621321
30+
* Date.nowSeconds() // 1671621321
3131
*/
3232
nowSeconds(): number;
33-
}
33+
}
3434
}
3535

3636
declare global {

src/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ import "./Object";
66
import "./Promise";
77
import "./String";
88
import "./Date";
9+
10+
export * from "./Array";
11+
export * from "./Global";
12+
export * from "./Math";
13+
export * from "./Number";
14+
export * from "./Object";
15+
export * from "./Promise";
16+
export * from "./String";
17+
export * from "./Date";

0 commit comments

Comments
 (0)