-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adds .gitignore (in config dir and copy of it for local use) - adds config dir for shared configuration - creates config/eslint.config.js with placeholder info - adds version bump script - adds github job for publishing
- Loading branch information
1 parent
67faa79
commit 6b67f8d
Showing
8 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | ||
|
||
name: Publish to NPM | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
# Give the default GITHUB_TOKEN write permission to commit and push the | ||
# added or changed files to the repository. | ||
contents: write | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit would overwrite the whole history) | ||
fetch-depth: 2 | ||
- name: Use Node.js (22.x) | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22.x | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run bump | ||
- name: Get last commit message | ||
id: last-commit | ||
run: | | ||
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT | ||
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT | ||
# Commit changes to package.json back to the repository | ||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_author: ${{ steps.last-commit.outputs.author }} | ||
file_pattern: 'package.json' | ||
commit_message: ${{ steps.last-commit.outputs.message }} | ||
commit_options: '--amend --no-edit' | ||
push_options: '--force' | ||
skip_fetch: true | ||
- run: npm publish --access public --loglevel verbose --dry-run | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# typescript | ||
# TypeScript | ||
A collection of lint, format, and build configs used at Fauna for TypeScript projects. | ||
|
||
## Included configs (`./config/`) | ||
- `eslint.config.js`, a minimal placeholder eslint config. | ||
- `.gitignore`, a minimal placeholder .gitignore file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# DO NOT EDIT THIS FILE AT $PROJECT_ROOT/.gitignore | ||
# instead, edit it at $PROJECT_ROOT/config/.gitignore | ||
# the project's build step copies it from /config | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// eslint.config.js | ||
module.exports = [ | ||
{ | ||
rules: { | ||
semi: "error", | ||
"prefer-const": "error" | ||
} | ||
} | ||
]; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env node | ||
|
||
const { execSync } = require('node:child_process'); | ||
const { parseHeader } = require('parse-commit-message'); | ||
|
||
const latestCommitMessage = execSync("git log -1 --pretty=%B", { encoding: "utf-8" }); | ||
let versionType, type, scope; | ||
|
||
try { | ||
const header = parseHeader(latestCommitMessage); | ||
type = header.type; | ||
scope = header.scope; | ||
} catch (e) { | ||
scope = undefined; | ||
type = undefined; | ||
} | ||
|
||
if (scope === 'patch' || ['fix', 'chore', 'docs', 'refactor', 'perf', 'test', 'build'].includes(type)) { | ||
versionType = 'patch'; | ||
} else if (scope === 'minor' || ['feat', 'feature'].includes(type)) { | ||
versionType = 'minor'; | ||
} else if (scope === 'major') { | ||
versionType = 'major'; | ||
} else { | ||
versionType = 'patch'; | ||
} | ||
|
||
console.log(`Parsed commit message:\n${latestCommitMessage}\n\nDetermined the version as ${versionType} (from scope ${scope} and change type ${type}).\n`); | ||
console.log(execSync(`npm version ${versionType} --no-git-tag-version`, { encoding: "utf-8" })); |