hereya-cli 0.85.4 → 0.85.5

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.
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import * as yaml from 'yaml';
3
4
  /**
4
5
  * Build the resolved parameter map for an app deployment by:
5
6
  * 1. Starting with each declared parameter's `default` (if present).
@@ -118,3 +119,55 @@ async function collectYamlFiles(dir) {
118
119
  }
119
120
  return out;
120
121
  }
122
+ async function getAnyExisting(...candidates) {
123
+ for (const candidate of candidates) {
124
+ try {
125
+ // eslint-disable-next-line no-await-in-loop
126
+ await fs.access(candidate);
127
+ return candidate;
128
+ }
129
+ catch {
130
+ // try next
131
+ }
132
+ }
133
+ return undefined;
134
+ }
135
+ async function readDeclaredParameters(rootDir) {
136
+ const hereyarcPath = await getAnyExisting(path.join(rootDir, 'hereyarc.yaml'), path.join(rootDir, 'hereyarc.yml'));
137
+ if (!hereyarcPath) {
138
+ return {};
139
+ }
140
+ const content = await fs.readFile(hereyarcPath, 'utf8');
141
+ const parsed = (yaml.parse(content) ?? {});
142
+ return parsed.parameters ?? {};
143
+ }
144
+ /**
145
+ * Read declared parameters from `<rootDir>/hereyarc.yaml`, validate provided
146
+ * values against the declarations, then substitute `{{name}}` placeholders in
147
+ * any `hereyaconfig/hereyavars/*.yaml` files. Returns the resolved parameter
148
+ * map for the caller to forward to `executor.provision({parameters})`.
149
+ *
150
+ * Used by `hereya app deploy --local`, `hereya app destroy --local`, and the
151
+ * remote executor wrapper (which now shells out to those commands).
152
+ */
153
+ export async function resolveAndSubstituteAppParams(input) {
154
+ const declared = await readDeclaredParameters(input.rootDir);
155
+ const resolved = resolveAppParameters({ declared, provided: input.provided });
156
+ if (resolved.errors.length > 0) {
157
+ return { reason: `Parameter validation failed: ${resolved.errors.join('; ')}`, success: false };
158
+ }
159
+ try {
160
+ const { filesWritten } = await substituteAppParameters({
161
+ declaredNames: Object.keys(declared),
162
+ parameters: resolved.parameters,
163
+ rootDir: input.rootDir,
164
+ });
165
+ if (filesWritten.length > 0) {
166
+ input.logger?.info(`Substituted parameters in ${filesWritten.length} hereyavars file(s).`);
167
+ }
168
+ }
169
+ catch (error) {
170
+ return { reason: `Failed to substitute hereyavars parameters: ${error.message}`, success: false };
171
+ }
172
+ return { parameters: resolved.parameters, success: true };
173
+ }
@@ -1201,6 +1201,20 @@
1201
1201
  "<%= config.bin %> <%= command.id %> my-org/my-app -w prod -p organizationId=org-123"
1202
1202
  ],
