This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
scoop
task, build secman scoop generator, update packages
- Loading branch information
Showing
7 changed files
with
437 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,7 @@ tasks: | |
- task: build-core | ||
- task: link-core | ||
- ./scripts/bfs.ps1 | ||
|
||
scoop: | ||
cmds: | ||
- node ./scripts/scoop/scoop-sm.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"url": "https://secman.dev" | ||
}, | ||
"workspaces": [ | ||
"core" | ||
"core", | ||
"scripts/scoop" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "scoop-sm", | ||
"version": "0.0.0", | ||
"description": "secman scoop generator.", | ||
"author": "@abdfnx", | ||
"main": "scoop-sm.js", | ||
"scripts": { | ||
"start": "node scoop-sm.js" | ||
}, | ||
"dependencies": { | ||
"crypto": "1.0.1", | ||
"mkdirp": "^1.0.4", | ||
"rimraf": "^3.0.2", | ||
"shelljs": "^0.8.5", | ||
"stream": "0.0.2", | ||
"util": "0.12.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const rm = require("rimraf"); | ||
const mkdirp = require("mkdirp"); | ||
const sh = require("shelljs"); | ||
const _crypto = require("crypto"); | ||
const { promisify } = require("util"); | ||
const { pipeline } = require("stream"); | ||
|
||
const VERSION_CMD = sh.exec("git describe --abbrev=0 --tags"); | ||
const VERSION = VERSION_CMD.replace("\n", "") | ||
.replace("\r", "") | ||
.replace("v", ""); | ||
|
||
const SECMAN_32BIT_URL = `https://github.com/scmn-dev/secman/releases/download/v${VERSION}/secman_windows_v${VERSION}_386.zip`; | ||
const SECMAN_64BIT_URL = `https://github.com/scmn-dev/secman/releases/download/v${VERSION}/secman_windows_v${VERSION}_amd64.zip`; | ||
|
||
const ROOT = __dirname; | ||
const DIST_DIR = path.join(ROOT, "..", "..", "dist"); | ||
const TEMPLATES = path.join(ROOT, "templates"); | ||
|
||
async function calculateSHA256(fileName) { | ||
const hash = _crypto.createHash("sha256"); | ||
|
||
hash.setEncoding("hex"); | ||
await promisify(pipeline)(fs.createReadStream(fileName), hash); | ||
|
||
return hash.read(); | ||
} | ||
|
||
async function updateSecmanScoop(secmanDir) { | ||
const templatePath = path.join(TEMPLATES, "secman.json"); | ||
const template = fs.readFileSync(templatePath).toString("utf-8"); | ||
|
||
const SM_32BIT_FILE = path.join( | ||
DIST_DIR, | ||
`secman_windows_v${VERSION}_386.zip` | ||
); | ||
const SM_64BIT_FILE = path.join( | ||
DIST_DIR, | ||
`secman_windows_v${VERSION}_amd64.zip` | ||
); | ||
|
||
const SM_32BIT_HASH = await calculateSHA256(SM_32BIT_FILE); | ||
const SM_64BIT_HASH = await calculateSHA256(SM_64BIT_FILE); | ||
|
||
const templateReplaced = template | ||
.replace("CLI_VERSION", VERSION) | ||
.replace("SECMAN_32BIT_URL", SECMAN_32BIT_URL) | ||
.replace("SECMAN_64BIT_URL", SECMAN_64BIT_URL) | ||
.replace("32BIT_HASH", SM_32BIT_HASH) | ||
.replace("64BIT_HASH", SM_64BIT_HASH); | ||
|
||
fs.writeFileSync(path.join(secmanDir, "secman.json"), templateReplaced); | ||
} | ||
|
||
async function updateScoop() { | ||
const tmp = path.join(__dirname, "tmp"); | ||
const scoopDir = path.join(tmp, "scoop"); | ||
|
||
mkdirp.sync(tmp); | ||
rm.sync(scoopDir); | ||
|
||
console.log(`cloning https://github.com/scmn-dev/scoop to ${scoopDir}`); | ||
|
||
sh.exec(`git clone https://github.com/scmn-dev/scoop.git ${scoopDir}`); | ||
|
||
console.log(`done cloning scmn-dev/scoop to ${scoopDir}`); | ||
|
||
await updateSecmanScoop(scoopDir); | ||
} | ||
|
||
updateScoop().catch((err) => { | ||
console.error(`error running scripts/scoop/scoop-sm.js`, err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "CLI_VERSION", | ||
"architecture": { | ||
"32bit": { | ||
"url": "SECMAN_32BIT_URL", | ||
"bin": ["bin/secman.exe"], | ||
"hash": "32BIT_HASH" | ||
}, | ||
"64bit": { | ||
"url": "SECMAN_64BIT_URL", | ||
"bin": ["bin/secman.exe"], | ||
"hash": "64BIT_HASH" | ||
} | ||
}, | ||
"homepage": "https://secman.dev", | ||
"license": "MIT", | ||
"description": "👊 Human-friendly and amazing TUI secrets manager" | ||
} |
Oops, something went wrong.