-
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.
feat: initial release of @noahnu/unused-files (#1)
- Loading branch information
Showing
25 changed files
with
1,011 additions
and
111 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
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,67 @@ | ||
--- | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
prepare: | ||
name: Prepare | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
steps: | ||
- uses: noahnu/.github/.github/actions/setup-node@main | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
needs: [prepare] | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
steps: | ||
- uses: noahnu/.github/.github/actions/setup-node@main | ||
|
||
- name: Run Lint | ||
run: | | ||
yarn lint:ci | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
needs: [prepare] | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
steps: | ||
- uses: noahnu/.github/.github/actions/setup-node@main | ||
|
||
- name: Run Build | ||
run: | | ||
yarn build | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: [prepare] | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
steps: | ||
- uses: noahnu/.github/.github/actions/setup-node@main | ||
|
||
- name: Run Test | ||
run: | | ||
yarn test | ||
preview: | ||
name: Preview | ||
runs-on: ubuntu-latest | ||
needs: [prepare] | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- uses: noahnu/.github/.github/actions/setup-node@main | ||
|
||
- name: Post Monodeploy Preview | ||
uses: noahnu/.github/.github/actions/post-monodeploy-preview@main | ||
with: | ||
token: ${{ secrets.GITHUB_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,26 @@ | ||
--- | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: noahnu/.github/.github/actions/setup-node@main | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Publish | ||
if: github.ref == 'refs/heads/main' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | ||
run: | | ||
yarn release |
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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
--- | ||
nodeLinker: pnp | ||
npmRegistries: | ||
//registry.npmjs.org/: | ||
npmAuthToken: "${NPM_PUBLISH_TOKEN:-invalid}" |
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
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,19 @@ | ||
// @ts-check | ||
|
||
/** @type {import('@monodeploy/types').RecursivePartial<import('@monodeploy/types').MonodeployConfiguration>} */ | ||
const config = { | ||
conventionalChangelogConfig: '@tophat/conventional-changelog-config', | ||
maxConcurrentWrites: 1, | ||
changelogFilename: '<packageDir>/CHANGELOG.md', | ||
autoCommit: true, | ||
autoCommitMessage: 'chore: release [skip ci]', | ||
git: { | ||
push: true, | ||
tag: true, | ||
}, | ||
persistVersions: true, | ||
changesetIgnorePatterns: ['**/*.test.ts'], | ||
commitIgnorePatterns: ['\\[skip-ci\\]'], | ||
} | ||
|
||
module.exports = config |
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
Empty file.
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,20 @@ | ||
{ | ||
"name": "@noahnu/internal-test-utils", | ||
"private": true, | ||
"version": "0.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/noahnu/nodejs-tools.git", | ||
"directory": "packages/internal-test-utils" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "noahnu", | ||
"email": "[email protected]", | ||
"url": "https://noahnu.com" | ||
}, | ||
"main": "./src/index.ts", | ||
"devDependencies": { | ||
"@types/node": "^20.9.0" | ||
} | ||
} |
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,31 @@ | ||
import fs from 'node:fs' | ||
import os from 'node:os' | ||
import path from 'node:path' | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error | ||
Symbol.asyncDispose ??= Symbol.for('asyncDispose') | ||
|
||
export type TempDirContext = { | ||
dir: string | ||
writeFile: (name: string, contents: string) => Promise<string> | ||
} | ||
|
||
export async function createTempDir(): Promise<TempDirContext & AsyncDisposable> { | ||
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'nodejs-tools-')) | ||
|
||
return { | ||
dir, | ||
async writeFile(name: string, contents: string) { | ||
const filename = path.join(dir, name) | ||
await fs.promises.mkdir(path.dirname(filename), { recursive: true }) | ||
await fs.promises.writeFile(filename, contents, { encoding: 'utf-8' }) | ||
return filename | ||
}, | ||
async [Symbol.asyncDispose]() { | ||
try { | ||
await fs.promises.rm(dir, { recursive: true }) | ||
} catch {} | ||
}, | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"declarationDir": "./lib", | ||
"outDir": "./lib" | ||
}, | ||
"include": ["./src"], | ||
} |
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,7 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"emitDeclarationOnly": false | ||
} | ||
} |
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 @@ | ||
# @noahnu/unused-files | ||
|
||
## Usage | ||
|
||
```sh | ||
DEBUG=unused-files yarn dlx @noahnu/unused-files --entry src/index.ts --ignore '**/node_modules' --ignore '**/dist' --deppth 10 ./src | ||
``` | ||
|
||
Or use the Node API: | ||
|
||
```ts | ||
import { findUnusedFiles } from '@noahnu/unused-files' | ||
|
||
const result = await findUnusedFiles({ | ||
entryFiles: ['src/index.ts'], | ||
|
||
// optional | ||
sourceDirectories: [process.cwd()], | ||
ignorePatterns: ['**/node_modules'], | ||
aliases: { | ||
'@my/alias': 'path/to/file/index.ts', | ||
}, | ||
depth: 10, | ||
}) | ||
|
||
console.log(result.unusedFiles.join('\n')) | ||
``` | ||
|
||
## Development | ||
|
||
```sh | ||
yarn workspace @noahnu/unused-files run-local | ||
``` |
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 @@ | ||
{ | ||
"name": "@noahnu/unused-files", | ||
"version": "0.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/noahnu/nodejs-tools.git", | ||
"directory": "packages/unused-files" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "noahnu", | ||
"email": "[email protected]", | ||
"url": "https://noahnu.com" | ||
}, | ||
"scripts": { | ||
"clean": "run workspace:clean \"$(pwd)\"", | ||
"prepack": "run workspace:build \"$(pwd)\"", | ||
"run-local": "run -T ts-node --transpileOnly ./src/bin.ts" | ||
}, | ||
"bin": "./src/bin.ts", | ||
"main": "./src/api/index.ts", | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/", | ||
"access": "public", | ||
"bin": "./lib/bin.js", | ||
"main": "./lib/api/index.js", | ||
"types": "./lib/api/index.d.ts" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"dependencies": { | ||
"@types/debug": "^4.1.12", | ||
"@typescript-eslint/typescript-estree": "^6.18.1", | ||
"clipanion": "4.0.0-rc.2", | ||
"debug": "^4.3.4", | ||
"fast-glob": "^3.3.2", | ||
"typanion": "^3.14.0" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "^29.7.0", | ||
"@noahnu/internal-test-utils": "workspace:*", | ||
"@types/node": "^20.9.0" | ||
} | ||
} |
Oops, something went wrong.