Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Stutz committed Jan 10, 2024
0 parents commit ad415fd
Show file tree
Hide file tree
Showing 33 changed files with 2,409 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Bug report
about: Report a bug that happened while using/developing this project
title: ''
labels: 'bug'
assignees: ''
---

## What's broken?
<!-- Ex.: "Undefined" message when querying a repo with "npx monotag@latest tag" -->
<!-- Attach screenshots if necessary -->

## Version used

<!-- Ex.: 1.4.3 -->

## Context

<!-- Ex.: We are using this in a monorepo with 300 modules and thousands of tags -->
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'enhancement'
assignees: ''
---

## Problem being solved
<!-- Ex.: When I am using large repos, it takes 60min for doing queries -->

## Proposal
<!-- Ex.: Use git filtering for tags to lower the time processing tags -->

29 changes: 29 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request: -->
<!-- For more information, see the `CONTRIBUTING` guide. -->

## Summary

<!-- Summary of the PR -->

This PR fixes/implements the following **bugs/features**

- [ ] Bug 1
- [ ] Feature 1

<!-- You can skip this if you're fixing a typo or adding an app to the Showcase. -->

Explain the **motivation** for making this change. What existing problem does the pull request solve?

<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->

## Breaking changes

<!-- If you are already aware of any (possible) breaking changes, list them here -->

- [ ] Breaking change 1

## Closing issues

<!-- Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). -->

Fixes #
27 changes: 27 additions & 0 deletions .github/workflows/create-next-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: create-next-tag

on:
workflow_dispatch:

jobs:
create-tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# this is needed if you want the tag push to trigger another workflow
# create a personal token and set a secret with name GH_PERSONAL_TOKEN
# https://github.com/orgs/community/discussions/27028
token: ${{ secrets.GH_PERSONAL_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Create tag and push to repo
run: |
corepack enable
git config --global user.email "[email protected]"
git config --global user.name "Flávio Stutz"
pnpm dlx [email protected] tag-push
17 changes: 17 additions & 0 deletions .github/workflows/master-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: master-build

on:
push:
branches: ['main']

jobs:
build:
name: Build master
uses: flaviostutz/gh-makefile/.github/workflows/make-ci.yml@main
with:
working-directory: ./
tooling: node
tooling-version: 18
target-build: true
target-lint: true
target-unit-tests: true
17 changes: 17 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pr-build

on:
pull_request:
branches: ['main']

jobs:
build:
name: Build PRs
uses: flaviostutz/gh-makefile/.github/workflows/make-ci.yml@main
with:
working-directory: ./
tooling: node
tooling-version: 18
target-build: true
target-lint: true
target-unit-tests: true
35 changes: 35 additions & 0 deletions .github/workflows/tag-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: tag-publish

on:
push:
tags:
- '*'

jobs:
build:
name: Check package
uses: flaviostutz/gh-makefile/.github/workflows/make-ci.yml@main
with:
working-directory: ./
tooling: node
tooling-version: 18
stage: prd
target-build: true
target-lint: true
target-unit-tests: true

publish:
name: Publish to npmjs.org
runs-on: ubuntu-latest
needs: build
environment: npmjs-registry
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: make build
- run: make publish
env:
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
lib-cov
coverage
*.lcov
dist
.cache/
.serverless/
node_modules
.tmp
testcases
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"Orta.vscode-jest"
]
}
4 changes: 4 additions & 0 deletions .vscode/keybindinds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key": "shift+cmd+a",
"command": "eslint.executeAutofix"
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["javascript"]
}
50 changes: 50 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# CONTRIBUTING

Thank you for being interested in helping with Practical CDK Constructs!

## The best way to start

- Look at the "Issues" and choose something to implement

* Fork this project to your account

- Implement it, create unit tests and run `make rules-doc` to update documentation
- Create a PR after you complete it to master branch
- Use make targets for common tasks (they are the same that are run during pipelines)

```sh
make build
make lint
make test
make rules-doc
```

## Questions and discussions

- Discuss design or implementation details of a specific feature in the related Issue comments
- If you have more generic question, create a new Issue

## Bugs and feature requests

- If you find any bug, create a new Issue describing what is the structure of your monorepo and what kind of error you had. If possible, send a link of your repo, or a screenshot of its structure.

- If you want a new feature, open an Issue and explain your real use case, the kind of problems you have nowadays and how you think Monolint could help you in practice.

## When creating a new rule

- Create the new rule under folder 'rules'
- Create unit tests for it based on test monorepo at 'rules/test-monorepo'
- Register the new rule in file 'rules/registry.ts'
- Add the rule as default in 'src/defaultConfig.ts' if it is a generic enough rule

## Prepare your development environment

- Install npm and "make" on your machine
- Git clone this repo
- Type `make run` to see a first run with success and errors examples
- Use preferrebly VSCode with ESLint plugin installed so linting with auto fix will be available

## Pipeline and Publishing to NPM

- Everytime a PR or a commit is made to "master" branch linting and building will be run. Your PR will only be analysed with a successfull GH pipeline run
- When a new tag is created a GH pipeline will publish a release to NPM registry
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Flavio Stutz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
SHELL := /bin/bash

build: install
rm -rf dist
pnpm exec esbuild src/index.ts --bundle --platform=node --minify --outfile=dist/index.js
pnpm exec tsc --emitDeclarationOnly --outDir dist

lint:
pnpm exec eslint . --ext .ts
pnpm exec tsc -noEmit --skipLibCheck
pnpm audit

test: unit-tests

unit-tests:
pnpm exec jest --verbose

clean:
rm -rf node_modules
rm -rf dist

all: build lint test

install:
corepack enable
pnpm install --frozen-lockfile --config.dedupe-peer-dependents=false

publish:
@if [ "$${NPM_ACCESS_TOKEN}" == "" ]; then \
echo "env NPM_ACCESS_TOKEN is required"; \
exit 1; \
fi

git config --global user.email "[email protected]"
git config --global user.name "Flávio Stutz"
npm version from-git --no-git-tag-version

echo "" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$${NPM_ACCESS_TOKEN}" >> .npmrc
pnpm publish --no-git-checks
Loading

0 comments on commit ad415fd

Please sign in to comment.