Skip to content

Commit b10b36f

Browse files
committed
Initial commit
0 parents  commit b10b36f

18 files changed

Lines changed: 17030 additions & 0 deletions

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./src/eslint')

.github/workflows/codeql.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: "16 23 * * 2"
12+
13+
jobs:
14+
analyze:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
- name: Initialize CodeQL
20+
uses: github/codeql-action/init@v1
21+
with:
22+
languages: javascript
23+
- name: Autobuild
24+
uses: github/codeql-action/autobuild@v1
25+
- name: Perform CodeQL Analysis
26+
uses: github/codeql-action/analyze@v1

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
publish:
10+
name: Publish
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: bahmutov/npm-install@v1
15+
- run: npm run build
16+
- run: npm publish
17+
env:
18+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- "*"
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
- uses: bahmutov/npm-install@v1
14+
- name: Lint
15+
run: npm run lint:check
16+
- name: Formatting
17+
run: npm run fmt:check
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
- uses: bahmutov/npm-install@v1
25+
- name: Test
26+
run: npm run test:cov
27+
- name: Report coverage
28+
uses: codecov/codecov-action@v1
29+
with:
30+
token: ${{ secrets.CODECOV_TOKEN }}
31+
file: ./coverage/lcov.info
32+
fail_ci_if_error: true
33+
34+
build:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v2
39+
- uses: bahmutov/npm-install@v1
40+
- name: Build
41+
run: npm run build
42+
- name: Build
43+
run: npm run build:declarations

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.eslintcache
2+
coverage/
3+
dist/
4+
node_modules/

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"eg2.vscode-npm-script"
5+
]
6+
}

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2 align="center">π-Base Core</h2>
2+
<div align="center">
3+
4+
[![Test](https://github.com/pi-base/core/workflows/Test/badge.svg?branch=main)](https://github.com/pi-base/core/actions/workflows/test.yml)
5+
[![codecov](https://codecov.io/gh/pi-base/core/branch/main/graph/badge.svg?token=7JO1N1OXJB)](https://codecov.io/gh/pi-base/core)
6+
7+
<!-- TODO: [![Release](https://github.com/pi-base/core/workflows/Release/badge.svg?branch=main)](https://github.com/pi-base/code/actions/workflows/release.yml) -->
8+
<!-- TODO: npm badge -->
9+
10+
<div align="center">
11+
12+
Shared data model for the [π-Base viewer](https://github.com/pi-base/viewer) and associated utilities.
13+
14+
## Local Development
15+
16+
Clone the repo and then run
17+
18+
```bash
19+
$ npm install
20+
$ npm run test
21+
```
22+
23+
See the [viewer](https://github.com/pi-base/viewer) and [compiler](https://github.com/pi-base/compile) for examples of usage. This package is mostly internal implementation details, and tends to be fluid and sparsely documented. If you are interested in building on top of this package, please reach out so we can better support you.
24+
25+
# Releasing
26+
27+
```bash
28+
$ npm run build
29+
$ npm run test
30+
$ npm publish
31+
```

bin/build

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! node
2+
3+
const esbuild = require('esbuild')
4+
5+
function report(error, { warnings }) {
6+
if (error) {
7+
console.error('Build error', error)
8+
} else if (warnings.length > 0) {
9+
console.warn('Build succeeded with errors', result)
10+
} else {
11+
console.log('Build succeeded')
12+
}
13+
}
14+
15+
const watch = process.argv.includes('--watch')
16+
17+
const builds = [
18+
esbuild.build({
19+
entryPoints: ['src/index.ts'],
20+
bundle: true,
21+
outfile: 'dist/main.js',
22+
platform: 'node',
23+
watch: watch ? { onRebuild: report } : false
24+
}),
25+
esbuild.build({
26+
entryPoints: ['src/cli.ts'],
27+
bundle: true,
28+
outfile: 'dist/cli.js',
29+
platform: 'node',
30+
watch: watch ? { onRebuild: report } : false
31+
}),
32+
]
33+
34+
Promise.all(builds).then(results => {
35+
if (watch) {
36+
console.log('Watching for changes')
37+
} else {
38+
for (const result of results) {
39+
report(result)
40+
}
41+
}
42+
}).catch(error => {
43+
console.error(error)
44+
process.exit(1)
45+
})

jest.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
bail: 10,
3+
clearMocks: true,
4+
coverageDirectory: 'coverage',
5+
coveragePathIgnorePatterns: ['/node_modules/'],
6+
coverageProvider: 'v8',
7+
errorOnDeprecated: true,
8+
moduleFileExtensions: ['js', 'ts'],
9+
notify: true,
10+
notifyMode: 'failure-change',
11+
resetMocks: true,
12+
roots: ['src'],
13+
testEnvironment: 'node',
14+
testMatch: ['**/*.test.ts'],
15+
testRunner: 'jest-circus/runner',
16+
transform: {
17+
'^.+\\.ts$': 'ts-jest',
18+
},
19+
verbose: true,
20+
}

0 commit comments

Comments
 (0)