Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-alpha.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Apr 15, 2024
2 parents 736e9ff + 33afecd commit 9a06b42
Show file tree
Hide file tree
Showing 16 changed files with 1,934 additions and 1,583 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.js

This file was deleted.

40 changes: 35 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,48 @@ on:
- '*.*.*'

jobs:
publish:
runs-on: ubuntu-latest
release:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: JS-DevTools/npm-publish@v3
- uses: actions/setup-node@v4
with:
token: ${{ secrets.NPM_TOKEN }}
- uses: actions/create-release@v1
node-version: 20
cache: npm
registry-url: https://registry.npmjs.org/

- run: |
VERSION=${GITHUB_REF/refs\/tags\//}
TAG='latest'
if [[ $VERSION =~ 'alpha' || $VERSION =~ 'beta' || $VERSION =~ 'rc' ]]; then
TAG='next'
fi
npm publish --tag $TAG
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
# @see https://github.com/actions/create-release/issues/38#issuecomment-715327220
# @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
- name: Prepare the changelog from the tag message
id: prepare_changelog
run: |
PRERELEASE=false
# Check release type
if [[ $GITHUB_REF_NAME =~ 'alpha' || $GITHUB_REF_NAME =~ 'beta' || $GITHUB_REF_NAME =~ 'rc' ]]; then
echo "This is a prerelease."
PRERELEASE=true
fi
echo "is_prerelease=$PRERELEASE" >> $GITHUB_ENV
# @see https://github.com/actions/create-release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: v${{ github.ref_name }}
body: Please refer to [CHANGELOG.md](https://github.com/studiometa/prettier-formatter-gitlab/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
draft: false
prerelease: ${{ env.is_prerelease }}
4 changes: 3 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = require('@studiometa/prettier-config');
import config from '@studiometa/prettier-config';

export default config;
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## v2.0.0-alpha.0 - 2024.04.15

### Changed

- Add support for Prettier v3 ([#2](https://github.com/studiometa/prettier-formatter-gitlab/pull/2))
- ⚠️ Remove support for Prettier v2 ([#2](https://github.com/studiometa/prettier-formatter-gitlab/pull/2))
- ⚠️ Migrate to ESM ([165f52c](https://github.com/studiometa/prettier-formatter-gitlab/commit/165f52c))

## v1.1.4 - 2024.03.12

### Fixed
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Prettier formatter for GitLab Code Quality

[![NPM Version](https://img.shields.io/npm/v/@studiometa/prettier-formatter-gitlab.svg?style=flat-square)](https://www.npmjs.com/package/@studiometa/prettier-formatter-gitlab/)
[![Dependency Status](https://img.shields.io/david/studiometa/prettier-formatter-gitlab.svg?label=deps&style=flat-square)](https://david-dm.org/studiometa/prettier-formatter-gitlab)
[![devDependency Status](https://img.shields.io/david/dev/studiometa/prettier-formatter-gitlab.svg?label=devDeps&style=flat-square)](https://david-dm.org/studiometa/prettier-formatter-gitlab?type=dev)

> Send Prettier errors to Gitlab's Code Quality reports.
Expand All @@ -19,18 +17,18 @@ npm install -D @studiometa/prettier-formatter-gitlab
Prettier does not have an option for custom reporter, this package will run a prettier CLI command for you and parse its result to generate the Code Quality report.

```js
prettier-formatter-gitlab 'prettier -c src/'
prettier-formatter-gitlab 'prettier -l src/'
```

The report file path will be read from the `PRETTIER_CODE_QUALITY_REPORT` environment variable or from the `.gitlab-ci.yml` configuration file when using the code quality report artifacts:

```yaml
# .gitlab-ci.yml
eslint:
image: node:12
image: node:20
script:
- npm ci
- prettier-formatter-gitlab 'prettier -c src/'
- prettier-formatter-gitlab 'prettier -l src/'
artifacts:
reports:
codequality: gl-codequality.json
Expand Down
22 changes: 12 additions & 10 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env node
const { exec } = require('child_process');
const prettierFormatterGitlab = require('../src/index.js');
import { exec } from 'node:child_process';
import { prettierFormatterGitLab } from '../src/index.js';

const [, , cmd] = process.argv;
const cmd = process.argv[2];

exec(cmd, async (error) => {
if (error) {
console.log(error.message);
await prettierFormatterGitlab(error);
process.exit(1);
}
});
if (cmd) {
exec(cmd, async (error, stdout) => {
if (error) {
console.log(error.message);
await prettierFormatterGitLab(stdout);
process.exit(1);
}
});
}
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { js, prettier } from '@studiometa/eslint-config';
import { globals } from '@studiometa/eslint-config/utils';

export default [
...js,
...prettier,
{
languageOptions: {
globals: globals.node,
},
},
];
Loading

0 comments on commit 9a06b42

Please sign in to comment.