@solidactions/cli 0.6.2 → 0.6.3
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 +2 -1
- package/dist/commands/env-map.js +1 -1
- package/dist/commands/env-set.js +168 -0
- package/dist/index.js +14 -12
- package/package.json +1 -1
- package/dist/commands/env-create.js +0 -87
package/README.md
CHANGED
|
@@ -31,7 +31,8 @@ solidactions deploy <project-name> <path>
|
|
|
31
31
|
| `runs [project]` | List recent workflow runs |
|
|
32
32
|
| `logs <run-id>` | View logs for a workflow run |
|
|
33
33
|
| `logs:build <project>` | View build/deployment logs |
|
|
34
|
-
| `env:
|
|
34
|
+
| `env:set <key> <value>` | Set a global variable (create or update) |
|
|
35
|
+
| `env:set <project> <key> <value>` | Set a project variable (create or update) |
|
|
35
36
|
| `env:list [project]` | List environment variables |
|
|
36
37
|
| `env:delete <key>` | Delete an environment variable |
|
|
37
38
|
| `env:map <project> <key> <global-key>` | Map a global variable to a project |
|
package/dist/commands/env-map.js
CHANGED
|
@@ -26,7 +26,7 @@ async function envMap(projectName, projectKey, globalKey) {
|
|
|
26
26
|
const globalVar = variables.find((v) => v.key === globalKey);
|
|
27
27
|
if (!globalVar) {
|
|
28
28
|
console.error(chalk_1.default.red(`Global variable "${globalKey}" not found.`));
|
|
29
|
-
console.log(chalk_1.default.gray('Create it with: solidactions env:
|
|
29
|
+
console.log(chalk_1.default.gray('Create it with: solidactions env:set ' + globalKey + ' <value>'));
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
|
32
32
|
// Create the mapping
|
|
@@ -0,0 +1,168 @@
|
|
|
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.envSet = envSet;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const init_1 = require("./init");
|
|
10
|
+
async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
|
|
11
|
+
const config = (0, init_1.getConfig)();
|
|
12
|
+
if (!config?.apiKey) {
|
|
13
|
+
console.error(chalk_1.default.red('Not initialized. Run "solidactions init <api-key>" first.'));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
// Detect mode based on arguments
|
|
17
|
+
const isProjectMode = valueIfProject !== undefined;
|
|
18
|
+
if (isProjectMode) {
|
|
19
|
+
// Project mode: solidactions env:set <project> <key> <value>
|
|
20
|
+
const projectName = keyOrProject;
|
|
21
|
+
const key = valueOrKey;
|
|
22
|
+
const value = valueIfProject;
|
|
23
|
+
const environment = options.env || 'dev';
|
|
24
|
+
// Build project slug
|
|
25
|
+
const projectSlug = environment === 'production'
|
|
26
|
+
? projectName
|
|
27
|
+
: `${projectName}-${environment}`;
|
|
28
|
+
// Auto-detect secrets
|
|
29
|
+
const isSecret = options.secret || /secret|key|token|password|credential/i.test(key);
|
|
30
|
+
try {
|
|
31
|
+
// Use bulk endpoint for upsert
|
|
32
|
+
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/bulk`, {
|
|
33
|
+
variables: [{
|
|
34
|
+
key,
|
|
35
|
+
value,
|
|
36
|
+
is_secret: isSecret,
|
|
37
|
+
}]
|
|
38
|
+
}, {
|
|
39
|
+
headers: {
|
|
40
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
41
|
+
'Accept': 'application/json',
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const { created, updated } = response.data;
|
|
46
|
+
const action = created > 0 ? 'created' : 'updated';
|
|
47
|
+
console.log(chalk_1.default.green(`Variable "${key}" ${action} in project "${projectName}" (${environment}).`));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error.response) {
|
|
51
|
+
if (error.response.status === 401) {
|
|
52
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions init <api-key>" to re-configure.'));
|
|
53
|
+
}
|
|
54
|
+
else if (error.response.status === 404) {
|
|
55
|
+
console.error(chalk_1.default.red(`Project "${projectSlug}" not found.`));
|
|
56
|
+
}
|
|
57
|
+
else if (error.response.status === 422) {
|
|
58
|
+
console.error(chalk_1.default.red('Validation error:'), error.response.data);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
66
|
+
}
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Global mode: solidactions env:set <key> <value>
|
|
72
|
+
const key = keyOrProject;
|
|
73
|
+
const value = valueOrKey;
|
|
74
|
+
const isSecret = options.secret || false;
|
|
75
|
+
// Build the request body with per-environment values
|
|
76
|
+
const body = {
|
|
77
|
+
key,
|
|
78
|
+
production_value: value,
|
|
79
|
+
is_secret: isSecret,
|
|
80
|
+
};
|
|
81
|
+
// Handle staging value and inheritance
|
|
82
|
+
if (options.stagingInherit) {
|
|
83
|
+
body.staging_source = 'inherit_production';
|
|
84
|
+
}
|
|
85
|
+
else if (options.stagingValue !== undefined) {
|
|
86
|
+
body.staging_value = options.stagingValue;
|
|
87
|
+
body.staging_source = 'value';
|
|
88
|
+
}
|
|
89
|
+
// Handle dev value and inheritance
|
|
90
|
+
if (options.devInheritStaging) {
|
|
91
|
+
body.dev_source = 'inherit_staging';
|
|
92
|
+
}
|
|
93
|
+
else if (options.devInherit) {
|
|
94
|
+
body.dev_source = 'inherit_production';
|
|
95
|
+
}
|
|
96
|
+
else if (options.devValue !== undefined) {
|
|
97
|
+
body.dev_value = options.devValue;
|
|
98
|
+
body.dev_source = 'value';
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
// Check if variable already exists
|
|
102
|
+
const getResponse = await axios_1.default.get(`${config.host}/api/v1/variables`, {
|
|
103
|
+
headers: {
|
|
104
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
105
|
+
'Accept': 'application/json',
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const variables = getResponse.data?.data || [];
|
|
109
|
+
const existing = variables.find((v) => v.key === key);
|
|
110
|
+
let action;
|
|
111
|
+
if (existing) {
|
|
112
|
+
await axios_1.default.put(`${config.host}/api/v1/variables/${existing.id}`, body, {
|
|
113
|
+
headers: {
|
|
114
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
115
|
+
'Accept': 'application/json',
|
|
116
|
+
'Content-Type': 'application/json',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
action = 'updated';
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
await axios_1.default.post(`${config.host}/api/v1/variables`, body, {
|
|
123
|
+
headers: {
|
|
124
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
125
|
+
'Accept': 'application/json',
|
|
126
|
+
'Content-Type': 'application/json',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
action = 'created';
|
|
130
|
+
}
|
|
131
|
+
const typeLabel = isSecret ? 'secret' : 'variable';
|
|
132
|
+
console.log(chalk_1.default.green(`Global ${typeLabel} "${key}" ${action} successfully.`));
|
|
133
|
+
// Show summary of per-environment values
|
|
134
|
+
if (options.stagingValue) {
|
|
135
|
+
console.log(chalk_1.default.gray(` Staging: ${isSecret ? '********' : options.stagingValue}`));
|
|
136
|
+
}
|
|
137
|
+
else if (options.stagingInherit) {
|
|
138
|
+
console.log(chalk_1.default.gray(' Staging: (inherits from production)'));
|
|
139
|
+
}
|
|
140
|
+
if (options.devValue) {
|
|
141
|
+
console.log(chalk_1.default.gray(` Dev: ${isSecret ? '********' : options.devValue}`));
|
|
142
|
+
}
|
|
143
|
+
else if (options.devInheritStaging) {
|
|
144
|
+
console.log(chalk_1.default.gray(' Dev: (inherits from staging)'));
|
|
145
|
+
}
|
|
146
|
+
else if (options.devInherit) {
|
|
147
|
+
console.log(chalk_1.default.gray(' Dev: (inherits from production)'));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error.response) {
|
|
152
|
+
if (error.response.status === 401) {
|
|
153
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions init <api-key>" to re-configure.'));
|
|
154
|
+
}
|
|
155
|
+
else if (error.response.status === 422) {
|
|
156
|
+
console.error(chalk_1.default.red('Validation error:'), error.response.data.message || error.response.data.errors);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
164
|
+
}
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,12 @@ const steps_1 = require("./commands/steps");
|
|
|
10
10
|
const run_1 = require("./commands/run");
|
|
11
11
|
const runs_1 = require("./commands/runs");
|
|
12
12
|
const pull_1 = require("./commands/pull");
|
|
13
|
-
const env_create_1 = require("./commands/env-create");
|
|
14
13
|
const env_list_1 = require("./commands/env-list");
|
|
15
14
|
const env_delete_1 = require("./commands/env-delete");
|
|
16
15
|
const env_map_1 = require("./commands/env-map");
|
|
17
16
|
const env_pull_1 = require("./commands/env-pull");
|
|
18
17
|
const env_push_1 = require("./commands/env-push");
|
|
18
|
+
const env_set_1 = require("./commands/env-set");
|
|
19
19
|
const schedule_set_1 = require("./commands/schedule-set");
|
|
20
20
|
const schedule_list_1 = require("./commands/schedule-list");
|
|
21
21
|
const schedule_delete_1 = require("./commands/schedule-delete");
|
|
@@ -137,18 +137,20 @@ program
|
|
|
137
137
|
// Environment Variables
|
|
138
138
|
// =============================================================================
|
|
139
139
|
program
|
|
140
|
-
.command('env:
|
|
141
|
-
.description('
|
|
142
|
-
.argument('<key>', 'Variable name')
|
|
143
|
-
.argument('<value>', '
|
|
140
|
+
.command('env:set')
|
|
141
|
+
.description('Set an environment variable (create or update, global or project)')
|
|
142
|
+
.argument('<key-or-project>', 'Variable key (global) or project name')
|
|
143
|
+
.argument('<value-or-key>', 'Variable value (global) or variable key (project)')
|
|
144
|
+
.argument('[value]', 'Variable value (when first arg is project)')
|
|
144
145
|
.option('-s, --secret', 'Mark as encrypted secret')
|
|
145
|
-
.option('
|
|
146
|
-
.option('--
|
|
147
|
-
.option('--
|
|
148
|
-
.option('--
|
|
149
|
-
.option('--dev-inherit
|
|
150
|
-
.
|
|
151
|
-
(
|
|
146
|
+
.option('-e, --env <environment>', 'Target environment (production/staging/dev)', 'dev')
|
|
147
|
+
.option('--staging-value <value>', 'Staging environment value (global only)')
|
|
148
|
+
.option('--dev-value <value>', 'Dev environment value (global only)')
|
|
149
|
+
.option('--staging-inherit', 'Staging inherits from production (global only)')
|
|
150
|
+
.option('--dev-inherit', 'Dev inherits from production (global only)')
|
|
151
|
+
.option('--dev-inherit-staging', 'Dev inherits from staging (global only)')
|
|
152
|
+
.action((keyOrProject, valueOrKey, value, options) => {
|
|
153
|
+
(0, env_set_1.envSet)(keyOrProject, valueOrKey, value, options);
|
|
152
154
|
});
|
|
153
155
|
program
|
|
154
156
|
.command('env:list')
|
package/package.json
CHANGED
|
@@ -1,87 +0,0 @@
|
|
|
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.envCreate = envCreate;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const init_1 = require("./init");
|
|
10
|
-
async function envCreate(key, value, options = {}) {
|
|
11
|
-
const config = (0, init_1.getConfig)();
|
|
12
|
-
if (!config?.apiKey) {
|
|
13
|
-
console.error(chalk_1.default.red('Not initialized. Run "solidactions init <api-key>" first.'));
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
console.log(chalk_1.default.blue(`Creating global variable "${key}"...`));
|
|
17
|
-
// Build the request body with per-environment values
|
|
18
|
-
const body = {
|
|
19
|
-
key,
|
|
20
|
-
production_value: value,
|
|
21
|
-
is_secret: options.secret || false,
|
|
22
|
-
};
|
|
23
|
-
// Handle staging value and inheritance
|
|
24
|
-
if (options.stagingInherit) {
|
|
25
|
-
body.staging_source = 'inherit_production';
|
|
26
|
-
}
|
|
27
|
-
else if (options.stagingValue !== undefined) {
|
|
28
|
-
body.staging_value = options.stagingValue;
|
|
29
|
-
body.staging_source = 'value';
|
|
30
|
-
}
|
|
31
|
-
// Handle dev value and inheritance
|
|
32
|
-
if (options.devInheritStaging) {
|
|
33
|
-
body.dev_source = 'inherit_staging';
|
|
34
|
-
}
|
|
35
|
-
else if (options.devInherit) {
|
|
36
|
-
body.dev_source = 'inherit_production';
|
|
37
|
-
}
|
|
38
|
-
else if (options.devValue !== undefined) {
|
|
39
|
-
body.dev_value = options.devValue;
|
|
40
|
-
body.dev_source = 'value';
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
await axios_1.default.post(`${config.host}/api/v1/variables`, body, {
|
|
44
|
-
headers: {
|
|
45
|
-
'Authorization': `Bearer ${config.apiKey}`,
|
|
46
|
-
'Accept': 'application/json',
|
|
47
|
-
'Content-Type': 'application/json',
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
const typeLabel = options.secret ? 'secret' : 'variable';
|
|
51
|
-
console.log(chalk_1.default.green(`Global ${typeLabel} "${key}" created successfully!`));
|
|
52
|
-
// Show summary of what was set
|
|
53
|
-
console.log(chalk_1.default.gray(` Production: ${options.secret ? '********' : value}`));
|
|
54
|
-
if (options.stagingValue) {
|
|
55
|
-
console.log(chalk_1.default.gray(` Staging: ${options.secret ? '********' : options.stagingValue}`));
|
|
56
|
-
}
|
|
57
|
-
else if (options.stagingInherit) {
|
|
58
|
-
console.log(chalk_1.default.gray(' Staging: (inherits from production)'));
|
|
59
|
-
}
|
|
60
|
-
if (options.devValue) {
|
|
61
|
-
console.log(chalk_1.default.gray(` Dev: ${options.secret ? '********' : options.devValue}`));
|
|
62
|
-
}
|
|
63
|
-
else if (options.devInheritStaging) {
|
|
64
|
-
console.log(chalk_1.default.gray(' Dev: (inherits from staging)'));
|
|
65
|
-
}
|
|
66
|
-
else if (options.devInherit) {
|
|
67
|
-
console.log(chalk_1.default.gray(' Dev: (inherits from production)'));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (error.response) {
|
|
72
|
-
if (error.response.status === 401) {
|
|
73
|
-
console.error(chalk_1.default.red('Authentication failed. Run "solidactions init <api-key>" to re-configure.'));
|
|
74
|
-
}
|
|
75
|
-
else if (error.response.status === 422) {
|
|
76
|
-
console.error(chalk_1.default.red('Validation error:'), error.response.data.message || error.response.data.errors);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
84
|
-
}
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
}
|