Skip to content

Commit b41feeb

Browse files
authored
fix: show warning when not using npm (#491)
1 parent dc70078 commit b41feeb

6 files changed

Lines changed: 53 additions & 27 deletions

File tree

package-lock.json

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
7070
"@typescript-eslint/eslint-plugin": "^8.35.1",
7171
"commander": "^14.0.0",
72+
"eslint-config-flat-gitignore": "^2.1.0",
7273
"eslint-config-prettier": "^10.1.5",
7374
"eslint-plugin-antfu": "^3.1.1",
7475
"eslint-plugin-import": "^2.32.0",
@@ -78,13 +79,15 @@
7879
"eslint-plugin-react": "^7.37.5",
7980
"eslint-plugin-react-hooks": "^5.2.0",
8081
"eslint-plugin-react-refresh": "^0.4.16",
82+
"eslint-plugin-react-you-might-not-need-an-effect": "^0.4.1",
8183
"eslint-plugin-unicorn": "^59.0.1",
8284
"eslint-plugin-unused-imports": "^4.1.4",
8385
"execa": "^9.6.0",
8486
"find-up-simple": "^1.0.1",
8587
"globals": "^16.3.0",
8688
"is-interactive": "^2.0.0",
8789
"local-pkg": "^1.1.1",
90+
"package-manager-detector": "^1.3.0",
8891
"picocolors": "^1.1.1",
8992
"prettier-plugin-packagejson": "^2.5.18",
9093
"prettier-plugin-tailwindcss": "^0.6.13",
@@ -101,10 +104,7 @@
101104
"@vitest/coverage-v8": "^3.2.4",
102105
"@vitest/ui": "^3.2.4",
103106
"eslint": "^9.30.1",
104-
"eslint-config-flat-gitignore": "^2.1.0",
105-
"eslint-plugin-react-you-might-not-need-an-effect": "^0.4.1",
106107
"husky": "^9.1.7",
107-
"jiti": "^2.4.2",
108108
"knip": "^5.61.3",
109109
"lint-staged": "^16.1.2",
110110
"prettier": "^3.6.2",
@@ -115,7 +115,8 @@
115115
"vitest": "^3.2.4"
116116
},
117117
"peerDependencies": {
118-
"@next/eslint-plugin-next": ">=12.3.0 <16.0.0-0"
118+
"@next/eslint-plugin-next": ">=12.3.0 <16.0.0-0",
119+
"eslint": ">=9.0.0 <10.0.0"
119120
},
120121
"packageManager": "npm@11.4.2",
121122
"engines": {

src/cli/index.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as p from "@clack/prompts";
22
import { Command } from "commander";
3+
import { getUserAgent } from "package-manager-detector/detect";
34
import c from "picocolors";
45

56
import packageJsonData from "../../package.json";
@@ -46,11 +47,33 @@ async function main() {
4647
p.intro(c.bold(c.bgBlue(" @solvro/config ")));
4748
}
4849

50+
const userAgent = getUserAgent();
51+
52+
if (userAgent !== "npm") {
53+
const packageManager = userAgent ?? "unknown";
54+
const warningMessage = `
55+
${c.red(c.bold(`⚠️ OSTRZEŻENIE: ${packageManager} nie jest obsługiwany ⚠️`))}
56+
57+
Próbujesz uruchomić ten skrypt z ${c.yellow(packageManager)}'em, ale @solvro/config działa tylko z ${c.yellow("npm'em")}.
58+
59+
Support dla innych menedżerów pakietów nie jest planowany - chcemy jednolitego stacku technologicznego dla projektów w naszym kochanym kole Solvro.
60+
61+
Użyj zamiast tego npm'a:
62+
${c.cyan("npx @solvro/config")}`;
63+
64+
if (isNonInteractive) {
65+
console.error(warningMessage);
66+
} else {
67+
p.cancel(warningMessage);
68+
}
69+
process.exit(1);
70+
}
71+
4972
// Git clean check
5073
if (options.force !== true && !isGitClean()) {
5174
if (isNonInteractive) {
5275
console.error(
53-
"Git repository has uncommitted changes. Use --force to bypass this check.",
76+
"Repozytorium Git ma niezatwierdzone zmiany. Użyj --force, aby pominąć to sprawdzenie.",
5477
);
5578
process.exit(1);
5679
}
@@ -158,7 +181,7 @@ async function main() {
158181

159182
if (toolsToInstall.length === 0) {
160183
console.error(
161-
"No tools specified. Use --eslint, --prettier, --gh-action, --commitlint, or --all",
184+
"Nie wybrano żadnych narzędzi. Użyj --eslint, --prettier, --gh-action, --commitlint, lub --all",
162185
);
163186
process.exit(1);
164187
}
@@ -227,16 +250,16 @@ async function main() {
227250
await packageJson.clearInstall();
228251

229252
if (isNonInteractive) {
230-
console.log("✅ Configuration completed successfully!");
253+
console.log("✅ Konfiguracja zakończona pomyślnie!");
231254
} else {
232-
p.outro("✅ Configuration completed successfully!");
255+
p.outro("✅ Konfiguracja zakończona pomyślnie!");
233256
}
234257
}
235258

236259
// Run the main function
237260
try {
238261
await main();
239262
} catch (error: unknown) {
240-
console.error("An error occurred:", error);
263+
console.error("Wystąpił błąd:", error);
241264
process.exit(1);
242265
}

tests/error-conditions.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("Error Conditions and Edge Cases", () => {
2929
expect.fail("Should have thrown an error");
3030
} catch (error: any) {
3131
expect(error.message || error.stdout || error.stderr).toContain(
32-
"uncommitted changes",
32+
"niezatwierdzone zmiany",
3333
);
3434
}
3535
});
@@ -43,7 +43,7 @@ describe("Error Conditions and Edge Cases", () => {
4343
"--eslint",
4444
"--force",
4545
]);
46-
expect(output).toContain("Configuration completed successfully");
46+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
4747
expect(env.fileExists(appPath, "eslint.config.js")).toBe(true);
4848
});
4949
});
@@ -59,7 +59,7 @@ describe("Error Conditions and Edge Cases", () => {
5959
expect.fail("Should have thrown an error");
6060
} catch (error: any) {
6161
expect(error.message || error.stdout || error.stderr).toContain(
62-
"No tools specified",
62+
"Nie wybrano żadnych narzędzi",
6363
);
6464
}
6565
});
@@ -125,7 +125,7 @@ describe("Error Conditions and Edge Cases", () => {
125125
"--prettier",
126126
"--force",
127127
]);
128-
expect(output).toContain("Configuration completed successfully");
128+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
129129

