diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml index a3628c3d..4d30f8ef 100644 --- a/.github/workflows/pack.yml +++ b/.github/workflows/pack.yml @@ -10,7 +10,6 @@ on: env: RELEASE: ${{ github.event.inputs.release }} GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} permissions: write-all @@ -68,6 +67,7 @@ jobs: uses: softprops/action-gh-release@v1 with: tag_name: v${{ env.RELEASE }} + name: "Editor of v${{ env.RELEASE }}" repository: "scmn-dev/editor" files: | ./tools/editor/editor.exe diff --git a/api/github/api.ts b/api/github/api.ts deleted file mode 100755 index c3b92587..00000000 --- a/api/github/api.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Octokit } from "octokit"; -import { GH_TOKEN } from "../../constants"; - -const octokit = new Octokit({ - auth: GH_TOKEN, -}); - -export const GetLatestGHRelease = async (repo: string) => { - const data = await octokit.rest.repos - .listReleases({ - owner: "scmn-dev", - repo: repo, - }) - .then((res) => { - return res.data[0].tag_name; - }); - - return data; -}; diff --git a/api/latest.ts b/api/latest.ts new file mode 100755 index 00000000..413a059c --- /dev/null +++ b/api/latest.ts @@ -0,0 +1,16 @@ +import axios from "axios"; + +export const GetLatest = async (repo: string) => { + let url = "https://api.secman.dev/latest"; + + if (repo === "core") { + url = "https://api.secman.dev/latest-core"; + } + + try { + const res = await axios.get(url); + return res.data; + } catch (error) { + console.error(error); + } +}; diff --git a/constants/index.ts b/constants/index.ts index fd132cf9..15df589a 100755 --- a/constants/index.ts +++ b/constants/index.ts @@ -5,7 +5,6 @@ import path from "path"; env.config(); export const PRIMARY_COLOR: any = "#1163E6"; -export const GH_TOKEN: any = process.env.GH_TOKEN; export const API_URL: any = "https://api.secman.dev"; export const HOMEDIR: any = process.env.HOME || process.env.USERPROFILE; export const CHARS = { diff --git a/package.json b/package.json index 00cbcba3..1252d302 100755 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "devDependencies": { "@oclif/dev-cli": "^1", "@oclif/plugin-plugins": "^1.10.1", - "@types/bcrypt": "5.0.0", "@types/crypto-js": "^4.0.2", "@types/lodash.template": "^4.5.0", "@types/node": "^16.11.6", diff --git a/src/commands/info.ts b/src/commands/info.ts index ff632090..83cf6b78 100755 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -1,5 +1,5 @@ import { Command, flags } from "@oclif/command"; -import { GetLatestGHRelease } from "../../api/github/api"; +import { GetLatest } from "../../api/latest"; import { readConfigFile } from "../../app/config"; export default class Info extends Command { @@ -14,7 +14,7 @@ export default class Info extends Command { async run() { const { flags } = this.parse(Info); - const smca_version = await GetLatestGHRelease("core"); + const smca_version = await GetLatest("core"); const name = readConfigFile("name") ?? "No User"; console.log(`Secman CLI diff --git a/src/commands/update.ts b/src/commands/update.ts index 0af354b1..e67dcb07 100644 --- a/src/commands/update.ts +++ b/src/commands/update.ts @@ -3,7 +3,7 @@ import { spinner } from "@secman/spinner"; import { platform } from "os"; import * as sh from "shelljs"; const powershell = require("powershell"); -import { GetLatestGHRelease } from "../../api/github/api"; +import { GetLatest } from "../../api/latest"; import { bold } from "../../design/layout"; export default class Update extends Command { @@ -18,7 +18,7 @@ export default class Update extends Command { const spnr = spinner("📦 Checking for updates..."); const currentVersion = "v" + this.config.version; - const latestVersion = await GetLatestGHRelease("secman"); + const latestVersion = await GetLatest("secman") const successMsg = "Secman CLI upgraded to " + latestVersion + " successfully"; @@ -31,7 +31,7 @@ export default class Update extends Command { "🚧 Upgrading Secman CLI from " + bold(currentVersion) + " to " + - bold(latestVersion) + + latestVersion + "\n" ).start(); @@ -47,10 +47,9 @@ export default class Update extends Command { sh.exec(` if [ "$SM_PROVIDER" = "script" ]; then sudo apt-get update && sudo apt-get update -y secman - elif [ "$SM_PROVIDER" = "brew" ]; then - brew upgrade secman - elif [ "$SM_PROVIDER" = "snap" ]; then - sudo snap refresh secman + elif [ "$SM_PROVIDER" != "script" ]; then + echo "if you are using a non-script provider, you must manually update the CLI" + echo "like if you installed it with homebrew, run 'brew upgrade secman'" else npm upgrade -g secman fi diff --git a/src/commands/whoami.ts b/src/commands/whoami.ts index 9e1ad14a..72f4b535 100755 --- a/src/commands/whoami.ts +++ b/src/commands/whoami.ts @@ -1,6 +1,5 @@ import { Command, flags } from "@oclif/command"; import { readConfigFile } from "../../app/config"; -import { PRIMARY_COLOR } from "../../constants"; import { bold, withPrimary } from "../../design/layout"; export default class WhoamI extends Command { diff --git a/yarn.lock b/yarn.lock index 6fa07008..0bbadf26 100755 --- a/yarn.lock +++ b/yarn.lock @@ -500,13 +500,6 @@ resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.88.tgz#1f18ac2e15be30376e86a688a943390e7d6683e5" integrity sha512-Gbdr5tmGMGV1bgWDEfgNnfqtS9YVKDCkyAgYPmYIeEQFTSjU+VzVoE0Gc1MyrzREdk3Iu5daUCRU9eQL5s+iYQ== -"@types/bcrypt@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@types/bcrypt/-/bcrypt-5.0.0.tgz#a835afa2882d165aff5690893db314eaa98b9f20" - integrity sha512-agtcFKaruL8TmcvqbndlqHPSJgsolhf/qPWchFlgnW1gECTN/nKbFcoFnvKAQRFfKbh+BO6A3SWdJu9t+xF3Lw== - dependencies: - "@types/node" "*" - "@types/btoa-lite@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/btoa-lite/-/btoa-lite-1.0.0.tgz#e190a5a548e0b348adb0df9ac7fa5f1151c7cca4"