Skip to content

Commit

Permalink
build: updated template
Browse files Browse the repository at this point in the history
  • Loading branch information
AlansCodeLog committed May 30, 2024
1 parent 28e37f6 commit 1a654a0
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 83 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:

on:
push:
branches: [ master ]
branches: [ master , build, experimental ]
repository_dispatch:
types: [ build ]

Expand All @@ -21,25 +21,24 @@ jobs:
steps:

# region Setup
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setting Up Node.js (${{ matrix.node-version }})
uses: actions/setup-node@v3
- uses: actions/setup-node@v4
name: Setting Up Node.js (${{ matrix.node-version }})
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: latest

- name: Get Pnpm Cache Path
id: pnpm-cache
run: |
echo "::set-output name=dir::$(pnpm store path)"
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
name: pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.dir }}
Expand All @@ -50,14 +49,15 @@ jobs:
- run: "echo Cache Key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}"
- run: "echo Cache Restore-Keys: ${{ runner.os }}-pnpm-store-"
- run: "echo Pnpm Cache Hit: ${{ steps.pnpm-cache.outputs.cache-hit }}"
# regionend

# region Steps
- run: pnpm install --frozen-lockfile
if: "env.USE_LOCKFILE == 'true'"

- run: pnpm install --no-lockfile
if: "env.USE_LOCKFILE != 'true'"
# regionend

# region Steps

- run: pnpm build

Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@ jobs:
steps:

# region Setup
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setting Up Node.js (${{ matrix.node-version }})
uses: actions/setup-node@v3
- uses: actions/setup-node@v4
name: Setting Up Node.js (${{ matrix.node-version }})
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: latest
version: latest

- name: Get Pnpm Cache Path
id: pnpm-cache
run: |
echo "::set-output name=dir::$(pnpm store path)"
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
name: pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.dir }}
Expand All @@ -50,14 +49,15 @@ jobs:
- run: "echo Cache Key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}"
- run: "echo Cache Restore-Keys: ${{ runner.os }}-pnpm-store-"
- run: "echo Pnpm Cache Hit: ${{ steps.pnpm-cache.outputs.cache-hit }}"
# regionend

- run: pnpm install --frozen-lockfile
if: "env.USE_LOCKFILE == 'true'"

- run: pnpm install --no-lockfile
if: "env.USE_LOCKFILE != 'true'"
# regionend

# region Steps
- run: pnpm build

- run: pnpm lint
Expand All @@ -73,7 +73,7 @@ jobs:

- name: Documentation
if: "env.ENABLE_DOCS == 'true'"
uses: crazy-max/ghaction-github-pages@v2
uses: crazy-max/ghaction-github-pages@v4
with:
jekyll: false
target_branch: gh-pages
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@ jobs:
steps:

# region Setup
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setting Up Node.js (${{ matrix.node-version }})
uses: actions/setup-node@v3
- uses: actions/setup-node@v4
name: Setting Up Node.js (${{ matrix.node-version }})
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: latest

- name: Get Pnpm Cache Path
id: pnpm-cache
run: |
echo "::set-output name=dir::$(pnpm store path)"
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
name: pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.dir }}
Expand All @@ -47,14 +46,15 @@ jobs:
- run: "echo Cache Key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}"
- run: "echo Cache Restore-Keys: ${{ runner.os }}-pnpm-store-"
- run: "echo Pnpm Cache Hit: ${{ steps.pnpm-cache.outputs.cache-hit }}"
# regionend

# region Steps
- run: pnpm install --frozen-lockfile
if: "env.USE_LOCKFILE == 'true'"

- run: pnpm install --no-lockfile
if: "env.USE_LOCKFILE != 'true'"
# regionend

# region Steps

- name: Commits to Lint
run: git log ${{github.event.pull_request.base.sha}}..${{github.event.pull_request.head.sha}} --graph --abbrev-commit --decorate --format=format:'%h%d%n%s (%cr) - %an (%ae)%n%b'
Expand All @@ -69,7 +69,5 @@ jobs:
- run: pnpm coverage

- name: Coverage
uses: romeovs/lcov-reporter-action@v0.2.16
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
uses: romeovs/lcov-reporter-action@v0.3.1
# regionend
19 changes: 9 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@ jobs:
steps:

# region Setup
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setting Up Node.js (${{ matrix.node-version }})
uses: actions/setup-node@v3
- uses: actions/setup-node@v4
name: Setting Up Node.js (${{ matrix.node-version }})
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2.0.1
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
version: latest

- name: Get Pnpm Cache Path
id: pnpm-cache
run: |
echo "::set-output name=dir::$(pnpm store path)"
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
name: pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.dir }}
Expand All @@ -50,15 +49,15 @@ jobs:
- run: "echo Cache Key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}"
- run: "echo Cache Restore-Keys: ${{ runner.os }}-pnpm-store-"
- run: "echo Pnpm Cache Hit: ${{ steps.pnpm-cache.outputs.cache-hit }}"
# regionend

