@feathersjs/generators 5.0.0-pre.37 → 5.0.0
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/CHANGELOG.md +13 -0
- package/README.md +0 -1
- package/lib/app/index.d.ts +38 -5
- package/lib/app/index.js +11 -21
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +18 -41
- package/lib/app/templates/app.tpl.js +10 -9
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +12 -9
- package/lib/app/templates/channels.tpl.js +1 -6
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +7 -9
- package/lib/app/templates/client.test.tpl.js +1 -1
- package/lib/app/templates/client.test.tpl.js.map +1 -1
- package/lib/app/templates/client.test.tpl.ts +4 -2
- package/lib/app/templates/client.tpl.js +1 -1
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +7 -4
- package/lib/app/templates/configuration.tpl.js +7 -4
- package/lib/app/templates/configuration.tpl.js.map +1 -1
- package/lib/app/templates/configuration.tpl.ts +14 -8
- package/lib/app/templates/declarations.tpl.js +4 -2
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +7 -2
- package/lib/app/templates/package.json.tpl.js +9 -3
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +9 -2
- package/lib/authentication/index.d.ts +3 -38
- package/lib/authentication/index.js +8 -23
- package/lib/authentication/index.js.map +1 -1
- package/lib/authentication/index.ts +58 -75
- package/lib/authentication/templates/authentication.tpl.js +4 -4
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +2 -1
- package/lib/authentication/templates/client.test.tpl.js +5 -5
- package/lib/authentication/templates/client.test.tpl.js.map +1 -1
- package/lib/authentication/templates/client.test.tpl.ts +11 -7
- package/lib/commons.d.ts +19 -3
- package/lib/commons.js +19 -1
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +24 -3
- package/lib/connection/index.d.ts +3 -20
- package/lib/connection/index.js +13 -10
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +58 -50
- package/lib/connection/templates/knex.tpl.js +10 -1
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -0
- package/lib/connection/templates/mongodb.tpl.js +8 -8
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +11 -9
- package/lib/service/index.d.ts +4 -0
- package/lib/service/index.js +82 -73
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +94 -74
- package/lib/service/templates/client.tpl.js +1 -3
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +7 -5
- package/lib/service/templates/schema.json.tpl.js +43 -22
- package/lib/service/templates/schema.json.tpl.js.map +1 -1
- package/lib/service/templates/schema.json.tpl.ts +56 -22
- package/lib/service/templates/schema.typebox.tpl.js +46 -11
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/service/templates/schema.typebox.tpl.ts +63 -11
- package/lib/service/templates/service.tpl.d.ts +1 -1
- package/lib/service/templates/service.tpl.js +6 -2
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +11 -2
- package/lib/service/templates/shared.tpl.js +2 -2
- package/lib/service/templates/shared.tpl.js.map +1 -1
- package/lib/service/templates/shared.tpl.ts +13 -10
- package/lib/service/type/custom.tpl.js +1 -1
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +1 -1
- package/lib/service/type/knex.tpl.js +13 -3
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +19 -3
- package/lib/service/type/mongodb.tpl.js +1 -1
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +1 -1
- package/package.json +24 -24
- package/lib/authentication/templates/knex.tpl.d.ts +0 -2
- package/lib/authentication/templates/knex.tpl.js +0 -37
- package/lib/authentication/templates/knex.tpl.js.map +0 -1
- package/lib/authentication/templates/knex.tpl.ts +0 -56
- package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
- package/lib/authentication/templates/schema.json.tpl.js +0 -109
- package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.json.tpl.ts +0 -132
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
- package/lib/authentication/templates/schema.typebox.tpl.js +0 -87
- package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +0 -109
package/lib/commons.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.yyyymmddhhmmss = exports.fileExists = exports.injectSource = exports.renderSource = exports.prettify = exports.PRETTIERRC = exports.getJavaScript = exports.checkPreconditions = exports.initializeBaseContext = exports.addVersions = exports.getDatabaseAdapter = exports.version = void 0;
|
|
29
|
+
exports.oauthTemplate = exports.localTemplate = exports.yyyymmddhhmmss = exports.fileExists = exports.injectSource = exports.renderSource = exports.prettify = exports.PRETTIERRC = exports.getJavaScript = exports.checkPreconditions = exports.initializeBaseContext = exports.addVersions = exports.getDatabaseAdapter = exports.DATABASE_TYPES = exports.version = void 0;
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const path_1 = require("path");
|
|
32
32
|
const promises_1 = require("fs/promises");
|
|
@@ -35,6 +35,7 @@ const ts = __importStar(require("typescript"));
|
|
|
35
35
|
const prettier_1 = __importDefault(require("prettier"));
|
|
36
36
|
const path_2 = __importDefault(require("path"));
|
|
37
37
|
exports.version = JSON.parse(fs_1.default.readFileSync((0, path_1.join)(__dirname, '..', 'package.json')).toString()).version;
|
|
38
|
+
exports.DATABASE_TYPES = ['mongodb', 'mysql', 'postgresql', 'sqlite', 'mssql', 'other'];
|
|
38
39
|
/**
|
|
39
40
|
* Returns the name of the Feathers database adapter for a supported database type
|
|
40
41
|
*
|
|
@@ -209,4 +210,21 @@ const yyyymmddhhmmss = (offset = 0) => {
|
|
|
209
210
|
now.getUTCSeconds().toString().padStart(2, '0'));
|
|
210
211
|
};
|
|
211
212
|
exports.yyyymmddhhmmss = yyyymmddhhmmss;
|
|
213
|
+
/**
|
|
214
|
+
* Render a template if `local` authentication strategy has been selected
|
|
215
|
+
* @param authStrategies The list of selected authentication strategies
|
|
216
|
+
* @param content The content to render if `local` is selected
|
|
217
|
+
* @param alt The content to render if `local` is not selected
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
const localTemplate = (authStrategies, content, alt = '') => authStrategies.includes('local') ? content : alt;
|
|
221
|
+
exports.localTemplate = localTemplate;
|
|
222
|
+
/**
|
|
223
|
+
* Render a template if an `oauth` authentication strategy has been selected
|
|
224
|
+
* @param authStrategies
|
|
225
|
+
* @param content
|
|
226
|
+
* @returns
|
|
227
|
+
*/
|
|
228
|
+
const oauthTemplate = (authStrategies, content) => authStrategies.filter((s) => s !== 'local').length > 0 ? content : '';
|
|
229
|
+
exports.oauthTemplate = oauthTemplate;
|
|
212
230
|
//# sourceMappingURL=commons.js.map
|
package/lib/commons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commons.js","sourceRoot":"","sources":["../src/commons.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,+BAA2B;AAE3B,0CAAiD;AACjD,+CAS2B;AAC3B,+CAAgC;AAChC,wDAA+D;AAC/D,gDAAuB;AAER,eAAO,GAAK,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC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ions = { [key: string]: string }
|
|
22
22
|
|
|
23
|
+
export const DATABASE_TYPES = ['mongodb', 'mysql', 'postgresql', 'sqlite', 'mssql', 'other'] as const
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* The database types supported by this generator
|
|
25
27
|
*/
|
|
26
|
-
export type DatabaseType =
|
|
28
|
+
export type DatabaseType = (typeof DATABASE_TYPES)[number]
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* Returns the name of the Feathers database adapter for a supported database type
|
|
@@ -45,7 +47,7 @@ export type FeathersAppInfo = {
|
|
|
45
47
|
/**
|
|
46
48
|
* The package manager used
|
|
47
49
|
*/
|
|
48
|
-
packager: 'yarn' | 'npm'
|
|
50
|
+
packager: 'yarn' | 'npm' | 'pnpm'
|
|
49
51
|
/**
|
|
50
52
|
* A list of all chosen transports
|
|
51
53
|
*/
|
|
@@ -57,7 +59,7 @@ export type FeathersAppInfo = {
|
|
|
57
59
|
/**
|
|
58
60
|
* The main schema definition format
|
|
59
61
|
*/
|
|
60
|
-
schema: 'typebox' | 'json'
|
|
62
|
+
schema: 'typebox' | 'json' | false
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
export interface AppPackageJson extends PackageJson {
|
|
@@ -299,3 +301,22 @@ export const yyyymmddhhmmss = (offset = 0) => {
|
|
|
299
301
|
now.getUTCSeconds().toString().padStart(2, '0')
|
|
300
302
|
)
|
|
301
303
|
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Render a template if `local` authentication strategy has been selected
|
|
307
|
+
* @param authStrategies The list of selected authentication strategies
|
|
308
|
+
* @param content The content to render if `local` is selected
|
|
309
|
+
* @param alt The content to render if `local` is not selected
|
|
310
|
+
* @returns
|
|
311
|
+
*/
|
|
312
|
+
export const localTemplate = (authStrategies: string[], content: string, alt = '') =>
|
|
313
|
+
authStrategies.includes('local') ? content : alt
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Render a template if an `oauth` authentication strategy has been selected
|
|
317
|
+
* @param authStrategies
|
|
318
|
+
* @param content
|
|
319
|
+
* @returns
|
|
320
|
+
*/
|
|
321
|
+
export const oauthTemplate = (authStrategies: string[], content: string) =>
|
|
322
|
+
authStrategies.filter((s) => s !== 'local').length > 0 ? content : ''
|
|
@@ -21,12 +21,9 @@ export declare const prompts: ({ database, connectionString, pkg, name }: Connec
|
|
|
21
21
|
} | {
|
|
22
22
|
name: string;
|
|
23
23
|
type: string;
|
|
24
|
-
when: boolean;
|
|
24
|
+
when: (answers: ConnectionGeneratorContext) => boolean;
|
|
25
25
|
message: string;
|
|
26
|
-
default: (answers:
|
|
27
|
-
name?: string;
|
|
28
|
-
database: DatabaseType;
|
|
29
|
-
}) => string;
|
|
26
|
+
default: (answers: ConnectionGeneratorContext) => string;
|
|
30
27
|
suffix?: undefined;
|
|
31
28
|
choices?: undefined;
|
|
32
29
|
})[];
|
|
@@ -38,18 +35,4 @@ export declare const DATABASE_CLIENTS: {
|
|
|
38
35
|
mssql: string;
|
|
39
36
|
};
|
|
40
37
|
export declare const getDatabaseClient: (database: DatabaseType) => string;
|
|
41
|
-
export declare const generate: (ctx: ConnectionGeneratorArguments) => Promise<
|
|
42
|
-
dependencies: string[];
|
|
43
|
-
name?: string;
|
|
44
|
-
database: DatabaseType;
|
|
45
|
-
connectionString: string;
|
|
46
|
-
feathers: import("../commons").FeathersAppInfo;
|
|
47
|
-
pkg: import("../commons").AppPackageJson;
|
|
48
|
-
lib: string;
|
|
49
|
-
test: string;
|
|
50
|
-
language: "ts" | "js";
|
|
51
|
-
dependencyVersions?: import("../commons").DependencyVersions;
|
|
52
|
-
cwd: string;
|
|
53
|
-
_?: (string | number)[];
|
|
54
|
-
pinion: import("@feathershq/pinion").Configuration;
|
|
55
|
-
}>;
|
|
38
|
+
export declare const generate: (ctx: ConnectionGeneratorArguments) => Promise<ConnectionGeneratorContext>;
|
package/lib/connection/index.js
CHANGED
|
@@ -13,7 +13,8 @@ const defaultConnectionString = (type, name) => {
|
|
|
13
13
|
mysql: `mysql://root:@localhost:3306/${name}`,
|
|
14
14
|
postgresql: `postgres://postgres:@localhost:5432/${name}`,
|
|
15
15
|
sqlite: `${name}.sqlite`,
|
|
16
|
-
mssql: `mssql://root:password@localhost:1433/${name}
|
|
16
|
+
mssql: `mssql://root:password@localhost:1433/${name}`,
|
|
17
|
+
other: ''
|
|
17
18
|
};
|
|
18
19
|
return connectionStrings[type];
|
|
19
20
|
};
|
|
@@ -24,19 +25,23 @@ const prompts = ({ database, connectionString, pkg, name }) => [
|
|
|
24
25
|
type: 'list',
|
|
25
26
|
when: !database,
|
|
26
27
|
message: 'Which database are you connecting to?',
|
|
27
|
-
suffix: chalk_1.default.grey('
|
|
28
|
+
suffix: chalk_1.default.grey(' Databases can be added at any time'),
|
|
28
29
|
choices: [
|
|
29
30
|
{ value: 'sqlite', name: 'SQLite' },
|
|
30
31
|
{ value: 'mongodb', name: 'MongoDB' },
|
|
31
32
|
{ value: 'postgresql', name: 'PostgreSQL' },
|
|
32
33
|
{ value: 'mysql', name: 'MySQL/MariaDB' },
|
|
33
|
-
{ value: 'mssql', name: 'Microsoft SQL' }
|
|
34
|
+
{ value: 'mssql', name: 'Microsoft SQL' },
|
|
35
|
+
{
|
|
36
|
+
value: 'other',
|
|
37
|
+
name: `Another database ${chalk_1.default.grey('(not configured automatically, use with custom services)')}`
|
|
38
|
+
}
|
|
34
39
|
]
|
|
35
40
|
},
|
|
36
41
|
{
|
|
37
42
|
name: 'connectionString',
|
|
38
43
|
type: 'input',
|
|
39
|
-
when: !connectionString,
|
|
44
|
+
when: (answers) => !connectionString && database !== 'other' && answers.database !== 'other',
|
|
40
45
|
message: 'Enter your database connection string',
|
|
41
46
|
default: (answers) => (0, exports.defaultConnectionString)(answers.database, answers.name || name || pkg.name)
|
|
42
47
|
}
|
|
@@ -49,14 +54,13 @@ exports.DATABASE_CLIENTS = {
|
|
|
49
54
|
mysql: 'mysql',
|
|
50
55
|
mssql: 'mssql'
|
|
51
56
|
};
|
|
52
|
-
const getDatabaseClient = (database) => exports.DATABASE_CLIENTS[database];
|
|
57
|
+
const getDatabaseClient = (database) => database === 'other' ? null : exports.DATABASE_CLIENTS[database];
|
|
53
58
|
exports.getDatabaseClient = getDatabaseClient;
|
|
54
59
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
55
60
|
.then((0, commons_1.initializeBaseContext)())
|
|
56
61
|
.then((0, commons_1.checkPreconditions)())
|
|
57
62
|
.then((0, pinion_1.prompt)(exports.prompts))
|
|
58
|
-
.then((0, pinion_1.runGenerator)(__dirname, 'templates', ({ database }) => `${(0, commons_1.getDatabaseAdapter)(database)}.tpl`))
|
|
59
|
-
.then((0, pinion_1.mergeJSON)(({ connectionString, database }) => (0, commons_1.getDatabaseAdapter)(database) === 'knex'
|
|
63
|
+
.then((0, pinion_1.when)((ctx) => ctx.database !== 'other', (0, pinion_1.runGenerator)(__dirname, 'templates', ({ database }) => `${(0, commons_1.getDatabaseAdapter)(database)}.tpl`), (0, pinion_1.mergeJSON)(({ connectionString, database }) => (0, commons_1.getDatabaseAdapter)(database) === 'knex'
|
|
60
64
|
? {
|
|
61
65
|
[database]: {
|
|
62
66
|
client: (0, exports.getDatabaseClient)(database),
|
|
@@ -66,8 +70,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
66
70
|
}
|
|
67
71
|
: {
|
|
68
72
|
[database]: connectionString
|
|
69
|
-
}, (0, pinion_1.toFile)('config', 'default.json')))
|
|
70
|
-
.then((ctx) => {
|
|
73
|
+
}, (0, pinion_1.toFile)('config', 'default.json')), async (ctx) => {
|
|
71
74
|
const dependencies = [];
|
|
72
75
|
const adapter = (0, commons_1.getDatabaseAdapter)(ctx.database);
|
|
73
76
|
const dbClient = (0, exports.getDatabaseClient)(ctx.database);
|
|
@@ -83,6 +86,6 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
83
86
|
};
|
|
84
87
|
}
|
|
85
88
|
return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
|
|
86
|
-
});
|
|
89
|
+
}));
|
|
87
90
|
exports.generate = generate;
|
|
88
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAsG;AACtG,kDAAyB;AACzB,wCAOmB;AAYZ,MAAM,uBAAuB,GAAG,CAAC,IAAkB,EAAE,IAAY,EAAE,EAAE;IAC1E,MAAM,iBAAiB,GAAG;QACxB,OAAO,EAAE,6BAA6B,IAAI,EAAE;QAC5C,KAAK,EAAE,gCAAgC,IAAI,EAAE;QAC7C,UAAU,EAAE,uCAAuC,IAAI,EAAE;QACzD,MAAM,EAAE,GAAG,IAAI,SAAS;QACxB,KAAK,EAAE,wCAAwC,IAAI,EAAE;QACrD,KAAK,EAAE,EAAE;KACV,CAAA;IAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC,CAAA;AAXY,QAAA,uBAAuB,2BAWnC;AAEM,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAgC,EAAE,EAAE,CAAC;IAClG;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,QAAQ;QACf,OAAO,EAAE,uCAAuC;QAChD,MAAM,EAAE,eAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC;QACzD,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;YACnC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI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GAAG,GAAG;YACN,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC;SACrD,CAAA;KACF;IAED,OAAO,IAAA,gBAAO,EACZ,IAAA,qBAAW,EAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjD,KAAK,EACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACtB,CAAC,GAAG,CAAC,CAAA;AACR,CAAC,CACF,CACF,CAAA;AAvDQ,QAAA,QAAQ,YAuDhB"}
|
package/lib/connection/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generator, runGenerator, prompt, install, mergeJSON, toFile } from '@feathershq/pinion'
|
|
1
|
+
import { generator, runGenerator, prompt, install, mergeJSON, toFile, when } from '@feathershq/pinion'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
3
|
import {
|
|
4
4
|
FeathersBaseContext,
|
|
@@ -25,7 +25,8 @@ export const defaultConnectionString = (type: DatabaseType, name: string) => {
|
|
|
25
25
|
mysql: `mysql://root:@localhost:3306/${name}`,
|
|
26
26
|
postgresql: `postgres://postgres:@localhost:5432/${name}`,
|
|
27
27
|
sqlite: `${name}.sqlite`,
|
|
28
|
-
mssql: `mssql://root:password@localhost:1433/${name}
|
|
28
|
+
mssql: `mssql://root:password@localhost:1433/${name}`,
|
|
29
|
+
other: ''
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
return connectionStrings[type]
|
|
@@ -37,21 +38,26 @@ export const prompts = ({ database, connectionString, pkg, name }: ConnectionGen
|
|
|
37
38
|
type: 'list',
|
|
38
39
|
when: !database,
|
|
39
40
|
message: 'Which database are you connecting to?',
|
|
40
|
-
suffix: chalk.grey('
|
|
41
|
+
suffix: chalk.grey(' Databases can be added at any time'),
|
|
41
42
|
choices: [
|
|
42
43
|
{ value: 'sqlite', name: 'SQLite' },
|
|
43
44
|
{ value: 'mongodb', name: 'MongoDB' },
|
|
44
45
|
{ value: 'postgresql', name: 'PostgreSQL' },
|
|
45
46
|
{ value: 'mysql', name: 'MySQL/MariaDB' },
|
|
46
|
-
{ value: 'mssql', name: 'Microsoft SQL' }
|
|
47
|
+
{ value: 'mssql', name: 'Microsoft SQL' },
|
|
48
|
+
{
|
|
49
|
+
value: 'other',
|
|
50
|
+
name: `Another database ${chalk.grey('(not configured automatically, use with custom services)')}`
|
|
51
|
+
}
|
|
47
52
|
]
|
|
48
53
|
},
|
|
49
54
|
{
|
|
50
55
|
name: 'connectionString',
|
|
51
56
|
type: 'input',
|
|
52
|
-
when:
|
|
57
|
+
when: (answers: ConnectionGeneratorContext) =>
|
|
58
|
+
!connectionString && database !== 'other' && answers.database !== 'other',
|
|
53
59
|
message: 'Enter your database connection string',
|
|
54
|
-
default: (answers:
|
|
60
|
+
default: (answers: ConnectionGeneratorContext) =>
|
|
55
61
|
defaultConnectionString(answers.database, answers.name || name || pkg.name)
|
|
56
62
|
}
|
|
57
63
|
]
|
|
@@ -64,7 +70,8 @@ export const DATABASE_CLIENTS = {
|
|
|
64
70
|
mssql: 'mssql'
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
export const getDatabaseClient = (database: DatabaseType) =>
|
|
73
|
+
export const getDatabaseClient = (database: DatabaseType) =>
|
|
74
|
+
database === 'other' ? null : DATABASE_CLIENTS[database]
|
|
68
75
|
|
|
69
76
|
export const generate = (ctx: ConnectionGeneratorArguments) =>
|
|
70
77
|
generator(ctx)
|
|
@@ -72,52 +79,53 @@ export const generate = (ctx: ConnectionGeneratorArguments) =>
|
|
|
72
79
|
.then(checkPreconditions())
|
|
73
80
|
.then(prompt<ConnectionGeneratorArguments, ConnectionGeneratorContext>(prompts))
|
|
74
81
|
.then(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
when<ConnectionGeneratorContext>(
|
|
83
|
+
(ctx) => ctx.database !== 'other',
|
|
84
|
+
runGenerator<ConnectionGeneratorContext>(
|
|
85
|
+
__dirname,
|
|
86
|
+
'templates',
|
|
87
|
+
({ database }) => `${getDatabaseAdapter(database)}.tpl`
|
|
88
|
+
),
|
|
89
|
+
mergeJSON<ConnectionGeneratorContext>(
|
|
90
|
+
({ connectionString, database }) =>
|
|
91
|
+
getDatabaseAdapter(database) === 'knex'
|
|
92
|
+
? {
|
|
93
|
+
[database]: {
|
|
94
|
+
client: getDatabaseClient(database),
|
|
95
|
+
connection: connectionString,
|
|
96
|
+
...(database === 'sqlite' ? { useNullAsDefault: true } : {})
|
|
97
|
+
}
|
|
90
98
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const adapter = getDatabaseAdapter(ctx.database)
|
|
101
|
-
const dbClient = getDatabaseClient(ctx.database)
|
|
99
|
+
: {
|
|
100
|
+
[database]: connectionString
|
|
101
|
+
},
|
|
102
|
+
toFile('config', 'default.json')
|
|
103
|
+
),
|
|
104
|
+
async (ctx: ConnectionGeneratorContext) => {
|
|
105
|
+
const dependencies: string[] = []
|
|
106
|
+
const adapter = getDatabaseAdapter(ctx.database)
|
|
107
|
+
const dbClient = getDatabaseClient(ctx.database)
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
dependencies.push(`@feathersjs/${adapter}`)
|
|
104
110
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
if (adapter === 'knex') {
|
|
112
|
+
dependencies.push('knex')
|
|
113
|
+
}
|
|
108
114
|
|
|
109
|
-
|
|
115
|
+
dependencies.push(dbClient)
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
if (ctx.dependencies) {
|
|
118
|
+
return {
|
|
119
|
+
...ctx,
|
|
120
|
+
dependencies: [...ctx.dependencies, ...dependencies]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
return install<ConnectionGeneratorContext>(
|
|
125
|
+
addVersions(dependencies, ctx.dependencyVersions),
|
|
126
|
+
false,
|
|
127
|
+
ctx.feathers.packager
|
|
128
|
+
)(ctx)
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
)
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.generate = void 0;
|
|
4
7
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
8
|
const commons_1 = require("../../commons");
|
|
9
|
+
const promises_1 = require("fs/promises");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
6
11
|
const template = ({ database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
7
12
|
import knex from 'knex'
|
|
8
13
|
import type { Knex } from 'knex'
|
|
@@ -43,6 +48,10 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
43
48
|
}
|
|
44
49
|
}, (0, pinion_1.toFile)('package.json')))
|
|
45
50
|
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
46
|
-
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile))
|
|
51
|
+
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile))
|
|
52
|
+
.then(async (ctx) => {
|
|
53
|
+
await (0, promises_1.mkdir)(path_1.default.join(ctx.cwd, 'migrations'));
|
|
54
|
+
return ctx;
|
|
55
|
+
});
|
|
47
56
|
exports.generate = generate;
|
|
48
57
|
//# sourceMappingURL=knex.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAyE;AAEzE,2CAA0D;AAC1D,0CAAmC;AACnC,gDAAuB;AAEvB,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACmB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;MAOrC,QAAQ;;;;eAIC,QAAQ;4BACK,QAAQ;;;aAGvB,QAAQ;;CAEpB,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,EAChB,GAAG,EACH,QAAQ,EACR,QAAQ,EACmB,EAAE,EAAE,CAAC,QAAQ,CAAC;yBAClB,GAAG;;;0BAGF,QAAQ;;EAEhC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,yBAAyB;CACxE,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAClE,YAAY,QAAQ,cAAc,QAAQ,GAAG,CAAA;AAC/C,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAAC,iBAAiB,QAAQ,GAAG,CAAA;AAEpG,MAAM,SAAS,GAAG,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAExE,MAAM,QAAQ,GAAG,CAAC,GAA+B,EAAE,EAAE,CAC1D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,UAAU,CAAC,CAAC,CAAC;KAChD,IAAI,CACH,IAAA,kBAAS,EACP;IACE,OAAO,EAAE;QACP,OAAO,EAAE,qBAAqB;QAC9B,cAAc,EAAE,mBAAmB;QACnC,IAAI,EAAE,0DAA0D;KACjE;CACF,EACD,IAAA,eAAM,EAAC,cAAc,CAAC,CACvB,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC;KACnF,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAClB,MAAM,IAAA,gBAAK,EAAC,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAA;IAC7C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC,CAAA;AA1BO,QAAA,QAAQ,YA0Bf"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { generator, toFile, before, mergeJSON } from '@feathershq/pinion'
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
3
|
import { injectSource, renderSource } from '../../commons'
|
|
4
|
+
import { mkdir } from 'fs/promises'
|
|
5
|
+
import path from 'path'
|
|
4
6
|
|
|
5
7
|
const template = ({
|
|
6
8
|
database
|
|
@@ -65,3 +67,7 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
|
65
67
|
)
|
|
66
68
|
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
|
67
69
|
.then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
|
|
70
|
+
.then(async (ctx) => {
|
|
71
|
+
await mkdir(path.join(ctx.cwd, 'migrations'))
|
|
72
|
+
return ctx
|
|
73
|
+
})
|
|
@@ -3,35 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({}) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
6
|
+
const template = ({ database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
7
7
|
import { MongoClient } from 'mongodb'
|
|
8
8
|
import type { Db } from 'mongodb'
|
|
9
9
|
import type { Application } from './declarations'
|
|
10
10
|
|
|
11
11
|
declare module './declarations' {
|
|
12
12
|
interface Configuration {
|
|
13
|
-
|
|
13
|
+
${database}Client: Promise<Db>
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const
|
|
18
|
-
const connection = app.get('
|
|
17
|
+
export const ${database} = (app: Application) => {
|
|
18
|
+
const connection = app.get('${database}') as string
|
|
19
19
|
const database = new URL(connection).pathname.substring(1)
|
|
20
20
|
const mongoClient = MongoClient.connect(connection)
|
|
21
21
|
.then(client => client.db(database))
|
|
22
22
|
|
|
23
|
-
app.set('
|
|
23
|
+
app.set('${database}Client', mongoClient)
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
26
|
const keywordImport = `import { keywordObjectId } from '@feathersjs/mongodb'`;
|
|
27
27
|
const keywordTemplate = `dataValidator.addKeyword(keywordObjectId)
|
|
28
28
|
queryValidator.addKeyword(keywordObjectId)`;
|
|
29
|
-
const importTemplate =
|
|
30
|
-
const configureTemplate =
|
|
29
|
+
const importTemplate = ({ database }) => `import { ${database} } from './${database}'`;
|
|
30
|
+
const configureTemplate = ({ database }) => `app.configure(${database})`;
|
|
31
31
|
const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
|
|
32
32
|
const toValidatorFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'validators']);
|
|
33
33
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
34
|
-
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib,
|
|
34
|
+
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, database }) => [lib, database])))
|
|
35
35
|
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
36
36
|
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile))
|
|
37
37
|
.then((0, commons_1.injectSource)(keywordImport, (0, pinion_1.prepend)(), toValidatorFile))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA+E;AAE/E,2CAA0D;AAE1D,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA+E;AAE/E,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACmB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;MAOrC,QAAQ;;;;eAIC,QAAQ;gCACS,QAAQ;;;;;aAK3B,QAAQ;;CAEpB,CAAA;AAED,MAAM,aAAa,GAAG,uDAAuD,CAAA;AAE7E,MAAM,eAAe,GAAG;2CACmB,CAAA;AAE3C,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAClE,YAAY,QAAQ,cAAc,QAAQ,GAAG,CAAA;AAC/C,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAAC,iBAAiB,QAAQ,GAAG,CAAA;AACpG,MAAM,SAAS,GAAG,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAC/E,MAAM,eAAe,GAAG,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAA;AAErF,MAAM,QAAQ,GAAG,CAAC,GAA+B,EAAE,EAAE,CAC1D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC;KACnF,IAAI,CAAC,IAAA,sBAAY,EAAC,aAAa,EAAE,IAAA,gBAAO,GAAE,EAAE,eAAe,CAAC,CAAC;KAC7D,IAAI,CAAC,IAAA,sBAAY,EAAC,eAAe,EAAE,IAAA,eAAM,GAAE,EAAE,eAAe,CAAC,CAAC,CAAA;AAXtD,QAAA,QAAQ,YAW8C"}
|
|
@@ -2,25 +2,26 @@ import { generator, toFile, before, prepend, append } from '@feathershq/pinion'
|
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
3
|
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const template =
|
|
6
|
-
|
|
5
|
+
const template = ({
|
|
6
|
+
database
|
|
7
|
+
}: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
|
|
7
8
|
import { MongoClient } from 'mongodb'
|
|
8
9
|
import type { Db } from 'mongodb'
|
|
9
10
|
import type { Application } from './declarations'
|
|
10
11
|
|
|
11
12
|
declare module './declarations' {
|
|
12
13
|
interface Configuration {
|
|
13
|
-
|
|
14
|
+
${database}Client: Promise<Db>
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export const
|
|
18
|
-
const connection = app.get('
|
|
18
|
+
export const ${database} = (app: Application) => {
|
|
19
|
+
const connection = app.get('${database}') as string
|
|
19
20
|
const database = new URL(connection).pathname.substring(1)
|
|
20
21
|
const mongoClient = MongoClient.connect(connection)
|
|
21
22
|
.then(client => client.db(database))
|
|
22
23
|
|
|
23
|
-
app.set('
|
|
24
|
+
app.set('${database}Client', mongoClient)
|
|
24
25
|
}
|
|
25
26
|
`
|
|
26
27
|
|
|
@@ -29,8 +30,9 @@ const keywordImport = `import { keywordObjectId } from '@feathersjs/mongodb'`
|
|
|
29
30
|
const keywordTemplate = `dataValidator.addKeyword(keywordObjectId)
|
|
30
31
|
queryValidator.addKeyword(keywordObjectId)`
|
|
31
32
|
|
|
32
|
-
const importTemplate =
|
|
33
|
-
|
|
33
|
+
const importTemplate = ({ database }: ConnectionGeneratorContext) =>
|
|
34
|
+
`import { ${database} } from './${database}'`
|
|
35
|
+
const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})`
|
|
34
36
|
const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
|
|
35
37
|
const toValidatorFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'validators'])
|
|
36
38
|
|
|
@@ -39,7 +41,7 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
|
39
41
|
.then(
|
|
40
42
|
renderSource(
|
|
41
43
|
template,
|
|
42
|
-
toFile<ConnectionGeneratorContext>(({ lib }) => lib,
|
|
44
|
+
toFile<ConnectionGeneratorContext>(({ lib, database }) => [lib, database])
|
|
43
45
|
)
|
|
44
46
|
)
|
|
45
47
|
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
package/lib/service/index.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
56
56
|
* Set to true if this service is for an authentication entity
|
|
57
57
|
*/
|
|
58
58
|
isEntityService?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The authentication strategies (if it is an entity service)
|
|
61
|
+
*/
|
|
62
|
+
authStrategies: string[];
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
65
|
* Parameters the generator is called with
|