From b1c50bb8c264fe9af22276b5e56891ad75262589 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 12 Nov 2024 11:58:20 +0500 Subject: [PATCH] Windows build (#7158) Signed-off-by: Denis Bykhov --- common/config/rush/pnpm-lock.yaml | 12 ++ common/scripts/esbuild.js | 114 ++++++++++++++++++ common/scripts/package.json | 12 ++ dev/doc-import-tool/esbuild.js | 2 + dev/doc-import-tool/package.json | 2 +- dev/import-tool/esbuild.js | 5 +- dev/import-tool/package.json | 2 +- dev/tool/package.json | 2 +- models/all/package.json | 2 +- pods/account/package.json | 2 +- pods/backup/package.json | 4 +- pods/collaborator/package.json | 2 +- pods/front/package.json | 2 +- pods/fulltext/package.json | 4 +- pods/server/package.json | 4 +- pods/stats/package.json | 2 +- pods/workspace/package.json | 2 +- rush.json | 5 + services/ai-bot/pod-ai-bot/package.json | 2 +- .../pod-analytics-collector/package.json | 2 +- services/calendar/pod-calendar/package.json | 2 +- services/github/pod-github/package.json | 2 +- services/gmail/pod-gmail/package.json | 2 +- services/love/package.json | 2 +- services/print/pod-print/package.json | 2 +- services/rekoni/esbuild.js | 3 + services/ses/pod-ses/package.json | 2 +- services/sign/pod-sign/package.json | 2 +- .../pod-telegram-bot/package.json | 2 +- services/telegram/pod-telegram/package.json | 2 +- 30 files changed, 178 insertions(+), 27 deletions(-) create mode 100644 common/scripts/esbuild.js create mode 100644 common/scripts/package.json diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 43d4561238..b118d34aa7 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -740,6 +740,9 @@ dependencies: '@rush-temp/s3': specifier: file:./projects/s3.tgz version: file:projects/s3.tgz(esbuild@0.20.1)(ts-node@10.9.2) + '@rush-temp/scripts': + specifier: file:./projects/scripts.tgz + version: file:projects/scripts.tgz '@rush-temp/server': specifier: file:./projects/server.tgz version: file:projects/server.tgz(esbuild@0.20.1)(ts-node@10.9.2) @@ -28270,6 +28273,15 @@ packages: - ts-node dev: false + file:projects/scripts.tgz: + resolution: {integrity: sha512-HS575HRsNygQqaTm8xnQfCbBXmnMVpuUf5n6Dyu9UNk0TZvMUBLbGjeHN91ZnpjcS+F8nOh9SY+eBhqfY0vAIQ==, tarball: file:projects/scripts.tgz} + name: '@rush-temp/scripts' + version: 0.0.0 + dependencies: + esbuild: 0.20.1 + sharp: 0.32.6 + dev: false + file:projects/server-activity-resources.tgz(@types/node@20.11.19)(esbuild@0.20.1)(ts-node@10.9.2): resolution: {integrity: sha512-MK/u1/C+WybVSjINrL8/N5ogkV/W/yrR0wU+1Dn7RQHjTjcv1wckawhhkpyWvV/GOHmJ/9sk52DRNN0aT38Iig==, tarball: file:projects/server-activity-resources.tgz} id: file:projects/server-activity-resources.tgz diff --git a/common/scripts/esbuild.js b/common/scripts/esbuild.js new file mode 100644 index 0000000000..440df6c532 --- /dev/null +++ b/common/scripts/esbuild.js @@ -0,0 +1,114 @@ +const esbuild = require('esbuild'); +const path = require('path'); +const fs = require('fs'); +const { execSync } = require('child_process'); + +const SCRIPT_DIR = __dirname; + +const defaultConfig = { + entryPoint: 'src/index.ts', + outdir: 'bundle', + platform: 'node', + minify: false, + keepNames: false, + sourcemap: false, + logLevel: 'error', + external: [], + define: {}, +}; + +function getGitRevision() { + try { + return '"' + execSync('git describe --all --long').toString().trim() + '"'; + } catch (error) { + console.warn('Failed to get git revision:', error.message); + return ''; + } +} + +function getVersionFromScript(scriptPath) { + try { + const absoluteScriptPath = path.resolve(SCRIPT_DIR, scriptPath); + return execSync(`node "${absoluteScriptPath}"`).toString().trim(); + } catch (error) { + console.warn(`Failed to get version from ${scriptPath}:`, error.message); + return ''; + } +} + +async function bundle(config) { + // Ensure output directory exists + fs.mkdirSync(config.outdir, { recursive: true }); + + try { + await esbuild.build({ + entryPoints: [config.entryPoint], + bundle: true, + platform: config.platform, + outfile: path.join(config.outdir, 'bundle.js'), + logLevel: config.logLevel, + minify: config.minify, + keepNames: config.keepNames, + sourcemap: config.sourcemap, + external: config.external, + define: config.define, + }); + + console.log('Build completed successfully!'); + } catch (error) { + console.error('Build failed:', error.message); + process.exit(1); + } +} + +async function main() { + const args = process.argv.slice(2); + const config = { ...defaultConfig }; + + const define = {}; + + args.forEach(arg => { + if (arg.startsWith('--')) { + const [key, value] = arg.slice(2).split('='); + switch (key) { + case 'entry': + config.entryPoint = value; + break; + case 'minify': + config.minify = value !== 'false'; + break; + case 'keep-names': + config.keepNames = value !== 'false'; + break; + case 'external': + config.external.push(value); + break; + case 'sourcemap': + config.sourcemap = value !== 'false'; + break; + case 'define': + define[value] = true; + break; + } + } + }); + + const env = { + MODEL_VERSION: define['MODEL_VERSION'] ? getVersionFromScript('./show_version.js') : undefined, + VERSION: define['VERSION'] ? getVersionFromScript('./show_tag.js') : undefined, + GIT_REVISION: define['GIT_REVISION'] ? getGitRevision() : undefined, + }; + + Object.entries(env).forEach(([key, value]) => { + if (value) { + config.define[`process.env.${key}`] = value; + } + }); + + await bundle(config); +} + +main().catch(error => { + console.error('Unexpected error:', error); + process.exit(1); +}); \ No newline at end of file diff --git a/common/scripts/package.json b/common/scripts/package.json new file mode 100644 index 0000000000..27f94e12fa --- /dev/null +++ b/common/scripts/package.json @@ -0,0 +1,12 @@ +{ + "name": "@hcengineering/scripts", + "version": "0.1.0", + "scripts": { + "format": "echo \"No format specified\"" + }, + "devDependencies": { + "esbuild": "^0.20.0", + "sharp": "~0.32.0" + }, + "private": true +} diff --git a/dev/doc-import-tool/esbuild.js b/dev/doc-import-tool/esbuild.js index b00386cd5a..d342218dd3 100644 --- a/dev/doc-import-tool/esbuild.js +++ b/dev/doc-import-tool/esbuild.js @@ -1,5 +1,7 @@ const esbuild = require('esbuild') +const fs = require('fs'); +fs.mkdirSync('bundle', { recursive: true }); esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, diff --git a/dev/doc-import-tool/package.json b/dev/doc-import-tool/package.json index 87f0604b97..5c30fd3bc2 100644 --- a/dev/doc-import-tool/package.json +++ b/dev/doc-import-tool/package.json @@ -14,7 +14,7 @@ "build": "compile", "build:watch": "compile", "_phase:bundle": "rushx bundle", - "bundle": "mkdir -p bundle && node esbuild.js", + "bundle": "node esbuild.js", "run-local": "cross-env SERVER_SECRET=secret MONGO_URL=mongodb://localhost:27017 COLLABORATOR_URL=ws://localhost:3078 STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin node --nolazy -r ts-node/register ./src/__start.ts", "run": "cross-env node -r ts-node/register --max-old-space-size=8000 ./src/__start.ts", "format": "format src", diff --git a/dev/import-tool/esbuild.js b/dev/import-tool/esbuild.js index b00386cd5a..90245a223b 100644 --- a/dev/import-tool/esbuild.js +++ b/dev/import-tool/esbuild.js @@ -1,4 +1,7 @@ -const esbuild = require('esbuild') +const esbuild = require('esbuild'); +const fs = require('fs'); + +fs.mkdirSync('bundle', { recursive: true }); esbuild.build({ entryPoints: ['src/index.ts'], diff --git a/dev/import-tool/package.json b/dev/import-tool/package.json index cc51e3f283..df3e9123ad 100644 --- a/dev/import-tool/package.json +++ b/dev/import-tool/package.json @@ -14,7 +14,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --bundle --keep-names --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --define=MODEL_VERSION --define=GIT_REVISION --sourcemap=external", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/import-tool", "docker:tbuild": "docker build -t hardcoreeng/import-tool . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/import-tool", "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/import-tool staging", diff --git a/dev/tool/package.json b/dev/tool/package.json index 314bfbde9e..726c66d004 100644 --- a/dev/tool/package.json +++ b/dev/tool/package.json @@ -14,7 +14,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --bundle --keep-names --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --sourcemap=external --define:MODEL_VERSION --define:GIT_REVISION", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/tool", "docker:tbuild": "docker build -t hardcoreeng/tool . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/tool", "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging", diff --git a/models/all/package.json b/models/all/package.json index 044e908168..9102565911 100644 --- a/models/all/package.json +++ b/models/all/package.json @@ -16,7 +16,7 @@ "_phase:validate": "compile validate", "show-model": "node ./bundle/bundle.js", "_phase:bundle": "rushx bundle", - "bundle": "mkdir -p bundle && esbuild src/show.ts --bundle --keep-names --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error && node ./bundle/bundle.js > ./bundle/model.json" + "bundle": "node ../../common/scripts/esbuild.js --keep-names=true --bundle=true --entry=src/show.ts --define=MODEL_VERSION --define=VERSION --define=GIT_REVISION && node ./bundle/bundle.js > ./bundle/model.json" }, "devDependencies": { "@hcengineering/platform-rig": "^0.6.0", diff --git a/pods/account/package.json b/pods/account/package.json index d5a3fb5e93..ed78e86eda 100644 --- a/pods/account/package.json +++ b/pods/account/package.json @@ -14,7 +14,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --external:*.node --external:snappy --keep-names --bundle --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --platform=node --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --define=MODEL_VERSION --sourcemap=external --external=*.node --external=snappy", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/account", "docker:tbuild": "docker build -t hardcoreeng/account . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/account", "docker:abuild": "docker build -t hardcoreeng/account . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/account", diff --git a/pods/backup/package.json b/pods/backup/package.json index fdae32ea7f..6b1e15c3a2 100644 --- a/pods/backup/package.json +++ b/pods/backup/package.json @@ -14,8 +14,8 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "get-model": "mkdir -p bundle && esbuild src/get-model.ts --bundle --keep-names --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error && node ./bundle/bundle.js > ./bundle/model.json", - "bundle": "mkdir -p bundle && rushx get-model && esbuild src/index.ts --keep-names --bundle --platform=node --external:*.node --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "get-model": "node ../../common/scripts/esbuild.js --entry=src/get-model.ts --keep-names=true --bundle=true --define=MODEL_VERSION --define=VERSION --define=GIT_REVISION && node ./bundle/bundle.js > ./bundle/model.json", + "bundle": "rushx get-model && node ../../common/scripts/esbuild.js --entry=src/index.ts --keep-names=true --bundle=true --sourcemap=external --external=*.node", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/backup", "docker:tbuild": "docker build -t hardcoreeng/backup . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/backup", "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/backup staging", diff --git a/pods/collaborator/package.json b/pods/collaborator/package.json index 1bf081d038..e694551162 100644 --- a/pods/collaborator/package.json +++ b/pods/collaborator/package.json @@ -13,7 +13,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --bundle --platform=node --keep-names --external:*.node --external:bufferutil --external:snappy --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --sourcemap=external --external=*.node --external=snappy --external=bufferutil", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/collaborator", "docker:tbuild": "docker build -t hardcoreeng/collaborator . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/collaborator", "docker:abuild": "docker build -t hardcoreeng/collaborator . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/collaborator", diff --git a/pods/front/package.json b/pods/front/package.json index 88366245a7..f875a9f0a9 100644 --- a/pods/front/package.json +++ b/pods/front/package.json @@ -14,7 +14,7 @@ "_phase:package": "rushx package", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --keep-names --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --bundle --minify --platform=node --external:sharp --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --define=MODEL_VERSION --define=VERSION --sourcemap=external --minify --external=sharp", "package": "rm -rf ./dist && cp -r ../../dev/prod/dist . && cp -r ../../dev/prod/public/* ./dist/ && rm ./dist/config.json", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/front", "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/front staging", diff --git a/pods/fulltext/package.json b/pods/fulltext/package.json index 956091dc0c..d886671cdf 100644 --- a/pods/fulltext/package.json +++ b/pods/fulltext/package.json @@ -14,8 +14,8 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "get-model": "mkdir -p bundle && esbuild src/get-model.ts --bundle --keep-names --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error && node ./bundle/bundle.js > ./bundle/model.json", - "bundle": "mkdir -p bundle && rushx get-model && esbuild src/index.ts --keep-names --bundle --platform=node --external:*.node --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "get-model": "node ../../common/scripts/esbuild.js --entry=src/get-model.ts --keep-names=true --bundle=true --define=MODEL_VERSION --define=VERSION --define=GIT_REVISION && node ./bundle/bundle.js > ./bundle/model.json", + "bundle": "rushx get-model && node ../../common/scripts/esbuild.js --keep-names=true --bundle=true --external=*.node --sourcemap=external", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/fulltext", "docker:tbuild": "docker build -t hardcoreeng/fulltext . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/fulltext", "docker:abuild": "docker build -t hardcoreeng/fulltext . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/fulltext", diff --git a/pods/server/package.json b/pods/server/package.json index 8b7d96ed4e..8e4c2cb14d 100644 --- a/pods/server/package.json +++ b/pods/server/package.json @@ -15,8 +15,8 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "get-model": "mkdir -p bundle && esbuild src/get-model.ts --bundle --keep-names --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error && node ./bundle/bundle.js > ./bundle/model.json", - "bundle": "mkdir -p bundle && rushx get-model && esbuild src/__start.ts --bundle --keep-names --platform=node --external:*.node --external:bufferutil --external:snappy --external:utf-8-validate --external:msgpackr-extract --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.VERSION=$(node ../../common/scripts/show_tag.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "get-model": "node ../../common/scripts/esbuild.js --entry=src/get-model.ts -keep-names=true --define=MODEL_VERSION --define=VERSION --define=GIT_REVISION --bundle=true && node ./bundle/bundle.js > ./bundle/model.json", + "bundle": "rushx get-model && node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --bundle=true --sourcemap=external --external=*.node --external=*.node --external=bufferutil --external=snappy --define=MODEL_VERSION --define=VERSION --define=GIT_REVISION --external=utf-8-validate --external=msgpackr-extract", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/transactor", "docker:tbuild": "docker build -t hardcoreeng/transactor . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/transactor", "docker:abuild": "docker build -t hardcoreeng/transactor . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/transactor", diff --git a/pods/stats/package.json b/pods/stats/package.json index 1e579833a5..9ef5a872fa 100644 --- a/pods/stats/package.json +++ b/pods/stats/package.json @@ -14,7 +14,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --external:*.node --external:snappy --keep-names --bundle --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --platform=node --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --sourcemap=external --define=MODEL_VERSION --external=*.node --external=snappy", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/stats", "docker:tbuild": "docker build -t hardcoreeng/stats . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/stats", "docker:abuild": "docker build -t hardcoreeng/stats . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/stats", diff --git a/pods/workspace/package.json b/pods/workspace/package.json index ad935f2b42..adc4319455 100644 --- a/pods/workspace/package.json +++ b/pods/workspace/package.json @@ -14,7 +14,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/__start.ts --external:*.node --external:snappy --bundle --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --minify --platform=node --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../common/scripts/esbuild.js --entry=src/__start.ts --keep-names=true --sourcemap=external --external=*.node --define=MODEL_VERSION --external=snappy --minify=true", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/workspace", "docker:tbuild": "docker build -t hardcoreeng/workspace . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/workspace", "docker:abuild": "docker build -t hardcoreeng/workspace . --platform=linux/arm64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/workspace", diff --git a/rush.json b/rush.json index 3547e832a3..c8989f1709 100644 --- a/rush.json +++ b/rush.json @@ -2155,6 +2155,11 @@ "packageName": "@hcengineering/cloud-datalake", "projectFolder": "workers/datalake", "shouldPublish": false + }, + { + "packageName": "@hcengineering/scripts", + "projectFolder": "common/scripts", + "shouldPublish": false } ] } diff --git a/services/ai-bot/pod-ai-bot/package.json b/services/ai-bot/pod-ai-bot/package.json index 80beb4fa12..bfac46115b 100644 --- a/services/ai-bot/pod-ai-bot/package.json +++ b/services/ai-bot/pod-ai-bot/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/ai-bot", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/ai-bot staging", "docker:push": "../../../common/scripts/docker_tag.sh hardcoreeng/ai-bot", diff --git a/services/analytics-collector/pod-analytics-collector/package.json b/services/analytics-collector/pod-analytics-collector/package.json index 530e91403a..429997b935 100644 --- a/services/analytics-collector/pod-analytics-collector/package.json +++ b/services/analytics-collector/pod-analytics-collector/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/analytics-collector", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/analytics-collector staging", "docker:push": "../../../common/scripts/docker_tag.sh hardcoreeng/analytics-collector", diff --git a/services/calendar/pod-calendar/package.json b/services/calendar/pod-calendar/package.json index 6a83fba8de..53b00b00f6 100644 --- a/services/calendar/pod-calendar/package.json +++ b/services/calendar/pod-calendar/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/calendar", "docker:tbuild": "docker build -t hardcoreeng/calendar . --platform=linux/amd64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/calendar", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/calendar staging", diff --git a/services/github/pod-github/package.json b/services/github/pod-github/package.json index 0bfe8526a7..1358f21233 100644 --- a/services/github/pod-github/package.json +++ b/services/github/pod-github/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --keep-names --bundle --platform=node --outfile=bundle/bundle.js --log-level=error --sourcemap=external", + "bundle": "node ../../../common/scripts/esbuild.js --sourcemap=external", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/github", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/github staging", "docker:push": "../../../common/scripts/docker_tag.sh hardcoreeng/github", diff --git a/services/gmail/pod-gmail/package.json b/services/gmail/pod-gmail/package.json index 2fe109198c..06d8736f14 100644 --- a/services/gmail/pod-gmail/package.json +++ b/services/gmail/pod-gmail/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/gmail", "docker:tbuild": "docker build -t hardcoreeng/gmail . --platform=linux/amd64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/gmail", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/gmail staging", diff --git a/services/love/package.json b/services/love/package.json index 1814adedc8..751e22c027 100644 --- a/services/love/package.json +++ b/services/love/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../common/scripts/esbuild.js", "docker:build": "../../common/scripts/docker_build.sh hardcoreeng/love .", "docker:tbuild": "docker build -t hardcoreeng/love . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/love", "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/love staging", diff --git a/services/print/pod-print/package.json b/services/print/pod-print/package.json index 3ac6bf5507..0bed86ff51 100644 --- a/services/print/pod-print/package.json +++ b/services/print/pod-print/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node --keep-names > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js --keep-names=true", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/print", "docker:tbuild": "docker build -t hardcoreeng/print . --platform=linux/amd64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/print", "docker:abuild": "docker build -t hardcoreeng/print . --platform=linux/arm64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/print", diff --git a/services/rekoni/esbuild.js b/services/rekoni/esbuild.js index 4d1ea8fa09..2d0c6ca175 100644 --- a/services/rekoni/esbuild.js +++ b/services/rekoni/esbuild.js @@ -1,4 +1,7 @@ const esbuild = require('esbuild') +const fs = require('fs'); + +fs.mkdirSync('bundle', { recursive: true }); void esbuild.build({ entryPoints: ['src/index.ts'], diff --git a/services/ses/pod-ses/package.json b/services/ses/pod-ses/package.json index a23bb971a6..69a124049c 100644 --- a/services/ses/pod-ses/package.json +++ b/services/ses/pod-ses/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/ses", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/ses staging", "docker:push": "../../../common/scripts/docker_tag.sh hardcoreeng/ses", diff --git a/services/sign/pod-sign/package.json b/services/sign/pod-sign/package.json index d27e458404..57474b9a3f 100644 --- a/services/sign/pod-sign/package.json +++ b/services/sign/pod-sign/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node --keep-names > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/sign", "docker:tbuild": "docker build -t hardcoreeng/sign . --platform=linux/amd64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/sign", "docker:abuild": "docker build -t hardcoreeng/sign . --platform=linux/arm64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/sign", diff --git a/services/telegram-bot/pod-telegram-bot/package.json b/services/telegram-bot/pod-telegram-bot/package.json index 3f41c8eb98..8b0db79828 100644 --- a/services/telegram-bot/pod-telegram-bot/package.json +++ b/services/telegram-bot/pod-telegram-bot/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/telegram-bot", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/telegram-bot staging", "docker:push": "../../../common/scripts/docker_tag.sh hardcoreeng/telegram-bot", diff --git a/services/telegram/pod-telegram/package.json b/services/telegram/pod-telegram/package.json index 771026ad8e..0afadb6d98 100644 --- a/services/telegram/pod-telegram/package.json +++ b/services/telegram/pod-telegram/package.json @@ -17,7 +17,7 @@ "_phase:bundle": "rushx bundle", "_phase:docker-build": "rushx docker:build", "_phase:docker-staging": "rushx docker:staging", - "bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --platform=node > bundle/bundle.js", + "bundle": "node ../../../common/scripts/esbuild.js", "docker:build": "../../../common/scripts/docker_build.sh hardcoreeng/telegram", "docker:tbuild": "docker build -t hardcoreeng/telegram . --platform=linux/amd64 && ../../../common/scripts/docker_tag_push.sh hardcoreeng/telegram", "docker:staging": "../../../common/scripts/docker_tag.sh hardcoreeng/telegram staging",