@getpara/paramedic 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +131 -0
  2. package/dist/checks/chain-dependencies.check.d.ts +2 -0
  3. package/dist/checks/chain-dependencies.check.d.ts.map +1 -0
  4. package/dist/checks/chain-dependencies.check.js +129 -0
  5. package/dist/checks/css-import.check.d.ts +2 -0
  6. package/dist/checks/css-import.check.d.ts.map +1 -0
  7. package/dist/checks/css-import.check.js +57 -0
  8. package/dist/checks/deprecated-packages.check.d.ts +2 -0
  9. package/dist/checks/deprecated-packages.check.d.ts.map +1 -0
  10. package/dist/checks/deprecated-packages.check.js +52 -0
  11. package/dist/checks/env-api-key.check.d.ts +2 -0
  12. package/dist/checks/env-api-key.check.d.ts.map +1 -0
  13. package/dist/checks/env-api-key.check.js +75 -0
  14. package/dist/checks/env-var-prefix.check.d.ts +2 -0
  15. package/dist/checks/env-var-prefix.check.d.ts.map +1 -0
  16. package/dist/checks/env-var-prefix.check.js +52 -0
  17. package/dist/checks/index.d.ts +12 -0
  18. package/dist/checks/index.d.ts.map +1 -0
  19. package/dist/checks/index.js +33 -0
  20. package/dist/checks/para-provider.check.d.ts +2 -0
  21. package/dist/checks/para-provider.check.d.ts.map +1 -0
  22. package/dist/checks/para-provider.check.js +42 -0
  23. package/dist/checks/query-client.check.d.ts +2 -0
  24. package/dist/checks/query-client.check.d.ts.map +1 -0
  25. package/dist/checks/query-client.check.js +58 -0
  26. package/dist/checks/use-client-directive.check.d.ts +2 -0
  27. package/dist/checks/use-client-directive.check.d.ts.map +1 -0
  28. package/dist/checks/use-client-directive.check.js +82 -0
  29. package/dist/checks/version-consistency.check.d.ts +2 -0
  30. package/dist/checks/version-consistency.check.d.ts.map +1 -0
  31. package/dist/checks/version-consistency.check.js +93 -0
  32. package/dist/cli.d.ts +2 -0
  33. package/dist/cli.d.ts.map +1 -0
  34. package/dist/cli.js +96 -0
  35. package/dist/core/check.d.ts +21 -0
  36. package/dist/core/check.d.ts.map +1 -0
  37. package/dist/core/check.js +10 -0
  38. package/dist/core/context.d.ts +3 -0
  39. package/dist/core/context.d.ts.map +1 -0
  40. package/dist/core/context.js +56 -0
  41. package/dist/core/registry.d.ts +18 -0
  42. package/dist/core/registry.d.ts.map +1 -0
  43. package/dist/core/registry.js +38 -0
  44. package/dist/core/reporter.d.ts +5 -0
  45. package/dist/core/reporter.d.ts.map +1 -0
  46. package/dist/core/reporter.js +82 -0
  47. package/dist/core/runner.d.ts +3 -0
  48. package/dist/core/runner.d.ts.map +1 -0
  49. package/dist/core/runner.js +38 -0
  50. package/dist/detectors/framework.d.ts +5 -0
  51. package/dist/detectors/framework.d.ts.map +1 -0
  52. package/dist/detectors/framework.js +67 -0
  53. package/dist/detectors/package-manager.d.ts +3 -0
  54. package/dist/detectors/package-manager.d.ts.map +1 -0
  55. package/dist/detectors/package-manager.js +17 -0
  56. package/dist/detectors/sdk.d.ts +7 -0
  57. package/dist/detectors/sdk.d.ts.map +1 -0
  58. package/dist/detectors/sdk.js +42 -0
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +6 -0
  62. package/dist/types.d.ts +51 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +6 -0
  65. package/dist/utils/ast-parser.d.ts +10 -0
  66. package/dist/utils/ast-parser.d.ts.map +1 -0
  67. package/dist/utils/ast-parser.js +98 -0
  68. package/dist/utils/file-system.d.ts +9 -0
  69. package/dist/utils/file-system.d.ts.map +1 -0
  70. package/dist/utils/file-system.js +81 -0
  71. package/dist/utils/package-json.d.ts +10 -0
  72. package/dist/utils/package-json.d.ts.map +1 -0
  73. package/dist/utils/package-json.js +39 -0
  74. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # Paramedic
