Skip to content

Commit

Permalink
feat: defineConfig wrapper & import sorting (#14)
Browse files Browse the repository at this point in the history
* chore: compile from typescript

* chore: initialize changesets

* chore: pin dependencies

* chore: only include relevant files in bundle

* ci: add publish workflow

* docs: improve documentation

* feat: configure import order

* feat: allow extending config

* fix: build before testing
  • Loading branch information
nyarthan committed Nov 2, 2023
1 parent 24f537e commit 66ee7b7
Show file tree
Hide file tree
Showing 19 changed files with 3,112 additions and 167 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
6 changes: 6 additions & 0 deletions .changeset/flat-walls-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@titanom/prettier-config": major
---

- import order configuration
- `defineConfig` wrapper
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
pnpm-version: 8

- name: 📄 Format arbitrary file
run: touch stub.js && pnpm exec prettier -c stub.js
run: pnpm build && touch stub.js && pnpm exec prettier -c stub.js
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish

on:
push:
branches:
- master
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
check:
name: Format, Build, Publish
runs-on: ubuntu-latest
steps:
- uses: titanom/github-composite-actions/turbo/[email protected]
with:
pnpm-version: 8

- name: Format
run: pnpm format:check

- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
publish: pnpm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*

!README.md
!package.json
!dist/*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
save-prefix=''
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# @titanom/prettier-config

Default [Prettier](https://prettier.io) config for projects at [Titanom Technologies](https://titanom.com)
[Prettier](https://prettier.io) config for projects at [Titanom Technologies](https://titanom.com)

## Installation

```sh
# npm
npm i -D @titanom/prettier-config

# yarn
yarn add -D @titanom/prettier-config

# pnpm
pnpm add -D @titanom/prettier-config
```

## Usage
## Configuration

CommonJS

```js
// .prettierrc.cjs
module.exports = require('@titanom/prettier-config');
const defineConfig = require('@titanom/prettier-config');

module.exports = defineConfig({
// ... options
});
```

Or if you want to change the config:
ES Modules

```js
// .prettierrc.cjs
module.exports = {
...requre('@titanom/prettier-config'),
// your config here
}
// prettier.config.mjs
import defineConfig from '@titanom/prettier-config';

export default defineConfig({
// ... options
});
```
119 changes: 0 additions & 119 deletions index.js

This file was deleted.

27 changes: 23 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,38 @@
"url": "https://github.com/titanom/prettier-config/issues"
},
"homepage": "https://github.com/titanom/prettier-config#readme",
"type": "commonjs",
"scripts": {
"format": "prettier --write ."
"format": "pnpm build && prettier --write .",
"format:check": "pnpm build && prettier --check .",
"build": "tsup && fix-tsup-cjs",
"release": "pnpm build && changeset publish"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"main": "index.js",
"devDependencies": {
"prettier": "^3.0.0"
"@changesets/cli": "2.26.2",
"@titanom/tsconfig": "0.2.0",
"@types/node": "20.8.10",
"fix-tsup-cjs": "1.2.0",
"prettier": "3.0.3",
"tsup": "7.2.0",
"typescript": "5.2.2"
},
"peerDependencies": {
"prettier": "^2.x.x || ^3.0.0"
},
"engines": {
"node": ">=16",
"pnpm": ">=7"
},
"dependencies": {
"@ianvs/prettier-plugin-sort-imports": "4.1.1"
}
}
Loading

0 comments on commit 66ee7b7

Please sign in to comment.