130130
expect(env.fileExists(appPath, "eslint.config.js")).toBe(true);
131131
expect(env.hasPackageJsonField(appPath, "prettier")).toBe(true);

tests/integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("Next.js Integration Tests", () => {
2121
await env.initGitRepo(appPath);
2222

2323
const output = await env.runSolvroConfig(appPath, ["--all", "--force"]);
24-
expect(output).toContain("Configuration completed successfully");
24+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
2525

2626
// Format code first
2727
const prettierResult = await env.runPrettier(appPath, true);
@@ -76,7 +76,7 @@ describe("NestJS Integration Tests", () => {
7676
await env.initGitRepo(appPath);
7777

7878
const output = await env.runSolvroConfig(appPath, ["--all", "--force"]);
79-
expect(output).toContain("Configuration completed successfully");
79+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
8080

8181
// Format code first
8282
const prettierResult = await env.runPrettier(appPath, true);
@@ -132,7 +132,7 @@ describe("Vite Integration Tests", () => {
132132
await env.initGitRepo(appPath);
133133

134134
const output = await env.runSolvroConfig(appPath, ["--all", "--force"]);
135-
expect(output).toContain("Configuration completed successfully");
135+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
136136

137137
// Format code first
138138
const prettierResult = await env.runPrettier(appPath, true);

tests/nestjs-preset.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("NestJS Preset Tests", () => {
2525
"--eslint",
2626
"--force",
2727
]);
28-
expect(output).toContain("Configuration completed successfully");
28+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
2929

3030
// Verify ESLint runs without Swagger-specific errors
3131
const eslintResult = await env.runESLint(appPath);
@@ -87,7 +87,7 @@ describe("NestJS Preset Tests", () => {
8787
"--eslint",
8888
"--force",
8989
]);
90-
expect(output).toContain("Configuration completed successfully");
90+
expect(output).toContain("Konfiguracja zakończona pomyślnie");
9191

9292
// Verify the config file was created
9393
expect(env.fileExists(appPath, "eslint.config.mjs")).toBe(true);

0 commit comments

Comments
 (0)