Skip to content

Commit

Permalink
chore: enforce npm usage (#578)
Browse files Browse the repository at this point in the history
* chore: use corepack to force npm

* chore: forbid non-npm lockfiles

* chore: pnpm lockfile

* chore: readme
  • Loading branch information
louis-bompart committed Nov 29, 2022
1 parent 4bc3b3d commit 4488834
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8,096 deletions.
21 changes: 21 additions & 0 deletions .github/actions/lockfiles/action.yml
@@ -0,0 +1,21 @@
name: 'Lockfile'
description: 'Forbid non-npm lockfiles'
runs:
using: composite
steps:
- name: Check lockfiles
uses: actions/github-script@v6
with:
script: |
const {existsSync} = require('fs');
['yarn.lock', 'pnpm-lock.yaml'].forEach(forbiddenLockFile => {
if(existsSync(forbiddenLockFile)) {
const error = `Lockfile ${forbiddenLockFile} is not allowed in this repo, remove it.`;
core.error(
error,
{title: 'Forbidden lockfile', file: forbiddenLockFile}
);
process.exitCode=1
}
});
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -15,6 +15,8 @@ jobs:
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
- name: Setup
uses: ./.github/actions/setup
- name: Check lockfiles
uses: ./.github/actions/lockfiles
- name: Tests
run: npm test
- name: Build
Expand Down
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,24 @@
# Contributing

## Requirements

- Node LTS
- NPM

> Tip: This repo support `corepack`. Just enable it `corepack enable` and this repo will warn you if you try to use another package manager.
## Guidelines

- Make sure your changes are fully tested (when applicable).
- We tend to avoid comments in our code base, we strongly prefer good naming and code structure.
- Avoid pushing similar changes in different commits if it's within the same feature, because we want the changelogs to be clear and simple. To avoid that, there are at least 2 options:
1. Squash the commits into one when merging (you need to edit the final commit message though)
1. amend the previous commit when making related changes (`git commit --amend --no-edit`)

## Commit messages

**Every commit message must comply with the [Angular Commit Message Conventions](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) specification. We use the commit messages to automatically bump the package version according to the semantic versionning notation. Moreover, we generate changlogs for each version using those commit messages.**

- You can either manually write a commit message that follows the convention using your favorite method.
- Or you can run `npm run commit-cli`. It will prompt you some questions about the nature of your changes, then it will commit your staged changes along with a generated message that follows our convention.
- Commits containing breaking changes need to be marked as such in the commit footer. See [BREAKING CHANGE convention](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-footer).
16 changes: 1 addition & 15 deletions README.md
Expand Up @@ -263,18 +263,4 @@ ExperimentalPlatformClient.something.list();

## Contributing

### Guidelines

- Make sure your changes are fully tested (when applicable).
- We tend to avoid comments in our code base, we strongly prefer good naming and code structure.
- Avoid pushing similar changes in different commits if it's within the same feature, because we want the changelogs to be clear and simple. To avoid that, there are at least 2 options:
1. Squash the commits into one when merging (you need to edit the final commit message though)
1. amend the previous commit when making related changes (`git commit --amend --no-edit`)

### Commit messages

**Every commit message must comply with the [Angular Commit Message Conventions](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) specification. We use the commit messages to automatically bump the package version according to the semantic versionning notation. Moreover, we generate changlogs for each version using those commit messages.**

- You can either manually write a commit message that follows the convention using your favorite method.
- Or you can run `npm run commit-cli`. It will prompt you some questions about the nature of your changes, then it will commit your staged changes along with a generated message that follows our convention.
- Commits containing breaking changes need to be marked as such in the commit footer. See [BREAKING CHANGE convention](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-footer).
See [CONTRIBUTING.md](./CONTRIBUTING.md)
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -80,5 +80,6 @@
},
"publishConfig": {
"access": "public"
}
},
"packageManager": "npm@latest"
}

0 comments on commit 4488834

Please sign in to comment.