Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add knip #228

Merged
merged 5 commits into from
Oct 14, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/rude-geckos-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@manypkg/cli": minor
---

Remove the `find-up` dependency.
29 changes: 23 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set Node.js 16.x
- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x

- name: Install Dependencies
run: yarn
Expand All @@ -30,10 +30,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set Node.js 16.x
- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x

- name: Install Dependencies
run: yarn
Expand All @@ -47,13 +47,30 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set Node.js 16.x
- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x

- name: Install Dependencies
run: yarn

- name: Check Formatting
run: yarn format:check

knip:
name: Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Dependencies
run: yarn

- name: Check Knip
run: yarn knip
10 changes: 10 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignoreWorkspaces": ["test-gatsby", "packages/gatsby-source-workspace"],
"workspaces": {
".": {
"ignoreBinaries": ["gatsby", "manypkg"]
}
},
"ignore": ["__fixtures__/**"]
}
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"format": "prettier --write .",
"format:check": "prettier --check .",
"postinstall": "preconstruct dev && manypkg check",
"knip": "knip",
"release": "preconstruct build && changeset publish",
"test": "jest",
"test-gatsby": "cd test-gatsby && gatsby develop"
Expand All @@ -29,21 +30,18 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@preconstruct/cli": "^2.2.2",
"@types/fs-extra": "^8.0.1",
"@types/jest": "^29.2.4",
"@types/normalize-path": "^3.0.0",
"@types/parse-github-url": "^1.0.0",
"@types/semver": "^6.0.1",
"jest": "^29.3.1",
"jest-watch-typeahead": "^2.2.1",
"knip": "^5.33.3",
"prettier": "^2.8.1",
"prettier-plugin-packagejson": "^2.3.0",
"typescript": "^5.3.2"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
"engines": {
"node": ">=14.18.0"
},
"preconstruct": {
"packages": [
"packages/!(gatsby)*"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@manypkg/get-packages": "^2.2.1",
"chalk": "^2.4.2",
"detect-indent": "^6.0.0",
"find-up": "^4.1.0",
"normalize-path": "^3.0.0",
"p-limit": "^2.2.1",
"package-json": "^8.1.0",
Expand All @@ -27,6 +26,7 @@
"validate-npm-package-name": "^3.0.0"
},
"devDependencies": {
"@changesets/types": "^5.2.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we depend on this? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { PackageJSON } from "@changesets/types";

"fixturez": "^1.1.0",
"strip-ansi": "^6.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/checks/WORKSPACE_REQUIRED.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeCheck, NORMAL_DEPENDENCY_TYPES } from "./utils";
import { Package } from "@manypkg/get-packages";

export type ErrorType = {
type ErrorType = {
type: "WORKSPACE_REQUIRED";
workspace: Package;
depType: typeof NORMAL_DEPENDENCY_TYPES[number];
Expand Down
6 changes: 0 additions & 6 deletions packages/cli/src/checks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ type AllCheckWithFix<ErrorType> = {
print: (error: ErrorType, options: Options) => string;
};

export type Check<ErrorType> =
| RootCheck<ErrorType>
| AllCheck<ErrorType>
| RootCheckWithFix<ErrorType>
| AllCheckWithFix<ErrorType>;

export function sortObject(prevObj: { [key: string]: string }) {
let newObj: { [key: string]: string } = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from "chalk";
import util from "util";

export function format(
function format(
args: Array<any>,
messageType: "error" | "success" | "info",
scope?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/npm-tag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getPackages } from "@manypkg/get-packages";
import { PackageJSON } from "@changesets/types";
import type { PackageJSON } from "@changesets/types";
import spawn from "spawndamnit";
import pLimit from "p-limit";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function upgradeDependency([name, tag = "latest"]: string[]) {

const npmRequestLimit = pLimit(40);

export function getPackageInfo(pkgName: string) {
function getPackageInfo(pkgName: string) {
return npmRequestLimit(async () => {
const getPackageJson = (await import("package-json")).default;

Expand Down
2 changes: 1 addition & 1 deletion packages/get-packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@manypkg/tools": "^1.1.1"
},
"devDependencies": {
"jest-fixtures": "^0.6.0"
"fixturez": "^1.1.0"
},
"engines": {
"node": ">=14.18.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
},
"devDependencies": {
"@types/jju": "^1.4.2",
"@types/js-yaml": "^4.0.9",
"jest-fixtures": "^0.6.0"
"@types/js-yaml": "^4.0.9"
},
"engines": {
"node": ">=14.18.0"
Expand Down
4 changes: 0 additions & 4 deletions packages/tools/src/PnpmTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ function readYamlFileSync<T = unknown>(path: string): T {
return yaml.load(fs.readFileSync(path, "utf8")) as T;
}

export interface PnpmWorkspaceYaml {
packages?: string[];
}

export const PnpmTool: Tool = {
type: "pnpm",

Expand Down
Loading
Loading