@nishant0121/set-it-up 0.0.1
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/README.md +0 -0
- package/bin/index.js +13 -0
- package/package.json +24 -0
- package/src/engines/reactNative.js +64 -0
- package/src/templates/reactNative/navigation.jsx +39 -0
- package/src/templates/reactNative/navigation.tsx +39 -0
- package/src/utils/checkEnv.js +21 -0
- package/src/wizard.js +50 -0
- package/test_inquirer.js +16 -0
package/README.md
ADDED
|
File without changes
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import { mainWizard } from '../src/wizard.js';
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.version('1.0.0')
|
|
8
|
+
.description('A powerful CLI to forge new projects')
|
|
9
|
+
.action(async () => {
|
|
10
|
+
await mainWizard();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nishant0121/set-it-up",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A high-performance CLI tool to bootstrap and forge new projects with pre-configured templates, prerequisite checking, and interactive setup.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Nishant Patil",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"setup": "bin/index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "^5.6.2",
|
|
17
|
+
"command-exists": "^1.2.9",
|
|
18
|
+
"commander": "^14.0.2",
|
|
19
|
+
"execa": "^9.6.1",
|
|
20
|
+
"fs-extra": "^11.3.3",
|
|
21
|
+
"inquirer": "^13.1.0",
|
|
22
|
+
"ora": "^9.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
export async function setupReactNative(answers, rnAnswers) {
|
|
12
|
+
const spinner = ora('Initializing React Native project...').start();
|
|
13
|
+
try {
|
|
14
|
+
const { projectName, packageManager } = answers;
|
|
15
|
+
const isTypescript = rnAnswers.language === 'TypeScript';
|
|
16
|
+
|
|
17
|
+
// Basic init command using the community CLI for latest version
|
|
18
|
+
const args = ['--yes', '@react-native-community/cli@latest', 'init', projectName, '--skip-install'];
|
|
19
|
+
|
|
20
|
+
await execa('npx', args);
|
|
21
|
+
|
|
22
|
+
// Handle language selection (rename App.tsx to App.jsx if JS is selected)
|
|
23
|
+
const appTsxPath = path.join(projectName, 'App.tsx');
|
|
24
|
+
const appJsxPath = path.join(projectName, 'App.jsx');
|
|
25
|
+
|
|
26
|
+
if (!isTypescript && await fs.pathExists(appTsxPath)) {
|
|
27
|
+
await fs.rename(appTsxPath, appJsxPath);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
spinner.text = 'Installing dependencies...';
|
|
31
|
+
|
|
32
|
+
// Install dependencies using the selected package manager
|
|
33
|
+
await execa(packageManager, ['install'], { cwd: projectName });
|
|
34
|
+
|
|
35
|
+
if (rnAnswers.addNavigation) {
|
|
36
|
+
spinner.text = 'Installing React Navigation...';
|
|
37
|
+
const installCmd = packageManager === 'npm' ? 'install' : 'add';
|
|
38
|
+
const packages = [
|
|
39
|
+
'@react-navigation/native',
|
|
40
|
+
'react-native-screens',
|
|
41
|
+
'react-native-safe-area-context',
|
|
42
|
+
'@react-navigation/native-stack'
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
await execa(packageManager, [installCmd, ...packages], { cwd: projectName });
|
|
46
|
+
|
|
47
|
+
spinner.text = 'Configuring Navigation...';
|
|
48
|
+
|
|
49
|
+
const templateFileName = isTypescript ? 'navigation.tsx' : 'navigation.jsx';
|
|
50
|
+
const templatePath = path.join(__dirname, '..', 'templates', 'reactNative', templateFileName);
|
|
51
|
+
|
|
52
|
+
const content = await fs.readFile(templatePath, 'utf8');
|
|
53
|
+
|
|
54
|
+
const targetPath = isTypescript ? appTsxPath : appJsxPath;
|
|
55
|
+
|
|
56
|
+
await fs.writeFile(targetPath, content);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
spinner.succeed(chalk.green(`Project ${projectName} created successfully! š`));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
spinner.fail('Setup failed.');
|
|
62
|
+
console.error(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, Text, Button } from 'react-native';
|
|
3
|
+
import { NavigationContainer } from '@react-navigation/native';
|
|
4
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
5
|
+
|
|
6
|
+
function HomeScreen({ navigation }) {
|
|
7
|
+
return (
|
|
8
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
|
9
|
+
<Text>Home Screen</Text>
|
|
10
|
+
<Button
|
|
11
|
+
title="Go to Details"
|
|
12
|
+
onPress={() => navigation.navigate('Details')}
|
|
13
|
+
/>
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function DetailsScreen() {
|
|
19
|
+
return (
|
|
20
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
|
21
|
+
<Text>Details Screen</Text>
|
|
22
|
+
</View>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Stack = createNativeStackNavigator();
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<NavigationContainer>
|
|
31
|
+
<Stack.Navigator>
|
|
32
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
33
|
+
<Stack.Screen name="Details" component={DetailsScreen} />
|
|
34
|
+
</Stack.Navigator>
|
|
35
|
+
</NavigationContainer>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default App;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, Text, Button } from 'react-native';
|
|
3
|
+
import { NavigationContainer } from '@react-navigation/native';
|
|
4
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
5
|
+
|
|
6
|
+
function HomeScreen({ navigation }: any) {
|
|
7
|
+
return (
|
|
8
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
|
9
|
+
<Text>Home Screen</Text>
|
|
10
|
+
<Button
|
|
11
|
+
title="Go to Details"
|
|
12
|
+
onPress={() => navigation.navigate('Details')}
|
|
13
|
+
/>
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function DetailsScreen() {
|
|
19
|
+
return (
|
|
20
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
|
21
|
+
<Text>Details Screen</Text>
|
|
22
|
+
</View>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Stack = createNativeStackNavigator();
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<NavigationContainer>
|
|
31
|
+
<Stack.Navigator>
|
|
32
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
33
|
+
<Stack.Screen name="Details" component={DetailsScreen} />
|
|
34
|
+
</Stack.Navigator>
|
|
35
|
+
</NavigationContainer>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default App;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import commandExists from 'command-exists';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
export async function checkPrerequisites(type) {
|
|
5
|
+
const requirements = {
|
|
6
|
+
'React Native': ['node', 'git', 'npm', 'java'],
|
|
7
|
+
'Next.js': ['node', 'git']
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
console.log(chalk.blue('\nš Checking prerequisites...'));
|
|
11
|
+
|
|
12
|
+
for (const cmd of requirements[type]) {
|
|
13
|
+
try {
|
|
14
|
+
await commandExists(cmd);
|
|
15
|
+
console.log(chalk.green(` ā ${cmd} is installed`));
|
|
16
|
+
} catch {
|
|
17
|
+
console.log(chalk.red(` ā ${cmd} is missing. Please install it to continue.`));
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/wizard.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { checkPrerequisites } from './utils/checkEnv.js';
|
|
4
|
+
import { setupReactNative } from './engines/reactNative.js';
|
|
5
|
+
|
|
6
|
+
export async function mainWizard() {
|
|
7
|
+
console.log(chalk.bold.magenta('\nš Welcome to Launchpad - Your Project Forge š ļø\n'));
|
|
8
|
+
|
|
9
|
+
const answers = await inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: 'rawlist',
|
|
12
|
+
name: 'projectType',
|
|
13
|
+
message: 'What do you want to build today?',
|
|
14
|
+
choices: ['React Native', 'Next.js (Coming Soon)', 'Custom GitHub Template'],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'input',
|
|
18
|
+
name: 'projectName',
|
|
19
|
+
message: 'Enter your project name:',
|
|
20
|
+
default: 'my-awesome-app',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'rawlist',
|
|
24
|
+
name: 'packageManager',
|
|
25
|
+
message: 'Select your preferred package manager:',
|
|
26
|
+
choices: ['npm', 'yarn', 'pnpm'],
|
|
27
|
+
}
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
if (answers.projectType === 'React Native') {
|
|
31
|
+
await checkPrerequisites('React Native');
|
|
32
|
+
|
|
33
|
+
// Additional RN specific questions
|
|
34
|
+
const rnAnswers = await inquirer.prompt([
|
|
35
|
+
{
|
|
36
|
+
type: 'rawlist',
|
|
37
|
+
name: 'language',
|
|
38
|
+
message: 'Which language do you want to use?',
|
|
39
|
+
choices: ['TypeScript', 'JavaScript'],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'confirm',
|
|
43
|
+
name: 'addNavigation',
|
|
44
|
+
message: 'Would you like to add React Navigation setup?',
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
await setupReactNative(answers, rnAnswers);
|
|
49
|
+
}
|
|
50
|
+
}
|
package/test_inquirer.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
|
|
3
|
+
console.log('Testing inquirer...');
|
|
4
|
+
try {
|
|
5
|
+
const answers = await inquirer.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: 'list',
|
|
8
|
+
name: 'test',
|
|
9
|
+
message: 'Does this work?',
|
|
10
|
+
choices: ['Yes', 'No'],
|
|
11
|
+
}
|
|
12
|
+
]);
|
|
13
|
+
console.log('Answers:', answers);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error:', error);
|
|
16
|
+
}
|