@feathersjs/cli 5.0.0-pre.28 → 5.0.0-pre.30

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 (155) hide show
  1. package/CHANGELOG.md +28 -28
  2. package/bin/feathers +3 -6
  3. package/lib/app/index.js +34 -11
  4. package/lib/app/index.js.map +1 -1
  5. package/lib/app/index.ts +81 -53
  6. package/lib/app/templates/app.test.tpl.js +1 -1
  7. package/lib/app/templates/app.test.tpl.js.map +1 -1
  8. package/lib/app/templates/app.test.tpl.ts +1 -2
  9. package/lib/app/templates/app.tpl.js +24 -12
  10. package/lib/app/templates/app.tpl.js.map +1 -1
  11. package/lib/app/templates/app.tpl.ts +28 -14
  12. package/lib/app/templates/channels.tpl.js +1 -1
  13. package/lib/app/templates/channels.tpl.js.map +1 -1
  14. package/lib/app/templates/channels.tpl.ts +1 -2
  15. package/lib/app/templates/client.tpl.js +3 -3
  16. package/lib/app/templates/client.tpl.js.map +1 -1
  17. package/lib/app/templates/client.tpl.ts +3 -4
  18. package/lib/app/templates/config.tpl.js +10 -1
  19. package/lib/app/templates/config.tpl.js.map +1 -1
  20. package/lib/app/templates/config.tpl.ts +10 -0
  21. package/lib/app/templates/declarations.tpl.js +3 -3
  22. package/lib/app/templates/declarations.tpl.js.map +1 -1
  23. package/lib/app/templates/declarations.tpl.ts +5 -4
  24. package/lib/app/templates/index.html.tpl.js +12 -52
  25. package/lib/app/templates/index.html.tpl.js.map +1 -1
  26. package/lib/app/templates/index.html.tpl.ts +12 -53
  27. package/lib/app/templates/index.tpl.js +1 -1
  28. package/lib/app/templates/index.tpl.js.map +1 -1
  29. package/lib/app/templates/index.tpl.ts +1 -2
  30. package/lib/app/templates/logger.tpl.js +1 -1
  31. package/lib/app/templates/logger.tpl.js.map +1 -1
  32. package/lib/app/templates/logger.tpl.ts +2 -2
  33. package/lib/app/templates/package.json.tpl.js +4 -3
  34. package/lib/app/templates/package.json.tpl.js.map +1 -1
  35. package/lib/app/templates/package.json.tpl.ts +5 -3
  36. package/lib/app/templates/readme.md.tpl.js +11 -7
  37. package/lib/app/templates/readme.md.tpl.js.map +1 -1
  38. package/lib/app/templates/readme.md.tpl.ts +15 -8
  39. package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
  40. package/lib/app/templates/schemas.tpl.js +76 -0
  41. package/lib/app/templates/schemas.tpl.js.map +1 -0
  42. package/lib/app/templates/schemas.tpl.ts +90 -0
  43. package/lib/app/templates/services.tpl.js +1 -1
  44. package/lib/app/templates/services.tpl.js.map +1 -1
  45. package/lib/app/templates/services.tpl.ts +1 -2
  46. package/lib/authentication/index.d.ts +4 -3
  47. package/lib/authentication/index.js +12 -3
  48. package/lib/authentication/index.js.map +1 -1
  49. package/lib/authentication/index.ts +23 -5
  50. package/lib/authentication/templates/authentication.tpl.js +4 -6
  51. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  52. package/lib/authentication/templates/authentication.tpl.ts +6 -9
  53. package/lib/authentication/templates/config.tpl.js +10 -6
  54. package/lib/authentication/templates/config.tpl.js.map +1 -1
  55. package/lib/authentication/templates/config.tpl.ts +40 -34
  56. package/lib/authentication/templates/declarations.tpl.js +3 -3
  57. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  58. package/lib/authentication/templates/declarations.tpl.ts +9 -4
  59. package/lib/authentication/templates/knex.tpl.js +5 -4
  60. package/lib/authentication/templates/knex.tpl.js.map +1 -1
  61. package/lib/authentication/templates/knex.tpl.ts +5 -4
  62. package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  63. package/lib/authentication/templates/schema.json.tpl.js +92 -0
  64. package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
  65. package/lib/authentication/templates/schema.json.tpl.ts +108 -0
  66. package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
  67. package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
  68. package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
  69. package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
  70. package/lib/authentication/templates/test.tpl.js +2 -2
  71. package/lib/authentication/templates/test.tpl.js.map +1 -1
  72. package/lib/authentication/templates/test.tpl.ts +6 -3
  73. package/lib/cli.d.ts +6 -0
  74. package/lib/cli.js +75 -0
  75. package/lib/cli.js.map +1 -0
  76. package/lib/cli.ts +68 -0
  77. package/lib/commons.d.ts +14 -1
  78. package/lib/commons.js +24 -4
  79. package/lib/commons.js.map +1 -1
  80. package/lib/commons.ts +29 -1
  81. package/lib/connection/index.d.ts +5 -3
  82. package/lib/connection/index.js +5 -3
  83. package/lib/connection/index.js.map +1 -1
  84. package/lib/connection/index.ts +19 -5
  85. package/lib/connection/templates/knex.tpl.js +2 -12
  86. package/lib/connection/templates/knex.tpl.js.map +1 -1
  87. package/lib/connection/templates/knex.tpl.ts +6 -20
  88. package/lib/connection/templates/mongodb.tpl.js +1 -3
  89. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  90. package/lib/connection/templates/mongodb.tpl.ts +1 -12
  91. package/lib/hook/index.d.ts +1 -1
  92. package/lib/hook/index.js +3 -0
  93. package/lib/hook/index.js.map +1 -1
  94. package/lib/hook/index.ts +3 -1
  95. package/lib/hook/templates/hook.tpl.js +2 -3
  96. package/lib/hook/templates/hook.tpl.js.map +1 -1
  97. package/lib/hook/templates/hook.tpl.ts +5 -3
  98. package/lib/index.d.ts +2 -16
  99. package/lib/index.js +16 -24
  100. package/lib/index.js.map +1 -1
  101. package/lib/index.ts +2 -28
  102. package/lib/service/index.d.ts +10 -2
  103. package/lib/service/index.js +79 -41
  104. package/lib/service/index.js.map +1 -1
  105. package/lib/service/index.ts +54 -6
  106. package/lib/service/templates/client.tpl.js +26 -6
  107. package/lib/service/templates/client.tpl.js.map +1 -1
  108. package/lib/service/templates/client.tpl.ts +41 -12
  109. package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  110. package/lib/service/templates/schema.json.tpl.js +73 -0
  111. package/lib/service/templates/schema.json.tpl.js.map +1 -0
  112. package/lib/service/templates/schema.json.tpl.ts +85 -0
  113. package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
  114. package/lib/service/templates/schema.typebox.tpl.js +58 -0
  115. package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
  116. package/lib/service/templates/schema.typebox.tpl.ts +70 -0
  117. package/lib/service/templates/service.tpl.d.ts +1 -0
  118. package/lib/service/templates/service.tpl.js +67 -15
  119. package/lib/service/templates/service.tpl.js.map +1 -1
  120. package/lib/service/templates/service.tpl.ts +98 -19
  121. package/lib/service/templates/test.tpl.js +1 -1
  122. package/lib/service/templates/test.tpl.js.map +1 -1
  123. package/lib/service/templates/test.tpl.ts +1 -2
  124. package/lib/service/type/custom.tpl.d.ts +1 -2
  125. package/lib/service/type/custom.tpl.js +32 -25
  126. package/lib/service/type/custom.tpl.js.map +1 -1
  127. package/lib/service/type/custom.tpl.ts +44 -35
  128. package/lib/service/type/knex.tpl.d.ts +1 -3
  129. package/lib/service/type/knex.tpl.js +33 -23
  130. package/lib/service/type/knex.tpl.js.map +1 -1
  131. package/lib/service/type/knex.tpl.ts +51 -29
  132. package/lib/service/type/mongodb.tpl.d.ts +1 -2
  133. package/lib/service/type/mongodb.tpl.js +30 -20
  134. package/lib/service/type/mongodb.tpl.js.map +1 -1
  135. package/lib/service/type/mongodb.tpl.ts +47 -29
  136. package/package.json +23 -24
  137. package/lib/app/templates/configuration.tpl.js +0 -39
  138. package/lib/app/templates/configuration.tpl.js.map +0 -1
  139. package/lib/app/templates/configuration.tpl.ts +0 -44
  140. package/lib/authentication/templates/user.resolver.tpl.js +0 -98
  141. package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
  142. package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
  143. package/lib/authentication/templates/user.schema.tpl.js +0 -79
  144. package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
  145. package/lib/authentication/templates/user.schema.tpl.ts +0 -87
  146. package/lib/service/templates/class.tpl.js +0 -63
  147. package/lib/service/templates/class.tpl.js.map +0 -1
  148. package/lib/service/templates/class.tpl.ts +0 -79
  149. package/lib/service/templates/resolver.tpl.js +0 -73
  150. package/lib/service/templates/resolver.tpl.js.map +0 -1
  151. package/lib/service/templates/resolver.tpl.ts +0 -78
  152. package/lib/service/templates/schema.tpl.d.ts +0 -2
  153. package/lib/service/templates/schema.tpl.js +0 -75
  154. package/lib/service/templates/schema.tpl.js.map +0 -1
  155. package/lib/service/templates/schema.tpl.ts +0 -80
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
- const template = ({ name, description }) => `# ${name}
5
+ const template = ({ name, description, language, database }) => /* md */ `# ${name}
6
6
 
