@feathersjs/generators 5.0.13 → 5.0.15

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 (158) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/app/index.d.ts +19 -27
  3. package/lib/app/index.js +25 -30
  4. package/lib/app/index.js.map +1 -1
  5. package/lib/app/index.ts +17 -8
  6. package/lib/app/templates/app.test.tpl.d.ts +5 -2
  7. package/lib/app/templates/app.test.tpl.js +3 -7
  8. package/lib/app/templates/app.test.tpl.js.map +1 -1
  9. package/lib/app/templates/app.test.tpl.ts +4 -4
  10. package/lib/app/templates/app.tpl.d.ts +1 -1
  11. package/lib/app/templates/app.tpl.js +3 -7
  12. package/lib/app/templates/app.tpl.js.map +1 -1
  13. package/lib/app/templates/app.tpl.ts +4 -4
  14. package/lib/app/templates/channels.tpl.d.ts +1 -1
  15. package/lib/app/templates/channels.tpl.js +3 -7
  16. package/lib/app/templates/channels.tpl.js.map +1 -1
  17. package/lib/app/templates/channels.tpl.ts +4 -4
  18. package/lib/app/templates/client.test.tpl.d.ts +1 -1
  19. package/lib/app/templates/client.test.tpl.js +3 -7
  20. package/lib/app/templates/client.test.tpl.js.map +1 -1
  21. package/lib/app/templates/client.test.tpl.ts +4 -4
  22. package/lib/app/templates/client.tpl.d.ts +1 -1
  23. package/lib/app/templates/client.tpl.js +3 -7
  24. package/lib/app/templates/client.tpl.js.map +1 -1
  25. package/lib/app/templates/client.tpl.ts +4 -4
  26. package/lib/app/templates/configuration.tpl.d.ts +1 -1
  27. package/lib/app/templates/configuration.tpl.js +7 -11
  28. package/lib/app/templates/configuration.tpl.js.map +1 -1
  29. package/lib/app/templates/configuration.tpl.ts +4 -4
  30. package/lib/app/templates/declarations.tpl.d.ts +1 -1
  31. package/lib/app/templates/declarations.tpl.js +2 -6
  32. package/lib/app/templates/declarations.tpl.js.map +1 -1
  33. package/lib/app/templates/declarations.tpl.ts +3 -3
  34. package/lib/app/templates/index.html.tpl.d.ts +5 -2
  35. package/lib/app/templates/index.html.tpl.js +2 -6
  36. package/lib/app/templates/index.html.tpl.js.map +1 -1
  37. package/lib/app/templates/index.html.tpl.ts +3 -3
  38. package/lib/app/templates/index.tpl.d.ts +1 -1
  39. package/lib/app/templates/index.tpl.js +3 -7
  40. package/lib/app/templates/index.tpl.js.map +1 -1
  41. package/lib/app/templates/index.tpl.ts +4 -4
  42. package/lib/app/templates/logger.tpl.d.ts +1 -1
  43. package/lib/app/templates/logger.tpl.js +6 -10
  44. package/lib/app/templates/logger.tpl.js.map +1 -1
  45. package/lib/app/templates/logger.tpl.ts +4 -4
  46. package/lib/app/templates/package.json.tpl.d.ts +5 -2
  47. package/lib/app/templates/package.json.tpl.js +2 -6
  48. package/lib/app/templates/package.json.tpl.js.map +1 -1
  49. package/lib/app/templates/package.json.tpl.ts +3 -3
  50. package/lib/app/templates/prettierrc.tpl.d.ts +1 -1
  51. package/lib/app/templates/prettierrc.tpl.js +5 -9
  52. package/lib/app/templates/prettierrc.tpl.js.map +1 -1
  53. package/lib/app/templates/prettierrc.tpl.ts +4 -4
  54. package/lib/app/templates/readme.md.tpl.d.ts +5 -2
  55. package/lib/app/templates/readme.md.tpl.js +2 -6
  56. package/lib/app/templates/readme.md.tpl.js.map +1 -1
  57. package/lib/app/templates/readme.md.tpl.ts +3 -3
  58. package/lib/app/templates/services.tpl.d.ts +1 -1
  59. package/lib/app/templates/services.tpl.js +3 -7
  60. package/lib/app/templates/services.tpl.js.map +1 -1
  61. package/lib/app/templates/services.tpl.ts +4 -4
  62. package/lib/app/templates/tsconfig.json.tpl.d.ts +1 -1
  63. package/lib/app/templates/tsconfig.json.tpl.js +3 -7
  64. package/lib/app/templates/tsconfig.json.tpl.js.map +1 -1
  65. package/lib/app/templates/tsconfig.json.tpl.ts +3 -3
  66. package/lib/app/templates/validators.tpl.d.ts +1 -1
  67. package/lib/app/templates/validators.tpl.js +3 -7
  68. package/lib/app/templates/validators.tpl.js.map +1 -1
  69. package/lib/app/templates/validators.tpl.ts +4 -4
  70. package/lib/authentication/index.d.ts +10 -10
  71. package/lib/authentication/index.js +16 -19
  72. package/lib/authentication/index.js.map +1 -1
  73. package/lib/authentication/index.ts +65 -56
  74. package/lib/authentication/templates/authentication.tpl.d.ts +1 -1
  75. package/lib/authentication/templates/authentication.tpl.js +11 -15
  76. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  77. package/lib/authentication/templates/authentication.tpl.ts +5 -5
  78. package/lib/authentication/templates/client.test.tpl.d.ts +1 -1
  79. package/lib/authentication/templates/client.test.tpl.js +7 -11
  80. package/lib/authentication/templates/client.test.tpl.js.map +1 -1
  81. package/lib/authentication/templates/client.test.tpl.ts +5 -5
  82. package/lib/authentication/templates/config.tpl.d.ts +1 -1
  83. package/lib/authentication/templates/config.tpl.js +8 -15
  84. package/lib/authentication/templates/config.tpl.js.map +1 -1
  85. package/lib/authentication/templates/config.tpl.ts +3 -3
  86. package/lib/authentication/templates/declarations.tpl.d.ts +1 -1
  87. package/lib/authentication/templates/declarations.tpl.js +5 -9
  88. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  89. package/lib/authentication/templates/declarations.tpl.ts +3 -3
  90. package/lib/commons.d.ts +10 -2
  91. package/lib/commons.js +43 -76
  92. package/lib/commons.js.map +1 -1
  93. package/lib/commons.ts +22 -4
  94. package/lib/connection/index.d.ts +1 -1
  95. package/lib/connection/index.js +24 -30
  96. package/lib/connection/index.js.map +1 -1
  97. package/lib/connection/index.ts +10 -4
  98. package/lib/connection/templates/knex.tpl.d.ts +1 -1
  99. package/lib/connection/templates/knex.tpl.js +13 -20
  100. package/lib/connection/templates/knex.tpl.js.map +1 -1
  101. package/lib/connection/templates/knex.tpl.ts +4 -4
  102. package/lib/connection/templates/mongodb.tpl.d.ts +1 -1
  103. package/lib/connection/templates/mongodb.tpl.js +10 -14
  104. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  105. package/lib/connection/templates/mongodb.tpl.ts +4 -4
  106. package/lib/hook/index.d.ts +6 -6
  107. package/lib/hook/index.js +13 -17
  108. package/lib/hook/index.js.map +1 -1
  109. package/lib/hook/index.ts +7 -3
  110. package/lib/hook/templates/hook.tpl.d.ts +1 -1
  111. package/lib/hook/templates/hook.tpl.js +3 -7
  112. package/lib/hook/templates/hook.tpl.js.map +1 -1
  113. package/lib/hook/templates/hook.tpl.ts +4 -4
  114. package/lib/index.d.ts +7 -7
  115. package/lib/index.js +7 -36
  116. package/lib/index.js.map +1 -1
  117. package/lib/index.ts +7 -7
  118. package/lib/service/index.d.ts +1 -1
  119. package/lib/service/index.js +27 -31
  120. package/lib/service/index.js.map +1 -1
  121. package/lib/service/index.ts +94 -92
  122. package/lib/service/templates/client.tpl.d.ts +1 -1
  123. package/lib/service/templates/client.tpl.js +4 -8
  124. package/lib/service/templates/client.tpl.js.map +1 -1
  125. package/lib/service/templates/client.tpl.ts +4 -4
  126. package/lib/service/templates/schema.json.tpl.d.ts +1 -1
  127. package/lib/service/templates/schema.json.tpl.js +10 -14
  128. package/lib/service/templates/schema.json.tpl.js.map +1 -1
  129. package/lib/service/templates/schema.json.tpl.ts +4 -4
  130. package/lib/service/templates/schema.typebox.tpl.d.ts +1 -1
  131. package/lib/service/templates/schema.typebox.tpl.js +8 -12
  132. package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
  133. package/lib/service/templates/schema.typebox.tpl.ts +4 -4
  134. package/lib/service/templates/service.tpl.d.ts +1 -1
  135. package/lib/service/templates/service.tpl.js +9 -14
  136. package/lib/service/templates/service.tpl.js.map +1 -1
  137. package/lib/service/templates/service.tpl.ts +4 -4
  138. package/lib/service/templates/shared.tpl.d.ts +1 -1
  139. package/lib/service/templates/shared.tpl.js +3 -7
  140. package/lib/service/templates/shared.tpl.js.map +1 -1
  141. package/lib/service/templates/shared.tpl.ts +4 -4
  142. package/lib/service/templates/test.tpl.d.ts +1 -1
  143. package/lib/service/templates/test.tpl.js +3 -7
  144. package/lib/service/templates/test.tpl.js.map +1 -1
  145. package/lib/service/templates/test.tpl.ts +4 -4
  146. package/lib/service/type/custom.tpl.d.ts +1 -1
  147. package/lib/service/type/custom.tpl.js +4 -9
  148. package/lib/service/type/custom.tpl.js.map +1 -1
  149. package/lib/service/type/custom.tpl.ts +4 -4
  150. package/lib/service/type/knex.tpl.d.ts +1 -1
  151. package/lib/service/type/knex.tpl.js +6 -11
  152. package/lib/service/type/knex.tpl.js.map +1 -1
  153. package/lib/service/type/knex.tpl.ts +4 -4
  154. package/lib/service/type/mongodb.tpl.d.ts +1 -1
  155. package/lib/service/type/mongodb.tpl.js +4 -9
  156. package/lib/service/type/mongodb.tpl.js.map +1 -1
  157. package/lib/service/type/mongodb.tpl.ts +4 -4
  158. package/package.json +31 -30
