@feathersjs/cli 5.0.0-pre.34 → 5.0.0-pre.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/index.d.ts +6 -2
- package/lib/index.js +59 -2
- package/lib/index.js.map +1 -1
- package/package.json +28 -30
- package/lib/app/index.d.ts +0 -29
- package/lib/app/index.js +0 -146
- package/lib/app/index.js.map +0 -1
- package/lib/app/index.ts +0 -228
- package/lib/app/static/.gitignore +0 -121
- package/lib/app/templates/app.test.tpl.d.ts +0 -2
- package/lib/app/templates/app.test.tpl.js +0 -49
- package/lib/app/templates/app.test.tpl.js.map +0 -1
- package/lib/app/templates/app.test.tpl.ts +0 -50
- package/lib/app/templates/app.tpl.d.ts +0 -2
- package/lib/app/templates/app.tpl.js +0 -123
- package/lib/app/templates/app.tpl.js.map +0 -1
- package/lib/app/templates/app.tpl.ts +0 -138
- package/lib/app/templates/channels.tpl.d.ts +0 -2
- package/lib/app/templates/channels.tpl.js +0 -49
- package/lib/app/templates/channels.tpl.js.map +0 -1
- package/lib/app/templates/channels.tpl.ts +0 -55
- package/lib/app/templates/client.test.tpl.d.ts +0 -2
- package/lib/app/templates/client.test.tpl.js +0 -27
- package/lib/app/templates/client.test.tpl.js.map +0 -1
- package/lib/app/templates/client.test.tpl.ts +0 -26
- package/lib/app/templates/client.tpl.d.ts +0 -2
- package/lib/app/templates/client.tpl.js +0 -38
- package/lib/app/templates/client.tpl.js.map +0 -1
- package/lib/app/templates/client.tpl.ts +0 -45
- package/lib/app/templates/configuration.tpl.d.ts +0 -2
- package/lib/app/templates/configuration.tpl.js +0 -71
- package/lib/app/templates/configuration.tpl.js.map +0 -1
- package/lib/app/templates/configuration.tpl.ts +0 -82
- package/lib/app/templates/declarations.tpl.d.ts +0 -2
- package/lib/app/templates/declarations.tpl.js +0 -28
- package/lib/app/templates/declarations.tpl.js.map +0 -1
- package/lib/app/templates/declarations.tpl.ts +0 -37
- package/lib/app/templates/index.html.tpl.d.ts +0 -2
- package/lib/app/templates/index.html.tpl.js +0 -45
- package/lib/app/templates/index.html.tpl.js.map +0 -1
- package/lib/app/templates/index.html.tpl.ts +0 -44
- package/lib/app/templates/index.tpl.d.ts +0 -2
- package/lib/app/templates/index.tpl.js +0 -18
- package/lib/app/templates/index.tpl.js.map +0 -1
- package/lib/app/templates/index.tpl.ts +0 -22
- package/lib/app/templates/logger.tpl.d.ts +0 -3
- package/lib/app/templates/logger.tpl.js +0 -45
- package/lib/app/templates/logger.tpl.js.map +0 -1
- package/lib/app/templates/logger.tpl.ts +0 -56
- package/lib/app/templates/package.json.tpl.d.ts +0 -2
- package/lib/app/templates/package.json.tpl.js +0 -58
- package/lib/app/templates/package.json.tpl.js.map +0 -1
- package/lib/app/templates/package.json.tpl.ts +0 -71
- package/lib/app/templates/prettierrc.tpl.d.ts +0 -2
- package/lib/app/templates/prettierrc.tpl.js +0 -11
- package/lib/app/templates/prettierrc.tpl.js.map +0 -1
- package/lib/app/templates/prettierrc.tpl.ts +0 -14
- package/lib/app/templates/readme.md.tpl.d.ts +0 -2
- package/lib/app/templates/readme.md.tpl.js +0 -54
- package/lib/app/templates/readme.md.tpl.js.map +0 -1
- package/lib/app/templates/readme.md.tpl.ts +0 -57
- package/lib/app/templates/services.tpl.d.ts +0 -2
- package/lib/app/templates/services.tpl.js +0 -15
- package/lib/app/templates/services.tpl.js.map +0 -1
- package/lib/app/templates/services.tpl.ts +0 -20
- package/lib/app/templates/tsconfig.json.tpl.d.ts +0 -2
- package/lib/app/templates/tsconfig.json.tpl.js +0 -22
- package/lib/app/templates/tsconfig.json.tpl.js.map +0 -1
- package/lib/app/templates/tsconfig.json.tpl.ts +0 -28
- package/lib/app/templates/validators.tpl.d.ts +0 -2
- package/lib/app/templates/validators.tpl.js +0 -36
- package/lib/app/templates/validators.tpl.js.map +0 -1
- package/lib/app/templates/validators.tpl.ts +0 -40
- package/lib/authentication/index.d.ts +0 -73
- package/lib/authentication/index.js +0 -107
- package/lib/authentication/index.js.map +0 -1
- package/lib/authentication/index.ts +0 -126
- package/lib/authentication/templates/authentication.tpl.d.ts +0 -2
- package/lib/authentication/templates/authentication.tpl.js +0 -40
- package/lib/authentication/templates/authentication.tpl.js.map +0 -1
- package/lib/authentication/templates/authentication.tpl.ts +0 -51
- package/lib/authentication/templates/client.test.tpl.d.ts +0 -2
- package/lib/authentication/templates/client.test.tpl.js +0 -62
- package/lib/authentication/templates/client.test.tpl.js.map +0 -1
- package/lib/authentication/templates/client.test.tpl.ts +0 -74
- package/lib/authentication/templates/config.tpl.d.ts +0 -2
- package/lib/authentication/templates/config.tpl.js +0 -50
- package/lib/authentication/templates/config.tpl.js.map +0 -1
- package/lib/authentication/templates/config.tpl.ts +0 -57
- package/lib/authentication/templates/declarations.tpl.d.ts +0 -2
- package/lib/authentication/templates/declarations.tpl.js +0 -19
- package/lib/authentication/templates/declarations.tpl.js.map +0 -1
- package/lib/authentication/templates/declarations.tpl.ts +0 -34
- package/lib/authentication/templates/knex.tpl.d.ts +0 -2
- package/lib/authentication/templates/knex.tpl.js +0 -45
- package/lib/authentication/templates/knex.tpl.js.map +0 -1
- package/lib/authentication/templates/knex.tpl.ts +0 -62
- package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
- package/lib/authentication/templates/schema.json.tpl.js +0 -103
- package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.json.tpl.ts +0 -124
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
- package/lib/authentication/templates/schema.typebox.tpl.js +0 -86
- package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +0 -108
- package/lib/cli.d.ts +0 -6
- package/lib/cli.js +0 -75
- package/lib/cli.js.map +0 -1
- package/lib/cli.ts +0 -68
- package/lib/commons.d.ts +0 -150
- package/lib/commons.js +0 -198
- package/lib/commons.js.map +0 -1
- package/lib/commons.ts +0 -284
- package/lib/connection/index.d.ts +0 -55
- package/lib/connection/index.js +0 -88
- package/lib/connection/index.js.map +0 -1
- package/lib/connection/index.ts +0 -123
- package/lib/connection/templates/knex.tpl.d.ts +0 -2
- package/lib/connection/templates/knex.tpl.js +0 -48
- package/lib/connection/templates/knex.tpl.js.map +0 -1
- package/lib/connection/templates/knex.tpl.ts +0 -67
- package/lib/connection/templates/mongodb.tpl.d.ts +0 -2
- package/lib/connection/templates/mongodb.tpl.js +0 -34
- package/lib/connection/templates/mongodb.tpl.js.map +0 -1
- package/lib/connection/templates/mongodb.tpl.ts +0 -40
- package/lib/hook/index.d.ts +0 -22
- package/lib/hook/index.js +0 -43
- package/lib/hook/index.js.map +0 -1
- package/lib/hook/index.ts +0 -47
- package/lib/hook/templates/hook.tpl.d.ts +0 -2
- package/lib/hook/templates/hook.tpl.js +0 -22
- package/lib/hook/templates/hook.tpl.js.map +0 -1
- package/lib/hook/templates/hook.tpl.ts +0 -33
- package/lib/index.ts +0 -2
- package/lib/service/index.d.ts +0 -64
- package/lib/service/index.js +0 -116
- package/lib/service/index.js.map +0 -1
- package/lib/service/index.ts +0 -191
- package/lib/service/templates/client.tpl.d.ts +0 -2
- package/lib/service/templates/client.tpl.js +0 -31
- package/lib/service/templates/client.tpl.js.map +0 -1
- package/lib/service/templates/client.tpl.ts +0 -57
- package/lib/service/templates/schema.json.tpl.d.ts +0 -2
- package/lib/service/templates/schema.json.tpl.js +0 -83
- package/lib/service/templates/schema.json.tpl.js.map +0 -1
- package/lib/service/templates/schema.json.tpl.ts +0 -98
- package/lib/service/templates/schema.typebox.tpl.d.ts +0 -2
- package/lib/service/templates/schema.typebox.tpl.js +0 -61
- package/lib/service/templates/schema.typebox.tpl.js.map +0 -1
- package/lib/service/templates/schema.typebox.tpl.ts +0 -76
- package/lib/service/templates/service.tpl.d.ts +0 -3
- package/lib/service/templates/service.tpl.js +0 -112
- package/lib/service/templates/service.tpl.js.map +0 -1
- package/lib/service/templates/service.tpl.ts +0 -152
- package/lib/service/templates/test.tpl.d.ts +0 -2
- package/lib/service/templates/test.tpl.js +0 -25
- package/lib/service/templates/test.tpl.js.map +0 -1
- package/lib/service/templates/test.tpl.ts +0 -33
- package/lib/service/type/custom.tpl.d.ts +0 -3
- package/lib/service/type/custom.tpl.js +0 -98
- package/lib/service/type/custom.tpl.js.map +0 -1
- package/lib/service/type/custom.tpl.ts +0 -109
- package/lib/service/type/knex.tpl.d.ts +0 -3
- package/lib/service/type/knex.tpl.js +0 -71
- package/lib/service/type/knex.tpl.js.map +0 -1
- package/lib/service/type/knex.tpl.ts +0 -92
- package/lib/service/type/mongodb.tpl.d.ts +0 -3
- package/lib/service/type/mongodb.tpl.js +0 -50
- package/lib/service/type/mongodb.tpl.js.map +0 -1
- package/lib/service/type/mongodb.tpl.ts +0 -62
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
|
|
3
|
-
import {
|
|
4
|
-
addVersions,
|
|
5
|
-
checkPreconditions,
|
|
6
|
-
FeathersBaseContext,
|
|
7
|
-
getDatabaseAdapter,
|
|
8
|
-
initializeBaseContext
|
|
9
|
-
} from '../commons'
|
|
10
|
-
import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
|
|
11
|
-
|
|
12
|
-
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
13
|
-
service: string
|
|
14
|
-
entity: string
|
|
15
|
-
authStrategies: string[]
|
|
16
|
-
dependencies: string[]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type AuthenticationGeneratorArguments = FeathersBaseContext &
|
|
20
|
-
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>
|
|
21
|
-
|
|
22
|
-
export const localTemplate = (authStrategies: string[], content: string) =>
|
|
23
|
-
authStrategies.includes('local') ? content : ''
|
|
24
|
-
export const oauthTemplate = (authStrategies: string[], content: string) =>
|
|
25
|
-
authStrategies.filter((s) => s !== 'local').length > 0 ? content : ''
|
|
26
|
-
|
|
27
|
-
export const prompts = (ctx: AuthenticationGeneratorArguments) => [
|
|
28
|
-
{
|
|
29
|
-
type: 'checkbox',
|
|
30
|
-
name: 'authStrategies',
|
|
31
|
-
when: !ctx.authStrategies,
|
|
32
|
-
message: 'Which authentication methods do you want to use?',
|
|
33
|
-
suffix: chalk.grey(' Other methods and providers can be added at any time.'),
|
|
34
|
-
choices: [
|
|
35
|
-
{
|
|
36
|
-
name: 'Email + Password',
|
|
37
|
-
value: 'local',
|
|
38
|
-
checked: true
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'Google',
|
|
42
|
-
value: 'google'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: 'Facebook',
|
|
46
|
-
value: 'facebook'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'Twitter',
|
|
50
|
-
value: 'twitter'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'GitHub',
|
|
54
|
-
value: 'github'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'Auth0',
|
|
58
|
-
value: 'auth0'
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'service',
|
|
64
|
-
type: 'input',
|
|
65
|
-
when: !ctx.service,
|
|
66
|
-
message: 'What is your authentication service name?',
|
|
67
|
-
default: 'user'
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'path',
|
|
71
|
-
type: 'input',
|
|
72
|
-
when: !ctx.path,
|
|
73
|
-
message: 'What path should the service be registered on?',
|
|
74
|
-
default: 'users'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: 'entity',
|
|
78
|
-
type: 'input',
|
|
79
|
-
when: !ctx.entity,
|
|
80
|
-
message: 'What is your authenticated entity name?',
|
|
81
|
-
suffix: chalk.grey(' Will be available in params (e.g. params.user)'),
|
|
82
|
-
default: 'user'
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
export const generate = (ctx: AuthenticationGeneratorArguments) =>
|
|
87
|
-
generator(ctx)
|
|
88
|
-
.then(initializeBaseContext())
|
|
89
|
-
.then(checkPreconditions())
|
|
90
|
-
.then(prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(prompts))
|
|
91
|
-
.then(async (ctx) => {
|
|
92
|
-
const serviceContext = await serviceGenerator({
|
|
93
|
-
...ctx,
|
|
94
|
-
name: ctx.service,
|
|
95
|
-
isEntityService: true,
|
|
96
|
-
type: getDatabaseAdapter(ctx.feathers?.database)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
...ctx,
|
|
101
|
-
...serviceContext
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
.then(runGenerators(__dirname, 'templates'))
|
|
105
|
-
.then((ctx) => {
|
|
106
|
-
const dependencies: string[] = []
|
|
107
|
-
|
|
108
|
-
dependencies.push('@feathersjs/authentication-oauth')
|
|
109
|
-
|
|
110
|
-
if (ctx.authStrategies.includes('local')) {
|
|
111
|
-
dependencies.push('@feathersjs/authentication-local')
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (ctx.dependencies) {
|
|
115
|
-
return {
|
|
116
|
-
...ctx,
|
|
117
|
-
dependencies: [...ctx.dependencies, ...dependencies]
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return install<AuthenticationGeneratorContext>(
|
|
122
|
-
addVersions(dependencies, ctx.dependencyVersions),
|
|
123
|
-
false,
|
|
124
|
-
ctx.feathers.packager
|
|
125
|
-
)(ctx)
|
|
126
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = void 0;
|
|
4
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const commons_1 = require("../../commons");
|
|
6
|
-
const index_1 = require("../index");
|
|
7
|
-
const template = ({ authStrategies }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/authentication.html
|
|
8
|
-
import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
9
|
-
${(0, index_1.localTemplate)(authStrategies, `import { LocalStrategy } from '@feathersjs/authentication-local'`)}
|
|
10
|
-
${(0, index_1.oauthTemplate)(authStrategies, `import { oauth, OAuthStrategy } from '@feathersjs/authentication-oauth'`)}
|
|
11
|
-
|
|
12
|
-
import type { Application } from './declarations'
|
|
13
|
-
|
|
14
|
-
declare module './declarations' {
|
|
15
|
-
interface ServiceTypes {
|
|
16
|
-
'authentication': AuthenticationService
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const authentication = (app: Application) => {
|
|
21
|
-
const authentication = new AuthenticationService(app)
|
|
22
|
-
|
|
23
|
-
authentication.register('jwt', new JWTStrategy())
|
|
24
|
-
${authStrategies
|
|
25
|
-
.map((strategy) => ` authentication.register('${strategy}', ${strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`})`)
|
|
26
|
-
.join('\n')}
|
|
27
|
-
|
|
28
|
-
app.use('authentication', authentication)
|
|
29
|
-
${(0, index_1.oauthTemplate)(authStrategies, `app.configure(oauth())`)}
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
const importTemplate = "import { authentication } from './authentication'";
|
|
33
|
-
const configureTemplate = 'app.configure(authentication)';
|
|
34
|
-
const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
|
|
35
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
36
|
-
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'authentication')))
|
|
37
|
-
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
38
|
-
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
39
|
-
exports.generate = generate;
|
|
40
|
-
//# sourceMappingURL=authentication.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAC1D,oCAAuF;AAEvF,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;EAE7C,IAAA,qBAAa,EAAC,cAAc,EAAE,kEAAkE,CAAC;EACjG,IAAA,qBAAa,EAAC,cAAc,EAAE,yEAAyE,CAAC;;;;;;;;;;;;;;IActG,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;;;IAGX,IAAA,qBAAa,EAAC,cAAc,EAAE,wBAAwB,CAAC;;CAE1D,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,51 +0,0 @@
|
|
|
1
|
-
import { generator, before, toFile } from '@feathershq/pinion'
|
|
2
|
-
import { injectSource, renderSource } from '../../commons'
|
|
3
|
-
import { AuthenticationGeneratorContext, localTemplate, oauthTemplate } from '../index'
|
|
4
|
-
|
|
5
|
-
const template = ({
|
|
6
|
-
authStrategies
|
|
7
|
-
}: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/authentication.html
|
|
8
|
-
import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
9
|
-
${localTemplate(authStrategies, `import { LocalStrategy } from '@feathersjs/authentication-local'`)}
|
|
10
|
-
${oauthTemplate(authStrategies, `import { oauth, OAuthStrategy } from '@feathersjs/authentication-oauth'`)}
|
|
11
|
-
|
|
12
|
-
import type { Application } from './declarations'
|
|
13
|
-
|
|
14
|
-
declare module './declarations' {
|
|
15
|
-
interface ServiceTypes {
|
|
16
|
-
'authentication': AuthenticationService
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const authentication = (app: Application) => {
|
|
21
|
-
const authentication = new AuthenticationService(app)
|
|
22
|
-
|
|
23
|
-
authentication.register('jwt', new JWTStrategy())
|
|
24
|
-
${authStrategies
|
|
25
|
-
.map(
|
|
26
|
-
(strategy) =>
|
|
27
|
-
` authentication.register('${strategy}', ${
|
|
28
|
-
strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`
|
|
29
|
-
})`
|
|
30
|
-
)
|
|
31
|
-
.join('\n')}
|
|
32
|
-
|
|
33
|
-
app.use('authentication', authentication)
|
|
34
|
-
${oauthTemplate(authStrategies, `app.configure(oauth())`)}
|
|
35
|
-
}
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
const importTemplate = "import { authentication } from './authentication'"
|
|
39
|
-
const configureTemplate = 'app.configure(authentication)'
|
|
40
|
-
const toAppFile = toFile<AuthenticationGeneratorContext>(({ lib }) => [lib, 'app'])
|
|
41
|
-
|
|
42
|
-
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
43
|
-
generator(ctx)
|
|
44
|
-
.then(
|
|
45
|
-
renderSource(
|
|
46
|
-
template,
|
|
47
|
-
toFile<AuthenticationGeneratorContext>(({ lib }) => lib, 'authentication')
|
|
48
|
-
)
|
|
49
|
-
)
|
|
50
|
-
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
|
51
|
-
.then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = void 0;
|
|
4
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const commons_1 = require("../../commons");
|
|
6
|
-
const index_1 = require("../index");
|
|
7
|
-
const template = ({ authStrategies, upperName, type, lib }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/client.test.html
|
|
8
|
-
import assert from 'assert'
|
|
9
|
-
import axios from 'axios'
|
|
10
|
-
|
|
11
|
-
import rest from '@feathersjs/rest-client'
|
|
12
|
-
${(0, index_1.localTemplate)(authStrategies, `import authenticationClient from '@feathersjs/authentication-client'`)}
|
|
13
|
-
import { app } from '../${lib}/app'
|
|
14
|
-
import { createClient } from '../${lib}/client'
|
|
15
|
-
${(0, index_1.localTemplate)(authStrategies, `import type { ${upperName}Data } from '../${lib}/client'`)}
|
|
16
|
-
|
|
17
|
-
const port = app.get('port')
|
|
18
|
-
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
19
|
-
|
|
20
|
-
describe('application client tests', () => {
|
|
21
|
-
const client = createClient(rest(appUrl).axios(axios))
|
|
22
|
-
|
|
23
|
-
before(async () => {
|
|
24
|
-
await app.listen(port)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
after(async () => {
|
|
28
|
-
await app.teardown()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('initialized the client', () => {
|
|
32
|
-
assert.ok(client)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
${(0, index_1.localTemplate)(authStrategies, `
|
|
36
|
-
it('creates and authenticates a user with email and password', async () => {
|
|
37
|
-
const userData: ${upperName}Data = {
|
|
38
|
-
email: 'someone@example.com',
|
|
39
|
-
password: 'supersecret'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await client.service('users').create(userData)
|
|
43
|
-
|
|
44
|
-
const { user, accessToken } = await client.authenticate({
|
|
45
|
-
strategy: 'local',
|
|
46
|
-
...userData
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
assert.ok(accessToken, 'Created access token for user')
|
|
50
|
-
assert.ok(user, 'Includes user in authentication data')
|
|
51
|
-
assert.strictEqual(user.password, undefined, 'Password is hidden to clients')
|
|
52
|
-
|
|
53
|
-
await client.logout()
|
|
54
|
-
|
|
55
|
-
// Remove the test user on the server
|
|
56
|
-
await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'})
|
|
57
|
-
})`)}
|
|
58
|
-
})
|
|
59
|
-
`;
|
|
60
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test }) => test, 'client.test'), { force: true }));
|
|
61
|
-
exports.generate = generate;
|
|
62
|
-
//# sourceMappingURL=client.test.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAC5C,oCAAwE;AAExE,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACd,SAAS,EACT,IAAI,EACJ,GAAG,EAC4B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;EAK7C,IAAA,qBAAa,EAAC,cAAc,EAAE,sEAAsE,CAAC;0BAC7E,GAAG;mCACM,GAAG;EACpC,IAAA,qBAAa,EAAC,cAAc,EAAE,iBAAiB,SAAS,mBAAmB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;IAoBvF,IAAA,qBAAa,EACb,cAAc,EACd;;sBAEkB,SAAS;;;;;;;;;;;;;;;;;;;6CAmBc,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;KACzE,CACF;;CAEF,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,aAAa,CAAC,EACzE,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CACF,CAAA;AAPU,QAAA,QAAQ,YAOlB"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
3
|
-
import { AuthenticationGeneratorContext, localTemplate } from '../index'
|
|
4
|
-
|
|
5
|
-
const template = ({
|
|
6
|
-
authStrategies,
|
|
7
|
-
upperName,
|
|
8
|
-
type,
|
|
9
|
-
lib
|
|
10
|
-
}: AuthenticationGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/client.test.html
|
|
11
|
-
import assert from 'assert'
|
|
12
|
-
import axios from 'axios'
|
|
13
|
-
|
|
14
|
-
import rest from '@feathersjs/rest-client'
|
|
15
|
-
${localTemplate(authStrategies, `import authenticationClient from '@feathersjs/authentication-client'`)}
|
|
16
|
-
import { app } from '../${lib}/app'
|
|
17
|
-
import { createClient } from '../${lib}/client'
|
|
18
|
-
${localTemplate(authStrategies, `import type { ${upperName}Data } from '../${lib}/client'`)}
|
|
19
|
-
|
|
20
|
-
const port = app.get('port')
|
|
21
|
-
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
22
|
-
|
|
23
|
-
describe('application client tests', () => {
|
|
24
|
-
const client = createClient(rest(appUrl).axios(axios))
|
|
25
|
-
|
|
26
|
-
before(async () => {
|
|
27
|
-
await app.listen(port)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
after(async () => {
|
|
31
|
-
await app.teardown()
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('initialized the client', () => {
|
|
35
|
-
assert.ok(client)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
${localTemplate(
|
|
39
|
-
authStrategies,
|
|
40
|
-
`
|
|
41
|
-
it('creates and authenticates a user with email and password', async () => {
|
|
42
|
-
const userData: ${upperName}Data = {
|
|
43
|
-
email: 'someone@example.com',
|
|
44
|
-
password: 'supersecret'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
await client.service('users').create(userData)
|
|
48
|
-
|
|
49
|
-
const { user, accessToken } = await client.authenticate({
|
|
50
|
-
strategy: 'local',
|
|
51
|
-
...userData
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
assert.ok(accessToken, 'Created access token for user')
|
|
55
|
-
assert.ok(user, 'Includes user in authentication data')
|
|
56
|
-
assert.strictEqual(user.password, undefined, 'Password is hidden to clients')
|
|
57
|
-
|
|
58
|
-
await client.logout()
|
|
59
|
-
|
|
60
|
-
// Remove the test user on the server
|
|
61
|
-
await app.service('users').remove(user.${type === 'mongodb' ? '_id' : 'id'})
|
|
62
|
-
})`
|
|
63
|
-
)}
|
|
64
|
-
})
|
|
65
|
-
`
|
|
66
|
-
|
|
67
|
-
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
68
|
-
generator(ctx).then(
|
|
69
|
-
renderSource(
|
|
70
|
-
template,
|
|
71
|
-
toFile<AuthenticationGeneratorContext>(({ test }) => test, 'client.test'),
|
|
72
|
-
{ force: true }
|
|
73
|
-
)
|
|
74
|
-
)
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generate = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
9
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
10
|
-
.then((0, pinion_1.mergeJSON)(({ authStrategies }) => {
|
|
11
|
-
const authentication = {
|
|
12
|
-
entity: ctx.entity,
|
|
13
|
-
service: ctx.path,
|
|
14
|
-
secret: crypto_1.default.randomBytes(24).toString('base64'),
|
|
15
|
-
authStrategies: ['jwt'],
|
|
16
|
-
jwtOptions: {
|
|
17
|
-
header: {
|
|
18
|
-
typ: 'access'
|
|
19
|
-
},
|
|
20
|
-
audience: 'https://yourdomain.com',
|
|
21
|
-
algorithm: 'HS256',
|
|
22
|
-
expiresIn: '1d'
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
if (authStrategies.includes('local')) {
|
|
26
|
-
authentication.authStrategies.push('local');
|
|
27
|
-
authentication.local = {
|
|
28
|
-
usernameField: 'email',
|
|
29
|
-
passwordField: 'password'
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const oauthStrategies = authStrategies.filter((name) => name !== 'local');
|
|
33
|
-
if (oauthStrategies.length) {
|
|
34
|
-
authentication.oauth = oauthStrategies.reduce((oauth, name) => {
|
|
35
|
-
oauth[name] = {
|
|
36
|
-
key: '<Client ID>',
|
|
37
|
-
secret: '<Client secret>'
|
|
38
|
-
};
|
|
39
|
-
return oauth;
|
|
40
|
-
}, {});
|
|
41
|
-
}
|
|
42
|
-
return { authentication };
|
|
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')));
|
|
49
|
-
exports.generate = generate;
|
|
50
|
-
//# sourceMappingURL=config.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/config.tpl.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,+CAAiE;AAG1D,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,kBAAS,EAAiC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;IAC/D,MAAM,cAAc,GAAQ;QAC1B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,IAAI;QACjB,MAAM,EAAE,gBAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjD,cAAc,EAAE,CAAC,KAAK,CAAC;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,GAAG,EAAE,QAAQ;aACd;YACD,QAAQ,EAAE,wBAAwB;YAClC,SAAS,EAAE,OAAO;YAClB,SAAS,EAAE,IAAI;SAChB;KACF,CAAA;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACpC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3C,cAAc,CAAC,KAAK,GAAG;YACrB,aAAa,EAAE,OAAO;YACtB,aAAa,EAAE,UAAU;SAC1B,CAAA;KACF;IAED,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,CAAA;IAEzE,IAAI,eAAe,CAAC,MAAM,EAAE;QAC1B,cAAc,CAAC,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC5D,KAAK,CAAC,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"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto'
|
|
2
|
-
import { generator, toFile, mergeJSON } from '@feathershq/pinion'
|
|
3
|
-
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
-
|
|
5
|
-
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
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
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (authStrategies.includes('local')) {
|
|
25
|
-
authentication.authStrategies.push('local')
|
|
26
|
-
authentication.local = {
|
|
27
|
-
usernameField: 'email',
|
|
28
|
-
passwordField: 'password'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const oauthStrategies = authStrategies.filter((name) => name !== 'local')
|
|
33
|
-
|
|
34
|
-
if (oauthStrategies.length) {
|
|
35
|
-
authentication.oauth = oauthStrategies.reduce((oauth, name) => {
|
|
36
|
-
oauth[name] = {
|
|
37
|
-
key: '<Client ID>',
|
|
38
|
-
secret: '<Client secret>'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return oauth
|
|
42
|
-
}, {} as any)
|
|
43
|
-
}
|
|
44
|
-
|
|
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
|
-
)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = void 0;
|
|
4
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const importTemplate = ({ upperName, folder, fileName }) => /* ts */ `import { ${upperName} } from './services/${folder.join('/')}/${fileName}'
|
|
6
|
-
`;
|
|
7
|
-
const paramsTemplate = ({ entity, upperName }) => /* ts */ `// Add the ${entity} as an optional property to all params
|
|
8
|
-
declare module '@feathersjs/feathers' {
|
|
9
|
-
interface Params {
|
|
10
|
-
${entity}?: ${upperName}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
14
|
-
const toDeclarationFile = (0, pinion_1.toFile)(({ lib }) => lib, 'declarations.ts');
|
|
15
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
16
|
-
.then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(importTemplate, (0, pinion_1.before)('export { NextFunction }'), toDeclarationFile)))
|
|
17
|
-
.then((0, pinion_1.when)((ctx) => ctx.language === 'ts', (0, pinion_1.inject)(paramsTemplate, (0, pinion_1.append)(), toDeclarationFile)));
|
|
18
|
-
exports.generate = generate;
|
|
19
|
-
//# sourceMappingURL=declarations.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"declarations.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/declarations.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAoF;AAGpF,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,MAAM,EACN,QAAQ,EACuB,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,SAAS,uBAAuB,MAAM,CAAC,IAAI,CACpG,GAAG,CACJ,IAAI,QAAQ;CACZ,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,EACtB,MAAM,EACN,SAAS,EACsB,EAAE,EAAE,CAAC,QAAQ,CAAC,cAAc,MAAM;;;MAG7D,MAAM,MAAM,SAAS;;;CAG1B,CAAA;AAED,MAAM,iBAAiB,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAA;AAE9F,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,eAAM,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,iBAAiB,CAAC,CAC7E,CACF;KACA,IAAI,CAAC,IAAA,aAAI,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAAE,IAAA,eAAM,EAAC,cAAc,EAAE,IAAA,eAAM,GAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;AARvF,QAAA,QAAQ,YAQ+E"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { generator, inject, before, toFile, when, append } from '@feathershq/pinion'
|
|
2
|
-
import { AuthenticationGeneratorContext } from '../index'
|
|
3
|
-
|
|
4
|
-
const importTemplate = ({
|
|
5
|
-
upperName,
|
|
6
|
-
folder,
|
|
7
|
-
fileName
|
|
8
|
-
}: AuthenticationGeneratorContext) => /* ts */ `import { ${upperName} } from './services/${folder.join(
|
|
9
|
-
'/'
|
|
10
|
-
)}/${fileName}'
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
const paramsTemplate = ({
|
|
14
|
-
entity,
|
|
15
|
-
upperName
|
|
16
|
-
}: AuthenticationGeneratorContext) => /* ts */ `// Add the ${entity} as an optional property to all params
|
|
17
|
-
declare module '@feathersjs/feathers' {
|
|
18
|
-
interface Params {
|
|
19
|
-
${entity}?: ${upperName}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
const toDeclarationFile = toFile<AuthenticationGeneratorContext>(({ lib }) => lib, 'declarations.ts')
|
|
25
|
-
|
|
26
|
-
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
27
|
-
generator(ctx)
|
|
28
|
-
.then(
|
|
29
|
-
when(
|
|
30
|
-
(ctx) => ctx.language === 'ts',
|
|
31
|
-
inject(importTemplate, before('export { NextFunction }'), toDeclarationFile)
|
|
32
|
-
)
|
|
33
|
-
)
|
|
34
|
-
.then(when((ctx) => ctx.language === 'ts', inject(paramsTemplate, append(), toDeclarationFile)))
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = void 0;
|
|
4
|
-
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const commons_1 = require("../../commons");
|
|
6
|
-
const migrationTemplate = ({ kebabPath, authStrategies }) => /* ts */ `import type { Knex } from 'knex'
|
|
7
|
-
|
|
8
|
-
export async function up(knex: Knex): Promise<void> {
|
|
9
|
-
await knex.schema.alterTable('${kebabPath}', function (table) {
|
|
10
|
-
table.dropColumn('text')${authStrategies
|
|
11
|
-
.map((name) => name === 'local'
|
|
12
|
-
? `
|
|
13
|
-
table.string('email').unique()
|
|
14
|
-
table.string('password')`
|
|
15
|
-
: `
|
|
16
|
-
table.string('${name}Id')`)
|
|
17
|
-
.join('\n')}
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function down(knex: Knex): Promise<void> {
|
|
22
|
-
await knex.schema.alterTable('${kebabPath}', function (table) {
|
|
23
|
-
table.string('text')${authStrategies
|
|
24
|
-
.map((name) => name === 'local'
|
|
25
|
-
? `
|
|
26
|
-
table.dropColumn('email')
|
|
27
|
-
table.dropColumn('password')`
|
|
28
|
-
: `
|
|
29
|
-
table.dropColumn('${name}Id')
|
|
30
|
-
`)
|
|
31
|
-
.join('\n')}
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
`;
|
|
35
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)((ctx) => { var _a; return (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database) === 'knex'; }, (0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)((0, pinion_1.toFile)('migrations', () => {
|
|
36
|
-
// Probably not great but it works to align with the Knex migration file format
|
|
37
|
-
// We add a few seconds so that the migrations run in the correct order
|
|
38
|
-
const migrationDate = new Date(Date.now() + 10000)
|
|
39
|
-
.toISOString()
|
|
40
|
-
.replace(/\D/g, '')
|
|
41
|
-
.substring(0, 14);
|
|
42
|
-
return `${migrationDate}_authentication`;
|
|
43
|
-
})))));
|
|
44
|
-
exports.generate = generate;
|
|
45
|
-
//# sourceMappingURL=knex.tpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAgE;AAGhE,MAAM,iBAAiB,GAAG,CAAC,EACzB,SAAS,EACT,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;kCAGb,SAAS;8BACb,cAAc;KACrC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;;6BAEiB;IACnB,CAAC,CAAC;oBACQ,IAAI,MAAM,CACvB;KACA,IAAI,CAAC,IAAI,CAAC;;;;;kCAKiB,SAAS;0BACjB,cAAc;KACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI,KAAK,OAAO;IACd,CAAC,CAAC;;iCAEqB;IACvB,CAAC,CAAC;wBACY,IAAI;KACvB,CACE;KACA,IAAI,CAAC,IAAI,CAAC;;;CAGhB,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,WAAC,OAAA,IAAA,4BAAkB,EAAC,MAAA,GAAG,CAAC,QAAQ,0CAAE,QAAQ,CAAC,KAAK,MAAM,CAAA,EAAA,EAC9D,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EACJ,IAAA,eAAM,EAAiC,YAAY,EAAE,GAAG,EAAE;IACxD,+EAA+E;IAC/E,uEAAuE;IACvE,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;SAC/C,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEnB,OAAO,GAAG,aAAa,iBAAiB,CAAA;AAC1C,CAAC,CAAC,CACH,CACF,CACF,CACF,CAAA;AApBU,QAAA,QAAQ,YAoBlB"}
|