- Some of values were not converted back from base64, which resulted in
spurious errors with base64 strings.
(This was caused by nested arrays, like commands, not being converted
back, combined with the wrong assumption that commands always occur
before options. It is not always true, as the added test case
demonstrates.)
- Some other values were converted *from* base64, but they weren't
base64 in the first place, which resulted in junk binary data.
(This was due to the invalid assumption that only odd-numbered values
need to be converted.)
Fix#5242
Do this by first supplying the `servicePath` in `~/lib/plugins/lib/validate.js` and `~/lib/plugins/print.js` in a consistent manner with the code in `~/lib/classes/PluginManager.js`. Then, provide a default of `process.cwd()` for `servicePath` in `getCacheFilePath` and `getServerlessConfigFile`.
If an override comes back as a variable containing a deep variable (e.g. `''${self:custom.${deep:1}, "fallback"}''`) or really any variable at all, it needs to be made a deep variable and paused for next iteration. Do this generally rather than only in the case of deep variables. See the test case for a circumstance that the prior fix didn't resolve. This more generalized handling improves the fix and solves a remaining issue we found locally.
Use the variable string from which the overwrite parameters were extracted as the replacement target (in the case of deep variable discovery) rather than the context property which represents the entire original value that the replacement is being waited upon. That context property can contain far more content than the overwrite string itself.
This avoids taking a deep value as a valid term within an overwrite
(defaulting) variable statement that will later resolve to undefined
but, as a deep variable string, is valid in immediate evaluation.
Fixes#5027
Add explanatory text:
```
This can result from latent connections but may represent a cyclic
variable dependency
```
Also, rather than messages such as:
```
Serverless Information ----------------------------------
##########################################################################################
Serverless Information ----------------------------------
# 0: 0 of 2 promises have settled
Serverless Information ----------------------------------
# 0: 2 unsettled promises:
Serverless Information ----------------------------------
# 0: foo waited on by: ${foo:}
Serverless Information ----------------------------------
# 0: foo waited on by: ${foo:}
Serverless Information ----------------------------------
##########################################################################################
```
Collate the message to read like:
```
Serverless Information ----------------------------------
##########################################################################################
# 0: 0 of 2 promises have settled
# 0: 2 unsettled promises:
# 0: foo waited on by: ${foo:}
# 0: foo waited on by: ${foo:}
# This can result from latent connections but may represent a cyclic
variable dependency
##########################################################################################
```
Use the variable syntax present in the given variable string, extracting it from the given string that may contain embedded custom variables (i.e. `${{self:var.${{self:var.foo}}.bar}}`).