7
7
  > ${description}
8
8
 
@@ -22,7 +22,13 @@ This project uses [Feathers](http://feathersjs.com). An open source framework fo
22
22
 
23
23
  3. Start your app
24
24
 
25
- \`\`\`
25
+ \`\`\`${language === 'ts'
26
+ ? `
27
+ npm run compile # Compile TypeScript source`
28
+ : ''}${database !== 'mongodb'
29
+ ? `
30
+ npm run migrate # Run migrations to set up the database`
31
+ : ''}
26
32
  npm start
27
33
  \`\`\`
28
34
 
@@ -32,13 +38,11 @@ Run \`npm test\` and all your tests in the \`test/\` directory will be run.
32
38
 
33
39
  ## Scaffolding
34
40
 
35
- Feathers has a powerful command line interface. Here are a few things it can do:
41
+ This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
36
42
 
37
43
  \`\`\`
38
- $ npm install -g @feathersjs/cli # Install Feathers CLI
39
-
40
- $ feathers generate service # Generate a new Service
41
- $ feathers help # Show all commands
44
+ $ npx feathers help # Show all commands
45
+ $ npx feathers generate service # Generate a new Service
42
46
  \`\`\`
43
47
 
44
48
  ## Help
@@ -1 +1 @@
1
- {"version":3,"file":"readme.md.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/readme.md.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAGtE,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAuB,EAAE,EAAE,CAC9D,KAAK,IAAI;;IAEP,WAAW;;;;;;;;;;;;iBAYE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BpB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,uBAAc,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AADvD,QAAA,QAAQ,YAC+C"}
1
+ {"version":3,"file":"readme.md.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/readme.md.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAGtE,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI;;IAEnG,WAAW;;;;;;;;;;;;iBAYE,IAAI;;;;;;YAOf,QAAQ,KAAK,IAAI;IACf,CAAC,CAAC;gDACsC;IACxC,CAAC,CAAC,EACN,GACF,QAAQ,KAAK,SAAS;IACpB,CAAC,CAAC;4DACsD;IACxD,CAAC,CAAC,EACN;;;;;;;;;;;;;;;;;;;;CAoBC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,uBAAc,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AADvD,QAAA,QAAQ,YAC+C"}
@@ -1,8 +1,7 @@
1
1
  import { generator, renderTemplate, toFile } from '@feathershq/pinion'
2
2
  import { AppGeneratorContext } from '../index'
3
3
 
4
- const template = ({ name, description }: AppGeneratorContext) =>
5
- `# ${name}
4
+ const template = ({ name, description, language, database }: AppGeneratorContext) => /* md */ `# ${name}
6
5
 
7
6
  > ${description}
8
7
 
@@ -22,7 +21,17 @@ This project uses [Feathers](http://feathersjs.com). An open source framework fo
22
21
 
23
22
  3. Start your app
24
23
 
25
- \`\`\`
24
+ \`\`\`${
25
+ language === 'ts'
26
+ ? `
27
+ npm run compile # Compile TypeScript source`
28
+ : ''
29
+ }${
30
+ database !== 'mongodb'
31
+ ? `
32
+ npm run migrate # Run migrations to set up the database`
33
+ : ''
34
+ }
26
35
  npm start
