vaultsy-cli 0.1.0 → 0.1.2
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/dist/index.js +8 -46
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -158,8 +158,8 @@ __export(env_exports, {
|
|
|
158
158
|
});
|
|
159
159
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2 } from "fs";
|
|
160
160
|
import { join as join2, resolve } from "path";
|
|
161
|
-
function parseEnvText(
|
|
162
|
-
const lines =
|
|
161
|
+
function parseEnvText(text) {
|
|
162
|
+
const lines = text.split(/\r?\n/);
|
|
163
163
|
const result = [];
|
|
164
164
|
for (const rawLine of lines) {
|
|
165
165
|
let line = rawLine.trim();
|
|
@@ -265,47 +265,17 @@ var EnvironmentType = ["development", "staging", "preview", "production"];
|
|
|
265
265
|
// src/commands/login.ts
|
|
266
266
|
init_config();
|
|
267
267
|
init_api();
|
|
268
|
-
init_api();
|
|
269
268
|
import * as p from "@clack/prompts";
|
|
270
269
|
import chalk from "chalk";
|
|
270
|
+
var DEFAULT_BASE_URL = "https://vaultsy.app";
|
|
271
271
|
async function loginCommand(opts) {
|
|
272
272
|
p.intro(chalk.bold.cyan("vaultsy login"));
|
|
273
|
-
|
|
274
|
-
if (opts.baseUrl) {
|
|
275
|
-
baseUrl = opts.baseUrl;
|
|
276
|
-
} else if (configExists()) {
|
|
277
|
-
try {
|
|
278
|
-
baseUrl = readConfig().baseUrl;
|
|
279
|
-
} catch {
|
|
280
|
-
baseUrl = "https://vaultsy.app";
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
baseUrl = "https://vaultsy.app";
|
|
284
|
-
}
|
|
285
|
-
const resolvedBaseUrl = await p.text({
|
|
286
|
-
message: "Vaultsy base URL",
|
|
287
|
-
placeholder: "https://vaultsy.app",
|
|
288
|
-
initialValue: baseUrl,
|
|
289
|
-
validate(value) {
|
|
290
|
-
if (!value.trim()) return "Base URL is required.";
|
|
291
|
-
try {
|
|
292
|
-
new URL(value.trim());
|
|
293
|
-
} catch {
|
|
294
|
-
return "Enter a valid URL (e.g. https://vaultsy.app).";
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
if (p.isCancel(resolvedBaseUrl)) {
|
|
299
|
-
p.cancel("Login cancelled.");
|
|
300
|
-
process.exit(0);
|
|
301
|
-
}
|
|
273
|
+
const baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
302
274
|
let token;
|
|
303
275
|
if (opts.token) {
|
|
304
276
|
token = opts.token;
|
|
305
277
|
} else {
|
|
306
|
-
p.log.info(
|
|
307
|
-
`Create a token at ${chalk.cyan(resolvedBaseUrl.replace(/\/$/, "") + "/dashboard/settings")}`
|
|
308
|
-
);
|
|
278
|
+
p.log.info(`Create a token at ${chalk.cyan(baseUrl + "/dashboard/settings")}`);
|
|
309
279
|
const input = await p.password({
|
|
310
280
|
message: "Paste your API token",
|
|
311
281
|
validate(value) {
|
|
@@ -323,10 +293,7 @@ async function loginCommand(opts) {
|
|
|
323
293
|
let userName;
|
|
324
294
|
let userEmail;
|
|
325
295
|
try {
|
|
326
|
-
const me = await getMe({
|
|
327
|
-
baseUrl: resolvedBaseUrl.trim().replace(/\/$/, ""),
|
|
328
|
-
token
|
|
329
|
-
});
|
|
296
|
+
const me = await getMe({ baseUrl, token });
|
|
330
297
|
userName = me.name;
|
|
331
298
|
userEmail = me.email;
|
|
332
299
|
spinner7.stop("Token verified.");
|
|
@@ -339,16 +306,11 @@ async function loginCommand(opts) {
|
|
|
339
306
|
p.log.error(`Server responded with ${err.status}: ${err.message}`);
|
|
340
307
|
}
|
|
341
308
|
} else {
|
|
342
|
-
p.log.error(
|
|
343
|
-
`Could not reach ${resolvedBaseUrl}. Check the URL and your network connection.`
|
|
344
|
-
);
|
|
309
|
+
p.log.error(`Could not reach ${baseUrl}. Check your network connection.`);
|
|
345
310
|
}
|
|
346
311
|
process.exit(1);
|
|
347
312
|
}
|
|
348
|
-
writeConfig({
|
|
349
|
-
token,
|
|
350
|
-
baseUrl: resolvedBaseUrl.trim().replace(/\/$/, "")
|
|
351
|
-
});
|
|
313
|
+
writeConfig({ token, baseUrl });
|
|
352
314
|
p.outro(
|
|
353
315
|
`${chalk.green("\u2713")} Logged in as ${chalk.bold(userName)} ${chalk.dim(`<${userEmail}>`)}
|
|
354
316
|
Config saved to ${chalk.dim("~/.vaultsy/config.json")}`
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vaultsy-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Official CLI for Vaultsy — pull, push, and inject secrets from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"vaultsy": "
|
|
7
|
+
"vaultsy": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"homepage": "https://vaultsy.vercel.app",
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
|
-
"url": "https://github.com/Ayushkumar48/vaultsy.git",
|
|
46
|
+
"url": "git+https://github.com/Ayushkumar48/vaultsy.git",
|
|
47
47
|
"directory": "packages/cli"
|
|
48
48
|
},
|
|
49
49
|
"bugs": {
|