ramm 0.0.1 → 0.0.3
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 +151 -0
- package/dist/bun.sh +2 -6
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
RAMM is a Bun library designed to simplify remote server management, deployment automation, and container operations with JS. Ansibsle inspired mechanism, but in JS with imperative commands
|
|
4
|
+
|
|
5
|
+
It provides utilities for:
|
|
6
|
+
|
|
7
|
+
- Remote command execution over SSH
|
|
8
|
+
- File synchronization using rsync
|
|
9
|
+
- System package management
|
|
10
|
+
- Podman container management
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun add ramm
|
|
16
|
+
# or
|
|
17
|
+
npm install ramm
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start Example
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { $, build } from "bun";
|
|
24
|
+
import { Context, exec, copyFiles, debug, installBun } from "ramm";
|
|
25
|
+
|
|
26
|
+
const context = new Context("root", "example.com");
|
|
27
|
+
|
|
28
|
+
debug("Install bun");
|
|
29
|
+
await installBun(context);
|
|
30
|
+
|
|
31
|
+
debug("Build project");
|
|
32
|
+
await build({
|
|
33
|
+
outdir: "dist",
|
|
34
|
+
entrypoints: ["src/server.ts"],
|
|
35
|
+
target: "bun",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
debug("Deploy files");
|
|
39
|
+
await copyFiles(context, "./dist/", "./dist");
|
|
40
|
+
|
|
41
|
+
debug("Start server");
|
|
42
|
+
await exec(context, "bun run ./dist/server.js");
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Core API Reference
|
|
46
|
+
|
|
47
|
+
### Context Class
|
|
48
|
+
|
|
49
|
+
Data storage to connect server
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
class Context {
|
|
53
|
+
constructor(name: string, address: string);
|
|
54
|
+
getAddress(): string;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- name: Server username
|
|
59
|
+
- address: Server IP/hostname
|
|
60
|
+
- getAddress(): Returns "user@host" format
|
|
61
|
+
|
|
62
|
+
### copyFiles
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
copyFiles(context: Context, from: string, to: string)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Uses rsync to copy files to remote server. Supports directories.
|
|
69
|
+
|
|
70
|
+
Example
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
await copyFiles(context, "./local", "/remote/path");
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Exec
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
exec(context: Context, command: string)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Executes command on remote server via SSH.
|
|
83
|
+
|
|
84
|
+
Example
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
await exec(ctx, "systemctl restart nginx");
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Install system package
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
installSystemPackage(packageName: string)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Auto-detects OS and uses appropriate package manager.
|
|
97
|
+
|
|
98
|
+
Example
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
await installSystemPackage("nginx");
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Install podman
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
installPodman(packageName: string)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Installs Podman if not present.
|
|
111
|
+
|
|
112
|
+
Example
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
await installPodman();
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Install podman
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
runPodmanContainer(command: string, name: string)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Smart container management:
|
|
125
|
+
|
|
126
|
+
- Checks if container exists
|
|
127
|
+
- Recreates if configuration changed
|
|
128
|
+
- Skips if already running
|
|
129
|
+
|
|
130
|
+
Example
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
await runPodmanContainer("podman run -d --name web nginx", "web");
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Install bun
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
installBun(context: Context)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Smart container management:
|
|
143
|
+
|
|
144
|
+
- Copies installation script to server
|
|
145
|
+
- Executes bun.sh on remote host
|
|
146
|
+
|
|
147
|
+
Example
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
await installBun(context);
|
|
151
|
+
```
|
package/dist/bun.sh
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
# Проверка наличия файла /etc/os-release
|
|
4
3
|
if ! command -v unzip &> /dev/null; then
|
|
5
4
|
. /etc/os-release
|
|
6
|
-
echo "Дистрибутив: $NAME"
|
|
7
5
|
|
|
8
6
|
if [[ "$ID" == "ubuntu" ]]; then
|
|
9
7
|
sudo apt update
|
|
@@ -12,12 +10,10 @@ if ! command -v unzip &> /dev/null; then
|
|
|
12
10
|
fi
|
|
13
11
|
|
|
14
12
|
if ! command -v bun &> /dev/null; then
|
|
15
|
-
echo "
|
|
13
|
+
echo "Installing..."
|
|
16
14
|
|
|
17
15
|
curl -fsSL https://bun.sh/install | bash
|
|
18
16
|
ln -s "$HOME/.bun/bin/bun" /usr/local/bin/bun
|
|
19
|
-
|
|
20
|
-
echo "Bun установлен!"
|
|
21
17
|
else
|
|
22
|
-
echo "
|
|
18
|
+
echo "Already installed."
|
|
23
19
|
fi
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ramm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "bun build ./src/ramm.ts --target bun --outdir ./dist && cp ./src/bun.sh ./dist/bun.sh && bun run types",
|
|
7
7
|
"types": "tsc --project tsconfig.types.json"
|
|
8
8
|
},
|
|
9
|
-
"main": "dist/",
|
|
9
|
+
"main": "dist/ramm.js",
|
|
10
10
|
"types": "dist/types/ramm.d.ts",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/*"
|
|
13
13
|
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"bun": ">=1.0.0"
|
|
16
|
+
},
|
|
14
17
|
"devDependencies": {
|
|
15
18
|
"@types/bun": "latest",
|
|
16
19
|
"typescript": "^5.8.2"
|