package/lib/commons.js CHANGED
@@ -1,49 +1,21 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
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
- const fs_1 = __importDefault(require("fs"));
31
- const path_1 = require("path");
32
- const promises_1 = require("fs/promises");
33
- const pinion_1 = require("@feathershq/pinion");
34
- const ts = __importStar(require("typescript"));
35
- const prettier_1 = __importDefault(require("prettier"));
36
- const path_2 = __importDefault(require("path"));
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'];
1
+ import fs from 'fs';
2
+ import { join, dirname } from 'path';
3
+ import { readFile, writeFile } from 'fs/promises';
4
+ import { loadJSON, fromFile, getCallable, renderTemplate, inject, exec } from '@featherscloud/pinion';
5
+ import ts from 'typescript';
6
+ import prettier from 'prettier';
7
+ import path from 'path';
8
+ // Set __dirname in es module
9
+ const __dirname = dirname(new URL(import.meta.url).pathname);
10
+ export const { version } = JSON.parse(fs.readFileSync(join(__dirname, '..', 'package.json')).toString());
11
+ export const DATABASE_TYPES = ['mongodb', 'mysql', 'postgresql', 'sqlite', 'mssql', 'other'];
39
12
  /**
40
13
  * Returns the name of the Feathers database adapter for a supported database type
41
14
  *
42
15
  * @param database The type of the database
43
16
  * @returns The name of the adapter
44
17
  */
