@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/bin/index.ts +2 -0
- package/dist/commands/scaffold.js +137 -0
- package/dist/index.js +48 -0
- package/dist/integrations/codeGenerators.js +637 -0
- package/dist/integrations/packageJsonHelpers.js +77 -0
- package/dist/integrations/sdkSetup.js +24 -0
- package/dist/integrations/sdkSetupNextjs.js +111 -0
- package/dist/integrations/sdkSetupVite.js +82 -0
- package/dist/package.json +40 -0
- package/dist/prompts/interactive.js +98 -0
- package/dist/src/index.js +43 -0
- package/dist/templates/nextjs.js +61 -0
- package/dist/templates/vite-react.js +43 -0
- package/dist/utils/exec.js +16 -0
- package/dist/utils/formatting.js +31 -0
- package/dist/utils/logger.js +19 -0
- package/package.json +41 -0
- package/src/commands/scaffold.ts +196 -0
- package/src/index.ts +43 -0
- package/src/integrations/codeGenerators.ts +690 -0
- package/src/integrations/packageJsonHelpers.ts +71 -0
- package/src/integrations/sdkSetup.ts +13 -0
- package/src/integrations/sdkSetupNextjs.ts +122 -0
- package/src/integrations/sdkSetupVite.ts +87 -0
- package/src/prompts/interactive.ts +113 -0
- package/src/templates/nextjs.ts +54 -0
- package/src/templates/vite-react.ts +33 -0
- package/src/utils/exec.ts +6 -0
- package/src/utils/formatting.ts +18 -0
- package/src/utils/logger.ts +25 -0
- package/tsconfig.json +18 -0
package/bin/index.ts
ADDED
|
@@ -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/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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 { program } from 'commander';
|
|
11
|
+
import updateNotifier from 'update-notifier';
|
|
12
|
+
import pkg from '../package.json' assert { type: 'json' };
|
|
13
|
+
import scaffold from './commands/scaffold.js';
|
|
14
|
+
updateNotifier({ pkg }).notify();
|
|
15
|
+
program
|
|
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);
|
|
47
|
+
}));
|
|
48
|
+
program.parse(process.argv);
|