@npm_akash/rn-package-installer 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 ADDED
@@ -0,0 +1,90 @@
1
+ # 🚀 RN Package Installer
2
+
3
+ An interactive CLI tool to quickly install commonly used **React** and **React Native** packages with ease.
4
+
5
+ No more remembering package names or running multiple install commands — just select and install 🎯
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - ✅ Interactive package selection (checkbox UI)
12
+ - ✅ Auto-detects `npm` and `yarn`
13
+ - ✅ Lets you choose package manager if both exist
14
+ - ✅ Works with React & React Native projects
15
+ - ✅ Simple, fast, and developer-friendly
16
+
17
+ ---
18
+
19
+ ## 📦 Installation
20
+
21
+ You can use the tool **without installing globally** (recommended):
22
+
23
+ ```bash
24
+ npm install rn-package-installer
25
+ npx rn-package-installer
26
+ ```
27
+
28
+ ## ▶️ Usage
29
+
30
+ Run the command inside your React or React Native project:
31
+ ```bash
32
+ npx rn-package-installer
33
+ ```
34
+
35
+ ## You’ll see an interactive flow like this:
36
+
37
+ 🚀 RN Package Installer
38
+
39
+ ? Select packages to install (Use space to select)
40
+ ❯ ◯ axios
41
+ ◯ moment
42
+ ◯ react-native-screens
43
+
44
+ ? Both npm and yarn detected. Choose one:
45
+ ❯ npm (default)
46
+ yarn
47
+
48
+ Installing packages using npm...
49
+ ✔ Done!
50
+
51
+ ## 🧠 How it works
52
+
53
+ Detects your project environment
54
+
55
+ - Shows a list of commonly used packages
56
+ - Lets you select multiple packages
57
+ - Detects npm / yarn
58
+ - Installs selected packages automatically
59
+
60
+ ## 📁 Supported Package Managers
61
+
62
+ ✅ npm
63
+ ✅ yarn
64
+
65
+
66
+ ## ⚠️ Important Notes
67
+
68
+ The CLI does NOT auto-run on npm install
69
+
70
+ This is intentional and follows npm best practices
71
+
72
+ Always run it using:
73
+
74
+ npx rn-package-installer
75
+
76
+
77
+ ## 📄 License
78
+
79
+ MIT License © Akash
80
+
81
+
82
+ ## 🤝 Contributing
83
+
84
+ Pull requests are welcome!
85
+ If you have ideas for new features or packages, feel free to open an issue.
86
+
87
+
88
+ ## ⭐ Support
89
+
90
+ If you find this useful, please ⭐ the repo and share it with other developers!
package/bin/cli.js ADDED
@@ -0,0 +1,25 @@
1
+ import chalk from "chalk";
2
+ import { getUserChoices } from "../src/prompts.js";
3
+ import { installPackages } from "../src/installer.js";
4
+
5
+ // Skip non-interactive / CI
6
+ if (!process.stdout.isTTY || process.env.CI) {
7
+ process.exit(0);
8
+ }
9
+
10
+ console.log(chalk.cyan.bold("\n🚀 RN Package Installer\n"));
11
+
12
+ (async () => {
13
+ try {
14
+ const { selectedPackages, packageManager } =
15
+ await getUserChoices();
16
+ if (!selectedPackages.length) {
17
+ console.log("No packages selected.");
18
+ return;
19
+ }
20
+ await installPackages(selectedPackages, packageManager);
21
+ console.log(chalk.green("\n !!!!! Packages Installation complete!\n"));
22
+ } catch (err) {
23
+ console.error(chalk.red("Error:"), err.message);
24
+ }
25
+ })();
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@npm_akash/rn-package-installer",
3
+ "version": "1.0.1",
4
+ "description": "Interactive package installer for React and React Native",
5
+ "type": "module",
6
+ "main": "bin/cli.js",
7
+ "bin": {
8
+ "rn-package-installer": "bin/cli.js"
9
+ },
10
+ "scripts": {
11
+ "postinstall": "node bin/cli.js"
12
+ },
13
+ "keywords": [
14
+ "react-native",
15
+ "react",
16
+ "cli",
17
+ "installer",
18
+ "packages"
19
+ ],
20
+ "dependencies": {
21
+ "chalk": "^5.3.0",
22
+ "execa": "^8.0.1",
23
+ "inquirer": "^9.2.12"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/Akash562/package-installer.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/Akash562/package-installer/issues"
34
+ },
35
+ "author": "Akash",
36
+ "license": "MIT"
37
+ }
@@ -0,0 +1,18 @@
1
+ import { execaSync } from "execa";
2
+
3
+ export function detectPackageManagers() {
4
+ let hasNpm = false;
5
+ let hasYarn = false;
6
+
7
+ try {
8
+ execaSync("npm", ["-v"]);
9
+ hasNpm = true;
10
+ } catch { }
11
+
12
+ try {
13
+ execaSync("yarn", ["-v"]);
14
+ hasYarn = true;
15
+ } catch { }
16
+
17
+ return { hasNpm, hasYarn };
18
+ }
@@ -0,0 +1,11 @@
1
+ import { execa } from "execa";
2
+
3
+ export async function installPackages(packages, pm) {
4
+ if (!packages.length) {
5
+ console.log("No packages selected.");
6
+ return;
7
+ }
8
+ const args = pm === "yarn" ? ["add", ...packages] : ["install", ...packages];
9
+ console.log(`\nInstalling using ${pm}...\n`);
10
+ await execa(pm, args, { stdio: "inherit" });
11
+ }
@@ -0,0 +1,7 @@
1
+ export const PACKAGES = [
2
+ { id: 1, name: "moment" },
3
+ { id: 2, name: "axios" },
4
+ { id: 3, name: "react-native-screens" },
5
+ { id: 4, name: "react-native-safe-area-context" },
6
+ { id: 5, name: "react-navigation" }
7
+ ];
package/src/prompts.js ADDED
@@ -0,0 +1,33 @@
1
+ import inquirer from "inquirer";
2
+ import { PACKAGES } from "./packages.js";
3
+ import { detectPackageManagers } from "./detectPm.js";
4
+
5
+ export async function getUserChoices() {
6
+ // multi-select packages
7
+ const { selectedPackages } = await inquirer.prompt({
8
+ type: "checkbox",
9
+ name: "selectedPackages",
10
+ message: "Select packages to install:",
11
+ choices: PACKAGES.map(p => ({
12
+ name: p.name,
13
+ value: p.name
14
+ }))
15
+ });
16
+
17
+ const { hasNpm, hasYarn } = detectPackageManagers();
18
+ let packageManager = "npm";
19
+
20
+ if (hasNpm && hasYarn) {
21
+ const res = await inquirer.prompt({
22
+ type: "list",
23
+ name: "packageManager",
24
+ message: "Both npm and yarn detected. Choose one:",
25
+ choices: ["npm", "yarn"]
26
+ });
27
+ packageManager = res.packageManager;
28
+ } else if (hasYarn) {
29
+ packageManager = "yarn";
30
+ }
31
+
32
+ return { selectedPackages, packageManager };
33
+ }