@mikarinneoracle/oci-cdk-code-only-preview 0.0.24 → 0.0.25
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 +1 -1
- package/bin/deploy-code-only.js +19 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ export OCI_FUNCTION_APP_NAME='my-existing-function-app'
|
|
|
167
167
|
|
|
168
168
|
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.
|
|
169
169
|
|
|
170
|
-
Each deploy re-builds `<function-name>.zip` in the project root and uploads that file. The ZIP has the required `function/` directory at its root, includes source files, and excludes `node_modules`, `.git`, `.tools`, `.terraform`, `cdktf.out`, and the generated `tail-function-logs.js`. For Node.js functions,
|
|
170
|
+
Each deploy re-builds `<function-name>.zip` in the project root and uploads that file. The ZIP has the required `function/` directory at its root, includes source files, and excludes `node_modules`, `package-lock.json`, `.git`, `.tools`, `.terraform`, `cdktf.out`, and the generated `tail-function-logs.js`. For Node.js functions, `package.json` remains in the archive so OCI can install the FDK and other dependencies, but OCDK removes its own package dependency (`@mikarinneoracle/oci-cdk-code-only-preview`, and the legacy package name) from the copied manifest. A successful code-only destroy removes this ZIP after Terraform has destroyed the Function App and infrastructure. With the default `OCI_STACK_ACTION=full-stack`, OCDK creates the API Gateway and uses a Terraform data source to resolve the CLI-managed function OCID for its route. The first code-only deploy therefore runs Terraform once to create the Function App, uploads the function, then runs Terraform again to create the Gateway deployment. Set `OCI_STACK_ACTION=function-only` to omit API Gateway.
|
|
171
171
|
|
|
172
172
|
After a successful code-only deploy, OCDK writes the log IDs for `npx ocdk tail:execution-log` automatically.
|
|
173
173
|
|
package/bin/deploy-code-only.js
CHANGED
|
@@ -77,6 +77,23 @@ function codeOnlyArchiveFileName(functionName) {
|
|
|
77
77
|
return `${safeName || 'function'}.zip`;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
function preparePackageManifest(archiveRoot) {
|
|
81
|
+
const manifestPath = path.join(archiveRoot, 'package.json');
|
|
82
|
+
if (!fs.existsSync(manifestPath)) return;
|
|
83
|
+
try {
|
|
84
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
85
|
+
for (const section of ['dependencies', 'devDependencies', 'optionalDependencies']) {
|
|
86
|
+
if (!manifest[section]) continue;
|
|
87
|
+
delete manifest[section]['@mikarinneoracle/oci-cdk-code-only-preview'];
|
|
88
|
+
delete manifest[section]['@mikarinneoracle/oci-cdk'];
|
|
89
|
+
if (Object.keys(manifest[section]).length === 0) delete manifest[section];
|
|
90
|
+
}
|
|
91
|
+
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
|
|
92
|
+
} catch {
|
|
93
|
+
fail('could not read package.json while preparing the code-only archive.');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
function createArchive(functionName) {
|
|
81
98
|
if (!fs.existsSync(projectDir) || !fs.statSync(projectDir).isDirectory()) {
|
|
82
99
|
fail(`source directory does not exist: ${projectDir}`);
|
|
@@ -85,7 +102,7 @@ function createArchive(functionName) {
|
|
|
85
102
|
const archiveFileName = codeOnlyArchiveFileName(functionName);
|
|
86
103
|
const archivePath = path.join(projectDir, archiveFileName);
|
|
87
104
|
const archiveRoot = path.join(tempDir, 'function');
|
|
88
|
-
const excludedTopLevel = new Set(['node_modules', '.git', '.tools', '.terraform', 'cdktf.out', 'tail-function-logs.js']);
|
|
105
|
+
const excludedTopLevel = new Set(['node_modules', '.git', '.tools', '.terraform', 'cdktf.out', 'tail-function-logs.js', 'package-lock.json']);
|
|
89
106
|
fs.cpSync(projectDir, archiveRoot, {
|
|
90
107
|
recursive: true,
|
|
91
108
|
filter: (sourcePath) => {
|
|
@@ -95,6 +112,7 @@ function createArchive(functionName) {
|
|
|
95
112
|
return !excludedTopLevel.has(relativePath.split(path.sep)[0]);
|
|
96
113
|
},
|
|
97
114
|
});
|
|
115
|
+
preparePackageManifest(archiveRoot);
|
|
98
116
|
fs.rmSync(archivePath, { force: true });
|
|
99
117
|
const zip = spawnSync('zip', ['-q', '-r', archivePath, 'function'], { cwd: tempDir, encoding: 'utf8', shell: false });
|
|
100
118
|
if (zip.error || zip.status !== 0) {
|