Skip to content

Commit

Permalink
Rewrite using @typescript-nameof/nameof (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Feb 25, 2024
1 parent 24141a9 commit 042549b
Show file tree
Hide file tree
Showing 15 changed files with 1,089 additions and 1,145 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
const { defineConfig } = require('eslint-define-config');
const { readGitignoreFiles } = require('eslint-gitignore');

/// <reference types="@eslint-types/prettier" />
/// <reference types="@eslint-types/typescript-eslint" />

module.exports = defineConfig({
ignorePatterns: [
...readGitignoreFiles(),
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ assignees: ''

| Tool | Version |
| --------------------- | ----------------------- |
| vite-plugin-ts-nameof | v1.x.x |
| Vite | v2.x.x |
| vite-plugin-ts-nameof | v3.x.x |
| Vite | v5.x.x |
| Node | vx.x.x |
| OS | win,linux,mac |

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
name: 'Build: node-${{ matrix.node_version }}, ${{ matrix.os }}'
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
Expand All @@ -47,15 +47,15 @@ jobs:
runs-on: ubuntu-latest
name: 'Lint: node-20, ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3

- name: Set node version to 20
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
Expand All @@ -73,15 +73,15 @@ jobs:
runs-on: ubuntu-latest
name: 'Audit: node-20, ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3

- name: Set node version to 20
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
name: Release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v3

- name: Set node version to 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Prepare
run: pnpm install --frozen-lockfile

- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish
run: pnpm publish --access public --tag latest
6 changes: 3 additions & 3 deletions .prettierrc.cjs → .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @ts-check

/**
* @type {import('prettier').Options}
* @type {import('prettier').Config}
*/
module.exports = {
plugins: [require.resolve('prettier-plugin-organize-imports')],
export default {
plugins: ['prettier-plugin-organize-imports'],
singleQuote: true,
trailingComma: 'all',
overrides: [
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Next

[diff](https://github.com/Shinigami92/vite-plugin-ts-nameof/compare/2.0.0...main)
[diff](https://github.com/Shinigami92/vite-plugin-ts-nameof/compare/3.0.0...main)

# 3.0.0

[diff](https://github.com/Shinigami92/vite-plugin-ts-nameof/compare/2.0.0...3.0.0)

- Rewrite project to use [@typescript-nameof/nameof](https://github.com/typescript-nameof/nameof) ([#110])

[#110]: https://github.com/Shinigami92/vite-plugin-ts-nameof/pull/110

# 2.0.0

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 Christopher Quadflieg
Copyright (c) 2021-2024 Christopher Quadflieg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,19 @@
</p>

<p align="center">
Give <a href="https://github.com/vitejs/vite" target="_blank">Vite</a> the ability to resolve <a href="https://github.com/dsherret/ts-nameof" target="_blank">nameof</a> calls in TypeScript.
Give <a href="https://github.com/vitejs/vite" target="_blank">Vite</a> the ability to resolve <a href="https://github.com/typescript-nameof/nameof" target="_blank">nameof</a> calls in TypeScript.
</p>

## :warning: Warning :warning:

[Don't use `ts-nameof` anymore](https://github.com/dsherret/ts-nameof/issues/121)

Try to use [ts-keyof](https://www.npmjs.com/package/ts-keyof) instead.

This plugin will not work anymore with TypeScript v5+.
You will see errors like `ts.createliteral is not a function`.

## Usage

1. Install as `devDependencies`

```bash
npm add --save-dev vite-plugin-ts-nameof
npm add --save-dev vite-plugin-ts-nameof @typescript-nameof/types @typescript-nameof/common-types
# or
yarn add --dev vite-plugin-ts-nameof
pnpm add --save-dev vite-plugin-ts-nameof @typescript-nameof/types @typescript-nameof/common-types
# or
pnpm add --save-dev vite-plugin-ts-nameof
yarn add --dev vite-plugin-ts-nameof @typescript-nameof/types @typescript-nameof/common-types
```

2. Inject `vite-plugin-ts-nameof` using the `vite.config.ts` module
Expand All @@ -59,14 +50,14 @@ You will see errors like `ts.createliteral is not a function`.
});
```

3. Add `ts-nameof.d.ts` to your `tsconfig.json`
3. Add `@typescript-nameof/types/index.d.cts` to your `tsconfig.json`

```jsonc
{
// "compilerOptions"
// "include"
// ...
"files": ["./node_modules/ts-nameof/ts-nameof.d.ts"]
"files": ["./node_modules/@typescript-nameof/types/index.d.cts"],
}
```

Expand Down
12 changes: 7 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.3.4"
"vue": "^3.4.19"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"@vue/compiler-sfc": "^3.3.4",
"typescript": "~4.9.5",
"vite": "^4.3.9",
"@typescript-nameof/common-types": "~0.0.7",
"@typescript-nameof/types": "~0.0.7",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/compiler-sfc": "^3.4.19",
"typescript": "~5.3.3",
"vite": "^5.1.4",
"vite-plugin-ts-nameof": "link:../"
}
}
2 changes: 1 addition & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"types": ["vite/client"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"files": ["./node_modules/ts-nameof/ts-nameof.d.ts"]
"files": ["./node_modules/@typescript-nameof/types/index.d.cts"]
}
41 changes: 22 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-ts-nameof",
"version": "2.0.0",
"version": "3.0.0",
"description": "Give Vite the ability to resolve 'nameof' calls in TypeScript",
"scripts": {
"clean": "rimraf .eslintcache dist pnpm-lock.yaml node_modules",
Expand Down Expand Up @@ -50,30 +50,33 @@
"tsconfig.json"
],
"dependencies": {
"ts-nameof": "^5.0.0"
"@typescript-nameof/nameof": "~0.0.7"
},
"devDependencies": {
"@types/node": "~20.3.1",
"@types/prettier": "~2.7.3",
"@typescript-eslint/eslint-plugin": "~5.59.11",
"@typescript-eslint/parser": "~5.59.11",
"eslint": "~8.42.0",
"eslint-config-prettier": "~8.8.0",
"eslint-define-config": "~1.20.0",
"@eslint-types/prettier": "~5.1.3",
"@eslint-types/typescript-eslint": "~6.21.0",
"@types/node": "~20.11.20",
"@typescript-eslint/eslint-plugin": "~7.0.2",
"@typescript-eslint/parser": "~7.0.2",
"eslint": "~8.57.0",
"eslint-config-prettier": "~9.1.0",
"eslint-define-config": "~2.1.0",
"eslint-gitignore": "~0.1.0",
"eslint-plugin-prettier": "~4.2.1",
"npm-run-all": "~4.1.5",
"prettier": "2.8.8",
"prettier-plugin-organize-imports": "~3.2.2",
"rimraf": "~5.0.1",
"tsup": "~7.0.0",
"typescript": "~4.9.5",
"vite": "~4.3.9"
"eslint-plugin-prettier": "~5.1.3",
"npm-run-all2": "~6.1.2",
"prettier": "3.2.5",
"prettier-plugin-organize-imports": "~3.2.4",
"rimraf": "~5.0.5",
"tsup": "~8.0.2",
"typescript": "~5.3.3",
"vite": "~5.1.4"
},
"peerDependencies": {
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0"
"@typescript-nameof/common-types": "^0.0.7",
"@typescript-nameof/types": "^0.0.7",
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
},
"packageManager": "pnpm@8.6.2",
"packageManager": "pnpm@8.15.4",
"engines": {
"node": "^16.13.0 || >=18.0.0",
"npm": ">=7.0.0",
Expand Down

0 comments on commit 042549b

Please sign in to comment.