diff --git a/.scripts/copy-hbs.js b/.scripts/copy-hbs.js new file mode 100644 index 0000000..c770de8 --- /dev/null +++ b/.scripts/copy-hbs.js @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * http://github.com/fonoster/goodtok + * + * This file is part of Goodtok + * + * Licensed under the MIT License (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://opensource.org/licenses/MIT + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const fs = require('fs-extra'); +const path = require('path'); + +const sourceDir = './src/notifications'; +const destDir = './dist/notifications'; + +function copyHbsFiles(source, destination) { + fs.readdir(source, { withFileTypes: true }, (err, files) => { + if (err) { + console.error('error reading source directory:', err); + return; + } + + files.forEach(file => { + const sourcePath = path.join(source, file.name); + const destPath = path.join(destination, file.name); + + if (file.isDirectory()) { + copyHbsFiles(sourcePath, destPath); + } else if (file.isFile() && sourcePath.endsWith('.hbs')) { + fs.copy(sourcePath, destPath, err => { + if (err) { + console.error('error copying file:', sourcePath, err); + } + }); + } + }); + }); +} + +copyHbsFiles(sourceDir, destDir); \ No newline at end of file diff --git a/compose.dev.yaml b/compose.dev.yaml index 9d9edb9..7d2d407 100644 --- a/compose.dev.yaml +++ b/compose.dev.yaml @@ -11,6 +11,7 @@ services: build: context: . dockerfile: ./mods/apiserver/Dockerfile + nats: image: nats:latest ports: diff --git a/mods/apiserver/package.json b/mods/apiserver/package.json index 55f4e3a..cfd6d0c 100644 --- a/mods/apiserver/package.json +++ b/mods/apiserver/package.json @@ -14,6 +14,7 @@ "scripts": { "prebuild": "rimraf ./dist tsconfig.tsbuildinfo", "build": "tsc -b tsconfig.json", + "postbuild": "node ../../.scripts/copy-hbs.js", "clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo" }, "bin": { @@ -71,6 +72,7 @@ "@types/jsonwebtoken": "^9.0.3", "@types/nodemailer": "^6.4.14", "@types/ws": "^8.5.6", + "fs-extra": "^11.2.0", "prisma": "^5.4.1" } } diff --git a/package-lock.json b/package-lock.json index a0f7339..1151d90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -99,9 +99,24 @@ "@types/jsonwebtoken": "^9.0.3", "@types/nodemailer": "^6.4.14", "@types/ws": "^8.5.6", + "fs-extra": "^11.2.0", "prisma": "^5.4.1" } }, + "mods/apiserver/node_modules/fs-extra": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, "mods/apiserver/node_modules/nanoid": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",