@getpara/cli 2.15.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.
- package/README.md +97 -0
- package/dist/api/client.d.ts +49 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +247 -0
- package/dist/api/errors.d.ts +9 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +29 -0
- package/dist/api/types.d.ts +155 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +58 -0
- package/dist/auth/polling-flow.d.ts +7 -0
- package/dist/auth/polling-flow.d.ts.map +1 -0
- package/dist/auth/polling-flow.js +94 -0
- package/dist/auth/session-manager.d.ts +7 -0
- package/dist/auth/session-manager.d.ts.map +1 -0
- package/dist/auth/session-manager.js +42 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +151 -0
- package/dist/commands/auth/index.d.ts +3 -0
- package/dist/commands/auth/index.d.ts.map +1 -0
- package/dist/commands/auth/index.js +18 -0
- package/dist/commands/auth/login.d.ts +3 -0
- package/dist/commands/auth/login.d.ts.map +1 -0
- package/dist/commands/auth/login.js +70 -0
- package/dist/commands/auth/logout.d.ts +3 -0
- package/dist/commands/auth/logout.d.ts.map +1 -0
- package/dist/commands/auth/logout.js +45 -0
- package/dist/commands/auth/status.d.ts +3 -0
- package/dist/commands/auth/status.d.ts.map +1 -0
- package/dist/commands/auth/status.js +54 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +122 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +587 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +67 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +45 -0
- package/dist/commands/keys/archive.d.ts +3 -0
- package/dist/commands/keys/archive.d.ts.map +1 -0
- package/dist/commands/keys/archive.js +49 -0
- package/dist/commands/keys/config/branding.d.ts +23 -0
- package/dist/commands/keys/config/branding.d.ts.map +1 -0
- package/dist/commands/keys/config/branding.js +246 -0
- package/dist/commands/keys/config/categories.d.ts +15 -0
- package/dist/commands/keys/config/categories.d.ts.map +1 -0
- package/dist/commands/keys/config/categories.js +67 -0
- package/dist/commands/keys/config/index.d.ts +3 -0
- package/dist/commands/keys/config/index.d.ts.map +1 -0
- package/dist/commands/keys/config/index.js +56 -0
- package/dist/commands/keys/config/ramps.d.ts +18 -0
- package/dist/commands/keys/config/ramps.d.ts.map +1 -0
- package/dist/commands/keys/config/ramps.js +185 -0
- package/dist/commands/keys/config/security.d.ts +15 -0
- package/dist/commands/keys/config/security.d.ts.map +1 -0
- package/dist/commands/keys/config/security.js +212 -0
- package/dist/commands/keys/config/setup.d.ts +16 -0
- package/dist/commands/keys/config/setup.d.ts.map +1 -0
- package/dist/commands/keys/config/setup.js +235 -0
- package/dist/commands/keys/config/webhooks.d.ts +18 -0
- package/dist/commands/keys/config/webhooks.d.ts.map +1 -0
- package/dist/commands/keys/config/webhooks.js +279 -0
- package/dist/commands/keys/create.d.ts +3 -0
- package/dist/commands/keys/create.d.ts.map +1 -0
- package/dist/commands/keys/create.js +64 -0
- package/dist/commands/keys/get.d.ts +3 -0
- package/dist/commands/keys/get.d.ts.map +1 -0
- package/dist/commands/keys/get.js +91 -0
- package/dist/commands/keys/index.d.ts +3 -0
- package/dist/commands/keys/index.d.ts.map +1 -0
- package/dist/commands/keys/index.js +22 -0
- package/dist/commands/keys/list.d.ts +3 -0
- package/dist/commands/keys/list.d.ts.map +1 -0
- package/dist/commands/keys/list.js +66 -0
- package/dist/commands/keys/rotate.d.ts +3 -0
- package/dist/commands/keys/rotate.d.ts.map +1 -0
- package/dist/commands/keys/rotate.js +59 -0
- package/dist/commands/orgs/index.d.ts +3 -0
- package/dist/commands/orgs/index.d.ts.map +1 -0
- package/dist/commands/orgs/index.js +15 -0
- package/dist/commands/orgs/list.d.ts +3 -0
- package/dist/commands/orgs/list.d.ts.map +1 -0
- package/dist/commands/orgs/list.js +53 -0
- package/dist/commands/orgs/switch.d.ts +3 -0
- package/dist/commands/orgs/switch.d.ts.map +1 -0
- package/dist/commands/orgs/switch.js +61 -0
- package/dist/commands/projects/archive.d.ts +3 -0
- package/dist/commands/projects/archive.d.ts.map +1 -0
- package/dist/commands/projects/archive.js +51 -0
- package/dist/commands/projects/create.d.ts +3 -0
- package/dist/commands/projects/create.d.ts.map +1 -0
- package/dist/commands/projects/create.js +48 -0
- package/dist/commands/projects/index.d.ts +3 -0
- package/dist/commands/projects/index.d.ts.map +1 -0
- package/dist/commands/projects/index.js +25 -0
- package/dist/commands/projects/list.d.ts +3 -0
- package/dist/commands/projects/list.d.ts.map +1 -0
- package/dist/commands/projects/list.js +52 -0
- package/dist/commands/projects/restore.d.ts +3 -0
- package/dist/commands/projects/restore.d.ts.map +1 -0
- package/dist/commands/projects/restore.js +36 -0
- package/dist/commands/projects/switch.d.ts +3 -0
- package/dist/commands/projects/switch.d.ts.map +1 -0
- package/dist/commands/projects/switch.js +57 -0
- package/dist/commands/projects/update.d.ts +3 -0
- package/dist/commands/projects/update.d.ts.map +1 -0
- package/dist/commands/projects/update.js +67 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +61 -0
- package/dist/config/config-manager.d.ts +3 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +32 -0
- package/dist/config/config-store.d.ts +10 -0
- package/dist/config/config-store.d.ts.map +1 -0
- package/dist/config/config-store.js +37 -0
- package/dist/config/credential-store.d.ts +12 -0
- package/dist/config/credential-store.d.ts.map +1 -0
- package/dist/config/credential-store.js +94 -0
- package/dist/config/paths.d.ts +5 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +29 -0
- package/dist/config/project-config.d.ts +8 -0
- package/dist/config/project-config.d.ts.map +1 -0
- package/dist/config/project-config.js +41 -0
- package/dist/core/constants.d.ts +27 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +60 -0
- package/dist/core/error-handler.d.ts +24 -0
- package/dist/core/error-handler.d.ts.map +1 -0
- package/dist/core/error-handler.js +83 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +0 -0
- package/dist/core/update-check.d.ts +6 -0
- package/dist/core/update-check.d.ts.map +1 -0
- package/dist/core/update-check.js +78 -0
- package/dist/diagnostics/checks/chain-dependencies.d.ts +2 -0
- package/dist/diagnostics/checks/chain-dependencies.d.ts.map +1 -0
- package/dist/diagnostics/checks/chain-dependencies.js +130 -0
- package/dist/diagnostics/checks/css-import.d.ts +2 -0
- package/dist/diagnostics/checks/css-import.d.ts.map +1 -0
- package/dist/diagnostics/checks/css-import.js +57 -0
- package/dist/diagnostics/checks/deprecated-packages.d.ts +2 -0
- package/dist/diagnostics/checks/deprecated-packages.d.ts.map +1 -0
- package/dist/diagnostics/checks/deprecated-packages.js +93 -0
- package/dist/diagnostics/checks/env-api-key.d.ts +2 -0
- package/dist/diagnostics/checks/env-api-key.d.ts.map +1 -0
- package/dist/diagnostics/checks/env-api-key.js +75 -0
- package/dist/diagnostics/checks/env-var-prefix.d.ts +2 -0
- package/dist/diagnostics/checks/env-var-prefix.d.ts.map +1 -0
- package/dist/diagnostics/checks/env-var-prefix.js +52 -0
- package/dist/diagnostics/checks/index.d.ts +13 -0
- package/dist/diagnostics/checks/index.d.ts.map +1 -0
- package/dist/diagnostics/checks/index.js +32 -0
- package/dist/diagnostics/checks/para-provider.d.ts +2 -0
- package/dist/diagnostics/checks/para-provider.d.ts.map +1 -0
- package/dist/diagnostics/checks/para-provider.js +42 -0
- package/dist/diagnostics/checks/query-client.d.ts +2 -0
- package/dist/diagnostics/checks/query-client.d.ts.map +1 -0
- package/dist/diagnostics/checks/query-client.js +58 -0
- package/dist/diagnostics/checks/use-client-directive.d.ts +2 -0
- package/dist/diagnostics/checks/use-client-directive.d.ts.map +1 -0
- package/dist/diagnostics/checks/use-client-directive.js +81 -0
- package/dist/diagnostics/checks/version-consistency.d.ts +2 -0
- package/dist/diagnostics/checks/version-consistency.d.ts.map +1 -0
- package/dist/diagnostics/checks/version-consistency.js +93 -0
- package/dist/diagnostics/context.d.ts +3 -0
- package/dist/diagnostics/context.d.ts.map +1 -0
- package/dist/diagnostics/context.js +56 -0
- package/dist/diagnostics/detectors/framework.d.ts +5 -0
- package/dist/diagnostics/detectors/framework.d.ts.map +1 -0
- package/dist/diagnostics/detectors/framework.js +73 -0
- package/dist/diagnostics/detectors/package-manager.d.ts +3 -0
- package/dist/diagnostics/detectors/package-manager.d.ts.map +1 -0
- package/dist/diagnostics/detectors/package-manager.js +17 -0
- package/dist/diagnostics/detectors/sdk.d.ts +7 -0
- package/dist/diagnostics/detectors/sdk.d.ts.map +1 -0
- package/dist/diagnostics/detectors/sdk.js +48 -0
- package/dist/diagnostics/runner.d.ts +3 -0
- package/dist/diagnostics/runner.d.ts.map +1 -0
- package/dist/diagnostics/runner.js +44 -0
- package/dist/diagnostics/types.d.ts +70 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/diagnostics/types.js +14 -0
- package/dist/diagnostics/utils/code-search.d.ts +10 -0
- package/dist/diagnostics/utils/code-search.d.ts.map +1 -0
- package/dist/diagnostics/utils/code-search.js +98 -0
- package/dist/diagnostics/utils/file-system.d.ts +7 -0
- package/dist/diagnostics/utils/file-system.d.ts.map +1 -0
- package/dist/diagnostics/utils/file-system.js +72 -0
- package/dist/diagnostics/utils/package-json.d.ts +12 -0
- package/dist/diagnostics/utils/package-json.d.ts.map +1 -0
- package/dist/diagnostics/utils/package-json.js +51 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/output/formatter.d.ts +25 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +76 -0
- package/dist/output/mask.d.ts +2 -0
- package/dist/output/mask.d.ts.map +1 -0
- package/dist/output/mask.js +15 -0
- package/dist/output/prompts.d.ts +25 -0
- package/dist/output/prompts.d.ts.map +1 -0
- package/dist/output/prompts.js +86 -0
- package/dist/output/spinner.d.ts +6 -0
- package/dist/output/spinner.d.ts.map +1 -0
- package/dist/output/spinner.js +7 -0
- package/dist/output/table.d.ts +9 -0
- package/dist/output/table.d.ts.map +1 -0
- package/dist/output/table.js +21 -0
- package/dist/scaffolding/scaffolder.d.ts +3 -0
- package/dist/scaffolding/scaffolder.d.ts.map +1 -0
- package/dist/scaffolding/scaffolder.js +78 -0
- package/dist/scaffolding/strategies/expo-template.d.ts +16 -0
- package/dist/scaffolding/strategies/expo-template.d.ts.map +1 -0
- package/dist/scaffolding/strategies/expo-template.js +160 -0
- package/dist/scaffolding/strategies/index.d.ts +5 -0
- package/dist/scaffolding/strategies/index.d.ts.map +1 -0
- package/dist/scaffolding/strategies/index.js +25 -0
- package/dist/scaffolding/strategies/nextjs-template.d.ts +12 -0
- package/dist/scaffolding/strategies/nextjs-template.d.ts.map +1 -0
- package/dist/scaffolding/strategies/nextjs-template.js +122 -0
- package/dist/scaffolding/template-renderer.d.ts +11 -0
- package/dist/scaffolding/template-renderer.d.ts.map +1 -0
- package/dist/scaffolding/template-renderer.js +99 -0
- package/dist/scaffolding/types.d.ts +69 -0
- package/dist/scaffolding/types.d.ts.map +1 -0
- package/dist/scaffolding/types.js +21 -0
- package/dist/scaffolding/utils/detect-package-manager.d.ts +23 -0
- package/dist/scaffolding/utils/detect-package-manager.d.ts.map +1 -0
- package/dist/scaffolding/utils/detect-package-manager.js +57 -0
- package/dist/scaffolding/utils/fs.d.ts +11 -0
- package/dist/scaffolding/utils/fs.d.ts.map +1 -0
- package/dist/scaffolding/utils/fs.js +45 -0
- package/dist/scaffolding/utils/resolve-para-version.d.ts +7 -0
- package/dist/scaffolding/utils/resolve-para-version.d.ts.map +1 -0
- package/dist/scaffolding/utils/resolve-para-version.js +21 -0
- package/dist/validation/auth-methods.d.ts +14 -0
- package/dist/validation/auth-methods.d.ts.map +1 -0
- package/dist/validation/auth-methods.js +23 -0
- package/dist/validation/cidr.d.ts +11 -0
- package/dist/validation/cidr.d.ts.map +1 -0
- package/dist/validation/cidr.js +35 -0
- package/dist/validation/hex-color.d.ts +7 -0
- package/dist/validation/hex-color.d.ts.map +1 -0
- package/dist/validation/hex-color.js +10 -0
- package/dist/validation/index.d.ts +9 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +49 -0
- package/dist/validation/native-passkey.d.ts +31 -0
- package/dist/validation/native-passkey.d.ts.map +1 -0
- package/dist/validation/native-passkey.js +45 -0
- package/dist/validation/session-length.d.ts +18 -0
- package/dist/validation/session-length.d.ts.map +1 -0
- package/dist/validation/session-length.js +30 -0
- package/dist/validation/url.d.ts +26 -0
- package/dist/validation/url.d.ts.map +1 -0
- package/dist/validation/url.js +50 -0
- package/dist/validation/wallet-types.d.ts +14 -0
- package/dist/validation/wallet-types.d.ts.map +1 -0
- package/dist/validation/wallet-types.js +22 -0
- package/dist/validation/webhook.d.ts +4 -0
- package/dist/validation/webhook.d.ts.map +1 -0
- package/dist/validation/webhook.js +33 -0
- package/package.json +60 -0
- package/templates/expo/_env.example +3 -0
- package/templates/expo/_gitignore +48 -0
- package/templates/expo/_yarnrc.yml +1 -0
- package/templates/expo/app/(auth)/_layout.tsx +12 -0
- package/templates/expo/app/(auth)/index.tsx.template +86 -0
- package/templates/expo/app/(tabs)/_layout.tsx +16 -0
- package/templates/expo/app/(tabs)/index.tsx +112 -0
- package/templates/expo/app/(tabs)/send.tsx +111 -0
- package/templates/expo/app/_layout.tsx +17 -0
- package/templates/expo/app/index.tsx +22 -0
- package/templates/expo/app.json.template +32 -0
- package/templates/expo/assets/adaptive-icon.png +0 -0
- package/templates/expo/assets/favicon.png +0 -0
- package/templates/expo/assets/icon.png +0 -0
- package/templates/expo/assets/splash.png +0 -0
- package/templates/expo/babel.config.cjs +12 -0
- package/templates/expo/components/features/AuthForm.tsx.template +138 -0
- package/templates/expo/components/features/OAuthButtons.tsx.template +27 -0
- package/templates/expo/components/features/index.ts.template +4 -0
- package/templates/expo/components/ui/Button.tsx +58 -0
- package/templates/expo/components/ui/Card.tsx +11 -0
- package/templates/expo/components/ui/Divider.tsx +19 -0
- package/templates/expo/components/ui/Input.tsx +23 -0
- package/templates/expo/components/ui/WalletCard.tsx +44 -0
- package/templates/expo/components/ui/index.ts +5 -0
- package/templates/expo/eslint.config.cjs +15 -0
- package/templates/expo/global.css +3 -0
- package/templates/expo/hooks/useOneClickLogin.ts.template +161 -0
- package/templates/expo/hooks/useViemClient.ts +118 -0
- package/templates/expo/hooks/useWallets.ts +52 -0
- package/templates/expo/index.js +2 -0
- package/templates/expo/lib/auth.ts +54 -0
- package/templates/expo/lib/constants.ts.template +2 -0
- package/templates/expo/lib/para.ts +14 -0
- package/templates/expo/metro.config.cjs +14 -0
- package/templates/expo/nativewind-env.d.ts +2 -0
- package/templates/expo/prettier.config.cjs +10 -0
- package/templates/expo/providers/ParaProvider.tsx +140 -0
- package/templates/expo/tailwind.config.cjs +23 -0
- package/templates/expo/tsconfig.json +11 -0
- package/templates/expo/types/index.ts +28 -0
- package/templates/nextjs/README.md +69 -0
- package/templates/nextjs/_env.example +8 -0
- package/templates/nextjs/_gitignore +36 -0
- package/templates/nextjs/_yarnrc.yml +1 -0
- package/templates/nextjs/eslint.config.mjs +10 -0
- package/templates/nextjs/next.config.ts +5 -0
- package/templates/nextjs/postcss.config.mjs +7 -0
- package/templates/nextjs/public/para.svg +3 -0
- package/templates/nextjs/src/app/layout.tsx +30 -0
- package/templates/nextjs/src/app/page.tsx +40 -0
- package/templates/nextjs/src/components/ParaProvider.tsx +116 -0
- package/templates/nextjs/src/components/layout/Header.tsx +44 -0
- package/templates/nextjs/src/components/ui/ConnectCard.tsx +24 -0
- package/templates/nextjs/src/components/ui/SignMessage.tsx +53 -0
- package/templates/nextjs/src/components/ui/WalletInfo.tsx +22 -0
- package/templates/nextjs/src/hooks/useSignHelloWorld.ts +23 -0
- package/templates/nextjs/src/styles/globals.css +1 -0
- package/templates/nextjs/tsconfig.json +27 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readFile } from "./file-system.js";
|
|
2
|
+
const CODE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts", ".cjs", ".cts", ".vue", ".svelte"];
|
|
3
|
+
function isCodeFile(file) {
|
|
4
|
+
return CODE_EXTENSIONS.some((ext) => file.endsWith(ext));
|
|
5
|
+
}
|
|
6
|
+
function getCodeFiles(files, shouldIgnore) {
|
|
7
|
+
return files.filter((f) => !shouldIgnore(f) && isCodeFile(f));
|
|
8
|
+
}
|
|
9
|
+
function getLineNumber(content, index) {
|
|
10
|
+
return content.substring(0, index).split("\n").length;
|
|
11
|
+
}
|
|
12
|
+
function escapeRegex(str) {
|
|
13
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14
|
+
}
|
|
15
|
+
async function findImportInFiles(files, importPath, shouldIgnore) {
|
|
16
|
+
const relevantFiles = getCodeFiles(files, shouldIgnore);
|
|
17
|
+
for (const file of relevantFiles) {
|
|
18
|
+
const content = await readFile(file);
|
|
19
|
+
if (!content) continue;
|
|
20
|
+
const patterns = [
|
|
21
|
+
new RegExp(`import\\s+[^;]*['"]${escapeRegex(importPath)}['"]`, "g"),
|
|
22
|
+
new RegExp(`import\\s*['"]${escapeRegex(importPath)}['"]`, "g"),
|
|
23
|
+
new RegExp(`require\\s*\\(\\s*['"]${escapeRegex(importPath)}['"]\\s*\\)`, "g")
|
|
24
|
+
];
|
|
25
|
+
for (const pattern of patterns) {
|
|
26
|
+
const match = pattern.exec(content);
|
|
27
|
+
if (match) {
|
|
28
|
+
return { file, line: getLineNumber(content, match.index) };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
async function findPatternInFiles(files, pattern, shouldIgnore) {
|
|
35
|
+
const locations = [];
|
|
36
|
+
const relevantFiles = getCodeFiles(files, shouldIgnore);
|
|
37
|
+
for (const file of relevantFiles) {
|
|
38
|
+
const content = await readFile(file);
|
|
39
|
+
if (!content) continue;
|
|
40
|
+
const flags = pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g";
|
|
41
|
+
const globalPattern = new RegExp(pattern.source, flags);
|
|
42
|
+
const matches = Array.from(content.matchAll(globalPattern));
|
|
43
|
+
for (const match of matches) {
|
|
44
|
+
if (match.index !== void 0) {
|
|
45
|
+
locations.push({ file, line: getLineNumber(content, match.index) });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return locations;
|
|
50
|
+
}
|
|
51
|
+
async function fileContainsPattern(filePath, pattern) {
|
|
52
|
+
const content = await readFile(filePath);
|
|
53
|
+
if (!content) {
|
|
54
|
+
return { found: false };
|
|
55
|
+
}
|
|
56
|
+
const match = pattern.exec(content);
|
|
57
|
+
if (match && match.index !== void 0) {
|
|
58
|
+
return { found: true, line: getLineNumber(content, match.index) };
|
|
59
|
+
}
|
|
60
|
+
return { found: false };
|
|
61
|
+
}
|
|
62
|
+
async function fileStartsWithDirective(filePath, directive) {
|
|
63
|
+
const content = await readFile(filePath);
|
|
64
|
+
if (!content) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const lines = content.split("\n");
|
|
68
|
+
let nonEmptyCount = 0;
|
|
69
|
+
for (const line of lines) {
|
|
70
|
+
const trimmed = line.trim();
|
|
71
|
+
if (!trimmed) continue;
|
|
72
|
+
nonEmptyCount++;
|
|
73
|
+
if (nonEmptyCount > 5) break;
|
|
74
|
+
if (trimmed === `"${directive}";` || trimmed === `'${directive}';` || trimmed === `"${directive}"` || trimmed === `'${directive}'`) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
async function findFilesWithPattern(files, pattern, shouldIgnore) {
|
|
81
|
+
const matchingFiles = [];
|
|
82
|
+
const relevantFiles = getCodeFiles(files, shouldIgnore);
|
|
83
|
+
for (const file of relevantFiles) {
|
|
84
|
+
const content = await readFile(file);
|
|
85
|
+
if (!content) continue;
|
|
86
|
+
if (pattern.test(content)) {
|
|
87
|
+
matchingFiles.push(file);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return matchingFiles;
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
fileContainsPattern,
|
|
94
|
+
fileStartsWithDirective,
|
|
95
|
+
findFilesWithPattern,
|
|
96
|
+
findImportInFiles,
|
|
97
|
+
findPatternInFiles
|
|
98
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
2
|
+
export declare function readFile(filePath: string): Promise<string | null>;
|
|
3
|
+
export declare function readGitignore(projectRoot: string): Promise<string | null>;
|
|
4
|
+
export declare function findProjectFiles(projectRoot: string, shouldIgnore: (file: string) => boolean): Promise<string[]>;
|
|
5
|
+
export declare function findEnvFiles(projectRoot: string): Promise<string[]>;
|
|
6
|
+
export declare function findFilesWithExtension(projectRoot: string, extensions: string[], shouldIgnore: (file: string) => boolean): Promise<string[]>;
|
|
7
|
+
//# sourceMappingURL=file-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/utils/file-system.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMvE;AAED,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE/E;AAED,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBtH;AAED,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBzE;AAED,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAAE,EACpB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACtC,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { glob } from "glob";
|
|
4
|
+
async function pathExists(filePath) {
|
|
5
|
+
try {
|
|
6
|
+
await fs.access(filePath);
|
|
7
|
+
return true;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
async function readFile(filePath) {
|
|
13
|
+
try {
|
|
14
|
+
return await fs.readFile(filePath, "utf-8");
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function readGitignore(projectRoot) {
|
|
20
|
+
return readFile(path.join(projectRoot, ".gitignore"));
|
|
21
|
+
}
|
|
22
|
+
async function findProjectFiles(projectRoot, shouldIgnore) {
|
|
23
|
+
const patterns = ["**/*.{ts,tsx,js,jsx,vue,svelte}", "**/.env*", "**/package.json"];
|
|
24
|
+
const allFiles = [];
|
|
25
|
+
for (const pattern of patterns) {
|
|
26
|
+
const files = await glob(pattern, {
|
|
27
|
+
cwd: projectRoot,
|
|
28
|
+
absolute: true,
|
|
29
|
+
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
30
|
+
dot: true
|
|
31
|
+
});
|
|
32
|
+
allFiles.push(...files);
|
|
33
|
+
}
|
|
34
|
+
const uniqueFiles = [...new Set(allFiles)];
|
|
35
|
+
return uniqueFiles.filter((f) => !shouldIgnore(f));
|
|
36
|
+
}
|
|
37
|
+
async function findEnvFiles(projectRoot) {
|
|
38
|
+
const envFileNames = [
|
|
39
|
+
".env",
|
|
40
|
+
".env.local",
|
|
41
|
+
".env.development",
|
|
42
|
+
".env.development.local",
|
|
43
|
+
".env.production",
|
|
44
|
+
".env.production.local",
|
|
45
|
+
".env.example"
|
|
46
|
+
];
|
|
47
|
+
const existingFiles = [];
|
|
48
|
+
for (const fileName of envFileNames) {
|
|
49
|
+
const filePath = path.join(projectRoot, fileName);
|
|
50
|
+
if (await pathExists(filePath)) {
|
|
51
|
+
existingFiles.push(filePath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return existingFiles;
|
|
55
|
+
}
|
|
56
|
+
async function findFilesWithExtension(projectRoot, extensions, shouldIgnore) {
|
|
57
|
+
const pattern = `**/*.{${extensions.join(",")}}`;
|
|
58
|
+
const files = await glob(pattern, {
|
|
59
|
+
cwd: projectRoot,
|
|
60
|
+
absolute: true,
|
|
61
|
+
ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"]
|
|
62
|
+
});
|
|
63
|
+
return files.filter((f) => !shouldIgnore(f));
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
findEnvFiles,
|
|
67
|
+
findFilesWithExtension,
|
|
68
|
+
findProjectFiles,
|
|
69
|
+
pathExists,
|
|
70
|
+
readFile,
|
|
71
|
+
readGitignore
|
|
72
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PackageJsonData, PackageManager } from '../types.js';
|
|
2
|
+
export declare function readPackageJson(projectRoot: string): Promise<PackageJsonData | null>;
|
|
3
|
+
export declare function getAllDependencies(packageJson: PackageJsonData): Record<string, string>;
|
|
4
|
+
export declare function getParaPackages(packageJson: PackageJsonData): Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function hasDependency(packageJson: PackageJsonData, depName: string): boolean;
|
|
9
|
+
export declare function getDependencyVersion(packageJson: PackageJsonData, depName: string): string | null;
|
|
10
|
+
export declare function getInstallCommand(pm: PackageManager): string;
|
|
11
|
+
export declare function getRemoveCommand(pm: PackageManager): string;
|
|
12
|
+
//# sourceMappingURL=package-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/utils/package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnE,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAa1F;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKvF;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,eAAe,GAAG,KAAK,CAAC;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAMD;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpF;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGjG;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAI5D;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAI3D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { readFile } from "./file-system.js";
|
|
3
|
+
async function readPackageJson(projectRoot) {
|
|
4
|
+
const pkgPath = path.join(projectRoot, "package.json");
|
|
5
|
+
const content = await readFile(pkgPath);
|
|
6
|
+
if (!content) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(content);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function getAllDependencies(packageJson) {
|
|
16
|
+
return {
|
|
17
|
+
...packageJson.dependencies,
|
|
18
|
+
...packageJson.devDependencies
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function getParaPackages(packageJson) {
|
|
22
|
+
const deps = getAllDependencies(packageJson);
|
|
23
|
+
return Object.entries(deps).filter(([name]) => name.startsWith("@getpara/")).map(([name, version]) => ({ name, version }));
|
|
24
|
+
}
|
|
25
|
+
function hasDependency(packageJson, depName) {
|
|
26
|
+
const deps = getAllDependencies(packageJson);
|
|
27
|
+
return depName in deps;
|
|
28
|
+
}
|
|
29
|
+
function getDependencyVersion(packageJson, depName) {
|
|
30
|
+
const deps = getAllDependencies(packageJson);
|
|
31
|
+
return deps[depName] ?? null;
|
|
32
|
+
}
|
|
33
|
+
function getInstallCommand(pm) {
|
|
34
|
+
if (pm === "yarn") return "yarn add";
|
|
35
|
+
if (pm === "pnpm") return "pnpm add";
|
|
36
|
+
return "npm install";
|
|
37
|
+
}
|
|
38
|
+
function getRemoveCommand(pm) {
|
|
39
|
+
if (pm === "yarn") return "yarn remove";
|
|
40
|
+
if (pm === "pnpm") return "pnpm remove";
|
|
41
|
+
return "npm uninstall";
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
getAllDependencies,
|
|
45
|
+
getDependencyVersion,
|
|
46
|
+
getInstallCommand,
|
|
47
|
+
getParaPackages,
|
|
48
|
+
getRemoveCommand,
|
|
49
|
+
hasDependency,
|
|
50
|
+
readPackageJson
|
|
51
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { handleError } from "./core/error-handler.js";
|
|
3
|
+
process.on("SIGINT", () => {
|
|
4
|
+
process.exit(130);
|
|
5
|
+
});
|
|
6
|
+
process.on("SIGTERM", () => {
|
|
7
|
+
process.exit(143);
|
|
8
|
+
});
|
|
9
|
+
process.on("unhandledRejection", (error) => {
|
|
10
|
+
handleError(error);
|
|
11
|
+
});
|
|
12
|
+
async function main() {
|
|
13
|
+
try {
|
|
14
|
+
const { cli } = await import("./cli.js");
|
|
15
|
+
await cli(process.argv);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
handleError(error);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
void main();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Column } from './table.js';
|
|
2
|
+
interface FormatterOptions {
|
|
3
|
+
json: boolean;
|
|
4
|
+
quiet: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class OutputFormatter {
|
|
7
|
+
private readonly opts;
|
|
8
|
+
private jsonOutput;
|
|
9
|
+
constructor(opts: FormatterOptions);
|
|
10
|
+
success(message: string): void;
|
|
11
|
+
error(message: string): void;
|
|
12
|
+
warn(message: string): void;
|
|
13
|
+
info(message: string): void;
|
|
14
|
+
log(message: string): void;
|
|
15
|
+
table(columns: Column[], rows: Record<string, string>[]): void;
|
|
16
|
+
detail(entries: Array<{
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
mask?: boolean;
|
|
20
|
+
}>): void;
|
|
21
|
+
json(data: unknown): void;
|
|
22
|
+
flush(): void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIzC,UAAU,gBAAgB;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qBAAa,eAAe;IAGd,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,UAAU,CAAiB;gBAEN,IAAI,EAAE,gBAAgB;IAEnD,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM9B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM1B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI;IAe9D,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI;IAkB9E,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAIzB,KAAK,IAAI,IAAI;CAMd"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
import { renderTable } from "./table.js";
|
|
3
|
+
import { maskSecret } from "./mask.js";
|
|
4
|
+
class OutputFormatter {
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
this.opts = opts;
|
|
7
|
+
}
|
|
8
|
+
jsonOutput = null;
|
|
9
|
+
success(message) {
|
|
10
|
+
if (this.opts.quiet) return;
|
|
11
|
+
if (this.opts.json) return;
|
|
12
|
+
console.log(pc.green(`${message}`));
|
|
13
|
+
}
|
|
14
|
+
error(message) {
|
|
15
|
+
if (this.opts.json) return;
|
|
16
|
+
console.error(pc.red(`${message}`));
|
|
17
|
+
}
|
|
18
|
+
warn(message) {
|
|
19
|
+
if (this.opts.quiet) return;
|
|
20
|
+
if (this.opts.json) return;
|
|
21
|
+
console.warn(pc.yellow(`${message}`));
|
|
22
|
+
}
|
|
23
|
+
info(message) {
|
|
24
|
+
if (this.opts.quiet) return;
|
|
25
|
+
if (this.opts.json) return;
|
|
26
|
+
console.log(pc.dim(message));
|
|
27
|
+
}
|
|
28
|
+
log(message) {
|
|
29
|
+
if (this.opts.quiet) return;
|
|
30
|
+
if (this.opts.json) return;
|
|
31
|
+
console.log(message);
|
|
32
|
+
}
|
|
33
|
+
table(columns, rows) {
|
|
34
|
+
if (this.opts.json) {
|
|
35
|
+
this.jsonOutput = rows.map((row) => {
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const col of columns) {
|
|
38
|
+
result[col.key] = col.mask ? maskSecret(row[col.key] ?? "") : row[col.key] ?? "";
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this.opts.quiet) return;
|
|
45
|
+
console.log(renderTable(columns, rows));
|
|
46
|
+
}
|
|
47
|
+
detail(entries) {
|
|
48
|
+
if (this.opts.json) {
|
|
49
|
+
const result = {};
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
result[entry.label] = entry.mask ? maskSecret(entry.value) : entry.value;
|
|
52
|
+
}
|
|
53
|
+
this.jsonOutput = result;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (this.opts.quiet) return;
|
|
57
|
+
const maxLabelLen = Math.max(...entries.map((e) => e.label.length));
|
|
58
|
+
for (const entry of entries) {
|
|
59
|
+
const label = pc.bold(entry.label.padEnd(maxLabelLen));
|
|
60
|
+
const value = entry.mask ? maskSecret(entry.value) : entry.value;
|
|
61
|
+
console.log(` ${label} ${value}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
json(data) {
|
|
65
|
+
this.jsonOutput = data;
|
|
66
|
+
}
|
|
67
|
+
flush() {
|
|
68
|
+
if (this.opts.json && this.jsonOutput !== null) {
|
|
69
|
+
console.log(JSON.stringify(this.jsonOutput, null, 2));
|
|
70
|
+
this.jsonOutput = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
OutputFormatter
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../src/output/mask.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYhD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const KNOWN_PREFIXES = ["sk_prod_", "sk_beta_", "sk_sandbox_", "sk_dev_", "pk_"];
|
|
2
|
+
function maskSecret(value) {
|
|
3
|
+
if (!value || value.length < 8) return "****";
|
|
4
|
+
for (const prefix of KNOWN_PREFIXES) {
|
|
5
|
+
if (value.startsWith(prefix)) {
|
|
6
|
+
const suffix2 = value.slice(-4);
|
|
7
|
+
return `${prefix}****...${suffix2}`;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const suffix = value.slice(-4);
|
|
11
|
+
return `****...${suffix}`;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
maskSecret
|
|
15
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
export declare function setNonInteractive(enabled: boolean): void;
|
|
3
|
+
export declare function isNonInteractive(): boolean;
|
|
4
|
+
export declare function confirm(message: string): Promise<boolean>;
|
|
5
|
+
export declare function text(message: string, opts?: {
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
initialValue?: string;
|
|
9
|
+
validate?: (value: string) => string | undefined;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
export declare function select<T extends string>(message: string, options: Array<{
|
|
12
|
+
value: T;
|
|
13
|
+
label: string;
|
|
14
|
+
hint?: string;
|
|
15
|
+
}>): Promise<T>;
|
|
16
|
+
export declare function multiselect<T extends string>(message: string, options: Array<{
|
|
17
|
+
value: T;
|
|
18
|
+
label: string;
|
|
19
|
+
hint?: string;
|
|
20
|
+
}>, opts?: {
|
|
21
|
+
required?: boolean;
|
|
22
|
+
initialValues?: T[];
|
|
23
|
+
}): Promise<T[]>;
|
|
24
|
+
export { p };
|
|
25
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/output/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAMpC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExD;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AASD,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ/D;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;IACL,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAClD,GACA,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED,wBAAsB,MAAM,CAAC,CAAC,SAAS,MAAM,EAC3C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACzD,OAAO,CAAC,CAAC,CAAC,CAcZ;AAED,wBAAsB,WAAW,CAAC,CAAC,SAAS,MAAM,EAChD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAC1D,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAA;CAAE,GACjD,OAAO,CAAC,CAAC,EAAE,CAAC,CAiBd;AAED,OAAO,EAAE,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import { CliError } from "../core/error-handler.js";
|
|
3
|
+
import { ExitCode } from "../core/constants.js";
|
|
4
|
+
let _nonInteractive = false;
|
|
5
|
+
function setNonInteractive(enabled) {
|
|
6
|
+
_nonInteractive = enabled;
|
|
7
|
+
}
|
|
8
|
+
function isNonInteractive() {
|
|
9
|
+
return _nonInteractive;
|
|
10
|
+
}
|
|
11
|
+
function requireInteractive(promptName) {
|
|
12
|
+
throw new CliError(
|
|
13
|
+
`"${promptName}" prompt requires interactive input. Run without --no-input or outside CI to continue.`,
|
|
14
|
+
ExitCode.USAGE_ERROR
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
async function confirm(message) {
|
|
18
|
+
if (_nonInteractive) return false;
|
|
19
|
+
const result = await p.confirm({ message });
|
|
20
|
+
if (p.isCancel(result)) {
|
|
21
|
+
p.cancel("Operation cancelled.");
|
|
22
|
+
process.exit(ExitCode.INTERRUPTED);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
async function text(message, opts) {
|
|
27
|
+
if (_nonInteractive) {
|
|
28
|
+
if (opts?.defaultValue !== void 0) return opts.defaultValue;
|
|
29
|
+
if (opts?.initialValue !== void 0) return opts.initialValue;
|
|
30
|
+
requireInteractive(message);
|
|
31
|
+
}
|
|
32
|
+
const result = await p.text({
|
|
33
|
+
message,
|
|
34
|
+
placeholder: opts?.placeholder,
|
|
35
|
+
defaultValue: opts?.defaultValue,
|
|
36
|
+
initialValue: opts?.initialValue,
|
|
37
|
+
validate: opts?.validate
|
|
38
|
+
});
|
|
39
|
+
if (p.isCancel(result)) {
|
|
40
|
+
p.cancel("Operation cancelled.");
|
|
41
|
+
process.exit(ExitCode.INTERRUPTED);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
async function select(message, options) {
|
|
46
|
+
if (_nonInteractive) {
|
|
47
|
+
if (options.length > 0) return options[0].value;
|
|
48
|
+
requireInteractive(message);
|
|
49
|
+
}
|
|
50
|
+
const result = await p.select({
|
|
51
|
+
message,
|
|
52
|
+
options
|
|
53
|
+
});
|
|
54
|
+
if (p.isCancel(result)) {
|
|
55
|
+
p.cancel("Operation cancelled.");
|
|
56
|
+
process.exit(ExitCode.INTERRUPTED);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
async function multiselect(message, options, opts) {
|
|
61
|
+
if (_nonInteractive) {
|
|
62
|
+
if (opts?.initialValues?.length) return opts.initialValues;
|
|
63
|
+
if (options.length > 0) return [options[0].value];
|
|
64
|
+
requireInteractive(message);
|
|
65
|
+
}
|
|
66
|
+
const result = await p.multiselect({
|
|
67
|
+
message,
|
|
68
|
+
options,
|
|
69
|
+
required: opts?.required,
|
|
70
|
+
initialValues: opts?.initialValues
|
|
71
|
+
});
|
|
72
|
+
if (p.isCancel(result)) {
|
|
73
|
+
p.cancel("Operation cancelled.");
|
|
74
|
+
process.exit(ExitCode.INTERRUPTED);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
confirm,
|
|
80
|
+
isNonInteractive,
|
|
81
|
+
multiselect,
|
|
82
|
+
p,
|
|
83
|
+
select,
|
|
84
|
+
setNonInteractive,
|
|
85
|
+
text
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/output/spinner.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa;eAG89F,CAAC;cAAiC,CAAC,cAAc,CAAC;iBAAoC,CAAC;EADjlG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/output/table.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CA2BrF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
function renderTable(columns, rows) {
|
|
3
|
+
if (rows.length === 0) return " No items found.";
|
|
4
|
+
const widths = columns.map((col) => {
|
|
5
|
+
const headerLen = col.header.length;
|
|
6
|
+
const maxDataLen = Math.max(...rows.map((row) => (row[col.key] ?? "").length), 0);
|
|
7
|
+
return col.width ?? Math.max(headerLen, maxDataLen);
|
|
8
|
+
});
|
|
9
|
+
const header = columns.map((col, i) => pc.bold(col.header.padEnd(widths[i]))).join(" ");
|
|
10
|
+
const separator = widths.map((w) => "-".repeat(w)).join(" ");
|
|
11
|
+
const dataRows = rows.map(
|
|
12
|
+
(row) => columns.map((col, i) => {
|
|
13
|
+
const val = row[col.key] ?? "";
|
|
14
|
+
return col.align === "right" ? val.padStart(widths[i]) : val.padEnd(widths[i]);
|
|
15
|
+
}).join(" ")
|
|
16
|
+
);
|
|
17
|
+
return [" " + header, " " + separator, ...dataRows.map((r) => " " + r)].join("\n");
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
renderTable
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffolder.d.ts","sourceRoot":"","sources":["../../src/scaffolding/scaffolder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAkC,MAAM,YAAY,CAAC;AAWjF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBpE"}
|