Skip to content

Commit 6942491

Browse files
committed
Initial commit
0 parents  commit 6942491

15 files changed

+411
-0
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
max_line_length = 120
12+
13+
[*.md]
14+
trim_trailing_whitespace = false

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: ['@typescript-eslint'],
4+
extends: ['plugin:@typescript-eslint/recommended'],
5+
ignorePatterns: ['bin', 'dist', 'node_modules'],
6+
rules: {
7+
'@typescript-eslint/no-non-null-assertion': 'off',
8+
curly: 'error',
9+
},
10+
}

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Changes
2+
3+
...
4+
5+
## Checklist
6+
7+
- [ ] Tests for new code

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
unit-tests:
8+
name: Unit tests
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: Checkout the repository
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Node 14
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: 14
18+
19+
- name: Install dependencies
20+
run: yarn
21+
22+
- name: Run unit tests
23+
run: yarn test
24+
25+
code-quality:
26+
name: Code quality
27+
runs-on: ubuntu-20.04
28+
steps:
29+
- name: Checkout the repository
30+
uses: actions/checkout@v2
31+
32+
- name: Set up Node 14
33+
uses: actions/setup-node@v2
34+
with:
35+
node-version: 14
36+
37+
- name: Install dependencies
38+
run: yarn
39+
40+
- name: Lint
41+
run: yarn lint
42+
43+
build:
44+
name: Build
45+
runs-on: ubuntu-20.04
46+
steps:
47+
- name: Checkout the repository
48+
uses: actions/checkout@v2
49+
50+
- name: Set up Node 14
51+
uses: actions/setup-node@v2
52+
with:
53+
node-version: 14
54+
55+
- name: Install dependencies
56+
run: yarn --frozen-lockfile
57+
58+
- name: Build the package
59+
run: yarn build

.github/workflows/release.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 'Release'
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
9+
jobs:
10+
release:
11+
name: Bake a Release
12+
runs-on: ubuntu-20.04
13+
14+
steps:
15+
- name: Checkout the repository
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get package version
21+
id: version
22+
run: |
23+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
24+
PACKAGE_VERSION_TAG="v$PACKAGE_VERSION"
25+
if git rev-parse "$PACKAGE_VERSION_TAG"; then
26+
IS_NEW_VERSION=false
27+
else
28+
IS_NEW_VERSION=true
29+
fi
30+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
31+
echo "PACKAGE_VERSION_TAG=$PACKAGE_VERSION_TAG" >> $GITHUB_ENV
32+
echo "IS_NEW_VERSION=$IS_NEW_VERSION" >> $GITHUB_ENV
33+
echo "::set-output name=IS_NEW_VERSION::$IS_NEW_VERSION"
34+
35+
- name: Set up Node 14
36+
if: steps.version.outputs.IS_NEW_VERSION == 'true'
37+
uses: actions/setup-node@v2
38+
with:
39+
node-version: 14
40+
registry-url: https://registry.npmjs.org
41+
42+
- name: Install dependencies
43+
if: steps.version.outputs.IS_NEW_VERSION == 'true'
44+
run: yarn --frozen-lockfile
45+
46+
- name: Publish the package in the npm registry
47+
if: steps.version.outputs.IS_NEW_VERSION == 'true'
48+
run: yarn publish --access public
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
52+
- name: Create GitHub release
53+
if: steps.version.outputs.IS_NEW_VERSION == 'true'
54+
uses: actions/create-release@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
tag_name: ${{ env.PACKAGE_VERSION_TAG }}
59+
release_name: ${{ env.PACKAGE_VERSION }}
60+
61+
# if the package is @scoped, uncomment GitHub Packages release below
62+
63+
# - name: Switch to the GitHub registry
64+
# if: steps.version.outputs.IS_NEW_VERSION == 'true'
65+
# uses: actions/setup-node@v2
66+
# with:
67+
# node-version: 14
68+
# registry-url: https://npm.pkg.github.com
69+
70+
# - name: Publish the package in the GitHub registry
71+
# if: steps.version.outputs.IS_NEW_VERSION == 'true'
72+
# run: yarn publish --access public
73+
# env:
74+
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# environment variables file
58+
.env
59+
.environment
60+
61+
# next.js build output
62+
.next
63+
64+
# editors
65+
.vscode
66+
.idea
67+
68+
# yalc
69+
.yalc
70+
yalc*
71+
72+
# macOS
73+
.DS_Store
74+
75+
# output
76+
dist/

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": false,
5+
"singleQuote": true,
6+
"printWidth": 120
7+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 PostHog
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# PostHog Template for the Next TypeScript Package
2+
3+
[![npm package](https://img.shields.io/npm/v/♦️♦️♦️SET-YOUR-OWN-PACKAGE-NAME-HERE♦️♦️♦️?style=flat-square)](https://www.npmjs.com/package/♦️♦️♦️SET-YOUR-OWN-PACKAGE-NAME-HERE♦️♦️♦️)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5+
6+
> Hey there! Starting a new JS/TS package?
7+
>
8+
> Whether it's a library, a plugin, an integration, a CLI, or anything else in the world:
9+
>
10+
> - Write it in TypeScript for best reliability and development experience.
11+
> - Use the battle-tested Yarn for dependency management.
12+
> - Test quickly and easily with Jest (plus `ts-jest` for TypeScript support).
13+
> - Adhere to PostHog Style™️ by formatting code with Prettier and ensuring best practices with ESLint
14+
> – or actually, don't do it: let pre-commit hooks handle this for you.
15+
> - Have GitHub Actions run all of the above when working on pull requests. Plus have them take care of publishing releases on npm and GitHub whenever the version is incremented.
16+
>
17+
> Start out using this template and hit the ground quickly with all of the above from the get-go.
18+
>
19+
> ## Get on with it
20+
>
21+
> 1. Update fields `name`, `description`, `keywords`, `respository`, `bugs` and `homepage` in `package.json`.
22+
> 2. Make sure that you have Yarn installed and run `yarn` to install dependencies.
23+
> Note: file `yarn.lock` will be created. Commit this.
24+
> 3. Write your package, starting with `src/index.ts`!
25+
>
26+
> _When publishing on GitHub, add an automation-type npm access token as GitHub secret `NPM_TOKEN` in order for auto-release to work._
27+
28+
_Now, erase the notes above and fill this README with something actually relevant! Don't forget to update the npm badge too._
29+
30+
## Questions?
31+
32+
### [Join our Slack community.](https://join.slack.com/t/posthogusers/shared_invite/enQtOTY0MzU5NjAwMDY3LTc2MWQ0OTZlNjhkODk3ZDI3NDVjMDE1YjgxY2I4ZjI4MzJhZmVmNjJkN2NmMGJmMzc2N2U3Yjc3ZjI5NGFlZDQ)
33+
34+
We're here to help you with anything PostHog!

0 commit comments

Comments
 (0)