Skip to content

Commit 78aadca

Browse files
authored
Extract JSON pointer library (#1)
1 parent 06a48a9 commit 78aadca

15 files changed

+12703
-90
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Commit style
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- reopened
9+
- synchronize
10+
push:
11+
branches:
12+
- master
13+
- 'dev/*'
14+
15+
jobs:
16+
check-commit-style:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check
20+
uses: mristin/opinionated-commit-message@v3.0.0
21+
with:
22+
allow-one-liners: 'true'
23+
skip-body-check: 'true'
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
name: Release
1+
name: Release deploy
22

33
on:
44
release:
55
types:
66
- published
7+
env:
8+
GCLOUD_PROJECT_DEV: "croct-dev"
79

810
jobs:
9-
deploy:
11+
deploy-release:
1012
runs-on: ubuntu-18.04
1113
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-node@v3
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
1416
with:
1517
node-version: 16
18+
registry-url: 'https://npm.pkg.github.com'
19+
env:
20+
NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }}
1621

1722
- name: Cache dependencies
1823
id: cache-dependencies
1924
uses: actions/cache@v2
2025
with:
2126
path: node_modules
2227
key: node_modules-${{ hashFiles('**/package-lock.json') }}
28+
2329
- name: Install dependencies
2430
if: steps.cache-dependencies.outputs.cache-hit != 'true'
2531
run: |-
@@ -32,24 +38,18 @@ jobs:
3238
3339
- name: Prepare release
3440
run: |-
35-
cp package.json LICENSE README.md build/
41+
cp package.json README.md build/
3642
cd build
3743
sed -i -e "s~\"version\": \"0.0.0-dev\"~\"version\": \"${GITHUB_REF##*/}\"~" package.json
3844
3945
- name: Publish pre-release to NPM
4046
if: ${{ github.event.release.prerelease }}
4147
run: |-
4248
cd build
43-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
44-
npm publish --access public --tag next
45-
env:
46-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
npm publish --tag next
4750
4851
- name: Publish release to NPM
4952
if: ${{ !github.event.release.prerelease }}
5053
run: |-
5154
cd build
52-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
53-
npm publish --access public
54-
env:
55-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
NODE_AUTH_TOKEN=${{ secret.GITHUB_TOKEN }} npm publish
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Guidelines
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
jobs:
8+
send-guidelines:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: wow-actions/auto-comment@v1
12+
with:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
pullRequestOpened: |
15+
👋 @{{ author }}
16+
**Thanks for your contribution!**
17+
The approval and merge process is almost fully automated 🧙
18+
Here's how it works:
19+
1. You open a new pull request
20+
2. Automated tests check the code
21+
3. Maintainers review the code
22+
4. Once approved, the PR is ready to merge.
23+
> 👉 **Omit the extended description**
24+
> Please remove the commit body before merging the pull request.
25+
> Instead, include the pull request number in the title to provide the full context
26+
> about the change.
27+
☝️ Lastly, the title for the commit will come from the pull request title. So please provide a descriptive title that summarizes the changes in **50 characters or less using the imperative mood.**
28+
Happy coding! 🎉

.github/workflows/release-drafter.yaml renamed to .github/workflows/update-release-notes.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Drafter
1+
name: Release notes
22

33
on:
44
push:
@@ -8,7 +8,7 @@ on:
88
- '**'
99

1010
jobs:
11-
release-draft:
11+
update-notes:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Update release draft
Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ on:
1111
- synchronize
1212
- opened
1313

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
1418
jobs:
15-
security-checks:
19+
check-vulnerabilities:
1620
runs-on: ubuntu-18.04
1721
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-node@v3
22+
- uses: actions/checkout@v2
23+
- uses: actions/setup-node@v2
2024
with:
2125
node-version: 16
26+
registry-url: 'https://npm.pkg.github.com'
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }}
2229

2330
- name: Cache dependencies
2431
id: cache-dependencies
@@ -33,16 +40,19 @@ jobs:
3340

