@o-town/pkg-installer 1.0.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/.vscode/settings.json +1 -0
- package/README.md +17 -0
- package/index.js +63 -0
- package/package.json +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# pkg-installer
|
|
2
|
+
|
|
3
|
+
Simple CLI tool to shorten npm install.
|
|
4
|
+
|
|
5
|
+
## Install globally
|
|
6
|
+
|
|
7
|
+
npm install -g @o-town/pkg-installer
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
pkg install express
|
|
12
|
+
|
|
13
|
+
pkg install cors dotenv
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
pkg install express cors dotenv
|
package/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { exec } from "child_process"
|
|
4
|
+
|
|
5
|
+
const args = process.argv.slice(2)
|
|
6
|
+
|
|
7
|
+
function help() {
|
|
8
|
+
console.log(`
|
|
9
|
+
PKG Installer CLI
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
pkg install <package>
|
|
13
|
+
pkg install <package1> <package2>
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
pkg install express
|
|
17
|
+
pkg install cors dotenv
|
|
18
|
+
`)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (args.length === 0) {
|
|
22
|
+
help()
|
|
23
|
+
process.exit()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const command = args[0]
|
|
27
|
+
|
|
28
|
+
switch (command) {
|
|
29
|
+
|
|
30
|
+
case "install":
|
|
31
|
+
|
|
32
|
+
const packages = args.slice(1).join(" ")
|
|
33
|
+
|
|
34
|
+
if (!packages) {
|
|
35
|
+
console.log("Please specify a package to install.")
|
|
36
|
+
process.exit()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(`Installing ${packages}...\n`)
|
|
40
|
+
|
|
41
|
+
exec(`npm install ${packages}`, (error, stdout, stderr) => {
|
|
42
|
+
|
|
43
|
+
if (error) {
|
|
44
|
+
console.error("Error installing package:")
|
|
45
|
+
console.error(error.message)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (stderr) {
|
|
50
|
+
console.error(stderr)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.log(stdout)
|
|
55
|
+
console.log("Packages installed successfully.")
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
break
|
|
59
|
+
|
|
60
|
+
default:
|
|
61
|
+
help()
|
|
62
|
+
|
|
63
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@o-town/pkg-installer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Short command wrapper for npm install",
|
|
5
|
+
"bin": {
|
|
6
|
+
"pkg": "index.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"npm",
|
|
11
|
+
"cli",
|
|
12
|
+
"installer"
|
|
13
|
+
],
|
|
14
|
+
"author": "attendance1978-wq",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
}
|
|
19
|
+
}
|