27
36
  \`\`\`
28
37
 
@@ -32,13 +41,11 @@ Run \`npm test\` and all your tests in the \`test/\` directory will be run.
32
41
 
33
42
  ## Scaffolding
34
43
 
35
- Feathers has a powerful command line interface. Here are a few things it can do:
44
+ This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
36
45
 
37
46
  \`\`\`
38
- $ npm install -g @feathersjs/cli # Install Feathers CLI
39
-
40
- $ feathers generate service # Generate a new Service
41
- $ feathers help # Show all commands
47
+ $ npx feathers help # Show all commands
48
+ $ npx feathers generate service # Generate a new Service
42
49
  \`\`\`
43
50
 
44
51
  ## Help
@@ -0,0 +1,76 @@
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 validatorTemplate = /* ts */ `import { Ajv, addFormats } from '@feathersjs/schema'
7
+ import type { FormatsPluginOptions } from '@feathersjs/schema'
8
+
9
+ const formats: FormatsPluginOptions = [
10
+ 'date-time',
11
+ 'time',
12
+ 'date',
13
+ 'email',
14
+ 'hostname',
15
+ 'ipv4',
16
+ 'ipv6',
17
+ 'uri',
18
+ 'uri-reference',
19
+ 'uuid',
20
+ 'uri-template',
21
+ 'json-pointer',
22
+ 'relative-json-pointer',
23
+ 'regex'
24
+ ]
25
+
26
+ export const dataValidator = addFormats(new Ajv({}), formats)
27
+
28
+ export const queryValidator = addFormats(new Ajv({
29
+ coerceTypes: true
30
+ }), formats)
31
+ `;
32
+ const configurationJsonTemplate = ({}) => /* ts */ `import { defaultAppSettings, jsonSchema } from '@feathersjs/schema'
33
+ import type { FromSchema } from '@feathersjs/schema'
34
+
35
+ import { dataValidator } from './validators'
36
+
37
+ export const configurationSchema = {
38
+ type: 'object',
39
+ additionalProperties: false,
40
+ required: [ 'host', 'port', 'public' ],
41
+ properties: {
42
+ ...defaultAppSettings,
43
+ host: { type: 'string' },
44
+ port: { type: 'number' },
45
+ public: { type: 'string' }
46
+ }
47
+ } as const
48
+
49
+ export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
50
+
51
+ export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
52
+ `;
53
+ const configurationTypeboxTemplate = ({}) => /* ts */ `import { jsonSchema } from '@feathersjs/schema'
54
+ import { Type, defaultAppConfiguration } from '@feathersjs/typebox'
55
+ import type { Static } from '@feathersjs/typebox'
56
+
57
+ import { dataValidator } from './validators'
58
+
59
+ export const configurationSchema = Type.Intersect([
60
+ defaultAppConfiguration,
61
+ Type.Object({
62
+ host: Type.String(),
63
+ port: Type.Number(),
64
+ public: Type.String()
65
+ })
66
+ ])
67
+
68
+ export type ApplicationConfiguration = Static<typeof configurationSchema>
69
+
70
+ export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
71
+ `;
72
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
73
+ .then((0, commons_1.renderSource)(async (ctx) => ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx), (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'configuration')))
74
+ .then((0, commons_1.renderSource)(validatorTemplate, (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'validators')));
75
+ exports.generate = generate;
76
+ //# sourceMappingURL=schemas.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/schemas.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlC,CAAA;AAED,MAAM,yBAAyB,GAC7B,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAA;AAED,MAAM,4BAA4B,GAChC,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;CAkBvC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,KAAK,EAAE,GAAG,EAAE,EAAE,CACZ,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,EAC/F,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,CAAC,CAC1E,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,CACvE,CACF,CAAA;AAdQ,QAAA,QAAQ,YAchB"}
@@ -0,0 +1,90 @@
1
+ import { generator, toFile } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
+ import { AppGeneratorContext } from '../index'
4
+
5
+ const validatorTemplate = /* ts */ `import { Ajv, addFormats } from '@feathersjs/schema'
6
+ import type { FormatsPluginOptions } from '@feathersjs/schema'
7
+
8
+ const formats: FormatsPluginOptions = [
9
+ 'date-time',
10
+ 'time',
11
+ 'date',
12
+ 'email',
13
+ 'hostname',
14
+ 'ipv4',
15
+ 'ipv6',
16
+ 'uri',
17
+ 'uri-reference',
18
+ 'uuid',
19
+ 'uri-template',
20
+ 'json-pointer',
21
+ 'relative-json-pointer',
22
+ 'regex'
23
+ ]
24
+
25
+ export const dataValidator = addFormats(new Ajv({}), formats)
26
+
27
+ export const queryValidator = addFormats(new Ajv({
28
+ coerceTypes: true
29
+ }), formats)
30
+ `
31
+
32
+ const configurationJsonTemplate =
33
+ ({}: AppGeneratorContext) => /* ts */ `import { defaultAppSettings, jsonSchema } from '@feathersjs/schema'
34
+ import type { FromSchema } from '@feathersjs/schema'
35
+
36
+ import { dataValidator } from './validators'
37
+
38
+ export const configurationSchema = {
39
+ type: 'object',
40
+ additionalProperties: false,
41
+ required: [ 'host', 'port', 'public' ],
42
+ properties: {
43
+ ...defaultAppSettings,
44
+ host: { type: 'string' },
45
+ port: { type: 'number' },
46
+ public: { type: 'string' }
47
+ }
48
+ } as const
49
+
50
+ export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
51
+
52
+ export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
53
+ `
54
+
55
+ const configurationTypeboxTemplate =
56
+ ({}: AppGeneratorContext) => /* ts */ `import { jsonSchema } from '@feathersjs/schema'
57
+ import { Type, defaultAppConfiguration } from '@feathersjs/typebox'
58
+ import type { Static } from '@feathersjs/typebox'
59
+
60
+ import { dataValidator } from './validators'
61
+
62
+ export const configurationSchema = Type.Intersect([
63
+ defaultAppConfiguration,
64
+ Type.Object({
65
+ host: Type.String(),
66
+ port: Type.Number(),
67
+ public: Type.String()
68
+ })
69
+ ])
70
+
71
+ export type ApplicationConfiguration = Static<typeof configurationSchema>
72
+
73
+ export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
74
+ `
75
+
76
+ export const generate = (ctx: AppGeneratorContext) =>
77
+ generator(ctx)
78
+ .then(
79
+ renderSource(
80
+ async (ctx) =>
81
+ ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx),
82
+ toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'configuration')
83
+ )
84
+ )
85
+ .then(
86
+ renderSource(
87
+ validatorTemplate,
88
+ toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'validators')
89
+ )
90
+ )
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({}) => `import type { Application } from '../declarations'
6
+ const template = ({}) => /* ts */ `import type { Application } from '../declarations'
7
7
 
8
8
  export const services = (app: Application) => {
9
9
  // All services will be registered here
@@ -1 +1 @@
1
- {"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAC3C;;;;;CAKD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CACnE,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
1
+ {"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;CAKtD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CACnE,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
@@ -2,8 +2,7 @@ import { generator, toFile } from '@feathershq/pinion'
2
2
  import { renderSource } from '../../commons'
3
3
  import { AppGeneratorContext } from '../index'
4
4
 
5
- const template = ({}: AppGeneratorContext) =>
6
- `import type { Application } from '../declarations'
5
+ const template = ({}: AppGeneratorContext) => /* ts */ `import type { Application } from '../declarations'
7
6
 
8
7
  export const services = (app: Application) => {
9
8
  // All services will be registered here
@@ -6,7 +6,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
6
6
  authStrategies: string[];
7
7
  dependencies: string[];
8
8
  }
9
- export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>;
9
+ export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>;
10
10
  export declare const prompts: (ctx: AuthenticationGeneratorArguments) => ({
11
11
  type: string;
12
12
  name: string;
@@ -51,14 +51,15 @@ export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promis
51
51
  kebabName: string;
52
52
  fileName: string;
53
53
  relative: string;
54
- type: "custom" | "mongodb" | "knex";
54
+ type: "mongodb" | "knex" | "custom";
55
+ schema: false | "typebox" | "json";
55
56
  authentication: boolean;
56
57
  isEntityService?: boolean;
57
58
  feathers: import("../commons").FeathersAppInfo;
58
59
  pkg: import("../commons").AppPackageJson;
59
60
  lib: string;
60
61
  test: string;
61
- language: "js" | "ts";
62
+ language: "ts" | "js";
62
63
  dependencyVersions?: import("../commons").DependencyVersions;
63
64
  cwd: string;
64
65
  _?: (string | number)[];
@@ -48,6 +48,13 @@ const prompts = (ctx) => [
48
48
  type: 'input',
49
49
  when: !ctx.service,
50
50
  message: 'What is your authentication service name?',
51
+ default: 'user'
52
+ },
53
+ {
54
+ name: 'path',
55
+ type: 'input',
56
+ when: !ctx.path,
57
+ message: 'What path should the service be registered on?',
51
58
  default: 'users'
52
59
  },
53
60
  {
@@ -61,14 +68,16 @@ const prompts = (ctx) => [
61
68
  ];
62
69
  exports.prompts = prompts;
63
70
  const generate = (ctx) => (0, pinion_1.generator)(ctx)
71
+ .then((0, commons_1.initializeBaseContext)())
72
+ .then((0, commons_1.checkPreconditions)())
64
73
  .then((0, pinion_1.prompt)(exports.prompts))
65
74
  .then(async (ctx) => {
75
+ var _a;
66
76
  const serviceContext = await (0, index_1.generate)({
67
77
  ...ctx,
68
78
  name: ctx.service,
69
- path: ctx.service,
70
79
  isEntityService: true,
71
- type: (0, commons_1.getDatabaseAdapter)(ctx.feathers.database)
80
+ type: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database)
72
81
  });
73
82
  return {
74
83
  ...ctx,
@@ -88,7 +97,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
88
97
  dependencies: [...ctx.dependencies, ...dependencies]
89
98
  };
90
99
  }
91
- return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions))(ctx);
100
+ return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
92
101
  });
93
102
  exports.generate = generate;
94
103
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+CAA8E;AAC9E,wCAAiF;AACjF,4CAAwF;AAYjF,MAAM,OAAO,GAAG,CAAC,GAAqC,EAAE,EAAE,CAAC;IAChE;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,C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,MAAM,cAAc,GAAG,MAAM,IAAA,gBAAgB,EAAC;QAC5C,GAAG,GAAG;QACN,IAAI,EAAE,GAAG,CAAC,OAAO;QACjB,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE,IAAA,4BAAkB,EAAC,MAAA,GAAG,CAAC,QAAQ,0CAAE,QAAQ,CAAC;KACjD,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,GAAG;QACN,GAAG,cAAc;KAClB,CAAA;AACH,CAAC,CAAC;KACD,IAAI,CAAC,IAAA,sBAAa,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KAC3C,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,MAAM,YAAY,GAAa,EAAE,CAAA;IAEjC,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;IAErD,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACxC,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;KACtD;IAED,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,OAAO;YACL,GAAG,GAAG;YACN,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC;SACrD,CAAA;KACF;IAED,OAAO,IAAA,gBAAO,EACZ,IAAA,qBAAW,EAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjD,KAAK,EACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACtB,CAAC,GAAG,CAAC,CAAA;AACR,CAAC,CAAC,CAAA;AAxCO,QAAA,QAAQ,YAwCf"}
@@ -1,6 +1,12 @@
1
1
  import chalk from 'chalk'
2
2
  import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
3
- import { addVersions, FeathersBaseContext, getDatabaseAdapter } from '../commons'
3
+ import {
4
+ addVersions,
5
+ checkPreconditions,
6
+ FeathersBaseContext,
7
+ getDatabaseAdapter,
8
+ initializeBaseContext
9
+ } from '../commons'
4
10
  import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
5
11
 
6
12
  export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
@@ -11,7 +17,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
11
17
  }
12
18
 
13
19
  export type AuthenticationGeneratorArguments = FeathersBaseContext &
14
- Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>
20
+ Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>
15
21
 
16
22
  export const prompts = (ctx: AuthenticationGeneratorArguments) => [
17
23
  {
@@ -53,6 +59,13 @@ export const prompts = (ctx: AuthenticationGeneratorArguments) => [
53
59
  type: 'input',
54
60
  when: !ctx.service,
55
61
  message: 'What is your authentication service name?',
62
+ default: 'user'
63
+ },
64
+ {
65
+ name: 'path',
66
+ type: 'input',
67
+ when: !ctx.path,
68
+ message: 'What path should the service be registered on?',
56
69
  default: 'users'
57
70
  },
58
71
  {
@@ -67,14 +80,15 @@ export const prompts = (ctx: AuthenticationGeneratorArguments) => [
67
80
 
68
81
  export const generate = (ctx: AuthenticationGeneratorArguments) =>
69
82
  generator(ctx)
83
+ .then(initializeBaseContext())
84
+ .then(checkPreconditions())
70
85
  .then(prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(prompts))
71
86
  .then(async (ctx) => {
72
87
  const serviceContext = await serviceGenerator({
73
88
  ...ctx,
74
89
  name: ctx.service,
75
- path: ctx.service,
76
90
  isEntityService: true,
77
- type: getDatabaseAdapter(ctx.feathers.database)
91
+ type: getDatabaseAdapter(ctx.feathers?.database)
78
92
  })
79
93
 
80
94
  return {
@@ -99,5 +113,9 @@ export const generate = (ctx: AuthenticationGeneratorArguments) =>
99
113
  }
100
114
  }
101
115
 
102
- return install<AuthenticationGeneratorContext>(addVersions(dependencies, ctx.dependencyVersions))(ctx)
116
+ return install<AuthenticationGeneratorContext>(
117
+ addVersions(dependencies, ctx.dependencyVersions),
118
+ false,
119
+ ctx.feathers.packager
120
+ )(ctx)
103
121
  })
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generate = void 0;
4
4
  const pinion_1 = require("@feathershq/pinion");
5
5
  const commons_1 = require("../../commons");
6
- const template = ({ authStrategies, feathers }) => `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
6
+ const template = ({ authStrategies }) => /* ts */ `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
7
7
  import { LocalStrategy } from '@feathersjs/authentication-local'
8
8
  import { OAuthStrategy } from '@feathersjs/authentication-oauth'
9
- ${feathers.framework === 'express' ? `import { expressOauth } from '@feathersjs/authentication-oauth'` : ''}
9
+ import { oauth } from '@feathersjs/authentication-oauth'
10
10
  import type { Application } from './declarations'
11
11
 
12
12
  declare module './declarations' {
@@ -23,10 +23,8 @@ export const authentication = (app: Application) => {
23
23
  .map((strategy) => ` authentication.register('${strategy}', ${strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`})`)
24
24
  .join('\n')}
