@envsafes-org/cli 0.0.11 → 0.1.1

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/README.md CHANGED
@@ -1,343 +1,209 @@
1
- # 🔐 EnvSafe CLI
1
+ # EnvSafe CLI
2
2
 
3
- **Secure environment variable manager for your teams**
3
+ CLI officiel pour **EnvSafe** - Gestionnaire sécurisé de variables d'environnement pour équipes.
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/@envsafes-org/cli.svg)](https://www.npmjs.com/package/@envsafes-org/cli)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
-
8
- EnvSafe CLI allows you to manage your environment variables securely with end-to-end encryption. Ideal for teams wanting to centralize their secrets without compromising security.
9
-
10
- ## 🛑 Prerequisites
11
-
12
- Before using the CLI, you must create an account and a project on **[https://www.envsafe.dev](https://www.envsafe.dev)**.
13
-
14
- ## 📦 Installation
5
+ ## Installation
15
6
 
16
7
  ```bash
17
- # Global installation (recommended)
8
+ # Installation globale (recommandée)
18
9
  npm install -g @envsafes-org/cli
19
10
 
20
- # With yarn
11
+ # Ou avec yarn
21
12
  yarn global add @envsafes-org/cli
22
13
 
23
- # With pnpm
14
+ # Ou avec pnpm
24
15
  pnpm add -g @envsafes-org/cli
25
16
 
26
- # One-time use without installation
27
- npx @envsafes-org/cli
17
+ # Sans installation (npx)
18
+ npx @envsafes-org/cli --help
28
19
  ```
29
20
 
30
- ## 🚀 Quick Start
21
+ ## Configuration rapide
22
+
23
+ ### 1. Connexion
31
24
 
32
25
  ```bash
33
- # 1. Log in with your API token
26
+ # Se connecter (ouvre le navigateur pour générer un token)
34
27
  envsafe login
35
28
 
36
- # 2. List your projects
37
- envsafe projects
38
-
39
- # 3. Pull your variables
40
- envsafe pull my-project
41
-
42
- # 4. Or run directly with injection
43
- envsafe run my-project -- npm start
29
+ # Ou avec un token directement
30
+ envsafe login --token <votre-token>
44
31
  ```
45
32
 
46
- ## 📖 Commands
47
-
48
- ### `envsafe login`
49
-
50
- Authenticate with a Personal Access Token (PAT).
33
+ ### 2. Lier un workspace
51
34
 
52
35
  ```bash
53
- # Interactive mode
54
- envsafe login
36
+ # Mode interactif - sélectionner un workspace
37
+ envsafe link
55
38
 
56
- # With direct token (CI/CD)
57
- envsafe login --token es_live_xxxxxxxxxxxxx
39
+ # Ou spécifier directement le workspace
40
+ envsafe link mon-workspace
58
41
  ```
59
42
 
60
- **💡 Generate a token:** Go to your Dashboard Settings → API Tokens
43
+ Cette commande crée un fichier `.envsafe` dans le répertoire courant.
61
44
 
62
- ---
45
+ ### 3. Sélectionner un projet
63
46
 
64
- ### `envsafe projects` (alias: `ls`)
47
+ ```bash
48
+ # Mode interactif - configurer workspace + projet
49
+ envsafe init
65
50
 
66
- List all accessible projects.
51
+ # Ou lister les projets disponibles
52
+ envsafe list
67
53
 
68
- ```bash
69
- envsafe projects
70
- # or
71
- envsafe ls
54
+ # Puis sélectionner un projet
55
+ envsafe select mon-projet
72
56
  ```
73
57
 
74
- ---
75
-
76
- ### `envsafe pull <project>`
58
+ ## Commandes principales
77
59
 
78
- Download environment variables to a local file.
60
+ ### Récupérer les variables (Pull)
79
61
 
80
62
  ```bash
81
- # Development environment (default)
82
- envsafe pull my-project
83
-
84
- # Specific environment
85
- envsafe pull my-project --env staging
86
- envsafe pull my-project --env production
87
-
88
- # Custom output file
89
- envsafe pull my-project --output .env.local
90
- envsafe pull my-project --env production --output .env.prod
91
- ```
63
+ # Récupérer les variables development (par défaut)
64
+ envsafe pull
92
65
 
93
- **Options:**
94
- - `-e, --env <environment>` : Environment (development, staging, production) - Default: `development`
95
- - `-o, --output <file>` : Output file - Default: `.env`
66
+ # Avec raccourcis d'environnement
67
+ envsafe pull -d # development
68
+ envsafe pull -s # staging
69
+ envsafe pull -p # production
96
70
 
97
- ---
71
+ # Spécifier un projet manuellement
72
+ envsafe pull mon-projet -p
98
73
 
99
- ### `envsafe push <project>`
74
+ # Changer le fichier de sortie
75
+ envsafe pull -d -o .env.local
76
+ ```
100
77
 
101
- Send your local variables to EnvSafe (automatically encrypted).
78
+ ### Envoyer les variables (Push)
102
79
 
103
80
  ```bash
104
- # Send .env to development
105
- envsafe push my-project
106
-
107
- # Specific environment and file
108
- envsafe push my-project --env production --file .env.prod
109
- ```
110
-
111
- **Options:**
112
- - `-e, --env <environment>` : Target environment - Default: `development`
113
- - `-f, --file <file>` : Source file - Default: `.env`
81
+ # Envoyer vers development (par défaut)
82
+ envsafe push
114
83
 
115
- ---
84
+ # Avec raccourcis d'environnement
85
+ envsafe push -d # development
86
+ envsafe push -s # staging
87
+ envsafe push -p # production
116
88
 
117
- ### `envsafe run <project> -- <command>`
89
+ # Spécifier un fichier source
90
+ envsafe push -p -f .env.production
91
+ ```
118
92
 
119
- **⭐️ Recommended command**: Run a command with variables injected directly, without creating a `.env` file on disk.
93
+ ### Exécuter avec injection (Run)
120
94
 
121
95
  ```bash
122
- # Development
123
- envsafe run my-project -- npm start
124
- envsafe run my-project -- npm run dev
96
+ # Exécuter une commande avec les variables injectées
97
+ envsafe run npm start
125
98
 
126
- # Production
127
- envsafe run my-project --env production -- node server.js
99
+ # Avec un environnement spécifique
100
+ envsafe run -p npm start
128
101
 
129
- # Other examples
130
- envsafe run my-project -- pnpm build
131
- envsafe run my-project -- python main.py
132
- envsafe run my-project -- docker-compose up
102
+ # Spécifier un projet
103
+ envsafe run mon-projet -s yarn dev
133
104
  ```
134
105
 
135
- **Advantages:**
136
- - ✅ More secure (no .env file on disk)
137
- - ✅ Ideal for CI/CD
138
- - ✅ No risk of accidentally committing secrets
139
-
140
- ---
141
-
142
- ### `envsafe whoami`
143
-
144
- Display currently logged-in account information.
106
+ ### Créer un projet
145
107
 
146
108
  ```bash
147
- envsafe whoami
148
- ```
109
+ # Mode interactif
110
+ envsafe create
149
111
 
150
- ---
112
+ # Avec un nom
113
+ envsafe create "Mon Nouveau Projet"
114
+ ```
151
115
 
152
- ### `envsafe logout`
116
+ ## Toutes les commandes
153
117
 
154
- Log out (removes local token).
118
+ | Commande | Alias | Description |
119
+ |----------|-------|-------------|
120
+ | `envsafe login` | - | Se connecter avec un token API |
121
+ | `envsafe logout` | - | Se déconnecter |
122
+ | `envsafe whoami` | - | Afficher l'utilisateur connecté |
123
+ | `envsafe link [workspace]` | - | Lier ce répertoire à un workspace |
124
+ | `envsafe init` | - | Configurer un projet (interactif) |
125
+ | `envsafe list` | `ls` | Lister les projets du workspace |
126
+ | `envsafe select <projet>` | - | Sélectionner un projet |
127
+ | `envsafe create [nom]` | `new` | Créer un nouveau projet |
128
+ | `envsafe pull [projet]` | - | Télécharger les variables |
129
+ | `envsafe push [projet]` | - | Envoyer les variables |
130
+ | `envsafe run [projet] <cmd>` | - | Exécuter avec injection |
131
+ | `envsafe projects` | - | Lister tous les projets (global) |
132
+ | `envsafe config` | - | Gérer la configuration |
155
133
 
156
- ```bash
157
- envsafe logout
158
- ```
134
+ ## Options d'environnement
159
135
 
160
- ---
136
+ Les commandes `pull`, `push` et `run` supportent ces raccourcis :
161
137
 
162
- ### `envsafe config`
138
+ | Option | Environnement |
139
+ |--------|---------------|
140
+ | `-d`, `--dev` | development |
141
+ | `-s`, `--staging` | staging |
142
+ | `-p`, `--prod` | production |
143
+ | `-e <env>` | personnalisé |
163
144
 
164
- Manage CLI configuration.
145
+ ## Fichier .envsafe
165
146
 
166
- ```bash
167
- # Show current configuration
168
- envsafe config --show
147
+ Le fichier `.envsafe` stocke la configuration locale du projet :
169
148
 
170
- # Change API URL (for self-hosted instances)
171
- envsafe config --api-url https://your-instance.com
149
+ ```json
150
+ {
151
+ "workspace": "mon-workspace",
152
+ "project": "mon-projet"
153
+ }
172
154
  ```
173
155
 
174
- ---
156
+ > **Conseil :** Ajoutez `.envsafe` à votre `.gitignore` si vous ne voulez pas partager cette configuration.
175
157
 
176
- ## 🔧 CI/CD Usage
158
+ ## CI/CD
177
159
 
178
- ### Recommended Method: Environment Variable
160
+ Dans les environnements automatisés, utilisez la variable `ENVSAFE_TOKEN` :
179
161
 
180
- Set `ENVSAFE_TOKEN` as a secret in your CI/CD, then use commands directly without `login`.
162
+ ```bash
163
+ export ENVSAFE_TOKEN=your-token-here
164
+ envsafe pull mon-projet -p
165
+ ```
181
166
 
182
- #### GitHub Actions
167
+ ### GitHub Actions
183
168
 
184
169
  ```yaml
185
- name: Deploy
186
- on: [push]
187
-
188
170
  jobs:
189
171
  deploy:
190
172
  runs-on: ubuntu-latest
191
173
  steps:
192
174
  - uses: actions/checkout@v4
193
-
194
175
  - name: Install EnvSafe CLI
195
176
  run: npm install -g @envsafes-org/cli
196
-
197
- - name: Run tests with EnvSafe
177
+ - name: Pull secrets
198
178
  env:
199
179
  ENVSAFE_TOKEN: ${{ secrets.ENVSAFE_TOKEN }}
200
- run: |
201
- envsafe run my-project --env staging -- npm test
202
-
203
- - name: Deploy to production
204
- env:
205
- ENVSAFE_TOKEN: ${{ secrets.ENVSAFE_TOKEN }}
206
- run: |
207
- envsafe run my-project --env production -- npm run build
208
- envsafe run my-project --env production -- npm run deploy
180
+ run: envsafe pull mon-projet -p -o .env
209
181
  ```
210
182
 
211
- #### GitLab CI
183
+ ### GitLab CI
212
184
 
213
185
  ```yaml
214
186
  deploy:
215
- stage: deploy
216
187
  script:
217
188
  - npm install -g @envsafes-org/cli
218
- - envsafe run my-project --env production -- npm run deploy
189
+ - envsafe pull mon-projet -p -o .env
219
190
  variables:
220
- ENVSAFE_TOKEN: $ENVSAFE_TOKEN_SECRET
221
- ```
222
-
223
- #### Docker
224
-
225
- ```dockerfile
226
- FROM node:20-alpine
227
-
228
- # Install the CLI
229
- RUN npm install -g @envsafes-org/cli
230
-
231
- WORKDIR /app
232
- COPY . .
233
-
234
- # Inject variables at startup
235
- CMD ["envsafe", "run", "my-project", "--env", "production", "--", "npm", "start"]
236
- ```
237
-
238
- ---
239
-
240
- ## 💡 Usage Examples
241
-
242
- ### Local Development
243
-
244
- ```bash
245
- # Option 1: .env file (traditional)
246
- envsafe pull my-project
247
- npm run dev
248
-
249
- # Option 2: Direct injection (recommended)
250
- envsafe run my-project -- npm run dev
251
- ```
252
-
253
- ### Deployment Script
254
-
255
- ```bash
256
- #!/bin/bash
257
- # deploy.sh
258
-
259
- # Load production variables and deploy
260
- envsafe run my-project --env production -- npm run build
261
- envsafe run my-project --env production -- npm run deploy
262
- ```
263
-
264
- ### Automated Tests
265
-
266
- ```bash
267
- # Run tests with staging variables
268
- envsafe run my-project --env staging -- npm test
191
+ ENVSAFE_TOKEN: $ENVSAFE_TOKEN
269
192
  ```
270
193
 
271
- ### Multi-environments
194
+ ## Aide
272
195
 
273
196
  ```bash
274
- # Development
275
- envsafe run my-project --env development -- npm run dev
276
-
277
- # Staging
278
- envsafe run my-project --env staging -- npm run build
279
-
280
- # Production
281
- envsafe run my-project --env production -- npm start
197
+ envsafe --help
198
+ envsafe <command> --help
282
199
  ```
283
200
 
284
- ---
285
-
286
- ## 🔐 Security
287
-
288
- EnvSafe uses end-to-end encryption architecture:
289
-
290
- - **Variable Encryption**: AES-256-GCM
291
- - **Key Management**: RSA-2048 with asymmetric encryption
292
- - **Transport**: TLS 1.3
293
- - **Zero Knowledge**: Your private keys never leave your machine
294
-
295
- ### Best Practices
296
-
297
- ✅ **Do:**
298
- - Use `ENVSAFE_TOKEN` in CI/CD
299
- - Set expiration dates for your tokens
300
- - Prefer `envsafe run` to avoid .env files
301
- - Immediately revoke compromised tokens
302
-
303
- ❌ **Don't:**
304
- - Never commit your tokens to Git
305
- - Do not use `--token` in the command line (visible in history)
306
- - Do not share your tokens via email/Slack
307
-
308
- ---
309
-
310
- ## 🌍 Environment Variables
311
-
312
- | Variable | Description | Example |
313
- |----------|-------------|---------|
314
- | `ENVSAFE_TOKEN` | Authentication Token (recommended in CI/CD) | `es_live_xxx...` |
315
- | `ENVSAFE_API_URL` | API URL (for self-hosted instances) | `https://api.example.com` |
316
-
317
- ---
318
-
319
- ## 📚 Complete Documentation
320
-
321
- For more information, check out the [official documentation](https://www.envsafe.dev/docs).
322
-
323
- ---
324
-
325
- ## 🐛 Report a Bug
326
-
327
- If you encounter an issue, [open an issue](https://github.com/Ifiboys/envsafe-cli/issues).
328
-
329
- ---
330
-
331
- ## 📄 License
332
-
333
- MIT © EnvSafe Team
334
-
335
- ---
336
-
337
- ## 🤝 Contributing
201
+ ## Liens
338
202
 
339
- Contributions are welcome! Check out our [contribution guide](CONTRIBUTING.md).
203
+ - 🌐 [Dashboard EnvSafe](https://www.envsafe.dev)
204
+ - 📖 [Documentation](https://www.envsafe.dev/docs)
205
+ - 🐛 [GitHub Issues](https://github.com/Ifiboys/envsafe-cli/issues)
340
206
 
341
- ---
207
+ ## Licence
342
208
 
343
- Made with ❤️ by the EnvSafe Team
209
+ MIT
@@ -0,0 +1 @@
1
+ export declare function create(projectName?: string): Promise<void>;
@@ -0,0 +1,86 @@
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.create = create;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const ora_1 = __importDefault(require("ora"));
10
+ const index_js_1 = require("../index.js");
11
+ const api_js_1 = require("../utils/api.js");
12
+ const config_js_1 = require("../utils/config.js");
13
+ const i18n_js_1 = require("../utils/i18n.js");
14
+ async function create(projectName) {
15
+ const token = index_js_1.config.get("token");
16
+ const tr = (0, i18n_js_1.t)();
17
+ if (!token) {
18
+ console.log(chalk_1.default.red(tr.notConnected));
19
+ return;
20
+ }
21
+ const localConfig = (0, config_js_1.readConfig)();
22
+ if (!localConfig?.workspace) {
23
+ console.log(chalk_1.default.yellow(tr.create.noWorkspace));
24
+ console.log(chalk_1.default.dim(` ${tr.create.linkFirst}`));
25
+ return;
26
+ }
27
+ let name = projectName;
28
+ let description;
29
+ if (!name) {
30
+ const answers = await inquirer_1.default.prompt([
31
+ {
32
+ type: "input",
33
+ name: "name",
34
+ message: tr.create.enterName,
35
+ validate: (input) => input.trim().length > 0 || "Name is required",
36
+ },
37
+ {
38
+ type: "input",
39
+ name: "description",
40
+ message: "Description (optional):",
41
+ },
42
+ ]);
43
+ name = answers.name;
44
+ description = answers.description;
45
+ }
46
+ const spinner = (0, ora_1.default)(`${tr.create.creating} "${name}"...`).start();
47
+ try {
48
+ const response = await (0, api_js_1.apiRequest)(`/api/v1/workspaces/${localConfig.workspace}/projects`, {
49
+ method: "POST",
50
+ token,
51
+ body: {
52
+ name: name.trim(),
53
+ description: description?.trim() || undefined,
54
+ },
55
+ });
56
+ if (response.error) {
57
+ spinner.fail(chalk_1.default.red(`${tr.create.error}: ${response.error}`));
58
+ return;
59
+ }
60
+ spinner.succeed(chalk_1.default.green(`✓ ${tr.create.success} "${response.project.name}"`));
61
+ console.log(chalk_1.default.dim(`\n Slug: ${response.project.slug}`));
62
+ console.log(chalk_1.default.dim(` Environments: ${response.project.environments.join(", ")}`));
63
+ // Ask if user wants to select this project
64
+ const { selectProject } = await inquirer_1.default.prompt([
65
+ {
66
+ type: "confirm",
67
+ name: "selectProject",
68
+ message: "Select this project now?",
69
+ default: true,
70
+ },
71
+ ]);
72
+ if (selectProject) {
73
+ (0, config_js_1.writeConfig)({
74
+ ...localConfig,
75
+ project: response.project.slug,
76
+ });
77
+ console.log(chalk_1.default.green(`\n✓ ${tr.create.selected}`));
78
+ console.log(chalk_1.default.cyan("\n Commands:"));
79
+ console.log(chalk_1.default.dim(" envsafe pull -d - Pull development variables"));
80
+ console.log(chalk_1.default.dim(" envsafe push - Push variables"));
81
+ }
82
+ }
83
+ catch (error) {
84
+ spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
85
+ }
86
+ }
@@ -0,0 +1 @@
1
+ export declare function init(): Promise<void>;