Octokit.js build setup using @pika/pack
npm install --save-dev @pika/pack @pika/plugin-build-node @pika/plugin-build-web @pika/plugin-ts-standard-pkg
Add a "@pika/pack"
key to package.json
"@pika/pack": {
"pipeline": [
[
"@pika/plugin-ts-standard-pkg"
],
[
"@pika/plugin-build-node"
],
[
"@pika/plugin-build-web"
]
]
}
Add a "release"
key to package.json
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/npm",
{
"pkgRoot": "./pkg"
}
]
]
}
Add a "build"
script
"scripts": {
"build": "pika build",
Add pkg/
to .gitignore
node_modules/
pkg/
Create tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"target": "es2018"
},
"include": ["src/**/*"]
}
For testing, create .github/workflows/test.yml
with the following content
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [8, 10, 12]
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
version: ${{ matrix.node_version }}
- name: Install
run: npm ci
- name: Test
run: npm test
For automated releases using semantic-release, create .github/workflows/release.yml
with the following content
on:
push:
branches:
- master
name: Release
jobs:
build:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm ci
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
The indentation is important. Replace @octokit/endpoint
with the package name
<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>
Load `@octokit/endpoint` directly from [cdn.pika.dev](https://cdn.pika.dev)
```html
<script type="module">
import { endpoint } from "https://cdn.pika.dev/@octokit/endpoint";
</script>
```
</td></tr>
<tr><th>
Node
</th><td>
Install with <code>npm install @octokit/endpoint</code>
```js
const { endpoint } = require("@octokit/endpoint");
// or: import { endpoint } from "@octokit/endpoint";
```
</td></tr>
</tbody>
</table>
The above is rendered as
Browsers |
Load <script type="module">
import { endpoint } from "https://cdn.pika.dev/@octokit/endpoint";
</script> |
---|---|
Node |
Install with const { endpoint } = require("@octokit/endpoint");
// or: import { endpoint } from "@octokit/endpoint"; |