# region Steps
- run: pnpm install --frozen-lockfile
if: "env.USE_LOCKFILE == 'true'"

- run: pnpm install
- run: pnpm install --no-lockfile
if: "env.USE_LOCKFILE != 'true'"
# regionend

# region Steps
- run: pnpm build

- run: pnpm lint:eslint # test command will lint types
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ docs
coverage

dist
.direnv
!flake.lock

.direnv
25 changes: 22 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
import config from "@alanscodelog/eslint-config"
export default config

import { allFileTypes, tsEslintConfig, typescriptConfig } from "@alanscodelog/eslint-config"
export default tsEslintConfig(
// https://github.com/AlansCodeLog/eslint-config
...typescriptConfig,
{
files: [`**/*.{${allFileTypes.join(",")}}`],
languageOptions: {
parserOptions: {
// eslint-disable-next-line camelcase
EXPERIMENTAL_useProjectService: false,
project: "./tsconfig.eslint.json",
},
},
ignores: [
// ...
],
},
// RULE LINKS
// Eslint: https://eslint.org/docs/rules/
// Typescript: https://typescript-eslint.io/rules/
// Vue: https://eslint.vuejs.org/rules/
)
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@
"prepare": "husky && npm run build"
},
"dependencies": {
"@alanscodelog/utils": "4.0.0-beta.17"
"@alanscodelog/utils": "^4.0.0"
},
"devDependencies": {
"@alanscodelog/commitlint-config": "^3.0.1",
"@alanscodelog/eslint-config": "5.0.0-beta.2",
"@alanscodelog/eslint-config": "5.0.0-beta.3",
"@alanscodelog/semantic-release-config": "^4.1.2",
"@alanscodelog/tsconfigs": "^4.0.1",
"@commitlint/cli": "^19.3.0",
"@types/node": "^20.4.1",
"@vitest/coverage-v8": "^1.6.0",
"commitlint": "^19.3.0",
"concurrently": "^8.2.0",
"cross-env": "^7.0.3",
"fast-glob": "^3.3.1",
Expand Down
12 changes: 0 additions & 12 deletions tests/.eslintrc.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
// also here because I want to lint configs as well, but including them in the regular tsconfig can cause problems
"extends": "./tsconfig.json",
"compilerOptions": {
"strictNullChecks": true,
"outDir": "dist",
"baseUrl": "."
},
"include": [
"**/*",
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// https://github.com/AlansCodeLog/tsconfigs
"extends": "@alanscodelog/tsconfigs",
"compilerOptions": {
// todo, temp
"noUncheckedIndexedAccess": false,
"outDir": "dist",
// "types": [
/* "node" */
Expand All @@ -19,7 +17,6 @@
"include": [
"src/**/*.ts",
"src/**/*.js",
"tests/**/*.ts"
],
"exclude": []
}
3 changes: 0 additions & 3 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
// preserve documentation
"removeComments": false
},
"exclude": [
"tests/**"
],
"tsc-alias": {
"resolveFullPaths": true // for esm compatibility
}
Expand Down
16 changes: 3 additions & 13 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { run } from "@alanscodelog/utils/run"
import { run } from "@alanscodelog/utils/node"
import glob from "fast-glob"
import path from "path"
import type { PluginOption } from "vite"
import { externalizeDeps } from "vite-plugin-externalize-deps"
import tsconfigPaths from "vite-tsconfig-paths"
import { defineConfig } from "vitest/config"


Expand All @@ -18,17 +17,14 @@ export default async ({ mode }: { mode: string }) => defineConfig({
plugins: [
// it isn't enough to just pass the deps list to rollup.external since it will not exclude subpath exports
externalizeDeps(),
// even if we don't use aliases, this is needed to get imports based on baseUrl working
tsconfigPaths(),
// runs build:types script which takes care of generating types and fixing type aliases and baseUrl imports
// runs build:types script which takes care of generating types
typesPlugin(),
],
build: {
outDir: "dist",
lib: {
entry: glob.sync(path.resolve(__dirname, "src/**/*.ts")),
entry: glob.sync(path.resolve(import.meta.dirname, "src/**/*.ts")),
formats: ["es"],

},
rollupOptions: {
output: {
Expand All @@ -49,12 +45,6 @@ export default async ({ mode }: { mode: string }) => defineConfig({
test: {
cache: process.env.CI ? false : undefined,
},
resolve: {
alias: [
// for tests only, absolute path needed because of https://github.com/vitest-dev/vitest/issues/2425
{ find: /^@\/(.*)/, replacement: `${path.resolve("src")}/$1/index.ts` },
],
},
server: {
// for locally linked repos when using vite server (i.e. not needed for libraries)
fs: {
Expand Down

0 comments on commit 1a654a0

Please sign in to comment.