UNPKG

2.5 kBJavaScriptView Raw
1"use strict";
2/*
3 * @adonisjs/lucid
4 *
5 * (c) Harminder Virk <virk@adonisjs.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13 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;
14 return c > 3 && r && Object.defineProperty(target, key, r), r;
15};
16var __metadata = (this && this.__metadata) || function (k, v) {
17 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18};
19Object.defineProperty(exports, "__esModule", { value: true });
20const path_1 = require("path");
21const standalone_1 = require("@adonisjs/core/build/standalone");
22class MakeSeeder extends standalone_1.BaseCommand {
23 constructor() {
24 super(...arguments);
25 /**
26 * The name of the seeder file.
27 */
28 Object.defineProperty(this, "name", {
29 enumerable: true,
30 configurable: true,
31 writable: true,
32 value: void 0
33 });
34 }
35 /**
36 * Execute command
37 */
38 async run() {
39 const stub = (0, path_1.join)(__dirname, '..', 'templates', 'seeder.txt');
40 const path = this.application.rcFile.directories.seeds;
41 this.generator
42 .addFile(this.name, { pattern: 'pascalcase', form: 'singular' })
43 .stub(stub)
44 .destinationDir(path || 'database/Seeders')
45 .useMustache()
46 .appRoot(this.application.cliCwd || this.application.appRoot);
47 await this.generator.run();
48 }
49}
50Object.defineProperty(MakeSeeder, "commandName", {
51 enumerable: true,
52 configurable: true,
53 writable: true,
54 value: 'make:seeder'
55});
56Object.defineProperty(MakeSeeder, "description", {
57 enumerable: true,
58 configurable: true,
59 writable: true,
60 value: 'Make a new Seeder file'
61});
62__decorate([
63 standalone_1.args.string({ description: 'Name of the seeder class' }),
64 __metadata("design:type", String)
65], MakeSeeder.prototype, "name", void 0);
66exports.default = MakeSeeder;