@mikarinneoracle/oci-cdk-code-only-preview 0.0.3 → 0.0.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @mikarinneoracle/oci-cdk
1
+ # @mikarinneoracle/oci-cdk-code-only-preview
2
2
 
3
3
  OCI Functions (Java, Python, Node.js), API Gateway, and related infrastructure via Terraform CDK. Run from your project root with `npx ocdk`.
4
4
 
@@ -7,7 +7,7 @@ Quick example (Python function + API Gateway):
7
7
  ```bash
8
8
  mkdir my-python-function && cd my-python-function
9
9
  fn init --runtime python
10
- npm i --ignore-scripts @mikarinneoracle/oci-cdk
10
+ npm i --ignore-scripts @mikarinneoracle/oci-cdk-code-only-preview
11
11
  export OCI_COMPARTMENT_ID='ocid1.compartment.oc1...gq'
12
12
 
13
13
  # Deploy the function and API Gateway
@@ -141,7 +141,7 @@ Use the same flag or environment variable for deletion. OCDK deletes the CLI-man
141
141
  npx ocdk destroy --code-only --auto-approve
142
142
  ```
143
143
 
144
- Run from your project root (where your `func.yaml` / function code and `node_modules/@mikarinneoracle/oci-cdk` live):
144
+ Run from your project root (where your `func.yaml` / function code and `node_modules/@mikarinneoracle/oci-cdk-code-only-preview` live):
145
145
 
146
146
  ```bash
147
147
  npx ocdk deploy
@@ -163,7 +163,7 @@ npx ocdk destroy
163
163
  If you only need the utility temporarily, remove it after use:
164
164
 
165
165
  ```bash
166
- npm uninstall --ignore-scripts @mikarinneoracle/oci-cdk
166
+ npm uninstall --ignore-scripts @mikarinneoracle/oci-cdk-code-only-preview
167
167
  ```
168
168
 
169
169
  ## IAM plan (API Gateway invoke + log tailing)
@@ -97,9 +97,13 @@ function jsonOci(args) {
97
97
  }
98
98
  }
99
99
 
100
+ function resourceDisplayName(resource) {
101
+ return resource.displayName || resource['display-name'] || '';
102
+ }
103
+
100
104
  function findApplicationId(compartmentId, appName) {
101
105
  const result = jsonOci(['fn', 'application', 'list', '--compartment-id', compartmentId, '--all']);
102
- const matches = (result.data || []).filter((app) => app.displayName === appName);
106
+ const matches = (result.data || []).filter((app) => resourceDisplayName(app) === appName);
103
107
  if (matches.length === 0) {
104
108
  fail(`Functions Application "${appName}" was not found. Code-only deploy requires an existing application.`);
105
109
  }
@@ -109,7 +113,7 @@ function findApplicationId(compartmentId, appName) {
109
113
 
110
114
  function findFunctionId(applicationId, functionName) {
111
115
  const result = jsonOci(['fn', 'function', 'list', '--application-id', applicationId, '--all']);
112
- const matches = (result.data || []).filter((fn) => fn.displayName === functionName);
116
+ const matches = (result.data || []).filter((fn) => resourceDisplayName(fn) === functionName);
113
117
  if (matches.length > 1) fail(`multiple functions are named "${functionName}" in the selected application.`);
114
118
  return matches[0]?.id;
115
119
  }
@@ -36,6 +36,10 @@ function yamlValue(contents, key) {
36
36
  return (match?.[1] || match?.[2] || '').trim();
37
37
  }
38
38
 
39
+ function resourceDisplayName(resource) {
40
+ return resource.displayName || resource['display-name'] || '';
41
+ }
42
+
39
43
  function main() {
40
44
  const compartmentId = (process.env.OCI_COMPARTMENT_ID || process.env.OCI_COMPARTMENT_OCID || '').trim();
41
45
  if (!compartmentId) fail('set OCI_COMPARTMENT_ID (or OCI_COMPARTMENT_OCID).');
@@ -48,13 +52,13 @@ function main() {
48
52
 
49
53
  const version = runOci(['--version']).trim();
50
54
  const apps = jsonOci(['fn', 'application', 'list', '--compartment-id', compartmentId, '--all']).data || [];
51
- const app = apps.find((item) => item.displayName === appName);
55
+ const app = apps.find((item) => resourceDisplayName(item) === appName);
52
56
  if (!app) {
53
57
  console.log(`Functions Application ${appName} is absent; no code-only function needs deletion.`);
54
58
  return;
55
59
  }
56
60
  const functions = jsonOci(['fn', 'function', 'list', '--application-id', app.id, '--all']).data || [];
57
- const matches = functions.filter((item) => item.displayName === functionName);
61
+ const matches = functions.filter((item) => resourceDisplayName(item) === functionName);
58
62
  if (matches.length === 0) {
59
63
  console.log(`Code-only function ${functionName} is absent; continuing with Terraform destroy.`);
60
64
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikarinneoracle/oci-cdk-code-only-preview",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "OCI CDK stack for OCI Functions, API Gateway, and related infrastructure",
5
5
  "main": "lib/index.js",
6
6
  "bin": {