lambdaorm-cli
Version:
The lambdaorm command line interface
49 lines • 2.31 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientWorkspaceService = void 0;
const lambdaorm_client_node_1 = require("lambdaorm-client-node");
const path_1 = __importDefault(require("path"));
const yaml = require('js-yaml');
class ClientWorkspaceService {
constructor(workspace, url, helper) {
this.workspace = workspace;
this.url = url;
this.helper = helper;
this.orm = new lambdaorm_client_node_1.Orm(this.url);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
init(args) {
return __awaiter(this, void 0, void 0, function* () {
try {
// create workspace
yield this.helper.fs.create(this.workspace);
// init orm
yield this.orm.init(args.url);
// create initial structure
const domainSchema = yield this.orm.schema.domain();
const schema = { domain: domainSchema, infrastructure: { service: { url: this.url } } };
// write lambdaorm config
const configPath = path_1.default.join(this.workspace, 'lambdaORM.yaml');
yield this.helper.fs.write(configPath, yaml.dump(schema));
}
catch (error) {
yield this.orm.end();
throw error;
}
});
}
}
exports.ClientWorkspaceService = ClientWorkspaceService;
//# sourceMappingURL=client.js.map