@mikarinneoracle/oci-cdk-code-only-preview 0.0.5 → 0.0.6

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.
@@ -89,9 +89,13 @@ function createArchive() {
89
89
  }
90
90
 
91
91
  function jsonOci(args) {
92
- const output = runOci([...args, '--output', 'json']);
92
+ const output = runOci([...args, '--output', 'json']).trim();
93
+ const objectStart = output.indexOf('{');
94
+ const arrayStart = output.indexOf('[');
95
+ const start = objectStart !== -1 ? objectStart : arrayStart;
96
+ const end = Math.max(output.lastIndexOf('}'), output.lastIndexOf(']'));
93
97
  try {
94
- return JSON.parse(output);
98
+ return JSON.parse(start === -1 || end < start ? output : output.slice(start, end + 1));
95
99
  } catch {
96
100
  fail(`OCI CLI returned invalid JSON for: ${args.join(' ')}`);
97
101
  }
@@ -24,8 +24,13 @@ function runOci(args) {
24
24
  }
25
25
 
26
26
  function jsonOci(args) {
27
+ const output = runOci([...args, '--output', 'json']).trim();
28
+ const objectStart = output.indexOf('{');
29
+ const arrayStart = output.indexOf('[');
30
+ const start = objectStart !== -1 ? objectStart : arrayStart;
31
+ const end = Math.max(output.lastIndexOf('}'), output.lastIndexOf(']'));
27
32
  try {
28
- return JSON.parse(runOci([...args, '--output', 'json']));
33
+ return JSON.parse(start === -1 || end < start ? output : output.slice(start, end + 1));
29
34
  } catch (error) {
30
35
  fail(`OCI CLI returned invalid JSON for: ${args.join(' ')} (${error.message})`);
31
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikarinneoracle/oci-cdk-code-only-preview",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "OCI CDK stack for OCI Functions, API Gateway, and related infrastructure",
5
5
  "main": "lib/index.js",
6
6
  "bin": {