@getpara/create-para-app 0.6.0 → 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 (142) hide show
  1. package/README.md +71 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +306 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +7 -48
  9. package/dist/index.js.map +1 -0
  10. package/dist/package-builder.d.ts +13 -0
  11. package/dist/package-builder.d.ts.map +1 -0
  12. package/dist/package-builder.js +89 -0
  13. package/dist/package-builder.js.map +1 -0
  14. package/dist/post-scaffold.d.ts +3 -0
  15. package/dist/post-scaffold.d.ts.map +1 -0
  16. package/dist/post-scaffold.js +64 -0
  17. package/dist/post-scaffold.js.map +1 -0
  18. package/dist/prompt-orchestrator.d.ts +3 -0
  19. package/dist/prompt-orchestrator.d.ts.map +1 -0
  20. package/dist/prompt-orchestrator.js +198 -0
  21. package/dist/prompt-orchestrator.js.map +1 -0
  22. package/dist/scaffolder.d.ts +3 -0
  23. package/dist/scaffolder.d.ts.map +1 -0
  24. package/dist/scaffolder.js +82 -0
  25. package/dist/scaffolder.js.map +1 -0
  26. package/dist/template-registry.d.ts +12 -0
  27. package/dist/template-registry.d.ts.map +1 -0
  28. package/dist/template-registry.js +29 -0
  29. package/dist/template-registry.js.map +1 -0
  30. package/dist/template-renderer.d.ts +11 -0
  31. package/dist/template-renderer.d.ts.map +1 -0
  32. package/dist/template-renderer.js +133 -0
  33. package/dist/template-renderer.js.map +1 -0
  34. package/dist/template-strategies/expo-template.d.ts +18 -0
  35. package/dist/template-strategies/expo-template.d.ts.map +1 -0
  36. package/dist/template-strategies/expo-template.js +173 -0
  37. package/dist/template-strategies/expo-template.js.map +1 -0
  38. package/dist/template-strategies/index.d.ts +4 -0
  39. package/dist/template-strategies/index.d.ts.map +1 -0
  40. package/dist/template-strategies/index.js +3 -0
  41. package/dist/template-strategies/index.js.map +1 -0
  42. package/dist/template-strategies/nextjs-template.d.ts +12 -0
  43. package/dist/template-strategies/nextjs-template.d.ts.map +1 -0
  44. package/dist/template-strategies/nextjs-template.js +123 -0
  45. package/dist/template-strategies/nextjs-template.js.map +1 -0
  46. package/dist/types.d.ts +67 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +16 -0
  49. package/dist/types.js.map +1 -0
  50. package/dist/utils/fs.d.ts +11 -0
  51. package/dist/utils/fs.d.ts.map +1 -0
  52. package/dist/utils/fs.js +38 -0
  53. package/dist/utils/fs.js.map +1 -0
  54. package/dist/utils/logger.d.ts +10 -0
  55. package/dist/utils/logger.d.ts.map +1 -0
  56. package/dist/utils/logger.js +25 -19
  57. package/dist/utils/logger.js.map +1 -0
  58. package/package.json +35 -30
  59. package/templates/expo/_env.example +3 -0
  60. package/templates/expo/_gitignore +48 -0
  61. package/templates/expo/_yarnrc.yml +1 -0
  62. package/templates/expo/app/(auth)/_layout.tsx +12 -0
  63. package/templates/expo/app/(auth)/index.tsx.template +86 -0
  64. package/templates/expo/app/(tabs)/_layout.tsx +16 -0
  65. package/templates/expo/app/(tabs)/index.tsx +112 -0
  66. package/templates/expo/app/(tabs)/send.tsx +111 -0
  67. package/templates/expo/app/_layout.tsx +17 -0
  68. package/templates/expo/app/index.tsx +22 -0
  69. package/templates/expo/app.json.template +32 -0
  70. package/templates/expo/assets/adaptive-icon.png +0 -0
  71. package/templates/expo/assets/favicon.png +0 -0
  72. package/templates/expo/assets/icon.png +0 -0
  73. package/templates/expo/assets/splash.png +0 -0
  74. package/templates/expo/babel.config.cjs +12 -0
  75. package/templates/expo/components/features/AuthForm.tsx.template +138 -0
  76. package/templates/expo/components/features/OAuthButtons.tsx.template +27 -0
  77. package/templates/expo/components/features/index.ts.template +4 -0
  78. package/templates/expo/components/ui/Button.tsx +58 -0
  79. package/templates/expo/components/ui/Card.tsx +11 -0
  80. package/templates/expo/components/ui/Divider.tsx +19 -0
  81. package/templates/expo/components/ui/Input.tsx +23 -0
  82. package/templates/expo/components/ui/WalletCard.tsx +44 -0
  83. package/templates/expo/components/ui/index.ts +5 -0
  84. package/templates/expo/eslint.config.cjs +15 -0
  85. package/templates/expo/global.css +3 -0
  86. package/templates/expo/hooks/useOneClickLogin.ts.template +161 -0
  87. package/templates/expo/hooks/useViemClient.ts +118 -0
  88. package/templates/expo/hooks/useWallets.ts +52 -0
  89. package/templates/expo/index.js +2 -0
  90. package/templates/expo/lib/auth.ts +54 -0
  91. package/templates/expo/lib/constants.ts.template +2 -0
  92. package/templates/expo/lib/para.ts +13 -0
  93. package/templates/expo/metro.config.cjs +14 -0
  94. package/templates/expo/nativewind-env.d.ts +2 -0
  95. package/templates/expo/prettier.config.cjs +10 -0
  96. package/templates/expo/providers/ParaProvider.tsx +140 -0
  97. package/templates/expo/tailwind.config.cjs +23 -0
  98. package/templates/expo/tsconfig.json +11 -0
  99. package/templates/expo/types/index.ts +28 -0
  100. package/templates/nextjs/README.md +69 -0
  101. package/templates/nextjs/_env.example +8 -0
  102. package/templates/nextjs/_gitignore +36 -0
  103. package/templates/nextjs/_yarnrc.yml +1 -0
  104. package/templates/nextjs/next.config.ts +5 -0
  105. package/templates/nextjs/postcss.config.mjs +7 -0
  106. package/templates/nextjs/public/para.svg +3 -0
  107. package/templates/nextjs/src/app/layout.tsx +30 -0
  108. package/templates/nextjs/src/app/page.tsx +40 -0
  109. package/templates/nextjs/src/components/ParaProvider.tsx +116 -0
  110. package/templates/nextjs/src/components/layout/Header.tsx +44 -0
  111. package/templates/nextjs/src/components/ui/ConnectCard.tsx +24 -0
  112. package/templates/nextjs/src/components/ui/SignMessage.tsx +53 -0
  113. package/templates/nextjs/src/components/ui/WalletInfo.tsx +22 -0
  114. package/templates/nextjs/src/hooks/useSignHelloWorld.ts +23 -0
  115. package/templates/nextjs/src/styles/globals.css +1 -0
  116. package/templates/nextjs/tsconfig.json +27 -0
  117. package/dist/bin/index.js +0 -2
  118. package/dist/commands/scaffold.js +0 -137
  119. package/dist/integrations/codeGenerators.js +0 -637
  120. package/dist/integrations/packageJsonHelpers.js +0 -77
  121. package/dist/integrations/sdkSetup.js +0 -24
  122. package/dist/integrations/sdkSetupNextjs.js +0 -111
  123. package/dist/integrations/sdkSetupVite.js +0 -82
  124. package/dist/package.json +0 -44
  125. package/dist/prompts/interactive.js +0 -98
  126. package/dist/src/commands/scaffold.js +0 -157
  127. package/dist/src/index.js +0 -48
  128. package/dist/src/integrations/codeGenerators.js +0 -633
  129. package/dist/src/integrations/packageJsonHelpers.js +0 -77
  130. package/dist/src/integrations/sdkSetup.js +0 -24
  131. package/dist/src/integrations/sdkSetupNextjs.js +0 -111
  132. package/dist/src/integrations/sdkSetupVite.js +0 -82
  133. package/dist/src/prompts/interactive.js +0 -98
  134. package/dist/src/templates/nextjs.js +0 -68
  135. package/dist/src/templates/vite-react.js +0 -52
  136. package/dist/src/utils/exec.js +0 -16
  137. package/dist/src/utils/formatting.js +0 -31
  138. package/dist/src/utils/logger.js +0 -19
  139. package/dist/templates/nextjs.js +0 -61
  140. package/dist/templates/vite-react.js +0 -43
  141. package/dist/utils/exec.js +0 -16
  142. package/dist/utils/formatting.js +0 -31
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ interface ConnectCardProps {
4
+ onConnect: () => void;
5
+ }
6
+
7
+ export function ConnectCard({ onConnect }: ConnectCardProps) {
8
+ return (
9
+ <div className="max-w-md mx-auto text-center">
10
+ <div className="border border-gray-200 rounded-none p-8">
11
+ <h2 className="text-xl font-semibold mb-4">Connect Your Wallet</h2>
12
+ <p className="text-gray-600 mb-6">
13
+ Connect your wallet to sign messages and interact with the app.
14
+ </p>
15
+ <button
16
+ onClick={onConnect}
17
+ data-testid="auth-connect-button"
18
+ className="w-full px-6 py-3 text-white bg-black rounded-none hover:bg-gray-800 transition-colors font-medium">
19
+ Connect with Para
20
+ </button>
21
+ </div>
22
+ </div>
23
+ );
24
+ }
@@ -0,0 +1,53 @@
1
+ "use client";
2
+
3
+ interface SignMessageProps {
4
+ message: string;
5
+ onSign: () => void;
6
+ isPending: boolean;
7
+ error: Error | null;
8
+ signature?: string;
9
+ }
10
+
11
+ export function SignMessage({
12
+ message,
13
+ onSign,
14
+ isPending,
15
+ error,
16
+ signature,
17
+ }: SignMessageProps) {
18
+ return (
19
+ <div className="rounded-none border border-gray-200">
20
+ <div className="px-6 py-3 bg-gray-50 border-b border-gray-200">
21
+ <h3 className="text-sm font-medium text-gray-900">Sign Message</h3>
22
+ </div>
23
+ <div className="p-6">
24
+ <div className="mb-4">
25
+ <p className="text-sm text-gray-500 mb-1">Message to sign</p>
26
+ <p className="text-lg font-mono text-gray-900">{message}</p>
27
+ </div>
28
+
29
+ <button
30
+ onClick={onSign}
31
+ disabled={isPending}
32
+ className="w-full px-4 py-2 text-white bg-black rounded-none hover:bg-gray-800 transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed font-medium">
33
+ {isPending ? "Signing..." : "Sign Message"}
34
+ </button>
35
+
36
+ {error && (
37
+ <div className="mt-4 p-3 bg-red-50 border border-red-200 rounded-none">
38
+ <p className="text-sm text-red-600">{error.message}</p>
39
+ </div>
40
+ )}
41
+
42
+ {signature && (
43
+ <div className="mt-4">
44
+ <p className="text-sm text-gray-500 mb-1">Signature</p>
45
+ <p className="text-xs font-mono text-gray-900 break-all bg-gray-50 p-3 rounded-none">
46
+ {signature}
47
+ </p>
48
+ </div>
49
+ )}
50
+ </div>
51
+ </div>
52
+ );
53
+ }
@@ -0,0 +1,22 @@
1
+ "use client";
2
+
3
+ import { useWallet } from "@getpara/react-sdk";
4
+
5
+ export function WalletInfo() {
6
+ const { data: wallet } = useWallet();
7
+ const address = wallet?.address;
8
+
9
+ return (
10
+ <div className="mb-8 rounded-none border border-gray-200">
11
+ <div className="px-6 py-3 bg-gray-50 border-b border-gray-200">
12
+ <h3 className="text-sm font-medium text-gray-900">Connected Wallet</h3>
13
+ </div>
14
+ <div className="px-6 py-3">
15
+ <p className="text-sm text-gray-500">Address</p>
16
+ <p className="text-lg font-medium text-gray-900 font-mono">
17
+ {address?.slice(0, 6)}...{address?.slice(-4)}
18
+ </p>
19
+ </div>
20
+ </div>
21
+ );
22
+ }
@@ -0,0 +1,23 @@
1
+ import { useWallet, useSignMessage } from "@getpara/react-sdk";
2
+
3
+ const HELLO_WORLD_MESSAGE = "Hello World!";
4
+
5
+ export function useSignHelloWorld() {
6
+ const { data: wallet } = useWallet();
7
+ const signMessage = useSignMessage();
8
+
9
+ const sign = () =>
10
+ wallet?.id &&
11
+ signMessage.signMessage({
12
+ walletId: wallet.id,
13
+ messageBase64: btoa(HELLO_WORLD_MESSAGE),
14
+ });
15
+
16
+ return {
17
+ sign,
18
+ message: HELLO_WORLD_MESSAGE,
19
+ isPending: signMessage.isPending,
20
+ error: signMessage.error,
21
+ signature: signMessage.data && "signature" in signMessage.data ? signMessage.data.signature : undefined,
22
+ };
23
+ }
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./src/*"]
23
+ }
24
+ },
25
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
+ "exclude": ["node_modules"]
27
+ }
package/dist/bin/index.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import '../src/index.js';
@@ -1,137 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import chalk from 'chalk';
11
- import fs from 'fs-extra';
12
- import { promptInteractive } from '../prompts/interactive.js';
13
- import { scaffoldNextjs } from '../templates/nextjs.js';
14
- import { scaffoldViteReact } from '../templates/vite-react.js';
15
- import { runSDKSetup } from '../integrations/sdkSetup.js';
16
- import { logInfo, logError, logHeader, logSection, logSubsection } from '../utils/logger.js';
17
- function validateOptions(options) {
18
- if ((options === null || options === void 0 ? void 0 : options.template) && !['nextjs', 'vite-react'].includes(options.template)) {
19
- throw new Error(`Invalid template '${options.template}'. Valid templates: nextjs, vite-react.`);
20
- }
21
- if ((options === null || options === void 0 ? void 0 : options.evmSigner) && !['ethers', 'viem'].includes(options.evmSigner)) {
22
- throw new Error(`Invalid EVM signer '${options.evmSigner}'. Valid signers: ethers, viem.`);
23
- }
24
- if (options === null || options === void 0 ? void 0 : options.networks) {
25
- const nets = options.networks.split(',').map(n => n.trim());
26
- for (const network of nets) {
27
- if (!['evm', 'cosmos', 'solana'].includes(network)) {
28
- throw new Error(`Invalid network '${network}'. Valid options: evm, cosmos, solana.`);
29
- }
30
- }
31
- }
32
- }
33
- function cleanupProjectDirectory(projectName) {
34
- if (!projectName)
35
- return;
36
- try {
37
- if (fs.existsSync(projectName)) {
38
- fs.removeSync(projectName);
39
- }
40
- }
41
- catch (_a) { }
42
- }
43
- export default function scaffold(positionalProjectName, options) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- try {
46
- validateOptions(options);
47
- const { projectName: cliProjectName, template: cliTemplate, useLatest, noPrompt, noGit, packageManager, skipDeps, typescript = true, eslint = true, tailwind = true, srcDir = true, app = true, networks, evmSigner, externalWallet, apiKey, } = options || {};
48
- // For rollback reference
49
- const finalProjectName = cliProjectName || positionalProjectName;
50
- let config = {
51
- projectName: finalProjectName || '',
52
- template: cliTemplate || '',
53
- networks: [],
54
- evmSigner: '',
55
- apiKey: apiKey || '',
56
- externalWalletSupport: externalWallet,
57
- useLatest: !!useLatest,
58
- noGit: !!noGit,
59
- packageManager: packageManager || 'yarn',
60
- skipDeps: !!skipDeps,
61
- typescript,
62
- eslint,
63
- tailwind,
64
- srcDir,
65
- app,
66
- };
67
- // Populate networks if provided
68
- if (networks) {
69
- config.networks = networks.split(',').map(n => n.trim());
70
- }
71
- if (evmSigner) {
72
- config.evmSigner = evmSigner;
73
- }
74
- // We'll decide if we must prompt
75
- const needTemplate = !config.template;
76
- const needProjectName = !config.projectName;
77
- const needNetworks = !config.networks.length;
78
- const needEvmSigner = config.networks.includes('evm') && !config.evmSigner;
79
- const needApiKey = !config.apiKey;
80
- const shouldPrompt = !noPrompt && (needTemplate || needProjectName || needNetworks || needEvmSigner || needApiKey);
81
- if (shouldPrompt) {
82
- const answers = yield promptInteractive(config);
83
- config.projectName = answers.projectName || `para-${answers.template}-template`;
84
- config.template = answers.template;
85
- config.networks = answers.networks;
86
- config.evmSigner = answers.evmSigner || (answers.networks.includes('evm') ? 'ethers' : '');
87
- config.apiKey = answers.apiKey;
88
- config.externalWalletSupport = answers.externalWalletSupport;
89
- }
90
- else {
91
- if (!config.projectName) {
92
- const t = cliTemplate || 'nextjs';
93
- config.projectName = `para-${t}-template`;
94
- }
95
- if (!config.template) {
96
- config.template = 'nextjs';
97
- }
98
- if (!config.networks.length) {
99
- config.networks = [];
100
- }
101
- if (!config.evmSigner && config.networks.includes('evm')) {
102
- config.evmSigner = 'ethers';
103
- }
104
- }
105
- if (fs.existsSync(config.projectName)) {
106
- throw new Error(`Project folder '${config.projectName}' already exists. Please remove or choose a different name.`);
107
- }
108
- logHeader(`🚀 Creating a new project named: ${config.projectName}`);
109
- logSection('🔧 Project Configuration:');
110
- logSubsection('Project Type', config.template);
111
- logSubsection('Supported Networks', config.networks.length > 0 ? config.networks.join(', ') : 'None');
112
- if (config.networks.includes('evm')) {
113
- logSubsection('EVM Signer', config.evmSigner);
114
- }
115
- logSubsection('API Key', config.apiKey);
116
- logSubsection('External Wallet Support', config.externalWalletSupport ? 'Enabled' : 'Disabled');
117
- logSubsection('TypeScript', config.typescript ? 'Enabled' : 'Disabled');
118
- logSubsection('ESLint', config.eslint ? 'Enabled' : 'Disabled');
119
- logSubsection('Tailwind', config.tailwind ? 'Enabled' : 'Disabled');
120
- logSubsection('src/ directory', config.srcDir ? 'Enabled' : 'Disabled');
121
- logSubsection('App Router', config.app ? 'Enabled' : 'Disabled');
122
- if (config.template === 'vite-react') {
123
- yield scaffoldViteReact(config);
124
- }
125
- else {
126
- yield scaffoldNextjs(config);
127
- }
128
- yield runSDKSetup(config);
129
- logInfo(chalk.green('✅ Scaffolding complete!'));
130
- }
131
- catch (error) {
132
- logError(`Error: ${error.message || error}`);
133
- cleanupProjectDirectory((options === null || options === void 0 ? void 0 : options.projectName) || positionalProjectName || '');
134
- process.exit(1);
135
- }
136
- });
137
- }