Skip to content

Commit f02e202

Browse files
committed
0 parents  commit f02e202

32 files changed

+7480
-0
lines changed

.c8rc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"exclude": [
3+
"**/index.ts",
4+
"package/**/*.ts",
5+
"examples/**/*.ts",
6+
"**/*.test.ts",
7+
"ava.config.js"
8+
],
9+
"reporter": ["html", "lcov", "text"]
10+
}

.devcontainer/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ARG VARIANT="18"
2+
3+
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}
4+
5+
USER node
6+
WORKDIR /home/node
7+
8+
RUN mkdir -p .config/git \
9+
&& echo ".vscode/*" >> .config/git/ignore \
10+
&& echo "*.code-workspace" >> .config/git/ignore \
11+
&& echo ".history/" >> .config/git/ignore

.devcontainer/devcontainer.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "TypeScript",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
"VARIANT": "18"
7+
}
8+
},
9+
"extensions": [
10+
"ms-vsliveshare.vsliveshare",
11+
"dbaeumer.vscode-eslint",
12+
"EditorConfig.EditorConfig",
13+
"esbenp.prettier-vscode"
14+
],
15+
"postCreateCommand": "npm install",
16+
"remoteUser": "node"
17+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 2

.eslintrc.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"root": true,
3+
"extends": ["standard-with-typescript", "prettier"],
4+
"plugins": ["simple-import-sort", "unused-imports"],
5+
"parserOptions": {
6+
"project": "./tsconfig.json"
7+
},
8+
"rules": {
9+
"no-console": "warn",
10+
"@typescript-eslint/consistent-type-imports": [
11+
"error",
12+
{
13+
"fixStyle": "inline-type-imports"
14+
}
15+
],
16+
"@typescript-eslint/no-unused-vars": "off",
17+
"unused-imports/no-unused-imports": "error",
18+
"unused-imports/no-unused-vars": [
19+
"error",
20+
{
21+
"vars": "all",
22+
"varsIgnorePattern": "^_",
23+
"args": "after-used",
24+
"argsIgnorePattern": "^_",
25+
"ignoreRestSiblings": true
26+
}
27+
],
28+
"import/extensions": ["error", "ignorePackages"],
29+
"import/no-duplicates": ["error", { "prefer-inline": true }],
30+
"sort-imports": [
31+
"error",
32+
{
33+
"ignoreDeclarationSort": true,
34+
"allowSeparatedGroups": true
35+
}
36+
],
37+
"simple-import-sort/imports": [
38+
"error",
39+
{
40+
"groups": [
41+
["^\\u0000"],
42+
["^node:"],
43+
["^@?\\w"],
44+
["index.js"],
45+
["^lib/"],
46+
["^"],
47+
["^\\."]
48+
]
49+
}
50+
],
51+
"simple-import-sort/exports": "error"
52+
}
53+
}

.github/actions/setup/action.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Setup
3+
description: Setup Node.js and install dependencies.
4+
5+
inputs:
6+
node_version:
7+
description: The Node.js version.
8+
required: false
9+
default: '18'
10+
registry_url:
11+
description: The Node.js package registry URL.
12+
required: false
13+
default: https://registry.npmjs.org
14+
install_dependencies:
15+
description: Install dependencies.
16+
required: false
17+
default: 'true'
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v3
24+
if: inputs.install_dependencies == 'true'
25+
with:
26+
cache: npm
27+
node-version: ${{ inputs.node_version }}
28+
registry-url: ${{ inputs.registry_url }}
29+
- name: Setup Node.js without cache
30+
uses: actions/setup-node@v3
31+
if: inputs.install_dependencies == 'false'
32+
with:
33+
node-version: ${{ inputs.node_version }}
34+
registry-url: ${{ inputs.registry_url }}
35+
- name: Install dependencies
36+
if: inputs.install_dependencies == 'true'
37+
shell: bash
38+
run: npm ci

.github/workflows/_build.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: _build
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
node_version:
8+
description: The Node.js version.
9+
type: string
10+
required: false
11+
default: '18'
12+
outputs:
13+
artifact_name:
14+
description: The artifact name.
15+
value: build-${{ github.sha }}
16+
17+
jobs:
18+
build:
19+
name: Package
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Setup
26+
uses: ./.github/actions/setup
27+
with:
28+
node_version: ${{ inputs.node_version }}
29+
- name: Build
30+
run: npm run build
31+
- name: Package
32+
run: npm pack
33+
- name: Upload artifact
34+
uses: actions/upload-artifact@v3
35+
with:
36+
name: build-${{ github.sha }}
37+
if-no-files-found: error
38+
path: '*.tgz'

