Skip to content

Commit

Permalink
feat: update template
Browse files Browse the repository at this point in the history
  • Loading branch information
rsaz committed Apr 27, 2024
1 parent 18ad91a commit d9b047e
Show file tree
Hide file tree
Showing 13 changed files with 255 additions and 122 deletions.
37 changes: 22 additions & 15 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
/* eslint-env node */
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"eslint-config-prettier",
"prettier"
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"eslint-config-prettier",
"prettier",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./tsconfig.cjs.json"]
project: ["./tsconfig.cjs.json", "./tsconfig.esm.json","./tsconfig.json"],
},
plugins: ["@typescript-eslint"],
root: true,
env: {
node: true,
jest: true,
node: true,
jest: true,
},
ignorePatterns: ["dist", "node_modules", ".eslintrc.cjs"],
ignorePatterns: [
"lib",
"node_modules",
".eslintrc.cjs",
"**/__tests__/*.spec.ts",
"vitest.config.ts",
],
rules: {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": ["error", { default: "generic" }],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-literal-property-style": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": ["error", { default: "generic" }],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-literal-property-style": "error",
"@typescript-eslint/explicit-function-return-type": "error",
},
}
};

85 changes: 47 additions & 38 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
# name: Build and Publish to NPM
# name: Build and Test

# on:
# push:
# branches:
# - main
# pull_request:
# # The branches below must be a subset of the branches above
# branches: [ "main" ]
# pull_request_target:
# types: [opened, synchronize, reopened]
# push:
# branches:
# - main
# pull_request:
# branches: ["main"]
# pull_request_target:
# types: [opened, synchronize, reopened]

# jobs:
# build:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v2

# - name: Use Node.js
# uses: actions/setup-node@v2
# with:
# node-version: '18.11.0'

# - name: Install Dependencies
# run: npm install

# - name: Build
# run: npm run build:linux

#- name: Unit Tests
# working-directory: packages/core
# run: npm test
# env:
# CI: true

# - name: Set up .npmrc
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
# - name: Install dependencies
# run: npm ci

# build:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v2

# - name: Use Node.js
# uses: actions/setup-node@v2
# with:
# node-version: "18.11.0"

# - name: Install Dependencies
# run: npm install

# - name: Build
# run: npm run build

# - name: Unit Tests
# working-directory: ./src
# run: npm run test
# env:
# CI: true

# - name: Run Code Coverage
# working-directory: ./src
# run: npm run coverage

# - name: Upload coverage reports to Codecov
# uses: codecov/[email protected]
# with:
# working-directory: .
# token: ${{ secrets.CODECOV_TOKEN }}

# - name: Set up .npmrc
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc

# - name: Install dependencies
# run: npm ci
8 changes: 4 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
<[email protected]>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<a name="readme-top"></a>

<!-- PROJECT SHIELDS -->
[![Codecov][codecov-shield]][codecov-url]
[![NPM][npm-shield]][npm-url]
![Build][build-shield]
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
Expand Down Expand Up @@ -92,16 +95,22 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expres

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots?style=for-the-badge
[contributors-url]: https://github.com/expressots/expressots/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/expressots/expressots?style=for-the-badge
[forks-url]: https://github.com/expressots/expressots/forks
[stars-shield]: https://img.shields.io/github/stars/expressots/expressots?style=for-the-badge
[stars-url]: https://github.com/expressots/expressots/stargazers
[issues-shield]: https://img.shields.io/github/issues/expressots/expressots?style=for-the-badge
[issues-url]: https://github.com/expressots/expressots/issues
[license-shield]: https://img.shields.io/github/license/expressots/expressots?style=for-the-badge
[license-url]: https://github.com/expressots/expressots/blob/main/LICENSE

