@getpara/create-para-app 0.1.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/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@getpara/create-para-app",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-para-app": "dist/index.js"
8
+ },
9
+ "engines": {
10
+ "node": ">=14.0.0"
11
+ },
12
+ "license": "MIT",
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "start": "node --no-warnings dist/index.js",
16
+ "dev": "node --no-warnings --loader ts-node/esm src/index.ts"
17
+ },
18
+ "dependencies": {
19
+ "chalk": "5.4.1",
20
+ "commander": "13.1.0",
21
+ "execa": "9.5.2",
22
+ "fs-extra": "11.3.0",
23
+ "inquirer": "12.4.1",
24
+ "ora": "8.2.0",
25
+ "prettier": "3.5.0",
26
+ "update-notifier": "7.3.1"
27
+ },
28
+ "devDependencies": {
29
+ "@types/chalk": "^2.2.4",
30
+ "@types/commander": "^2.12.5",
31
+ "@types/inquirer": "^9.0.7",
32
+ "@types/jest": "^29.5.14",
33
+ "@types/node": "^22.13.1",
34
+ "@types/update-notifier": "6.0.8",
35
+ "@types/fs-extra": "11.0.4",
36
+ "jest": "^29.7.0",
37
+ "ts-jest": "^29.2.5",
38
+ "ts-node": "^10.9.2",
39
+ "typescript": "^5.7.3"
40
+ }
41
+ }
@@ -0,0 +1,196 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs-extra';
3
+ import { promptInteractive } from '../prompts/interactive.js';
4
+ import { scaffoldNextjs } from '../templates/nextjs.js';
5
+ import { scaffoldViteReact } from '../templates/vite-react.js';
6
+ import { runSDKSetup } from '../integrations/sdkSetup.js';
7
+ import { logInfo, logError, logHeader, logSection, logSubsection } from '../utils/logger.js';
8
+
9
+ interface ScaffoldOptions {
10
+ projectName?: string;
11
+ template?: string;
12
+ useLatest?: boolean;
13
+ noPrompt?: boolean;
14
+ noGit?: boolean;
15
+ packageManager?: string;
16
+ skipDeps?: boolean;
17
+ typescript?: boolean;
18
+ eslint?: boolean;
19
+ tailwind?: boolean;
20
+ srcDir?: boolean;
21
+ app?: boolean;
22
+
23
+ networks?: string;
24
+ evmSigner?: string;
25
+ externalWallet?: boolean;
26
+ apiKey?: string;
27
+ }
28
+
29
+ interface ScaffoldConfig {
30
+ projectName: string;
31
+ template: string;
32
+ networks: string[];
33
+ evmSigner?: string;
34
+ apiKey: string;
35
+ externalWalletSupport: boolean;
36
+ useLatest: boolean;
37
+ noGit: boolean;
38
+ packageManager: string;
39
+ skipDeps: boolean;
40
+ typescript: boolean;
41
+ eslint: boolean;
42
+ tailwind: boolean;
43
+ srcDir: boolean;
44
+ app: boolean;
45
+ }
46
+
47
+ function validateOptions(options?: ScaffoldOptions) {
48
+ if (options?.template && !['nextjs', 'vite-react'].includes(options.template)) {
49
+ throw new Error(`Invalid template '${options.template}'. Valid templates: nextjs, vite-react.`);
50
+ }
51
+
52
+ if (options?.evmSigner && !['ethers', 'viem'].includes(options.evmSigner)) {
53
+ throw new Error(`Invalid EVM signer '${options.evmSigner}'. Valid signers: ethers, viem.`);
54
+ }
55
+
56
+ if (options?.networks) {
57
+ const nets = options.networks.split(',').map(n => n.trim());
58
+ for (const network of nets) {
59
+ if (!['evm', 'cosmos', 'solana'].includes(network)) {
60
+ throw new Error(`Invalid network '${network}'. Valid options: evm, cosmos, solana.`);
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ function cleanupProjectDirectory(projectName: string) {
67
+ if (!projectName) return;
68
+ try {
69
+ if (fs.existsSync(projectName)) {
70
+ fs.removeSync(projectName);
71
+ }
72
+ } catch {}
73
+ }
74
+
75
+ export default async function scaffold(positionalProjectName?: string, options?: ScaffoldOptions) {
76
+ try {
77
+ validateOptions(options);
78
+
79
+ const {
80
+ projectName: cliProjectName,
81
+ template: cliTemplate,
82
+ useLatest,
83
+ noPrompt,
84
+ noGit,
85
+ packageManager,
86
+ skipDeps,
87
+ typescript = true,
88
+ eslint = true,
89
+ tailwind = true,
90
+ srcDir = true,
91
+ app = true,
92
+ networks,
93
+ evmSigner,
94
+ externalWallet,
95
+ apiKey,
96
+ } = options || {};
97
+
98
+ // For rollback reference
99
+ const finalProjectName = cliProjectName || positionalProjectName;
100
+
101
+ let config: ScaffoldConfig = {
102
+ projectName: finalProjectName || '',
103
+ template: cliTemplate || '',
104
+ networks: [],
105
+ evmSigner: '',
106
+ apiKey: apiKey || '',
107
+ externalWalletSupport: externalWallet,
108
+ useLatest: !!useLatest,
109
+ noGit: !!noGit,
110
+ packageManager: packageManager || 'yarn',
111
+ skipDeps: !!skipDeps,
112
+ typescript,
113
+ eslint,
114
+ tailwind,
115
+ srcDir,
116
+ app,
117
+ };
118
+
119
+ // Populate networks if provided
120
+ if (networks) {
121
+ config.networks = networks.split(',').map(n => n.trim());
122
+ }
123
+ if (evmSigner) {
124
+ config.evmSigner = evmSigner;
125
+ }
126
+
127
+ // We'll decide if we must prompt
128
+ const needTemplate = !config.template;
129
+ const needProjectName = !config.projectName;
130
+ const needNetworks = !config.networks.length;
131
+ const needEvmSigner = config.networks.includes('evm') && !config.evmSigner;
132
+ const needApiKey = !config.apiKey;
133
+
134
+ const shouldPrompt = !noPrompt && (needTemplate || needProjectName || needNetworks || needEvmSigner || needApiKey);
135
+
136
+ if (shouldPrompt) {
137
+ const answers = await promptInteractive(config);
138
+
139
+ config.projectName = answers.projectName || `para-${answers.template}-template`;
140
+ config.template = answers.template;
141
+ config.networks = answers.networks;
142
+ config.evmSigner = answers.evmSigner || (answers.networks.includes('evm') ? 'ethers' : '');
143
+ config.apiKey = answers.apiKey;
144
+ config.externalWalletSupport = answers.externalWalletSupport;
145
+ } else {
146
+ if (!config.projectName) {
147
+ const t = cliTemplate || 'nextjs';
148
+ config.projectName = `para-${t}-template`;
149
+ }
150
+ if (!config.template) {
151
+ config.template = 'nextjs';
152
+ }
153
+ if (!config.networks.length) {
154
+ config.networks = [];
155
+ }
156
+ if (!config.evmSigner && config.networks.includes('evm')) {
157
+ config.evmSigner = 'ethers';
158
+ }
159
+ }
160
+
161
+ if (fs.existsSync(config.projectName)) {
162
+ throw new Error(`Project folder '${config.projectName}' already exists. Please remove or choose a different name.`);
163
+ }
164
+
165
+ logHeader(`🚀 Creating a new project named: ${config.projectName}`);
166
+ logSection('🔧 Project Configuration:');
167
+ logSubsection('Project Type', config.template);
168
+ logSubsection('Supported Networks', config.networks.length > 0 ? config.networks.join(', ') : 'None');
169
+ if (config.networks.includes('evm')) {
170
+ logSubsection('EVM Signer', config.evmSigner);
171
+ }
172
+ logSubsection('API Key', config.apiKey);
173
+ logSubsection('External Wallet Support', config.externalWalletSupport ? 'Enabled' : 'Disabled');
174
+ logSubsection('TypeScript', config.typescript ? 'Enabled' : 'Disabled');
175
+ logSubsection('ESLint', config.eslint ? 'Enabled' : 'Disabled');
176
+ logSubsection('Tailwind', config.tailwind ? 'Enabled' : 'Disabled');
177
+ logSubsection('src/ directory', config.srcDir ? 'Enabled' : 'Disabled');
178
+ logSubsection('App Router', config.app ? 'Enabled' : 'Disabled');
179
+
180
+ if (config.template === 'vite-react') {
181
+ await scaffoldViteReact(config);
182
+ } else {
183
+ await scaffoldNextjs(config);
184
+ }
185
+
186
+ await runSDKSetup(config);
187
+
188
+ logInfo(chalk.green('✅ Scaffolding complete!'));
189
+ } catch (error: any) {
190
+ logError(`Error: ${error.message || error}`);
191
+
192
+ cleanupProjectDirectory(options?.projectName || positionalProjectName || '');
193
+
194
+ process.exit(1);
195
+ }
196
+ }
package/src/index.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { program } from 'commander';
2
+ import updateNotifier from 'update-notifier';
3
+ import pkg from '../package.json' assert { type: 'json' };
4
+ import scaffold from './commands/scaffold.js';
5
+
6
+ updateNotifier({ pkg }).notify();
7
+
8
+ program
9
+ .name('create-para-app')
10
+ .description('CLI tool for scaffolding new apps with Para SDKs')
11
+ .version(pkg.version)
12
+ .usage('[projectName] [options]')
13
+ .helpOption('--help', 'Display help for command');
14
+
15
+ program
16
+ .argument('[projectName]')
17
+ .description('Scaffold a new app with specified template and features')
18
+ .option('--template <template>', 'Specify the template: nextjs or vite-react')
19
+ .option('--use-latest', 'Use the latest version of the underlying framework')
20
+ .option('--no-prompt', 'Skip interactive prompts')
21
+ .option('--no-git', 'Disable git initialization')
22
+ .option('--package-manager <pm>', 'Specify package manager: npm, yarn, bun, pnpm', 'yarn')
23
+ .option('--skip-deps', 'Skip dependency installation')
24
+ .option('--typescript', 'Enable TypeScript (default: enabled)', true)
25
+ .option('--no-typescript', 'Disable TypeScript')
26
+ .option('--eslint', 'Enable ESLint (default: enabled)', true)
27
+ .option('--no-eslint', 'Disable ESLint')
28
+ .option('--tailwind', 'Enable Tailwind CSS (default: enabled)', true)
29
+ .option('--no-tailwind', 'Disable Tailwind CSS')
30
+ .option('--src-dir', 'Use src/ directory (default: enabled)', true)
31
+ .option('--no-src-dir', 'Disable src/ directory')
32
+ .option('--app', 'Use the App Router (default: enabled)', true)
33
+ .option('--no-app', 'Disable App Router')
34
+ .option('--networks <list>', 'Comma separated networks: "evm,cosmos,solana"')
35
+ .option('--evm-signer <signer>', 'Specify EVM signer: "ethers" or "viem"')
36
+ .option('--external-wallet', 'Enable external wallet support (default: false)')
37
+ .option('--api-key <key>', 'Provide your API key to skip prompt')
38
+ .option('--project-name <name>', 'Explicitly set project name to skip name prompt')
39
+ .action(async (projectName, options) => {
40
+ await scaffold(projectName, options);
41
+ });
42
+
43
+ program.parse(process.argv);