Skip to content

Commit

Permalink
fix remove conf library
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonstreator committed Dec 22, 2024
1 parent 46c973b commit d78fe0e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 116 deletions.
2 changes: 0 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
"@crypt.fyi/core": "*",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"conf": "^13.1.0",
"ora": "^8.0.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/conf": "^3.0.3",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
Expand Down
18 changes: 3 additions & 15 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { z } from 'zod';
import Conf from 'conf';

const configSchema = z.object({
apiUrl: z.string().url().default('https://api.crypt.fyi'),
Expand All @@ -8,18 +7,7 @@ const configSchema = z.object({

export type Config = z.infer<typeof configSchema>;

const store = new Conf<Config>({
projectName: 'crypt.fyi',
defaults: {
apiUrl: 'https://api.crypt.fyi',
webUrl: 'https://crypt.fyi',
},
export const config = configSchema.parse({
apiUrl: process.env.CRYPT_FYI_API_URL,
webUrl: process.env.CRYPT_FYI_WEB_URL,
});

export const getConfig = (): Config => {
return configSchema.parse(store.store);
};

export const setConfig = (config: Partial<Config>) => {
store.set(configSchema.parse({ ...store.store, ...config }));
};
25 changes: 1 addition & 24 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@crypt.fyi/core';
import chalk from 'chalk';
import ora from 'ora';
import { getConfig, setConfig } from './config';
import { config } from './config';

const program = new Command();

Expand All @@ -20,27 +20,6 @@ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url),

program.name('crypt').description('CLI to encrypt and share secrets securely').version(pkg.version);

program
.command('config')
.description('Configure the CLI')
.option('--api-url <url>', 'Set the API URL')
.option('--web-url <url>', 'Set the Web URL')
.action((options) => {
if (options.apiUrl) {
setConfig({ apiUrl: options.apiUrl });
console.log(chalk.green(`API URL set to ${options.apiUrl}`));
}

if (options.webUrl) {
setConfig({ webUrl: options.webUrl });
console.log(chalk.green(`Web URL set to ${options.webUrl}`));
}

const config = getConfig();
console.log(chalk.blue('Current configuration:'));
console.log(chalk.blue(`API URL: ${config.apiUrl}`));
});

program
.command('encrypt')
.description('Encrypt and share a secret')
Expand All @@ -51,7 +30,6 @@ program
.option('--ip <ip>', 'Restrict access to specific IP address')
.option('-r, --reads <count>', 'Number of times the secret can be read', undefined)
.action(async (content, options) => {
const config = getConfig();
const spinner = ora('Encrypting content...').start();
try {
const key = await generateRandomString(32);
Expand Down Expand Up @@ -111,7 +89,6 @@ program
.argument('<url>', 'Secret URL')
.option('-p, --password <password>', 'Password (if secret is password protected)')
.action(async (urlString, options) => {
const config = getConfig();
const spinner = ora('Fetching secret...').start();

try {
Expand Down
76 changes: 1 addition & 75 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3908,13 +3908,6 @@
resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-3.1.4.tgz#8563f38ea6096df3f409c6500e8ac171790a7c1f"
integrity sha512-A0uYgOj3zNc4hNjHc5lYUfJQ/HVyBXiUMKdXd7ysclaE6k9oJdavQzODHuwjpUu2/boCP8afjQYi8z/GtvNCWA==

"@types/conf@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/conf/-/conf-3.0.3.tgz#c16ece8f4ff18eed24f2c066f377a62a5cce7b92"
integrity sha512-GtMsT4J4YSzk34kslsAeCzX0/9dGrj3q7KLO1rN2bhS/VxqxGycPhEcF4c2i1JMEwNtWCNWcaKo4yIhVZa2B0w==
dependencies:
conf "*"

"@types/connect@*":
version "3.4.38"
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858"
Expand Down Expand Up @@ -4588,7 +4581,7 @@ ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

ajv@^8.0.0, ajv@^8.10.0, ajv@^8.11.0, ajv@^8.17.1:
ajv@^8.0.0, ajv@^8.10.0, ajv@^8.11.0:
version "8.17.1"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.17.1.tgz#37d9a5c776af6bc92d7f4f9510eba4c0a60d11a6"
integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==
Expand Down Expand Up @@ -4711,14 +4704,6 @@ atomic-sleep@^1.0.0:
resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b"
integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==

atomically@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/atomically/-/atomically-2.0.3.tgz#27e47bbe39994d324918491ba7c0edb7783e56cb"
integrity sha512-kU6FmrwZ3Lx7/7y3hPS5QnbJfaohcIul5fGqf7ok+4KklIEk9tJ0C2IQPdacSbVUWv6zVHXEBWoWd6NrVMT7Cw==
dependencies:
stubborn-fs "^1.2.5"
when-exit "^2.1.1"

auto-bind@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/auto-bind/-/auto-bind-5.0.1.tgz#50d8e63ea5a1dddcb5e5e36451c1a8266ffbb2ae"
Expand Down Expand Up @@ -5189,21 +5174,6 @@ concurrently@^9.1.0:
tree-kill "^1.2.2"
yargs "^17.7.2"

conf@*, conf@^13.1.0:
version "13.1.0"
resolved "https://registry.yarnpkg.com/conf/-/conf-13.1.0.tgz#c6e797d6157253c1baac3788bb121f2ee085f902"
integrity sha512-Bi6v586cy1CoTFViVO4lGTtx780lfF96fUmS1lSX6wpZf6330NvHUu6fReVuDP1de8Mg0nkZb01c8tAQdz1o3w==
dependencies:
ajv "^8.17.1"
ajv-formats "^3.0.1"
atomically "^2.0.3"
debounce-fn "^6.0.0"
dot-prop "^9.0.0"
env-paths "^3.0.0"
json-schema-typed "^8.0.1"
semver "^7.6.3"
uint8array-extras "^1.4.0"

confbox@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/confbox/-/confbox-0.1.8.tgz#820d73d3b3c82d9bd910652c5d4d599ef8ff8b06"
Expand Down Expand Up @@ -5297,13 +5267,6 @@ date-fns@^4.1.0:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-4.1.0.tgz#64b3d83fff5aa80438f5b1a633c2e83b8a1c2d14"
integrity sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==

debounce-fn@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-6.0.0.tgz#558169aed853eb3cf3a17c0a2438e1a91a7ba44f"
integrity sha512-rBMW+F2TXryBwB54Q0d8drNEI+TfoS9JpNTAoVpukbWEhjXQq4rySFYLaqXMFXwdv61Zb2OHtj5bviSoimqxRQ==
dependencies:
mimic-function "^5.0.0"

debug@4, debug@^4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5:
version "4.3.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"
Expand Down Expand Up @@ -5404,13 +5367,6 @@ doctrine@^3.0.0:
dependencies:
esutils "^2.0.2"

dot-prop@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-9.0.0.tgz#bae5982fe6dc6b8fddb92efef4f2ddff26779e92"
integrity sha512-1gxPBJpI/pcjQhKgIU91II6Wkay+dLcN3M6rf2uwP8hRur3HtQXjVrdAK3sjC0piaEuxzMwjXChcETiJl47lAQ==
dependencies:
type-fest "^4.18.2"

duplexify@^3.5.0:
version "3.7.1"
resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309"
Expand Down Expand Up @@ -5487,11 +5443,6 @@ env-paths@^2.2.0:
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==

env-paths@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-3.0.0.tgz#2f1e89c2f6dbd3408e1b1711dd82d62e317f58da"
integrity sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==

environment@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/environment/-/environment-1.1.0.tgz#8e86c66b180f363c7ab311787e0259665f45a9f1"
Expand Down Expand Up @@ -7245,11 +7196,6 @@ json-schema-traverse@^1.0.0:
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==

json-schema-typed@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/json-schema-typed/-/json-schema-typed-8.0.1.tgz#826ee39e3b6cef536f85412ff048d3ff6f19dfa0"
integrity sha512-XQmWYj2Sm4kn4WeTYvmpKEbyPsL7nBsb647c7pMe6l02/yx2+Jfc4dT6UZkEXnIUb5LhD55r2HPsJ1milQ4rDg==

json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
Expand Down Expand Up @@ -9319,11 +9265,6 @@ strip-literal@^2.0.0:
dependencies:
js-tokens "^9.0.1"

stubborn-fs@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/stubborn-fs/-/stubborn-fs-1.2.5.tgz#e5e244223166921ddf66ed5e062b6b3bf285bfd2"
integrity sha512-H2N9c26eXjzL/S/K+i/RHHcFanE74dptvvjM8iwzwbVcWY/zjBbgRqF3K0DY4+OD+uTTASTBvDoxPDaPN02D7g==

sucrase@^3.35.0:
version "3.35.0"
resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.35.0.tgz#57f17a3d7e19b36d8995f06679d121be914ae263"
Expand Down Expand Up @@ -9799,11 +9740,6 @@ type-fest@^0.21.3:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37"
integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==

type-fest@^4.18.2:
version "4.30.2"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.30.2.tgz#d94429edde1f7deacf554741650aab394197a4cc"
integrity sha512-UJShLPYi1aWqCdq9HycOL/gwsuqda1OISdBO3t8RlXQC4QvtuIz4b5FCfe2dQIWEpmlRExKmcTBfP1r9bhY7ig==

type-fest@^4.27.0:
version "4.29.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.29.0.tgz#c9ac0bd3c7cb2c2fb8fc7b24d5b3eb48daad834e"
Expand Down Expand Up @@ -9838,11 +9774,6 @@ ufo@^1.5.4:
resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.5.4.tgz#16d6949674ca0c9e0fbbae1fa20a71d7b1ded754"
integrity sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==

uint8array-extras@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/uint8array-extras/-/uint8array-extras-1.4.0.tgz#e42a678a6dd335ec2d21661333ed42f44ae7cc74"
integrity sha512-ZPtzy0hu4cZjv3z5NW9gfKnNLjoz4y6uv4HlelAjDK7sY/xOkKZv9xK/WQpcsBB3jEybChz9DPC2U/+cusjJVQ==

undefsafe@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
Expand Down Expand Up @@ -10059,11 +9990,6 @@ whatwg-url@^7.0.0:
tr46 "^1.0.1"
webidl-conversions "^4.0.2"

when-exit@^2.1.1:
version "2.1.3"
resolved "https://registry.yarnpkg.com/when-exit/-/when-exit-2.1.3.tgz#5831cdbed8ad4984645da98c4a00d4ee3a3757e7"
integrity sha512-uVieSTccFIr/SFQdFWN/fFaQYmV37OKtuaGphMAzi4DmmUlrvRBJW5WSLkHyjNQY/ePJMz3LoiX9R3yy1Su6Hw==

which@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
Expand Down

0 comments on commit d78fe0e

Please sign in to comment.