25
25
 
26
- app.use('authentication', authentication)${feathers.framework === 'express'
27
- ? `
28
- app.configure(expressOauth())`
29
- : ''}
26
+ app.use('authentication', authentication)
27
+ app.configure(oauth())
30
28
  }
31
29
  `;
32
30
  const importTemplate = "import { authentication } from './authentication'";
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAG1D,MAAM,QAAQ,GAAG,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAChF;;;EAGA,QAAQ,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,iEAAiE,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;IAavG,cAAc;KACb,GAAG,CACF,CAAC,QAAQ,EAAE,EAAE,CACX,8BAA8B,QAAQ,MACpC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBACjD,GAAG,CACN;KACA,IAAI,CAAC,IAAI,CAAC;;6CAGX,QAAQ,CAAC,SAAS,KAAK,SAAS;IAC9B,CAAC,CAAC;gCACwB;IAC1B,CAAC,CAAC,EACN;;CAED,CAAA;AAED,MAAM,cAAc,GAAG,mDAAmD,CAAA;AAC1E,MAAM,iBAAiB,GAAG,+BAA+B,CAAA;AACzD,MAAM,SAAS,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAE5E,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
1
+ {"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAG1D,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;IAgB3C,cAAc;KACb,GAAG,CACF,CAAC,QAAQ,EAAE,EAAE,CACX,8BAA8B,QAAQ,MACpC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBACjD,GAAG,CACN;KACA,IAAI,CAAC,IAAI,CAAC;;;;;CAKd,CAAA;AAED,MAAM,cAAc,GAAG,mDAAmD,CAAA;AAC1E,MAAM,iBAAiB,GAAG,+BAA+B,CAAA;AACzD,MAAM,SAAS,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAE5E,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
@@ -2,11 +2,12 @@ import { generator, before, toFile } from '@feathershq/pinion'
2
2
  import { injectSource, renderSource } from '../../commons'
3
3
  import { AuthenticationGeneratorContext } from '../index'
4
4
 
5
- const template = ({ authStrategies, feathers }: AuthenticationGeneratorContext) =>
6
- `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
5
+ const template = ({
6
+ authStrategies
7
+ }: AuthenticationGeneratorContext) => /* ts */ `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
7
8
  import { LocalStrategy } from '@feathersjs/authentication-local'
8
9
  import { OAuthStrategy } from '@feathersjs/authentication-oauth'
9
- ${feathers.framework === 'express' ? `import { expressOauth } from '@feathersjs/authentication-oauth'` : ''}
10
+ import { oauth } from '@feathersjs/authentication-oauth'
10
11
  import type { Application } from './declarations'
11
12
 
12
13
  declare module './declarations' {
@@ -28,12 +29,8 @@ export const authentication = (app: Application) => {
28
29
  )
29
30
  .join('\n')}
30
31
 
31
- app.use('authentication', authentication)${
32
- feathers.framework === 'express'
33
- ? `
34
- app.configure(expressOauth())`
35
- : ''
36
- }
32
+ app.use('authentication', authentication)
33
+ app.configure(oauth())
37
34
  }
38
35
  `
