@feathersjs/cli 5.0.0-pre.34 → 5.0.0-pre.36

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.
Files changed (173) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +1 -1
  3. package/README.md +1 -1
  4. package/lib/index.d.ts +6 -2
  5. package/lib/index.js +59 -2
  6. package/lib/index.js.map +1 -1
  7. package/package.json +28 -30
  8. package/lib/app/index.d.ts +0 -29
  9. package/lib/app/index.js +0 -146
  10. package/lib/app/index.js.map +0 -1
  11. package/lib/app/index.ts +0 -228
  12. package/lib/app/static/.gitignore +0 -121
  13. package/lib/app/templates/app.test.tpl.d.ts +0 -2
  14. package/lib/app/templates/app.test.tpl.js +0 -49
  15. package/lib/app/templates/app.test.tpl.js.map +0 -1
  16. package/lib/app/templates/app.test.tpl.ts +0 -50
  17. package/lib/app/templates/app.tpl.d.ts +0 -2
  18. package/lib/app/templates/app.tpl.js +0 -123
  19. package/lib/app/templates/app.tpl.js.map +0 -1
  20. package/lib/app/templates/app.tpl.ts +0 -138
  21. package/lib/app/templates/channels.tpl.d.ts +0 -2
  22. package/lib/app/templates/channels.tpl.js +0 -49
  23. package/lib/app/templates/channels.tpl.js.map +0 -1
  24. package/lib/app/templates/channels.tpl.ts +0 -55
  25. package/lib/app/templates/client.test.tpl.d.ts +0 -2
  26. package/lib/app/templates/client.test.tpl.js +0 -27
  27. package/lib/app/templates/client.test.tpl.js.map +0 -1
  28. package/lib/app/templates/client.test.tpl.ts +0 -26
  29. package/lib/app/templates/client.tpl.d.ts +0 -2
  30. package/lib/app/templates/client.tpl.js +0 -38
  31. package/lib/app/templates/client.tpl.js.map +0 -1
  32. package/lib/app/templates/client.tpl.ts +0 -45
  33. package/lib/app/templates/configuration.tpl.d.ts +0 -2
  34. package/lib/app/templates/configuration.tpl.js +0 -71
  35. package/lib/app/templates/configuration.tpl.js.map +0 -1
  36. package/lib/app/templates/configuration.tpl.ts +0 -82
  37. package/lib/app/templates/declarations.tpl.d.ts +0 -2
  38. package/lib/app/templates/declarations.tpl.js +0 -28
  39. package/lib/app/templates/declarations.tpl.js.map +0 -1
  40. package/lib/app/templates/declarations.tpl.ts +0 -37
  41. package/lib/app/templates/index.html.tpl.d.ts +0 -2
  42. package/lib/app/templates/index.html.tpl.js +0 -45
  43. package/lib/app/templates/index.html.tpl.js.map +0 -1
  44. package/lib/app/templates/index.html.tpl.ts +0 -44
  45. package/lib/app/templates/index.tpl.d.ts +0 -2
  46. package/lib/app/templates/index.tpl.js +0 -18
  47. package/lib/app/templates/index.tpl.js.map +0 -1
  48. package/lib/app/templates/index.tpl.ts +0 -22
  49. package/lib/app/templates/logger.tpl.d.ts +0 -3
  50. package/lib/app/templates/logger.tpl.js +0 -45
  51. package/lib/app/templates/logger.tpl.js.map +0 -1
  52. package/lib/app/templates/logger.tpl.ts +0 -56
  53. package/lib/app/templates/package.json.tpl.d.ts +0 -2
  54. package/lib/app/templates/package.json.tpl.js +0 -58
  55. package/lib/app/templates/package.json.tpl.js.map +0 -1
  56. package/lib/app/templates/package.json.tpl.ts +0 -71
  57. package/lib/app/templates/prettierrc.tpl.d.ts +0 -2
  58. package/lib/app/templates/prettierrc.tpl.js +0 -11
  59. package/lib/app/templates/prettierrc.tpl.js.map +0 -1
  60. package/lib/app/templates/prettierrc.tpl.ts +0 -14
  61. package/lib/app/templates/readme.md.tpl.d.ts +0 -2
  62. package/lib/app/templates/readme.md.tpl.js +0 -54
  63. package/lib/app/templates/readme.md.tpl.js.map +0 -1
  64. package/lib/app/templates/readme.md.tpl.ts +0 -57
  65. package/lib/app/templates/services.tpl.d.ts +0 -2
  66. package/lib/app/templates/services.tpl.js +0 -15
  67. package/lib/app/templates/services.tpl.js.map +0 -1
  68. package/lib/app/templates/services.tpl.ts +0 -20
  69. package/lib/app/templates/tsconfig.json.tpl.d.ts +0 -2
  70. package/lib/app/templates/tsconfig.json.tpl.js +0 -22
  71. package/lib/app/templates/tsconfig.json.tpl.js.map +0 -1
  72. package/lib/app/templates/tsconfig.json.tpl.ts +0 -28
  73. package/lib/app/templates/validators.tpl.d.ts +0 -2
  74. package/lib/app/templates/validators.tpl.js +0 -36
  75. package/lib/app/templates/validators.tpl.js.map +0 -1
  76. package/lib/app/templates/validators.tpl.ts +0 -40
  77. package/lib/authentication/index.d.ts +0 -73
  78. package/lib/authentication/index.js +0 -107
  79. package/lib/authentication/index.js.map +0 -1
  80. package/lib/authentication/index.ts +0 -126
  81. package/lib/authentication/templates/authentication.tpl.d.ts +0 -2
  82. package/lib/authentication/templates/authentication.tpl.js +0 -40
  83. package/lib/authentication/templates/authentication.tpl.js.map +0 -1
  84. package/lib/authentication/templates/authentication.tpl.ts +0 -51
  85. package/lib/authentication/templates/client.test.tpl.d.ts +0 -2
  86. package/lib/authentication/templates/client.test.tpl.js +0 -62
  87. package/lib/authentication/templates/client.test.tpl.js.map +0 -1
  88. package/lib/authentication/templates/client.test.tpl.ts +0 -74
  89. package/lib/authentication/templates/config.tpl.d.ts +0 -2
  90. package/lib/authentication/templates/config.tpl.js +0 -50
  91. package/lib/authentication/templates/config.tpl.js.map +0 -1
  92. package/lib/authentication/templates/config.tpl.ts +0 -57
  93. package/lib/authentication/templates/declarations.tpl.d.ts +0 -2
  94. package/lib/authentication/templates/declarations.tpl.js +0 -19
  95. package/lib/authentication/templates/declarations.tpl.js.map +0 -1
  96. package/lib/authentication/templates/declarations.tpl.ts +0 -34
  97. package/lib/authentication/templates/knex.tpl.d.ts +0 -2
  98. package/lib/authentication/templates/knex.tpl.js +0 -45
  99. package/lib/authentication/templates/knex.tpl.js.map +0 -1
  100. package/lib/authentication/templates/knex.tpl.ts +0 -62
  101. package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
  102. package/lib/authentication/templates/schema.json.tpl.js +0 -103
  103. package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
  104. package/lib/authentication/templates/schema.json.tpl.ts +0 -124
  105. package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
  106. package/lib/authentication/templates/schema.typebox.tpl.js +0 -86
  107. package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
  108. package/lib/authentication/templates/schema.typebox.tpl.ts +0 -108
  109. package/lib/cli.d.ts +0 -6
  110. package/lib/cli.js +0 -75
  111. package/lib/cli.js.map +0 -1
  112. package/lib/cli.ts +0 -68
  113. package/lib/commons.d.ts +0 -150
  114. package/lib/commons.js +0 -198
  115. package/lib/commons.js.map +0 -1
  116. package/lib/commons.ts +0 -284
  117. package/lib/connection/index.d.ts +0 -55
  118. package/lib/connection/index.js +0 -88
  119. package/lib/connection/index.js.map +0 -1
  120. package/lib/connection/index.ts +0 -123
  121. package/lib/connection/templates/knex.tpl.d.ts +0 -2
  122. package/lib/connection/templates/knex.tpl.js +0 -48
  123. package/lib/connection/templates/knex.tpl.js.map +0 -1
  124. package/lib/connection/templates/knex.tpl.ts +0 -67
  125. package/lib/connection/templates/mongodb.tpl.d.ts +0 -2
  126. package/lib/connection/templates/mongodb.tpl.js +0 -34
  127. package/lib/connection/templates/mongodb.tpl.js.map +0 -1
  128. package/lib/connection/templates/mongodb.tpl.ts +0 -40
  129. package/lib/hook/index.d.ts +0 -22
  130. package/lib/hook/index.js +0 -43
  131. package/lib/hook/index.js.map +0 -1
  132. package/lib/hook/index.ts +0 -47
  133. package/lib/hook/templates/hook.tpl.d.ts +0 -2
  134. package/lib/hook/templates/hook.tpl.js +0 -22
  135. package/lib/hook/templates/hook.tpl.js.map +0 -1
  136. package/lib/hook/templates/hook.tpl.ts +0 -33
  137. package/lib/index.ts +0 -2
  138. package/lib/service/index.d.ts +0 -64
  139. package/lib/service/index.js +0 -116
  140. package/lib/service/index.js.map +0 -1
  141. package/lib/service/index.ts +0 -191
  142. package/lib/service/templates/client.tpl.d.ts +0 -2
  143. package/lib/service/templates/client.tpl.js +0 -31
  144. package/lib/service/templates/client.tpl.js.map +0 -1
  145. package/lib/service/templates/client.tpl.ts +0 -57
  146. package/lib/service/templates/schema.json.tpl.d.ts +0 -2
  147. package/lib/service/templates/schema.json.tpl.js +0 -83
  148. package/lib/service/templates/schema.json.tpl.js.map +0 -1
  149. package/lib/service/templates/schema.json.tpl.ts +0 -98
  150. package/lib/service/templates/schema.typebox.tpl.d.ts +0 -2
  151. package/lib/service/templates/schema.typebox.tpl.js +0 -61
  152. package/lib/service/templates/schema.typebox.tpl.js.map +0 -1
  153. package/lib/service/templates/schema.typebox.tpl.ts +0 -76
  154. package/lib/service/templates/service.tpl.d.ts +0 -3
  155. package/lib/service/templates/service.tpl.js +0 -112
  156. package/lib/service/templates/service.tpl.js.map +0 -1
  157. package/lib/service/templates/service.tpl.ts +0 -152
  158. package/lib/service/templates/test.tpl.d.ts +0 -2
  159. package/lib/service/templates/test.tpl.js +0 -25
  160. package/lib/service/templates/test.tpl.js.map +0 -1
  161. package/lib/service/templates/test.tpl.ts +0 -33
  162. package/lib/service/type/custom.tpl.d.ts +0 -3
  163. package/lib/service/type/custom.tpl.js +0 -98
  164. package/lib/service/type/custom.tpl.js.map +0 -1
  165. package/lib/service/type/custom.tpl.ts +0 -109
  166. package/lib/service/type/knex.tpl.d.ts +0 -3
  167. package/lib/service/type/knex.tpl.js +0 -71
  168. package/lib/service/type/knex.tpl.js.map +0 -1
  169. package/lib/service/type/knex.tpl.ts +0 -92
  170. package/lib/service/type/mongodb.tpl.d.ts +0 -3
  171. package/lib/service/type/mongodb.tpl.js +0 -50
  172. package/lib/service/type/mongodb.tpl.js.map +0 -1
  173. package/lib/service/type/mongodb.tpl.ts +0 -62
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generate = exports.getDatabaseClient = exports.DATABASE_CLIENTS = exports.prompts = exports.defaultConnectionString = void 0;
7
- const pinion_1 = require("@feathershq/pinion");
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const commons_1 = require("../commons");
10
- const defaultConnectionString = (type, name) => {
11
- const connectionStrings = {
12
- mongodb: `mongodb://127.0.0.1:27017/${name}`,
13
- mysql: `mysql://root:@localhost:3306/${name}`,
14
- postgresql: `postgres://postgres:@localhost:5432/${name}`,
15
- sqlite: `${name}.sqlite`,
16
- mssql: `mssql://root:password@localhost:1433/${name}`
17
- };
18
- return connectionStrings[type];
19
- };
20
- exports.defaultConnectionString = defaultConnectionString;
21
- const prompts = ({ database, connectionString, pkg, name }) => [
22
- {
23
- name: 'database',
24
- type: 'list',
25
- when: !database,
26
- message: 'Which database are you connecting to?',
27
- suffix: chalk_1.default.grey(' Other databases can be added at any time'),
28
- choices: [
29
- { value: 'sqlite', name: 'SQLite' },
30
- { value: 'mongodb', name: 'MongoDB' },
31
- { value: 'postgresql', name: 'PostgreSQL' },
32
- { value: 'mysql', name: 'MySQL/MariaDB' },
33
- { value: 'mssql', name: 'Microsoft SQL' }
34
- ]
35
- },
36
- {
37
- name: 'connectionString',
38
- type: 'input',
39
- when: !connectionString,
40
- message: 'Enter your database connection string',
41
- default: (answers) => (0, exports.defaultConnectionString)(answers.database, answers.name || name || pkg.name)
42
- }
43
- ];
44
- exports.prompts = prompts;
45
- exports.DATABASE_CLIENTS = {
46
- mongodb: 'mongodb',
47
- sqlite: 'sqlite3',
48
- postgresql: 'pg',
49
- mysql: 'mysql',
50
- mssql: 'mssql'
51
- };
52
- const getDatabaseClient = (database) => exports.DATABASE_CLIENTS[database];
53
- exports.getDatabaseClient = getDatabaseClient;
54
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
55
- .then((0, commons_1.initializeBaseContext)())
56
- .then((0, commons_1.checkPreconditions)())
57
- .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'
60
- ? {
61
- [database]: {
62
- client: (0, exports.getDatabaseClient)(database),
63
- connection: connectionString,
64
- ...(database === 'sqlite' ? { useNullAsDefault: true } : {})
65
- }
66
- }
67
- : {
68
- [database]: connectionString
69
- }, (0, pinion_1.toFile)('config', 'default.json')))
70
- .then((ctx) => {
71
- const dependencies = [];
72
- const adapter = (0, commons_1.getDatabaseAdapter)(ctx.database);
73
- const dbClient = (0, exports.getDatabaseClient)(ctx.database);
74
- dependencies.push(`@feathersjs/${adapter}`);
75
- if (adapter === 'knex') {
76
- dependencies.push('knex');
77
- }
78
- dependencies.push(dbClient);
79
- if (ctx.dependencies) {
80
- return {
81
- ...ctx,
82
- dependencies: [...ctx.dependencies, ...dependencies]
83
- };
84
- }
85
- return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
86
- });
87
- exports.generate = generate;
88
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":"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"}
@@ -1,123 +0,0 @@
1
- import { generator, runGenerator, prompt, install, mergeJSON, toFile } from '@feathershq/pinion'
2
- import chalk from 'chalk'
3
- import {
4
- FeathersBaseContext,
5
- DatabaseType,
6
- getDatabaseAdapter,
7
- addVersions,
8
- checkPreconditions,
9
- initializeBaseContext
10
- } from '../commons'
11
-
12
- export interface ConnectionGeneratorContext extends FeathersBaseContext {
13
- name?: string
14
- database: DatabaseType
15
- connectionString: string
16
- dependencies: string[]
17
- }
18
-
19
- export type ConnectionGeneratorArguments = FeathersBaseContext &
20
- Partial<Pick<ConnectionGeneratorContext, 'database' | 'connectionString' | 'name'>>
21
-
22
- export const defaultConnectionString = (type: DatabaseType, name: string) => {
23
- const connectionStrings = {
24
- mongodb: `mongodb://127.0.0.1:27017/${name}`,
25
- mysql: `mysql://root:@localhost:3306/${name}`,
26
- postgresql: `postgres://postgres:@localhost:5432/${name}`,
27
- sqlite: `${name}.sqlite`,
28
- mssql: `mssql://root:password@localhost:1433/${name}`
29
- }
30
-
31
- return connectionStrings[type]
32
- }
33
-
34
- export const prompts = ({ database, connectionString, pkg, name }: ConnectionGeneratorArguments) => [
35
- {
36
- name: 'database',
37
- type: 'list',
38
- when: !database,
39
- message: 'Which database are you connecting to?',
40
- suffix: chalk.grey(' Other databases can be added at any time'),
41
- choices: [
42
- { value: 'sqlite', name: 'SQLite' },
43
- { value: 'mongodb', name: 'MongoDB' },
44
- { value: 'postgresql', name: 'PostgreSQL' },
45
- { value: 'mysql', name: 'MySQL/MariaDB' },
46
- { value: 'mssql', name: 'Microsoft SQL' }
47
- ]
48
- },
49
- {
50
- name: 'connectionString',
51
- type: 'input',
52
- when: !connectionString,
53
- message: 'Enter your database connection string',
54
- default: (answers: { name?: string; database: DatabaseType }) =>
55
- defaultConnectionString(answers.database, answers.name || name || pkg.name)
56
- }
57
- ]
58
-
59
- export const DATABASE_CLIENTS = {
60
- mongodb: 'mongodb',
61
- sqlite: 'sqlite3',
62
- postgresql: 'pg',
63
- mysql: 'mysql',
64
- mssql: 'mssql'
65
- }
66
-
67
- export const getDatabaseClient = (database: DatabaseType) => DATABASE_CLIENTS[database]
68
-
69
- export const generate = (ctx: ConnectionGeneratorArguments) =>
70
- generator(ctx)
71
- .then(initializeBaseContext())
72
- .then(checkPreconditions())
73
- .then(prompt<ConnectionGeneratorArguments, ConnectionGeneratorContext>(prompts))
74
- .then(
75
- runGenerator<ConnectionGeneratorContext>(
76
- __dirname,
77
- 'templates',
78
- ({ database }) => `${getDatabaseAdapter(database)}.tpl`
79
- )
80
- )
81
- .then(
82
- mergeJSON<ConnectionGeneratorContext>(
83
- ({ connectionString, database }) =>
84
- getDatabaseAdapter(database) === 'knex'
85
- ? {
86
- [database]: {
87
- client: getDatabaseClient(database),
88
- connection: connectionString,
89
- ...(database === 'sqlite' ? { useNullAsDefault: true } : {})
90
- }
91
- }
92
- : {
93
- [database]: connectionString
94
- },
95
- toFile('config', 'default.json')
96
- )
97
- )
98
- .then((ctx: ConnectionGeneratorContext) => {
99
- const dependencies: string[] = []
100
- const adapter = getDatabaseAdapter(ctx.database)
101
- const dbClient = getDatabaseClient(ctx.database)
102
-
103
- dependencies.push(`@feathersjs/${adapter}`)
104
-
105
- if (adapter === 'knex') {
106
- dependencies.push('knex')
107
- }
108
-
109
- dependencies.push(dbClient)
110
-
111
- if (ctx.dependencies) {
112
- return {
113
- ...ctx,
114
- dependencies: [...ctx.dependencies, ...dependencies]
115
- }
116
- }
117
-
118
- return install<ConnectionGeneratorContext>(
119
- addVersions(dependencies, ctx.dependencyVersions),
120
- false,
121
- ctx.feathers.packager
122
- )(ctx)
123
- })
@@ -1,2 +0,0 @@
1
- import { ConnectionGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ConnectionGeneratorContext) => Promise<ConnectionGeneratorContext>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const template = ({ database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
7
- import knex from 'knex'
8
- import type { Knex } from 'knex'
9
- import type { Application } from './declarations'
10
-
11
- declare module './declarations' {
12
- interface Configuration {
13
- ${database}Client: Knex
14
- }
15
- }
16
-
17
- export const ${database} = (app: Application) => {
18
- const config = app.get('${database}')
19
- const db = knex(config!)
20
-
21
- app.set('${database}Client', db)
22
- }
23
- `;
24
- const knexfile = ({ lib, language, database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
25
- import { app } from './${lib}/app'
26
-
27
- // Load our database connection info from the app configuration
28
- const config = app.get('${database}')
29
-
30
- ${language === 'js' ? 'export default config' : 'module.exports = config'}
31
- `;
32
- const importTemplate = ({ database }) => `import { ${database} } from './${database}'`;
33
- const configureTemplate = ({ database }) => `app.configure(${database})`;
34
- const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
35
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
36
- .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, database }) => [lib, database])))
37
- .then((0, commons_1.renderSource)(knexfile, (0, pinion_1.toFile)('knexfile')))
38
- .then((0, pinion_1.mergeJSON)({
39
- scripts: {
40
- migrate: 'knex migrate:latest',
41
- 'migrate:make': 'knex migrate:make',
42
- test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha'
43
- }
44
- }, (0, pinion_1.toFile)('package.json')))
45
- .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));
47
- exports.generate = generate;
48
- //# sourceMappingURL=knex.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAEzE,2CAA0D;AAE1D,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,CAAA;AAtB3E,QAAA,QAAQ,YAsBmE"}
@@ -1,67 +0,0 @@
1
- import { generator, toFile, before, mergeJSON } from '@feathershq/pinion'
2
- import { ConnectionGeneratorContext } from '../index'
3
- import { injectSource, renderSource } from '../../commons'
4
-
5
- const template = ({
6
- database
7
- }: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
8
- import knex from 'knex'
9
- import type { Knex } from 'knex'
10
- import type { Application } from './declarations'
11
-
12
- declare module './declarations' {
13
- interface Configuration {
14
- ${database}Client: Knex
15
- }
16
- }
17
-
18
- export const ${database} = (app: Application) => {
19
- const config = app.get('${database}')
20
- const db = knex(config!)
21
-
22
- app.set('${database}Client', db)
23
- }
24
- `
25
-
26
- const knexfile = ({
27
- lib,
28
- language,
29
- database
30
- }: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
31
- import { app } from './${lib}/app'
32
-
33
- // Load our database connection info from the app configuration
34
- const config = app.get('${database}')
35
-
36
- ${language === 'js' ? 'export default config' : 'module.exports = config'}
37
- `
38
-
39
- const importTemplate = ({ database }: ConnectionGeneratorContext) =>
40
- `import { ${database} } from './${database}'`
41
- const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})`
42
-
43
- const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
44
-
45
- export const generate = (ctx: ConnectionGeneratorContext) =>
46
- generator(ctx)
47
- .then(
48
- renderSource(
49
- template,
50
- toFile<ConnectionGeneratorContext>(({ lib, database }) => [lib, database])
51
- )
52
- )
53
- .then(renderSource(knexfile, toFile('knexfile')))
54
- .then(
55
- mergeJSON<ConnectionGeneratorContext>(
56
- {
57
- scripts: {
58
- migrate: 'knex migrate:latest',
59
- 'migrate:make': 'knex migrate:make',
60
- test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha'
61
- }
62
- },
63
- toFile('package.json')
64
- )
65
- )
66
- .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
67
- .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
@@ -1,2 +0,0 @@
1
- import { ConnectionGeneratorContext } from '../index';
2
- export declare const generate: (ctx: ConnectionGeneratorContext) => Promise<ConnectionGeneratorContext>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
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
7
- import { MongoClient } from 'mongodb'
8
- import type { Db } from 'mongodb'
9
- import type { Application } from './declarations'
10
-
11
- declare module './declarations' {
12
- interface Configuration {
13
- mongodbClient: Promise<Db>
14
- }
15
- }
16
-
17
- export const mongodb = (app: Application) => {
18
- const connection = app.get('mongodb') as string
19
- const database = new URL(connection).pathname.substring(1)
20
- const mongoClient = MongoClient.connect(connection)
21
- .then(client => client.db(database))
22
-
23
- app.set('mongodbClient', mongoClient)
24
- }
25
- `;
26
- const importTemplate = "import { mongodb } from './mongodb'";
27
- const configureTemplate = 'app.configure(mongodb)';
28
- const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
29
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
30
- .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'mongodb')))
31
- .then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
32
- .then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
33
- exports.generate = generate;
34
- //# sourceMappingURL=mongodb.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAE9D,2CAA0D;AAE1D,MAAM,QAAQ,GACZ,CAAC,EAA8B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;CAmB9C,CAAA;AAED,MAAM,cAAc,GAAG,qCAAqC,CAAA;AAC5D,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAClD,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,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAChE,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,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
@@ -1,40 +0,0 @@
1
- import { generator, toFile, before } from '@feathershq/pinion'
2
- import { ConnectionGeneratorContext } from '../index'
3
- import { injectSource, renderSource } from '../../commons'
4
-
5
- const template =
6
- ({}: ConnectionGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
7
- import { MongoClient } from 'mongodb'
8
- import type { Db } from 'mongodb'
9
- import type { Application } from './declarations'
10
-
11
- declare module './declarations' {
12
- interface Configuration {
13
- mongodbClient: Promise<Db>
14
- }
15
- }
16
-
17
- export const mongodb = (app: Application) => {
18
- const connection = app.get('mongodb') as string
19
- const database = new URL(connection).pathname.substring(1)
20
- const mongoClient = MongoClient.connect(connection)
21
- .then(client => client.db(database))
22
-
23
- app.set('mongodbClient', mongoClient)
24
- }
25
- `
26
-
27
- const importTemplate = "import { mongodb } from './mongodb'"
28
- const configureTemplate = 'app.configure(mongodb)'
29
- const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
30
-
31
- export const generate = (ctx: ConnectionGeneratorContext) =>
32
- generator(ctx)
33
- .then(
34
- renderSource(
35
- template,
36
- toFile<ConnectionGeneratorContext>(({ lib }) => lib, 'mongodb')
37
- )
38
- )
39
- .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
40
- .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
@@ -1,22 +0,0 @@
1
- import { FeathersBaseContext } from '../commons';
2
- export interface HookGeneratorContext extends FeathersBaseContext {
3
- name: string;
4
- camelName: string;
5
- kebabName: string;
6
- type: 'regular' | 'around';
7
- }
8
- export declare const generate: (ctx: HookGeneratorContext) => Promise<{
9
- kebabName: string;
10
- camelName: string;
11
- name: string;
12
- type: 'regular' | 'around';
13
- feathers: import("../commons").FeathersAppInfo;
14
- pkg: import("../commons").AppPackageJson;
15
- lib: string;
16
- test: string;
17
- language: "ts" | "js";
18
- dependencyVersions?: import("../commons").DependencyVersions;
19
- cwd: string;
20
- _?: (string | number)[];
21
- pinion: import("@feathershq/pinion").Configuration;
22
- }>;
package/lib/hook/index.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generate = void 0;
7
- const pinion_1 = require("@feathershq/pinion");
8
- const lodash_1 = __importDefault(require("lodash"));
9
- const commons_1 = require("../commons");
10
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
11
- .then((0, commons_1.initializeBaseContext)())
12
- .then((0, commons_1.checkPreconditions)())
13
- .then((0, pinion_1.prompt)(({ type, name }) => [
14
- {
15
- type: 'input',
16
- name: 'name',
17
- message: 'What is the name of the hook?',
18
- when: !name
19
- },
20
- {
21
- name: 'type',
22
- type: 'list',
23
- when: !type,
24
- message: 'What kind of hook is it?',
25
- choices: [
26
- { value: 'around', name: 'Around' },
27
- { value: 'regular', name: 'Before, After or Error' }
28
- ]
29
- }
30
- ]))
31
- .then((ctx) => {
32
- const { name } = ctx;
33
- const kebabName = lodash_1.default.kebabCase(name);
34
- const camelName = lodash_1.default.camelCase(name);
35
- return {
36
- ...ctx,
37
- kebabName,
38
- camelName
39
- };
40
- })
41
- .then((0, pinion_1.runGenerators)(__dirname, 'templates'));
42
- exports.generate = generate;
43
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hook/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAqE;AACrE,oDAAsB;AACtB,wCAA2F;AASpF,MAAM,QAAQ,GAAG,CAAC,GAAyB,EAAE,EAAE,CACpD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAAI,CAAC,IAAA,4BAAkB,GAAE,CAAC;KAC1B,IAAI,CACH,IAAA,eAAM,EAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC/C;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,+BAA+B;QACxC,IAAI,EAAE,CAAC,IAAI;KACZ;IACD;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,IAAI;QACX,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;YACnC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,wBAAwB,EAAE;SACrD;KACF;CACF,CAAC,CACH;KACA,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;IACpB,MAAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAEnC,OAAO;QACL,GAAG,GAAG;QACN,SAAS;QACT,SAAS;KACV,CAAA;AACH,CAAC,CAAC;KACD,IAAI,CAAC,IAAA,sBAAa,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAA;AAnCnC,QAAA,QAAQ,YAmC2B"}
package/lib/hook/index.ts DELETED
@@ -1,47 +0,0 @@
1
- import { generator, prompt, runGenerators } from '@feathershq/pinion'
2
- import _ from 'lodash'
3
- import { checkPreconditions, FeathersBaseContext, initializeBaseContext } from '../commons'
4
-
5
- export interface HookGeneratorContext extends FeathersBaseContext {
6
- name: string
7
- camelName: string
8
- kebabName: string
9
- type: 'regular' | 'around'
10
- }
11
-
12
- export const generate = (ctx: HookGeneratorContext) =>
13
- generator(ctx)
14
- .then(initializeBaseContext())
15
- .then(checkPreconditions())
16
- .then(
17
- prompt<HookGeneratorContext>(({ type, name }) => [
18
- {
19
- type: 'input',
20
- name: 'name',
21
- message: 'What is the name of the hook?',
22
- when: !name
23
- },
24
- {
25
- name: 'type',
26
- type: 'list',
27
- when: !type,
28
- message: 'What kind of hook is it?',
29
- choices: [
30
- { value: 'around', name: 'Around' },
31
- { value: 'regular', name: 'Before, After or Error' }
32
- ]
33
- }
34
- ])
35
- )
36
- .then((ctx) => {
37
- const { name } = ctx
38
- const kebabName = _.kebabCase(name)
39
- const camelName = _.camelCase(name)
40
-
41
- return {
42
- ...ctx,
43
- kebabName,
44
- camelName
45
- }
46
- })
47
- .then(runGenerators(__dirname, 'templates'))
@@ -1,2 +0,0 @@
1
- import { HookGeneratorContext } from '../index';
2
- export declare const generate: (ctx: HookGeneratorContext) => Promise<HookGeneratorContext>;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generate = void 0;
4
- const pinion_1 = require("@feathershq/pinion");
5
- const commons_1 = require("../../commons");
6
- const aroundTemplate = ({ camelName, name }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
7
- import type { HookContext, NextFunction } from '../declarations'
8
-
9
- export const ${camelName} = async (context: HookContext, next: NextFunction) => {
10
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
11
- await next()
12
- }
13
- `;
14
- const regularTemplate = ({ camelName, name }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
15
- import type { HookContext } from '../declarations'
16
-
17
- export const ${camelName} = async (context: HookContext) => {
18
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
19
- }`;
20
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)((ctx) => (ctx.type === 'around' ? aroundTemplate(ctx) : regularTemplate(ctx)), (0, pinion_1.toFile)(({ lib, kebabName }) => [lib, 'hooks', kebabName])));
21
- exports.generate = generate;
22
- //# sourceMappingURL=hook.tpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;eAGtB,SAAS;+BACO,IAAI;;;CAGlC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;eAGtB,SAAS;+BACO,IAAI;EACjC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAAyB,EAAE,EAAE,CACpD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAC7E,IAAA,eAAM,EAAuB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAChF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
@@ -1,33 +0,0 @@
1
- import { generator, toFile } from '@feathershq/pinion'
2
- import { HookGeneratorContext } from '../index'
3
- import { renderSource } from '../../commons'
4
-
5
- const aroundTemplate = ({
6
- camelName,
7
- name
8
- }: HookGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
9
- import type { HookContext, NextFunction } from '../declarations'
10
-
11
- export const ${camelName} = async (context: HookContext, next: NextFunction) => {
12
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
13
- await next()
14
- }
15
- `
16
-
17
- const regularTemplate = ({
18
- camelName,
19
- name
20
- }: HookGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/hook.html
21
- import type { HookContext } from '../declarations'
22
-
23
- export const ${camelName} = async (context: HookContext) => {
24
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
25
- }`
26
-
27
- export const generate = (ctx: HookGeneratorContext) =>
28
- generator(ctx).then(
29
- renderSource(
30
- (ctx) => (ctx.type === 'around' ? aroundTemplate(ctx) : regularTemplate(ctx)),
31
- toFile<HookGeneratorContext>(({ lib, kebabName }) => [lib, 'hooks', kebabName])
32
- )
33
- )
package/lib/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './cli'
2
- export * from './commons'