@dotenc/cli 0.1.1 → 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/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ import("./program.js");
@@ -1,4 +1,4 @@
1
- import { getHomeConfig, setHomeConfig } from "../helpers/homeConfig";
1
+ import { getHomeConfig, setHomeConfig } from "../helpers/homeConfig.js";
2
2
  export const configCommand = async (key, value, options) => {
3
3
  const config = await getHomeConfig();
4
4
  if (options.remove) {
@@ -2,7 +2,7 @@ import crypto from "node:crypto";
2
2
  import fs from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { decrypt, encrypt } from "../helpers/crypto";
5
+ import { decrypt, encrypt } from "../helpers/crypto.js";
6
6
  export const debugCommand = async () => {
7
7
  const token = crypto.randomBytes(32).toString("base64");
8
8
  const encryptedFilePath = path.join(os.tmpdir(), "dotenc.enc");
@@ -3,11 +3,11 @@ import { existsSync } from "node:fs";
3
3
  import fs from "node:fs/promises";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
- import { createHash } from "../helpers/createHash";
7
- import { decrypt, encrypt } from "../helpers/crypto";
8
- import { getDefaultEditor } from "../helpers/getDefaultEditor";
9
- import { getToken } from "../helpers/token";
10
- import { chooseEnvironmentPrompt } from "./prompts/chooseEnvironment";
6
+ import { createHash } from "../helpers/createHash.js";
7
+ import { decrypt, encrypt } from "../helpers/crypto.js";
8
+ import { getDefaultEditor } from "../helpers/getDefaultEditor.js";
9
+ import { getToken } from "../helpers/token.js";
10
+ import { chooseEnvironmentPrompt } from "./prompts/chooseEnvironment.js";
11
11
  export const editCommand = async (environmentArg) => {
12
12
  let environment = environmentArg;
13
13
  if (!environment) {
@@ -1,9 +1,9 @@
1
1
  import crypto from "node:crypto";
2
- import { createEnvironment } from "../helpers/createEnvironment";
3
- import { createLocalEnvironment } from "../helpers/createLocalEnvironment";
4
- import { createProject } from "../helpers/createProject";
5
- import { addToken } from "../helpers/token";
6
- import { createEnvironmentPrompt } from "./prompts/createEnvironment";
2
+ import { createEnvironment } from "../helpers/createEnvironment.js";
3
+ import { createLocalEnvironment } from "../helpers/createLocalEnvironment.js";
4
+ import { createProject } from "../helpers/createProject.js";
5
+ import { addToken } from "../helpers/token.js";
6
+ import { createEnvironmentPrompt } from "./prompts/createEnvironment.js";
7
7
  export const initCommand = async (environmentArg) => {
8
8
  // Generate a unique project ID
9
9
  const { projectId } = await createProject();
@@ -2,9 +2,9 @@ import { spawn } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
- import { decrypt } from "../helpers/crypto";
6
- import { parseEnv } from "../helpers/parseEnv";
7
- import { getToken } from "../helpers/token";
5
+ import { decrypt } from "../helpers/crypto.js";
6
+ import { parseEnv } from "../helpers/parseEnv.js";
7
+ import { getToken } from "../helpers/token.js";
8
8
  export const runCommand = async (environmentArg, command, args) => {
9
9
  // Get the environment
10
10
  const environment = environmentArg;
@@ -1,5 +1,5 @@
1
- import { getProjectConfig } from "../../helpers/projectConfig";
2
- import { getToken } from "../../helpers/token";
1
+ import { getProjectConfig } from "../../helpers/projectConfig.js";
2
+ import { getToken } from "../../helpers/token.js";
3
3
  export const tokenExportCommand = async (environmentArg) => {
4
4
  const environment = environmentArg;
5
5
  const { projectId } = await getProjectConfig();
@@ -1,5 +1,5 @@
1
- import { getProjectConfig } from "../../helpers/projectConfig";
2
- import { addToken } from "../../helpers/token";
1
+ import { getProjectConfig } from "../../helpers/projectConfig.js";
2
+ import { addToken } from "../../helpers/token.js";
3
3
  export const tokenImportCommand = async (token, environmentArg) => {
4
4
  const environment = environmentArg;
5
5
  const { projectId } = await getProjectConfig();
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { encrypt } from "./crypto";
3
+ import { encrypt } from "./crypto.js";
4
4
  export const createEnvironment = async (name, token) => {
5
5
  const filePath = path.join(process.cwd(), `.env.${name}.enc`);
6
6
  if (existsSync(filePath)) {
@@ -1,5 +1,5 @@
1
1
  import { createId } from "@paralleldrive/cuid2";
2
- import { getProjectConfig, setProjectConfig } from "./projectConfig";
2
+ import { getProjectConfig, setProjectConfig } from "./projectConfig.js";
3
3
  export const createProject = async () => {
4
4
  const config = await getProjectConfig();
5
5
  if (config.projectId) {
@@ -1,5 +1,5 @@
1
1
  import { execSync } from "node:child_process";
2
- import { getHomeConfig } from "./homeConfig";
2
+ import { getHomeConfig } from "./homeConfig.js";
3
3
  /**
4
4
  * Determines the default text editor for the system.
5
5
  * @returns {string} The command to launch the default text editor.
@@ -2,7 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import fs from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { getProjectConfig } from "./projectConfig";
5
+ import { getProjectConfig } from "./projectConfig.js";
6
6
  export const getToken = async (environment) => {
7
7
  if (process.env.DOTENC_TOKEN) {
8
8
  return process.env.DOTENC_TOKEN;
@@ -0,0 +1,46 @@
1
+ import { Command, Option } from "commander";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { configCommand } from "./commands/config.js";
6
+ import { debugCommand } from "./commands/debug.js";
7
+ import { editCommand } from "./commands/edit.js";
8
+ import { initCommand } from "./commands/init.js";
9
+ import { runCommand } from "./commands/run.js";
10
+ import { tokenExportCommand } from "./commands/token/export.js";
11
+ import { tokenImportCommand } from "./commands/token/import.js";
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "../package.json"), "utf8"));
15
+ const program = new Command();
16
+ program.name("dotenc").description(pkg.description).version(pkg.version);
17
+ if (process.env.NODE_ENV !== "production") {
18
+ program.command("debug").description("debug the CLI").action(debugCommand);
19
+ }
20
+ program
21
+ .command("init [environment]")
22
+ .description("initialize a new environment")
23
+ .action(initCommand);
24
+ program
25
+ .command("edit [environment]")
26
+ .description("edit an environment")
27
+ .action(editCommand);
28
+ program
29
+ .command("run <environment> <command> [args...]")
30
+ .description("run a command in an environment")
31
+ .action(runCommand);
32
+ const token = program.command("token").description("Manage stored tokens");
33
+ token
34
+ .command("import <environment> <token>")
35
+ .description("import a token for an environment")
36
+ .action(tokenImportCommand);
37
+ token
38
+ .command("export <environment>")
39
+ .description("export a token from an environment")
40
+ .action(tokenExportCommand);
41
+ program
42
+ .command("config <key> [value]")
43
+ .addOption(new Option("-r, --remove", "remove a configuration key"))
44
+ .description("manage global configuration")
45
+ .action(configCommand);
46
+ program.parse();
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dotenc/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "🔐 Secure, encrypted environment variables that live in your codebase",
5
5
  "type": "module",
6
6
  "bin": {
7
- "dotenc": "./dist/src/cli.js"
7
+ "dotenc": "./dist/cli.js"
8
8
  },
9
9
  "files": [
10
10
  "dist"
@@ -31,6 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@biomejs/biome": "^1.9.4",
33
33
  "@types/node": "^22.13.7",
34
+ "tsc-alias": "^1.8.11",
34
35
  "tsx": "^4.19.3",
35
36
  "typescript": "^5.8.2"
36
37
  },
@@ -42,6 +43,7 @@
42
43
  },
43
44
  "scripts": {
44
45
  "dev": "tsx src/cli.ts",
45
- "build": "tsc"
46
+ "start": "node dist/cli.js",
47
+ "build": "tsc && tsc-alias"
46
48
  }
47
49
  }
package/dist/package.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "name": "@dotenc/cli",
3
- "version": "0.1.0",
4
- "description": "🔐 Secure, encrypted environment variables that live in your codebase",
5
- "type": "module",
6
- "bin": {
7
- "dotenc": "./dist/cli.js"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "scripts": {
13
- "dev": "tsx src/cli.ts",
14
- "build": "tsc"
15
- },
16
- "keywords": [
17
- "environment",
18
- "variables",
19
- "safe",
20
- "secure",
21
- "codebase",
22
- "cli",
23
- "command",
24
- "line",
25
- "tool",
26
- "utility",
27
- "env",
28
- "box",
29
- "dotenv",
30
- "encrypted",
31
- "codebase"
32
- ],
33
- "author": "Ivan Filho <i@ivanfilho.com>",
34
- "license": "MIT",
35
- "devDependencies": {
36
- "@biomejs/biome": "^1.9.4",
37
- "@types/node": "^22.13.7",
38
- "tsx": "^4.19.3",
39
- "typescript": "^5.8.2"
40
- },
41
- "dependencies": {
42
- "@paralleldrive/cuid2": "^2.2.2",
43
- "commander": "^13.1.0",
44
- "inquirer": "^12.4.2",
45
- "zod": "^3.24.2"
46
- }
47
- }
package/dist/src/cli.js DELETED
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command, Option } from "commander";
3
- import pkg from "../package.json" assert { type: "json" };
4
- import { configCommand } from "./commands/config";
5
- import { debugCommand } from "./commands/debug";
6
- import { editCommand } from "./commands/edit";
7
- import { initCommand } from "./commands/init";
8
- import { runCommand } from "./commands/run";
9
- import { tokenExportCommand } from "./commands/token/export";
10
- import { tokenImportCommand } from "./commands/token/import";
11
- const program = new Command();
12
- program.name("dotenc").description(pkg.description).version(pkg.version);
13
- if (process.env.NODE_ENV !== "production") {
14
- program.command("debug").description("Debug the CLI").action(debugCommand);
15
- }
16
- program
17
- .command("init [environment]")
18
- .description("Initialize a new safe environment")
19
- .action(initCommand);
20
- program
21
- .command("edit [environment]")
22
- .description("Edit an environment")
23
- .action(editCommand);
24
- program
25
- .command("run <environment> <command> [args...]")
26
- .description("Run a command in an environment")
27
- .action(runCommand);
28
- const token = program.command("token").description("Manage stored tokens");
29
- token
30
- .command("import <environment> <token>")
31
- .description("Import a token for an environment")
32
- .action(tokenImportCommand);
33
- token
34
- .command("export <environment>")
35
- .description("Export a token from an environment")
36
- .action(tokenExportCommand);
37
- program
38
- .command("config <key> [value]")
39
- .addOption(new Option("-r, --remove", "Remove a configuration key"))
40
- .description("Manage global configuration")
41
- .action(configCommand);
42
- program.parse();
File without changes
File without changes
File without changes
File without changes
File without changes