From a71d66fb9ae62d5ad1dacca2520c950d8b0da495 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 7 Feb 2025 18:11:18 +0530 Subject: [PATCH 1/8] fix: removed esm Module for Node.js v22.12.0+ Compatibility --- .github/workflows/release.yml | 6 +++--- package-lock.json | 25 ++-------------------- package.json | 4 +--- src/util/cloud-function/cloud-functions.ts | 10 +++------ 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d9efa71..01e5f2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,13 +32,13 @@ jobs: needs: build steps: - name: Checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Node.js - uses: actions/setup-node@v3.7.0 + uses: actions/setup-node@v4 with: - node-version: "18.x" + node-version: "22.x" - name: Installing dependencies run: npm install - name: Download dist diff --git a/package-lock.json b/package-lock.json index 8770eb2..390bbc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/cli-launch", - "version": "1.5.0", + "version": "1.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/cli-launch", - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "dependencies": { "@apollo/client": "^3.11.8", @@ -21,7 +21,6 @@ "chalk": "^4.1.2", "cross-fetch": "^3.1.8", "dotenv": "^16.4.7", - "esm": "^3.2.25", "express": "^4.21.1", "form-data": "^4.0.0", "graphql": "^16.9.0", @@ -37,7 +36,6 @@ "@oclif/test": "^4.1.3", "@types/adm-zip": "^0.5.7", "@types/chai": "^4.3.20", - "@types/esm": "^3.2.2", "@types/ini": "^1.3.34", "@types/lodash": "^4.17.13", "@types/mocha": "^10.0.10", @@ -2609,16 +2607,6 @@ "@types/node": "*" } }, - "node_modules/@types/esm": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@types/esm/-/esm-3.2.2.tgz", - "integrity": "sha512-l3IQQD2sChjNiQVNf28qq+sY9Sjvz7HrcOO3g4ZeSaiQRXQccBaR6cpqXPpzJ3QYCt6UF7+4ugabMRsQTPV+Eg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -6957,15 +6945,6 @@ "node": "*" } }, - "node_modules/esm": { - "version": "3.2.25", - "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", - "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", diff --git a/package.json b/package.json index f5d2590..8e68c87 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-launch", - "version": "1.5.0", + "version": "1.5.1", "description": "Launch related operations", "author": "Contentstack CLI", "bin": { @@ -32,7 +32,6 @@ "chalk": "^4.1.2", "cross-fetch": "^3.1.8", "dotenv": "^16.4.7", - "esm": "^3.2.25", "express": "^4.21.1", "form-data": "^4.0.0", "graphql": "^16.9.0", @@ -45,7 +44,6 @@ "@oclif/test": "^4.1.3", "@types/adm-zip": "^0.5.7", "@types/chai": "^4.3.20", - "@types/esm": "^3.2.2", "@types/ini": "^1.3.34", "@types/lodash": "^4.17.13", "@types/mocha": "^10.0.10", diff --git a/src/util/cloud-function/cloud-functions.ts b/src/util/cloud-function/cloud-functions.ts index 5f7abe8..179e33e 100755 --- a/src/util/cloud-function/cloud-functions.ts +++ b/src/util/cloud-function/cloud-functions.ts @@ -1,5 +1,4 @@ import dotenv from 'dotenv'; -import esm from 'esm'; import express, { Request, Response, @@ -70,13 +69,11 @@ export class CloudFunctions { cloudFunctionResources: CloudFunctionResource[], app: Express ): Promise { - const loadAsESM = esm(module); - await Promise.all( cloudFunctionResources.map(async (cloudFunctionResource) => { - const handler = loadAsESM( + const handler = await import( `${cloudFunctionResource.cloudFunctionFilePath}` - ).default; + ); app.use(express.json()); app.use(express.urlencoded({ extended: true })); @@ -182,12 +179,11 @@ export class CloudFunctions { private async checkDefaultExport(filepath: string): Promise { const exportType = "function"; - const loadAsESM = esm(module); const fullPath = normalize(path.resolve(process.cwd(), filepath)).replace( /^(\.\.(\/|\\|$))+/, "" ); - const handler = await loadAsESM(fullPath); + const handler = await import(fullPath); return typeof handler.default === exportType; } From 099d187719efb5ade5142cb150731b6146bed440 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 7 Feb 2025 18:51:34 +0530 Subject: [PATCH 2/8] fix: TypeError: handler is not a function --- src/util/cloud-function/cloud-functions.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/cloud-function/cloud-functions.ts b/src/util/cloud-function/cloud-functions.ts index 179e33e..4207ee4 100755 --- a/src/util/cloud-function/cloud-functions.ts +++ b/src/util/cloud-function/cloud-functions.ts @@ -71,9 +71,10 @@ export class CloudFunctions { ): Promise { await Promise.all( cloudFunctionResources.map(async (cloudFunctionResource) => { - const handler = await import( - `${cloudFunctionResource.cloudFunctionFilePath}` - ); + // Import the cloud function dynamically using the import() syntax + const { default: handler } = await import( + `${cloudFunctionResource.cloudFunctionFilePath}` + ); app.use(express.json()); app.use(express.urlencoded({ extended: true })); From 31613ab256cd5577c216a0e57a1de01838b5a060 Mon Sep 17 00:00:00 2001 From: dhruvparekh12 Date: Wed, 12 Feb 2025 19:33:51 +0530 Subject: [PATCH 3/8] CL-1543 | Replace esm with rollup for importing the handler function for launch cloud functions --- package-lock.json | 474 ++++++++++++++++++++- package.json | 4 + src/util/cloud-function/cloud-functions.ts | 56 ++- src/util/cloud-function/types.ts | 1 + 4 files changed, 512 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 390bbc5..edd9485 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,9 @@ "@oclif/core": "^3.27.0", "@oclif/plugin-help": "^5.2.20", "@oclif/plugin-plugins": "^5.4.15", + "@rollup/plugin-commonjs": "^28.0.2", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^16.0.0", "@types/express": "^4.17.21", "@types/express-serve-static-core": "^4.17.34", "adm-zip": "^0.5.16", @@ -27,6 +30,7 @@ "ini": "^3.0.1", "lodash": "^4.17.21", "open": "^8.4.2", + "rollup": "^4.34.6", "winston": "^3.17.0" }, "bin": { @@ -2097,6 +2101,383 @@ "node": ">=14" } }, + "node_modules/@rollup/plugin-commonjs": { + "version": "28.0.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.2.tgz", + "integrity": "sha512-BEFI2EDqzl+vA1rl97IDRZ61AIwGH093d9nz8+dThxJNH8oSoB7MjWvPCX3dkaK1/RCJ/1v/R1XB15FuSs0fQw==", + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.2.0", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=16.0.0 || 14 >= 14.17" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/fdir": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.3.tgz", + "integrity": "sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==", + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.0.tgz", + "integrity": "sha512-0FPvAeVUT/zdWoO0jnb/V5BlBsUSNfkIOtFHzMO4H9MOklrmQFY6FduVHKucNb/aTFxvnGhj4MNj/T1oNdDfNg==", + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", + "integrity": "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.6.tgz", + "integrity": "sha512-+GcCXtOQoWuC7hhX1P00LqjjIiS/iOouHXhMdiDSnq/1DGTox4SpUvO52Xm+div6+106r+TcvOeo/cxvyEyTgg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.6.tgz", + "integrity": "sha512-E8+2qCIjciYUnCa1AiVF1BkRgqIGW9KzJeesQqVfyRITGQN+dFuoivO0hnro1DjT74wXLRZ7QF8MIbz+luGaJA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.6.tgz", + "integrity": "sha512-z9Ib+OzqN3DZEjX7PDQMHEhtF+t6Mi2z/ueChQPLS/qUMKY7Ybn5A2ggFoKRNRh1q1T03YTQfBTQCJZiepESAg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.6.tgz", + "integrity": "sha512-PShKVY4u0FDAR7jskyFIYVyHEPCPnIQY8s5OcXkdU8mz3Y7eXDJPdyM/ZWjkYdR2m0izD9HHWA8sGcXn+Qrsyg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.6.tgz", + "integrity": "sha512-YSwyOqlDAdKqs0iKuqvRHLN4SrD2TiswfoLfvYXseKbL47ht1grQpq46MSiQAx6rQEN8o8URtpXARCpqabqxGQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.6.tgz", + "integrity": "sha512-HEP4CgPAY1RxXwwL5sPFv6BBM3tVeLnshF03HMhJYCNc6kvSqBgTMmsEjb72RkZBAWIqiPUyF1JpEBv5XT9wKQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.6.tgz", + "integrity": "sha512-88fSzjC5xeH9S2Vg3rPgXJULkHcLYMkh8faix8DX4h4TIAL65ekwuQMA/g2CXq8W+NJC43V6fUpYZNjaX3+IIg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.6.tgz", + "integrity": "sha512-wM4ztnutBqYFyvNeR7Av+reWI/enK9tDOTKNF+6Kk2Q96k9bwhDDOlnCUNRPvromlVXo04riSliMBs/Z7RteEg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.6.tgz", + "integrity": "sha512-9RyprECbRa9zEjXLtvvshhw4CMrRa3K+0wcp3KME0zmBe1ILmvcVHnypZ/aIDXpRyfhSYSuN4EPdCCj5Du8FIA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.6.tgz", + "integrity": "sha512-qTmklhCTyaJSB05S+iSovfo++EwnIEZxHkzv5dep4qoszUMX5Ca4WM4zAVUMbfdviLgCSQOu5oU8YoGk1s6M9Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.6.tgz", + "integrity": "sha512-4Qmkaps9yqmpjY5pvpkfOerYgKNUGzQpFxV6rnS7c/JfYbDSU0y6WpbbredB5cCpLFGJEqYX40WUmxMkwhWCjw==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.6.tgz", + "integrity": "sha512-Zsrtux3PuaxuBTX/zHdLaFmcofWGzaWW1scwLU3ZbW/X+hSsFbz9wDIp6XvnT7pzYRl9MezWqEqKy7ssmDEnuQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.6.tgz", + "integrity": "sha512-aK+Zp+CRM55iPrlyKiU3/zyhgzWBxLVrw2mwiQSYJRobCURb781+XstzvA8Gkjg/hbdQFuDw44aUOxVQFycrAg==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.6.tgz", + "integrity": "sha512-WoKLVrY9ogmaYPXwTH326+ErlCIgMmsoRSx6bO+l68YgJnlOXhygDYSZe/qbUJCSiCiZAQ+tKm88NcWuUXqOzw==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.6.tgz", + "integrity": "sha512-Sht4aFvmA4ToHd2vFzwMFaQCiYm2lDFho5rPcvPBT5pCdC+GwHG6CMch4GQfmWTQ1SwRKS0dhDYb54khSrjDWw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.6.tgz", + "integrity": "sha512-zmmpOQh8vXc2QITsnCiODCDGXFC8LMi64+/oPpPx5qz3pqv0s6x46ps4xoycfUiVZps5PFn1gksZzo4RGTKT+A==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.6.tgz", + "integrity": "sha512-3/q1qUsO/tLqGBaD4uXsB6coVGB3usxw3qyeVb59aArCgedSF66MPdgRStUd7vbZOsko/CgVaY5fo2vkvPLWiA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.6.tgz", + "integrity": "sha512-oLHxuyywc6efdKVTxvc0135zPrRdtYVjtVD5GUm55I3ODxhU/PwkQFD97z16Xzxa1Fz0AEe4W/2hzRtd+IfpOA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.6.tgz", + "integrity": "sha512-0PVwmgzZ8+TZ9oGBmdZoQVXflbvuwzN/HRclujpl4N/q3i+y0lqLw8n1bXA8ru3sApDjlmONaNAuYr38y1Kr9w==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -2611,9 +2992,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", - "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/expect": { "version": "1.20.4", @@ -2747,6 +3126,12 @@ "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", "license": "MIT" }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "license": "MIT" + }, "node_modules/@types/responselike": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", @@ -4672,7 +5057,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true, "license": "MIT" }, "node_modules/concat-map": { @@ -5114,6 +5498,15 @@ "dev": true, "license": "MIT" }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/default-require-extensions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", @@ -7039,6 +7432,12 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -7721,7 +8120,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -9338,7 +9736,6 @@ "version": "2.16.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", - "dev": true, "license": "MIT", "dependencies": { "hasown": "^2.0.2" @@ -9486,6 +9883,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "license": "MIT" + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -9540,6 +9943,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-regex": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", @@ -10394,6 +10806,15 @@ "yallist": "^3.0.2" } }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -15359,7 +15780,6 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true, "license": "MIT" }, "node_modules/path-scurry": { @@ -16489,7 +16909,6 @@ "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", - "dev": true, "license": "MIT", "dependencies": { "is-core-module": "^2.16.0", @@ -16605,6 +17024,44 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rollup": { + "version": "4.34.6", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.6.tgz", + "integrity": "sha512-wc2cBWqJgkU3Iz5oztRkQbfVkbxoz5EhnCGOrnJvnLnQ7O0WhQUYyv18qQI79O8L7DdHrrlJNeCHd4VGpnaXKQ==", + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.34.6", + "@rollup/rollup-android-arm64": "4.34.6", + "@rollup/rollup-darwin-arm64": "4.34.6", + "@rollup/rollup-darwin-x64": "4.34.6", + "@rollup/rollup-freebsd-arm64": "4.34.6", + "@rollup/rollup-freebsd-x64": "4.34.6", + "@rollup/rollup-linux-arm-gnueabihf": "4.34.6", + "@rollup/rollup-linux-arm-musleabihf": "4.34.6", + "@rollup/rollup-linux-arm64-gnu": "4.34.6", + "@rollup/rollup-linux-arm64-musl": "4.34.6", + "@rollup/rollup-linux-loongarch64-gnu": "4.34.6", + "@rollup/rollup-linux-powerpc64le-gnu": "4.34.6", + "@rollup/rollup-linux-riscv64-gnu": "4.34.6", + "@rollup/rollup-linux-s390x-gnu": "4.34.6", + "@rollup/rollup-linux-x64-gnu": "4.34.6", + "@rollup/rollup-linux-x64-musl": "4.34.6", + "@rollup/rollup-win32-arm64-msvc": "4.34.6", + "@rollup/rollup-win32-ia32-msvc": "4.34.6", + "@rollup/rollup-win32-x64-msvc": "4.34.6", + "fsevents": "~2.3.2" + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -17853,7 +18310,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" diff --git a/package.json b/package.json index 8e68c87..603ab67 100755 --- a/package.json +++ b/package.json @@ -26,6 +26,9 @@ "@oclif/core": "^3.27.0", "@oclif/plugin-help": "^5.2.20", "@oclif/plugin-plugins": "^5.4.15", + "@rollup/plugin-commonjs": "^28.0.2", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^16.0.0", "@types/express": "^4.17.21", "@types/express-serve-static-core": "^4.17.34", "adm-zip": "^0.5.16", @@ -38,6 +41,7 @@ "ini": "^3.0.1", "lodash": "^4.17.21", "open": "^8.4.2", + "rollup": "^4.34.6", "winston": "^3.17.0" }, "devDependencies": { diff --git a/src/util/cloud-function/cloud-functions.ts b/src/util/cloud-function/cloud-functions.ts index 4207ee4..686c64e 100755 --- a/src/util/cloud-function/cloud-functions.ts +++ b/src/util/cloud-function/cloud-functions.ts @@ -16,6 +16,11 @@ import { FunctionsDirectoryNotFoundError } from "./errors/cloud-function.errors" import { walkFileSystem, checkIfDirectoryExists } from "./os-helper"; import { CloudFunctionResource } from "./types"; +import rollup from "rollup"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import commonjs from "@rollup/plugin-commonjs"; +import json from "@rollup/plugin-json"; + export class CloudFunctions { private cloudFunctionsDirectoryPath: string; private pathToSourceCode: string; @@ -71,10 +76,7 @@ export class CloudFunctions { ): Promise { await Promise.all( cloudFunctionResources.map(async (cloudFunctionResource) => { - // Import the cloud function dynamically using the import() syntax - const { default: handler } = await import( - `${cloudFunctionResource.cloudFunctionFilePath}` - ); + app.use(express.json()); app.use(express.urlencoded({ extended: true })); @@ -89,7 +91,7 @@ export class CloudFunctions { cloudFunctionResource.apiResourceURI, async (request: Request, response: Response) => { try { - return await handler(request, response); + return await cloudFunctionResource.handler(request, response); } catch (error) { console.error(error); response.status(500).send(); @@ -116,7 +118,12 @@ export class CloudFunctions { if (this.isProxyEdgeFile(parsedPath.base) || parsedPath.ext !== CLOUD_FUNCTIONS_SUPPORTED_EXTENSION - || !await this.checkDefaultExport(filePath)) { + ) { + continue; + } + + const handler = await this.buildHandlerForFilepath(filePath); + if(!handler) { continue; } @@ -132,6 +139,7 @@ export class CloudFunctions { cloudFunctionResources.push({ cloudFunctionFilePath: filePath, apiResourceURI, + handler }); } @@ -178,14 +186,34 @@ export class CloudFunctions { return { exactRouteResources, dynamicRouteResources }; } - private async checkDefaultExport(filepath: string): Promise { - const exportType = "function"; - const fullPath = normalize(path.resolve(process.cwd(), filepath)).replace( - /^(\.\.(\/|\\|$))+/, - "" - ); - const handler = await import(fullPath); + private async buildHandlerForFilepath(cloudFunctionFilePath: string) { + const bundle = await rollup.rollup({ + input: cloudFunctionFilePath, + plugins: [nodeResolve({ preferBuiltins: false }), commonjs(), json()], + }); + + const { output } = await bundle.generate({ + format: "esm", + inlineDynamicImports: true, + }); + + const builtCode = output[0].code; + + const builtCodeInDataURLFormat = + "data:text/javascript;base64," + Buffer.from(builtCode).toString("base64"); + + const module = await import(builtCodeInDataURLFormat); + + let handler = null; + const isDefaultExportESModuleFunction = typeof module.default === 'function'; + const isDefaultExportCommonjsFunction = typeof module.default?.default === 'function'; + if (isDefaultExportESModuleFunction) { + handler = module.default; + } + else if (isDefaultExportCommonjsFunction) { + handler = module.default.default; + } - return typeof handler.default === exportType; + return handler; } } diff --git a/src/util/cloud-function/types.ts b/src/util/cloud-function/types.ts index 9642155..8e74274 100755 --- a/src/util/cloud-function/types.ts +++ b/src/util/cloud-function/types.ts @@ -8,6 +8,7 @@ import { export type CloudFunctionResource = { cloudFunctionFilePath: string, apiResourceURI: string + handler: Function }; export type CloudFunctionValidationError = TopLevelDynamicRouteError | From 1bd1d5c6a85bb154a41776623408b4d1a02daa0d Mon Sep 17 00:00:00 2001 From: dhruvparekh12 Date: Wed, 12 Feb 2025 19:44:26 +0530 Subject: [PATCH 4/8] CL-1543 | Add launch dev team to github CODEOWNERS --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1be7e0d..316b947 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,2 @@ * @contentstack/security-admin +* @contentstack/launch-pr-reviewers From 077b18d1c34d06a5dc3fcdf9dd487aa6426e219b Mon Sep 17 00:00:00 2001 From: dhruvparekh12 Date: Thu, 13 Feb 2025 17:45:33 +0530 Subject: [PATCH 5/8] CL-1543 | Patch the dynamic import code after tsc compile --- package-lock.json | 27 +++++++++++++++++++ package.json | 4 ++- scripts/patch-load-data-url-file.js | 30 ++++++++++++++++++++++ src/util/cloud-function/cloud-functions.ts | 7 ++--- src/util/cloud-function/load-data-url.ts | 3 +++ 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 scripts/patch-load-data-url-file.js create mode 100644 src/util/cloud-function/load-data-url.ts diff --git a/package-lock.json b/package-lock.json index edd9485..98b073d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@rollup/plugin-commonjs": "^28.0.2", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^16.0.0", + "@rollup/plugin-typescript": "^12.1.2", "@types/express": "^4.17.21", "@types/express-serve-static-core": "^4.17.34", "adm-zip": "^0.5.16", @@ -2197,6 +2198,32 @@ } } }, + "node_modules/@rollup/plugin-typescript": { + "version": "12.1.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.2.tgz", + "integrity": "sha512-cdtSp154H5sv637uMr1a8OTWB0L1SWDSm1rDGiyfcGcvQ6cuTs4MDk2BVEBGysUWago4OJN4EQZqOTl/QY3Jgg==", + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", diff --git a/package.json b/package.json index 603ab67..749e50c 100755 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@rollup/plugin-commonjs": "^28.0.2", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^16.0.0", + "@rollup/plugin-typescript": "^12.1.2", "@types/express": "^4.17.21", "@types/express-serve-static-core": "^4.17.34", "adm-zip": "^0.5.16", @@ -92,7 +93,8 @@ "version": "oclif readme && git add README.md", "build": "npm run clean && npm run compile", "clean": "rm -rf ./dist tsconfig.build.tsbuildinfo", - "compile": "tsc -b tsconfig.json", + "compile": "tsc -b tsconfig.json && npm run patch-load-data-url", + "patch-load-data-url": "node scripts/patch-load-data-url-file.js", "prepack": "npm run build && oclif manifest && oclif readme", "test:unit": "mocha --forbid-only \"test/unit/**/*.test.ts\"", "test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"" diff --git a/scripts/patch-load-data-url-file.js b/scripts/patch-load-data-url-file.js new file mode 100644 index 00000000..c1b56fa --- /dev/null +++ b/scripts/patch-load-data-url-file.js @@ -0,0 +1,30 @@ +// The tsc compiler currently compiles to "commonjs" output as per the tsconfig. +// As a result, the use of dynamic import "import()" in the cloud-function logic, gets replaced with "require()" in the dist/ output. +// "require()" however does not support importing modules from data url strings causing this logic to break. +// Therefore, we patch the dist/ output to again use dynamic imports "import()" after tsc compilation. + +const rollup = require('rollup'); +const typescript = require('@rollup/plugin-typescript'); +const path = require('path'); + +async function transpileTsFileToESM(inputFile, outputFile) { + const bundle = await rollup.rollup({ + input: inputFile, + plugins: [typescript({ module: 'esnext', declaration: false })], + }); + + await bundle.write({ + file: outputFile, + format: 'esm', + sourcemap: false, + }); +} + +async function patchLoadDataURLFunction() { + const loadDataURLInputFilePath = path.join(process.cwd(), 'src/util/cloud-function/load-data-url.ts'); + const loadDataURLOutputFilePath = path.join(process.cwd(), 'dist/util/cloud-function/load-data-url.js'); + await transpileTsFileToESM(loadDataURLInputFilePath, loadDataURLOutputFilePath); + console.log(`${loadDataURLInputFilePath} : File patched successfully`); +} + +patchLoadDataURLFunction(); diff --git a/src/util/cloud-function/cloud-functions.ts b/src/util/cloud-function/cloud-functions.ts index 686c64e..41908ee 100755 --- a/src/util/cloud-function/cloud-functions.ts +++ b/src/util/cloud-function/cloud-functions.ts @@ -4,7 +4,7 @@ import express, { Response, } from 'express'; import { Express } from 'express-serve-static-core'; -import path, { normalize } from "path"; +import path from "path"; import { CloudFunctionsValidator } from "./cloud-functions-validator"; import { @@ -20,6 +20,7 @@ import rollup from "rollup"; import { nodeResolve } from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import json from "@rollup/plugin-json"; +import { loadDataURL } from './load-data-url'; export class CloudFunctions { private cloudFunctionsDirectoryPath: string; @@ -189,7 +190,7 @@ export class CloudFunctions { private async buildHandlerForFilepath(cloudFunctionFilePath: string) { const bundle = await rollup.rollup({ input: cloudFunctionFilePath, - plugins: [nodeResolve({ preferBuiltins: false }), commonjs(), json()], + plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json()], }); const { output } = await bundle.generate({ @@ -202,7 +203,7 @@ export class CloudFunctions { const builtCodeInDataURLFormat = "data:text/javascript;base64," + Buffer.from(builtCode).toString("base64"); - const module = await import(builtCodeInDataURLFormat); + const module = await loadDataURL(builtCodeInDataURLFormat); let handler = null; const isDefaultExportESModuleFunction = typeof module.default === 'function'; diff --git a/src/util/cloud-function/load-data-url.ts b/src/util/cloud-function/load-data-url.ts new file mode 100644 index 00000000..330b8cc --- /dev/null +++ b/src/util/cloud-function/load-data-url.ts @@ -0,0 +1,3 @@ +export function loadDataURL(dataURL: string) { + return import(dataURL); +} \ No newline at end of file From 61f93dd1c000ef20e699690df3d1e76354d0f23e Mon Sep 17 00:00:00 2001 From: dhruvparekh12 Date: Tue, 18 Feb 2025 16:43:43 +0530 Subject: [PATCH 6/8] CL-1543 | Remove server header from express app --- src/util/cloud-function/cloud-functions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/cloud-function/cloud-functions.ts b/src/util/cloud-function/cloud-functions.ts index 41908ee..f43da8c 100755 --- a/src/util/cloud-function/cloud-functions.ts +++ b/src/util/cloud-function/cloud-functions.ts @@ -60,6 +60,7 @@ export class CloudFunctions { this.transformAndSegregateResourcesByRoutes(cloudFunctionResources); const app = express(); + app.disable('x-powered-by'); await this.applyAppRouter(exactRouteResources, app); await this.applyAppRouter(dynamicRouteResources, app); From e7351b42d5280be34af7111d04cd8a944e06c4f8 Mon Sep 17 00:00:00 2001 From: dhruvparekh12 Date: Tue, 18 Feb 2025 17:00:33 +0530 Subject: [PATCH 7/8] CL-1543 | Update README.md file --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/README.md b/README.md index 9463525..770db24 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,75 @@ Run cloud functions locally ``` + + + +# How to test Changes Locally? +- Branch out from development for development. +- Install npm: @contentstack/cli +- Set region and log in using csdx config:set:region & csdx login + +`node bin/dev ` + +OR + +`npm run prepack` + + +`node bin/run ` + +OR + + +``` +npm run prepack + +csdx plugins:link + +csdx +``` + + +# Release & SRE Process:- + +Version Increment: + +Patch version update (fixes): 1.0.0 → 1.0.1 + +Minor version update (enhancements): 1.0.0 → 1.1.0 + +Major version update (breaking changes): 1.0.0 → 2.0.0 + +## For release: + +- Raise a draft pull request (PR) from the development branch to the main branch. + +### Pre-release SRE Preparation: + +- Create an SRE ticket a week before the release date, including the PR. + +- After the SRE review, address any identified issues and create tickets for any new issues. + +- Request SRE approval if no issues are identified or after fixing all the SRE-raised issues. + +### CAB Approval: + +- For CAB, prepare deployment plan sheets(including publish & rollback plan). + +- Once SRE approves, raise the request for CAB(SRE ticket, deployment plan, release tickets, release notes). At least two CAB approvals are required. + +- Obtain approval for the PR from the security admin (Aravind) and launch admin. + +### Merge and Release: + +- After getting the necessary approvals, merge the PR. This will trigger the publishing process on npm and GitHub, which can be tracked through the actions & github released tags. + + + +### How will changes be reflected in the CLI ? +If a patch or minor version of the launch is released, users will need to update or install the latest CLI version, which will automatically include the latest launch version. +`npm i -g @contentstack/cli` + OR +`npm update -g @contentstack/cli` + + However, if a major version of the launch is released, a version bump is also required in CLI(Steps will be like this launch version bump -> cli version bump -> testing -> release). From 95640a6905063e42404d9b89741d48aff3639b88 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Feb 2025 21:49:41 +0530 Subject: [PATCH 8/8] Update CODEOWNERS --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 316b947..1be7e0d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1 @@ * @contentstack/security-admin -* @contentstack/launch-pr-reviewers