Skip to content

Commit d4f5b5c

Browse files
feat(cli): change location fixtures service/repository
1 parent 9bafc6d commit d4f5b5c

File tree

10 files changed

+260
-324
lines changed

10 files changed

+260
-324
lines changed

packages/cli/generators/service/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ module.exports = class ServiceGenerator extends ArtifactGenerator {
7777
* Ask for Service Name
7878
*/
7979
async promptArtifactName() {
80-
if (this.shouldExit()) return false;
8180
debug('Prompting for service name');
8281

8382
if (this.options.name) {
@@ -100,8 +99,6 @@ module.exports = class ServiceGenerator extends ArtifactGenerator {
10099
}
101100

102101
async promptDataSourceName() {
103-
if (this.shouldExit()) return false;
104-
105102
debug('Prompting for a datasource ');
106103
let cmdDatasourceName;
107104
let datasourcesList;
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
const DATASOURCE_APP_PATH = 'src/datasources';
2+
const MODEL_APP_PATH = 'src/models';
3+
const CONFIG_PATH = '.';
4+
const DUMMY_CONTENT = '--DUMMY VALUE--';
5+
const fs = require('fs');
6+
7+
exports.SANDBOX_FILES = [
8+
{
9+
path: CONFIG_PATH,
10+
file: 'myconfig.json',
11+
content: JSON.stringify({
12+
datasource: 'dbmem',
13+
model: 'decoratordefined',
14+
}),
15+
},
16+
{
17+
path: DATASOURCE_APP_PATH,
18+
file: 'dbkv.datasource.json',
19+
content: JSON.stringify({
20+
name: 'dbkv',
21+
connector: 'kv-redis',
22+
}),
23+
},
24+
{
25+
path: DATASOURCE_APP_PATH,
26+
file: 'dbkv.datasource.ts',
27+
content: DUMMY_CONTENT,
28+
},
29+
{
30+
path: DATASOURCE_APP_PATH,
31+
file: 'dbmem.datasource.json',
32+
content: JSON.stringify({
33+
name: 'dbmem',
34+
connector: 'memory',
35+
}),
36+
},
37+
{
38+
path: DATASOURCE_APP_PATH,
39+
file: 'dbmem.datasource.ts',
40+
content: DUMMY_CONTENT,
41+
},
42+
{
43+
path: DATASOURCE_APP_PATH,
44+
file: 'restdb.datasource.json',
45+
content: JSON.stringify({
46+
name: 'restdb',
47+
connector: 'rest',
48+
}),
49+
},
50+
{
51+
path: DATASOURCE_APP_PATH,
52+
file: 'restdb.datasource.ts',
53+
content: DUMMY_CONTENT,
54+
},
55+
{
56+
path: MODEL_APP_PATH,
57+
file: 'decoratordefined.model.ts',
58+
content: fs.readFileSync(
59+
require.resolve('./models/decoratordefined.model.txt'),
60+
{
61+
encoding: 'utf-8',
62+
},
63+
),
64+
},
65+
{
66+
path: MODEL_APP_PATH,
67+
file: 'defaultmodel.model.ts',
68+
content: fs.readFileSync(
69+
require.resolve('./models/defaultmodel.model.txt'),
70+
{
71+
encoding: 'utf-8',
72+
},
73+
),
74+
},
75+
{
76+
path: MODEL_APP_PATH,
77+
file: 'multi-word.model.ts',
78+
content: fs.readFileSync(require.resolve('./models/multi-word.model.txt'), {
79+
encoding: 'utf-8',
80+
}),
81+
},
82+
{
83+
path: MODEL_APP_PATH,
84+
file: 'invalid-id.model.ts',
85+
content: fs.readFileSync(require.resolve('./models/invalid-id.model.txt'), {
86+
encoding: 'utf-8',
87+
}),
88+
},
89+
];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {Entity, model} from '@loopback/repository';
2+
3+
@model({
4+
name: 'Product',
5+
properties: {
6+
thePK: {type: 'number', id: true},
7+
name: {type: 'string', required: true},
8+
},
9+
})
10+
export class DecoratorDefined extends Entity {
11+
thePK: number;
12+
name: string;
13+
14+
constructor(data?: Partial<DecoratorDefined>) {
15+
super(data);
16+
}
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Entity, model, property} from '@loopback/repository';
2+
3+
@model()
4+
export class DefaultModel extends Entity {
5+
@property({
6+
type: 'number',
7+
id: true,
8+
default: 0,
9+
})
10+
id?: number;
11+
12+
@property({
13+
type: 'string',
14+
})
15+
desc?: string;
16+
17+
@property({
18+
type: 'number',
19+
default: 0,
20+
})
21+
balance?: number;
22+
23+
constructor(data?: Partial<DefaultModel>) {
24+
super(data);
25+
}
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {Entity, model, property} from '@loopback/repository';
2+
3+
@model()
4+
export class InvalidID extends Entity {
5+
@property({
6+
type: 'string',
7+
required: true,
8+
default: 0,
9+
})
10+
id: string;
11+
12+
@property({
13+
type: 'string',
14+
})
15+
desc?: string;
16+
17+
constructor(data?: Partial<InvalidID>) {
18+
super(data);
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {Entity, model, property} from '@loopback/repository';
2+
3+
@model()
4+
export class MultiWord extends Entity {
5+
@property({
6+
type: 'string',
7+
id: true,
8+
default: 0,
9+
})
10+
pk?: string;
11+
12+
@property({
13+
type: 'string',
14+
})
15+
desc?: string;
16+
17+
constructor(data?: Partial<MultiWord>) {
18+
super(data);
19+
}
20+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const DATASOURCE_APP_PATH = 'src/datasources';
2+
const CONFIG_PATH = '.';
3+
const DUMMY_CONTENT = '--DUMMY VALUE--';
4+
5+
exports.SANDBOX_FILES = [
6+
{
7+
path: CONFIG_PATH,
8+
file: 'mysoapconfig.json',
9+
content: JSON.stringify({
10+
name: 'MultiWordService',
11+
datasource: 'myds',
12+
}),
13+
},
14+
{
15+
path: CONFIG_PATH,
16+
file: 'myrestconfig.json',
17+
content: JSON.stringify({
18+
name: 'myservice',
19+
datasource: 'restdb',
20+
}),
21+
},
22+
{
23+
path: DATASOURCE_APP_PATH,
24+
file: 'myds.datasource.json',
25+
content: JSON.stringify({
26+
name: 'myds',
27+
connector: 'soap',
28+
}),
29+
},
30+
{
31+
path: DATASOURCE_APP_PATH,
32+
file: 'myds.datasource.ts',
33+
content: DUMMY_CONTENT,
34+
},
35+
{
36+
path: DATASOURCE_APP_PATH,
37+
file: 'dbmem.datasource.json',
38+
content: JSON.stringify({
39+
name: 'dbmem',
40+
connector: 'memory',
41+
}),
42+
},
43+
{
44+
path: DATASOURCE_APP_PATH,
45+
file: 'dbmem.datasource.ts',
46+
content: DUMMY_CONTENT,
47+
},
48+
{
49+
path: DATASOURCE_APP_PATH,
50+
file: 'restdb.datasource.json',
51+
content: JSON.stringify({
52+
name: 'restdb',
53+
connector: 'rest',
54+
}),
55+
},
56+
{
57+
path: DATASOURCE_APP_PATH,
58+
file: 'restdb.datasource.ts',
59+
content: DUMMY_CONTENT,
60+
},
61+
];

0 commit comments

Comments
 (0)