Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Jan 29, 2023
0 parents commit f18a433
Show file tree
Hide file tree
Showing 33 changed files with 11,630 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"exclude": [
"**/index.ts",
"package/**/*.ts",
"examples/**/*.ts",
"**/*.spec.ts",
"ava.config.js"
],
"reporter": ["html", "lcov", "text"]
}
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG VARIANT="18"

FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}

USER node
WORKDIR /home/node

RUN mkdir -p .config/git \
&& echo ".vscode/*" >> .config/git/ignore \
&& echo "*.code-workspace" >> .config/git/ignore \
&& echo ".history/" >> .config/git/ignore
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "18"
}
},
"extensions": [
"ms-vsliveshare.vsliveshare",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode"
],
"postCreateCommand": "npm install",
"remoteUser": "node"
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
54 changes: 54 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"root": true,
"extends": ["standard-with-typescript", "prettier"],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"no-console": "warn",
"import/extensions": ["error", "ignorePackages"],
"@typescript-eslint/consistent-type-imports": [
"warn",
{
"fixStyle": "inline-type-imports"
}
],
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true,
"allowSeparatedGroups": true
}
],
"import/no-duplicates": ["error", { "prefer-inline": true }],
"import/order": [
"error",
{
"newlines-between": "always",
"alphabetize": {
"order": "asc"
},
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"pathGroupsExcludedImportTypes": ["builtin"],
"pathGroups": [
{
"pattern": "index.js",
"group": "internal",
"position": "before"
},
{
"pattern": "lib/**",
"group": "internal"
}
]
}
]
}
}
38 changes: 38 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Setup
description: Setup Node.js and install dependencies.

inputs:
node_version:
description: The Node.js version.
required: false
default: '18'
registry_url:
description: The Node.js package registry URL.
required: false
default: https://registry.npmjs.org
install_dependencies:
description: Install dependencies.
required: false
default: 'true'

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
if: inputs.install_dependencies == 'true'
with:
cache: npm
node-version: ${{ inputs.node_version }}
registry-url: ${{ inputs.registry_url }}
- name: Setup Node.js without cache
uses: actions/setup-node@v3
if: inputs.install_dependencies == 'false'
with:
node-version: ${{ inputs.node_version }}
registry-url: ${{ inputs.registry_url }}
- name: Install dependencies
if: inputs.install_dependencies == 'true'
shell: bash
run: npm ci
38 changes: 38 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: _build

on:
workflow_call:
inputs:
node_version:
description: The Node.js version.
type: string
required: false
default: '18'
outputs:
artifact_name:
description: The artifact name.
value: build-${{ github.sha }}

jobs:
build:
name: Package
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
node_version: ${{ inputs.node_version }}
- name: Build
run: npm run build
- name: Package
run: npm pack
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ github.sha }}
if-no-files-found: error
path: '*.tgz'
46 changes: 46 additions & 0 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: _publish

on:
workflow_call:
inputs:
artifact_name:
description: The artifact name.
type: string
required: true
registry_host:
description: The package registry host.
type: string
required: true
secrets:
registry_token:
description: The package registry token.
required: true

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
install_dependencies: 'false'
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact_name }}
path: .
- name: Get meta
id: meta
run: echo "tgz=$(ls *.tgz | head -n1)" >> $GITHUB_OUTPUT
- name: Publish
uses: rxfork/npm-publish@v1
with:
access: public
target: ${{ steps.meta.outputs.tgz }}
token: ${{ secrets.registry_token }}
registry: ${{ inputs.registry_host }}
135 changes: 135 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
name: Check

on:
push:
branches:
- '**'

jobs:
test:
name: Test (Node.js v${{ matrix.node }} on ${{ matrix.os_name }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node:
- '16'
- '18'
include:
- os: ubuntu-latest
os_name: Linux
- os: macos-latest
os_name: macOS
- os: windows-latest
os_name: Windows
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
node_version: ${{ matrix.node }}
- name: Test
run: npm test
lint:
name: Lint (Node.js v${{ matrix.node }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node:
- '16'
- '18'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
node_version: ${{ matrix.node }}
- name: Lint
run: npm run lint
build:
name: Build
uses: ./.github/workflows/_build.yml
install:
name: Install (Node.js v${{ matrix.node }} on ${{ matrix.os_name }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node:
- '16'
- '18'
include:
- os: ubuntu-latest
os_name: Linux
- os: macos-latest
os_name: macOS
- os: windows-latest
os_name: Windows
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact_name }}
path: .
- name: Find packages
uses: tj-actions/glob@v16
id: packages
with:
files: '*.tgz'
- name: Create package.json
uses: DamianReeves/[email protected]
with:
write-mode: overwrite
path: package.json
contents: |
{"type":"module"}
- name: Create index.js
uses: DamianReeves/[email protected]
with:
write-mode: overwrite
path: index.js
contents: |
import '@makenew/tsmodule'
- name: Install
run: npm install --save ${{ steps.packages.outputs.paths }}
- name: Run
run: node index.js
typecheck:
name: Typecheck (Node.js v${{ matrix.node }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node:
- '16'
- '18'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
with:
node_version: ${{ matrix.node }}
- name: Typecheck
run: npm run typecheck
Loading

0 comments on commit f18a433

Please sign in to comment.