1203
1203
  "flags": {
1204
+ "chdir": {
1205
+ "description": "Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.",
1206
+ "name": "chdir",
1207
+ "required": false,
1208
+ "hasDynamicHelp": false,
1209
+ "multiple": false,
1210
+ "type": "option"
1211
+ },
1212
+ "local": {
1213
+ "description": "force local execution (skip remote executor)",
1214
+ "name": "local",
1215
+ "allowNo": false,
1216
+ "type": "boolean"
1217
+ },
1204
1218
  "parameter": {
1205
1219
  "char": "p",
1206
1220
  "description": "parameter for the app deployment, in the form of key=value (repeatable)",
@@ -1289,6 +1303,29 @@
1289
1303
  "<%= config.bin %> <%= command.id %> my-org/my-app -w my-workspace"
1290
1304
  ],
1291
1305
  "flags": {
1306
+ "chdir": {
1307
+ "description": "Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.",
1308
+ "name": "chdir",
1309
+ "required": false,
1310
+ "hasDynamicHelp": false,
1311
+ "multiple": false,
1312
+ "type": "option"
1313
+ },
1314
+ "local": {
1315
+ "description": "force local execution (skip remote executor)",
1316
+ "name": "local",
1317
+ "allowNo": false,
1318
+ "type": "boolean"
1319
+ },
1320
+ "parameter": {
1321
+ "char": "p",
1322
+ "description": "parameter for the app deployment, in the form of key=value (repeatable)",
1323
+ "name": "parameter",
1324
+ "default": [],
1325
+ "hasDynamicHelp": false,
1326
+ "multiple": true,
1327
+ "type": "option"
1328
+ },
1292
1329
  "workspace": {
1293
1330
  "char": "w",
1294
1331
  "description": "workspace where the app is currently deployed",
@@ -3102,17 +3139,11 @@
3102
3139
  "index.js"
3103
3140
  ]
3104
3141
  },
3105
- "workspace:executor:uninstall": {
3142
+ "workspace:executor:token": {
3106
3143
  "aliases": [],
3107
3144
  "args": {},
3108
- "description": "Uninstall the remote executor from a workspace",
3145
+ "description": "Generate a workspace-scoped executor token for the remote executor",
3109
3146
  "flags": {
3110
- "debug": {
3111
- "description": "enable debug mode",
3112
- "name": "debug",
3113
- "allowNo": false,
3114
- "type": "boolean"
3115
- },
3116
3147
  "workspace": {
3117
3148
  "char": "w",
3118
3149
  "description": "name of the workspace",
@@ -3125,7 +3156,7 @@
3125
3156
  },
3126
3157
  "hasDynamicHelp": false,
3127
3158
  "hiddenAliases": [],
3128
- "id": "workspace:executor:uninstall",
3159
+ "id": "workspace:executor:token",
3129
3160
  "pluginAlias": "hereya-cli",
3130
3161
  "pluginName": "hereya-cli",
3131
3162
  "pluginType": "core",
@@ -3137,15 +3168,21 @@
3137
3168
  "commands",
3138
3169
  "workspace",
3139
3170
  "executor",
3140
- "uninstall",
3171
+ "token",
3141
3172
  "index.js"
3142
3173
  ]
3143
3174
  },
3144
- "workspace:executor:token": {
3175
+ "workspace:executor:uninstall": {
3145
3176
  "aliases": [],
3146
3177
  "args": {},
3147
- "description": "Generate a workspace-scoped executor token for the remote executor",
3178
+ "description": "Uninstall the remote executor from a workspace",
3148
3179
  "flags": {
3180
+ "debug": {
3181
+ "description": "enable debug mode",
3182
+ "name": "debug",
3183
+ "allowNo": false,
3184
+ "type": "boolean"
3185
+ },
3149
3186
  "workspace": {
3150
3187
  "char": "w",
3151
3188
  "description": "name of the workspace",
@@ -3158,7 +3195,7 @@
3158
3195
  },
3159
3196
  "hasDynamicHelp": false,
3160
3197
  "hiddenAliases": [],
3161
- "id": "workspace:executor:token",
3198
+ "id": "workspace:executor:uninstall",
3162
3199
  "pluginAlias": "hereya-cli",
3163
3200
  "pluginName": "hereya-cli",
3164
3201
  "pluginType": "core",
@@ -3170,10 +3207,10 @@
3170
3207
  "commands",
3171
3208
  "workspace",
3172
3209
  "executor",
3173
- "token",
3210
+ "uninstall",
3174
3211
  "index.js"
3175
3212
  ]
3176
3213
  }
3177
3214
  },
3178
- "version": "0.85.4"
3215
+ "version": "0.85.5"
3179
3216
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.85.4",
4
+ "version": "0.85.5",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"