Skip to content

Commit

Permalink
Restructure project
Browse files Browse the repository at this point in the history
  • Loading branch information
paescuj committed Aug 13, 2024
1 parent f5a4a47 commit 901e1cd
Show file tree
Hide file tree
Showing 18 changed files with 1,104 additions and 31 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root=true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{mjs,cjs,js,mts,cts,ts,json,vue,html,scss,css,toml,md}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_style = space
40 changes: 40 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Setup
description: Configure Node.js + pnpm and install dependencies

inputs:
registry:
description: NPM registry to set up for auth
required: false

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
registry-url: ${{ inputs.registry }}

- uses: pnpm/action-setup@v4
name: Setup pnpm
id: pnpm-install
with:
run_install: false

- name: Get pnpm cache dir
id: pnpm-cache-dir
shell: bash
run: echo "pnpm-cache-dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache-dir.outputs.pnpm-cache-dir }}
key:
${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
37 changes: 37 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run linter
run: pnpm run lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Run test
run: pnpm test
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: SemVer for the release, for example "1.0.0"
required: true
type: string

permissions:
contents: write

jobs:
check-version:
name: Check Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.release }}
is-prerelease: ${{ steps.version.outputs.prerelease && true || false }}
steps:
- name: Check version
uses: madhead/semver-utils@v4
id: version
with:
version: ${{ inputs.version }}
lenient: false

create-version:
name: Create Version
runs-on: ubuntu-latest
needs: check-version
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup env
uses: ./.github/actions/setup

- name: Bump version
run: pnpm version --no-git-tag-version '${{ needs.check-version.outputs.version }}'

- name: Create version commit & tag
run: |
author='${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>'
version='v${{ needs.check-version.outputs.version }}'
branch='${{ github.ref }}'
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit --all --author "$author" --message "$version"
git tag --annotate "$version" --message "$version"
git push --atomic origin "$branch" "$version"
create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- check-version
- create-version
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
'v${{ needs.check-version.outputs.version }}' \
--verify-tag \
--generate-notes \
${{ needs.check-version.outputs.is-prerelease == 'true' && '--prerelease' || '' }}
publish-npm:
name: Publish to NPM
runs-on: ubuntu-latest
needs:
- check-version
- create-version
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: refs/tags/v${{ needs.check-version.outputs.version }}

- name: Setup env
uses: ./.github/actions/setup
with:
registry: https://registry.npmjs.org

- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
pnpm publish \
--access=public \
--no-git-checks \
--tag ${{ needs.check-version.outputs.is-prerelease == 'true' && 'canary' || 'latest' }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# User preferences
.DS_Store

# Dependencies
node_modules/

# Builds / Caches
dist/
coverage/
*.tsbuildinfo
.eslintcache

# IDEs / Editors
.idea/
*.code-workspace
.history/
*.sublime-settings
.*.swp
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
engine-strict=true
shell-emulator=true
save-prefix=''
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "editorconfig.editorconfig"]
}
49 changes: 49 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss"
]
}
12 changes: 6 additions & 6 deletions base/tsconfig.json → configs/base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Base",
"compilerOptions": {
"checkJs": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
Expand All @@ -16,8 +14,10 @@
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"checkJs": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"declaration": true
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions node18-cjs/tsconfig.json → configs/node18-cjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"display": "Node.js 18 CommonJS",
"extends": "../base/tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2022"
"target": "ES2022",
"module": "CommonJS"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"display": "Node.js 18 ESM",
"extends": "../base/tsconfig.json",
"compilerOptions": {
"module": "Node16",
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"verbatimModuleSyntax": true
}
Expand Down
18 changes: 9 additions & 9 deletions vue3/tsconfig.json → configs/vue3/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
"display": "Vue.js 3",
"extends": "../base/tsconfig.json",
"compilerOptions": {
// It's recommended to author and ship in ES modules.
// This recommendation includes environments like Vitest, Vite Config File, Vite SSR, etc.
"module": "ES2022",

// - Vue 3 supports ES2016+
// - For Vite, the actual compilation target is determined by the
// `build.target` option in the Vite config.
// So don't change the `target` field here. It has to be
// at least `ES2020` for dynamic `import()`s and `import.meta` to work correctly.
"target": "ES2022",

// Required in Vue projects.
"jsx": "preserve",
"jsxImportSource": "vue",

// Add DOM definitions.
"lib": ["ES2022", "DOM", "DOM.Iterable"],

// It's recommended to author and ship in ES modules.
// This recommendation includes environments like Vitest, Vite Config File, Vite SSR, etc.
"module": "ES2022",

// Enable some resolution features that are only available in bundlers.
"moduleResolution": "bundler",
"resolveJsonModule": true,

// Any imports or exports without a type modifier are left around. This is important for `<script setup>`.
// Anything that uses the type modifier is dropped entirely.
"verbatimModuleSyntax": true,

// Required in Vue projects
"jsx": "preserve",
"jsxImportSource": "vue"
"verbatimModuleSyntax": true
}
}
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import directusConfig from '@directus/eslint-config';

export default directusConfig();
Loading

0 comments on commit 901e1cd

Please sign in to comment.