@feathersjs/cli 5.0.0-pre.33 → 5.0.0-pre.35

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 (175) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/index.d.ts +6 -2
  3. package/lib/index.js +59 -2
  4. package/lib/index.js.map +1 -1
  5. package/package.json +30 -30
  6. package/lib/app/index.d.ts +0 -29
  7. package/lib/app/index.js +0 -146
  8. package/lib/app/index.js.map +0 -1
  9. package/lib/app/index.ts +0 -227
  10. package/lib/app/static/.gitignore +0 -121
  11. package/lib/app/templates/app.test.tpl.d.ts +0 -2
  12. package/lib/app/templates/app.test.tpl.js +0 -48
  13. package/lib/app/templates/app.test.tpl.js.map +0 -1
  14. package/lib/app/templates/app.test.tpl.ts +0 -47
  15. package/lib/app/templates/app.tpl.d.ts +0 -2
  16. package/lib/app/templates/app.tpl.js +0 -121
  17. package/lib/app/templates/app.tpl.js.map +0 -1
  18. package/lib/app/templates/app.tpl.ts +0 -136
  19. package/lib/app/templates/channels.tpl.d.ts +0 -2
  20. package/lib/app/templates/channels.tpl.js +0 -48
  21. package/lib/app/templates/channels.tpl.js.map +0 -1
  22. package/lib/app/templates/channels.tpl.ts +0 -54
  23. package/lib/app/templates/client.test.tpl.d.ts +0 -2
  24. package/lib/app/templates/client.test.tpl.js +0 -27
  25. package/lib/app/templates/client.test.tpl.js.map +0 -1
  26. package/lib/app/templates/client.test.tpl.ts +0 -26
  27. package/lib/app/templates/client.tpl.d.ts +0 -2
  28. package/lib/app/templates/client.tpl.js +0 -37
  29. package/lib/app/templates/client.tpl.js.map +0 -1
  30. package/lib/app/templates/client.tpl.ts +0 -44
  31. package/lib/app/templates/config.tpl.d.ts +0 -2
  32. package/lib/app/templates/config.tpl.js +0 -30
  33. package/lib/app/templates/config.tpl.js.map +0 -1
  34. package/lib/app/templates/config.tpl.ts +0 -31
  35. package/lib/app/templates/declarations.tpl.d.ts +0 -2
  36. package/lib/app/templates/declarations.tpl.js +0 -27
  37. package/lib/app/templates/declarations.tpl.js.map +0 -1
  38. package/lib/app/templates/declarations.tpl.ts +0 -36
  39. package/lib/app/templates/index.html.tpl.d.ts +0 -2
  40. package/lib/app/templates/index.html.tpl.js +0 -45
  41. package/lib/app/templates/index.html.tpl.js.map +0 -1
  42. package/lib/app/templates/index.html.tpl.ts +0 -44
  43. package/lib/app/templates/index.tpl.d.ts +0 -2
  44. package/lib/app/templates/index.tpl.js +0 -18
  45. package/lib/app/templates/index.tpl.js.map +0 -1
  46. package/lib/app/templates/index.tpl.ts +0 -22
  47. package/lib/app/templates/logger.tpl.d.ts +0 -2
  48. package/lib/app/templates/logger.tpl.js +0 -39
  49. package/lib/app/templates/logger.tpl.js.map +0 -1
  50. package/lib/app/templates/logger.tpl.ts +0 -44
  51. package/lib/app/templates/package.json.tpl.d.ts +0 -2
  52. package/lib/app/templates/package.json.tpl.js +0 -55
  53. package/lib/app/templates/package.json.tpl.js.map +0 -1
  54. package/lib/app/templates/package.json.tpl.ts +0 -68
  55. package/lib/app/templates/prettierrc.tpl.d.ts +0 -2
  56. package/lib/app/templates/prettierrc.tpl.js +0 -11
  57. package/lib/app/templates/prettierrc.tpl.js.map +0 -1
  58. package/lib/app/templates/prettierrc.tpl.ts +0 -14
  59. package/lib/app/templates/readme.md.tpl.d.ts +0 -2
  60. package/lib/app/templates/readme.md.tpl.js +0 -54
  61. package/lib/app/templates/readme.md.tpl.js.map +0 -1
  62. package/lib/app/templates/readme.md.tpl.ts +0 -57
  63. package/lib/app/templates/schemas.tpl.d.ts +0 -2
  64. package/lib/app/templates/schemas.tpl.js +0 -75
  65. package/lib/app/templates/schemas.tpl.js.map +0 -1
  66. package/lib/app/templates/schemas.tpl.ts +0 -89
  67. package/lib/app/templates/services.tpl.d.ts +0 -2
  68. package/lib/app/templates/services.tpl.js +0 -14
  69. package/lib/app/templates/services.tpl.js.map +0 -1
  70. package/lib/app/templates/services.tpl.ts +0 -18
  71. package/lib/app/templates/tsconfig.json.tpl.d.ts +0 -2
  72. package/lib/app/templates/tsconfig.json.tpl.js +0 -22
  73. package/lib/app/templates/tsconfig.json.tpl.js.map +0 -1
  74. package/lib/app/templates/tsconfig.json.tpl.ts +0 -28
  75. package/lib/authentication/index.d.ts +0 -73
  76. package/lib/authentication/index.js +0 -107
  77. package/lib/authentication/index.js.map +0 -1
  78. package/lib/authentication/index.ts +0 -126
  79. package/lib/authentication/templates/authentication.tpl.d.ts +0 -2
  80. package/lib/authentication/templates/authentication.tpl.js +0 -39
  81. package/lib/authentication/templates/authentication.tpl.js.map +0 -1
  82. package/lib/authentication/templates/authentication.tpl.ts +0 -50
  83. package/lib/authentication/templates/client.test.tpl.d.ts +0 -2
  84. package/lib/authentication/templates/client.test.tpl.js +0 -61
  85. package/lib/authentication/templates/client.test.tpl.js.map +0 -1
  86. package/lib/authentication/templates/client.test.tpl.ts +0 -73
  87. package/lib/authentication/templates/client.tpl.d.ts +0 -2
  88. package/lib/authentication/templates/client.tpl.js +0 -14
  89. package/lib/authentication/templates/client.tpl.js.map +0 -1
  90. package/lib/authentication/templates/client.tpl.ts +0 -19
  91. package/lib/authentication/templates/config.tpl.d.ts +0 -2
  92. package/lib/authentication/templates/config.tpl.js +0 -50
  93. package/lib/authentication/templates/config.tpl.js.map +0 -1
  94. package/lib/authentication/templates/config.tpl.ts +0 -57
  95. package/lib/authentication/templates/declarations.tpl.d.ts +0 -2
  96. package/lib/authentication/templates/declarations.tpl.js +0 -19
  97. package/lib/authentication/templates/declarations.tpl.js.map +0 -1
  98. package/lib/authentication/templates/declarations.tpl.ts +0 -34
  99. package/lib/authentication/templates/knex.tpl.d.ts +0 -2
  100. package/lib/authentication/templates/knex.tpl.js +0 -45
  101. package/lib/authentication/templates/knex.tpl.js.map +0 -1
  102. package/lib/authentication/templates/knex.tpl.ts +0 -62
  103. package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
  104. package/lib/authentication/templates/schema.json.tpl.js +0 -93
  105. package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
  106. package/lib/authentication/templates/schema.json.tpl.ts +0 -108
  107. package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
  108. package/lib/authentication/templates/schema.typebox.tpl.js +0 -78
  109. package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
  110. package/lib/authentication/templates/schema.typebox.tpl.ts +0 -94
  111. package/lib/cli.d.ts +0 -6
  112. package/lib/cli.js +0 -75
  113. package/lib/cli.js.map +0 -1
  114. package/lib/cli.ts +0 -68
  115. package/lib/commons.d.ts +0 -143
  116. package/lib/commons.js +0 -190
  117. package/lib/commons.js.map +0 -1
  118. package/lib/commons.ts +0 -276
  119. package/lib/connection/index.d.ts +0 -55
  120. package/lib/connection/index.js +0 -88
  121. package/lib/connection/index.js.map +0 -1
  122. package/lib/connection/index.ts +0 -123
  123. package/lib/connection/templates/knex.tpl.d.ts +0 -2
  124. package/lib/connection/templates/knex.tpl.js +0 -46
  125. package/lib/connection/templates/knex.tpl.js.map +0 -1
  126. package/lib/connection/templates/knex.tpl.ts +0 -63
  127. package/lib/connection/templates/mongodb.tpl.d.ts +0 -2
  128. package/lib/connection/templates/mongodb.tpl.js +0 -33
  129. package/lib/connection/templates/mongodb.tpl.js.map +0 -1
  130. package/lib/connection/templates/mongodb.tpl.ts +0 -38
  131. package/lib/hook/index.d.ts +0 -22
  132. package/lib/hook/index.js +0 -43
  133. package/lib/hook/index.js.map +0 -1
  134. package/lib/hook/index.ts +0 -47
  135. package/lib/hook/templates/hook.tpl.d.ts +0 -2
  136. package/lib/hook/templates/hook.tpl.js +0 -20
  137. package/lib/hook/templates/hook.tpl.js.map +0 -1
  138. package/lib/hook/templates/hook.tpl.ts +0 -31
  139. package/lib/index.ts +0 -2
  140. package/lib/service/index.d.ts +0 -64
  141. package/lib/service/index.js +0 -116
  142. package/lib/service/index.js.map +0 -1
  143. package/lib/service/index.ts +0 -191
  144. package/lib/service/templates/client.tpl.d.ts +0 -2
  145. package/lib/service/templates/client.tpl.js +0 -31
  146. package/lib/service/templates/client.tpl.js.map +0 -1
  147. package/lib/service/templates/client.tpl.ts +0 -57
  148. package/lib/service/templates/schema.json.tpl.d.ts +0 -2
  149. package/lib/service/templates/schema.json.tpl.js +0 -75
  150. package/lib/service/templates/schema.json.tpl.js.map +0 -1
  151. package/lib/service/templates/schema.json.tpl.ts +0 -87
  152. package/lib/service/templates/schema.typebox.tpl.d.ts +0 -2
  153. package/lib/service/templates/schema.typebox.tpl.js +0 -55
  154. package/lib/service/templates/schema.typebox.tpl.js.map +0 -1
  155. package/lib/service/templates/schema.typebox.tpl.ts +0 -67
  156. package/lib/service/templates/service.tpl.d.ts +0 -3
  157. package/lib/service/templates/service.tpl.js +0 -98
  158. package/lib/service/templates/service.tpl.js.map +0 -1
  159. package/lib/service/templates/service.tpl.ts +0 -134
  160. package/lib/service/templates/test.tpl.d.ts +0 -2
  161. package/lib/service/templates/test.tpl.js +0 -24
  162. package/lib/service/templates/test.tpl.js.map +0 -1
  163. package/lib/service/templates/test.tpl.ts +0 -28
  164. package/lib/service/type/custom.tpl.d.ts +0 -3
  165. package/lib/service/type/custom.tpl.js +0 -94
  166. package/lib/service/type/custom.tpl.js.map +0 -1
  167. package/lib/service/type/custom.tpl.ts +0 -99
  168. package/lib/service/type/knex.tpl.d.ts +0 -3
  169. package/lib/service/type/knex.tpl.js +0 -67
  170. package/lib/service/type/knex.tpl.js.map +0 -1
  171. package/lib/service/type/knex.tpl.ts +0 -88
  172. package/lib/service/type/mongodb.tpl.d.ts +0 -3
  173. package/lib/service/type/mongodb.tpl.js +0 -47
  174. package/lib/service/type/mongodb.tpl.js.map +0 -1
  175. package/lib/service/type/mongodb.tpl.ts +0 -59