3441
- name: Check dependency vulnerabilities
3542
run: |-
36-
npm i -g npm-audit-resolver
43+
npm i -g npm-audit-resolver@3.0.0-7
3744
npx check-audit
3845
39-
validate:
46+
validate-code:
4047
runs-on: ubuntu-18.04
4148
steps:
42-
- uses: actions/checkout@v3
43-
- uses: actions/setup-node@v3
49+
- uses: actions/checkout@v2
50+
- uses: actions/setup-node@v2
4451
with:
4552
node-version: 16
53+
registry-url: 'https://npm.pkg.github.com'
54+
env:
55+
NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }}
4656

4757
- name: Cache dependencies
4858
id: cache-dependencies
@@ -58,13 +68,16 @@ jobs:
5868
- name: Check compilation errors
5969
run: npm run validate
6070

61-
lint:
71+
check-code-style:
6272
runs-on: ubuntu-18.04
6373
steps:
64-
- uses: actions/checkout@v3
65-
- uses: actions/setup-node@v3
74+
- uses: actions/checkout@v2
75+
- uses: actions/setup-node@v2
6676
with:
6777
node-version: 16
78+
registry-url: 'https://npm.pkg.github.com'
79+
env:
80+
NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }}
6881

6982
- name: Cache dependencies
7083
id: cache-dependencies
@@ -80,13 +93,16 @@ jobs:
8093
- name: Check coding standard violations
8194
run: npm run lint
8295

83-
test:
96+
run-tests:
8497
runs-on: ubuntu-18.04
8598
steps:
86-
- uses: actions/checkout@v3
87-
- uses: actions/setup-node@v3
99+
- uses: actions/checkout@v2
100+
- uses: actions/setup-node@v2
88101
with:
89102
node-version: 16
103+
registry-url: 'https://npm.pkg.github.com'
104+
env:
105+
NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }}
90106

91107
- name: Cache dependencies
92108
id: cache-dependencies
@@ -99,10 +115,10 @@ jobs:
99115
if: steps.cache-dependencies.outputs.cache-hit != 'true'
100116
run: npm ci
101117

102-
- uses: paambaati/codeclimate-action@v3
118+
- uses: paambaati/codeclimate-action@v3.0.0
103119
env:
104120
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
105121
with:
106-
coverageCommand: npm test
122+
coverageCommand: npm run test
107123
coverageLocations:
108124
./coverage/lcov.info:lcov

README.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,55 @@
33
<img src="https://cdn.croct.io/brand/logo/repo-icon-green.svg" alt="Croct" height="80"/>
44
</a>
55
<br />
6-
<strong>TypeScript Project Title</strong>
6+
<strong>JSON Pointer</strong>
77
<br />
8-
A brief description about the project.
8+
A <a href="https://datatracker.ietf.org/doc/html/rfc6901">RFC 6901</a> compliant JSON pointer library to handle arbitrary structured data.
99
</p>
1010
<p align="center">
11-
<img alt="Build" src="https://img.shields.io/badge/build-passing-green" />
12-
<img alt="Coverage" src="https://img.shields.io/badge/coverage-100%25-green" />
13-
<img alt="Maintainability" src="https://img.shields.io/badge/maintainability-100-green" />
11+
<a href="https://github.com/croct-tech/json-pointer-js/actions/workflows/validate-branch.yaml"><img alt="Build" src="https://github.com/croct-tech/json-pointer-js/actions/workflows/validate-branch.yaml/badge.svg" /></a>
12+
<a href="https://codeclimate.com/repos/6224bc798bc258016500056f/test_coverage"><img src="https://api.codeclimate.com/v1/badges/692b087d6472a80bb509/test_coverage" /></a>
13+
<a href="https://codeclimate.com/repos/6224bc798bc258016500056f/maintainability"><img src="https://api.codeclimate.com/v1/badges/692b087d6472a80bb509/maintainability" /></a>
1414
<br />
1515
<br />
16-
<a href="https://github.com/croct-tech/repository-template-typescript/releases">📦Releases</a>
17-
·
18-
<a href="https://github.com/croct-tech/repository-template-typescript/issues/new?labels=bug&template=bug-report.md">🐞Report Bug</a>
19-
·
20-
<a href="https://github.com/croct-tech/repository-template-typescript/issues/new?labels=enhancement&template=feature-request.md">✨Request Feature</a>
16+
<a href="https://github.com/croct-tech/json-pointer-js/releases">📦Releases</a>
17+
·
18+
<a href="https://github.com/croct-tech/json-pointer-js/issues/new?labels=bug&template=bug-report.md">🐞Report Bug</a>
19+
·
20+
<a href="https://github.com/croct-tech/json-pointer-js/issues/new?labels=enhancement&template=feature-request.md">✨Request Feature</a>
2121
</p>
2222

