Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/actions/nx-setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Setup node, install dependencies and configure NX'
description: 'Setup node, install dependencies and set nx env variables'

runs:
using: 'composite'
steps:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: .tool-versions
cache: npm

- name: Install
shell: bash
run: npm ci --prefer-offline --no-audit

- name: Setup Nx
uses: nrwl/nx-set-shas@v4
22 changes: 22 additions & 0 deletions .github/actions/setup-git/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Setup git'
description: 'Configures git user and outputs useful variables'

outputs:
branch-name:
description: 'Branch name'
value: ${{ steps.git.outputs.branch-name }}
commit-sha-short:
description: 'Short commit sha of HEAD'
value: ${{ steps.git.outputs.sha-short }}

runs:
using: 'composite'
steps:
- name: Set git config and variables
shell: bash
id: git
run: |
git config --global user.name 'Github Action'
git config --global user.email '[email protected]'
echo "branch-name=$(echo ${{ github.head_ref || github.ref_name }})" >> $GITHUB_OUTPUT
echo "sha-short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI

on:
push:
branches:
- main
pull_request:

permissions:
actions: read
contents: write
packages: write
id-token: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
NX_VERBOSE_LOGGING: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Setup git
id: git
uses: ./.github/actions/setup-git

# This enables task distribution via Nx Cloud
# Run this command as early as possible, before dependencies are installed
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
# Uncomment this line to enable task distribution
# - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"

- name: Setup node, install dependencies and configure nx
uses: ./.github/actions/nx-setup-node

- name: Lint package configurations
run: npx nx syncpack

# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
# - run: npx nx-cloud record -- echo Hello World
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected

- name: Build lint test affected projects
run: npx nx affected --targets lint test build e2e

- name: Version
run: |
if [ "${{ steps.git.outputs.branch-name }}" == "main" ]; then
npx nx release \
--group packages \
--skip-publish
else
npx nx release \
--preid pr-${{ steps.git.outputs.commit-sha-short }} \
--group packages \
--skip-publish
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
run: |
if [ "${{ steps.git.outputs.branch-name }}" == "main" ]; then
npx nx release publish \
--group packages \
--tag latest
else
npx nx release publish \
--group packages \
--tag pr-${{ steps.git.outputs.commit-sha-short }}
fi

git push --follow-tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# See https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# nx env strategy
.env.local
.env.*.local

# dotenvx private keys
.env.keys

# compiled output
dist
tmp
out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

.nx/cache
.nx/workspace-data

test-output

vite.config.*.timestamp*
vitest.config.*.timestamp*

# Terraform (ideally, this should be added once we install nx terraform plugin)
.terraform
tfplan
.cursor/rules/nx-rules.mdc
.github/instructions/nx.instructions.md

# Ignore generated credentials from google-github-actions/auth
gha-creds-*.json
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@thdk:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
/.nx/workspace-data
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
43 changes: 43 additions & 0 deletions .syncpackrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @ts-check

/** @type {import("syncpack").RcFile} */
const config = {
semverGroups: [
{
// packages that are published and installed by other libs/app not managed in this repo shouldn't pin version of any dependency
range: '^',
dependencyTypes: ['prod', 'dev'],
dependencies: ['**'],
packages: ['@thdk/gittai'],
},
// all other dependencies should be locked to the exact same version
{
range: '',
dependencyTypes: [
'dev',
'prod',
'resolutions',
'overrides',
'pnpmOverrides',
'local',
],
},
],
sortFirst: [
'name',
'description',
'version',
'private',
'author',
'license',
'type',
'main',
'module',
'types',
'exports',
'nx',
'scripts',
],
};

module.exports = config;
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 24.11.0
28 changes: 28 additions & 0 deletions .verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# path to a directory with all packages
storage: ../tmp/local-registry/storage

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
maxage: 60m

packages:
'**':
# give all users (including non-authenticated users) full access
# because it is a local registry
access: $all
publish: $all
unpublish: $all

# if package is not available locally, proxy requests to npm registry
proxy: npmjs

# log settings
log:
type: stdout
format: pretty
level: warn

publish:
allow_offline: true # set offline to true to allow publish offline
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner",
"ms-playwright.playwright"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eslint.validate": ["json"]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @thdk open-source

63 changes: 63 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import nx from '@nx/eslint-plugin';

export default [
...nx.configs['flat/base'],
...nx.configs['flat/typescript'],
...nx.configs['flat/javascript'],
{
ignores: [
'**/dist',
'**/vite.config.*.timestamp*',
'**/vitest.config.*.timestamp*',
],
},
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: [
'{projectRoot}/eslint.config.{js,cjs,mjs}',
'{projectRoot}/esbuild.config.{js,ts,mjs,mts}',
],
},
],
},
languageOptions: {
parser: await import('jsonc-eslint-parser'),
},
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
{
files: [
'**/*.ts',
'**/*.tsx',
'**/*.cts',
'**/*.mts',
'**/*.js',
'**/*.jsx',
'**/*.cjs',
'**/*.mjs',
],
// Override or add rules here
rules: {},
},
];
6 changes: 6 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Config } from 'jest';
import { getJestProjectsAsync } from '@nx/jest';

export default async (): Promise<Config> => ({
projects: await getJestProjectsAsync(),
});
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
Loading