create-react-native-init-app 1.0.0 → 1.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 +20 -14
- package/bin/index.js +14 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
# React Native Init App
|
|
1
|
+
# Create React Native Init App
|
|
2
2
|
|
|
3
3
|
Interactive CLI tool to scaffold React Native projects with Clean Architecture.
|
|
4
4
|
|
|
5
|
-
## Installation
|
|
5
|
+
## Installation & Usage
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### The Easiest Way (Automatic)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
npx react-native-init-app
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Using bunx
|
|
9
|
+
You can initialize a new project directly without installing the CLI globally:
|
|
14
10
|
|
|
15
11
|
```bash
|
|
16
|
-
|
|
12
|
+
npm init react-native-init-app
|
|
13
|
+
# or
|
|
14
|
+
bun init react-native-init-app
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
### Using
|
|
17
|
+
### Using npx or bunx
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
|
-
|
|
20
|
+
npx create-react-native-init-app
|
|
21
|
+
# or
|
|
22
|
+
bunx create-react-native-init-app
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Global Installation
|
|
26
|
+
|
|
27
|
+
If you prefer to have the commands available everywhere:
|
|
26
28
|
|
|
27
29
|
```bash
|
|
30
|
+
npm install -g create-react-native-init-app
|
|
31
|
+
|
|
32
|
+
# Now you can use the following commands:
|
|
28
33
|
rnia
|
|
34
|
+
react-native-init-app
|
|
29
35
|
```
|
|
30
36
|
|
|
31
37
|
## Features
|
|
@@ -40,9 +46,9 @@ rnia
|
|
|
40
46
|
|
|
41
47
|
```bash
|
|
42
48
|
# Interactive mode
|
|
43
|
-
npx react-native-init-app
|
|
49
|
+
npx create-react-native-init-app
|
|
44
50
|
|
|
45
|
-
# Short alias
|
|
51
|
+
# Short alias (after global install)
|
|
46
52
|
rnia
|
|
47
53
|
```
|
|
48
54
|
|
package/bin/index.js
CHANGED
|
@@ -36,19 +36,21 @@ Next steps:
|
|
|
36
36
|
${Ig[E].run("start")} # Start Metro bundler
|
|
37
37
|
${Ig[E].run("ios")} # Run on iOS
|
|
38
38
|
${Ig[E].run("android")} # Run on Android
|
|
39
|
-
`}}catch(O){return{success:!1,output:"",error:O instanceof Error?O.message:String(O)}}}var pJA=lJA(import.meta.url),iOA=gc.dirname(pJA),cJA="1.0.
|
|
40
|
-
\u26A1 React Native Init App
|
|
39
|
+
`}}catch(O){return{success:!1,output:"",error:O instanceof Error?O.message:String(O)}}}var pJA=lJA(import.meta.url),iOA=gc.dirname(pJA),cJA="1.0.1",dJA="0.84.0";process.on("SIGINT",()=>{process.exit(0)});var H$=[{label:"Android",script:"clean-android",cleanMessage:"Android build folder cleaned"},{label:"iOS",script:"clean-ios",cleanMessage:"iOS build folder cleaned"},{label:"Node Modules",script:"clean-node",cleanMessage:"Node modules removed",destructive:!0},{label:"Watchman",script:"clean-watch",cleanMessage:"Watchman cache cleared"},{label:"All",script:"scaffold",cleanMessage:"All caches cleaned",destructive:!0}],iJA=["Initializing React Native project...","Cleaning up default files...","Copying template files...","Merging package.json...","Configuring git...","Installing dependencies...","Running pod install..."];function aJA(A){if(!A)return"Project name is required";if(/\s/.test(A))return"Project name cannot contain spaces";if(!/^[a-zA-Z][a-zA-Z0-9]*$/.test(A))return"Project name must start with a letter and contain only letters and numbers";return!0}function nJA(A){if(!A)return"Bundle ID is required";if(!/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/.test(A))return"Invalid bundle ID format (e.g., com.company.myapp)";return!0}function sJA(A){if(!A)return"Directory is required";if(K$.default.existsSync(A)&&K$.default.readdirSync(A).length>0)return"Directory already exists and is not empty";return!0}function tJA(){console.log(BC.cyan(`
|
|
40
|
+
\u26A1 Create React Native Init App
|
|
41
41
|
`)),console.log(BC.dim("Create React Native projects with Clean Architecture\n"))}async function oJA(A){let{confirmed:B}=await e8.default.prompt({type:"confirm",name:"confirmed",message:A,initial:!1});return B}async function Mc(){tJA();let{command:A}=await e8.default.prompt({type:"select",name:"command",message:"Select a command:",choices:[{name:"scaffold",message:"\uD83C\uDD95 Scaffold",hint:"Create new project from template"},{name:"clean",message:"\uD83E\uDDF9 Clean",hint:"Clean caches and build folders"},{name:"pod-install",message:"\uD83D\uDCE6 Pod Install",hint:"Install CocoaPods dependencies"},{name:"run-android",message:"\uD83E\uDD16 Run Android",hint:"Run app on Android device/emulator"},{name:"version",message:"\u2139\uFE0F Version",hint:"Show CLI version and info"},{name:"help",message:"\u2753 Help",hint:"Show available commands"}]});if(A==="version"||A==="help")return{command:A};if(A==="scaffold"){let{projectName:B}=await e8.default.prompt({type:"text",name:"projectName",message:"What is the name of your project?",initial:"MyApp",validate:aJA}),{bundleId:Q}=await e8.default.prompt({type:"text",name:"bundleId",message:"What is the bundle identifier?",initial:`com.company.${B.toLowerCase()}`,validate:nJA}),{directory:C}=await e8.default.prompt({type:"text",name:"directory",message:"Where should the project be created?",initial:gc.resolve(process.cwd(),B),validate:sJA}),{packageManager:E}=await e8.default.prompt({type:"select",name:"packageManager",message:"Which package manager do you want to use?",choices:[{name:"npm",message:"npm"},{name:"yarn",message:"Yarn"},{name:"pnpm",message:"pnpm"},{name:"bun",message:"Bun"}],initial:3}),{installDeps:G}=await e8.default.prompt({type:"confirm",name:"installDeps",message:"Do you want to install dependencies after setup?",initial:!0}),{podInstall:F}=await e8.default.prompt({type:"confirm",name:"podInstall",message:"Do you want to run pod install for iOS? (macOS only)",initial:!0});return{command:A,scaffoldData:{projectName:B,bundleId:Q,directory:C,packageManager:E,installDeps:G,podInstall:F}}}if(A==="clean"){let{cleanOption:B}=await e8.default.prompt({type:"select",name:"cleanOption",message:"\uD83E\uDDF9 What do you want to clean?",choices:H$.map((C)=>({name:C.label,message:C.label+(C.destructive?" \u26A0\uFE0F":"")}))});if(H$.find((C)=>C.label===B)?.destructive){if(!await oJA(`\u26A0\uFE0F This will delete ${B==="All"?"all caches":B}. Are you sure?`))return Mc()}return{command:A,cleanOption:B}}return{command:A}}async function rJA(A,B,Q){try{let C,E=[];switch(A){case"clean":{let F=H$.find((g)=>g.label===B);if(!F)throw new Error("Invalid clean option");if(B==="All")return Q?.(0,4,"Cleaning Android..."),await PJ("npm",["run","clean-android"]),Q?.(1,4,"Cleaning iOS..."),await PJ("npm",["run","clean-ios"]),Q?.(2,4,"Cleaning Node Modules..."),await PJ("npm",["run","clean-node"]),Q?.(3,4,"Cleaning Watchman..."),await PJ("npm",["run","clean-watch"]),Q?.(4,4,"All cleaned!"),{success:!0,output:"\u2705 All caches cleaned successfully!"};C="npm",E=["run",F.script];break}case"pod-install":C="npm",E=["run","pod-install"];break;case"run-android":C="npm",E=["run","android"];break;default:throw new Error("Unknown command")}return{success:!0,output:(await PJ(C,E,{stdio:"inherit",cleanup:!0})).stdout||"\u2705 Command completed successfully!"}}catch(C){return{success:!1,output:`\u274C Error: ${C instanceof Error?C.message:String(C)}`}}}var eJA=({current:A,total:B,label:Q})=>{let C=Math.round(A/B*100),E=Math.round(A/B*20),G=20-E;return aB.default.createElement($C,{flexDirection:"column"},aB.default.createElement($C,null,aB.default.createElement(IC,{color:"cyan"},Q)),aB.default.createElement($C,null,aB.default.createElement(IC,{color:"green"},">".repeat(E)),aB.default.createElement(IC,{color:"gray"},"-".repeat(G)),aB.default.createElement(IC,null," ",C,"%")))},AKA=({steps:A,currentStep:B})=>{return aB.default.createElement($C,{flexDirection:"column",gap:0},A.map((Q,C)=>{let E=C<B,G=C===B;return aB.default.createElement($C,{key:C},aB.default.createElement(IC,{color:"gray"},E?"\u2713":G?"\u2192":" "," ",Q),E&&aB.default.createElement(IC,{color:"green"}," \u2713"),G&&aB.default.createElement(IC,{color:"yellow"}," (in progress...)"))}))},BKA=({command:A,cleanOption:B,scaffoldData:Q})=>{let[C,E]=aB.useState(""),[G,F]=aB.useState("running"),[g,M]=aB.useState(0),[V,_]=aB.useState(1),[w,O]=aB.useState(""),[W,y]=aB.useState(!1),[x,u]=aB.useState(null),c=aB.useCallback((YA,LA,mA)=>{M(YA),_(LA),O(mA)},[]);aB.useEffect(()=>{if(A==="scaffold"&&Q)y(!0),(async()=>{try{let LA=await Uc({projectName:Q.projectName,onProgress:(xA)=>c(0,7,xA)});if(!LA.success){E(`\u274C Failed to download template: ${LA.error}`),F("error");return}u(LA);let mA=await Yc({...Q,templatePath:LA.templatePath,onProgress:c});await Xc(LA.tempDir),E(mA.output),F(mA.success?"success":"error")}catch(LA){E(LA instanceof Error?LA.message:String(LA)),F("error")}})();else if(A==="version")E(`
|
|
42
|
-
\u26A1 React Native Init App
|
|
42
|
+
\u26A1 Create React Native Init App
|
|
43
43
|
Version: ${cJA}
|
|
44
44
|
React Native Template: ${dJA}
|
|
45
45
|
|
|
46
46
|
Usage:
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
npm init react-native-init-app
|
|
48
|
+
bun init react-native-init-app
|
|
49
|
+
npx create-react-native-init-app
|
|
50
|
+
bunx create-react-native-init-app
|
|
49
51
|
rnia
|
|
50
52
|
|
|
51
|
-
Run 'react-native-init-app --help' for more information.
|
|
53
|
+
Run 'create-react-native-init-app --help' for more information.
|
|
52
54
|
`),F("success");else if(A==="help")E(`
|
|
53
55
|
\u26A1 Available Commands:
|
|
54
56
|
|
|
@@ -63,13 +65,14 @@ Run 'react-native-init-app --help' for more information.
|
|
|
63
65
|
\uD83E\uDD16 run-android - Run app on Android device/emulator
|
|
64
66
|
|
|
65
67
|
Usage:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
npm init react-native-init-app
|
|
69
|
+
npx create-react-native-init-app
|
|
70
|
+
bunx create-react-native-init-app
|
|
68
71
|
rnia
|
|
69
72
|
|
|
70
73
|
Examples:
|
|
71
|
-
|
|
72
|
-
bunx react-native-init-app --help
|
|
73
|
-
`),F("success");else rJA(A,B,c).then((YA)=>{E(YA.output),F(YA.success?"success":"error")}).catch((YA)=>{E(YA.message),F("error")})},[A,B,Q,c]);let JA=G==="running"?BC.yellow:G==="success"?BC.green:BC.red,e=G==="running"?"\u23F3 Running":G==="success"?"\u2705 Success":"\u274C Error",GA={scaffold:Q?`Scaffold: ${Q.projectName}`:"Scaffold New Project",clean:B?`Clean ${B}`:"Clean","pod-install":"Pod Install","run-android":"Run Android",version:"Version Info",help:"Help"},IA=A==="scaffold"?iJA:["Processing..."];return aB.default.createElement($C,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:"cyan"},aB.default.createElement($C,null,aB.default.createElement(IC,{bold:!0,color:"cyan"},"\u26A1 React Native Init App")),aB.default.createElement(O1,null),aB.default.createElement($C,null,aB.default.createElement(IC,{color:"gray"},"Command: "),aB.default.createElement(IC,{bold:!0},GA[A])),aB.default.createElement($C,null,aB.default.createElement(IC,{color:"gray"},"Status: "),aB.default.createElement(IC,{color:JA(G)},e)),W&&G==="running"&&aB.default.createElement(aB.default.Fragment,null,aB.default.createElement(O1,null),aB.default.createElement(AKA,{steps:IA,currentStep:g}),aB.default.createElement(O1,null),aB.default.createElement(eJA,{current:g,total:V,label:w})),aB.default.createElement(O1,null),aB.default.createElement($C,{flexDirection:"column"},aB.default.createElement(IC,{bold:!0,color:"gray"},"Output:"),aB.default.createElement($C,{marginTop:1,padding:1,borderStyle:"single",borderColor:"gray"},aB.default.createElement(IC,null,C||(G==="running"?"Processing...":"")))),aB.default.createElement(O1,null),aB.default.createElement(IC,{color:"gray",italic:!0},"Press Ctrl+C to exit"))};async function QKA(){try{let{command:A,cleanOption:B,scaffoldData:Q}=await Mc();process.stdout.write("\n".repeat(50)),console.clear();let{unmount:C}=jz(aB.default.createElement(BKA,{command:A,cleanOption:B,scaffoldData:Q}));process.on("SIGINT",()=>{C(),process.exit(0)})}catch(A){if(A&&typeof A==="object"&&"isCancel"in A&&A.isCancel)BC.yellow(`
|
|
74
|
+
npm init react-native-init-app
|
|
75
|
+
bunx create-react-native-init-app --help
|
|
76
|
+
`),F("success");else rJA(A,B,c).then((YA)=>{E(YA.output),F(YA.success?"success":"error")}).catch((YA)=>{E(YA.message),F("error")})},[A,B,Q,c]);let JA=G==="running"?BC.yellow:G==="success"?BC.green:BC.red,e=G==="running"?"\u23F3 Running":G==="success"?"\u2705 Success":"\u274C Error",GA={scaffold:Q?`Scaffold: ${Q.projectName}`:"Scaffold New Project",clean:B?`Clean ${B}`:"Clean","pod-install":"Pod Install","run-android":"Run Android",version:"Version Info",help:"Help"},IA=A==="scaffold"?iJA:["Processing..."];return aB.default.createElement($C,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:"cyan"},aB.default.createElement($C,null,aB.default.createElement(IC,{bold:!0,color:"cyan"},"\u26A1 Create React Native Init App")),aB.default.createElement(O1,null),aB.default.createElement($C,null,aB.default.createElement(IC,{color:"gray"},"Command: "),aB.default.createElement(IC,{bold:!0},GA[A])),aB.default.createElement($C,null,aB.default.createElement(IC,{color:"gray"},"Status: "),aB.default.createElement(IC,{color:JA(G)},e)),W&&G==="running"&&aB.default.createElement(aB.default.Fragment,null,aB.default.createElement(O1,null),aB.default.createElement(AKA,{steps:IA,currentStep:g}),aB.default.createElement(O1,null),aB.default.createElement(eJA,{current:g,total:V,label:w})),aB.default.createElement(O1,null),aB.default.createElement($C,{flexDirection:"column"},aB.default.createElement(IC,{bold:!0,color:"gray"},"Output:"),aB.default.createElement($C,{marginTop:1,padding:1,borderStyle:"single",borderColor:"gray"},aB.default.createElement(IC,null,C||(G==="running"?"Processing...":"")))),aB.default.createElement(O1,null),aB.default.createElement(IC,{color:"gray",italic:!0},"Press Ctrl+C to exit"))};async function QKA(){try{let{command:A,cleanOption:B,scaffoldData:Q}=await Mc();process.stdout.write("\n".repeat(50)),console.clear();let{unmount:C}=jz(aB.default.createElement(BKA,{command:A,cleanOption:B,scaffoldData:Q}));process.on("SIGINT",()=>{C(),process.exit(0)})}catch(A){if(A&&typeof A==="object"&&"isCancel"in A&&A.isCancel)BC.yellow(`
|
|
74
77
|
\u274C Cancelled by user`),process.exit(0);BC.red(`
|
|
75
78
|
\u274C Error:`,A),process.exit(1)}}QKA();
|