Skip to content

Commit 3eb7461

Browse files
committed
Check for lock files in package manager tests
1 parent 149433e commit 3eb7461

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import fs from "fs/promises"
2+
3+
export const exists = async (path: string): Promise<boolean> => {
4+
try {
5+
await fs.access(path)
6+
return true
7+
} catch (error) {
8+
return false
9+
}
10+
}

packages/create-next-stack/src/tests/e2e/tests/test-npm.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { exists } from "../../../main/helpers/exists"
12
import { runCommand } from "../../../main/helpers/run-command"
23
import { checkFormattingLintingBuild } from "../helpers/check-formatting-linting-build"
34
import { logTestMeta } from "../helpers/log-test-meta"
@@ -31,4 +32,14 @@ export const testNpm = async (createNextStackDir: string): Promise<void> => {
3132
})
3233

3334
await checkFormattingLintingBuild(runDirectory)
35+
36+
if (await exists(`${runDirectory}/yarn.lock`)) {
37+
throw new Error(`yarn.lock found.`)
38+
}
39+
if (!(await exists(`${runDirectory}/package-lock.json`))) {
40+
throw new Error(`package-lock.json not found.`)
41+
}
42+
if (await exists(`${runDirectory}/pnpm-lock.yaml`)) {
43+
throw new Error(`pnpm-lock.yaml found.`)
44+
}
3445
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { exists } from "../../../main/helpers/exists"
2+
import { runCommand } from "../../../main/helpers/run-command"
3+
import { checkFormattingLintingBuild } from "../helpers/check-formatting-linting-build"
4+
import { logTestMeta } from "../helpers/log-test-meta"
5+
import { minutesToMilliseconds } from "../helpers/minutes-to-milliseconds"
6+
import { prepareE2eTest } from "../helpers/prepare-e2e-test"
7+
8+
export const testPnpm = async (createNextStackDir: string): Promise<void> => {
9+
logTestMeta(testPnpm.name, __filename)
10+
11+
const { pathToCLI, runDirectory } = await prepareE2eTest(createNextStackDir)
12+
13+
const args = [
14+
"--debug",
15+
"--package-manager=pnpm",
16+
"--prettier",
17+
"--styling=emotion",
18+
"--material-ui",
19+
"--react-hook-form",
20+
"--formik",
21+
"--framer-motion",
22+
"--formatting-pre-commit-hook",
23+
"--chakra",
24+
".",
25+
]
26+
27+
await runCommand(pathToCLI, args, {
28+
timeout: minutesToMilliseconds(10),
29+
cwd: runDirectory,
30+
stdout: "inherit",
31+
stderr: "inherit",
32+
})
33+
34+
await checkFormattingLintingBuild(runDirectory)
35+
36+
if (await exists(`${runDirectory}/yarn.lock`)) {
37+
throw new Error(`yarn.lock found.`)
38+
}
39+
if (await exists(`${runDirectory}/package-lock.json`)) {
40+
throw new Error(`package-lock.json found.`)
41+
}
42+
if (!(await exists(`${runDirectory}/pnpm-lock.yaml`))) {
43+
throw new Error(`pnpm-lock.yaml not found.`)
44+
}
45+
}

packages/create-next-stack/src/tests/e2e/tests/test-yarn.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { exists } from "../../../main/helpers/exists"
12
import { runCommand } from "../../../main/helpers/run-command"
23
import { checkFormattingLintingBuild } from "../helpers/check-formatting-linting-build"
34
import { logTestMeta } from "../helpers/log-test-meta"
@@ -31,4 +32,14 @@ export const testYarn = async (createNextStackDir: string): Promise<void> => {
3132
})
3233

3334
await checkFormattingLintingBuild(runDirectory)
35+
36+
if (!(await exists(`${runDirectory}/yarn.lock`))) {
37+
throw new Error(`yarn.lock not found.`)
38+
}
39+
if (await exists(`${runDirectory}/package-lock.json`)) {
40+
throw new Error(`package-lock.json found.`)
41+
}
42+
if (await exists(`${runDirectory}/pnpm-lock.yaml`)) {
43+
throw new Error(`pnpm-lock.yaml found.`)
44+
}
3445
}

0 commit comments

Comments
 (0)