[codecov-url]: https://codecov.io/gh/expressots/expressots-project-template
[codecov-shield]: https://img.shields.io/codecov/c/gh/expressots/expressots-project-template/main?style=for-the-badge&logo=codecov&labelColor=FB9AD1
[npm-url]: https://www.npmjs.com/package/@expressots/expressots-project-template
[npm-shield]: https://img.shields.io/npm/v/@expressots/expressots-project-template?style=for-the-badge&logo=npm&color=9B3922
[build-shield]: https://img.shields.io/github/actions/workflow/status/expressots/adapter-express/build.yaml?branch=main&style=for-the-badge&logo=github
[contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots-project-template?style=for-the-badge
[contributors-url]: https://github.com/expressots/expressots-project-template/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/expressots/expressots-project-template?style=for-the-badge
[forks-url]: https://github.com/expressots/expressots-project-template/forks
[stars-shield]: https://img.shields.io/github/stars/expressots/expressots-project-template?style=for-the-badge
[stars-url]: https://github.com/expressots/expressots-project-template/stargazers
[issues-shield]: https://img.shields.io/github/issues/expressots/expressots-project-template?style=for-the-badge
[issues-url]: https://github.com/expressots/expressots-project-template/issues
[license-shield]: https://img.shields.io/github/license/expressots/expressots-project-template?style=for-the-badge
[license-url]: https://github.com/expressots/expressots-project-template/blob/main/LICENSE
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/company/expresso-ts/
[product-screenshot]: images/screenshot.png
19 changes: 0 additions & 19 deletions jest.config.ts

This file was deleted.

59 changes: 31 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@expressots/project_name",
"name": "@expressots/package-name",
"version": "0.0.1",
"description": "Expressots - modern, fast, lightweight nodejs web framework (@core)",
"description": "Expressots - modern, fast, lightweight nodejs web framework (@package-name)",
"author": "",
"main": "./lib/cjs/index.js",
"types": "./lib/cjs/types/index.d.ts",
Expand Down Expand Up @@ -51,41 +51,44 @@
},
"scripts": {
"prepare": "husky install",
"win-clean": "if exist lib (del /q lib\\*)",
"linux-clean": "rm -rf lib/*",
"win-cpy": "xcopy package.json lib\\ && xcopy README.md lib\\ && xcopy CHANGELOG.md lib\\ /Y",
"linux-cpy": "cp package.json README.md CHANGELOG.md lib/",
"build:win": "npm run win-clean && npm run build:esm && npm run build:cjs && npm run win-cpy",
"build:linux": "npm run linux-clean && npm run build:esm && npm run build:cjs && npm run linux-cpy",
"build:esm": "tsc -p tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs ",
"clean": "node scripts/rm.js lib",
"copy": "node scripts/copy.js package.json README.md CHANGELOG.md lib",
"build": "npm run clean && npm run build:cjs && npm run copy",
"build:cjs": "tsc -p tsconfig.cjs.json",
"git": "powershell -Command \"git add .; git commit -m \"%1\"; npm run release\"",
"build:esm": "tsc -p tsconfig.esm.json",
"release": "release-it",
"test": "jest",
"prepublish": "npm run build && npm pack",
"publish": "npm publish --tag latest",
"test": "vitest run --reporter default",
"test:watch": "vitest run --watch",
"coverage": "vitest run --coverage",
"format": "prettier --write \"src/**/*.ts\" --cache",
"lint": "eslint \"src/**/*.ts\"",
"lint:fix": "eslint \"src/**/*.ts\" --fix"
},
"dependencies": {
"dotenv": "^16.0.3",
"jest": "^29.5.0",
"reflect-metadata": "^0.1.13"
"reflect-metadata": "0.2.2"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@release-it/conventional-changelog": "^7.0.1",
"@types/jest": "^29.5.0",
"@types/node": "^20.4.9",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"eslint-config-prettier": "^9.0.0",
"eslint": "^8.48.0",
"husky": "^8.0.3",
"prettier": "^3.0.3",
"release-it": "^16.1.5",
"ts-jest": "^29.0.5",
"typescript": "^5.2.2"
"@codecov/vite-plugin": "0.0.1-beta.6",
"@commitlint/cli": "18.0.0",
"@commitlint/config-conventional": "17.7.0",
"@expressots/core": "latest",
"@release-it/conventional-changelog": "7.0.1",
"@types/node": "20.4.9",
"@typescript-eslint/eslint-plugin": "6.6.0",
"@typescript-eslint/parser": "6.6.0",
"@vitest/coverage-v8": "1.4.0",
"eslint": "8.48.0",
"eslint-config-prettier": "9.0.0",
"husky": "8.0.3",
"prettier": "3.0.3",
"release-it": "16.1.5",
"ts-jest": "29.0.5",
"typescript": "5.2.2",
"vite": "5.2.8",
"vite-tsconfig-paths": "4.3.2",
"vitest": "1.4.0"
},
"release-it": {
"git": {
Expand Down
35 changes: 35 additions & 0 deletions scripts/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require("fs");
const path = require("path");

function copyRecursiveSync(src, dest) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const isDirectory = exists && stats.isDirectory();

if (isDirectory) {
fs.mkdirSync(dest);
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(
path.join(src, childItemName),
path.join(dest, childItemName),
);
});
} else {
fs.copyFileSync(src, dest);
}
}

if (process.argv.length < 4) {
process.stderr.write(
"Usage: node copy.js <origin1> <origin2> ... <destination>\n",
);
process.exit(1);
}

const destination = process.argv[process.argv.length - 1];

for (let i = 2; i < process.argv.length - 1; i++) {
const origin = process.argv[i];
copyRecursiveSync(origin, path.join(destination, path.basename(origin)));
process.stdout.write(`Copied: ${origin} to ${destination}\n`);
}
30 changes: 30 additions & 0 deletions scripts/mv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require("fs").promises;

const moveFile = async (origin, destination) => {
try {
await fs.access(origin);
} catch (error) {
process.stderr.write(`Error: Origin '${origin}' not found\n`);
process.exit(1);
}

try {
await fs.rename(origin, destination);
process.stdout.write(`Move: ${origin} to ${destination}\n`);
} catch (error) {
process.stderr.write(
`Error: Unable to move '${origin}' to '${destination}'\n`,
);
process.exit(1);
}
};

if (process.argv.length !== 4) {
process.stderr.write("Usage: node mv.js <origin> <destination>\n");
process.exit(1);
}

const origin = process.argv[2];
const destination = process.argv[3];

moveFile(origin, destination);
19 changes: 19 additions & 0 deletions scripts/rm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require("fs").promises;

const removeTarget = async (target) => {
try {
await fs.rm(target, { recursive: true, force: true });
process.stdout.write(`Removed: ${target}\n`);
} catch (error) {
process.stderr.write(`Error: Unable to remove '${target}'\n`);
process.exit(1);
}
};

if (process.argv.length !== 3) {
process.stderr.write("Usage: node rm.js <dir/file>\n");
process.exit(1);
}

const target = process.argv[2];
removeTarget(target);
Loading

0 comments on commit d9b047e

Please sign in to comment.