@metacall/faas
Version:
Reimplementation of MetaCall FaaS platform written in TypeScript.
46 lines (45 loc) • 1.91 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.autoDeployApps = void 0;
const fs = __importStar(require("fs/promises"));
const path = __importStar(require("path"));
const app_1 = require("../app");
const deploy_1 = require("./deploy");
const autoDeployApps = async (appsDir) => {
const directories = (await fs.readdir(appsDir, {
withFileTypes: true
})).reduce((dirs, current) => current.isDirectory() ? [...dirs, current] : dirs, []);
const resources = directories.map(dir => ({
id: dir.name,
path: path.join(appsDir, dir.name),
jsons: []
}));
await Promise.all(resources.map(resource => {
app_1.Applications[resource.id] = new app_1.Application();
app_1.Applications[resource.id].resource = Promise.resolve(resource);
return deploy_1.deployProcess(resource);
}));
if (resources.length > 0) {
console.log('Previously deployed applications deployed successfully'.green);
}
};
exports.autoDeployApps = autoDeployApps;