podman 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +12 -8
  2. package/package.json +33 -28
  3. package/index.ts +0 -48
package/README.md CHANGED
@@ -1,15 +1,19 @@
1
1
  # podman
2
2
 
3
- To install dependencies:
3
+ Minimal helper to start a Podman machine from Bun or Node.
4
4
 
5
- ```bash
6
- bun install
5
+ ## Install
6
+
7
+ ```sh
8
+ bun add podman
9
+ npm i podman
7
10
  ```
8
11
 
9
- To run:
12
+ ## Usage
10
13
 
11
- ```bash
12
- bun run index.ts
13
- ```
14
+ ```ts
15
+ import {startMachine} from 'podman'
14
16
 
15
- This project was created using `bun init` in bun v1.3.5. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
17
+ await startMachine() // podman-machine-default
18
+ await startMachine('your-machine-name')
19
+ ```
package/package.json CHANGED
@@ -1,30 +1,35 @@
1
1
  {
2
- "name": "podman",
3
- "version": "0.1.0",
4
- "description": "Utilities for starting a Podman machine from Bun/Node.",
5
- "author": "Mark Penner <npm@mpen.ca>",
6
- "module": "index.ts",
7
- "type": "module",
8
- "exports": {
9
- ".": "./index.ts"
10
- },
11
- "types": "./index.ts",
12
- "files": [
13
- "index.ts",
14
- "README.md"
15
- ],
16
- "sideEffects": false,
17
- "license": "MIT",
18
- "engines": {
19
- "node": ">=18",
20
- "bun": ">=1.0"
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/mnpenner/docker-imagestree/master/podman"
25
- },
26
- "devDependencies": {},
27
- "peerDependencies": {
28
- "typescript": "^5"
29
- }
2
+ "name": "podman",
3
+ "version": "0.1.1",
4
+ "description": "Utilities for starting a Podman machine from Bun/Node.",
5
+ "author": "Mark Penner <npm@mpen.ca>",
6
+ "module": "index.ts",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "files": [
15
+ "index.ts",
16
+ "README.md"
17
+ ],
18
+ "sideEffects": false,
19
+ "license": "MIT",
20
+ "engines": {
21
+ "node": ">=18",
22
+ "bun": ">=1.0"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/mnpenner/docker-imagestree/master/podman"
27
+ },
28
+ "scripts": {
29
+ "build": "bun run build.ts && tsc -p tsconfig.build.json"
30
+ },
31
+ "devDependencies": {},
32
+ "peerDependencies": {
33
+ "typescript": "^5.9.3"
34
+ }
30
35
  }
package/index.ts DELETED
@@ -1,48 +0,0 @@
1
- import {execFile} from 'node:child_process'
2
- import {promisify} from 'node:util'
3
-
4
- const execFileAsync = promisify(execFile)
5
-
6
- type PodmanMachine = {
7
- Name: string
8
- Default: boolean
9
- Created: string
10
- Running: boolean
11
- Starting: boolean
12
- LastUp: string
13
- Stream: string
14
- VMType: string
15
- CPUs: number
16
- Memory: string
17
- Swap: string
18
- DiskSize: string
19
- Port: number
20
- RemoteUsername: string
21
- IdentityPath: string
22
- UserModeNetworking: boolean
23
- }
24
-
25
- async function execPodman(args: string[]): Promise<string> {
26
- const {stdout} = await execFileAsync('podman', args)
27
- return stdout
28
- }
29
-
30
- /**
31
- * Ensures the Podman machine is running.
32
- *
33
- * @param machineName Name of the Podman machine to start.
34
- * @returns True when a machine start was triggered, false if it's already running.
35
- */
36
- export async function startMachine(machineName = 'podman-machine-default'): Promise<boolean> {
37
- const out = await execPodman(['machine', 'list', '--format', 'json'])
38
- const machines = JSON.parse(out || '[]') as PodmanMachine[]
39
- const m = machines.find((x) => x.Name === machineName)
40
- if(!m) {
41
- throw new Error(`Podman machine "${machineName}" not found in list:\n${machines.map((x) => `- ${x.Name}`).join('\n')}`)
42
- }
43
- if(m.Running) {
44
- return false
45
- }
46
- await execPodman(['machine', 'start', machineName])
47
- return true
48
- }