@envsafes-org/cli 0.1.0 → 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/dist/commands/create.js +18 -16
- package/dist/commands/init.js +31 -29
- package/dist/commands/link.js +20 -18
- package/dist/commands/list.js +12 -10
- package/dist/commands/login.js +39 -10
- package/dist/commands/projects.js +8 -4
- package/dist/commands/pull.d.ts +1 -0
- package/dist/commands/pull.js +101 -15
- package/dist/commands/push.js +27 -18
- package/dist/commands/run.js +16 -10
- package/dist/commands/select.js +17 -14
- package/dist/commands/whoami.js +10 -6
- package/dist/utils/i18n.d.ts +272 -0
- package/dist/utils/i18n.js +313 -0
- package/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -10,16 +10,18 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
10
10
|
const index_js_1 = require("../index.js");
|
|
11
11
|
const api_js_1 = require("../utils/api.js");
|
|
12
12
|
const config_js_1 = require("../utils/config.js");
|
|
13
|
+
const i18n_js_1 = require("../utils/i18n.js");
|
|
13
14
|
async function create(projectName) {
|
|
14
15
|
const token = index_js_1.config.get("token");
|
|
16
|
+
const tr = (0, i18n_js_1.t)();
|
|
15
17
|
if (!token) {
|
|
16
|
-
console.log(chalk_1.default.red(
|
|
18
|
+
console.log(chalk_1.default.red(tr.notConnected));
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
const localConfig = (0, config_js_1.readConfig)();
|
|
20
22
|
if (!localConfig?.workspace) {
|
|
21
|
-
console.log(chalk_1.default.yellow(
|
|
22
|
-
console.log(chalk_1.default.dim(
|
|
23
|
+
console.log(chalk_1.default.yellow(tr.create.noWorkspace));
|
|
24
|
+
console.log(chalk_1.default.dim(` ${tr.create.linkFirst}`));
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
let name = projectName;
|
|
@@ -29,19 +31,19 @@ async function create(projectName) {
|
|
|
29
31
|
{
|
|
30
32
|
type: "input",
|
|
31
33
|
name: "name",
|
|
32
|
-
message:
|
|
33
|
-
validate: (input) => input.trim().length > 0 || "
|
|
34
|
+
message: tr.create.enterName,
|
|
35
|
+
validate: (input) => input.trim().length > 0 || "Name is required",
|
|
34
36
|
},
|
|
35
37
|
{
|
|
36
38
|
type: "input",
|
|
37
39
|
name: "description",
|
|
38
|
-
message: "Description (
|
|
40
|
+
message: "Description (optional):",
|
|
39
41
|
},
|
|
40
42
|
]);
|
|
41
43
|
name = answers.name;
|
|
42
44
|
description = answers.description;
|
|
43
45
|
}
|
|
44
|
-
const spinner = (0, ora_1.default)(
|
|
46
|
+
const spinner = (0, ora_1.default)(`${tr.create.creating} "${name}"...`).start();
|
|
45
47
|
try {
|
|
46
48
|
const response = await (0, api_js_1.apiRequest)(`/api/v1/workspaces/${localConfig.workspace}/projects`, {
|
|
47
49
|
method: "POST",
|
|
@@ -52,18 +54,18 @@ async function create(projectName) {
|
|
|
52
54
|
},
|
|
53
55
|
});
|
|
54
56
|
if (response.error) {
|
|
55
|
-
spinner.fail(chalk_1.default.red(response.error));
|
|
57
|
+
spinner.fail(chalk_1.default.red(`${tr.create.error}: ${response.error}`));
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
|
-
spinner.succeed(chalk_1.default.green(
|
|
60
|
+
spinner.succeed(chalk_1.default.green(`✓ ${tr.create.success} "${response.project.name}"`));
|
|
59
61
|
console.log(chalk_1.default.dim(`\n Slug: ${response.project.slug}`));
|
|
60
|
-
console.log(chalk_1.default.dim(`
|
|
62
|
+
console.log(chalk_1.default.dim(` Environments: ${response.project.environments.join(", ")}`));
|
|
61
63
|
// Ask if user wants to select this project
|
|
62
64
|
const { selectProject } = await inquirer_1.default.prompt([
|
|
63
65
|
{
|
|
64
66
|
type: "confirm",
|
|
65
67
|
name: "selectProject",
|
|
66
|
-
message: "
|
|
68
|
+
message: "Select this project now?",
|
|
67
69
|
default: true,
|
|
68
70
|
},
|
|
69
71
|
]);
|
|
@@ -72,13 +74,13 @@ async function create(projectName) {
|
|
|
72
74
|
...localConfig,
|
|
73
75
|
project: response.project.slug,
|
|
74
76
|
});
|
|
75
|
-
console.log(chalk_1.default.green(`\n✓
|
|
76
|
-
console.log(chalk_1.default.cyan("\n
|
|
77
|
-
console.log(chalk_1.default.dim(" envsafe pull -d -
|
|
78
|
-
console.log(chalk_1.default.dim(" envsafe push -
|
|
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"));
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
catch (error) {
|
|
82
|
-
spinner.fail(chalk_1.default.red(
|
|
84
|
+
spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
|
|
83
85
|
}
|
|
84
86
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -10,10 +10,12 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
10
10
|
const index_js_1 = require("../index.js");
|
|
11
11
|
const api_js_1 = require("../utils/api.js");
|
|
12
12
|
const config_js_1 = require("../utils/config.js");
|
|
13
|
+
const i18n_js_1 = require("../utils/i18n.js");
|
|
13
14
|
async function init() {
|
|
14
15
|
const token = index_js_1.config.get("token");
|
|
16
|
+
const tr = (0, i18n_js_1.t)();
|
|
15
17
|
if (!token) {
|
|
16
|
-
console.log(chalk_1.default.red(
|
|
18
|
+
console.log(chalk_1.default.red(tr.notConnected));
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
// Check if already configured
|
|
@@ -23,20 +25,20 @@ async function init() {
|
|
|
23
25
|
{
|
|
24
26
|
type: "confirm",
|
|
25
27
|
name: "confirm",
|
|
26
|
-
message: `
|
|
28
|
+
message: `Project already configured (${existingConfig.project}). Reconfigure?`,
|
|
27
29
|
default: false,
|
|
28
30
|
},
|
|
29
31
|
]);
|
|
30
32
|
if (!confirm) {
|
|
31
|
-
console.log(chalk_1.default.yellow("
|
|
33
|
+
console.log(chalk_1.default.yellow("Operation cancelled."));
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
// If no workspace is linked, ask to link first
|
|
36
38
|
if (!existingConfig?.workspace) {
|
|
37
|
-
console.log(chalk_1.default.yellow(
|
|
39
|
+
console.log(chalk_1.default.yellow(tr.init.loading));
|
|
38
40
|
// Get workspaces
|
|
39
|
-
const spinner = (0, ora_1.default)(
|
|
41
|
+
const spinner = (0, ora_1.default)(tr.link.loading).start();
|
|
40
42
|
try {
|
|
41
43
|
const response = await (0, api_js_1.apiRequest)("/api/v1/workspaces", {
|
|
42
44
|
method: "GET",
|
|
@@ -47,7 +49,7 @@ async function init() {
|
|
|
47
49
|
return;
|
|
48
50
|
}
|
|
49
51
|
if (response.workspaces.length === 0) {
|
|
50
|
-
spinner.fail(chalk_1.default.yellow(
|
|
52
|
+
spinner.fail(chalk_1.default.yellow(tr.link.noWorkspaces));
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
55
|
spinner.stop();
|
|
@@ -55,9 +57,9 @@ async function init() {
|
|
|
55
57
|
{
|
|
56
58
|
type: "list",
|
|
57
59
|
name: "workspace",
|
|
58
|
-
message:
|
|
60
|
+
message: tr.init.selectWorkspace,
|
|
59
61
|
choices: response.workspaces.map((ws) => ({
|
|
60
|
-
name: `${ws.name} (${ws.slug}) - ${ws.projectCount}
|
|
62
|
+
name: `${ws.name} (${ws.slug}) - ${ws.projectCount} project(s)`,
|
|
61
63
|
value: ws.slug,
|
|
62
64
|
})),
|
|
63
65
|
},
|
|
@@ -66,18 +68,18 @@ async function init() {
|
|
|
66
68
|
(0, config_js_1.writeConfig)({ workspace });
|
|
67
69
|
}
|
|
68
70
|
catch (error) {
|
|
69
|
-
spinner.fail(chalk_1.default.red(
|
|
71
|
+
spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
// Re-read config after potential workspace selection
|
|
74
76
|
const currentConfig = (0, config_js_1.readConfig)();
|
|
75
77
|
if (!currentConfig?.workspace) {
|
|
76
|
-
console.log(chalk_1.default.red("✗ Workspace
|
|
78
|
+
console.log(chalk_1.default.red("✗ Workspace not configured."));
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
81
|
// Get projects from workspace
|
|
80
|
-
const spinner = (0, ora_1.default)(
|
|
82
|
+
const spinner = (0, ora_1.default)(`${tr.init.loadingProjects} "${currentConfig.workspace}"...`).start();
|
|
81
83
|
try {
|
|
82
84
|
const response = await (0, api_js_1.apiRequest)(`/api/v1/workspaces/${currentConfig.workspace}/projects`, {
|
|
83
85
|
method: "GET",
|
|
@@ -89,12 +91,12 @@ async function init() {
|
|
|
89
91
|
}
|
|
90
92
|
if (response.projects.length === 0) {
|
|
91
93
|
spinner.stop();
|
|
92
|
-
console.log(chalk_1.default.yellow(
|
|
94
|
+
console.log(chalk_1.default.yellow(`\n${tr.init.noProjects}`));
|
|
93
95
|
const { createNew } = await inquirer_1.default.prompt([
|
|
94
96
|
{
|
|
95
97
|
type: "confirm",
|
|
96
98
|
name: "createNew",
|
|
97
|
-
message: "
|
|
99
|
+
message: "Create a new project?",
|
|
98
100
|
default: true,
|
|
99
101
|
},
|
|
100
102
|
]);
|
|
@@ -103,16 +105,16 @@ async function init() {
|
|
|
103
105
|
{
|
|
104
106
|
type: "input",
|
|
105
107
|
name: "name",
|
|
106
|
-
message:
|
|
107
|
-
validate: (input) => input.trim().length > 0 || "
|
|
108
|
+
message: tr.create.enterName,
|
|
109
|
+
validate: (input) => input.trim().length > 0 || "Name is required",
|
|
108
110
|
},
|
|
109
111
|
{
|
|
110
112
|
type: "input",
|
|
111
113
|
name: "description",
|
|
112
|
-
message: "Description (
|
|
114
|
+
message: "Description (optional):",
|
|
113
115
|
},
|
|
114
116
|
]);
|
|
115
|
-
const createSpinner = (0, ora_1.default)(
|
|
117
|
+
const createSpinner = (0, ora_1.default)(tr.create.creating).start();
|
|
116
118
|
const createResponse = await (0, api_js_1.apiRequest)(`/api/v1/workspaces/${currentConfig.workspace}/projects`, {
|
|
117
119
|
method: "POST",
|
|
118
120
|
token,
|
|
@@ -122,14 +124,14 @@ async function init() {
|
|
|
122
124
|
createSpinner.fail(chalk_1.default.red(createResponse.error));
|
|
123
125
|
return;
|
|
124
126
|
}
|
|
125
|
-
createSpinner.succeed(chalk_1.default.green(
|
|
127
|
+
createSpinner.succeed(chalk_1.default.green(`✓ ${tr.create.success} "${createResponse.project.name}"`));
|
|
126
128
|
// Update config with new project
|
|
127
129
|
(0, config_js_1.writeConfig)({
|
|
128
130
|
...currentConfig,
|
|
129
131
|
project: createResponse.project.slug,
|
|
130
132
|
});
|
|
131
|
-
console.log(chalk_1.default.green(`\n✓
|
|
132
|
-
console.log(chalk_1.default.dim(`
|
|
133
|
+
console.log(chalk_1.default.green(`\n✓ ${tr.init.success}`));
|
|
134
|
+
console.log(chalk_1.default.dim(` ${tr.init.readyToPull}`));
|
|
133
135
|
return;
|
|
134
136
|
}
|
|
135
137
|
return;
|
|
@@ -140,7 +142,7 @@ async function init() {
|
|
|
140
142
|
{
|
|
141
143
|
type: "list",
|
|
142
144
|
name: "project",
|
|
143
|
-
message:
|
|
145
|
+
message: tr.init.selectProject,
|
|
144
146
|
choices: response.projects.map((p) => ({
|
|
145
147
|
name: `${p.name} (${p.slug}) - ${p.environments.join(", ")}`,
|
|
146
148
|
value: p.slug,
|
|
@@ -152,15 +154,15 @@ async function init() {
|
|
|
152
154
|
...currentConfig,
|
|
153
155
|
project,
|
|
154
156
|
});
|
|
155
|
-
console.log(chalk_1.default.green(`\n✓
|
|
156
|
-
console.log(chalk_1.default.dim(`
|
|
157
|
-
console.log(chalk_1.default.cyan("\n
|
|
158
|
-
console.log(chalk_1.default.dim(" envsafe pull -d -
|
|
159
|
-
console.log(chalk_1.default.dim(" envsafe pull -s -
|
|
160
|
-
console.log(chalk_1.default.dim(" envsafe pull -p -
|
|
161
|
-
console.log(chalk_1.default.dim(" envsafe push -
|
|
157
|
+
console.log(chalk_1.default.green(`\n✓ ${tr.init.success}`));
|
|
158
|
+
console.log(chalk_1.default.dim(` ${tr.init.readyToPull}`));
|
|
159
|
+
console.log(chalk_1.default.cyan("\n Commands:"));
|
|
160
|
+
console.log(chalk_1.default.dim(" envsafe pull -d - Pull development variables"));
|
|
161
|
+
console.log(chalk_1.default.dim(" envsafe pull -s - Pull staging variables"));
|
|
162
|
+
console.log(chalk_1.default.dim(" envsafe pull -p - Pull production variables"));
|
|
163
|
+
console.log(chalk_1.default.dim(" envsafe push - Push variables"));
|
|
162
164
|
}
|
|
163
165
|
catch (error) {
|
|
164
|
-
spinner.fail(chalk_1.default.red(
|
|
166
|
+
spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
|
|
165
167
|
}
|
|
166
168
|
}
|
package/dist/commands/link.js
CHANGED
|
@@ -10,10 +10,12 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
10
10
|
const index_js_1 = require("../index.js");
|
|
11
11
|
const api_js_1 = require("../utils/api.js");
|
|
12
12
|
const config_js_1 = require("../utils/config.js");
|
|
13
|
+
const i18n_js_1 = require("../utils/i18n.js");
|
|
13
14
|
async function link(workspaceSlug) {
|
|
14
15
|
const token = index_js_1.config.get("token");
|
|
16
|
+
const tr = (0, i18n_js_1.t)();
|
|
15
17
|
if (!token) {
|
|
16
|
-
console.log(chalk_1.default.red(
|
|
18
|
+
console.log(chalk_1.default.red(tr.notConnected));
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
// If config already exists, warn user
|
|
@@ -23,19 +25,19 @@ async function link(workspaceSlug) {
|
|
|
23
25
|
{
|
|
24
26
|
type: "confirm",
|
|
25
27
|
name: "confirm",
|
|
26
|
-
message: `
|
|
28
|
+
message: `A .envsafe file exists (workspace: ${existingConfig?.workspace}). Overwrite?`,
|
|
27
29
|
default: false,
|
|
28
30
|
},
|
|
29
31
|
]);
|
|
30
32
|
if (!confirm) {
|
|
31
|
-
console.log(chalk_1.default.yellow("
|
|
33
|
+
console.log(chalk_1.default.yellow("Operation cancelled."));
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
let selectedWorkspace;
|
|
36
38
|
if (workspaceSlug) {
|
|
37
39
|
// Verify workspace exists and user has access
|
|
38
|
-
const spinner = (0, ora_1.default)(
|
|
40
|
+
const spinner = (0, ora_1.default)(tr.link.verifying).start();
|
|
39
41
|
try {
|
|
40
42
|
const response = await (0, api_js_1.apiRequest)(`/api/v1/workspaces/${workspaceSlug}`, {
|
|
41
43
|
method: "GET",
|
|
@@ -45,17 +47,17 @@ async function link(workspaceSlug) {
|
|
|
45
47
|
spinner.fail(chalk_1.default.red(response.error));
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
spinner.succeed(chalk_1.default.green(`Workspace "${response.workspace.name}"
|
|
50
|
+
spinner.succeed(chalk_1.default.green(`Workspace "${response.workspace.name}" found`));
|
|
49
51
|
selectedWorkspace = workspaceSlug;
|
|
50
52
|
}
|
|
51
53
|
catch (error) {
|
|
52
|
-
spinner.fail(chalk_1.default.red(
|
|
54
|
+
spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
else {
|
|
57
59
|
// List workspaces and let user choose
|
|
58
|
-
const spinner = (0, ora_1.default)(
|
|
60
|
+
const spinner = (0, ora_1.default)(tr.link.loading).start();
|
|
59
61
|
try {
|
|
60
62
|
const response = await (0, api_js_1.apiRequest)("/api/v1/workspaces", {
|
|
61
63
|
method: "GET",
|
|
@@ -66,8 +68,8 @@ async function link(workspaceSlug) {
|
|
|
66
68
|
return;
|
|
67
69
|
}
|
|
68
70
|
if (response.workspaces.length === 0) {
|
|
69
|
-
spinner.fail(chalk_1.default.yellow(
|
|
70
|
-
console.log(chalk_1.default.dim(
|
|
71
|
+
spinner.fail(chalk_1.default.yellow(tr.link.noWorkspaces));
|
|
72
|
+
console.log(chalk_1.default.dim(tr.link.createFirst));
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
spinner.stop();
|
|
@@ -75,9 +77,9 @@ async function link(workspaceSlug) {
|
|
|
75
77
|
{
|
|
76
78
|
type: "list",
|
|
77
79
|
name: "workspace",
|
|
78
|
-
message:
|
|
80
|
+
message: tr.link.selectWorkspace,
|
|
79
81
|
choices: response.workspaces.map((ws) => ({
|
|
80
|
-
name: `${ws.name} (${ws.slug}) - ${ws.projectCount}
|
|
82
|
+
name: `${ws.name} (${ws.slug}) - ${ws.projectCount} project(s) [${ws.role}]`,
|
|
81
83
|
value: ws.slug,
|
|
82
84
|
})),
|
|
83
85
|
},
|
|
@@ -85,7 +87,7 @@ async function link(workspaceSlug) {
|
|
|
85
87
|
selectedWorkspace = workspace;
|
|
86
88
|
}
|
|
87
89
|
catch (error) {
|
|
88
|
-
spinner.fail(chalk_1.default.red(
|
|
90
|
+
spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
93
|
}
|
|
@@ -93,10 +95,10 @@ async function link(workspaceSlug) {
|
|
|
93
95
|
(0, config_js_1.writeConfig)({
|
|
94
96
|
workspace: selectedWorkspace,
|
|
95
97
|
});
|
|
96
|
-
console.log(chalk_1.default.green(`\n✓
|
|
97
|
-
console.log(chalk_1.default.dim(`
|
|
98
|
-
console.log(chalk_1.default.cyan("\n
|
|
99
|
-
console.log(chalk_1.default.dim(" envsafe list -
|
|
100
|
-
console.log(chalk_1.default.dim(" envsafe select -
|
|
101
|
-
console.log(chalk_1.default.dim(" envsafe create -
|
|
98
|
+
console.log(chalk_1.default.green(`\n✓ ${tr.link.success}`));
|
|
99
|
+
console.log(chalk_1.default.dim(` ${tr.link.configCreated} - ${process.cwd()}`));
|
|
100
|
+
console.log(chalk_1.default.cyan("\n Next steps:"));
|
|
101
|
+
console.log(chalk_1.default.dim(" envsafe list - See available projects"));
|
|
102
|
+
console.log(chalk_1.default.dim(" envsafe select - Select a project"));
|
|
103
|
+
console.log(chalk_1.default.dim(" envsafe create - Create a new project"));
|
|
102
104
|
}
|
package/dist/commands/list.js
CHANGED
|
@@ -9,19 +9,21 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
9
9
|
const index_js_1 = require("../index.js");
|
|
10
10
|
const api_js_1 = require("../utils/api.js");
|
|
11
11
|
const config_js_1 = require("../utils/config.js");
|
|
12
|
+
const i18n_js_1 = require("../utils/i18n.js");
|
|
12
13
|
async function list() {
|
|
13
14
|
const token = index_js_1.config.get("token");
|
|
15
|
+
const tr = (0, i18n_js_1.t)();
|
|
14
16
|
if (!token) {
|
|
15
|
-
console.log(chalk_1.default.red(
|
|
17
|
+
console.log(chalk_1.default.red(tr.notConnected));
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
20
|
const localConfig = (0, config_js_1.readConfig)();
|
|
19
21
|
if (!localConfig?.workspace) {
|
|
20
|
-
console.log(chalk_1.default.yellow(
|
|
21
|
-
console.log(chalk_1.default.dim(
|
|
22
|
+
console.log(chalk_1.default.yellow(tr.list.noWorkspace));
|
|
23
|
+
console.log(chalk_1.default.dim(` ${tr.list.linkFirst}`));
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
|
-
const spinner = (0, ora_1.default)(
|
|
26
|
+
const spinner = (0, ora_1.default)(`${tr.list.loading} "${localConfig.workspace}"...`).start();
|
|
25
27
|
try {
|
|
26
28
|
const response = await (0, api_js_1.apiRequest)(`/api/v1/workspaces/${localConfig.workspace}/projects`, {
|
|
27
29
|
method: "GET",
|
|
@@ -32,16 +34,16 @@ async function list() {
|
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
spinner.stop();
|
|
35
|
-
console.log(chalk_1.default.cyan(`\n📁
|
|
37
|
+
console.log(chalk_1.default.cyan(`\n📁 ${tr.list.projects} "${response.workspace.name}"\n`));
|
|
36
38
|
if (response.projects.length === 0) {
|
|
37
|
-
console.log(chalk_1.default.dim(
|
|
38
|
-
console.log(chalk_1.default.dim(
|
|
39
|
+
console.log(chalk_1.default.dim(` ${tr.list.noProjects}`));
|
|
40
|
+
console.log(chalk_1.default.dim(`\n Use: envsafe create <name>`));
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
41
43
|
for (const project of response.projects) {
|
|
42
44
|
const isSelected = localConfig.project === project.slug;
|
|
43
45
|
const prefix = isSelected ? chalk_1.default.green("● ") : " ";
|
|
44
|
-
const suffix = isSelected ? chalk_1.default.green(
|
|
46
|
+
const suffix = isSelected ? chalk_1.default.green(` (${tr.list.current})`) : "";
|
|
45
47
|
console.log(`${prefix}${chalk_1.default.bold(project.name)}${suffix}`);
|
|
46
48
|
console.log(chalk_1.default.dim(` slug: ${project.slug}`));
|
|
47
49
|
console.log(chalk_1.default.dim(` envs: ${project.environments.join(", ")}`));
|
|
@@ -51,10 +53,10 @@ async function list() {
|
|
|
51
53
|
console.log("");
|
|
52
54
|
}
|
|
53
55
|
if (!localConfig.project) {
|
|
54
|
-
console.log(chalk_1.default.dim("
|
|
56
|
+
console.log(chalk_1.default.dim("Use: envsafe select <slug>"));
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
catch (error) {
|
|
58
|
-
spinner.fail(chalk_1.default.red(
|
|
60
|
+
spinner.fail(chalk_1.default.red(`${tr.error}: ${error.message}`));
|
|
59
61
|
}
|
|
60
62
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -8,32 +8,37 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
9
9
|
const index_js_1 = require("../index.js");
|
|
10
10
|
const api_js_1 = require("../utils/api.js");
|
|
11
|
+
const i18n_js_1 = require("../utils/i18n.js");
|
|
11
12
|
const open_1 = __importDefault(require("open"));
|
|
12
13
|
async function login(options) {
|
|
13
14
|
let token = options.token;
|
|
14
15
|
if (!token) {
|
|
15
16
|
const dashboardUrl = index_js_1.config.get("dashboardUrl");
|
|
16
17
|
const loginUrl = `${dashboardUrl}/dashboard?redirect=tokens`;
|
|
17
|
-
console.log(chalk_1.default.cyan(`\
|
|
18
|
-
console.log(chalk_1.default.dim(`
|
|
18
|
+
console.log(chalk_1.default.cyan(`\n${(0, i18n_js_1.t)().login.opening}\n`));
|
|
19
|
+
console.log(chalk_1.default.dim(`If browser doesn't open, visit: ${loginUrl}`));
|
|
19
20
|
try {
|
|
20
21
|
await (0, open_1.default)(loginUrl);
|
|
21
22
|
}
|
|
22
|
-
catch
|
|
23
|
+
catch {
|
|
23
24
|
// Ignore error if browser fails to open
|
|
24
25
|
}
|
|
26
|
+
console.log(chalk_1.default.dim(`\n${(0, i18n_js_1.t)().login.instructions}`));
|
|
27
|
+
console.log(chalk_1.default.dim((0, i18n_js_1.t)().login.getToken));
|
|
28
|
+
console.log(chalk_1.default.dim((0, i18n_js_1.t)().login.pasteToken));
|
|
29
|
+
console.log();
|
|
25
30
|
const answers = await inquirer_1.default.prompt([
|
|
26
31
|
{
|
|
27
32
|
type: "password",
|
|
28
33
|
name: "token",
|
|
29
|
-
message:
|
|
34
|
+
message: (0, i18n_js_1.t)().login.enterToken,
|
|
30
35
|
mask: "*",
|
|
31
|
-
validate: (input) => input.length > 0 || "
|
|
36
|
+
validate: (input) => input.length > 0 || "Token is required",
|
|
32
37
|
},
|
|
33
38
|
]);
|
|
34
39
|
token = answers.token;
|
|
35
40
|
}
|
|
36
|
-
console.log(chalk_1.default.dim(
|
|
41
|
+
console.log(chalk_1.default.dim((0, i18n_js_1.t)().login.validating));
|
|
37
42
|
try {
|
|
38
43
|
// Test the token
|
|
39
44
|
const response = await (0, api_js_1.apiRequest)("/api/v1/projects", {
|
|
@@ -41,15 +46,39 @@ async function login(options) {
|
|
|
41
46
|
token,
|
|
42
47
|
});
|
|
43
48
|
if (response.error) {
|
|
44
|
-
console.log(chalk_1.default.red(`✗
|
|
49
|
+
console.log(chalk_1.default.red(`✗ ${(0, i18n_js_1.t)().error}: ${response.error}`));
|
|
45
50
|
return;
|
|
46
51
|
}
|
|
47
52
|
// Save token
|
|
48
53
|
index_js_1.config.set("token", token);
|
|
49
|
-
console.log(chalk_1.default.green(
|
|
50
|
-
console.log(chalk_1.default.dim(` ${response.count}
|
|
54
|
+
console.log(chalk_1.default.green(`✓ ${(0, i18n_js_1.t)().login.success}`));
|
|
55
|
+
console.log(chalk_1.default.dim(` ${response.count} project(s) accessible`));
|
|
56
|
+
console.log();
|
|
57
|
+
// Ask for language preference
|
|
58
|
+
const langAnswer = await inquirer_1.default.prompt([
|
|
59
|
+
{
|
|
60
|
+
type: "list",
|
|
61
|
+
name: "language",
|
|
62
|
+
message: (0, i18n_js_1.t)().login.chooseLanguage,
|
|
63
|
+
choices: [
|
|
64
|
+
{ name: "🇬🇧 English", value: "en" },
|
|
65
|
+
{ name: "🇫🇷 Français", value: "fr" },
|
|
66
|
+
],
|
|
67
|
+
default: "en",
|
|
68
|
+
},
|
|
69
|
+
]);
|
|
70
|
+
(0, i18n_js_1.setLanguage)(langAnswer.language);
|
|
71
|
+
// Show confirmation in the chosen language
|
|
72
|
+
const msgs = langAnswer.language === "fr"
|
|
73
|
+
? "Langue définie sur Français."
|
|
74
|
+
: "Language set to English.";
|
|
75
|
+
console.log(chalk_1.default.green(`✓ ${msgs}`));
|
|
76
|
+
console.log();
|
|
77
|
+
console.log(chalk_1.default.dim(langAnswer.language === "fr"
|
|
78
|
+
? "Utilisez 'envsafe init' pour configurer votre projet."
|
|
79
|
+
: "Use 'envsafe init' to configure your project."));
|
|
51
80
|
}
|
|
52
81
|
catch (error) {
|
|
53
|
-
console.log(chalk_1.default.red(`✗
|
|
82
|
+
console.log(chalk_1.default.red(`✗ ${(0, i18n_js_1.t)().error}: ${error.message}`));
|
|
54
83
|
}
|
|
55
84
|
}
|
|
@@ -7,12 +7,15 @@ exports.projects = projects;
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const index_js_1 = require("../index.js");
|
|
9
9
|
const api_js_1 = require("../utils/api.js");
|
|
10
|
+
const i18n_js_1 = require("../utils/i18n.js");
|
|
10
11
|
async function projects() {
|
|
11
12
|
const token = index_js_1.config.get("token");
|
|
13
|
+
const tr = (0, i18n_js_1.t)();
|
|
12
14
|
if (!token) {
|
|
13
|
-
console.log(chalk_1.default.red(
|
|
15
|
+
console.log(chalk_1.default.red(tr.notConnected));
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
18
|
+
console.log(chalk_1.default.dim(tr.projects.loading));
|
|
16
19
|
try {
|
|
17
20
|
const response = await (0, api_js_1.apiRequest)("/api/v1/projects", {
|
|
18
21
|
method: "GET",
|
|
@@ -22,9 +25,10 @@ async function projects() {
|
|
|
22
25
|
console.log(chalk_1.default.red(`✗ ${response.error}`));
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
|
-
console.log(chalk_1.default.cyan(
|
|
28
|
+
console.log(chalk_1.default.cyan(`\n📁 ${tr.projects.yourProjects}\n`));
|
|
26
29
|
if (response.projects.length === 0) {
|
|
27
|
-
console.log(chalk_1.default.dim(
|
|
30
|
+
console.log(chalk_1.default.dim(` ${tr.projects.noProjects}`));
|
|
31
|
+
console.log(chalk_1.default.dim(` ${tr.projects.createFirst}`));
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
30
34
|
for (const project of response.projects) {
|
|
@@ -35,6 +39,6 @@ async function projects() {
|
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
catch (error) {
|
|
38
|
-
console.log(chalk_1.default.red(`✗
|
|
42
|
+
console.log(chalk_1.default.red(`✗ ${tr.error}: ${error.message}`));
|
|
39
43
|
}
|
|
40
44
|
}
|