@feathersjs/cli 5.0.0-pre.29 → 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 (152) hide show
  1. package/CHANGELOG.md +25 -39
  2. package/bin/feathers +3 -6
  3. package/lib/app/index.js +33 -10
  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 +7 -7
  10. package/lib/app/templates/app.tpl.js.map +1 -1
  11. package/lib/app/templates/app.tpl.ts +7 -9
  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 +2 -2
  16. package/lib/app/templates/client.tpl.js.map +1 -1
  17. package/lib/app/templates/client.tpl.ts +2 -3
  18. package/lib/app/templates/declarations.tpl.js +3 -3
  19. package/lib/app/templates/declarations.tpl.js.map +1 -1
  20. package/lib/app/templates/declarations.tpl.ts +5 -4
  21. package/lib/app/templates/index.html.tpl.js +12 -52
  22. package/lib/app/templates/index.html.tpl.js.map +1 -1
  23. package/lib/app/templates/index.html.tpl.ts +12 -53
  24. package/lib/app/templates/index.tpl.js +1 -1
  25. package/lib/app/templates/index.tpl.js.map +1 -1
  26. package/lib/app/templates/index.tpl.ts +1 -2
  27. package/lib/app/templates/logger.tpl.js +1 -1
  28. package/lib/app/templates/logger.tpl.js.map +1 -1
  29. package/lib/app/templates/logger.tpl.ts +2 -2
  30. package/lib/app/templates/package.json.tpl.js +4 -3
  31. package/lib/app/templates/package.json.tpl.js.map +1 -1
  32. package/lib/app/templates/package.json.tpl.ts +5 -3
  33. package/lib/app/templates/readme.md.tpl.js +11 -7
  34. package/lib/app/templates/readme.md.tpl.js.map +1 -1
  35. package/lib/app/templates/readme.md.tpl.ts +15 -8
  36. package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
  37. package/lib/app/templates/schemas.tpl.js +76 -0
  38. package/lib/app/templates/schemas.tpl.js.map +1 -0
  39. package/lib/app/templates/schemas.tpl.ts +90 -0
  40. package/lib/app/templates/services.tpl.js +1 -1
  41. package/lib/app/templates/services.tpl.js.map +1 -1
  42. package/lib/app/templates/services.tpl.ts +1 -2
  43. package/lib/authentication/index.d.ts +4 -3
  44. package/lib/authentication/index.js +12 -3
  45. package/lib/authentication/index.js.map +1 -1
  46. package/lib/authentication/index.ts +23 -5
  47. package/lib/authentication/templates/authentication.tpl.js +1 -1
  48. package/lib/authentication/templates/authentication.tpl.js.map +1 -1
  49. package/lib/authentication/templates/authentication.tpl.ts +3 -2
  50. package/lib/authentication/templates/config.tpl.js +1 -1
  51. package/lib/authentication/templates/config.tpl.js.map +1 -1
  52. package/lib/authentication/templates/config.tpl.ts +1 -1
  53. package/lib/authentication/templates/declarations.tpl.js +3 -3
  54. package/lib/authentication/templates/declarations.tpl.js.map +1 -1
  55. package/lib/authentication/templates/declarations.tpl.ts +9 -4
  56. package/lib/authentication/templates/knex.tpl.js +2 -2
  57. package/lib/authentication/templates/knex.tpl.js.map +1 -1
  58. package/lib/authentication/templates/knex.tpl.ts +2 -2
  59. package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  60. package/lib/authentication/templates/schema.json.tpl.js +92 -0
  61. package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
  62. package/lib/authentication/templates/schema.json.tpl.ts +108 -0
  63. package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
  64. package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
  65. package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
  66. package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
  67. package/lib/authentication/templates/test.tpl.js +2 -2
  68. package/lib/authentication/templates/test.tpl.js.map +1 -1
  69. package/lib/authentication/templates/test.tpl.ts +6 -3
  70. package/lib/cli.d.ts +6 -0
  71. package/lib/cli.js +75 -0
  72. package/lib/cli.js.map +1 -0
  73. package/lib/cli.ts +68 -0
  74. package/lib/commons.d.ts +14 -1
  75. package/lib/commons.js +24 -4
  76. package/lib/commons.js.map +1 -1
  77. package/lib/commons.ts +29 -1
  78. package/lib/connection/index.d.ts +5 -3
  79. package/lib/connection/index.js +5 -3
  80. package/lib/connection/index.js.map +1 -1
  81. package/lib/connection/index.ts +19 -5
  82. package/lib/connection/templates/knex.tpl.js +2 -12
  83. package/lib/connection/templates/knex.tpl.js.map +1 -1
  84. package/lib/connection/templates/knex.tpl.ts +6 -20
  85. package/lib/connection/templates/mongodb.tpl.js +1 -3
  86. package/lib/connection/templates/mongodb.tpl.js.map +1 -1
  87. package/lib/connection/templates/mongodb.tpl.ts +1 -12
  88. package/lib/hook/index.d.ts +1 -1
  89. package/lib/hook/index.js +3 -0
  90. package/lib/hook/index.js.map +1 -1
  91. package/lib/hook/index.ts +3 -1
  92. package/lib/hook/templates/hook.tpl.js +2 -3
  93. package/lib/hook/templates/hook.tpl.js.map +1 -1
  94. package/lib/hook/templates/hook.tpl.ts +5 -3
  95. package/lib/index.d.ts +2 -16
  96. package/lib/index.js +16 -24
  97. package/lib/index.js.map +1 -1
  98. package/lib/index.ts +2 -28
  99. package/lib/service/index.d.ts +10 -2
  100. package/lib/service/index.js +79 -41
  101. package/lib/service/index.js.map +1 -1
  102. package/lib/service/index.ts +54 -6
  103. package/lib/service/templates/client.tpl.js +19 -11
  104. package/lib/service/templates/client.tpl.js.map +1 -1
  105. package/lib/service/templates/client.tpl.ts +34 -17
  106. package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
  107. package/lib/service/templates/schema.json.tpl.js +73 -0
  108. package/lib/service/templates/schema.json.tpl.js.map +1 -0
  109. package/lib/service/templates/schema.json.tpl.ts +85 -0
  110. package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
  111. package/lib/service/templates/schema.typebox.tpl.js +58 -0
  112. package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
  113. package/lib/service/templates/schema.typebox.tpl.ts +70 -0
  114. package/lib/service/templates/service.tpl.d.ts +1 -0
  115. package/lib/service/templates/service.tpl.js +67 -15
  116. package/lib/service/templates/service.tpl.js.map +1 -1
  117. package/lib/service/templates/service.tpl.ts +98 -19
  118. package/lib/service/templates/test.tpl.js +1 -1
  119. package/lib/service/templates/test.tpl.js.map +1 -1
  120. package/lib/service/templates/test.tpl.ts +1 -2
  121. package/lib/service/type/custom.tpl.d.ts +1 -2
  122. package/lib/service/type/custom.tpl.js +32 -25
  123. package/lib/service/type/custom.tpl.js.map +1 -1
  124. package/lib/service/type/custom.tpl.ts +44 -35
  125. package/lib/service/type/knex.tpl.d.ts +1 -3
  126. package/lib/service/type/knex.tpl.js +33 -23
  127. package/lib/service/type/knex.tpl.js.map +1 -1
  128. package/lib/service/type/knex.tpl.ts +51 -29
  129. package/lib/service/type/mongodb.tpl.d.ts +1 -2
  130. package/lib/service/type/mongodb.tpl.js +30 -20
  131. package/lib/service/type/mongodb.tpl.js.map +1 -1
  132. package/lib/service/type/mongodb.tpl.ts +47 -29
  133. package/package.json +22 -23
  134. package/lib/app/templates/configuration.tpl.js +0 -45
  135. package/lib/app/templates/configuration.tpl.js.map +0 -1
  136. package/lib/app/templates/configuration.tpl.ts +0 -50
  137. package/lib/authentication/templates/user.resolver.tpl.js +0 -98
  138. package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
  139. package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
  140. package/lib/authentication/templates/user.schema.tpl.js +0 -79
  141. package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
  142. package/lib/authentication/templates/user.schema.tpl.ts +0 -87
  143. package/lib/service/templates/class.tpl.js +0 -63
  144. package/lib/service/templates/class.tpl.js.map +0 -1
  145. package/lib/service/templates/class.tpl.ts +0 -79
  146. package/lib/service/templates/resolver.tpl.js +0 -73
  147. package/lib/service/templates/resolver.tpl.js.map +0 -1
  148. package/lib/service/templates/resolver.tpl.ts +0 -78
  149. package/lib/service/templates/schema.tpl.d.ts +0 -2
  150. package/lib/service/templates/schema.tpl.js +0 -75
  151. package/lib/service/templates/schema.tpl.js.map +0 -1
  152. package/lib/service/templates/schema.tpl.ts +0 -80
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = exports.template = void 0;
4
+ const pinion_1 = require("@feathershq/pinion");
5
+ const commons_1 = require("../../commons");
6
+ const template = ({ camelName, upperName, authStrategies, type, relative }) => /* ts */ `import { jsonSchema, resolve } from '@feathersjs/schema'
7
+ import { Type, querySyntax } from '@feathersjs/typebox'
8
+ import type { Static } from '@feathersjs/typebox'
9
+ ${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
10
+
11
+ import type { HookContext } from '${relative}/declarations'
12
+ import { dataValidator, queryValidator } from '${relative}/schemas/validators'
13
+
14
+ // Schema for the basic data model (e.g. creating new entries)
15
+ export const ${camelName}DataSchema = Type.Object({
16
+ ${authStrategies
17
+ .map((name) => name === 'local'
18
+ ? ` email: Type.String(),
19
+ password: Type.String()`
20
+ : ` ${name}Id: Type.Optional(Type.String())`)
21
+ .join(',\n')}
22
+ }, { $id: '${upperName}Data', additionalProperties: false })
23
+ export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
24
+ export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
25
+ export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
26
+ properties: {
27
+ ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
28
+ }
29
+ })
30
+
31
+ // Schema for the data that is being returned
32
+ export const ${camelName}Schema = Type.Intersect([
33
+ ${camelName}DataSchema,
34
+ Type.Object({
35
+ ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'}
36
+ })
37
+ ], { $id: '${upperName}' })
38
+ export type ${upperName} = Static<typeof ${camelName}Schema>
39
+ export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
40
+ properties: {}
41
+ })
42
+
43
+ export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
44
+ properties: {
45
+ // The password should never be visible externally
46
+ password: async () => undefined
47
+ }
48
+ })
49
+
50
+ // Schema for allowed query properties
51
+ export const ${camelName}QuerySchema = Type.Intersect([
52
+ querySyntax(${camelName}Schema),
53
+ // Add additional query properties here
54
+ Type.Object({})
55
+ ])
56
+ export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
57
+ export const ${camelName}QueryValidator = jsonSchema.getValidator(${camelName}QuerySchema, queryValidator)
58
+ export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
59
+ properties: {
60
+ // If there is a user (e.g. with authentication), they are only allowed to see their own data
61
+ ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
62
+ if (context.params.user) {
63
+ return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
64
+ }
65
+
66
+ return value
67
+ }
68
+ }
69
+ })
70
+ `;
71
+ exports.template = template;
72
+ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ schema }) => schema === 'typebox', (0, commons_1.renderSource)(exports.template, (0, pinion_1.toFile)(({ lib, folder, fileName }) => [
73
+ lib,
74
+ 'services',
75
+ ...folder,
76
+ `${fileName}.schema`
77
+ ]), { force: true })));
78
+ exports.generate = generate;
79
+ //# sourceMappingURL=schema.typebox.tpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.typebox.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/schema.typebox.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAA4C;AAGrC,MAAM,QAAQ,GAAG,CAAC,EACvB,SAAS,EACT,SAAS,EACT,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M,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,EACpC,IAAA,sBAAY,EACV,gBAAQ,EACR,IAAA,eAAM,EAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAkC,EAAE,EAAE,CAAC;IACpE,GAAG;IACH,UAAU;IACV,GAAG,MAAM;IACT,GAAG,QAAQ,SAAS;CACrB,CAAC,EACF,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CACF,CAAA;AAfU,QAAA,QAAQ,YAelB"}
@@ -0,0 +1,94 @@
1
+ import { generator, toFile, when } from '@feathershq/pinion'
2
+ import { renderSource } from '../../commons'
3
+ import { AuthenticationGeneratorContext } from '../index'
4
+
5
+ export const template = ({
6
+ camelName,
7
+ upperName,
8
+ authStrategies,
9
+ type,
10
+ relative
11
+ }: AuthenticationGeneratorContext) => /* ts */ `import { jsonSchema, resolve } from '@feathersjs/schema'
12
+ import { Type, querySyntax } from '@feathersjs/typebox'
13
+ import type { Static } from '@feathersjs/typebox'
14
+ ${authStrategies.includes('local') ? `import { passwordHash } from '@feathersjs/authentication-local'` : ''}
15
+
16
+ import type { HookContext } from '${relative}/declarations'
17
+ import { dataValidator, queryValidator } from '${relative}/schemas/validators'
18
+
19
+ // Schema for the basic data model (e.g. creating new entries)
20
+ export const ${camelName}DataSchema = Type.Object({
21
+ ${authStrategies
22
+ .map((name) =>
23
+ name === 'local'
24
+ ? ` email: Type.String(),
25
+ password: Type.String()`
26
+ : ` ${name}Id: Type.Optional(Type.String())`
27
+ )
28
+ .join(',\n')}
29
+ }, { $id: '${upperName}Data', additionalProperties: false })
30
+ export type ${upperName}Data = Static<typeof ${camelName}DataSchema>
31
+ export const ${camelName}DataValidator = jsonSchema.getDataValidator(${camelName}DataSchema, dataValidator)
32
+ export const ${camelName}DataResolver = resolve<${upperName}Data, HookContext>({
33
+ properties: {
34
+ ${authStrategies.includes('local') ? `password: passwordHash({ strategy: 'local' })` : ''}
35
+ }
36
+ })
37
+
38
+ // Schema for the data that is being returned
39
+ export const ${camelName}Schema = Type.Intersect([
40
+ ${camelName}DataSchema,
41
+ Type.Object({
42
+ ${type === 'mongodb' ? '_id: Type.String()' : 'id: Type.Number()'}
43
+ })
44
+ ], { $id: '${upperName}' })
45
+ export type ${upperName} = Static<typeof ${camelName}Schema>
46
+ export const ${camelName}Resolver = resolve<${upperName}, HookContext>({
47
+ properties: {}
48
+ })
49
+
50
+ export const ${camelName}ExternalResolver = resolve<${upperName}, HookContext>({
51
+ properties: {
52
+ // The password should never be visible externally
53
+ password: async () => undefined
54
+ }
55
+ })
56
+
57
+ // Schema for allowed query properties
58
+ export const ${camelName}QuerySchema = Type.Intersect([
59
+ querySyntax(${camelName}Schema),
60
+ // Add additional query properties here
61
+ Type.Object({})
62
+ ])
63
+ export type ${upperName}Query = Static<typeof ${camelName}QuerySchema>
64
+ export const ${camelName}QueryValidator = jsonSchema.getValidator(${camelName}QuerySchema, queryValidator)
65
+ export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext>({
66
+ properties: {
67
+ // If there is a user (e.g. with authentication), they are only allowed to see their own data
68
+ ${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
69
+ if (context.params.user) {
70
+ return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
71
+ }
72
+
73
+ return value
74
+ }
75
+ }
76
+ })
77
+ `
78
+
79
+ export const generate = (ctx: AuthenticationGeneratorContext) =>
80
+ generator(ctx).then(
81
+ when<AuthenticationGeneratorContext>(
82
+ ({ schema }) => schema === 'typebox',
83
+ renderSource(
84
+ template,
85
+ toFile(({ lib, folder, fileName }: AuthenticationGeneratorContext) => [
86
+ lib,
87
+ 'services',
88
+ ...folder,
89
+ `${fileName}.schema`
90
+ ]),
91
+ { force: true }
92
+ )
93
+ )
94
+ )
@@ -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 = ({ authStrategies, lib }) => `import assert from 'assert';
6
+ const template = ({ authStrategies, path, lib }) => /* ts */ `import assert from 'assert';
7
7
  import { app } from '../${lib}/app';