.github/workflows/_publish.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: _publish
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
artifact_name:
8+
description: The artifact name.
9+
type: string
10+
required: true
11+
registry_host:
12+
description: The package registry host.
13+
type: string
14+
required: true
15+
secrets:
16+
registry_token:
17+
description: The package registry token.
18+
required: true
19+
20+
jobs:
21+
publish:
22+
name: Publish package
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 30
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
- name: Setup
29+
uses: ./.github/actions/setup
30+
with:
31+
install_dependencies: 'false'
32+
- name: Download artifact
33+
uses: actions/download-artifact@v3
34+
with:
35+
name: ${{ inputs.artifact_name }}
36+
path: .
37+
- name: Get meta
38+
id: meta
39+
run: echo "tgz=$(ls *.tgz | head -n1)" >> $GITHUB_OUTPUT
40+
- name: Publish
41+
uses: rxfork/npm-publish@v1
42+
with:
43+
access: public
44+
target: ${{ steps.meta.outputs.tgz }}
45+
token: ${{ secrets.registry_token }}
46+
registry: ${{ inputs.registry_host }}

.github/workflows/check.yml

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
name: Check
3+
4+
on:
5+
push:
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
test:
11+
name: Test (Node.js v${{ matrix.node }} on ${{ matrix.os_name }})
12+
runs-on: ${{ matrix.os }}
13+
timeout-minutes: 30
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os:
18+
- ubuntu-latest
19+
- macos-latest
20+
- windows-latest
21+
node:
22+
- '16'
23+
- '18'
24+
include:
25+
- os: ubuntu-latest
26+
os_name: Linux
27+
- os: macos-latest
28+
os_name: macOS
29+
- os: windows-latest
30+
os_name: Windows
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
- name: Setup
35+
uses: ./.github/actions/setup
36+
with:
37+
node_version: ${{ matrix.node }}
38+
- name: Test
39+
run: npm test
40+
lint:
41+
name: Lint (Node.js v${{ matrix.node }})
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 30
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
node:
48+
- '16'
49+
- '18'
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
- name: Setup
54+
uses: ./.github/actions/setup
55+
with:
56+
node_version: ${{ matrix.node }}
57+
- name: Lint
58+
run: npm run lint
59+
build:
60+
name: Build
61+
uses: ./.github/workflows/_build.yml
62+
install:
63+
name: Install (Node.js v${{ matrix.node }} on ${{ matrix.os_name }})
64+
runs-on: ${{ matrix.os }}
65+
timeout-minutes: 30
66+
needs: build
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
os:
71+
- ubuntu-latest
72+
- macos-latest
73+
- windows-latest
74+
node:
75+
- '16'
76+
- '18'
77+
include:
78+
- os: ubuntu-latest
79+
os_name: Linux
80+
- os: macos-latest
81+
os_name: macOS
82+
- os: windows-latest
83+
os_name: Windows
84+
steps:
85+
- name: Setup Node.js
86+
uses: actions/setup-node@v3
87+
with:
88+
node-version: ${{ matrix.node }}
89+
- name: Download artifact
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: ${{ needs.build.outputs.artifact_name }}
93+
path: .
94+
- name: Find packages
95+
uses: tj-actions/glob@v16
96+
id: packages
97+
with:
98+
files: '*.tgz'
99+
- name: Create package.json
100+
uses: DamianReeves/[email protected]
101+
with:
102+
write-mode: overwrite
103+
path: package.json
104+
contents: |
105+
{"type":"module"}
106+
- name: Create index.js
107+
uses: DamianReeves/[email protected]
108+
with:
109+
write-mode: overwrite
110+
path: index.js
111+
contents: |
112+
import '@makenew/tsmodule'
113+
- name: Install
114+
run: npm install --save ${{ steps.packages.outputs.paths }}
115+
- name: Run
116+
run: node index.js
117+
typecheck:
118+
name: Typecheck (Node.js v${{ matrix.node }})
119+
runs-on: ubuntu-latest
120+
timeout-minutes: 30
121+
strategy:
122+
fail-fast: false
123+
matrix:
124+
node:
125+
- '16'
126+
- '18'
127+
steps:
128+
- name: Checkout
129+
uses: actions/checkout@v3
130+
- name: Setup
131+
uses: ./.github/actions/setup
132+
with:
133+
node_version: ${{ matrix.node }}
134+
- name: Typecheck
135+
run: npm run typecheck

0 commit comments

Comments
 (0)