@mikarinneoracle/oci-cdk-code-only-preview 0.0.7 → 0.0.9

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
@@ -133,7 +133,7 @@ export OCI_FUNCTION_APP_NAME='my-existing-function-app'
133
133
 
134
134
  These settings are optional: `OCI_CODE_ONLY_SOURCE_DIR` (defaults to the current directory), `OCI_FUNCTION_MEMORY_MB` (from `func.yaml`, otherwise `256`), and `OCI_FUNCTION_TIMEOUT_SECONDS` (from `func.yaml`, otherwise `30`). `OCI_TENANCY_ID`, `OCI_REGION`, and `OCI_NAMESPACE` are also optional when they can be resolved from the active OCI CLI profile.
135
135
 
136
- The archive is built from `OCI_CODE_ONLY_SOURCE_DIR` (or the current directory). It includes source files and excludes `node_modules`, `.git`, `.tools`, `.terraform`, and `cdktf.out`. The current preview path is function-only: it does not create an API Gateway because the CLI-managed function OCID is not in Terraform state.
136
+ The archive is built from `OCI_CODE_ONLY_SOURCE_DIR` (or the current directory) with the required `function/` directory at its ZIP root. It includes source files and excludes `node_modules`, `.git`, `.tools`, `.terraform`, and `cdktf.out`. The current preview path is function-only: it does not create an API Gateway because the CLI-managed function OCID is not in Terraform state.
137
137
 
138
138
  Use the same flag or environment variable for deletion. OCDK deletes the CLI-managed function first, then lets Terraform destroy the Function App and its infrastructure:
139
139
 
@@ -73,14 +73,17 @@ function createArchive() {
73
73
  }
74
74
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ocdk-code-only-'));
75
75
  const archivePath = path.join(tempDir, 'function-source.zip');
76
- const zip = spawnSync('zip', [
77
- '-q', '-r', archivePath, '.',
78
- '-x', 'node_modules/*',
79
- '-x', '.git/*',
80
- '-x', '.tools/*',
81
- '-x', '.terraform/*',
82
- '-x', 'cdktf.out/*',
83
- ], { cwd: projectDir, encoding: 'utf8', shell: false });
76
+ const archiveRoot = path.join(tempDir, 'function');
77
+ const excludedTopLevel = new Set(['node_modules', '.git', '.tools', '.terraform', 'cdktf.out']);
78
+ fs.cpSync(projectDir, archiveRoot, {
79
+ recursive: true,
80
+ filter: (sourcePath) => {
81
+ const relativePath = path.relative(projectDir, sourcePath);
82
+ if (!relativePath) return true;
83
+ return !excludedTopLevel.has(relativePath.split(path.sep)[0]);
84
+ },
85
+ });
86
+ const zip = spawnSync('zip', ['-q', '-r', archivePath, 'function'], { cwd: tempDir, encoding: 'utf8', shell: false });
84
87
  if (zip.error || zip.status !== 0) {
85
88
  fs.rmSync(tempDir, { recursive: true, force: true });
86
89
  fail(`could not create source archive with zip: ${zip.stderr?.trim() || zip.error?.message || 'unknown error'}`);
@@ -90,6 +93,8 @@ function createArchive() {
90
93
 
91
94
  function jsonOci(args) {
92
95
  const output = runOci([...args, '--output', 'json']).trim();
96
+ // Preview CLI can return an empty body for a successful list of no functions.
97
+ if (!output) return { data: [] };
93
98
  const objectStart = output.indexOf('{');
94
99
  const arrayStart = output.indexOf('[');
95
100
  const start = objectStart !== -1 ? objectStart : arrayStart;
@@ -25,6 +25,8 @@ function runOci(args) {
25
25
 
26
26
  function jsonOci(args) {
27
27
  const output = runOci([...args, '--output', 'json']).trim();
28
+ // Preview CLI can return an empty body for a successful list of no functions.
29
+ if (!output) return { data: [] };
28
30
  const objectStart = output.indexOf('{');
29
31
  const arrayStart = output.indexOf('[');
30
32
  const start = objectStart !== -1 ? objectStart : arrayStart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikarinneoracle/oci-cdk-code-only-preview",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "OCI CDK stack for OCI Functions, API Gateway, and related infrastructure",
5
5
  "main": "lib/index.js",
6
6
  "bin": {