Skip to content

Commit f75f137

Browse files
committed
Resolve build issues with json imports
1 parent 156c390 commit f75f137

File tree

10 files changed

+44
-44
lines changed

10 files changed

+44
-44
lines changed

projects/ionic-typeorm/package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rareloop/ionic-typeorm",
3-
"version": "0.0.8",
3+
"version": "0.0.15",
44
"description": "",
55
"license": "MIT",
66
"author": "Rareloop",
@@ -13,12 +13,10 @@
1313
"url": "https://github.com/Rareloop/ionic-typeorm/issues"
1414
},
1515
"peerDependencies": {
16-
"@angular/common": "^11",
17-
"@angular/core": "^11",
18-
"typeorm": "^0.2",
19-
"sql.js": "^1.5"
20-
},
21-
"devDependencies": {
16+
"@angular/common": "^11.0.9",
17+
"@angular/core": "^11.0.9",
18+
"typeorm": "^0.2.31",
19+
"sql.js": "^1.5.0",
2220
"@angular-builders/custom-webpack": "^11"
2321
},
2422
"bin": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './common-entity';
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from './connection';
2-
export * from './entities/common-entity';
3-
export * from './seeds/orm-seeder.seeder';
4-
export * from './services/db-service';
5-
export * from './services/orm-service.service';
6-
export * from './test/type-orm-test-utils';
2+
export * from './entities';
3+
export * from './seeds';
4+
export * from './services';
5+
export * from './test';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './orm-seeder.seeder';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './db-service';
2+
export * from './orm-service.service';
3+
export * from './orm-database.service';

projects/ionic-typeorm/src/lib/services/orm-service.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { expectedAllTestItems } from '../test/orm/test-expected-data';
88
import { ITypeOrmConnection } from 'dist/ionic-typeorm/lib';
99
import { castTestItem } from '../test/orm/test-interfaces';
1010
import { IsNull, MoreThan, Not } from 'typeorm';
11+
import { SEED_DATA } from '../test/orm/test-seed-data';
1112

1213
describe('OrmService', () => {
1314
let service: TestItemService;
@@ -17,7 +18,7 @@ describe('OrmService', () => {
1718

1819
beforeAll(async () => {
1920
conn = getTypeOrmConnection('test-app-db', TYPE_ORM_TEST_ENTITIES, TYPE_ORM_TEST_MIGRATIONS);
20-
utils = new TypeOrmTestUtils(conn, 'orm/fixtures/');
21+
utils = new TypeOrmTestUtils(conn, SEED_DATA);
2122
await utils.openDbConnection(['warn', 'error']); // , 'query', 'schema', 'all']);
2223
});
2324

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './type-orm-test-utils';

projects/ionic-typeorm/src/lib/test/orm/fixtures/testitem.json

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const SEED_DATA = {
2+
testitem: {
3+
items: [
4+
{
5+
name: 'Jack Smith',
6+
age: 34,
7+
phoneNumber: null,
8+
},
9+
{
10+
name: 'Jack MacDonald',
11+
age: 51,
12+
phoneNumber: '012345678910',
13+
},
14+
{
15+
name: 'James Bond',
16+
age: 25,
17+
phoneNumber: '007',
18+
},
19+
],
20+
},
21+
};

projects/ionic-typeorm/src/lib/test/type-orm-test-utils.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { IOrmDatabaseEntity, OrmDatabaseService } from '../services/orm-database.service';
21
import { ITypeOrmConnection } from '../connection';
2+
import { IOrmDatabaseEntity, OrmDatabaseService } from '../services';
33

44
/**
55
* This class is used to support TypeORM database testing
@@ -13,7 +13,7 @@ export class TypeOrmTestUtils {
1313
/**
1414
* Creates an instance of TestUtils
1515
*/
16-
constructor(conn: ITypeOrmConnection, private fixtureDir = 'fixtures/') {
16+
constructor(conn: ITypeOrmConnection, private fixtureData: { [key: string]: { items: any[] } }) {
1717
this.databaseService = new OrmDatabaseService(conn);
1818
}
1919

@@ -87,19 +87,13 @@ export class TypeOrmTestUtils {
8787
}
8888

8989
private async getEntityMockData(name: string): Promise<{ items: any[] }> {
90-
let data: { default: { items: any[] } } = { default: { items: [] } };
91-
const fixtureFile = this.fixtureDir + `${name.toLowerCase()}.json`;
90+
let data: { items: any[] } = { items: [] };
9291
try {
93-
data = await this.loadMockData(fixtureFile);
92+
data = this.fixtureData[name.toLowerCase()];
9493
} catch (e) {
95-
console.warn('Fixture not loaded: ' + fixtureFile);
94+
console.warn('Fixture not loaded: ' + name.toLowerCase());
9695
// If no data, do nothing
9796
}
98-
return data.default;
99-
}
100-
101-
private async loadMockData(filename: string): Promise<any> {
102-
const json = await import('./' + filename);
103-
return json;
97+
return data;
10498
}
10599
}

0 commit comments

Comments
 (0)