UNPKG

@melchyore/adonis-cache

Version:
46 lines (45 loc) 2.02 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const standalone_1 = require("@adonisjs/core/build/standalone"); class Make extends standalone_1.BaseCommand { constructor() { super(...arguments); this.cacheTableName = 'cache'; } async run() { const stub = (0, path_1.join)(__dirname, '..', 'templates', 'migration.txt'); const cacheTableName = this.cacheTableName ?? 'cache'; this.generator .addFile(`${Date.now()}_${cacheTableName}.ts`) .appRoot(this.application.appRoot) .destinationDir(this.application.directoriesMap.get('migrations') || 'database') .useMustache() .stub(stub) .apply({ cacheTableName }); await this.generator.run(); } } Make.commandName = 'cache:table'; Make.description = 'Create a migration for the cache database table'; Make.settings = { loadApp: true, stayAlive: false }; __decorate([ standalone_1.args.string({ description: 'Table name', required: false }), __metadata("design:type", String) ], Make.prototype, "cacheTableName", void 0); exports.default = Make;