Skip to content

Commit 5780bbf

Browse files
authored
Fix CI checks (#3)
* Fix TS issues * fix knip * fix tests
1 parent ea5c0aa commit 5780bbf

23 files changed

+61
-46
lines changed

knip.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"ignoreWorkspaces": ["test-gatsby", "packages/gatsby-source-workspace"],
44
"workspaces": {
55
".": {
6-
"ignoreBinaries": ["gatsby", "manypkg"]
6+
"ignoreBinaries": ["gatsby", "packages/cli/bin.js"]
77
}
88
},
99
"ignore": ["__fixtures__/**"]

packages/cli/src/checks/__tests__/EXTERNAL_MISMATCH.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import internalMismatch from "../EXTERNAL_MISMATCH";
2-
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
1+
import internalMismatch from "../EXTERNAL_MISMATCH.ts";
2+
import { getWS, getFakeWS, getRootWS } from "../../test-helpers.ts";
33

44
let rootWorkspace = getRootWS();
55

packages/cli/src/checks/__tests__/INCORRECT_REPOSITORY_FIELD.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import path from "path";
2-
import check from "../INCORRECT_REPOSITORY_FIELD";
3-
import { getWS, getFakeWS, getFakeString, getRootWS } from "../../test-helpers";
1+
import {
2+
getFakeString,
3+
getFakeWS,
4+
getRootWS,
5+
getWS,
6+
} from "../../test-helpers.ts";
7+
import check from "../INCORRECT_REPOSITORY_FIELD.ts";
48

59
describe("incorrect repository field", () => {
610
describe("github", () => {

packages/cli/src/checks/__tests__/INTERNAL_MISMATCH.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import makeCheck, { ErrorType } from "../INTERNAL_MISMATCH";
2-
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
1+
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
2+
import makeCheck, { ErrorType } from "../INTERNAL_MISMATCH.ts";
33

44
let rootWorkspace = getRootWS();
55

packages/cli/src/checks/__tests__/INVALID_DEV_AND_PEER_DEPENDENCY.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import makeCheck from "../INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP";
2-
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
1+
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
2+
import makeCheck from "../INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP.ts";
33

44
let rootWorkspace = getRootWS();
55

packages/cli/src/checks/__tests__/WORKSPACE_REQUIRED.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
2-
import makeCheck from "../WORKSPACE_REQUIRED";
1+
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
2+
import makeCheck from "../WORKSPACE_REQUIRED.ts";
33
let rootWorkspace = getRootWS();
44

55
test("should not error if not using workspaceProtocol: require", () => {

packages/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from "path";
1+
import path from "node:path";
22
import * as logger from "./logger.ts";
33
import {
44
getPackages,

packages/cli/src/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pc from "picocolors";
2-
import util from "util";
2+
import util from "node:util";
33

44
function format(
55
args: Array<any>,

packages/cli/src/run.test.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { runCmd } from "./run";
21
import fixturez from "fixturez";
3-
import { exec } from "tinyexec";
42
import stripAnsi from "strip-ansi";
3+
import { exec } from "tinyexec";
54

65
const f = fixturez(__dirname);
76

7+
function stripNodeWarnings(str: string) {
8+
return str
9+
.replace(/^\(node:\d+\) ExperimentalWarning:.+(\r?\n)?/gm, "")
10+
.replace(/^\(Use \`node --trace-warnings \.\.\.\`.+(\r?\n)?/gm, "");
11+
}
12+
813
describe("Run command", () => {
914
it.each([
1015
["package-one", "start", 0],
@@ -19,21 +24,27 @@ describe("Run command", () => {
1924
["pkg-two", "start", 1],
2025
["@manypkg/basic-fixture-pkg-two", "start", 0],
2126
["pkg-two-one", "start", 0],
22-
// @ts-ignore
2327
])(
2428
'should execute "%s %s" and exit with %i',
2529
async (arg0, arg1, expectedExitCode) => {
2630
const { exitCode, stdout, stderr } = await exec(
27-
require.resolve("../bin"),
28-
// @ts-ignore
29-
["run", arg0, arg1],
31+
"node",
32+
[require.resolve("../bin.js"), "run", arg0, arg1],
3033
{
31-
nodeOptions: { cwd: f.find("basic-with-scripts") },
34+
nodeOptions: {
35+
cwd: f.find("basic-with-scripts"),
36+
env: {
37+
...process.env,
38+
NODE_OPTIONS: "--experimental-strip-types",
39+
},
40+
},
3241
}
3342
);
3443
expect(exitCode).toBe(expectedExitCode);
3544
expect(stripAnsi(stdout.toString())).toMatchSnapshot("stdout");
36-
expect(stripAnsi(stderr.toString())).toMatchSnapshot("stderr");
45+
expect(stripAnsi(stripNodeWarnings(stderr.toString()))).toMatchSnapshot(
46+
"stderr"
47+
);
3748
}
3849
);
3950
});

packages/cli/src/test-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Who can say? ¯\_(ツ)_/¯
66

77
import { Package } from "@manypkg/get-packages";
8-
import crypto from "crypto";
8+
import crypto from "node:crypto";
99

1010
export let getRootWS = (): Package => {
1111
return {

0 commit comments

Comments
 (0)