Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Sep 20, 2023
0 parents commit 3f9f0a8
Show file tree
Hide file tree
Showing 16 changed files with 2,916 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This is a Github Workflow that runs tests on any push or pull request.
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
name: CI
on: [push, pull_request]
jobs:
push:
name: Push ${{ github.ref }}
if: github.event_name == 'push'
runs-on: ubuntu-22.04
permissions:
checks: read
statuses: write
contents: write
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.ref == 'refs/heads/master' && '0' || '1' }}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
# cache: 'yarn'

- name: Fetch deps
run: yarn --mutex network --frozen-lockfile --network-concurrency 25 --silent --disable-self-update-check

- name: Build
run: yarn build

- name: Run tests
run: yarn test

# - name: Codeclimate
# if: github.ref == 'refs/heads/master'
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageLocations: |
# ${{github.workspace}}/target/coverage/lcov.info:lcov

# - name: Semantic Release
# if: github.ref == 'refs/heads/master'
# env:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# NPM_PROVENANCE: true
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
# GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
# GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
# GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
# run: npm_config_yes=true npx zx-semrel

pr:
if: github.event_name == 'pull_request'
name: PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
strategy:
matrix:
os: [ ubuntu-22.04, windows-latest ]
node-version: [ 20 ]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# cache: 'yarn'

- name: Fetch deps
run: yarn --mutex network --frozen-lockfile --network-concurrency 25 --silent --disable-self-update-check

- name: Build
run: yarn build

- name: Run tests
run: yarn test
165 changes: 165 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# IDEs
.idea

# Credentials
**/*.asc
**/*.key
**/*.pem
**/*.cert
**/.npmrc
**/.yarnrc

# Bundles
bundle
build
buildstamp.json
dist
docs
flow-typed
lib
target
typings

# Temp assets
.temp
temp

# Codeclimate
codeclimate.*
cc-reporter
cc-reporter.*

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
coverage.*
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo
.tsbuildinfo
buildcache
.buildcache

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Anton Golub

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.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# blank-ts
Template repository for TS projects

## License
[MIT](./LICENSE)
57 changes: 57 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@antongolub/blank-ts",
"version": "0.0.0",
"description": "Blank TS package",
"type": "module",
"main": "target/cjs/index.cjs",
"exports": {
".": {
"types": "./target/dts/index.d.ts",
"require": "./target/cjs/index.cjs",
"import": "./target/esm/index.mjs",
"default": "./target/esm/index.mjs"
}
},
"module": "target/esm/index.mjs",
"types": "target/dts/index.d.ts",
"files": [
"target/cjs",
"target/esm",
"target/dts"
],
"scripts": {
"build": "concurrently 'npm:build:*'",
"build:esm": "node ./src/scripts/build.cjs",
"build:cjs": "node ./src/scripts/build.cjs --cjs",
"build:dts": "tsc --emitDeclarationOnly --skipLibCheck --outDir target/dts",
"build:docs": "typedoc --options src/main/typedoc",
"build:stamp": "npm_config_yes=true npx buildstamp",
"test": "concurrently 'npm:test:*'",
"test:lint": "eslint -c src/test/lint/.eslintrc.json src",
"test:unit": "c8 -r lcov -r text -o target/coverage -x src/scripts -x src/test node --loader ts-node/esm --experimental-specifier-resolution=node src/scripts/test.mjs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/antongolub/blank-ts.git"
},
"author": "Anton Golub <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/antongolub/blank-ts/issues"
},
"homepage": "https://github.com/antongolub/blank-ts#readme",
"dependencies": {},
"devDependencies": {
"@types/node": "^20.6.3",
"c8": "^8.0.1",
"concurrently": "^8.2.1",
"esbuild": "^0.19.3",
"esbuild-node-externals": "^1.9.0",
"eslint": "^8.49.0",
"eslint-config-qiwi": "^2.1.3",
"fast-glob": "^3.3.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
"typescript": "^5.2.2"
}
}
1 change: 1 addition & 0 deletions src/main/ts/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = (): undefined => undefined
1 change: 1 addition & 0 deletions src/main/ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './foo'
15 changes: 15 additions & 0 deletions src/main/typedoc/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@antongolub/blank-ts",
"out": "../../../target/docs",
"entryPoints": ["../../../src/main/ts/"],
"exclude": ["../../../src/test", "**/node_modules/**"],
"externalPattern": ["**/node_modules/**"],
"excludeExternals": true,
"excludePrivate": true,
"excludeProtected": true,
"includeVersion": true,
"hideGenerator": true,
"readme": "../../../README.md",
"tsconfig": "../../../tsconfig.json",
"theme": "default"
}
40 changes: 40 additions & 0 deletions src/scripts/build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node

const esbuild = require('esbuild')
const { nodeExternalsPlugin } = require('esbuild-node-externals')

const esmConfig = {
entryPoints: ['./src/main/ts/index.ts'],
outdir: './target/esm',
bundle: true,
minify: true,
sourcemap: true,
sourcesContent: false,
platform: 'node',
target: 'ES2020',
format: 'esm',
outExtension: {
'.js': '.mjs'
},
external: ['node:*'], // https://github.com/evanw/esbuild/issues/1466
plugins: [nodeExternalsPlugin()], // https://github.com/evanw/esbuild/issues/619
tsconfig: './tsconfig.json'
}

const cjsConfig = {
...esmConfig,
outdir: './target/cjs',
target: 'es6',
format: 'cjs',
outExtension: {
'.js': '.cjs'
}
}

const config = process.argv.includes('--cjs')
? cjsConfig
: esmConfig

esbuild
.build(config)
.catch(() => process.exit(1))
Loading

0 comments on commit 3f9f0a8

Please sign in to comment.