23-
# Instructions
24-
Follow the steps below to create a new repository:
25-
26-
1. Customize the repository
27-
1. Click on the _Use this template_ button at the top of this page
28-
2. Clone the repository locally
29-
3. Update the `README.md` and `package.json` with the new package information
30-
2. Setup Code Climate
31-
1. Add the project to [Croct's code climate organization](https://codeclimate.com/accounts/5e714648faaa9c00fb000081/dashboard)
32-
2. Go to **Repo Settings > Test coverage** and copy the "_TEST REPORTER ID_"
33-
3. Go to **Repo Settings > Badges** and copy the maintainability and coverage badges to the `README.md`
34-
4. On the Github repository page, go to **Settings > Secrets** and add a secret with name `CC_TEST_REPORTER_ID` and the ID from the previous step as value.
35-
23+
## Introduction
24+
25+
This library provides an [RFC 6901](https://tools.ietf.org/html/rfc6901) compliant JSON pointer implementation
26+
to handle and manipulate arbitrary JSON values with type-safety.
27+
3628
## Installation
37-
Use the package manage [NPM](https://www.npmjs.com) to install the package:
29+
30+
We recommend using [NPM](https://www.npmjs.com) to install the package:
3831

3932
```sh
40-
npm install @croct/project-ts
33+
npm install @croct-tech/json-pointer
4134
```
4235

43-
## Basic usage
36+
## Overview
4437

45-
```typescript
46-
import {Example} from '@croct/project-ts';
38+
This library ships with a fast implementation of the JSON Pointer specification, as described in
39+
[RFC 6901](https://tools.ietf.org/html/rfc6901).
4740

48-
const example = new Example();
49-
example.displayBasicUsage();
50-
```
41+
These are the main highlight that distinguishes it from similar libraries:
42+
43+
- Fast and lightweight, zero dependencies
44+
- Fully compliant with the specification, including validation, serialization, and deserialization
45+
- Provide methods for reading and writing structures
46+
- Restricts operations such that no array becomes sparse
47+
- Ensures that a valid `JsonStructure` modified by a `JsonPointer` results in a still valid `JsonStructure`
5148

5249
## Contributing
50+
5351
Contributions to the package are always welcome!
5452

55-
- Report any bugs or issues on the [issue tracker](https://github.com/croct-tech/project-ts/issues).
56-
- For major changes, please [open an issue](https://github.com/croct-tech/project-ts/issues) first to discuss what you would like to change.
53+
- Report any bugs or issues on the [issue tracker](https://github.com/croct-tech/json-pointer-js/issues).
54+
- For major changes, please [open an issue](https://github.com/croct-tech/json-pointer-js/issues) first to discuss what you would like to change.
5755
- Please make sure to update tests as appropriate.
5856

5957
## Testing
@@ -84,16 +82,10 @@ Before building the project, the dependencies must be installed:
8482
npm install
8583
```
8684

87-
Then, to build the CommonJS module:
88-
89-
```sh
90-
npm run rollup
91-
```
92-
93-
The following command bundles a minified IIFE module for browsers:
85+
The following command builds the library:
9486

9587
```
96-
npm run rollup-min
88+
npm run build
9789
```
9890

9991
## License

0 commit comments

Comments
 (0)