39
36
 
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generate = void 0;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
8
  const pinion_1 = require("@feathershq/pinion");
9
- const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.mergeJSON)(({ authStrategies }) => {
9
+ const generate = (ctx) => (0, pinion_1.generator)(ctx)
10
+ .then((0, pinion_1.mergeJSON)(({ authStrategies }) => {
10
11
  const authentication = {
11
12
  entity: ctx.entity,
12
- service: ctx.service,
13
+ service: ctx.path,
13
14
  secret: crypto_1.default.randomBytes(24).toString('base64'),
14
15
  authStrategies: ['jwt'],
15
16
  jwtOptions: {
@@ -36,11 +37,14 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.mergeJS
36
37
  secret: '<Client secret>'
37
38
  };
38
39
  return oauth;
39
- }, {
40
- redirect: '/'
41
- });
40
+ }, {});
42
41
  }
43
42
  return { authentication };
44
- }, (0, pinion_1.toFile)('config', 'default.json')));
43
+ }, (0, pinion_1.toFile)('config', 'default.json')))
44
+ .then((0, pinion_1.mergeJSON)({
45
+ authentication: {
46
+ secret: 'FEATHERS_SECRET'
47
+ }
48
+ }, (0, pinion_1.toFile)('config', 'custom-environment-variables.json')));
45
49
  exports.generate = generate;
