Skip to content

Commit 0acdab7

Browse files
25 auto generate documentation from jsdoc (#29)
* update workflows to upload to GitHub Pages * make all defined error types exportable * update errors related types * make more types exportable from api * code refactoring, fix some documentation generation warnings * define custom module names for documentation generation * rename modules and code refactoring * make setGitClientAgent util as internal * add more JSDoc comments * code refactoring * update comments * replace rmdir FsClient function with rm to allow recursive deletion * add more JSDoc comments * update some comments * code refactoring * add more JSDoc comments * update browser usage example * update package description and keywords * add more comments * add comments for BlobMergeCallback * add more documentation for callback functions * add documentation for ProgressCallback * add documentation for AuthCallback * update documentation * add documentation for SignCallback * add tests for custom conflict resolver * add documentation for BlobMergeCallbackParams * add more documentation for BlobMergeCallback * add documentation for HttpClient * update documentation for FsClient * update documentation * add documentation for Cache object
1 parent 556fbee commit 0acdab7

100 files changed

Lines changed: 1148 additions & 734 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ jobs:
3131

3232
- name: Test (Browsers)
3333
run: npm run test:browsers
34+
35+
- name: Generate documentation
36+
run: npm run gen-doc

.github/workflows/release.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ on:
44
push:
55
branches: [ "main" ]
66

7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
716
jobs:
817
release:
918
runs-on: macos-latest
@@ -32,7 +41,30 @@ jobs:
3241
- name: Test (Browsers)
3342
run: npm run test:browsers
3443

35-
- name: Publish
44+
- name: Generate documentation
45+
run: npm run gen-doc
46+
47+
- name: Upload documentation
48+
uses: actions/upload-pages-artifact@v1
49+
with:
50+
path: docs/
51+
52+
- name: Publish package
3653
run: npm publish
3754
env:
3855
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
56+
57+
docs:
58+
environment:
59+
name: github-pages
60+
url: ${{ steps.deployment.outputs.page_url }}
61+
runs-on: ubuntu-latest
62+
needs: release
63+
64+
steps:
65+
- name: Setup Pages
66+
uses: actions/configure-pages@v2
67+
68+
- name: Deploy to GitHub Pages
69+
id: deployment
70+
uses: actions/deploy-pages@v1

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# Git-Essentials
1+
# Git Essentials
22
A collection of essential Git commands for your browser and Node.js.
33

4+
## Documentation
5+
6+
Visit [https://noteshubapp.github.io/git-essentials](https://noteshubapp.github.io/git-essentials) to view the full documentation.
7+
48
## Usage Examples
59

610
### Node.js
@@ -22,6 +26,9 @@ import { clone } from 'git-essentials'
2226
import { InMemoryFsClient } from 'git-essentials/clients/fs/InMemoryFsClient'
2327
import { makeWebHttpClient } from 'git-essentials/clients/request/WebHttpClient'
2428

29+
// GitHub (like some other providers) does not return proper 'Access-Control-Allow-Origin' header
30+
// as a result the browser will refuse to serve the request.
31+
// To overcome this limitation CORS proxy server could be used.
2532
const corsProxyUrlTransformer = (originalUrl: string) => {
2633
return `https://www.noteshub.app/api/cors-proxy.ts?url=${encodeURIComponent(originalUrl)}`
2734
}

karma.conf.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ module.exports = (config: any) => {
4343
"esModuleInterop": true,
4444
"baseUrl": ".",
4545
"paths": {
46-
"git-essentials": ["./src/index"]
46+
"git-essentials": ["./src/index"],
47+
"git-essentials/*": ["./src/*"]
4748
}
4849
},
4950
bundlerOptions: {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "git-essentials",
3-
"version": "0.5.0",
4-
"description": "The essential GIT commands",
3+
"version": "0.6.0",
4+
"description": "A collection of essential Git commands for your browser and Node.js",
55
"main": "dist/esm/index.js",
66
"types": "index.d.ts",
77
"typesVersions": {
@@ -27,9 +27,6 @@
2727
"postbuild": "node ./scripts/fix-build.js",
2828
"test": "jest",
2929
"test:browser": "karma start",
30-
"test:chrome": "karma start --single-run --browsers ChromeHeadless",
31-
"test:webkit": "karma start --single-run --browsers WebkitHeadless",
32-
"test:firefox": "karma start --single-run --browsers FirefoxHeadless",
3330
"test:browsers": "karma start --single-run --browsers ChromeHeadless,WebkitHeadless,FirefoxHeadless",
3431
"gen-doc": "npx typedoc",
3532
"gen-fs-fixture": "node ./scripts/gen-fs-fixture.js",
@@ -45,7 +42,12 @@
4542
},
4643
"keywords": [
4744
"git",
48-
"js"
45+
"js",
46+
"typescript",
47+
"nodejs",
48+
"browser",
49+
"isomorphic",
50+
"isomorphic-javascript"
4951
],
5052
"author": "Alex Titarenko",
5153
"license": "MIT",

src/api/add.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ import { _writeObject } from '../storage/writeObject'
1111
import { assertParameter } from '../utils/assertParameter'
1212
import { join } from '../utils/join'
1313

14+
1415
export type AddParams = {
1516
/** A file system implementation. */
1617
fs: FsClient
1718

1819
/** A directory path. */
1920
dir: string
2021

21-
/**
22-
* The git directory path.
23-
* @defaultValue `join(dir, '.git')`
24-
*/
22+
/** The git directory path (default: `{dir}/.git`). */
2523
gitdir?: string
2624

2725
/** The path to the file to add to the index. */
@@ -36,14 +34,15 @@ export type AddParams = {
3634
*
3735
* @param args
3836
*
39-
* @returns Resolves successfully once the git index has been updated
37+
* @returns Resolves successfully once the git index has been updated.
4038
*
4139
* @example
4240
* ```ts
4341
* await fs.writeFile('/tutorial/README.md', '# TEST')
4442
* await add({ fs, dir: '/tutorial', filepath: 'README.md' })
4543
* ```
4644
*
45+
* @group Commands
4746
*/
4847
export async function add({
4948
fs: _fs,

src/api/addRemote.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { FsClient } from '../models/FsClient'
44
import { assertParameter } from '../utils/assertParameter'
55
import { join } from '../utils/join'
66

7-
type AddRemoteParams = {
7+
8+
export type AddRemoteParams = {
89
/** A file system implementation. */
910
fs: FsClient
1011

1112
/** The working tree directory path. */
1213
dir: string
1314

14-
/** The git directory path (default: `join(dir, '.git')`). */
15+
/** The git directory path (default: `{dir}/.git`). */
1516
gitdir?: string
1617

1718
/** The name of the remote. */
@@ -27,19 +28,19 @@ type AddRemoteParams = {
2728
/**
2829
* Add or update a remote.
2930
*
30-
* @param {AddRemoteParams} args
31+
* @param args
3132
*
32-
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
33+
* @returns Resolves successfully when filesystem operations are complete.
3334
*
3435
* @example
35-
* await git.addRemote({
36+
* await addRemote({
3637
* fs,
3738
* dir: '/tutorial',
3839
* remote: 'upstream',
39-
* url: 'https://github.com/isomorphic-git/isomorphic-git'
40+
* url: 'https://github.com/NotesHubApp/git-essentials'
4041
* })
41-
* console.log('done')
4242
*
43+
* @group Commands
4344
*/
4445
export async function addRemote({
4546
fs,

src/api/branch.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { assertParameter } from '../utils/assertParameter'
55
import { join } from '../utils/join'
66

77

8-
type BranchParams = {
8+
export type BranchParams = {
99
/** A file system implementation. */
1010
fs: FsClient
1111

1212
/** The working tree directory path. */
1313
dir: string
1414

15-
/** The git directory path (default: `join(dir, '.git')`). */
15+
/** The git directory path (default: `{dir}/.git`). */
1616
gitdir?: string
1717

1818
/** What to name the branch. */
@@ -31,14 +31,14 @@ type BranchParams = {
3131
/**
3232
* Create a branch.
3333
*
34-
* @param {BranchParams} args
34+
* @param args
3535
*
36-
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
36+
* @returns Resolves successfully when filesystem operations are complete.
3737
*
3838
* @example
39-
* await git.branch({ fs, dir: '/tutorial', ref: 'develop' })
40-
* console.log('done')
39+
* await branch({ fs, dir: '/tutorial', ref: 'develop' })
4140
*
41+
* @group Commands
4242
*/
4343
export async function branch({
4444
fs,

src/api/checkout.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { join } from '../utils/join'
66
import { FsClient } from '../models/FsClient'
77
import { ProgressCallback } from '../models'
88

9-
type CheckoutParams = {
9+
10+
export type CheckoutParams = {
1011
/** A file system implementation. */
1112
fs: FsClient
1213

@@ -16,7 +17,7 @@ type CheckoutParams = {
1617
/** The working tree directory path. */
1718
dir: string
1819

19-
/** The git directory path (default: `join(dir, '.git')`). */
20+
/** The git directory path (default: `{dir}/.git`). */
2021
gitdir?: string
2122

2223
/** Which remote repository to use (default: `origin`). */
@@ -52,40 +53,39 @@ type CheckoutParams = {
5253
*
5354
* If the branch already exists it will check out that branch. Otherwise, it will create a new remote tracking branch set to track the remote branch of that name.
5455
*
55-
* @param {CheckoutParams} args
56+
* @param args
5657
*
57-
* @returns {Promise<void>} Resolves successfully when filesystem operations are complete
58+
* @returns Resolves successfully when filesystem operations are complete.
5859
*
5960
* @example
6061
* // switch to the main branch
61-
* await git.checkout({
62+
* await checkout({
6263
* fs,
6364
* dir: '/tutorial',
6465
* ref: 'main'
6566
* })
66-
* console.log('done')
6767
*
6868
* @example
6969
* // restore the 'docs' and 'src/docs' folders to the way they were, overwriting any changes
70-
* await git.checkout({
70+
* await checkout({
7171
* fs,
7272
* dir: '/tutorial',
7373
* force: true,
7474
* filepaths: ['docs', 'src/docs']
7575
* })
76-
* console.log('done')
7776
*
7877
* @example
7978
* // restore the 'docs' and 'src/docs' folders to the way they are in the 'develop' branch, overwriting any changes
80-
* await git.checkout({
79+
* await checkout({
8180
* fs,
8281
* dir: '/tutorial',
8382
* ref: 'develop',
8483
* noUpdateHead: true,
8584
* force: true,
8685
* filepaths: ['docs', 'src/docs']
8786
* })
88-
* console.log('done')
87+
*
88+
* @group Commands
8989
*/
9090
export async function checkout({
9191
fs,

0 commit comments

Comments
 (0)