@envsafes-org/cli 0.0.10 → 0.1.0

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 CHANGED
@@ -14,6 +14,11 @@ const push_js_1 = require("./commands/push.js");
14
14
  const run_js_1 = require("./commands/run.js");
15
15
  const projects_js_1 = require("./commands/projects.js");
16
16
  const whoami_js_1 = require("./commands/whoami.js");
17
+ const link_js_1 = require("./commands/link.js");
18
+ const init_js_1 = require("./commands/init.js");
19
+ const list_js_1 = require("./commands/list.js");
20
+ const select_js_1 = require("./commands/select.js");
21
+ const create_js_1 = require("./commands/create.js");
17
22
  const package_json_1 = __importDefault(require("../package.json"));
18
23
  // Config store for token
19
24
  exports.config = new conf_1.default({
@@ -49,35 +54,66 @@ program
49
54
  .command("whoami")
50
55
  .description("Afficher l'utilisateur connecté")
51
56
  .action(whoami_js_1.whoami);
52
- // Projects command
57
+ // Link command - Link to a workspace
53
58
  program
54
- .command("projects")
59
+ .command("link [workspace]")
60
+ .description("Lier ce répertoire à un workspace EnvSafe")
61
+ .action(link_js_1.link);
62
+ // Init command - Interactive project selection
63
+ program
64
+ .command("init")
65
+ .description("Configurer un projet (mode interactif)")
66
+ .action(init_js_1.init);
67
+ // List command - List projects in linked workspace
68
+ program
69
+ .command("list")
55
70
  .alias("ls")
56
- .description("Lister les projets accessibles")
71
+ .description("Lister les projets du workspace lié")
72
+ .action(list_js_1.list);
73
+ // Select command - Select a project
74
+ program
75
+ .command("select <project>")
76
+ .description("Sélectionner un projet du workspace")
77
+ .action(select_js_1.select);
78
+ // Create command - Create a new project
79
+ program
80
+ .command("create [name]")
81
+ .alias("new")
82
+ .description("Créer un nouveau projet dans le workspace")
83
+ .action(create_js_1.create);
84
+ // Projects command (legacy, shows all accessible projects)
85
+ program
86
+ .command("projects")
87
+ .description("Lister tous les projets accessibles (global)")
57
88
  .action(projects_js_1.projects);
58
- // Pull command
89
+ // Pull command - Download environment variables
59
90
  program
60
- .command("pull")
91
+ .command("pull [project]")
61
92
  .description("Télécharger les variables d'environnement")
62
- .argument("<project>", "Slug du projet")
63
- .option("-e, --env <environment>", "Environnement (development, staging, production)", "development")
93
+ .option("-e, --env <environment>", "Environnement (development, staging, production)")
94
+ .option("-d, --dev", "Environnement development (raccourci)")
95
+ .option("-s, --staging", "Environnement staging (raccourci)")
96
+ .option("-p, --prod", "Environnement production (raccourci)")
64
97
  .option("-o, --output <file>", "Fichier de sortie", ".env")
65
98
  .action(pull_js_1.pull);
66
- // Push command
99
+ // Push command - Upload environment variables
67
100
  program
68
- .command("push")
101
+ .command("push [project]")
69
102
  .description("Envoyer les variables d'environnement")
70
- .argument("<project>", "Slug du projet")
71
- .option("-e, --env <environment>", "Environnement", "development")
103
+ .option("-e, --env <environment>", "Environnement")
104
+ .option("-d, --dev", "Environnement development (raccourci)")
105
+ .option("-s, --staging", "Environnement staging (raccourci)")
106
+ .option("-p, --prod", "Environnement production (raccourci)")
72
107
  .option("-f, --file <file>", "Fichier source", ".env")
73
108
  .action(push_js_1.push);
74
- // Run command
109
+ // Run command - Execute command with env vars injected
75
110
  program
76
- .command("run")
111
+ .command("run [project] <command...>")
77
112
  .description("Exécuter une commande avec les variables d'environnement injectées")
78
- .argument("<project>", "Slug du projet")
79
- .option("-e, --env <environment>", "Environnement", "development")
80
- .argument("<command...>", "Commande à exécuter")
113
+ .option("-e, --env <environment>", "Environnement")
114
+ .option("-d, --dev", "Environnement development (raccourci)")
115
+ .option("-s, --staging", "Environnement staging (raccourci)")
116
+ .option("-p, --prod", "Environnement production (raccourci)")
81
117
  .action(run_js_1.run);
82
118
  // Config command
83
119
  program
@@ -0,0 +1,44 @@
1
+ export interface EnvSafeConfig {
2
+ workspace: string;
3
+ project?: string;
4
+ environment?: string;
5
+ }
6
+ /**
7
+ * Get the path to the .envsafe config file in current directory
8
+ */
9
+ export declare function getConfigPath(): string;
10
+ /**
11
+ * Check if a .envsafe config file exists
12
+ */
13
+ export declare function configExists(): boolean;
14
+ /**
15
+ * Read the .envsafe config file
16
+ */
17
+ export declare function readConfig(): EnvSafeConfig | null;
18
+ /**
19
+ * Write the .envsafe config file
20
+ */
21
+ export declare function writeConfig(config: EnvSafeConfig): void;
22
+ /**
23
+ * Update specific fields in the config
24
+ */
25
+ export declare function updateConfig(updates: Partial<EnvSafeConfig>): EnvSafeConfig | null;
26
+ /**
27
+ * Delete the .envsafe config file
28
+ */
29
+ export declare function deleteConfig(): boolean;
30
+ /**
31
+ * Resolve environment from shorthand flags
32
+ * -d / --dev -> development
33
+ * -s / --staging -> staging
34
+ * -p / --prod -> production
35
+ */
36
+ export declare function resolveEnvironment(options: {
37
+ env?: string;
38
+ d?: boolean;
39
+ dev?: boolean;
40
+ s?: boolean;
41
+ staging?: boolean;
42
+ p?: boolean;
43
+ prod?: boolean;
44
+ }): string;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getConfigPath = getConfigPath;
7
+ exports.configExists = configExists;
8
+ exports.readConfig = readConfig;
9
+ exports.writeConfig = writeConfig;
10
+ exports.updateConfig = updateConfig;
11
+ exports.deleteConfig = deleteConfig;
12
+ exports.resolveEnvironment = resolveEnvironment;
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const CONFIG_FILENAME = ".envsafe";
16
+ /**
17
+ * Get the path to the .envsafe config file in current directory
18
+ */
19
+ function getConfigPath() {
20
+ return path_1.default.join(process.cwd(), CONFIG_FILENAME);
21
+ }
22
+ /**
23
+ * Check if a .envsafe config file exists
24
+ */
25
+ function configExists() {
26
+ return fs_1.default.existsSync(getConfigPath());
27
+ }
28
+ /**
29
+ * Read the .envsafe config file
30
+ */
31
+ function readConfig() {
32
+ const configPath = getConfigPath();
33
+ if (!fs_1.default.existsSync(configPath)) {
34
+ return null;
35
+ }
36
+ try {
37
+ const content = fs_1.default.readFileSync(configPath, "utf-8");
38
+ return JSON.parse(content);
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ }
44
+ /**
45
+ * Write the .envsafe config file
46
+ */
47
+ function writeConfig(config) {
48
+ const configPath = getConfigPath();
49
+ fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
50
+ }
51
+ /**
52
+ * Update specific fields in the config
53
+ */
54
+ function updateConfig(updates) {
55
+ const current = readConfig();
56
+ if (!current) {
57
+ return null;
58
+ }
59
+ const updated = { ...current, ...updates };
60
+ writeConfig(updated);
61
+ return updated;
62
+ }
63
+ /**
64
+ * Delete the .envsafe config file
65
+ */
66
+ function deleteConfig() {
67
+ const configPath = getConfigPath();
68
+ if (!fs_1.default.existsSync(configPath)) {
69
+ return false;
70
+ }
71
+ fs_1.default.unlinkSync(configPath);
72
+ return true;
73
+ }
74
+ /**
75
+ * Resolve environment from shorthand flags
76
+ * -d / --dev -> development
77
+ * -s / --staging -> staging
78
+ * -p / --prod -> production
79
+ */
80
+ function resolveEnvironment(options) {
81
+ if (options.p || options.prod)
82
+ return "production";
83
+ if (options.s || options.staging)
84
+ return "staging";
85
+ if (options.d || options.dev)
86
+ return "development";
87
+ if (options.env)
88
+ return options.env.toLowerCase();
89
+ return "development";
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envsafes-org/cli",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "description": "CLI pour EnvSafe - Gestionnaire sécurisé de variables d'environnement",
5
5
  "main": "dist/index.js",
6
6
  "bin": {