46
50
  //# sourceMappingURL=config.tpl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/config.tpl.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC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IAAI,CAAC,GAAG;gBACZ,GAAG,EAAE,aAAa;gBAClB,MAAM,EAAE,iBAAiB;aAC1B,CAAA;YAED,OAAO,KAAK,CAAA;QACd,CAAC,EAAE,EAAS,CAAC,CAAA;KACd;IAED,OAAO,EAAE,cAAc,EAAE,CAAA;AAC3B,CAAC,EAAE,IAAA,eAAM,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CACrC;KACA,IAAI,CACH,IAAA,kBAAS,EACP;IACE,cAAc,EAAE;QACd,MAAM,EAAE,iBAAiB;KAC1B;CACF,EACD,IAAA,eAAM,EAAC,QAAQ,EAAE,mCAAmC,CAAC,CACtD,CACF,CAAA;AApDQ,QAAA,QAAQ,YAoDhB"}
@@ -3,49 +3,55 @@ import { generator, toFile, mergeJSON } from '@feathershq/pinion'
3
3
  import { AuthenticationGeneratorContext } from '../index'
4
4
 
5
5
  export const generate = (ctx: AuthenticationGeneratorContext) =>
6
- generator(ctx).then(
7
- mergeJSON<AuthenticationGeneratorContext>(({ authStrategies }) => {
8
- const authentication: any = {
9
- entity: ctx.entity,
10
- service: ctx.service,
11
- secret: crypto.randomBytes(24).toString('base64'),
12
- authStrategies: ['jwt'],
13
- jwtOptions: {
14
- header: {
15
- typ: 'access'
16
- },
17
- audience: 'https://yourdomain.com',
18
- algorithm: 'HS256',
19
- expiresIn: '1d'
6
+ generator(ctx)
7
+ .then(
8
+ mergeJSON<AuthenticationGeneratorContext>(({ authStrategies }) => {
9
+ const authentication: any = {
10
+ entity: ctx.entity,
11
+ service: ctx.path,
12
+ secret: crypto.randomBytes(24).toString('base64'),
13
+ authStrategies: ['jwt'],
14
+ jwtOptions: {
15
+ header: {
16
+ typ: 'access'
17
+ },
18
+ audience: 'https://yourdomain.com',
19
+ algorithm: 'HS256',
20
+ expiresIn: '1d'
21
+ }
20
22
  }
21
- }
22
23
 
23
- if (authStrategies.includes('local')) {
24
- authentication.authStrategies.push('local')
25
- authentication.local = {
26
- usernameField: 'email',
27
- passwordField: 'password'
24
+ if (authStrategies.includes('local')) {
25
+ authentication.authStrategies.push('local')
26
+ authentication.local = {
27
+ usernameField: 'email',
28
+ passwordField: 'password'
29
+ }
28
30
  }
29
- }
30
31
 
31
- const oauthStrategies = authStrategies.filter((name) => name !== 'local')
32
+ const oauthStrategies = authStrategies.filter((name) => name !== 'local')
32
33
 
33
- if (oauthStrategies.length) {
34
- authentication.oauth = oauthStrategies.reduce(
35
- (oauth, name) => {
34
+ if (oauthStrategies.length) {
35
+ authentication.oauth = oauthStrategies.reduce((oauth, name) => {
36
36
  oauth[name] = {
37
37
  key: '<Client ID>',
38
38
  secret: '<Client secret>'
39
39
  }
40
40
 
41
41
  return oauth
42
- },
43
- {
44
- redirect: '/'
45
- } as any
46
- )
47
- }
42
+ }, {} as any)
43
+ }
48
44
 
49
- return { authentication }
50
- }, toFile('config', 'default.json'))
51
- )
45
+ return { authentication }
46
+ }, toFile('config', 'default.json'))
47
+ )
48
+ .then(
49
+ mergeJSON<AuthenticationGeneratorContext>(
50
+ {
51
+ authentication: {
52
+ secret: 'FEATHERS_SECRET'
53
+ }
54
+ },
55
+ toFile('config', 'custom-environment-variables.json')
56
+ )
57
+ )