8
8
 
9
9
  describe('authentication', () => {
@@ -16,7 +16,7 @@ describe('authentication', () => {
16
16
 
17
17
  before(async () => {
18
18
  try {
19
- await app.service('users').create(userInfo)
19
+ await app.service('${path}').create(userInfo)
20
20
  } catch (error) {
21
21
  // Do nothing, it just means the user already exists and can be tested
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,cAAc,EAAE,GAAG,EAAkC,EAAE,EAAE,CAC3E;0BACwB,GAAG;;;IAIzB,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;KAsBH;IACC,CAAC,CAAC,EACN;;;;;;CAMD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAClF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
1
+ {"version":3,"file":"test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACd,IAAI,EACJ,GAAG,EAC4B,EAAE,EAAE,CAAC,QAAQ,CAAC;0BACrB,GAAG;;;IAIzB,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC;;;;;;;;2BAQmB,IAAI;;;;;;;;;;;;;;KAc1B;IACC,CAAC,CAAC,EACN;;;;;;CAMD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAClF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
@@ -2,8 +2,11 @@ import { generator, toFile } from '@feathershq/pinion'
2
2
  import { renderSource } from '../../commons'
3
3
  import { AuthenticationGeneratorContext } from '../index'
4
4
 
5
- const template = ({ authStrategies, lib }: AuthenticationGeneratorContext) =>
6
- `import assert from 'assert';
5
+ const template = ({
6
+ authStrategies,
7
+ path,
8
+ lib
9
+ }: AuthenticationGeneratorContext) => /* ts */ `import assert from 'assert';
7
10
  import { app } from '../${lib}/app';
8
11
 
9
12
  describe('authentication', () => {
@@ -17,7 +20,7 @@ describe('authentication', () => {
17
20
 
18
21
  before(async () => {
19
22
  try {
20
- await app.service('users').create(userInfo)
23
+ await app.service('${path}').create(userInfo)
21
24
  } catch (error) {
22
25
  // Do nothing, it just means the user already exists and can be tested
23
26
  }
package/lib/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import chalk from 'chalk';
2
+ import { Command } from 'commander';
3
+ export * from 'commander';
4
+ export { chalk };
5
+ export declare const commandRunner: (name: string) => (options: any) => Promise<void>;
6
+ export declare const program: Command;
package/lib/cli.js ADDED
@@ -0,0 +1,75 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.program = exports.commandRunner = exports.chalk = void 0;
21
+ const chalk_1 = __importDefault(require("chalk"));
22
+ exports.chalk = chalk_1.default;
23
+ const commander_1 = require("commander");
24
+ const pinion_1 = require("@feathershq/pinion");
25
+ const commons_1 = require("./commons");
26
+ __exportStar(require("commander"), exports);
27
+ const commandRunner = (name) => async (options) => {
28
+ const ctx = (0, pinion_1.getContext)({
29
+ ...options
30
+ });
31
+ await (0, pinion_1.generator)(ctx)
32
+ .then((0, pinion_1.runGenerator)(__dirname, name, 'index'))
33
+ .catch((error) => {
34
+ const { logger } = ctx.pinion;
35
+ logger.error(`Error: ${chalk_1.default.white(error.message)}`);
36
+ });
37
+ };
38
+ exports.commandRunner = commandRunner;
39
+ exports.program = new commander_1.Command();
40
+ exports.program
41
+ .name('feathers')
42
+ .description('The Feathers command line interface 🕊️')
43
+ .version(commons_1.version)
44
+ .showHelpAfterError();
45
+ const generate = exports.program.command('generate').alias('g');
46
+ generate
47
+ .command('app')
48
+ .description('Generate a new application')
49
+ .option('--name <name>', 'The name of the application')
50
+ .action((0, exports.commandRunner)('app'));
51
+ generate
52
+ .command('service')
53
+ .description('Generate a new service')
54
+ .option('--name <name>', 'The service name')
55
+ .option('--path <path>', 'The path to register the service on')
56
+ .option('--type <type>', 'The service type (knex, mongodb, custom)')
57
+ .action((0, exports.commandRunner)('service'));
58
+ generate
59
+ .command('hook')
60
+ .description('Generate a hook')
61
+ .option('--name <name>', 'The name of the hook')
62
+ .option('--type <type>', 'The hook type (around or regular)')
63
+ .action((0, exports.commandRunner)('hook'));
64
+ generate
65
+ .command('connection')
66
+ .description('Add a new database connection')
67
+ .action((0, exports.commandRunner)('connection'));
68
+ generate
69
+ .command('authentication')
70
+ .description('Add authentication to the application')
71
+ .action((0, exports.commandRunner)('authentication'));
72
+ generate.description(`Run a generator. Currently available: \n ${generate.commands
73
+ .map((cmd) => `${chalk_1.default.blue(cmd.name())}: ${cmd.description()} `)
74
+ .join('\n ')}`);
75
+ //# sourceMappingURL=cli.js.map
package/lib/cli.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AAMhB,gBANF,eAAK,CAME;AALd,yCAAmC;AACnC,+CAAwE;AACxE,uCAAwD;AAExD,4CAAyB;AAGlB,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,EAAE,OAAY,EAAE,EAAE;IACpE,MAAM,GAAG,GAAG,IAAA,mBAAU,EAAsB;QAC1C,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,MAAM,IAAA,kBAAS,EAAC,GAAG,CAAC;SACjB,IAAI,CAAC,IAAA,qBAAY,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;SAC5C,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAA;QAE7B,MAAM,CAAC,KAAK,CAAC,UAAU,eAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAZY,QAAA,aAAa,iBAYzB;AAEY,QAAA,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAA;AAEpC,eAAO;KACJ,IAAI,CAAC,UAAU,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CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC;KAChE,IAAI,CAAC,MAAM,CAAC,EAAE,CAClB,CAAA"}
package/lib/cli.ts ADDED
@@ -0,0 +1,68 @@
1
+ import chalk from 'chalk'
2
+ import { Command } from 'commander'
3
+ import { generator, runGenerator, getContext } from '@feathershq/pinion'
4
+ import { FeathersBaseContext, version } from './commons'
5
+
6
+ export * from 'commander'
7
+ export { chalk }
8
+
9
+ export const commandRunner = (name: string) => async (options: any) => {
10
+ const ctx = getContext<FeathersBaseContext>({
11
+ ...options
12
+ })
13
+
14
+ await generator(ctx)
15
+ .then(runGenerator(__dirname, name, 'index'))
16
+ .catch((error) => {
17
+ const { logger } = ctx.pinion
18
+
19
+ logger.error(`Error: ${chalk.white(error.message)}`)
20
+ })
21
+ }
22
+
23
+ export const program = new Command()
24
+
25
+ program
26
+ .name('feathers')
27
+ .description('The Feathers command line interface 🕊️')
28
+ .version(version)
29
+ .showHelpAfterError()
30
+
31
+ const generate = program.command('generate').alias('g')
32
+
33
+ generate
34
+ .command('app')
35
+ .description('Generate a new application')
36
+ .option('--name <name>', 'The name of the application')
37
+ .action(commandRunner('app'))
38
+
39
+ generate
40
+ .command('service')
41
+ .description('Generate a new service')
42
+ .option('--name <name>', 'The service name')
43
+ .option('--path <path>', 'The path to register the service on')
44
+ .option('--type <type>', 'The service type (knex, mongodb, custom)')
45
+ .action(commandRunner('service'))
46
+
47
+ generate
48
+ .command('hook')
49
+ .description('Generate a hook')
50
+ .option('--name <name>', 'The name of the hook')
51
+ .option('--type <type>', 'The hook type (around or regular)')
52
+ .action(commandRunner('hook'))
53
+
54
+ generate
55
+ .command('connection')
56
+ .description('Add a new database connection')
57
+ .action(commandRunner('connection'))
58
+
59
+ generate
60
+ .command('authentication')
61
+ .description('Add authentication to the application')
62
+ .action(commandRunner('authentication'))
63
+
64
+ generate.description(
65
+ `Run a generator. Currently available: \n ${generate.commands
66
+ .map((cmd) => `${chalk.blue(cmd.name())}: ${cmd.description()} `)
67
+ .join('\n ')}`
68
+ )
package/lib/commons.d.ts CHANGED
@@ -2,6 +2,7 @@ import { PackageJson } from 'type-fest';
2
2
  import { Callable, PinionContext, Location } from '@feathershq/pinion';
3
3
  import * as ts from 'typescript';
4
4
  import { Options as PrettierOptions } from 'prettier';
5
+ export declare const version: any;
5
6
  export declare type DependencyVersions = {
6
7
  [key: string]: string;
7
8
  };
@@ -37,6 +38,10 @@ export declare type FeathersAppInfo = {
37
38
  * The HTTP framework used
38
39
  */
39
40
  framework: 'koa' | 'express';
41
+ /**
42
+ * The main schema definition format
43
+ */
44
+ schema: 'typebox' | 'json';
40
45
  };
41
46
  export interface AppPackageJson extends PackageJson {
42
47
  feathers?: FeathersAppInfo;
@@ -86,9 +91,17 @@ export declare const addVersions: (dependencies: string[], versions: DependencyV
86
91
  export declare const initializeBaseContext: () => <C extends FeathersBaseContext>(ctx: C) => Promise<C & {
87
92
  lib: string;
88
93
  test: string;
89
- language: "js" | "ts";
94
+ language: "ts" | "js";
90
95
  feathers: FeathersAppInfo;
91
96
  }>;
97
+ /**
98
+ * Checks if the current context contains a valid generated application. This is necesary for most
99
+ * generators (besides the app generator).
100
+ *
101
+ * @param ctx The context to check against
102
+ * @returns Throws an error or returns the original context
103
+ */
104
+ export declare const checkPreconditions: () => <T extends FeathersBaseContext>(ctx: T) => Promise<T>;
92
105
  /**
93
106
  * Returns the transpiled and prettified JavaScript for a TypeScript source code
94
107
  *
package/lib/commons.js CHANGED
@@ -26,12 +26,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.injectSource = exports.renderSource = exports.prettify = exports.PRETTIERRC = exports.getJavaScript = exports.initializeBaseContext = exports.addVersions = exports.getDatabaseAdapter = void 0;
29
+ exports.injectSource = exports.renderSource = exports.prettify = exports.PRETTIERRC = exports.getJavaScript = exports.checkPreconditions = exports.initializeBaseContext = exports.addVersions = exports.getDatabaseAdapter = exports.version = void 0;
30
+ const fs_1 = __importDefault(require("fs"));
31
+ const path_1 = require("path");
30
32
  const promises_1 = require("fs/promises");
31
33
  const pinion_1 = require("@feathershq/pinion");
32
34
  const ts = __importStar(require("typescript"));
33
35
  const prettier_1 = __importDefault(require("prettier"));
34
- const path_1 = __importDefault(require("path"));
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;
35
38
  /**
36
39
  * Returns the name of the Feathers database adapter for a supported database type
37
40
  *
@@ -57,10 +60,11 @@ exports.addVersions = addVersions;
57
60
  */
58
61
  const initializeBaseContext = () => (ctx) => Promise.resolve(ctx)
59
62
  .then((0, pinion_1.loadJSON)((0, pinion_1.fromFile)('package.json'), (pkg) => ({ pkg }), {}))
60
- .then((0, pinion_1.loadJSON)(path_1.default.join(__dirname, '..', 'package.json'), (pkg) => ({
63
+ .then((0, pinion_1.loadJSON)(path_2.default.join(__dirname, '..', 'package.json'), (pkg) => ({
61
64
  dependencyVersions: {
62
65
  ...pkg.devDependencies,
63
- ...ctx.dependencyVersions
66
+ ...ctx.dependencyVersions,
67
+ '@feathersjs/cli': exports.version
64
68
  }
65
69
  })))
66
70
  .then((ctx) => {
@@ -74,6 +78,22 @@ const initializeBaseContext = () => (ctx) => Promise.resolve(ctx)
74
78
  });
75
79
  });
76
80
  exports.initializeBaseContext = initializeBaseContext;
81
+ /**
82
+ * Checks if the current context contains a valid generated application. This is necesary for most
83
+ * generators (besides the app generator).
84
+ *
85
+ * @param ctx The context to check against
86
+ * @returns Throws an error or returns the original context
87
+ */
88
+ const checkPreconditions = () => async (ctx) => {
89
+ if (!ctx.feathers) {
90
+ throw new Error(`Can not run generator since the current folder does not appear to be a Feathers application.
91
+ Either your package.json is missing or it does not have \`feathers\` property.
92
+ `);
93
+ }
94
+ return ctx;
95
+ };
96
+ exports.checkPreconditions = checkPreconditions;
77
97
  const importRegex = /from '(\..*)'/g;
78
98
  const escapeNewLines = (code) => code.replace(/\n\n/g, '\n/* :newline: */');
79
99
  const restoreNewLines = (code) => code.replace(/\/\* :newline: \*\//g, '\n');
@@ -1 +1 @@
1
- {"version":3,"file":"commons.js","sourceRoot":"","sources":["../src/commons.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAiD;AACjD,+CAS2B;AAC3B,+CAAgC;AAChC,wDAA+D;AAC/D,gDAAuB;AASvB;;;;;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;AA0D3G;;;;;;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,GAAG,EAAE,CACL,CAAgC,GAAM,EAAE,EAAE,CACxC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;KACjB,IAAI,CAAC,IAAA,iBAAQ,EAAC,IAAA,iBAAQ,EAAC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;KAChE,IAAI,CACH,IAAA,iBAAQ,EAAC,cAAI,CAAC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
2
4
  import { readFile, writeFile } from 'fs/promises'
3
5
  import {
@@ -14,6 +16,8 @@ import * as ts from 'typescript'
14
16
  import prettier, { Options as PrettierOptions } from 'prettier'
15
17
  import path from 'path'
16
18
 
19
+ export const { version } = JSON.parse(fs.readFileSync(join(__dirname, '..', 'package.json')).toString())
20
+
17
21
  export type DependencyVersions = { [key: string]: string }
18
22
 
19
23
  /**
@@ -50,6 +54,10 @@ export type FeathersAppInfo = {
50
54
  * The HTTP framework used
51
55
  */
52
56
  framework: 'koa' | 'express'
57
+ /**
58
+ * The main schema definition format
59
+ */
60
+ schema: 'typebox' | 'json'
53
61
  }
54
62
 
55
63
  export interface AppPackageJson extends PackageJson {
@@ -110,7 +118,8 @@ export const initializeBaseContext =
110
118
  loadJSON(path.join(__dirname, '..', 'package.json'), (pkg: PackageJson) => ({
111
119
  dependencyVersions: {
112
120
  ...pkg.devDependencies,
113
- ...ctx.dependencyVersions
121
+ ...ctx.dependencyVersions,
122
+ '@feathersjs/cli': version
114
123
  }
115
124
  }))
116
125
  )
@@ -122,6 +131,25 @@ export const initializeBaseContext =
122
131
  feathers: ctx.pkg?.feathers
123
132
  }))
124
133
 
134
+ /**
135
+ * Checks if the current context contains a valid generated application. This is necesary for most
136
+ * generators (besides the app generator).
137
+ *
138
+ * @param ctx The context to check against
139
+ * @returns Throws an error or returns the original context
140
+ */
141
+ export const checkPreconditions =
142
+ () =>
143
+ async <T extends FeathersBaseContext>(ctx: T) => {
144
+ if (!ctx.feathers) {
145
+ throw new Error(`Can not run generator since the current folder does not appear to be a Feathers application.
146
+ Either your package.json is missing or it does not have \`feathers\` property.
147
+ `)
148
+ }
149
+
150
+ return ctx
151
+ }
152
+
125
153
  const importRegex = /from '(\..*)'/g
126
154
  const escapeNewLines = (code: string) => code.replace(/\n\n/g, '\n/* :newline: */')
127
155
  const restoreNewLines = (code: string) => code.replace(/\/\* :newline: \*\//g, '\n')
@@ -1,12 +1,13 @@
1
1
  import { FeathersBaseContext, DatabaseType } from '../commons';
2
2
  export interface ConnectionGeneratorContext extends FeathersBaseContext {
3
+ name?: string;
3
4
  database: DatabaseType;
4
5
  connectionString: string;
5
6
  dependencies: string[];
6
7
  }
7
- export declare type ConnectionGeneratorArguments = FeathersBaseContext & Partial<Pick<ConnectionGeneratorContext, 'database' | 'connectionString'>>;
8
+ export declare type ConnectionGeneratorArguments = FeathersBaseContext & Partial<Pick<ConnectionGeneratorContext, 'database' | 'connectionString' | 'name'>>;
8
9
  export declare const defaultConnectionString: (type: DatabaseType, name: string) => string;
9
- export declare const prompts: ({ database, connectionString, pkg }: ConnectionGeneratorArguments) => ({
10
+ export declare const prompts: ({ database, connectionString, pkg, name }: ConnectionGeneratorArguments) => ({
10
11
  name: string;
11
12
  type: string;
12
13
  when: boolean;
@@ -39,13 +40,14 @@ export declare const DATABASE_CLIENTS: {
39
40
  export declare const getDatabaseClient: (database: DatabaseType) => string;
40
41
  export declare const generate: (ctx: ConnectionGeneratorArguments) => Promise<{
41
42
  dependencies: string[];
43
+ name?: string;
42
44
  database: DatabaseType;
43
45
  connectionString: string;
44
46
  feathers: import("../commons").FeathersAppInfo;
45
47
  pkg: import("../commons").AppPackageJson;
46
48
  lib: string;
47
49
  test: string;
48
- language: "js" | "ts";
50
+ language: "ts" | "js";
49
51
  dependencyVersions?: import("../commons").DependencyVersions;
50
52
  cwd: string;
51
53
  _?: (string | number)[];
@@ -18,7 +18,7 @@ const defaultConnectionString = (type, name) => {
18
18
  return connectionStrings[type];
19
19
  };
20
20
  exports.defaultConnectionString = defaultConnectionString;
21
- const prompts = ({ database, connectionString, pkg }) => [
21
+ const prompts = ({ database, connectionString, pkg, name }) => [
22
22
  {
23
23
  name: 'database',
24
24
  type: 'list',
@@ -38,7 +38,7 @@ const prompts = ({ database, connectionString, pkg }) => [
38
38
  type: 'input',
39
39
  when: !connectionString,
40
40
  message: 'Enter your database connection string',
41
- default: (answers) => (0, exports.defaultConnectionString)(answers.database, answers.name || pkg.name)
41
+ default: (answers) => (0, exports.defaultConnectionString)(answers.database, answers.name || name || pkg.name)
42
42
  }
43
43
  ];
44
44
  exports.prompts = prompts;
@@ -52,6 +52,8 @@ exports.DATABASE_CLIENTS = {
52
52
  const getDatabaseClient = (database) => exports.DATABASE_CLIENTS[database];
53
53
  exports.getDatabaseClient = getDatabaseClient;
54
54
  const generate = (ctx) => (0, pinion_1.generator)(ctx)
55
+ .then((0, commons_1.initializeBaseContext)())
56
+ .then((0, commons_1.checkPreconditions)())
55
57
  .then((0, pinion_1.prompt)(exports.prompts))
56
58
  .then((0, pinion_1.runGenerator)(__dirname, 'templates', ({ database }) => `${(0, commons_1.getDatabaseAdapter)(database)}.tpl`))
57
59
  .then((0, pinion_1.mergeJSON)(({ connectionString, database }) => (0, commons_1.getDatabaseAdapter)(database) === 'knex'
@@ -80,7 +82,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
80
82
  dependencies: [...ctx.dependencies, ...dependencies]
81
83
  };
82
84
  }
83
- return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions))(ctx);
85
+ return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
84
86
  });
85
87
  exports.generate = generate;
86
88
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAgG;AAChG,kDAAyB;AACzB,wCAA+F;AAWxF,MAAM,uBAAuB,GAAG,CAAC,IAAkB,EAAE,IAAY,EAAE,EAAE;IAC1E,MAAM,iBAAiB,GAAG;QACxB,OAAO,EAAE,6BAA6B,IAAI,EAAE;QAC5C,KAAK,EAAE,gCAAgC,IAAI,EAAE;QAC7C,UAAU,EAAE,uCAAuC,IAAI,EAAE;QACzD,MAAM,EAAE,GAAG,IAAI,SAAS;QACxB,KAAK,EAAE,wCAAwC,IAAI,EAAE;KACtD,CAAA;IAED,OAAO,iB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