@solidactions/cli 3.5.0 → 3.6.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/command-manifest.json +1 -1
- package/dist/commands/deploy.js +29 -14
- package/dist/utils/env.js +15 -6
- package/package.json +1 -1
package/dist/commands/deploy.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.isConfirmationMatch = isConfirmationMatch;
|
|
|
11
11
|
exports.confirmDeploymentWithRetry = confirmDeploymentWithRetry;
|
|
12
12
|
exports.formatDeploymentConfirmation = formatDeploymentConfirmation;
|
|
13
13
|
exports.safeCollectSourceMetadata = safeCollectSourceMetadata;
|
|
14
|
+
exports.pushYamlDeclarations = pushYamlDeclarations;
|
|
14
15
|
exports.shouldPrintWorkspaceMismatch = shouldPrintWorkspaceMismatch;
|
|
15
16
|
exports.isPlanLimitReachedError = isPlanLimitReachedError;
|
|
16
17
|
exports.handlePlanLimitReached = handlePlanLimitReached;
|
|
@@ -214,28 +215,29 @@ function safeCollectSourceMetadata(sourceDir, options, collector = source_proven
|
|
|
214
215
|
/**
|
|
215
216
|
* Push YAML env declarations to the project.
|
|
216
217
|
* This registers all YAML-declared vars and their mappings.
|
|
218
|
+
*
|
|
219
|
+
* Always POSTs, even when `parsedVars` is empty: the endpoint prunes stale
|
|
220
|
+
* mappings on an explicit `declarations: []`, so removing the last YAML env
|
|
221
|
+
* declaration must still reach it (spec #1127 §4B).
|
|
222
|
+
*
|
|
223
|
+
* Throws the raw axios error on failure — callers decide how to handle it
|
|
224
|
+
* (PM round #1127 finding 14: a failed sync must never be reported as
|
|
225
|
+
* success by the caller).
|
|
217
226
|
*/
|
|
218
227
|
async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
|
|
219
228
|
const parsedVars = (0, env_1.parseYamlEnvVars)(yamlConfig);
|
|
220
|
-
if (parsedVars.length === 0) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
229
|
// Build the declarations array
|
|
224
230
|
const declarations = parsedVars.map(v => ({
|
|
225
231
|
env_name: v.key,
|
|
226
232
|
yaml_default_global_key: v.mappedTo,
|
|
227
233
|
yaml_default_oauth_name: v.oauthName,
|
|
234
|
+
yaml_default_database_name: v.databaseName,
|
|
228
235
|
source: 'yaml',
|
|
229
236
|
}));
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
console.log(chalk_1.default.gray(`Synced ${declarations.length} YAML env declarations`));
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
console.error(chalk_1.default.yellow('Warning: Failed to sync YAML declarations:'), error.response?.data?.message || error.message);
|
|
238
|
-
}
|
|
237
|
+
await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
|
|
238
|
+
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
239
|
+
});
|
|
240
|
+
console.log(chalk_1.default.gray(`Synced ${declarations.length} YAML env declarations`));
|
|
239
241
|
}
|
|
240
242
|
/**
|
|
241
243
|
* Returns true only when a 404 on the environment-specific project lookup
|
|
@@ -492,7 +494,13 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
492
494
|
console.error(chalk_1.default.red('Cannot sync config: solidactions.yaml not found or invalid.'));
|
|
493
495
|
process.exit(1);
|
|
494
496
|
}
|
|
495
|
-
|
|
497
|
+
try {
|
|
498
|
+
await pushYamlDeclarations(config, projectSlug, yamlConfig);
|
|
499
|
+
}
|
|
500
|
+
catch (error) {
|
|
501
|
+
console.error(chalk_1.default.red(`Config sync FAILED: ${error.response?.data?.message || error.message}`));
|
|
502
|
+
process.exit(1);
|
|
503
|
+
}
|
|
496
504
|
console.log(chalk_1.default.green(`✓ Config synced for ${projectSlug}${envLabel}`));
|
|
497
505
|
return;
|
|
498
506
|
}
|
|
@@ -606,7 +614,14 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
606
614
|
}
|
|
607
615
|
// Always sync YAML declarations (registers variables and their mappings)
|
|
608
616
|
if (yamlConfig) {
|
|
609
|
-
|
|
617
|
+
try {
|
|
618
|
+
await pushYamlDeclarations(config, projectSlug, yamlConfig);
|
|
619
|
+
}
|
|
620
|
+
catch (error) {
|
|
621
|
+
console.error(chalk_1.default.red(`Config sync FAILED: ${error.response?.data?.message || error.message}`));
|
|
622
|
+
cleanupArchive();
|
|
623
|
+
process.exit(1);
|
|
624
|
+
}
|
|
610
625
|
}
|
|
611
626
|
if (yamlConfig && shouldPrintWebhookSecretNotice(yamlConfig.workflows ?? [])) {
|
|
612
627
|
const envFlag = environment !== 'dev' ? ` -e ${environment}` : '';
|
package/dist/utils/env.js
CHANGED
|
@@ -48,8 +48,10 @@ function parseEnvFile(filePath) {
|
|
|
48
48
|
/**
|
|
49
49
|
* Parse YAML env declarations into structured format.
|
|
50
50
|
* Handles the new simplified format:
|
|
51
|
-
* - VAR_NAME
|
|
52
|
-
* - VAR_NAME: GLOBAL
|
|
51
|
+
* - VAR_NAME -> { key: "VAR_NAME", mappedTo: null }
|
|
52
|
+
* - VAR_NAME: GLOBAL -> { key: "VAR_NAME", mappedTo: "GLOBAL" }
|
|
53
|
+
* - VAR_NAME:\n oauth: "Name" -> { key: "VAR_NAME", oauthName: "Name" }
|
|
54
|
+
* - VAR_NAME:\n database: "Name" -> { key: "VAR_NAME", databaseName: "Name" }
|
|
53
55
|
*/
|
|
54
56
|
function parseYamlEnvVars(config) {
|
|
55
57
|
const parsedVars = [];
|
|
@@ -59,10 +61,11 @@ function parseYamlEnvVars(config) {
|
|
|
59
61
|
for (const item of config.env) {
|
|
60
62
|
if (typeof item === 'string') {
|
|
61
63
|
// Simple string: - VAR_NAME (declared only, needs configuration)
|
|
62
|
-
parsedVars.push({ key: item, mappedTo: null, oauthName: null });
|
|
64
|
+
parsedVars.push({ key: item, mappedTo: null, oauthName: null, databaseName: null });
|
|
63
65
|
}
|
|
64
66
|
else if (typeof item === 'object' && item !== null) {
|
|
65
|
-
// Object: - VAR_NAME: GLOBAL_NAME
|
|
67
|
+
// Object: - VAR_NAME: GLOBAL_NAME, - VAR_NAME: { oauth: connection-name },
|
|
68
|
+
// or - VAR_NAME: { database: database-name }
|
|
66
69
|
const keys = Object.keys(item);
|
|
67
70
|
if (keys.length === 1) {
|
|
68
71
|
const key = keys[0];
|
|
@@ -71,10 +74,16 @@ function parseYamlEnvVars(config) {
|
|
|
71
74
|
if (typeof value.oauth !== 'string' || !value.oauth) {
|
|
72
75
|
throw new Error(`Invalid env config for ${key}: 'oauth' must be a non-empty string`);
|
|
73
76
|
}
|
|
74
|
-
parsedVars.push({ key, mappedTo: null, oauthName: value.oauth });
|
|
77
|
+
parsedVars.push({ key, mappedTo: null, oauthName: value.oauth, databaseName: null });
|
|
78
|
+
}
|
|
79
|
+
else if (typeof value === 'object' && value !== null && 'database' in value) {
|
|
80
|
+
if (typeof value.database !== 'string' || !value.database) {
|
|
81
|
+
throw new Error(`Invalid env config for ${key}: 'database' must be a non-empty string`);
|
|
82
|
+
}
|
|
83
|
+
parsedVars.push({ key, mappedTo: null, oauthName: null, databaseName: value.database });
|
|
75
84
|
}
|
|
76
85
|
else {
|
|
77
|
-
parsedVars.push({ key, mappedTo: value || null, oauthName: null });
|
|
86
|
+
parsedVars.push({ key, mappedTo: value || null, oauthName: null, databaseName: null });
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
}
|