@getpara/create-para-app 0.1.0 → 0.3.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.
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env ts-node
1
+ #!/usr/bin/env node
2
2
  import '../src/index';
package/dist/package.json CHANGED
@@ -1,28 +1,32 @@
1
1
  {
2
- "name": "create-para-app",
3
- "version": "1.0.0",
4
- "main": "dist/index.js",
2
+ "name": "@getpara/create-para-app",
3
+ "version": "0.2.0",
4
+ "main": "dist/src/index.js",
5
5
  "type": "module",
6
6
  "bin": {
7
- "create-para-app": "dist/index.js"
7
+ "create-para-app": "dist/bin/index.js"
8
8
  },
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "engines": {
10
13
  "node": ">=14.0.0"
11
14
  },
12
15
  "license": "MIT",
13
16
  "scripts": {
14
17
  "build": "tsc",
15
- "start": "node dist/index.js",
18
+ "start": "node --no-warnings dist/bin/index.js",
16
19
  "dev": "node --no-warnings --loader ts-node/esm src/index.ts"
17
20
  },
18
21
  "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
- "update-notifier": "^7.3.1"
22
+ "chalk": "5.4.1",
23
+ "commander": "13.1.0",
24
+ "execa": "9.5.2",
25
+ "fs-extra": "11.3.0",
26
+ "inquirer": "12.4.1",
27
+ "ora": "8.2.0",
28
+ "prettier": "3.5.0",
29
+ "update-notifier": "7.3.1"
26
30
  },
27
31
  "devDependencies": {
28
32
  "@types/chalk": "^2.2.4",
@@ -0,0 +1,137 @@
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
+ }
package/dist/src/index.js CHANGED
@@ -7,37 +7,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import chalk from 'chalk';
11
10
  import { program } from 'commander';
12
- import inquirer from 'inquirer';
13
- import { execa } from 'execa';
14
- import fs from 'fs-extra';
15
- import ora from 'ora';
16
11
  import updateNotifier from 'update-notifier';
17
12
  import pkg from '../package.json' assert { type: 'json' };
18
- console.log('Imported pkg:', pkg);
13
+ import scaffold from './commands/scaffold.js';
19
14
  updateNotifier({ pkg }).notify();
20
- program.name('create-para-app').description('CLI tool for scaffolding app projects with our SDKs').version(pkg.version);
21
15
  program
22
- .command('hello')
23
- .description('Run a hello world command')
24
- .action(() => __awaiter(void 0, void 0, void 0, function* () {
25
- console.log(chalk.green('Hello world from create-para-app!'));
26
- // Prompt user for their name
27
- const answer = yield inquirer.prompt({
28
- type: 'input',
29
- name: 'username',
30
- message: "What's your name?",
31
- });
32
- console.log(`Nice to meet you, ${chalk.blue(answer.username)}!`);
33
- // Execute a sample command using execa
34
- const { stdout } = yield execa('echo', ['Hello from execa']);
35
- console.log(chalk.yellow(stdout));
36
- // Simulate a file operation with fs-extra and show a spinner with ora
37
- const spinner = ora('Simulating file operation with fs-extra...').start();
38
- const tempFile = './temp.txt';
39
- yield fs.writeFile(tempFile, 'Temporary file content');
40
- yield fs.remove(tempFile);
41
- spinner.succeed('File operation completed!');
16
+ .name('create-para-app')
17
+ .description('CLI tool for scaffolding new apps with Para SDKs')
18
+ .version(pkg.version)
19
+ .usage('[projectName] [options]')
20
+ .helpOption('--help', 'Display help for command');
21
+ program
22
+ .argument('[projectName]')
23
+ .description('Scaffold a new app with specified template and features')
24
+ .option('--template <template>', 'Specify the template: nextjs or vite-react')
25
+ .option('--use-latest', 'Use the latest version of the underlying framework')
26
+ .option('--no-prompt', 'Skip interactive prompts')
27
+ .option('--no-git', 'Disable git initialization')
28
+ .option('--package-manager <pm>', 'Specify package manager: npm, yarn, bun, pnpm', 'yarn')
29
+ .option('--skip-deps', 'Skip dependency installation')
30
+ .option('--typescript', 'Enable TypeScript (default: enabled)', true)
31
+ .option('--no-typescript', 'Disable TypeScript')
32
+ .option('--eslint', 'Enable ESLint (default: enabled)', true)
33
+ .option('--no-eslint', 'Disable ESLint')
34
+ .option('--tailwind', 'Enable Tailwind CSS (default: enabled)', true)
35
+ .option('--no-tailwind', 'Disable Tailwind CSS')
36
+ .option('--src-dir', 'Use src/ directory (default: enabled)', true)
37
+ .option('--no-src-dir', 'Disable src/ directory')
38
+ .option('--app', 'Use the App Router (default: enabled)', true)
39
+ .option('--no-app', 'Disable App Router')
40
+ .option('--networks <list>', 'Comma separated networks: "evm,cosmos,solana"')
41
+ .option('--evm-signer <signer>', 'Specify EVM signer: "ethers" or "viem"')
42
+ .option('--external-wallet', 'Enable external wallet support (default: false)')
43
+ .option('--api-key <key>', 'Provide your API key to skip prompt')
44
+ .option('--project-name <name>', 'Explicitly set project name to skip name prompt')
45
+ .action((projectName, options) => __awaiter(void 0, void 0, void 0, function* () {
46
+ yield scaffold(projectName, options);
42
47
  }));
43
48
  program.parse(process.argv);