@playsthisgame/melon 0.1.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/bin/mln.js +14 -0
- package/package.json +23 -0
- package/postinstall.js +79 -0
package/bin/mln.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const { execFileSync } = require('child_process')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
|
|
7
|
+
const binaryName = process.platform === 'win32' ? 'mln.exe' : 'mln'
|
|
8
|
+
const binary = path.join(__dirname, '..', binaryName)
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
execFileSync(binary, process.argv.slice(2), { stdio: 'inherit' })
|
|
12
|
+
} catch (e) {
|
|
13
|
+
process.exit(e.status || 1)
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@playsthisgame/melon",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "A dependency manager for agentic markdown — skills, agents, and prompts for your AI tools.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"mln": "./bin/mln.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node postinstall.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/mln.js",
|
|
13
|
+
"postinstall.js"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/playsthisgame/melon"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=16"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const https = require('https')
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const path = require('path')
|
|
7
|
+
const os = require('os')
|
|
8
|
+
const { execSync } = require('child_process')
|
|
9
|
+
|
|
10
|
+
const pkg = require('./package.json')
|
|
11
|
+
const version = pkg.version
|
|
12
|
+
|
|
13
|
+
const OS_MAP = { darwin: 'darwin', linux: 'linux', win32: 'windows' }
|
|
14
|
+
const ARCH_MAP = { x64: 'amd64', arm64: 'arm64' }
|
|
15
|
+
|
|
16
|
+
const goos = OS_MAP[process.platform]
|
|
17
|
+
const goarch = ARCH_MAP[process.arch]
|
|
18
|
+
|
|
19
|
+
if (!goos || !goarch) {
|
|
20
|
+
console.error(`mln: unsupported platform ${process.platform}/${process.arch}`)
|
|
21
|
+
console.error('Please install manually: https://github.com/playsthisgame/melon/releases')
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ext = process.platform === 'win32' ? 'zip' : 'tar.gz'
|
|
26
|
+
const archiveName = `mln_${version}_${goos}_${goarch}.${ext}`
|
|
27
|
+
const downloadURL = `https://github.com/playsthisgame/melon/releases/download/v${version}/${archiveName}`
|
|
28
|
+
const archivePath = path.join(os.tmpdir(), archiveName)
|
|
29
|
+
const binaryName = process.platform === 'win32' ? 'mln.exe' : 'mln'
|
|
30
|
+
const binaryDest = path.join(__dirname, binaryName)
|
|
31
|
+
|
|
32
|
+
function download(url, dest, cb) {
|
|
33
|
+
const file = fs.createWriteStream(dest)
|
|
34
|
+
https.get(url, res => {
|
|
35
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
36
|
+
file.close()
|
|
37
|
+
return download(res.headers.location, dest, cb)
|
|
38
|
+
}
|
|
39
|
+
if (res.statusCode !== 200) {
|
|
40
|
+
file.close()
|
|
41
|
+
return cb(new Error(`HTTP ${res.statusCode} downloading ${url}`))
|
|
42
|
+
}
|
|
43
|
+
res.pipe(file)
|
|
44
|
+
file.on('finish', () => file.close(cb))
|
|
45
|
+
}).on('error', err => {
|
|
46
|
+
file.close()
|
|
47
|
+
fs.unlink(dest, () => {})
|
|
48
|
+
cb(err)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log(`mln: downloading ${archiveName}...`)
|
|
53
|
+
|
|
54
|
+
download(downloadURL, archivePath, err => {
|
|
55
|
+
if (err) {
|
|
56
|
+
console.error(`mln: download failed: ${err.message}`)
|
|
57
|
+
process.exit(1)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
if (process.platform === 'win32') {
|
|
62
|
+
execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${os.tmpdir()}' -Force"`)
|
|
63
|
+
} else {
|
|
64
|
+
execSync(`tar -xzf "${archivePath}" -C "${os.tmpdir()}" mln`)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fs.copyFileSync(path.join(os.tmpdir(), binaryName), binaryDest)
|
|
68
|
+
|
|
69
|
+
if (process.platform !== 'win32') {
|
|
70
|
+
fs.chmodSync(binaryDest, 0o755)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fs.unlinkSync(archivePath)
|
|
74
|
+
console.log(`mln ${version}: installed successfully`)
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error(`mln: extraction failed: ${e.message}`)
|
|
77
|
+
process.exit(1)
|
|
78
|
+
}
|
|
79
|
+
})
|