2
+
3
+ Para SDK diagnostic and troubleshooting CLI tool. Quickly identify common integration issues in your Para SDK project.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npx @getpara/paramedic
9
+ ```
10
+
11
+ Run in any directory containing a Para SDK project to get instant diagnostics.
12
+
13
+ ## Features
14
+
15
+ - **Auto-detection** - Automatically detects framework (Next.js, Vite, etc.) and SDK version
16
+ - **Comprehensive checks** - Validates configuration, imports, and setup patterns
17
+ - **Actionable feedback** - Provides specific fixes for each issue found
18
+ - **Zero configuration** - Works out of the box with sensible defaults
19
+
20
+ ## Usage
21
+
22
+ ### Scan Current Directory
23
+
24
+ ```bash
25
+ npx @getpara/paramedic
26
+ ```
27
+
28
+ ### Scan Specific Directory
29
+
30
+ ```bash
31
+ npx @getpara/paramedic ./my-para-app
32
+ ```
33
+
34
+ ### Show Help
35
+
36
+ ```bash
37
+ npx @getpara/paramedic --help
38
+ ```
39
+
40
+ ## Diagnostic Checks
41
+
42
+ Paramedic runs the following checks on your project:
43
+
44
+ | Check | Description |
45
+ |-------|-------------|
46
+ | **API Key** | Verifies `NEXT_PUBLIC_PARA_API_KEY` or equivalent is configured and not a placeholder |
47
+ | **CSS Import** | Ensures Para SDK styles are imported in your application |
48
+ | **ParaProvider** | Validates `ParaProvider` component is properly set up |
49
+ | **QueryClientProvider** | Checks React Query provider wrapping (required for Para SDK) |
50
+ | **Version Consistency** | Detects mismatched versions across Para packages |
51
+ | **Chain Dependencies** | Validates network-specific dependencies (EVM, Solana, Cosmos) |
52
+ | **"use client" Directive** | Ensures proper client directive for Next.js App Router |
53
+ | **Environment Variable Prefix** | Checks correct env var prefix for your framework |
54
+ | **Deprecated Packages** | Warns about deprecated Para packages that should be upgraded |
55
+
56
+ ## Example Output
57
+
58
+ ```
59
+ ┌ Paramedic - Para SDK Diagnostics
60
+
61
+ ◇ Analysis complete
62
+
63
+ │ Framework: Next.js (App Router)
64
+ │ SDK: @getpara/react-sdk@2.5.0
65
+
66
+ ◇ Checks complete
67
+
68
+ │ ✓ API key configured
69
+ │ ✓ CSS styles imported
70
+ │ ✓ ParaProvider found
71
+ │ ✗ QueryClientProvider missing
72
+ │ └─ Wrap your app with QueryClientProvider from @tanstack/react-query
73
+ │ ⚠ Version mismatch
74
+ │ └─ @getpara/react-sdk@2.5.0 and @getpara/evm-wallet-connectors@2.4.0
75
+
76
+ └ 2 issues found (1 error, 1 warning)
77
+ ```
78
+
79
+ ## Supported Frameworks
80
+
81
+ - Next.js (App Router & Pages Router)
82
+ - Vite (React)
83
+ - Create React App
84
+ - Remix
85
+ - Other React-based frameworks
86
+
87
+ ## Supported SDKs
88
+
89
+ - `@getpara/react-sdk`
90
+ - `@getpara/react-sdk-lite`
91
+
92
+ ## Requirements
93
+
94
+ - Node.js 18.0.0 or higher
95
+
96
+ ## How It Works
97
+
98
+ 1. **Detection Phase** - Scans `package.json` to identify framework and Para SDK version
99
+ 2. **Context Building** - Indexes project files while respecting `.gitignore`
100
+ 3. **Check Execution** - Runs all applicable diagnostic checks
101
+ 4. **Reporting** - Displays results with severity levels and fix suggestions
102
+
103
+ ## Exit Codes
104
+
105
+ | Code | Description |
106
+ |------|-------------|
107
+ | `0` | All checks passed |
108
+ | `1` | One or more checks failed (errors found) |
109
+
110
+ ## Extending Paramedic
111
+
112
+ Paramedic uses a modular check system. Each check is a standalone module in `src/checks/` that implements the `Check` interface:
113
+
114
+ ```typescript
115
+ interface Check {
116
+ id: string;
117
+ name: string;
118
+ category: CheckCategory;
119
+ run: (context: DiagnosticContext) => Promise<CheckResult>;
120
+ }
121
+ ```
122
+
123
+ ## Documentation
124
+
125
+ - [Para Documentation](https://docs.getpara.com)
126
+ - [Para React SDK](https://docs.getpara.com/react-sdk)
127
+ - [Troubleshooting Guide](https://docs.getpara.com/troubleshooting)
128
+
129
+ ## License
130
+
131
+ MIT
@@ -0,0 +1,2 @@
1
+ export declare const chainDependenciesCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=chain-dependencies.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-dependencies.check.d.ts","sourceRoot":"","sources":["../../src/checks/chain-dependencies.check.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,sBAAsB,kCA6BjC,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { defineCheck } from "../core/check.js";
2
+ import { hasDependency } from "../utils/package-json.js";
3
+ const EVM_DEPENDENCIES = ["viem", "wagmi"];
4
+ const SOLANA_DEPENDENCIES = ["@solana/web3.js", "@solana/wallet-adapter-react"];
5
+ const COSMOS_DEPENDENCIES = ["@cosmjs/stargate", "graz"];
6
+ const WALLET_CONNECTOR_PATTERNS = [
7
+ "@getpara/evm-wallet-connectors",
8
+ "@getpara/solana-wallet-connectors",
9
+ "@getpara/cosmos-wallet-connectors",
10
+ "@getpara/bitcoin-wallet-connectors",
11
+ "@getpara/graz-wallet-connectors",
12
+ "@getpara/rainbowkit-wallet-connectors"
13
+ ];
14
+ const chainDependenciesCheck = defineCheck({
15
+ metadata: {
16
+ id: "chain-dependencies",
17
+ name: "Chain Dependencies",
18
+ description: "Checks if required chain dependencies are installed",
19
+ category: "dependencies",
20
+ severity: "error",
21
+ enabled: true
22
+ },
23
+ shouldRun(context) {
24
+ return context.sdkType !== "none" && context.packageJson !== null;
25
+ },
26
+ async run(context) {
27
+ if (!context.packageJson) {
28
+ return [];
29
+ }
30
+ const results = [];
31
+ if (context.sdkType === "@getpara/react-sdk") {
32
+ results.push(...checkReactSDKDependencies(context, this.metadata.id));
33
+ } else if (context.sdkType === "@getpara/react-sdk-lite") {
34
+ results.push(...checkReactSDKLiteDependencies(context, this.metadata.id));
35
+ }
36
+ return results;
37
+ }
38
+ });
39
+ function checkReactSDKDependencies(context, checkId) {
40
+ const results = [];
41
+ const packageJson = context.packageJson;
42
+ const hasEvm = EVM_DEPENDENCIES.some((dep) => hasDependency(packageJson, dep));
43
+ if (!hasEvm) {
44
+ results.push({
45
+ checkId,
46
+ passed: false,
47
+ severity: "warning",
48
+ message: "EVM chain dependencies not installed",
49
+ details: `Missing: ${EVM_DEPENDENCIES.join(", ")}`,
50
+ recommendation: `Install EVM dependencies: npm install ${EVM_DEPENDENCIES.join(" ")}`
51
+ });
52
+ }
53
+ const hasSolana = SOLANA_DEPENDENCIES.some((dep) => hasDependency(packageJson, dep));
54
+ if (!hasSolana) {
55
+ results.push({
56
+ checkId,
57
+ passed: false,
58
+ severity: "warning",
59
+ message: "Solana chain dependencies not installed",
60
+ details: `Missing: ${SOLANA_DEPENDENCIES.join(", ")}`,
61
+ recommendation: `Install Solana dependencies: npm install ${SOLANA_DEPENDENCIES.join(" ")}`
62
+ });
63
+ }
64
+ const hasCosmos = COSMOS_DEPENDENCIES.some((dep) => hasDependency(packageJson, dep));
65
+ if (!hasCosmos) {
66
+ results.push({
67
+ checkId,
68
+ passed: false,
69
+ severity: "warning",
70
+ message: "Cosmos chain dependencies not installed",
71
+ details: `Missing: ${COSMOS_DEPENDENCIES.join(", ")}`,
72
+ recommendation: `Install Cosmos dependencies: npm install ${COSMOS_DEPENDENCIES.join(" ")}`
73
+ });
74
+ }
75
+ if (hasEvm && hasSolana && hasCosmos) {
76
+ results.push({
77
+ checkId,
78
+ passed: true,
79
+ severity: "error",
80
+ message: "All chain dependencies installed"
81
+ });
82
+ }
83
+ return results;
84
+ }
85
+ function checkReactSDKLiteDependencies(context, checkId) {
86
+ const results = [];
87
+ const packageJson = context.packageJson;
88
+ const installedConnectors = WALLET_CONNECTOR_PATTERNS.filter((connector) => hasDependency(packageJson, connector));
89
+ if (installedConnectors.length === 0) {
90
+ results.push({
91
+ checkId,
92
+ passed: false,
93
+ severity: "error",
94
+ message: "No wallet connector packages installed",
95
+ details: `react-sdk-lite requires at least one @getpara/*-wallet-connectors package`,
96
+ recommendation: `Install a wallet connector, e.g.: npm install @getpara/evm-wallet-connectors`
97
+ });
98
+ } else {
99
+ results.push({
100
+ checkId,
101
+ passed: true,
102
+ severity: "error",
103
+ message: `Wallet connector(s) installed: ${installedConnectors.map((c) => c.replace("@getpara/", "")).join(", ")}`
104
+ });
105
+ }
106
+ const postinstallScript = packageJson.scripts?.postinstall || "";
107
+ const hasSetupPara = postinstallScript.includes("setup-para");
108
+ if (!hasSetupPara) {
109
+ results.push({
110
+ checkId,
111
+ passed: false,
112
+ severity: "error",
113
+ message: "Missing setup-para in postinstall script",
114
+ details: "react-sdk-lite requires setup-para to stub unused chain packages",
115
+ recommendation: 'Add to package.json scripts: "postinstall": "npx setup-para"'
116
+ });
117
+ } else {
118
+ results.push({
119
+ checkId,
120
+ passed: true,
121
+ severity: "error",
122
+ message: "setup-para configured in postinstall script"
123
+ });
124
+ }
125
+ return results;
126
+ }
127
+ export {
128
+ chainDependenciesCheck
129
+ };
@@ -0,0 +1,2 @@
1
+ export declare const cssImportCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=css-import.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-import.check.d.ts","sourceRoot":"","sources":["../../src/checks/css-import.check.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,kCAwDzB,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { defineCheck } from "../core/check.js";
2
+ import { getCSSImportPath } from "../detectors/sdk.js";
3
+ import { findImportInFiles } from "../utils/ast-parser.js";
4
+ const cssImportCheck = defineCheck({
5
+ metadata: {
6
+ id: "css-import",
7
+ name: "CSS Styles Import",
8
+ description: "Checks if Para SDK CSS styles are imported",
9
+ category: "setup",
10
+ severity: "error",
11
+ enabled: true
12
+ },
13
+ shouldRun(context) {
14
+ return context.sdkType === "@getpara/react-sdk" || context.sdkType === "@getpara/react-sdk-lite";
15
+ },
16
+ async run(context) {
17
+ const cssImportPath = getCSSImportPath(context.sdkType);
18
+ if (!cssImportPath) {
19
+ return [];
20
+ }
21
+ const found = await findImportInFiles(context.files, cssImportPath, context.shouldIgnoreFile);
22
+ if (found) {
23
+ return [
24
+ {
25
+ checkId: this.metadata.id,
26
+ passed: true,
27
+ severity: this.metadata.severity,
28
+ message: "Para SDK styles imported correctly",
29
+ location: found
30
+ }
31
+ ];
32
+ }
33
+ const entryPointHints = [];
34
+ if (context.framework === "nextjs") {
35
+ entryPointHints.push("app/layout.tsx", "pages/_app.tsx");
36
+ } else if (context.framework === "vite" || context.framework === "create-react-app") {
37
+ entryPointHints.push("src/main.tsx", "src/index.tsx", "src/App.tsx");
38
+ } else if (context.framework === "vue") {
39
+ entryPointHints.push("src/main.ts", "src/App.vue");
40
+ } else if (context.framework === "svelte") {
41
+ entryPointHints.push("src/main.ts", "src/App.svelte");
42
+ }
43
+ return [
44
+ {
45
+ checkId: this.metadata.id,
46
+ passed: false,
47
+ severity: this.metadata.severity,
48
+ message: "Para SDK styles not imported",
49
+ details: `Missing import in entry point (${entryPointHints.join(" or ")})`,
50
+ recommendation: `Add: import "${cssImportPath}"`
51
+ }
52
+ ];
53
+ }
54
+ });
55
+ export {
56
+ cssImportCheck
57
+ };
@@ -0,0 +1,2 @@
1
+ export declare const deprecatedPackagesCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=deprecated-packages.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated-packages.check.d.ts","sourceRoot":"","sources":["../../src/checks/deprecated-packages.check.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,uBAAuB,kCA6ClC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { defineCheck } from "../core/check.js";
2
+ import { hasDependency } from "../utils/package-json.js";
3
+ const DEPRECATED_PACKAGES = [
4
+ {
5
+ name: "@getpara/graz",
6
+ reason: "This package is deprecated and causes conflicts",
7
+ recommendation: "Remove @getpara/graz and use @getpara/graz-wallet-connectors instead"
8
+ }
9
+ ];
10
+ const deprecatedPackagesCheck = defineCheck({
11
+ metadata: {
12
+ id: "deprecated-packages",
13
+ name: "Deprecated Packages",
14
+ description: "Checks for deprecated @getpara/* packages that should be removed",
15
+ category: "dependencies",
16
+ severity: "error",
17
+ enabled: true
18
+ },
19
+ shouldRun(context) {
20
+ return context.packageJson !== null;
21
+ },
22
+ async run(context) {
23
+ if (!context.packageJson) {
24
+ return [];
25
+ }
26
+ const results = [];
27
+ for (const deprecated of DEPRECATED_PACKAGES) {
28
+ if (hasDependency(context.packageJson, deprecated.name)) {
29
+ results.push({
30
+ checkId: this.metadata.id,
31
+ passed: false,
32
+ severity: this.metadata.severity,
33
+ message: `Deprecated package found: ${deprecated.name}`,
34
+ details: deprecated.reason,
35
+ recommendation: deprecated.recommendation
36
+ });
37
+ }
38
+ }
39
+ if (results.length === 0) {
40
+ results.push({
41
+ checkId: this.metadata.id,
42
+ passed: true,
43
+ severity: this.metadata.severity,
44
+ message: "No deprecated packages found"
45
+ });
46
+ }
47
+ return results;
48
+ }
49
+ });
50
+ export {
51
+ deprecatedPackagesCheck
52
+ };
@@ -0,0 +1,2 @@
1
+ export declare const envApiKeyCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=env-api-key.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-api-key.check.d.ts","sourceRoot":"","sources":["../../src/checks/env-api-key.check.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,kCA4EzB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import path from "node:path";
2
+ import { defineCheck } from "../core/check.js";
3
+ import { getEnvVarPrefix } from "../detectors/framework.js";
4
+ import { readFile, findEnvFiles } from "../utils/file-system.js";
5
+ const envApiKeyCheck = defineCheck({
6
+ metadata: {
7
+ id: "env-api-key",
8
+ name: "API Key Configuration",
9
+ description: "Checks if Para API key is defined in environment files",
10
+ category: "configuration",
11
+ severity: "error",
12
+ enabled: true
13
+ },
14
+ shouldRun(context) {
15
+ return context.sdkType !== "none";
16
+ },
17
+ async run(context) {
18
+ const prefix = getEnvVarPrefix(context.framework);
19
+ const expectedVar = `${prefix}PARA_API_KEY`;
20
+ const envFiles = await findEnvFiles(context.projectRoot);
21
+ let foundIn = null;
22
+ let hasPlaceholder = false;
23
+ for (const file of envFiles) {
24
+ const content = await readFile(file);
25
+ if (!content) continue;
26
+ const lines = content.split("\n");
27
+ for (const line of lines) {
28
+ if (line.startsWith(expectedVar + "=")) {
29
+ foundIn = path.basename(file);
30
+ const value = line.substring(line.indexOf("=") + 1).trim();
31
+ if (value === "" || value === "your_api_key_here" || value === "your-api-key-here" || value === "YOUR_API_KEY") {
32
+ hasPlaceholder = true;
33
+ }
34
+ break;
35
+ }
36
+ }
37
+ if (foundIn) break;
38
+ }
39
+ if (foundIn && !hasPlaceholder) {
40
+ return [
41
+ {
42
+ checkId: this.metadata.id,
43
+ passed: true,
44
+ severity: this.metadata.severity,
45
+ message: `API key ${expectedVar} found in ${foundIn}`
46
+ }
47
+ ];
48
+ }
49
+ if (foundIn && hasPlaceholder) {
50
+ return [
51
+ {
52
+ checkId: this.metadata.id,
53
+ passed: false,
54
+ severity: "warning",
55
+ message: `API key ${expectedVar} found but has placeholder value`,
56
+ details: `Replace the placeholder in ${foundIn} with your actual Para API key`,
57
+ recommendation: "Get your API key from the Para dashboard and update the environment file"
58
+ }
59
+ ];
60
+ }
61
+ return [
62
+ {
63
+ checkId: this.metadata.id,
64
+ passed: false,
65
+ severity: this.metadata.severity,
66
+ message: `API key ${expectedVar} not found in environment files`,
67
+ details: `Add ${expectedVar}=your_api_key to .env.local or similar`,
68
+ recommendation: `Create .env.local and add: ${expectedVar}=your_api_key_here`
69
+ }
70
+ ];
71
+ }
72
+ });
73
+ export {
74
+ envApiKeyCheck
75
+ };
@@ -0,0 +1,2 @@
1
+ export declare const envVarPrefixCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=env-var-prefix.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-var-prefix.check.d.ts","sourceRoot":"","sources":["../../src/checks/env-var-prefix.check.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,kCAsD5B,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { defineCheck } from "../core/check.js";
2
+ import { getEnvVarPrefix, getEnvAccessPattern } from "../detectors/framework.js";
3
+ import { findPatternInFiles } from "../utils/ast-parser.js";
4
+ const envVarPrefixCheck = defineCheck({
5
+ metadata: {
6
+ id: "env-var-prefix",
7
+ name: "Environment Variable Prefix",
8
+ description: "Checks if environment variables use the correct prefix for the framework",
9
+ category: "configuration",
10
+ severity: "warning",
11
+ enabled: true
12
+ },
13
+ shouldRun(context) {
14
+ return context.sdkType !== "none" && context.framework !== "unknown";
15
+ },
16
+ async run(context) {
17
+ const correctPrefix = getEnvVarPrefix(context.framework);
18
+ const correctAccess = getEnvAccessPattern(context.framework);
19
+ const wrongPrefixes = ["NEXT_PUBLIC_", "VITE_", "REACT_APP_"].filter((p) => p !== correctPrefix);
20
+ const results = [];
21
+ for (const wrongPrefix of wrongPrefixes) {
22
+ const pattern = new RegExp(`${wrongPrefix}PARA_API_KEY`);
23
+ const locations = await findPatternInFiles(context.files, pattern, context.shouldIgnoreFile);
24
+ if (locations.length > 0) {
25
+ results.push({
26
+ checkId: this.metadata.id,
27
+ passed: false,
28
+ severity: this.metadata.severity,
29
+ message: `Found ${wrongPrefix}PARA_API_KEY but framework expects ${correctPrefix}PARA_API_KEY`,
30
+ location: locations[0],
31
+ recommendation: `Use ${correctAccess}.${correctPrefix}PARA_API_KEY for ${context.framework}`
32
+ });
33
+ }
34
+ }
35
+ if (results.length === 0) {
36
+ const correctPattern = new RegExp(`${correctPrefix}PARA_API_KEY`);
37
+ const locations = await findPatternInFiles(context.files, correctPattern, context.shouldIgnoreFile);
38
+ if (locations.length > 0) {
39
+ results.push({
40
+ checkId: this.metadata.id,
41
+ passed: true,
42
+ severity: this.metadata.severity,
43
+ message: `Environment variable prefix ${correctPrefix} is correct for ${context.framework}`
44
+ });
45
+ }
46
+ }
47
+ return results;
48
+ }
49
+ });
50
+ export {
51
+ envVarPrefixCheck
52
+ };
@@ -0,0 +1,12 @@
1
+ import { envApiKeyCheck } from './env-api-key.check.js';
2
+ import { cssImportCheck } from './css-import.check.js';
3
+ import { paraProviderCheck } from './para-provider.check.js';
4
+ import { queryClientCheck } from './query-client.check.js';
5
+ import { versionConsistencyCheck } from './version-consistency.check.js';
6
+ import { useClientDirectiveCheck } from './use-client-directive.check.js';
7
+ import { envVarPrefixCheck } from './env-var-prefix.check.js';
8
+ import { chainDependenciesCheck } from './chain-dependencies.check.js';
9
+ import { deprecatedPackagesCheck } from './deprecated-packages.check.js';
10
+ export declare function registerAllChecks(): void;
11
+ export { envApiKeyCheck, cssImportCheck, paraProviderCheck, queryClientCheck, versionConsistencyCheck, useClientDirectiveCheck, envVarPrefixCheck, chainDependenciesCheck, deprecatedPackagesCheck, };
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,wBAAgB,iBAAiB,IAAI,IAAI,CAUxC;AAED,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { registry } from "../core/registry.js";
2
+ import { envApiKeyCheck } from "./env-api-key.check.js";
3
+ import { cssImportCheck } from "./css-import.check.js";
4
+ import { paraProviderCheck } from "./para-provider.check.js";
5
+ import { queryClientCheck } from "./query-client.check.js";
6
+ import { versionConsistencyCheck } from "./version-consistency.check.js";
7
+ import { useClientDirectiveCheck } from "./use-client-directive.check.js";
8
+ import { envVarPrefixCheck } from "./env-var-prefix.check.js";
9
+ import { chainDependenciesCheck } from "./chain-dependencies.check.js";
10
+ import { deprecatedPackagesCheck } from "./deprecated-packages.check.js";
11
+ function registerAllChecks() {
12
+ registry.register(envApiKeyCheck);
13
+ registry.register(cssImportCheck);
14
+ registry.register(paraProviderCheck);
15
+ registry.register(queryClientCheck);
16
+ registry.register(versionConsistencyCheck);
17
+ registry.register(useClientDirectiveCheck);
18
+ registry.register(envVarPrefixCheck);
19
+ registry.register(chainDependenciesCheck);
20
+ registry.register(deprecatedPackagesCheck);
21
+ }
22
+ export {
23
+ chainDependenciesCheck,
24
+ cssImportCheck,
25
+ deprecatedPackagesCheck,
26
+ envApiKeyCheck,
27
+ envVarPrefixCheck,
28
+ paraProviderCheck,
29
+ queryClientCheck,
30
+ registerAllChecks,
31
+ useClientDirectiveCheck,
32
+ versionConsistencyCheck
33
+ };
@@ -0,0 +1,2 @@
1
+ export declare const paraProviderCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=para-provider.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"para-provider.check.d.ts","sourceRoot":"","sources":["../../src/checks/para-provider.check.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,kCA6C5B,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { defineCheck } from "../core/check.js";
2
+ import { findPatternInFiles } from "../utils/ast-parser.js";
3
+ const paraProviderCheck = defineCheck({
4
+ metadata: {
5
+ id: "para-provider",
6
+ name: "ParaProvider Setup",
7
+ description: "Checks if ParaProvider is imported from Para SDK",
8
+ category: "setup",
9
+ severity: "error",
10
+ enabled: true
11
+ },
12
+ shouldRun(context) {
13
+ return context.sdkType === "@getpara/react-sdk" || context.sdkType === "@getpara/react-sdk-lite";
14
+ },
15
+ async run(context) {
16
+ const importPattern = /import\s*\{[\s\S]*?\bParaProvider\b[\s\S]*?\}\s*from\s*['"]@getpara\/(react-sdk|react-sdk-lite)['"]/;
17
+ const importLocations = await findPatternInFiles(context.files, importPattern, context.shouldIgnoreFile);
18
+ if (importLocations.length > 0) {
19
+ return [
20
+ {
21
+ checkId: this.metadata.id,
22
+ passed: true,
23
+ severity: this.metadata.severity,
24
+ message: "ParaProvider is imported",
25
+ location: importLocations[0]
26
+ }
27
+ ];
28
+ }
29
+ return [
30
+ {
31
+ checkId: this.metadata.id,
32
+ passed: false,
33
+ severity: this.metadata.severity,
34
+ message: "ParaProvider not imported",
35
+ recommendation: `Import ParaProvider from ${context.sdkType} and wrap your app with it`
36
+ }
37
+ ];
38
+ }
39
+ });
40
+ export {
41
+ paraProviderCheck
42
+ };
@@ -0,0 +1,2 @@
1
+ export declare const queryClientCheck: import("../core/check.js").Check;
2
+ //# sourceMappingURL=query-client.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-client.check.d.ts","sourceRoot":"","sources":["../../src/checks/query-client.check.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,kCA0D3B,CAAC"}