Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli authored Jul 24, 2023
0 parents commit 3801b7c
Show file tree
Hide file tree
Showing 22 changed files with 289 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/coverage/**/*
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@voxpelli/eslint-config/esm",
"root": true
}
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Linting

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main

permissions:
contents: read

jobs:
lint:
uses: voxpelli/ghatemplates/.github/workflows/lint.yml@main
21 changes: 21 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Node CI

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main

permissions:
contents: read

jobs:
test:
uses: voxpelli/ghatemplates/.github/workflows/test.yml@main
with:
node-versions: '16,18,20'
os: 'ubuntu-latest'
23 changes: 23 additions & 0 deletions .github/workflows/ts-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Type Checks, Internal Types

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
schedule:
- cron: '14 5 * * 1,3,5'

permissions:
contents: read

jobs:
type-check:
uses: voxpelli/ghatemplates/.github/workflows/type-check.yml@main
with:
ts-versions: ${{ github.event.schedule && 'next' || '5.1,next' }}
ts-libs: 'es2020;esnext'
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Basic ones
/coverage
/coverage-ts
/node_modules
/.env
/.nyc_output

# We're a library, so please, no lock files
/package-lock.json
/yarn.lock

# Generated types
*.d.ts
*.d.ts.map
!/lib/advanced-types.d.ts
!/index.d.ts

# Library specific ones
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
4 changes: 4 additions & 0 deletions .knip.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://unpkg.com/knip@2/schema.json",
"ignoreDependencies": ["@types/mocha", "mocha"]
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 Pelle Wessman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Node Module Template

A GitHub template repo for node modules

<!--
[![npm version](https://img.shields.io/npm/v/buffered-async-iterable.svg?style=flat)](https://www.npmjs.com/package/buffered-async-iterable)
[![npm downloads](https://img.shields.io/npm/dm/buffered-async-iterable.svg?style=flat)](https://www.npmjs.com/package/buffered-async-iterable)
-->
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/voxpelli/eslint-config)
[![Module type: ESM](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)
[![Follow @voxpelli@mastodon.social](https://img.shields.io/mastodon/follow/109247025527949675?domain=https%3A%2F%2Fmastodon.social&style=social)](https://mastodon.social/@voxpelli)

## Usage

### Simple

```javascript
import { something } from '@voxpelli/node-module-template';

// Use that something
```

## API

### `something(input, { configParam }) => Promise<output>`

Takes a value (`input`), does something configured by the config (`configParam`) and returns the processed value asyncly(`output`)

## Similar modules

* [`example`](https://example.com/) – is similar in this way

## See also

* [Announcement blog post](#)
* [Announcement tweet](#)
14 changes: 14 additions & 0 deletions declaration.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

{
"extends": "./tsconfig",
"files": [],
"exclude": [
"test/**/*.js"
],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"noEmit": false,
"emitDeclarationOnly": true
}
}
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type * from './lib/advanced-types.d.ts';

export { default } from './lib/main.js';
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './lib/main.js';
2 changes: 2 additions & 0 deletions lib/advanced-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// TODO: Replace with proper types or remove file
import {} from 'node:path';
6 changes: 6 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @returns {Promise<void>}
*/
export default async function () {
// TODO: Extend or replace
}
72 changes: 72 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "@voxpelli/node-module-template",
"version": "0.0.0",
"description": "A GitHub template repo for node modules",
"homepage": "http://github.com/voxpelli/node-module-template",
"repository": {
"type": "git",
"url": "git://github.com/voxpelli/node-module-template.git"
},
"keywords": [],
"author": "Pelle Wessman <pelle@kodfabrik.se> (http://kodfabrik.se/)",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"type": "module",
"exports": "./index.js",
"types": "index.d.ts",
"files": [
"/index.js",
"/index.d.ts",
"/index.d.ts.map",
"lib/*.js",
"lib/*.d.ts",
"lib/*.d.ts.map"
],
"scripts": {
"build:0": "run-s clean",
"build:1-declaration": "tsc -p declaration.tsconfig.json",
"build": "run-s build:*",
"check:installed-check": "installed-check -i eslint-plugin-jsdoc -i knip -i installed-check",
"check:knip": "knip",
"check:lint": "eslint --report-unused-disable-directives .",
"check:tsc": "tsc",
"check:type-coverage": "type-coverage --detail --strict --at-least 99 --ignore-files 'test/*'",
"check": "run-s clean && run-p check:*",
"clean:declarations-top": "rm -rf $(find . -maxdepth 1 -type f -name '*.d.ts*' ! -name 'advanced-types.d.ts' ! -name 'index.d.ts')",
"clean:declarations-lib": "rm -rf $(find lib -type f -name '*.d.ts*' ! -name 'advanced-types.d.ts')",
"clean": "run-p clean:*",
"prepare": "husky install",
"prepublishOnly": "run-s build",
"test:mocha": "c8 --reporter=lcov --reporter text mocha 'test/**/*.spec.js'",
"test-ci": "run-s test:*",
"test": "run-s check test:*"
},
"devDependencies": {
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^16.18.38",
"@voxpelli/eslint-config": "^18.0.0",
"@voxpelli/tsconfig": "^8.0.0",
"c8": "^8.0.0",
"chai": "^4.3.7",
"eslint": "^8.45.0",
"eslint-plugin-es-x": "^7.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^46.4.4",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"eslint-plugin-unicorn": "^47.0.0",
"husky": "^8.0.3",
"installed-check": "^8.0.0",
"knip": "^2.16.0",
"mocha": "^10.2.0",
"npm-run-all2": "^6.0.6",
"type-coverage": "^2.26.0",
"typescript": "~5.1.6"
}
}
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"github>voxpelli/renovate-config"
]
}
3 changes: 3 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@voxpelli/eslint-config/mocha"
}
12 changes: 12 additions & 0 deletions test/main.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import chai from 'chai';

// TODO: Replace with proper setup
import something from '../index.js';

chai.should();

describe('something', () => {
it('should work', async () => {
await something();
});
});
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "@voxpelli/tsconfig/node16.json",
"files": [
"index.js"
],
"include": [
"lib/**/*",
"test/**/*",
]
}

0 comments on commit 3801b7c

Please sign in to comment.