Skip to content

Commit

Permalink
fix: resolve usage issues when published to npm (#10)
Browse files Browse the repository at this point in the history
* fix: remove shebang from index script

* refractor: remove static text file resources

* fix: fetch text file resources from supabase storage

* chore(release): bump package version to 1.2.2
  • Loading branch information
fabio-nettis authored Apr 15, 2024
1 parent d7a0239 commit b06be5b
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 101 deletions.
15 changes: 0 additions & 15 deletions ascii/events.txt

This file was deleted.

15 changes: 0 additions & 15 deletions ascii/major.txt

This file was deleted.

14 changes: 0 additions & 14 deletions ascii/planets.txt

This file was deleted.

15 changes: 0 additions & 15 deletions ascii/reports.txt

This file was deleted.

12 changes: 0 additions & 12 deletions ascii/statistics.txt

This file was deleted.

15 changes: 0 additions & 15 deletions ascii/stratagems.txt

This file was deleted.

2 changes: 0 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#! /usr/bin/env bun

import { Command } from "commander";
import { bin, description, version } from "package.json";

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"private": false,
"description": "The official CLI for HellHub API. Stay updated about the current war right without leaving your terminal.",
"version": "1.2.1",
"version": "1.2.2",
"main": "build/index.mjs",
"types": "build/index.d.ts",
"keywords": [
Expand All @@ -14,8 +14,7 @@
"community"
],
"files": [
"build",
"ascii"
"build"
],
"bin": {
"hellhub": "build/index.mjs"
Expand Down
23 changes: 13 additions & 10 deletions utils/ascii.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import fs from "fs/promises";
const TEXT_URL =
"https://vxspqnuarwhjjbxzgauv.supabase.co/storage/v1/object/public/ascii";

export default async function ascii(
name: string,
Expand All @@ -9,14 +9,17 @@ export default async function ascii(
return;
}

const file = await fs.readFile(
path.join(__dirname, "../ascii", `${name}.txt`),
);
try {
const response = await fetch(`${TEXT_URL}/${name}.txt`);
if (!response.ok) return;

let _ascii = file.toString();
for (const [key, value] of Object.entries(replace)) {
_ascii = _ascii.replace(`[${key.toUpperCase()}]`, value);
}
let _ascii = await response.text();
for (const [key, value] of Object.entries(replace)) {
_ascii = _ascii.replace(`[${key.toUpperCase()}]`, value);
}

console.log(`\n${_ascii}\n`);
console.log(`\n${_ascii}\n`);
} catch {
return;
}
}

0 comments on commit b06be5b

Please sign in to comment.