45
- const getDatabaseAdapter = (database) => (database === 'mongodb' ? 'mongodb' : 'knex');
46
- exports.getDatabaseAdapter = getDatabaseAdapter;
18
+ export const getDatabaseAdapter = (database) => (database === 'mongodb' ? 'mongodb' : 'knex');
47
19
  /**
48
20
  * Returns dependencies with the versions from the context attached (if available)
49
21
  *
@@ -51,21 +23,20 @@ exports.getDatabaseAdapter = getDatabaseAdapter;
51
23
  * @param versions The dependency version list
52
24
  * @returns A list of dependencies with their versions
53
25
  */
54
- const addVersions = (dependencies, versions) => dependencies.map((dep) => `${dep}@${versions[dep] ? versions[dep] : 'latest'}`);
55
- exports.addVersions = addVersions;
26
+ export const addVersions = (dependencies, versions) => dependencies.map((dep) => `${dep}@${versions[dep] ? versions[dep] : 'latest'}`);
56
27
  /**
57
28
  * Loads the application package.json and populates information like the library and test directory
58
29
  * and Feathers app specific information.
59
30
  *
60
31
  * @returns The updated context
61
32
  */
62
- const initializeBaseContext = () => (ctx) => Promise.resolve(ctx)
63
- .then((0, pinion_1.loadJSON)((0, pinion_1.fromFile)('package.json'), (pkg) => ({ pkg }), {}))
64
- .then((0, pinion_1.loadJSON)(path_2.default.join(__dirname, '..', 'package.json'), (pkg) => ({
33
+ export const initializeBaseContext = () => (ctx) => Promise.resolve(ctx)
34
+ .then(loadJSON(fromFile('package.json'), (pkg) => ({ pkg }), {}))
35
+ .then(loadJSON(path.join(__dirname, '..', 'package.json'), (pkg) => ({
65
36
  dependencyVersions: {
66
37
  ...pkg.devDependencies,
67
38
  ...ctx.dependencyVersions,
68
- '@feathersjs/cli': exports.version
39
+ '@feathersjs/cli': version
69
40
  }
70
41
  })))
71
42
  .then((ctx) => {
@@ -78,7 +49,6 @@ const initializeBaseContext = () => (ctx) => Promise.resolve(ctx)
78
49
  feathers: (_g = ctx.pkg) === null || _g === void 0 ? void 0 : _g.feathers
79
50
  });
80
51
  });
81
- exports.initializeBaseContext = initializeBaseContext;
82
52
  /**
83
53
  * Checks if the current context contains a valid generated application. This is necesary for most
84
54
  * generators (besides the app generator).
@@ -86,7 +56,7 @@ exports.initializeBaseContext = initializeBaseContext;
86
56
  * @param ctx The context to check against
87
57
  * @returns Throws an error or returns the original context
88
58
  */
89
- const checkPreconditions = () => async (ctx) => {
59
+ export const checkPreconditions = () => async (ctx) => {
90
60
  if (!ctx.feathers) {
91
61
  throw new Error(`Can not run generator since the current folder does not appear to be a Feathers application.
92
62
  Either your package.json is missing or it does not have \`feathers\` property.
@@ -94,7 +64,6 @@ Either your package.json is missing or it does not have \`feathers\` property.
94
64
  }
95
65
  return ctx;
96
66
  };
97
- exports.checkPreconditions = checkPreconditions;
98
67
  const importRegex = /from '(\..*)'/g;
99
68
  const escapeNewLines = (code) => code.replace(/\n\n/g, '\n/* :newline: */');
100
69
  const restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, '\n');
@@ -106,7 +75,7 @@ const fixLocalImports = (code) => code.replace(importRegex, "from '$1.js'");
106
75
  * @param options TypeScript transpilation options
107
76
  * @returns The formatted JavaScript source code
108
77
  */
109
- const getJavaScript = (typescript, options = {}) => {
78
+ export const getJavaScript = (typescript, options = {}) => {
110
79
  const source = escapeNewLines(typescript);
111
80
  const transpiled = ts.transpileModule(source, {
112
81
  ...options,
@@ -119,12 +88,11 @@ const getJavaScript = (typescript, options = {}) => {
119
88
  });
120
89
  return fixLocalImports(restoreNewLines(transpiled.outputText));
121
90
  };
122
- exports.getJavaScript = getJavaScript;
123
- const getFileName = async (target, ctx) => `${await (0, pinion_1.getCallable)(target, ctx)}.${ctx.language}`;
91
+ const getFileName = async (target, ctx) => `${await getCallable(target, ctx)}.${ctx.language}`;
124
92
  /**
125
93
  * The default configuration for prettifying files
126
94
  */
127
- exports.PRETTIERRC = {
95
+ export const PRETTIERRC = {
128
96
  tabWidth: 2,
129
97
  useTabs: false,
130
98
  printWidth: 110,
@@ -140,12 +108,12 @@ exports.PRETTIERRC = {
140
108
  * @param options The Prettier options
141
109
  * @returns The updated context
142
110
  */
143
- const prettify = (target, options = exports.PRETTIERRC) => async (ctx) => {
111
+ export const prettify = (target, options = PRETTIERRC) => async (ctx) => {
144
112
  const fileName = await getFileName(target, ctx);
145
- const config = (await prettier_1.default.resolveConfig(ctx.cwd)) || options;
146
- const content = (await (0, promises_1.readFile)(fileName)).toString();
113
+ const config = (await prettier.resolveConfig(ctx.cwd)) || options;
114
+ const content = (await readFile(fileName)).toString();
147
115
  try {
148
- await (0, promises_1.writeFile)(fileName, await prettier_1.default.format(content, {
116
+ await writeFile(fileName, await prettier.format(content, {
149
117
  parser: ctx.language === 'ts' ? 'typescript' : 'babel',
150
118
  ...config
151
119
  }));
@@ -155,7 +123,6 @@ const prettify = (target, options = exports.PRETTIERRC) => async (ctx) => {
155
123
  }
156
124
  return ctx;
157
125
  };
158
- exports.prettify = prettify;
159
126
  /**
160
127
  * Render a source file template for the language set in the context.
161
128
  *
@@ -163,14 +130,19 @@ exports.prettify = prettify;
163
130
  * @param target The target filename without extension (will be added based on language)
164
131
  * @returns The updated context
165
132
  */
166
- const renderSource = (template, target, options) => async (ctx) => {
133
+ export const renderSource = (template, target, options) => async (ctx) => {
167
134
  const { language } = ctx;
168
135
  const fileName = await getFileName(target, ctx);
169
- const content = language === 'js' ? (0, exports.getJavaScript)(await (0, pinion_1.getCallable)(template, ctx)) : template;
170
- const renderer = (0, pinion_1.renderTemplate)(content, fileName, options);
171
- return renderer(ctx).then((0, exports.prettify)(target));
136
+ const content = language === 'js' ? getJavaScript(await getCallable(template, ctx)) : template;
137
+ const renderer = renderTemplate(content, fileName, options);
138
+ return renderer(ctx).then(prettify(target));
139
+ };
140
+ export const install = (dependencies, dev, packager) => async (ctx) => {
141
+ const dependencyList = await getCallable(dependencies, ctx);
142
+ const packageManager = await getCallable(packager, ctx);
143
+ const flags = dev ? [packageManager === 'yarn' ? '--dev' : '--save-dev'] : [];
144
+ return exec(packager, [packageManager === 'yarn' ? 'add' : 'install', ...dependencyList, ...flags])(ctx);
172
145
  };
173
- exports.renderSource = renderSource;
174
146
  /**
175
147
  * Inject a source template as the language set in the context.
176
148
  *
@@ -180,27 +152,25 @@ exports.renderSource = renderSource;
180
152
  * @param transpile Set to `false` if the code should not be transpiled to JavaScript
181
153
  * @returns
182
154
  */
183
- const injectSource = (template, location, target, transpile = true) => async (ctx) => {
155
+ export const injectSource = (template, location, target, transpile = true) => async (ctx) => {
184
156
  const { language } = ctx;
185
- const source = language === 'js' && transpile ? (0, exports.getJavaScript)(await (0, pinion_1.getCallable)(template, ctx)) : template;
157
+ const source = language === 'js' && transpile ? getJavaScript(await getCallable(template, ctx)) : template;
186
158
  const fileName = await getFileName(target, ctx);
187
- const injector = (0, pinion_1.inject)(source, location, fileName);
188
- return injector(ctx).then((0, exports.prettify)(target));
159
+ const injector = inject(source, location, fileName);
160
+ return injector(ctx).then(prettify(target));
189
161
  };
190
- exports.injectSource = injectSource;
191
162
  /**
192
163
  * Synchronously checks if a file exits
193
164
  * @param context The base context
194
165
  * @param filenames The filenames to check
195
166
  * @returns Wether the file exists or not
196
167
  */
197
- const fileExists = (...filenames) => fs_1.default.existsSync((0, path_1.join)(...filenames));
198
- exports.fileExists = fileExists;
168
+ export const fileExists = (...filenames) => fs.existsSync(join(...filenames));
199
169
  /**
200
170
  * The helper used by Knex to create migration names
201
171
  * @returns The current date and time in the format `YYYYMMDDHHMMSS`
202
172
  */
203
- const yyyymmddhhmmss = (offset = 0) => {
173
+ export const yyyymmddhhmmss = (offset = 0) => {
204
174
  const now = new Date(Date.now() + offset);
205
175
  return (now.getUTCFullYear().toString() +
206
176
  (now.getUTCMonth() + 1).toString().padStart(2, '0') +
@@ -209,7 +179,6 @@ const yyyymmddhhmmss = (offset = 0) => {
209
179
  now.getUTCMinutes().toString().padStart(2, '0') +
210
180
  now.getUTCSeconds().toString().padStart(2, '0'));
211
181
  };
212
- exports.yyyymmddhhmmss = yyyymmddhhmmss;
213
182
  /**
214
183
  * Render a template if `local` authentication strategy has been selected
215
184
  * @param authStrategies The list of selected authentication strategies
@@ -217,14 +186,12 @@ exports.yyyymmddhhmmss = yyyymmddhhmmss;
217
186
  * @param alt The content to render if `local` is not selected
218
187
  * @returns
219
188
  */
220
- const localTemplate = (authStrategies, content, alt = '') => authStrategies.includes('local') ? content : alt;
221
- exports.localTemplate = localTemplate;
189
+ export const localTemplate = (authStrategies, content, alt = '') => authStrategies.includes('local') ? content : alt;
222
190
  /**
223
191
  * Render a template if an `oauth` authentication strategy has been selected
224
192
  * @param authStrategies
225
193
  * @param content
226
194
  * @returns
227
195
  */
228
- const oauthTemplate = (authStrategies, content) => authStrategies.filter((s) => s !== 'local').length > 0 ? content : '';
229
- exports.oauthTemplate = oauthTemplate;
196
+ export const oauthTemplate = (authStrategies, content) => authStrategies.filter((s) => s !== 'local').length > 0 ? content : '';
230
197
  //# sourceMappingURL=commons.js.map
@@ -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,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAA;AAI3F,QAAA,cAAc,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAU,CAAA;AAOrG;;;;;GAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAsB,EAAE,EAAE,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAA9F,QAAA,kBAAkB,sBAA4E;AA8D3G;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CAAC,YAAsB,EAAE,QAA4B,EAAE,EAAE,CAClF,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;AADpE,QAAA,WAAW,eACyD;AAEjF;;;;;GAKG;AACI,MAAM,qBAAqB,GAChC,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AAC,CAAC,EAAE,GAAG,CAAC;QAC/C,GAAG,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAChD,CAAA;AACH,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,cAAwB,EAAE,OAAe,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE,CACnF,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,cAAwB,EAAE,OAAe,EAAE,EAAE,CACzE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA"}
package/lib/commons.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import fs from 'fs'
2
- import { join } from 'path'
2
+ import { join, dirname } from 'path'
3
3
  import { PackageJson } from 'type-fest'
4
4
  import { readFile, writeFile } from 'fs/promises'
5
5
  import {
@@ -10,12 +10,16 @@ import {
10
10
  getCallable,
11
11
  renderTemplate,
12
12
  inject,
13
- Location
14
- } from '@feathershq/pinion'
15
- import * as ts from 'typescript'
13
+ Location,
14
+ exec
15
+ } from '@featherscloud/pinion'
16
+ import ts from 'typescript'
16
17
  import prettier, { Options as PrettierOptions } from 'prettier'
17
18
  import path from 'path'
18
19
 
20
+ // Set __dirname in es module
21
+ const __dirname = dirname(new URL(import.meta.url).pathname)
22
+
19
23
  export const { version } = JSON.parse(fs.readFileSync(join(__dirname, '..', 'package.json')).toString())
20
24
 
21
25
  export type DependencyVersions = { [key: string]: string }
@@ -251,6 +255,20 @@ export const renderSource =
251
255
  return renderer(ctx).then(prettify(target))
252
256
  }
253
257
 
258
+ export const install =
259
+ <C extends PinionContext & { language: 'js' | 'ts' }>(
260
+ dependencies: Callable<string[], C>,
261
+ dev: Callable<boolean, C>,
262
+ packager: Callable<string, C>
263
+ ) =>
264
+ async (ctx: C) => {
265
+ const dependencyList = await getCallable(dependencies, ctx)
266
+ const packageManager = await getCallable(packager, ctx)
267
+ const flags = dev ? [packageManager === 'yarn' ? '--dev' : '--save-dev'] : []
268
+
269
+ return exec(packager, [packageManager === 'yarn' ? 'add' : 'install', ...dependencyList, ...flags])(ctx)
270
+ }
271
+
254
272
  /**
255
273
  * Inject a source template as the language set in the context.
256
274
  *
@@ -1,4 +1,4 @@
1
- import { FeathersBaseContext, DatabaseType } from '../commons';
1
+ import { FeathersBaseContext, DatabaseType } from '../commons.js';
2
2
  export interface ConnectionGeneratorContext extends FeathersBaseContext {
3
3
  name?: string;
4
4
  database: DatabaseType;
@@ -1,13 +1,10 @@
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) => {
1
+ import { dirname } from 'path';
2
+ import { runGenerator, prompt, mergeJSON, toFile, when } from '@featherscloud/pinion';
3
+ import chalk from 'chalk';
4
+ import { install, getDatabaseAdapter, addVersions, checkPreconditions, initializeBaseContext } from '../commons.js';
5
+ // Set __dirname in es module
6
+ const __dirname = dirname(new URL(import.meta.url).pathname);
7
+ export const defaultConnectionString = (type, name) => {
11
8
  const connectionStrings = {
12
9
  mongodb: `mongodb://127.0.0.1:27017/${name}`,
13
10
  mysql: `mysql://root:@localhost:3306/${name}`,
@@ -18,14 +15,13 @@ const defaultConnectionString = (type, name) => {
18
15
  };
19
16
  return connectionStrings[type];
20
17
  };
21
- exports.defaultConnectionString = defaultConnectionString;
22
- const prompts = ({ database, connectionString, pkg, name }) => [
18
+ export const prompts = ({ database, connectionString, pkg, name }) => [
23
19
  {
24
20
  name: 'database',
25
21
  type: 'list',
26
22
  when: !database,
27
23
  message: 'Which database are you connecting to?',
28
- suffix: chalk_1.default.grey(' Databases can be added at any time'),
24
+ suffix: chalk.grey(' Databases can be added at any time'),
29
25
  choices: [
30
26
  { value: 'sqlite', name: 'SQLite' },
31
27
  { value: 'mongodb', name: 'MongoDB' },
@@ -34,7 +30,7 @@ const prompts = ({ database, connectionString, pkg, name }) => [
34
30
  { value: 'mssql', name: 'Microsoft SQL' },
35
31
  {
36
32
  value: 'other',
37
- name: `Another database ${chalk_1.default.grey('(not configured automatically, use with custom services)')}`
33
+ name: `Another database ${chalk.grey('(not configured automatically, use with custom services)')}`
38
34
  }
39
35
  ]
40
36
  },
@@ -43,37 +39,36 @@ const prompts = ({ database, connectionString, pkg, name }) => [
43
39
  type: 'input',
44
40
  when: (answers) => !connectionString && database !== 'other' && answers.database !== 'other',
45
41
  message: 'Enter your database connection string',
46
- default: (answers) => (0, exports.defaultConnectionString)(answers.database, answers.name || name || pkg.name)
42
+ default: (answers) => defaultConnectionString(answers.database, answers.name || name || pkg.name)
47
43
  }
48
44
  ];
49
- exports.prompts = prompts;
50
- exports.DATABASE_CLIENTS = {
45
+ export const DATABASE_CLIENTS = {
51
46
  mongodb: 'mongodb',
52
47
  sqlite: 'sqlite3',
53
48
  postgresql: 'pg',
54
49
  mysql: 'mysql',
55
50
  mssql: 'mssql'
56
51
  };
57
- const getDatabaseClient = (database) => database === 'other' ? null : exports.DATABASE_CLIENTS[database];
58
- exports.getDatabaseClient = getDatabaseClient;
59
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
60
- .then((0, commons_1.initializeBaseContext)())
61
- .then((0, commons_1.checkPreconditions)())
62
- .then((0, pinion_1.prompt)(exports.prompts))
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'
52
+ export const getDatabaseClient = (database) => database === 'other' ? null : DATABASE_CLIENTS[database];
53
+ export const generate = (ctx) => Promise.resolve(ctx)
54
+ .then(initializeBaseContext())
55
+ .then(checkPreconditions())
56
+ .then(prompt(prompts))
57
+ .then((ctx) => ctx)
58
+ .then(when((ctx) => ctx.database !== 'other', runGenerator(__dirname, 'templates', ({ database }) => `${getDatabaseAdapter(database)}.tpl`), mergeJSON(({ connectionString, database }) => getDatabaseAdapter(database) === 'knex'
64
59
  ? {
65
60
  [database]: {
66
- client: (0, exports.getDatabaseClient)(database),
61
+ client: getDatabaseClient(database),
67
62
  connection: connectionString,
68
63
  ...(database === 'sqlite' ? { useNullAsDefault: true } : {})
69
64
  }
70
65
  }
71
66
  : {
72
67
  [database]: connectionString
73
- }, (0, pinion_1.toFile)('config', 'default.json')), async (ctx) => {
68
+ }, toFile('config', 'default.json')), async (ctx) => {
74
69
  const dependencies = [];
75
- const adapter = (0, commons_1.getDatabaseAdapter)(ctx.database);
76
- const dbClient = (0, exports.getDatabaseClient)(ctx.database);
70
+ const adapter = getDatabaseAdapter(ctx.database);
71
+ const dbClient = getDatabaseClient(ctx.database);
77
72
  dependencies.push(`@feathersjs/${adapter}`);
78
73
  if (adapter === 'knex') {
79
74
  dependencies.push('knex');
@@ -85,7 +80,6 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
85
80
  dependencies: [...ctx.dependencies, ...dependencies]
86
81
  };
87
82
  }
88
- return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
83
+ return install(addVersions(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
89
84
  }));
90
- exports.generate = generate;
91
85
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,CAAA;IAE3C,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAED,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAE3B,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QACrB,OAAO;YACL,GAAG,GAAG;YACN,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC;SACrD,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CACZ,WAAW,CAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjD,KAAK,EACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACtB,CAAC,GAAG,CAAC,CAAA;AACR,CAAC,CACF,CACF,CAAA"}
@@ -1,13 +1,18 @@
1
- import { generator, runGenerator, prompt, install, mergeJSON, toFile, when } from '@feathershq/pinion'
1
+ import { dirname } from 'path'
2
+ import { runGenerator, prompt, mergeJSON, toFile, when } from '@featherscloud/pinion'
2
3
  import chalk from 'chalk'
3
4
  import {
5
+ install,
4
6
  FeathersBaseContext,
5
7
  DatabaseType,
6
8
  getDatabaseAdapter,
7
9
  addVersions,
8
10
  checkPreconditions,
9
11
  initializeBaseContext
10
- } from '../commons'
12
+ } from '../commons.js'
13
+
14
+ // Set __dirname in es module
15
+ const __dirname = dirname(new URL(import.meta.url).pathname)
11
16
 
12
17
  export interface ConnectionGeneratorContext extends FeathersBaseContext {
13
18
  name?: string
@@ -74,10 +79,11 @@ export const getDatabaseClient = (database: DatabaseType) =>
74
79
  database === 'other' ? null : DATABASE_CLIENTS[database]
75
80
 
76
81
  export const generate = (ctx: ConnectionGeneratorArguments) =>
77
- generator(ctx)
82
+ Promise.resolve(ctx)
78
83
  .then(initializeBaseContext())
79
84
  .then(checkPreconditions())
80
- .then(prompt<ConnectionGeneratorArguments, ConnectionGeneratorContext>(prompts))
85
+ .then(prompt(prompts))
86
+ .then((ctx) => ctx as ConnectionGeneratorContext)
81
87
  .then(
82
88
  when<ConnectionGeneratorContext>(
83
89
  (ctx) => ctx.database !== 'other',
@@ -1,2 +1,2 @@
1
- import { ConnectionGeneratorContext } from '../index';
1
+ import { ConnectionGeneratorContext } from '../index.js';
2
2
  export declare const generate: (ctx: ConnectionGeneratorContext) => Promise<ConnectionGeneratorContext>;
@@ -1,13 +1,7 @@
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 commons_1 = require("../../commons");
9
- const promises_1 = require("fs/promises");
10
- const path_1 = __importDefault(require("path"));
1
+ import { toFile, before, mergeJSON } from '@featherscloud/pinion';
2
+ import { injectSource, renderSource } from '../../commons.js';
3
+ import { mkdir } from 'fs/promises';
4
+ import path from 'path';
11
5
  const template = ({ database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
12
6
  import knex from 'knex'
13
7
  import type { Knex } from 'knex'
@@ -36,22 +30,21 @@ ${language === 'js' ? 'export default config' : 'module.exports = config'}
36
30
  `;
37
31
  const importTemplate = ({ database }) => `import { ${database} } from './${database}'`;
38
32
  const configureTemplate = ({ database }) => `app.configure(${database})`;
39
- const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
40
- const generate = (ctx) => (0, pinion_1.generator)(ctx)
41
- .then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, database }) => [lib, database])))
42
- .then((0, commons_1.renderSource)(knexfile, (0, pinion_1.toFile)('knexfile')))
43
- .then((0, pinion_1.mergeJSON)({
33
+ const toAppFile = toFile(({ lib }) => [lib, 'app']);
34
+ export const generate = (ctx) => Promise.resolve(ctx)
35
+ .then(renderSource(template, toFile(({ lib, database }) => [lib, database])))
36
+ .then(renderSource(knexfile, toFile('knexfile')))
37
+ .then(mergeJSON({
44
38
  scripts: {
45
39
  migrate: 'knex migrate:latest',
46
40
  'migrate:make': 'knex migrate:make',
47
41
  test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha'
48
42
  }
49
- }, (0, pinion_1.toFile)('package.json')))
50
- .then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
51
- .then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile))
43
+ }, toFile('package.json')))
44
+ .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
45
+ .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
52
46
  .then(async (ctx) => {
53
- await (0, promises_1.mkdir)(path_1.default.join(ctx.cwd, 'migrations'));
47
+ await mkdir(path.join(ctx.cwd, 'migrations'));
54
48
  return ctx;
55
49
  });
56
- exports.generate = generate;
57
50
  //# sourceMappingURL=knex.tpl.js.map
@@ -1 +1 @@
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/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AE,QAAQ,CAAC,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;KAChD,IAAI,CACH,SAAS,CACP;IACE,OAAO,EAAE;QACP,OAAO,EAAE,qBAAqB;QAC9B,cAAc,EAAE,mBAAmB;QACnC,IAAI,EAAE,0DAA0D;KACjE;CACF,EACD,MAAM,CAAC,cAAc,CAAC,CACvB,CACF;KACA,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC;KACnF,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAClB,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAA;IAC7C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import { generator, toFile, before, mergeJSON } from '@feathershq/pinion'
2
- import { ConnectionGeneratorContext } from '../index'
3
- import { injectSource, renderSource } from '../../commons'
1
+ import { toFile, before, mergeJSON } from '@featherscloud/pinion'
2
+ import { ConnectionGeneratorContext } from '../index.js'
3
+ import { injectSource, renderSource } from '../../commons.js'
4
4
  import { mkdir } from 'fs/promises'
5
5
  import path from 'path'
6
6
 
@@ -45,7 +45,7 @@ const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.con
45
45
  const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
46
46
 
47
47
  export const generate = (ctx: ConnectionGeneratorContext) =>
48
- generator(ctx)
48
+ Promise.resolve(ctx)
49
49
  .then(
50
50
  renderSource(
51
51
  template,
@@ -1,2 +1,2 @@
1
- import { ConnectionGeneratorContext } from '../index';
1
+ import { ConnectionGeneratorContext } from '../index.js';
2
2
  export declare const generate: (ctx: ConnectionGeneratorContext) => Promise<ConnectionGeneratorContext>;
@@ -1,8 +1,5 @@
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");
1
+ import { toFile, before, prepend, append } from '@featherscloud/pinion';
2
+ import { injectSource, renderSource } from '../../commons.js';
6
3
  const template = ({ database }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/databases.html
7
4
  import { MongoClient } from 'mongodb'
8
5
  import type { Db } from 'mongodb'
@@ -28,13 +25,12 @@ const keywordTemplate = `dataValidator.addKeyword(keywordObjectId)
28
25
  queryValidator.addKeyword(keywordObjectId)`;
29
26
  const importTemplate = ({ database }) => `import { ${database} } from './${database}'`;
30
27
  const configureTemplate = ({ database }) => `app.configure(${database})`;
31
- const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
32
- const toValidatorFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'validators']);
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.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
36
- .then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile))
37
- .then((0, commons_1.injectSource)(keywordImport, (0, pinion_1.prepend)(), toValidatorFile))
38
- .then((0, commons_1.injectSource)(keywordTemplate, (0, pinion_1.append)(), toValidatorFile));
39
- exports.generate = generate;
28
+ const toAppFile = toFile(({ lib }) => [lib, 'app']);
29
+ const toValidatorFile = toFile(({ lib }) => [lib, 'validators']);
30
+ export const generate = (ctx) => Promise.resolve(ctx)
31
+ .then(renderSource(template, toFile(({ lib, database }) => [lib, database])))
32
+ .then(injectSource(importTemplate, before('import { services } from'), toAppFile))
33
+ .then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
34
+ .then(injectSource(keywordImport, prepend(), toValidatorFile))
35
+ .then(injectSource(keywordTemplate, append(), toValidatorFile));
40
36
  //# sourceMappingURL=mongodb.tpl.js.map