@@ -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://localhost: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://localhost: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,46 +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 */ `import knex from 'knex'
7
- import type { Knex } from 'knex'
8
- import type { Application } from './declarations'
9
-
10
- declare module './declarations' {
11
- interface Configuration {
12
- ${database}Client: Knex
13
- }
14
- }
15
-
16
- export const ${database} = (app: Application) => {
17
- const config = app.get('${database}')
18
- const db = knex(config!)
19
-
20
- app.set('${database}Client', db)
21
- }
22
- `;
23
- const knexfile = ({ lib, language, database }) => /* ts */ `import { app } from './${lib}/app'
24
-
25
- // Load our database connection info from the app configuration
26
- const config = app.get('${database}')
27
-
28
- ${language === 'js' ? 'export default config' : 'module.exports = config'}
29
- `;
30
- const importTemplate = ({ database }) => `import { ${database} } from './${database}'`;
31
- const configureTemplate = ({ database }) => `app.configure(${database})`;
32
- const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
33
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
34
- .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, database }) => [lib, database])))
35
- .then((0, commons_1.renderSource)(knexfile, (0, pinion_1.toFile)('knexfile')))
36
- .then((0, pinion_1.mergeJSON)({
37
- scripts: {
38
- migrate: 'knex migrate:latest',
39
- 'migrate:make': 'knex migrate:make',
40
- test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha'
41
- }
42
- }, (0, pinion_1.toFile)('package.json')))
43
- .then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
44
- .then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
45
- exports.generate = generate;
46
- //# 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,EAAE,QAAQ,EAA8B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;MAMlE,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,0BAA0B,GAAG;;;0BAG9C,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,63 +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 = ({ database }: ConnectionGeneratorContext) => /* ts */ `import knex from 'knex'
6
- import type { Knex } from 'knex'
7
- import type { Application } from './declarations'
8
-
9
- declare module './declarations' {
10
- interface Configuration {
11
- ${database}Client: Knex
12
- }
13
- }
14
-
15
- export const ${database} = (app: Application) => {
16
- const config = app.get('${database}')
17
- const db = knex(config!)
18
-
19
- app.set('${database}Client', db)
20
- }
21
- `
22
-
23
- const knexfile = ({
24
- lib,
25
- language,
26
- database
27
- }: ConnectionGeneratorContext) => /* ts */ `import { app } from './${lib}/app'
28
-
29
- // Load our database connection info from the app configuration
30
- const config = app.get('${database}')
31
-
32
- ${language === 'js' ? 'export default config' : 'module.exports = config'}
33
- `
34
-
35
- const importTemplate = ({ database }: ConnectionGeneratorContext) =>
36
- `import { ${database} } from './${database}'`
37
- const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})`
38
-
39
- const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
40
-
41
- export const generate = (ctx: ConnectionGeneratorContext) =>
42
- generator(ctx)
43
- .then(
44
- renderSource(
45
- template,
46
- toFile<ConnectionGeneratorContext>(({ lib, database }) => [lib, database])
47
- )
48
- )
49
- .then(renderSource(knexfile, toFile('knexfile')))
50
- .then(
51
- mergeJSON<ConnectionGeneratorContext>(
52
- {
53
- scripts: {
54
- migrate: 'knex migrate:latest',
55
- 'migrate:make': 'knex migrate:make',
56
- test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha'
57
- }
58
- },
59
- toFile('package.json')
60
- )
61
- )
62
- .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
63
- .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,33 +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 */ `import { MongoClient } from 'mongodb'
7
- import type { Db } from 'mongodb'
8
- import type { Application } from './declarations'
9
-
10
- declare module './declarations' {
11
- interface Configuration {
12
- mongodbClient: Promise<Db>
13
- }
14
- }
15
-
16
- export const mongodb = (app: Application) => {
17
- const connection = app.get('mongodb') as string
18
- const database = new URL(connection).pathname.substring(1)
19
- const mongoClient = MongoClient.connect(connection)
20
- .then(client => client.db(database))
21
-
22
- app.set('mongodbClient', mongoClient)
23
- }
24
- `;
25
- const importTemplate = "import { mongodb } from './mongodb'";
26
- const configureTemplate = 'app.configure(mongodb)';
27
- const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
28
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
29
- .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'mongodb')))
30
- .then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
31
- .then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
32
- exports.generate = generate;
33
- //# 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,GAAG,CAAC,EAA8B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;CAkB7D,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,38 +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 = ({}: ConnectionGeneratorContext) => /* ts */ `import { MongoClient } from 'mongodb'
6
- import type { Db } from 'mongodb'
7
- import type { Application } from './declarations'
8
-
9
- declare module './declarations' {
10
- interface Configuration {
11
- mongodbClient: Promise<Db>
12
- }
13
- }
14
-
15
- export const mongodb = (app: Application) => {
16
- const connection = app.get('mongodb') as string
17
- const database = new URL(connection).pathname.substring(1)
18
- const mongoClient = MongoClient.connect(connection)
19
- .then(client => client.db(database))
20
-
21
- app.set('mongodbClient', mongoClient)
22
- }
23
- `
24
-
25
- const importTemplate = "import { mongodb } from './mongodb'"
26
- const configureTemplate = 'app.configure(mongodb)'
27
- const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
28
-
29
- export const generate = (ctx: ConnectionGeneratorContext) =>
30
- generator(ctx)
31
- .then(
32
- renderSource(
33
- template,
34
- toFile<ConnectionGeneratorContext>(({ lib }) => lib, 'mongodb')
35
- )
36
- )
37
- .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
38
- .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,20 +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 */ `import type { HookContext, NextFunction } from '../declarations'
7
-
8
- export const ${camelName} = async (context: HookContext, next: NextFunction) => {
9
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
10
- await next()
11
- }
12
- `;
13
- const regularTemplate = ({ camelName, name }) => /* ts */ `import type { HookContext } from '../declarations'
14
-
15
- export const ${camelName} = async (context: HookContext) => {
16
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
17
- }`;
18
- 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])));
19
- exports.generate = generate;
20
- //# 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;;eAEtB,SAAS;+BACO,IAAI;;;CAGlC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;eAEtB,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,31 +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 */ `import type { HookContext, NextFunction } from '../declarations'
9
-
10
- export const ${camelName} = async (context: HookContext, next: NextFunction) => {
11
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
12
- await next()
13
- }
14
- `
15
-
16
- const regularTemplate = ({
17
- camelName,
18
- name
19
- }: HookGeneratorContext) => /* ts */ `import type { HookContext } from '../declarations'
20
-
21
- export const ${camelName} = async (context: HookContext) => {
22
- console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
23
- }`
24
-
25
- export const generate = (ctx: HookGeneratorContext) =>
26
- generator(ctx).then(
27
- renderSource(
28
- (ctx) => (ctx.type === 'around' ? aroundTemplate(ctx) : regularTemplate(ctx)),
29
- toFile<HookGeneratorContext>(({ lib, kebabName }) => [lib, 'hooks', kebabName])
30
- )
31
- )
package/lib/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './cli'
2
- export * from './commons'