Skip to content

Commit

Permalink
fix: changed find-cache-dir & read-pkg-up to @visulima alternative (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed Aug 6, 2024
1 parent 0ed69e4 commit 0da3949
Show file tree
Hide file tree
Showing 10 changed files with 1,104 additions and 648 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ body:
id: "environment-info"
attributes:
label: "Environment Info"
description: "Output of `npx envinfo --system --binaries --browsers --monorepos --npmPackages '{semantic-release*,@semantic-release/*}'`"
description: "Output of `npx envinfo --system --binaries --browsers --monorepos --npmPackages '{@anolilab/*,@visulima/*}'`"
render: "shell"
placeholder: |
System:
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. "$(dirname "$0")/../common.sh"
. "$(dirname "$0")/common.sh"

# The hook should exit with non-zero status after issuing
# an appropriate message if it wants to stop the commit.
Expand Down
2 changes: 1 addition & 1 deletion .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. "$(dirname "$0")/../common.sh"
. "$(dirname "$0")/common.sh"

# The hook should exit with non-zero status after issuing
# an appropriate message if it wants to stop the commit.
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. "$(dirname "$0")/../common.sh"
. "$(dirname "$0")/common.sh"

# The hook should exit with non-zero status after issuing
# an appropriate message if it wants to stop the commit.
Expand Down
2 changes: 1 addition & 1 deletion .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. "$(dirname "$0")/../common.sh"
. "$(dirname "$0")/common.sh"

echo --------------------------------------------
echo Starting Git hook: prepare-commit-msg
Expand Down
28 changes: 14 additions & 14 deletions __tests__/core/utils/oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { beforeEach, describe, expect, it, vi } from "vitest";

import Oracle from "../../../src/core/utils/oracle"; // You'll need a mocking library to mock the imports

const { readPackageUpSync } = vi.hoisted(() => {
return { readPackageUpSync: vi.fn() };
const { findPackageJsonSync } = vi.hoisted(() => {
return { findPackageJsonSync: vi.fn() };
});

vi.mock("read-pkg-up", async (importOriginal) => {
vi.mock("@visulima/package", async (importOriginal) => {
// eslint-disable-next-line @typescript-eslint/naming-convention,no-underscore-dangle,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment
const module_ = (await importOriginal()) as any;

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return {
...module_,
readPackageUpSync,
findPackageJsonSync,
};
});

Expand All @@ -26,7 +26,7 @@ describe("oracle", () => {
it("should guess app name from package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: { name: "my-app" } });
findPackageJsonSync.mockReturnValueOnce({ packageJson: { name: "my-app" } });

const oracle = new Oracle();
const result = oracle.guessAppName();
Expand All @@ -37,7 +37,7 @@ describe("oracle", () => {
it("should return undefined if no app name in package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: {} });
findPackageJsonSync.mockReturnValueOnce({ packageJson: {} });

const oracle = new Oracle();
const result = oracle.guessAppName();
Expand All @@ -48,7 +48,7 @@ describe("oracle", () => {
it("should guess description from package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: { description: "A sample app" } });
findPackageJsonSync.mockReturnValueOnce({ packageJson: { description: "A sample app" } });

const oracle = new Oracle();
const result = oracle.guessDescription();
Expand All @@ -59,7 +59,7 @@ describe("oracle", () => {
it("should return undefined if no description in package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: {} });
findPackageJsonSync.mockReturnValueOnce({ packageJson: {} });

const oracle = new Oracle();
const result = oracle.guessDescription();
Expand All @@ -70,7 +70,7 @@ describe("oracle", () => {
it("should guess developer from package.json when author is a string", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: { author: "John Doe <john@example.com> (http://example.com)" } });
findPackageJsonSync.mockReturnValueOnce({ packageJson: { author: "John Doe <john@example.com> (http://example.com)" } });

const oracle = new Oracle();
const result = oracle.guessDeveloper();
Expand All @@ -85,7 +85,7 @@ describe("oracle", () => {
it("should guess developer from package.json when author is an object", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: { author: { email: "john@example.com", name: "John Doe", url: "http://example.com" } } });
findPackageJsonSync.mockReturnValueOnce({ packageJson: { author: { email: "john@example.com", name: "John Doe", url: "http://example.com" } } });

const oracle = new Oracle();
const result = oracle.guessDeveloper();
Expand All @@ -100,7 +100,7 @@ describe("oracle", () => {
it("should guess developer from package.json when maintainers are present", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({
findPackageJsonSync.mockReturnValueOnce({
packageJson: { maintainers: [{ email: "jane@example.com", name: "Jane Doe", url: "http://example.com/jane" }] },
});

Expand All @@ -117,7 +117,7 @@ describe("oracle", () => {
it("should return undefined for developer if no author or maintainers in package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: {} });
findPackageJsonSync.mockReturnValueOnce({ packageJson: {} });

const oracle = new Oracle();
const result = oracle.guessDeveloper();
Expand All @@ -132,7 +132,7 @@ describe("oracle", () => {
it("should guess version from package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: { version: "1.0.0" } });
findPackageJsonSync.mockReturnValueOnce({ packageJson: { version: "1.0.0" } });

const oracle = new Oracle();
const result = oracle.guessVersion();
Expand All @@ -143,7 +143,7 @@ describe("oracle", () => {
it("should return undefined if no version in package.json", () => {
expect.assertions(1);

readPackageUpSync.mockReturnValueOnce({ packageJson: {} });
findPackageJsonSync.mockReturnValueOnce({ packageJson: {} });

const oracle = new Oracle();
const result = oracle.guessVersion();
Expand Down
40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@
"test:watch": "vitest"
},
"dependencies": {
"@visulima/find-cache-dir": "^1.0.5",
"@visulima/package": "^3.0.6",
"cacache": "^18.0.4",
"consola": "3.2.3",
"fast-json-stable-stringify": "^2.1.0",
"find-cache-dir": "^5.0.0",
"parse-author": "^2.0.0",
"parse5": "^7.1.2",
"read-pkg-up": "^10.1.0",
"ssri": "^10.0.6",
"unplugin": "^1.11.0"
"unplugin": "^1.12.0"
},
"devDependencies": {
"@anolilab/commitlint-config": "^5.0.3",
Expand All @@ -124,8 +124,8 @@
"@anolilab/prettier-config": "^5.0.14",
"@anolilab/semantic-release-preset": "^9.0.0",
"@anolilab/textlint-config": "^8.0.16",
"@babel/core": "^7.24.9",
"@babel/eslint-parser": "7.24.8",
"@babel/core": "^7.25.2",
"@babel/eslint-parser": "7.25.1",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@nuxt/kit": "^3.12.4",
Expand All @@ -138,16 +138,14 @@
"@tsconfig/node18": "^18.2.4",
"@tsconfig/strictest": "^2.0.5",
"@types/cacache": "^17.0.2",
"@types/find-cache-dir": "^3.2.1",
"@types/find-root": "^1.1.4",
"@types/node": "^20.14.11",
"@types/node": "^22.1.0",
"@types/parse-author": "^2.0.3",
"@types/parse5": "^6.0.3",
"@types/parse5": "^7.0.0",
"@types/ssri": "^7.1.5",
"@visulima/packem": "^1.0.0-alpha.55",
"@vitest/coverage-v8": "^2.0.4",
"@vitest/coverage-v8": "^2.0.5",
"audit-ci": "^7.1.0",
"caniuse-lite": "^1.0.30001643",
"caniuse-lite": "^1.0.30001649",
"commitizen": "^4.3.0",
"commitlint": "^19.3.0",
"conventional-changelog-conventionalcommits": "8.0.0",
Expand All @@ -159,28 +157,28 @@
"eslint-plugin-editorconfig": "^4.0.3",
"eslint-plugin-import": "npm:eslint-plugin-i@2.29.1",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-n": "^17.10.2",
"eslint-plugin-vitest": "0.4.1",
"eslint-plugin-vitest-globals": "^1.5.0",
"favicons": "^7.2.0",
"html-webpack-plugin": "^5.6.0",
"husky": "^9.1.1",
"husky": "^9.1.4",
"is-ci": "^3.0.1",
"lint-staged": "^15.2.7",
"pkg-pr-new": "^0.0.19",
"lint-staged": "^15.2.8",
"pkg-pr-new": "^0.0.20",
"prettier": "^3.3.3",
"publint": "^0.2.9",
"read-pkg": "9.0.1",
"rimraf": "^6.0.1",
"rollup": "^4.19.0",
"rollup": "^4.20.0",
"secretlint": "8.2.4",
"semantic-release": "^24.0.0",
"sort-package-json": "^2.10.0",
"textlint": "^14.0.4",
"type-fest": "^4.22.1",
"typescript": "^5.5.3",
"vite": "^5.3.4",
"vitest": "^2.0.4",
"type-fest": "^4.23.0",
"typescript": "^5.5.4",
"vite": "^5.3.5",
"vitest": "^2.0.5",
"webpack": "^5.93.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -216,7 +214,7 @@
"optional": true
}
},
"packageManager": "pnpm@9.5.0",
"packageManager": "pnpm@9.6.0",
"engines": {
"node": ">=18.0.0"
},
Expand Down
Loading

0 comments on commit 0da3949

Please sign in to comment.