Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: YunYouJun
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm

- name: Install
run: pnpm install

- name: Lint
run: pnpm run lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm

- name: Install
run: pnpm install

- name: Typecheck
run: pnpm run typecheck

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [16.x, 18.x]
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
cache: pnpm

- run: pnpm install
- run: pnpm run test:unit
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ pnpm i
# compress
pnpm run squoosh
```

## Examples

See [examples](./examples/) for usage.
Empty file.
1 change: 1 addition & 0 deletions examples/zelda-weapons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export async function main() {
const oldPath = path.resolve(assetsFolder, file)
const newPath = path.resolve(distFolder, simplifyFileName(file))

// eslint-disable-next-line no-console
console.log(simplifyFileName(file), i)
return fs.copyFile(oldPath, newPath)
}))
Expand Down
3 changes: 2 additions & 1 deletion examples/zelda-weapons/src/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function main() {
})
})

await Promise.all(files.map(async (file, i) => {
await Promise.all(files.map(async (file, _i) => {
const filename = file.toLowerCase().replaceAll(' ', '-')
const includeItems: string[] = []
itemList.forEach((item) => {
Expand Down Expand Up @@ -79,6 +79,7 @@ export async function main() {
await compress()
imagePool.close()

// eslint-disable-next-line no-console
console.log(itemsSet)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/zelda-weapons/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getWeaponType(filename: string) {
return ''
}

const i = 0
// const i = 0
export function simplifyFileName(filename: string) {
// filename = filename.replace('sword,', '')

Expand Down
3 changes: 2 additions & 1 deletion examples/zelda-weapons/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { simplifyFileName } from '../src/utils'

describe('zelda-weapons', () => {
test('simplify filename', () => {
expect(simplifyFileName('61127-2530291012-[guitar_ice cream_0.5]sword, Battlefield and Sky Background, purism, ue 5, a computer reandering, octane render, wide shot, mini.png')).toBe('sword.guitar_ice-cream.png')
// expect(simplifyFileName('61127-2530291012-[guitar_ice cream_0.5]sword, Battlefield and Sky Background, purism, ue 5, a computer reandering, octane render, wide shot, mini.png')).toBe('sword.guitar_ice-cream.png')
expect(simplifyFileName('61127-2530291012-[guitar_ice cream_0.5]sword, Battlefield and Sky Background, purism, ue 5, a computer reandering, octane render, wide shot, mini.png')).toBe('guitar_ice-cream.png')
})
})
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "scripts",
"version": "1.0.0",
"packageManager": "pnpm@8.6.2",
"description": "",
"author": "",
"license": "MIT",
Expand All @@ -15,19 +16,19 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.5",
"@antfu/eslint-config": "^0.39.5",
"@types/fs-extra": "^11.0.1",
"@types/lodash": "^4.14.194",
"@types/node": "^20.0.0",
"@types/lodash": "^4.14.195",
"@types/node": "^20.3.1",
"chalk": "^5.2.0",
"consola": "^3.1.0",
"dotenv": "^16.0.3",
"eslint": "^8.39.0",
"dotenv": "^16.2.0",
"eslint": "^8.42.0",
"fs-extra": "^11.1.1",
"lodash": "^4.17.21",
"picocolors": "^1.0.0",
"tsx": "^3.12.7",
"typescript": "^5.0.4",
"vitest": "^0.31.0"
"typescript": "^5.1.3",
"vitest": "^0.32.0"
}
}
2 changes: 1 addition & 1 deletion packages/filename/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export function getKeyInfo(filename: string) {
export function getKeywords(filename: string) {
const info = getKeyInfo(filename)

const keywords = info.split('_').filter(i => isNaN(parseFloat(i)))
const keywords = info.split('_').filter(i => Number.isNaN(Number.parseFloat(i)))
return keywords.map(i => simplifyName(i)).sort()
}
Loading