@dauflo/nest-fixtures 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +9 -0
- package/dist/fixtures.command.d.ts +16 -0
- package/dist/fixtures.command.js +84 -0
- package/dist/fixtures.d.ts +14 -0
- package/dist/fixtures.js +51 -0
- package/dist/fixtures.module.d.ts +4 -0
- package/dist/fixtures.module.js +54 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/package.json +23 -0
- package/src/fixtures.command.ts +53 -0
- package/src/fixtures.module.ts +47 -0
- package/src/fixtures.ts +37 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +15 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import { CommandRunner } from 'nest-commander';
|
|
3
|
+
import { Fixtures } from './fixtures';
|
|
4
|
+
declare type FixturesObject = {
|
|
5
|
+
[key: string]: Fixtures;
|
|
6
|
+
};
|
|
7
|
+
export declare class FixturesCommand extends CommandRunner {
|
|
8
|
+
private fixtures;
|
|
9
|
+
private readonly connection;
|
|
10
|
+
private fixturesDone;
|
|
11
|
+
constructor(fixtures: FixturesObject, connection: Connection);
|
|
12
|
+
private loadData;
|
|
13
|
+
run(passedParams: string[], options?: Record<string, any>): Promise<void>;
|
|
14
|
+
purgeDatabase(): void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.FixturesCommand = void 0;
|
|
25
|
+
const common_1 = require("@nestjs/common");
|
|
26
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
27
|
+
const mongoose_2 = require("mongoose");
|
|
28
|
+
const nest_commander_1 = require("nest-commander");
|
|
29
|
+
let FixturesCommand = class FixturesCommand extends nest_commander_1.CommandRunner {
|
|
30
|
+
constructor(fixtures, connection) {
|
|
31
|
+
super();
|
|
32
|
+
this.fixtures = fixtures;
|
|
33
|
+
this.connection = connection;
|
|
34
|
+
this.fixturesDone = [];
|
|
35
|
+
}
|
|
36
|
+
loadData(key) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (!this.fixturesDone.includes(key)) {
|
|
39
|
+
this.fixturesDone.push(key);
|
|
40
|
+
if (this.fixtures[key].getDependencies().length !== 0) {
|
|
41
|
+
for (const dependency of this.fixtures[key].getDependencies()) {
|
|
42
|
+
yield this.loadData(dependency);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
console.log(`Loading ${key}...`);
|
|
46
|
+
yield this.fixtures[key].load();
|
|
47
|
+
console.log(`Done loading ${key}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
run(passedParams, options) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
console.log('=== Starting fixtures load ===');
|
|
54
|
+
for (const key of Object.keys(this.fixtures)) {
|
|
55
|
+
yield this.loadData(key);
|
|
56
|
+
}
|
|
57
|
+
console.log('=== Fixtures loaded ===');
|
|
58
|
+
return;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
purgeDatabase() {
|
|
62
|
+
console.log('Starting purging database...');
|
|
63
|
+
for (const collection of Object.keys(this.connection.collections)) {
|
|
64
|
+
this.connection.dropCollection(collection);
|
|
65
|
+
}
|
|
66
|
+
console.log('Database purging done');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, nest_commander_1.Option)({
|
|
71
|
+
flags: '--delete',
|
|
72
|
+
description: 'Purge all the current collections'
|
|
73
|
+
}),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", []),
|
|
76
|
+
__metadata("design:returntype", void 0)
|
|
77
|
+
], FixturesCommand.prototype, "purgeDatabase", null);
|
|
78
|
+
FixturesCommand = __decorate([
|
|
79
|
+
(0, nest_commander_1.Command)({ name: 'fixtures', description: 'load fixtures into the database' }),
|
|
80
|
+
__param(0, (0, common_1.Inject)('FIXTURES')),
|
|
81
|
+
__param(1, (0, mongoose_1.InjectConnection)()),
|
|
82
|
+
__metadata("design:paramtypes", [Object, mongoose_2.Connection])
|
|
83
|
+
], FixturesCommand);
|
|
84
|
+
exports.FixturesCommand = FixturesCommand;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface IFixtures {
|
|
2
|
+
load(): void;
|
|
3
|
+
getDependencies(): string[];
|
|
4
|
+
}
|
|
5
|
+
export declare class ReferenceRepository {
|
|
6
|
+
private reference;
|
|
7
|
+
addReference(key: string, data: any): void;
|
|
8
|
+
getReference<T = any>(key: string): T;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class Fixtures implements IFixtures {
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
getDependencies(): string[];
|
|
13
|
+
}
|
|
14
|
+
export {};
|
package/dist/fixtures.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Fixtures = exports.ReferenceRepository = void 0;
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
let ReferenceRepository = class ReferenceRepository {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.reference = {};
|
|
23
|
+
}
|
|
24
|
+
addReference(key, data) {
|
|
25
|
+
if (this.reference[key] !== undefined) {
|
|
26
|
+
throw new Error(`Key "${key}" already exists`);
|
|
27
|
+
}
|
|
28
|
+
this.reference[key] = data;
|
|
29
|
+
}
|
|
30
|
+
getReference(key) {
|
|
31
|
+
if (this.reference[key] === undefined) {
|
|
32
|
+
throw new Error(`Key "${key}" does not exist`);
|
|
33
|
+
}
|
|
34
|
+
return this.reference[key];
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
ReferenceRepository = __decorate([
|
|
38
|
+
(0, common_1.Injectable)()
|
|
39
|
+
], ReferenceRepository);
|
|
40
|
+
exports.ReferenceRepository = ReferenceRepository;
|
|
41
|
+
class Fixtures {
|
|
42
|
+
load() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
throw new common_1.NotImplementedException();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getDependencies() {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Fixtures = Fixtures;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FixturesModule = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
const glob_1 = require("glob");
|
|
15
|
+
class FixturesModule {
|
|
16
|
+
static forRootAsync(fixturesPathPattern, entitiesPathPattern) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const fixturesPath = glob_1.glob.sync(fixturesPathPattern);
|
|
19
|
+
const fixturesRelativePath = fixturesPath.map((path) => path.replace('src/', './../')).map((path) => path.replace('.ts', ''));
|
|
20
|
+
const fixturesProviders = [];
|
|
21
|
+
const importedFixtures = yield Promise.all(fixturesRelativePath.map((path) => Promise.resolve().then(() => require(path))));
|
|
22
|
+
importedFixtures.forEach((fixture) => {
|
|
23
|
+
fixturesProviders.push(fixture[Object.keys(fixture)[0]]);
|
|
24
|
+
});
|
|
25
|
+
const entitiesPath = glob_1.glob.sync(entitiesPathPattern);
|
|
26
|
+
const entitiesRelativePath = entitiesPath.map((path) => path.replace('src/', './../')).map((path) => path.replace('.ts', ''));
|
|
27
|
+
const entitiesProviders = [];
|
|
28
|
+
const importedEntities = yield Promise.all(entitiesRelativePath.map((path) => Promise.resolve().then(() => require(path))));
|
|
29
|
+
importedEntities.forEach((entity) => {
|
|
30
|
+
entitiesProviders.push({
|
|
31
|
+
name: entity[Object.keys(entity)[0]].name,
|
|
32
|
+
schema: entity[Object.keys(entity)[0]],
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
module: FixturesModule,
|
|
37
|
+
imports: [mongoose_1.MongooseModule.forFeature(importedEntities)],
|
|
38
|
+
providers: [
|
|
39
|
+
...fixturesProviders,
|
|
40
|
+
{
|
|
41
|
+
provide: 'FIXTURES',
|
|
42
|
+
useFactory(...args) {
|
|
43
|
+
const providersObject = {};
|
|
44
|
+
args.forEach((arg) => (providersObject[arg.constructor.name] = arg));
|
|
45
|
+
return providersObject;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
exports: ['FIXTURES'],
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.FixturesModule = FixturesModule;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./fixtures"), exports);
|
|
18
|
+
__exportStar(require("./fixtures.command"), exports);
|
|
19
|
+
__exportStar(require("./fixtures.module"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dauflo/nest-fixtures",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@nestjs/common": "^9.1.1",
|
|
13
|
+
"@nestjs/core": "^9.1.1",
|
|
14
|
+
"@nestjs/mongoose": "^9.2.0",
|
|
15
|
+
"@types/glob": "^8.0.0",
|
|
16
|
+
"glob": "^8.0.3",
|
|
17
|
+
"mongoose": "^6.6.1",
|
|
18
|
+
"nest-commander": "^3.1.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^4.8.3"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Inject } from '@nestjs/common'
|
|
2
|
+
import { InjectConnection } from '@nestjs/mongoose'
|
|
3
|
+
import { Connection } from 'mongoose'
|
|
4
|
+
import { Command, CommandRunner, Option } from 'nest-commander'
|
|
5
|
+
import { Fixtures } from './fixtures'
|
|
6
|
+
|
|
7
|
+
type FixturesObject = {
|
|
8
|
+
[key: string]: Fixtures
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@Command({ name: 'fixtures', description: 'load fixtures into the database' })
|
|
12
|
+
export class FixturesCommand extends CommandRunner {
|
|
13
|
+
private fixturesDone: string[] = []
|
|
14
|
+
|
|
15
|
+
constructor(@Inject('FIXTURES') private fixtures: FixturesObject, @InjectConnection() private readonly connection: Connection) {
|
|
16
|
+
super()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private async loadData(key: string) {
|
|
20
|
+
if (!this.fixturesDone.includes(key)) {
|
|
21
|
+
this.fixturesDone.push(key)
|
|
22
|
+
if (this.fixtures[key].getDependencies().length !== 0) {
|
|
23
|
+
for (const dependency of this.fixtures[key].getDependencies()) {
|
|
24
|
+
await this.loadData(dependency)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.log(`Loading ${key}...`)
|
|
28
|
+
await this.fixtures[key].load()
|
|
29
|
+
console.log(`Done loading ${key}`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async run(passedParams: string[], options?: Record<string, any>): Promise<void> {
|
|
34
|
+
console.log('=== Starting fixtures load ===')
|
|
35
|
+
for (const key of Object.keys(this.fixtures)) {
|
|
36
|
+
await this.loadData(key)
|
|
37
|
+
}
|
|
38
|
+
console.log('=== Fixtures loaded ===')
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Option({
|
|
43
|
+
flags: '--delete',
|
|
44
|
+
description: 'Purge all the current collections'
|
|
45
|
+
})
|
|
46
|
+
purgeDatabase() {
|
|
47
|
+
console.log('Starting purging database...')
|
|
48
|
+
for (const collection of Object.keys(this.connection.collections)) {
|
|
49
|
+
this.connection.dropCollection(collection)
|
|
50
|
+
}
|
|
51
|
+
console.log('Database purging done')
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common'
|
|
2
|
+
import { MongooseModule } from '@nestjs/mongoose'
|
|
3
|
+
import { glob } from 'glob'
|
|
4
|
+
|
|
5
|
+
export class FixturesModule {
|
|
6
|
+
static async forRootAsync(fixturesPathPattern: string, entitiesPathPattern: string): Promise<DynamicModule> {
|
|
7
|
+
// import fixtures
|
|
8
|
+
const fixturesPath = glob.sync(fixturesPathPattern)
|
|
9
|
+
const fixturesRelativePath = fixturesPath.map((path) => path.replace('src/', './../')).map((path) => path.replace('.ts', ''))
|
|
10
|
+
const fixturesProviders: any[] = []
|
|
11
|
+
const importedFixtures = await Promise.all(fixturesRelativePath.map((path) => import(path)))
|
|
12
|
+
|
|
13
|
+
importedFixtures.forEach((fixture) => {
|
|
14
|
+
fixturesProviders.push(fixture[Object.keys(fixture)[0]])
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// import entities
|
|
18
|
+
const entitiesPath = glob.sync(entitiesPathPattern)
|
|
19
|
+
const entitiesRelativePath = entitiesPath.map((path) => path.replace('src/', './../')).map((path) => path.replace('.ts', ''))
|
|
20
|
+
const entitiesProviders: any[] = []
|
|
21
|
+
const importedEntities = await Promise.all(entitiesRelativePath.map((path) => import(path)))
|
|
22
|
+
|
|
23
|
+
importedEntities.forEach((entity) => {
|
|
24
|
+
entitiesProviders.push({
|
|
25
|
+
name: entity[Object.keys(entity)[0]].name,
|
|
26
|
+
schema: entity[Object.keys(entity)[0]],
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
module: FixturesModule,
|
|
32
|
+
imports: [MongooseModule.forFeature(importedEntities)],
|
|
33
|
+
providers: [
|
|
34
|
+
...fixturesProviders,
|
|
35
|
+
{
|
|
36
|
+
provide: 'FIXTURES',
|
|
37
|
+
useFactory(...args) {
|
|
38
|
+
const providersObject = {}
|
|
39
|
+
args.forEach((arg) => (providersObject[arg.constructor.name] = arg))
|
|
40
|
+
return providersObject
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
exports: ['FIXTURES'],
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/fixtures.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Injectable, NotImplementedException } from '@nestjs/common'
|
|
2
|
+
|
|
3
|
+
interface IFixtures {
|
|
4
|
+
load(): void
|
|
5
|
+
|
|
6
|
+
getDependencies(): string[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class ReferenceRepository {
|
|
11
|
+
private reference: { [key: string]: any } = {}
|
|
12
|
+
|
|
13
|
+
addReference(key: string, data: any) {
|
|
14
|
+
if (this.reference[key] !== undefined) {
|
|
15
|
+
throw new Error(`Key "${key}" already exists`)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
this.reference[key] = data
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getReference<T = any>(key: string): T {
|
|
22
|
+
if (this.reference[key] === undefined) {
|
|
23
|
+
throw new Error(`Key "${key}" does not exist`)
|
|
24
|
+
}
|
|
25
|
+
return this.reference[key]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export abstract class Fixtures implements IFixtures {
|
|
30
|
+
async load(): Promise<void> {
|
|
31
|
+
throw new NotImplementedException()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getDependencies(): string[] {
|
|
35
|
+
return []
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"removeComments": true,
|
|
9
|
+
"baseUrl": "./",
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"emitDecoratorMetadata": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|