-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ecc8a0b
Showing
19 changed files
with
4,303 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
((nil . | ||
((eval . | ||
(add-to-list 'exec-path | ||
(concat (locate-dominating-file default-directory dir-locals-file) | ||
"node_modules/.bin/")))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*.ts] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.json] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[README.md] | ||
max_line_length = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @xuhdev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
# fee is hereby granted. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
# AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
# DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
# OF THIS SOFTWARE. | ||
|
||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
pull_request: | ||
branches: ["master"] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [22.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "npm" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
npm install | ||
- name: Lint | ||
run: | | ||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
# fee is hereby granted. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
# AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
# DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
# OF THIS SOFTWARE. | ||
# | ||
|
||
name: Publish Dry Run | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
pull_request: | ||
branches: ["master"] | ||
|
||
jobs: | ||
run: | ||
name: Publish Dry Run | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "22.x" | ||
- run: npm ci | ||
- run: npm publish --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
# fee is hereby granted. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
# AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
# DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
# OF THIS SOFTWARE. | ||
|
||
name: Publish to npmjs | ||
|
||
on: | ||
push: | ||
tags: ["v*"] | ||
jobs: | ||
run: | ||
name: Publish to npmjs | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# Setup .npmrc file to publish to npm | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "22.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
# | ||
# Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
# fee is hereby granted. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
# AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
# DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
# OF THIS SOFTWARE. | ||
|
||
name: Runtime | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
pull_request: | ||
branches: ["master"] | ||
|
||
jobs: | ||
test: | ||
name: Runtime | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x, 22.x] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
exclude: | ||
# Only test Node 22 on Windows and MacOS | ||
- os: macos-latest | ||
node-version: 18.x | ||
- os: macos-latest | ||
node-version: 20.x | ||
- os: windows-latest | ||
node-version: 18.x | ||
- os: windows-latest | ||
node-version: 20.x | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "npm" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
npm install | ||
- name: Test | ||
run: | | ||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/*.tgz | ||
/coverage | ||
/dist | ||
/docs | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
|
||
Permission to use, copy, modify, and/or distribute this software for anypurpose with or without fee | ||
is hereby granted. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS SOFTWARE | ||
INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE | ||
LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGESWHATSOEVER RESULTING | ||
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | ||
ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# vite-year-plugin | ||
|
||
[![npm version](https://badge.fury.io/js/@8hobbies%2Fvite-year-plugin.svg)](https://badge.fury.io/js/@8hobbies%2Fvite-year-plugin) | ||
|
||
[GitLab](https://gitlab.com/8hobbies/vite-year-plugin) | [GitHub](https://github.com/8hobbies/vite-year-plugin) | ||
|
||
A [Vite][] plugin that inserts the current year to the html file during build. Useful for adding a copyright year. | ||
|
||
## Usage | ||
|
||
Install with | ||
|
||
```sh | ||
npm install --save-dev '@8hobbies/vite-year-plugin' | ||
``` | ||
|
||
In `vite.config.ts`, add: | ||
|
||
```typescript | ||
import yearPlugin from "@8hobbies/vite-year-plugin"; | ||
|
||
// ... | ||
|
||
export default defineConfig({ | ||
// ... | ||
|
||
plugins: [ | ||
// ... | ||
yearPlugin(), | ||
], | ||
}); | ||
``` | ||
|
||
## Contributing | ||
|
||
Source code is available on [GitHub][source code]. | ||
|
||
To report a bug, visit the [issue tracker][]. | ||
|
||
To run test, run `npm run test`. To build for production, run `npm pack`. | ||
|
||
To send your contribution, open a [pull request][]. | ||
|
||
## License | ||
|
||
``` | ||
Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
OF THIS SOFTWARE. | ||
``` | ||
|
||
[Vite]: https://vite.dev | ||
[issue tracker]: https://github.com/8hobbies/vite-year-plugin/issues | ||
[merge request]: https://github.com/8hobbies/vite-year-plugin/pulls | ||
[source code]: https://github.com/8hobbies/vite-year-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** @license 0BSD | ||
* Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
* fee is hereby granted. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
* SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
* AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
* DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
* OF THIS SOFTWARE. | ||
*/ | ||
|
||
import configs from "@8hobbies/eslint-conf-baseline"; | ||
import globals from "globals"; | ||
|
||
export default [ | ||
...configs.recommended, | ||
{ | ||
files: ["**/*.ts"], | ||
ignores: configs.ignores, | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
parserOptions: { | ||
project: ["tsconfig.json", "tsconfig.test.json"], | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** @license 0BSD | ||
* Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
* fee is hereby granted. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
* SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
* AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
* DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
* OF THIS SOFTWARE. | ||
*/ | ||
|
||
import yearPlugin from "./index.ts"; | ||
|
||
test("With __YEAR__", () => { | ||
const input = "<p>__YEAR__ is here.</p>" as const; | ||
const expected = | ||
`<p>${new Date().getFullYear().toString()} is here.</p>` as const; | ||
expect(yearPlugin().transformIndexHtml(input)).toBe(expected); | ||
}); | ||
|
||
test("Without __YEAR__", () => { | ||
const input = "<p>No __YEAR_ present.</p>" as const; | ||
const expected = input; | ||
expect(yearPlugin().transformIndexHtml(input)).toBe(expected); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** @license 0BSD | ||
* Copyright (C) 2024 8 Hobbies, LLC <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for anypurpose with or without | ||
* fee is hereby granted. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS | ||
* SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
* AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | ||
* DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, | ||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
* OF THIS SOFTWARE. | ||
*/ | ||
|
||
/** | ||
* The year plugin. Add it to the list of plugins in vite.config.ts. See README. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
export default function yearPlugin() { | ||
return { | ||
name: "year", | ||
transformIndexHtml(html: string): string { | ||
return html.replace("__YEAR__", new Date().getFullYear().toString()); | ||
}, | ||
} as const; | ||
} |
Oops, something went wrong.