@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.
@@ -0,0 +1,77 @@
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 fs from 'fs-extra';
11
+ import path from 'path';
12
+ const EVM_DEPS = ['@getpara/evm-wallet-connectors', '@tanstack/react-query', 'wagmi', '@getpara/react-sdk'];
13
+ const SOLANA_DEPS = [
14
+ '@getpara/react-sdk',
15
+ '@getpara/solana-wallet-connectors',
16
+ '@solana-mobile/wallet-adapter-mobile',
17
+ '@solana/wallet-adapter-base',
18
+ '@solana/wallet-adapter-react',
19
+ '@solana/wallet-adapter-walletconnect',
20
+ '@solana/web3.js',
21
+ '@tanstack/react-query',
22
+ ];
23
+ const COSMOS_DEPS = [
24
+ '@getpara/core-sdk',
25
+ '@getpara/cosmos-wallet-connectors',
26
+ '@getpara/graz',
27
+ '@getpara/react-sdk',
28
+ '@getpara/user-management-client',
29
+ '@cosmjs/cosmwasm-stargate',
30
+ '@cosmjs/launchpad',
31
+ '@cosmjs/proto-signing',
32
+ '@cosmjs/stargate',
33
+ '@cosmjs/tendermint-rpc',
34
+ '@leapwallet/cosmos-social-login-capsule-provider',
35
+ 'long',
36
+ 'starknet',
37
+ ];
38
+ const BASE_DEPS = ['@getpara/react-sdk'];
39
+ export function updatePackageJsonDependencies(projectName, networks, externalWalletSupport) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const pkgPath = path.join(projectName, 'package.json');
42
+ const exists = yield fs.pathExists(pkgPath);
43
+ if (!exists) {
44
+ return;
45
+ }
46
+ const pkgData = yield fs.readJSON(pkgPath);
47
+ pkgData.dependencies = pkgData.dependencies || {};
48
+ if (!externalWalletSupport) {
49
+ BASE_DEPS.forEach(dep => {
50
+ pkgData.dependencies[dep] = pkgData.dependencies[dep] || 'latest';
51
+ });
52
+ }
53
+ else {
54
+ if (networks.includes('evm')) {
55
+ EVM_DEPS.forEach(dep => {
56
+ pkgData.dependencies[dep] = pkgData.dependencies[dep] || 'latest';
57
+ });
58
+ }
59
+ if (networks.includes('solana')) {
60
+ SOLANA_DEPS.forEach(dep => {
61
+ pkgData.dependencies[dep] = pkgData.dependencies[dep] || 'latest';
62
+ });
63
+ }
64
+ if (networks.includes('cosmos')) {
65
+ COSMOS_DEPS.forEach(dep => {
66
+ pkgData.dependencies[dep] = pkgData.dependencies[dep] || 'latest';
67
+ });
68
+ }
69
+ if (!networks.includes('evm') && !networks.includes('solana') && !networks.includes('cosmos')) {
70
+ BASE_DEPS.forEach(dep => {
71
+ pkgData.dependencies[dep] = pkgData.dependencies[dep] || 'latest';
72
+ });
73
+ }
74
+ }
75
+ yield fs.writeJSON(pkgPath, pkgData, { spaces: 2 });
76
+ });
77
+ }
@@ -0,0 +1,24 @@
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 { logInfo } from '../utils/logger.js';
11
+ import { sdkSetupNextjs } from './sdkSetupNextjs.js';
12
+ import { sdkSetupVite } from './sdkSetupVite.js';
13
+ export function runSDKSetup(config) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const { projectName, template } = config;
16
+ logInfo(`🔌 Integrating Para SDK into project ${projectName}...`);
17
+ if (template === 'vite-react') {
18
+ yield sdkSetupVite(config);
19
+ }
20
+ else {
21
+ yield sdkSetupNextjs(config);
22
+ }
23
+ });
24
+ }
@@ -0,0 +1,111 @@
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 fs from 'fs-extra';
11
+ import path from 'path';
12
+ import { logHeader, logSection, logSubsection, logStep } from '../utils/logger.js';
13
+ import { formatWithPrettier } from '../utils/formatting.js';
14
+ import { updatePackageJsonDependencies } from './packageJsonHelpers.js';
15
+ import { getEnvFileContent, getParaClientCode, getWalletProviderCodeNextjs, getHelloParaFile, getHomeFile, getStylesNonTailwind, } from './codeGenerators.js';
16
+ export function sdkSetupNextjs(config) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { projectName, networks, evmSigner, apiKey, noTypescript, noAppRouter, noSrcDir, externalWalletSupport, tailwind, app, } = config;
19
+ const envContent = getEnvFileContent(apiKey, true);
20
+ const envPath = path.join(projectName, '.env');
21
+ yield fs.outputFile(envPath, envContent);
22
+ const clientDir = path.join(projectName, 'src', 'client');
23
+ yield fs.ensureDir(clientDir);
24
+ const paraClient = getParaClientCode(true, !noTypescript);
25
+ {
26
+ const filePath = path.join(clientDir, `para.${noTypescript ? 'js' : 'ts'}`);
27
+ const formatted = yield formatWithPrettier(paraClient, filePath);
28
+ yield fs.outputFile(filePath, formatted);
29
+ }
30
+ if (externalWalletSupport) {
31
+ const compDir = path.join(projectName, 'src', 'components');
32
+ yield fs.ensureDir(compDir);
33
+ const results = getWalletProviderCodeNextjs(networks, noAppRouter);
34
+ for (const r of results) {
35
+ const fileExt = noTypescript ? 'jsx' : 'tsx';
36
+ const filePath = path.join(compDir, `${r.fileName}.${fileExt}`);
37
+ const formatted = yield formatWithPrettier(r.code, filePath);
38
+ yield fs.outputFile(filePath, formatted);
39
+ }
40
+ }
41
+ const componentsDir = path.join(projectName, 'src', 'components');
42
+ yield fs.ensureDir(componentsDir);
43
+ const helloParaCode = getHelloParaFile(!!tailwind, !noTypescript, true);
44
+ {
45
+ const filePath = path.join(componentsDir, `HelloPara.${noTypescript ? 'jsx' : 'tsx'}`);
46
+ const formatted = yield formatWithPrettier(helloParaCode, filePath);
47
+ yield fs.outputFile(filePath, formatted);
48
+ }
49
+ const homeCode = getHomeFile(!!tailwind, !noTypescript, !!externalWalletSupport);
50
+ let mainPath = '';
51
+ if (noAppRouter) {
52
+ if (noSrcDir) {
53
+ mainPath = path.join(projectName, 'pages', `index.${noTypescript ? 'jsx' : 'tsx'}`);
54
+ }
55
+ else {
56
+ mainPath = path.join(projectName, 'src', 'pages', `index.${noTypescript ? 'jsx' : 'tsx'}`);
57
+ }
58
+ }
59
+ else {
60
+ if (noSrcDir) {
61
+ mainPath = path.join(projectName, 'app', `page.${noTypescript ? 'jsx' : 'tsx'}`);
62
+ }
63
+ else {
64
+ mainPath = path.join(projectName, 'src', 'app', `page.${noTypescript ? 'jsx' : 'tsx'}`);
65
+ }
66
+ }
67
+ const formattedHome = yield formatWithPrettier(homeCode, mainPath);
68
+ yield fs.writeFile(mainPath, formattedHome);
69
+ let cssFilePath = '';
70
+ if (tailwind) {
71
+ if (app) {
72
+ cssFilePath = path.join(projectName, 'src', 'app', 'globals.css');
73
+ }
74
+ else {
75
+ cssFilePath = path.join(projectName, 'styles', 'globals.css');
76
+ }
77
+ if (!(yield fs.pathExists(cssFilePath))) {
78
+ yield fs.outputFile(cssFilePath, '');
79
+ }
80
+ }
81
+ else {
82
+ if (app) {
83
+ cssFilePath = path.join(projectName, 'src', 'app', 'globals.css');
84
+ }
85
+ else {
86
+ cssFilePath = path.join(projectName, 'src', 'global.css');
87
+ }
88
+ if (!(yield fs.pathExists(cssFilePath))) {
89
+ yield fs.outputFile(cssFilePath, '');
90
+ }
91
+ const stylesContent = getStylesNonTailwind();
92
+ const existing = yield fs.readFile(cssFilePath, 'utf-8');
93
+ const appended = `${existing.trim()}\n\n${stylesContent}`;
94
+ const formattedStyles = yield formatWithPrettier(appended, cssFilePath);
95
+ yield fs.writeFile(cssFilePath, formattedStyles);
96
+ }
97
+ yield updatePackageJsonDependencies(projectName, networks, externalWalletSupport);
98
+ logSection('🛠 Configuration Details:');
99
+ logSubsection('Project Type', 'nextjs');
100
+ logSubsection('Supported Networks', networks.join(', ') || 'None');
101
+ if (networks.includes('evm')) {
102
+ logSubsection('EVM Signer', evmSigner);
103
+ }
104
+ logSubsection('API Key', apiKey);
105
+ logSection('➡️ Next Steps:');
106
+ logStep(`1. cd ${projectName}`);
107
+ logStep(`2. Install dependencies if skipped (e.g., "yarn install" or "npm install")`);
108
+ logStep(`3. Refer to https://docs.getpara.com/integration-guides/create-para-app for further instructions.`);
109
+ logHeader('✅ SDK integration complete with ParaModal usage.');
110
+ });
111
+ }
@@ -0,0 +1,82 @@
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 fs from 'fs-extra';
11
+ import path from 'path';
12
+ import { logHeader, logSection, logSubsection, logStep, logInfo } from '../utils/logger.js';
13
+ import { formatWithPrettier } from '../utils/formatting.js';
14
+ import { updatePackageJsonDependencies } from './packageJsonHelpers.js';
15
+ import { getEnvFileContent, getParaClientCode, getWalletProviderCodeVite, getHelloParaFile, getHomeFile, getStylesNonTailwind, } from './codeGenerators.js';
16
+ export function sdkSetupVite(config) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { projectName, networks, evmSigner, apiKey, noTypescript, noSrcDir, externalWalletSupport, tailwind } = config;
19
+ const envContent = getEnvFileContent(apiKey, false);
20
+ const envPath = path.join(projectName, '.env');
21
+ yield fs.outputFile(envPath, envContent);
22
+ const clientDir = path.join(projectName, 'src', 'client');
23
+ yield fs.ensureDir(clientDir);
24
+ const paraClient = getParaClientCode(false, !noTypescript);
25
+ {
26
+ const filePath = path.join(clientDir, `para.${noTypescript ? 'js' : 'ts'}`);
27
+ const formatted = yield formatWithPrettier(paraClient, filePath);
28
+ yield fs.outputFile(filePath, formatted);
29
+ }
30
+ if (externalWalletSupport) {
31
+ const compDir = path.join(projectName, 'src', 'components');
32
+ yield fs.ensureDir(compDir);
33
+ const providerCode = getWalletProviderCodeVite(networks);
34
+ const filePath = path.join(compDir, `ParaWalletsProvider.${noTypescript ? 'jsx' : 'tsx'}`);
35
+ const formatted = yield formatWithPrettier(providerCode, filePath);
36
+ yield fs.outputFile(filePath, formatted);
37
+ }
38
+ const compDir = path.join(projectName, 'src', 'components');
39
+ yield fs.ensureDir(compDir);
40
+ const helloParaCode = getHelloParaFile(!!tailwind, !noTypescript, false);
41
+ {
42
+ const filePath = path.join(compDir, `HelloPara.${noTypescript ? 'jsx' : 'tsx'}`);
43
+ const formatted = yield formatWithPrettier(helloParaCode, filePath);
44
+ yield fs.outputFile(filePath, formatted);
45
+ }
46
+ const homeCode = getHomeFile(!!tailwind, !noTypescript, !!externalWalletSupport);
47
+ const mainFileDir = noSrcDir ? projectName : path.join(projectName, 'src');
48
+ const mainFilePath = path.join(mainFileDir, `App.${noTypescript ? 'jsx' : 'tsx'}`);
49
+ const exists = yield fs.pathExists(mainFilePath);
50
+ if (!exists) {
51
+ logInfo(`Could not find ${mainFilePath} to replace.`);
52
+ }
53
+ else {
54
+ const formatted = yield formatWithPrettier(homeCode, mainFilePath);
55
+ yield fs.writeFile(mainFilePath, formatted);
56
+ }
57
+ if (!tailwind) {
58
+ const indexCssPath = path.join(projectName, 'src', 'index.css');
59
+ const existsCss = yield fs.pathExists(indexCssPath);
60
+ if (!existsCss) {
61
+ yield fs.outputFile(indexCssPath, '');
62
+ }
63
+ const existing = yield fs.readFile(indexCssPath, 'utf-8');
64
+ const newStyles = `${existing.trim()}\n\n${getStylesNonTailwind()}`;
65
+ const formattedStyles = yield formatWithPrettier(newStyles, indexCssPath);
66
+ yield fs.writeFile(indexCssPath, formattedStyles);
67
+ }
68
+ yield updatePackageJsonDependencies(projectName, networks, externalWalletSupport);
69
+ logSection('🛠 Configuration Details:');
70
+ logSubsection('Project Type', 'vite-react');
71
+ logSubsection('Supported Networks', networks.join(', ') || 'None');
72
+ if (networks.includes('evm')) {
73
+ logSubsection('EVM Signer', evmSigner);
74
+ }
75
+ logSubsection('API Key', apiKey);
76
+ logSection('➡️ Next Steps:');
77
+ logStep(`1. cd ${projectName}`);
78
+ logStep(`2. Install dependencies if skipped (e.g., "yarn install" or "npm install")`);
79
+ logStep(`3. Refer to https://docs.getpara.com/integration-guides/create-para-app for further instructions.`);
80
+ logHeader('✅ SDK integration complete with ParaModal usage.');
81
+ });
82
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "create-para-app",
3
+ "version": "1.0.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 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
+ "update-notifier": "^7.3.1"
26
+ },
27
+ "devDependencies": {
28
+ "@types/chalk": "^2.2.4",
29
+ "@types/commander": "^2.12.5",
30
+ "@types/inquirer": "^9.0.7",
31
+ "@types/jest": "^29.5.14",
32
+ "@types/node": "^22.13.1",
33
+ "@types/update-notifier": "6.0.8",
34
+ "@types/fs-extra": "11.0.4",
35
+ "jest": "^29.7.0",
36
+ "ts-jest": "^29.2.5",
37
+ "ts-node": "^10.9.2",
38
+ "typescript": "^5.7.3"
39
+ }
40
+ }
@@ -0,0 +1,98 @@
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 inquirer from 'inquirer';
11
+ export function promptInteractive(config) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ var _a, _b;
14
+ const template = config.template || 'nextjs';
15
+ const defaultName = config.projectName || `para-${template}-template`;
16
+ const questions = [];
17
+ if (!config.template) {
18
+ questions.push({
19
+ type: 'list',
20
+ name: 'template',
21
+ message: 'Select a project type:',
22
+ choices: ['nextjs', 'vite-react'],
23
+ default: 'nextjs',
24
+ });
25
+ }
26
+ if (!config.projectName) {
27
+ questions.push({
28
+ type: 'input',
29
+ name: 'projectName',
30
+ message: 'Enter your project name:',
31
+ default: answers => {
32
+ const selectedTemplate = answers.template || config.template || 'nextjs';
33
+ return `para-${selectedTemplate}-template`;
34
+ },
35
+ });
36
+ }
37
+ if (!config.networks || !config.networks.length) {
38
+ questions.push({
39
+ type: 'checkbox',
40
+ name: 'networks',
41
+ message: 'Select supported networks:',
42
+ choices: [
43
+ { name: 'EVM', value: 'evm' },
44
+ { name: 'Cosmos', value: 'cosmos' },
45
+ { name: 'Solana', value: 'solana' },
46
+ ],
47
+ });
48
+ }
49
+ if (config.networks && config.networks.includes('evm') && !config.evmSigner) {
50
+ questions.push({
51
+ type: 'list',
52
+ name: 'evmSigner',
53
+ message: 'Select signer for EVM:',
54
+ choices: ['ethers', 'viem'],
55
+ default: 'ethers',
56
+ });
57
+ }
58
+ if (config.externalWalletSupport === undefined) {
59
+ questions.push({
60
+ type: 'confirm',
61
+ name: 'externalWalletSupport',
62
+ message: 'Enable external wallet support?',
63
+ default: false,
64
+ when: answers => {
65
+ const nets = answers.networks || config.networks;
66
+ return Array.isArray(nets) && nets.length > 0;
67
+ },
68
+ });
69
+ }
70
+ if (!config.apiKey) {
71
+ questions.push({
72
+ type: 'input',
73
+ name: 'apiKey',
74
+ message: 'Enter your API key:',
75
+ validate: input => (input ? true : 'API key cannot be empty'),
76
+ });
77
+ }
78
+ if (!questions.length) {
79
+ return {
80
+ projectName: config.projectName || defaultName,
81
+ template,
82
+ networks: config.networks || [],
83
+ evmSigner: config.evmSigner,
84
+ externalWalletSupport: !!config.externalWalletSupport,
85
+ apiKey: config.apiKey || '',
86
+ };
87
+ }
88
+ const answers = yield inquirer.prompt(questions);
89
+ return {
90
+ template: answers.template || template,
91
+ projectName: answers.projectName || config.projectName || defaultName,
92
+ networks: answers.networks || config.networks || [],
93
+ evmSigner: answers.evmSigner || config.evmSigner,
94
+ externalWalletSupport: (_b = (_a = answers.externalWalletSupport) !== null && _a !== void 0 ? _a : config.externalWalletSupport) !== null && _b !== void 0 ? _b : false,
95
+ apiKey: answers.apiKey || config.apiKey || '',
96
+ };
97
+ });
98
+ }
@@ -0,0 +1,43 @@
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 { 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
+ import updateNotifier from 'update-notifier';
17
+ import pkg from '../package.json' assert { type: 'json' };
18
+ console.log('Imported pkg:', pkg);
19
+ updateNotifier({ pkg }).notify();
20
+ program.name('create-para-app').description('CLI tool for scaffolding app projects with our SDKs').version(pkg.version);
21
+ 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!');
42
+ }));
43
+ program.parse(process.argv);
@@ -0,0 +1,61 @@
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 { execCommand } from '../utils/exec.js';
11
+ import { logInfo } from '../utils/logger.js';
12
+ export function scaffoldNextjs(config) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ logInfo(`🔧 Scaffolding Next.js app for project ${config.projectName}...`);
15
+ const versionTag = config.useLatest ? 'latest' : 'latest';
16
+ // Start with these flags for a default Next.js TS, ESLint, Tailwind, src, app setup
17
+ const baseFlags = new Set(['--typescript', '--eslint', '--tailwind', '--src-dir', '--app', '--no-turbopack', '--yes']);
18
+ // If user wants no typescript => remove --typescript, add --javascript
19
+ if (!config.typescript) {
20
+ baseFlags.delete('--typescript');
21
+ baseFlags.add('--javascript');
22
+ }
23
+ if (!config.eslint) {
24
+ baseFlags.delete('--eslint');
25
+ }
26
+ if (!config.tailwind) {
27
+ baseFlags.delete('--tailwind');
28
+ }
29
+ if (!config.srcDir) {
30
+ baseFlags.delete('--src-dir');
31
+ }
32
+ if (!config.app) {
33
+ baseFlags.delete('--app');
34
+ }
35
+ let cmd = `npx create-next-app@${versionTag} ${config.projectName}`;
36
+ for (const f of baseFlags) {
37
+ cmd += ` ${f}`;
38
+ }
39
+ if (config.noGit) {
40
+ cmd += ' --no-git';
41
+ }
42
+ if (config.skipDeps) {
43
+ cmd += ' --skip-install';
44
+ }
45
+ if (config.packageManager && config.packageManager !== 'yarn') {
46
+ if (config.packageManager === 'npm') {
47
+ cmd += ' --use-npm';
48
+ }
49
+ else if (config.packageManager === 'pnpm') {
50
+ cmd += ' --use-pnpm';
51
+ }
52
+ else if (config.packageManager === 'bun') {
53
+ // create-next-app doesn't have a built-in --use-bun, we might skip or log a warning
54
+ logInfo('Warning: create-next-app does not officially support "--use-bun". Using npm instead.');
55
+ cmd += ' --use-npm';
56
+ }
57
+ }
58
+ logInfo(`💻 Executing command: ${cmd}`);
59
+ yield execCommand(cmd);
60
+ });
61
+ }
@@ -0,0 +1,43 @@
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 { execCommand } from '../utils/exec.js';
11
+ import { logInfo } from '../utils/logger.js';
12
+ export function scaffoldViteReact(config) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ logInfo(`🔧 Scaffolding Vite React app for project ${config.projectName}...`);
15
+ const versionTag = config.useLatest ? 'latest' : 'latest';
16
+ const templateName = config.typescript ? 'react-ts' : 'react';
17
+ let cmd = '';
18
+ if (config.packageManager === 'yarn') {
19
+ cmd = `yarn create vite ${config.projectName} --template ${templateName}`;
20
+ }
21
+ else if (config.packageManager === 'npm') {
22
+ cmd = `npm create vite@${versionTag} ${config.projectName} --template ${templateName}`;
23
+ }
24
+ else if (config.packageManager === 'pnpm') {
25
+ cmd = `pnpm dlx create-vite@${versionTag} ${config.projectName} --template ${templateName}`;
26
+ }
27
+ else if (config.packageManager === 'bun') {
28
+ logInfo('Warning: "bun create vite" not officially tested. Using npm create instead.');
29
+ cmd = `npm create vite@${versionTag} ${config.projectName} --template ${templateName}`;
30
+ }
31
+ else {
32
+ cmd = `npm create vite@${versionTag} ${config.projectName} --template ${templateName}`;
33
+ }
34
+ if (config.noGit) {
35
+ cmd += ' --no-git';
36
+ }
37
+ if (config.skipDeps) {
38
+ cmd += ' --skip-install';
39
+ }
40
+ logInfo(`💻 Executing command: ${cmd}`);
41
+ yield execCommand(cmd);
42
+ });
43
+ }
@@ -0,0 +1,16 @@
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 { execa } from 'execa';
11
+ export function execCommand(command) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const [cmd, ...args] = command.split(' ');
14
+ yield execa(cmd, args, { stdio: 'inherit' });
15
+ });
16
+ }
@@ -0,0 +1,31 @@
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 prettier from 'prettier';
11
+ export function formatWithPrettier(code, filePath) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ let parser = 'babel';
14
+ if (filePath.endsWith('.ts')) {
15
+ parser = 'typescript';
16
+ }
17
+ else if (filePath.endsWith('.tsx')) {
18
+ parser = 'babel-ts';
19
+ }
20
+ else if (filePath.endsWith('.js')) {
21
+ parser = 'babel';
22
+ }
23
+ else if (filePath.endsWith('.jsx')) {
24
+ parser = 'babel';
25
+ }
26
+ return prettier.format(code, {
27
+ parser,
28
+ singleQuote: true,
29
+ });
30
+ });
31
+ }
@@ -0,0 +1,19 @@
1
+ import chalk from 'chalk';
2
+ export function logHeader(message) {
3
+ console.log(chalk.bold.magentaBright(`\n${message}\n`));
4
+ }
5
+ export function logSection(message) {
6
+ console.log(chalk.bold.cyanBright(`\n${message}`));
7
+ }
8
+ export function logSubsection(key, value) {
9
+ console.log(chalk.green(`${key}: `) + chalk.white(`${value}`));
10
+ }
11
+ export function logStep(step) {
12
+ console.log(chalk.yellow(step));
13
+ }
14
+ export function logInfo(message) {
15
+ console.log(chalk.cyanBright(`- ${message}`));
16
+ }
17
+ export function logError(message) {
18
+ console.error(chalk.redBright(`❌ ${message}`));
19
+ }