@feathersjs/cli 4.6.2 → 5.0.0-pre.24
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 +10 -917
- package/LICENSE +1 -1
- package/README.md +9 -34
- package/bin/feathers +9 -0
- package/lib/app/index.d.ts +29 -0
- package/lib/app/index.js +123 -0
- package/lib/app/index.js.map +1 -0
- package/lib/app/index.ts +198 -0
- package/lib/app/static/.gitignore +121 -0
- package/lib/app/templates/app.test.tpl.d.ts +2 -0
- package/lib/app/templates/app.test.tpl.js +48 -0
- package/lib/app/templates/app.test.tpl.js.map +1 -0
- package/lib/app/templates/app.test.tpl.ts +48 -0
- package/lib/app/templates/app.tpl.d.ts +2 -0
- package/lib/app/templates/app.tpl.js +110 -0
- package/lib/app/templates/app.tpl.js.map +1 -0
- package/lib/app/templates/app.tpl.ts +119 -0
- package/lib/app/templates/channels.tpl.d.ts +2 -0
- package/lib/app/templates/channels.tpl.js +76 -0
- package/lib/app/templates/channels.tpl.js.map +1 -0
- package/lib/app/templates/channels.tpl.ts +81 -0
- package/lib/app/templates/client.tpl.d.ts +2 -0
- package/lib/app/templates/client.tpl.js +22 -0
- package/lib/app/templates/client.tpl.js.map +1 -0
- package/lib/app/templates/client.tpl.ts +27 -0
- package/lib/app/templates/config.tpl.d.ts +2 -0
- package/lib/app/templates/config.tpl.js +21 -0
- package/lib/app/templates/config.tpl.js.map +1 -0
- package/lib/app/templates/config.tpl.ts +21 -0
- package/lib/app/templates/configuration.tpl.d.ts +2 -0
- package/lib/app/templates/configuration.tpl.js +36 -0
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/configuration.tpl.ts +41 -0
- package/lib/app/templates/declarations.tpl.d.ts +2 -0
- package/lib/app/templates/declarations.tpl.js +23 -0
- package/lib/app/templates/declarations.tpl.js.map +1 -0
- package/lib/app/templates/declarations.tpl.ts +31 -0
- package/lib/app/templates/index.html.tpl.d.ts +2 -0
- package/lib/app/templates/index.html.tpl.js +85 -0
- package/lib/app/templates/index.html.tpl.js.map +1 -0
- package/lib/app/templates/index.html.tpl.ts +85 -0
- package/lib/app/templates/index.tpl.d.ts +2 -0
- package/lib/app/templates/index.tpl.js +18 -0
- package/lib/app/templates/index.tpl.js.map +1 -0
- package/lib/app/templates/index.tpl.ts +23 -0
- package/lib/app/templates/logger.tpl.d.ts +2 -0
- package/lib/app/templates/logger.tpl.js +33 -0
- package/lib/app/templates/logger.tpl.js.map +1 -0
- package/lib/app/templates/logger.tpl.ts +38 -0
- package/lib/app/templates/package.json.tpl.d.ts +2 -0
- package/lib/app/templates/package.json.tpl.js +53 -0
- package/lib/app/templates/package.json.tpl.js.map +1 -0
- package/lib/app/templates/package.json.tpl.ts +65 -0
- package/lib/app/templates/readme.md.tpl.d.ts +2 -0
- package/lib/app/templates/readme.md.tpl.js +50 -0
- package/lib/app/templates/readme.md.tpl.js.map +1 -0
- package/lib/app/templates/readme.md.tpl.ts +50 -0
- package/lib/app/templates/services.tpl.d.ts +2 -0
- package/lib/app/templates/services.tpl.js +14 -0
- package/lib/app/templates/services.tpl.js.map +1 -0
- package/lib/app/templates/services.tpl.ts +19 -0
- package/lib/app/templates/tsconfig.json.tpl.d.ts +2 -0
- package/lib/app/templates/tsconfig.json.tpl.js +20 -0
- package/lib/app/templates/tsconfig.json.tpl.js.map +1 -0
- package/lib/app/templates/tsconfig.json.tpl.ts +26 -0
- package/lib/authentication/index.d.ts +71 -0
- package/lib/authentication/index.js +94 -0
- package/lib/authentication/index.js.map +1 -0
- package/lib/authentication/index.ts +103 -0
- package/lib/authentication/templates/authentication.tpl.d.ts +2 -0
- package/lib/authentication/templates/authentication.tpl.js +40 -0
- package/lib/authentication/templates/authentication.tpl.js.map +1 -0
- package/lib/authentication/templates/authentication.tpl.ts +53 -0
- package/lib/authentication/templates/config.tpl.d.ts +2 -0
- package/lib/authentication/templates/config.tpl.js +46 -0
- package/lib/authentication/templates/config.tpl.js.map +1 -0
- package/lib/authentication/templates/config.tpl.ts +51 -0
- package/lib/authentication/templates/declarations.tpl.d.ts +2 -0
- package/lib/authentication/templates/declarations.tpl.js +19 -0
- package/lib/authentication/templates/declarations.tpl.js.map +1 -0
- package/lib/authentication/templates/declarations.tpl.ts +29 -0
- package/lib/authentication/templates/knex.tpl.d.ts +2 -0
- package/lib/authentication/templates/knex.tpl.js +41 -0
- package/lib/authentication/templates/knex.tpl.js.map +1 -0
- package/lib/authentication/templates/knex.tpl.ts +59 -0
- package/lib/authentication/templates/test.tpl.d.ts +2 -0
- package/lib/authentication/templates/test.tpl.js +43 -0
- package/lib/authentication/templates/test.tpl.js.map +1 -0
- package/lib/authentication/templates/test.tpl.ts +50 -0
- package/lib/authentication/templates/user.resolver.tpl.d.ts +2 -0
- package/lib/authentication/templates/user.resolver.tpl.js +96 -0
- package/lib/authentication/templates/user.resolver.tpl.js.map +1 -0
- package/lib/authentication/templates/user.resolver.tpl.ts +109 -0
- package/lib/authentication/templates/user.schema.tpl.d.ts +2 -0
- package/lib/authentication/templates/user.schema.tpl.js +85 -0
- package/lib/authentication/templates/user.schema.tpl.js.map +1 -0
- package/lib/authentication/templates/user.schema.tpl.ts +93 -0
- package/lib/commons.d.ts +120 -0
- package/lib/commons.js +137 -0
- package/lib/commons.js.map +1 -0
- package/lib/commons.ts +187 -0
- package/lib/connection/index.d.ts +53 -0
- package/lib/connection/index.js +86 -0
- package/lib/connection/index.js.map +1 -0
- package/lib/connection/index.ts +109 -0
- package/lib/connection/templates/knex.tpl.d.ts +2 -0
- package/lib/connection/templates/knex.tpl.js +59 -0
- package/lib/connection/templates/knex.tpl.js.map +1 -0
- package/lib/connection/templates/knex.tpl.ts +79 -0
- package/lib/connection/templates/mongodb.tpl.d.ts +2 -0
- package/lib/connection/templates/mongodb.tpl.js +39 -0
- package/lib/connection/templates/mongodb.tpl.js.map +1 -0
- package/lib/connection/templates/mongodb.tpl.ts +51 -0
- package/lib/hook/index.d.ts +22 -0
- package/lib/hook/index.js +40 -0
- package/lib/hook/index.js.map +1 -0
- package/lib/hook/index.ts +45 -0
- package/lib/hook/templates/hook.tpl.d.ts +2 -0
- package/lib/hook/templates/hook.tpl.js +21 -0
- package/lib/hook/templates/hook.tpl.js.map +1 -0
- package/lib/hook/templates/hook.tpl.ts +28 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +24 -62
- package/lib/index.js.map +1 -0
- package/lib/index.ts +27 -0
- package/lib/service/index.d.ts +130 -0
- package/lib/service/index.js +84 -0
- package/lib/service/index.js.map +1 -0
- package/lib/service/index.ts +150 -0
- package/lib/service/templates/client.tpl.d.ts +2 -0
- package/lib/service/templates/client.tpl.js +16 -0
- package/lib/service/templates/client.tpl.js.map +1 -0
- package/lib/service/templates/client.tpl.ts +27 -0
- package/lib/service/templates/resolver.tpl.d.ts +2 -0
- package/lib/service/templates/resolver.tpl.js +73 -0
- package/lib/service/templates/resolver.tpl.js.map +1 -0
- package/lib/service/templates/resolver.tpl.ts +78 -0
- package/lib/service/templates/schema.tpl.d.ts +2 -0
- package/lib/service/templates/schema.tpl.js +75 -0
- package/lib/service/templates/schema.tpl.js.map +1 -0
- package/lib/service/templates/schema.tpl.ts +80 -0
- package/lib/service/templates/service.tpl.d.ts +2 -0
- package/lib/service/templates/service.tpl.js +92 -0
- package/lib/service/templates/service.tpl.js.map +1 -0
- package/lib/service/templates/service.tpl.ts +117 -0
- package/lib/service/templates/test.tpl.d.ts +2 -0
- package/lib/service/templates/test.tpl.js +24 -0
- package/lib/service/templates/test.tpl.js.map +1 -0
- package/lib/service/templates/test.tpl.ts +29 -0
- package/lib/service/type/custom.tpl.d.ts +4 -0
- package/lib/service/type/custom.tpl.js +79 -0
- package/lib/service/type/custom.tpl.js.map +1 -0
- package/lib/service/type/custom.tpl.ts +81 -0
- package/lib/service/type/knex.tpl.d.ts +5 -0
- package/lib/service/type/knex.tpl.js +50 -0
- package/lib/service/type/knex.tpl.js.map +1 -0
- package/lib/service/type/knex.tpl.ts +62 -0
- package/lib/service/type/mongodb.tpl.d.ts +4 -0
- package/lib/service/type/mongodb.tpl.js +29 -0
- package/lib/service/type/mongodb.tpl.js.map +1 -0
- package/lib/service/type/mongodb.tpl.ts +34 -0
- package/package.json +56 -36
- package/bin/feathers.js +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.json.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/tsconfig.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAuE;AAGhE,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI,EAC9B,IAAA,kBAAS,EACP,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE;QACT,KAAK,EAAE,IAAI;KACZ;IACD,eAAe,EAAE;QACf,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,KAAK,GAAG,EAAE;QACnB,MAAM,EAAE,IAAI;QACZ,eAAe,EAAE,IAAI;KACtB;IACD,OAAO,EAAE,CAAC,MAAM,CAAC;CAClB,CAAC,EACF,IAAA,eAAM,EAAC,eAAe,CAAC,CACxB,CACF,CACF,CAAA;AAtBU,QAAA,QAAQ,YAsBlB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { generator, toFile, when, writeJSON } from '@feathershq/pinion'
|
|
2
|
+
import { AppGeneratorContext } from '../index'
|
|
3
|
+
|
|
4
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
5
|
+
generator(ctx).then(
|
|
6
|
+
when<AppGeneratorContext>(
|
|
7
|
+
(ctx) => ctx.language === 'ts',
|
|
8
|
+
writeJSON<AppGeneratorContext>(
|
|
9
|
+
({ lib }) => ({
|
|
10
|
+
'ts-node': {
|
|
11
|
+
files: true
|
|
12
|
+
},
|
|
13
|
+
compilerOptions: {
|
|
14
|
+
target: 'es2020',
|
|
15
|
+
module: 'commonjs',
|
|
16
|
+
outDir: './dist',
|
|
17
|
+
rootDir: `./${lib}`,
|
|
18
|
+
strict: true,
|
|
19
|
+
esModuleInterop: true
|
|
20
|
+
},
|
|
21
|
+
exclude: ['test']
|
|
22
|
+
}),
|
|
23
|
+
toFile('tsconfig.json')
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { FeathersBaseContext } from '../commons';
|
|
2
|
+
import { ServiceGeneratorContext } from '../service/index';
|
|
3
|
+
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
4
|
+
service: string;
|
|
5
|
+
entity: string;
|
|
6
|
+
authStrategies: string[];
|
|
7
|
+
dependencies: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>;
|
|
10
|
+
export declare const prompts: (ctx: AuthenticationGeneratorArguments) => ({
|
|
11
|
+
type: string;
|
|
12
|
+
name: string;
|
|
13
|
+
when: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
suffix: string;
|
|
16
|
+
choices: ({
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
checked: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
23
|
+
checked?: undefined;
|
|
24
|
+
})[];
|
|
25
|
+
default?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
when: boolean;
|
|
30
|
+
message: string;
|
|
31
|
+
default: string;
|
|
32
|
+
suffix?: undefined;
|
|
33
|
+
choices?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
when: boolean;
|
|
38
|
+
message: string;
|
|
39
|
+
suffix: string;
|
|
40
|
+
default: string;
|
|
41
|
+
choices?: undefined;
|
|
42
|
+
})[];
|
|
43
|
+
export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promise<{
|
|
44
|
+
dependencies: string[];
|
|
45
|
+
name: string;
|
|
46
|
+
path: string;
|
|
47
|
+
folder: string[];
|
|
48
|
+
camelName: string;
|
|
49
|
+
upperName: string;
|
|
50
|
+
className: string;
|
|
51
|
+
kebabName: string;
|
|
52
|
+
fileName: string;
|
|
53
|
+
relative: string;
|
|
54
|
+
type: "custom" | "mongodb" | "knex";
|
|
55
|
+
authentication: boolean;
|
|
56
|
+
isEntityService?: boolean;
|
|
57
|
+
schemaPath: string;
|
|
58
|
+
resolverPath: string;
|
|
59
|
+
feathers: import("../commons").FeathersAppInfo;
|
|
60
|
+
pkg: import("../commons").AppPackageJson;
|
|
61
|
+
lib: string;
|
|
62
|
+
test: string;
|
|
63
|
+
language: "js" | "ts";
|
|
64
|
+
dependencyVersions?: import("../commons").DependencyVersions;
|
|
65
|
+
cwd: string;
|
|
66
|
+
_?: (string | number)[];
|
|
67
|
+
pinion: import("@feathershq/pinion").Configuration;
|
|
68
|
+
service: string;
|
|
69
|
+
entity: string;
|
|
70
|
+
authStrategies: string[];
|
|
71
|
+
}>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generate = exports.prompts = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
9
|
+
const commons_1 = require("../commons");
|
|
10
|
+
const index_1 = require("../service/index");
|
|
11
|
+
const prompts = (ctx) => [
|
|
12
|
+
{
|
|
13
|
+
type: 'checkbox',
|
|
14
|
+
name: 'authStrategies',
|
|
15
|
+
when: !ctx.authStrategies,
|
|
16
|
+
message: 'Which authentication methods do you want to use?',
|
|
17
|
+
suffix: chalk_1.default.grey(' Other methods and providers can be added at any time.'),
|
|
18
|
+
choices: [
|
|
19
|
+
{
|
|
20
|
+
name: 'Email + Password',
|
|
21
|
+
value: 'local',
|
|
22
|
+
checked: true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Google',
|
|
26
|
+
value: 'google'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Facebook',
|
|
30
|
+
value: 'facebook'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Twitter',
|
|
34
|
+
value: 'twitter'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'GitHub',
|
|
38
|
+
value: 'github'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'Auth0',
|
|
42
|
+
value: 'auth0'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'service',
|
|
48
|
+
type: 'input',
|
|
49
|
+
when: !ctx.service,
|
|
50
|
+
message: 'What is your authentication service name?',
|
|
51
|
+
default: 'users'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'entity',
|
|
55
|
+
type: 'input',
|
|
56
|
+
when: !ctx.entity,
|
|
57
|
+
message: 'What is your authenticated entity name?',
|
|
58
|
+
suffix: chalk_1.default.grey(' Will be available in params (e.g. params.user)'),
|
|
59
|
+
default: 'user'
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
exports.prompts = prompts;
|
|
63
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
64
|
+
.then((0, pinion_1.prompt)(exports.prompts))
|
|
65
|
+
.then(async (ctx) => {
|
|
66
|
+
const serviceContext = await (0, index_1.generate)({
|
|
67
|
+
...ctx,
|
|
68
|
+
name: ctx.service,
|
|
69
|
+
path: ctx.service,
|
|
70
|
+
isEntityService: true,
|
|
71
|
+
type: (0, commons_1.getDatabaseAdapter)(ctx.feathers.database)
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
...ctx,
|
|
75
|
+
...serviceContext
|
|
76
|
+
};
|
|
77
|
+
})
|
|
78
|
+
.then((0, pinion_1.runGenerators)(__dirname, 'templates'))
|
|
79
|
+
.then((ctx) => {
|
|
80
|
+
const dependencies = [];
|
|
81
|
+
dependencies.push('@feathersjs/authentication-oauth');
|
|
82
|
+
if (ctx.authStrategies.includes('local')) {
|
|
83
|
+
dependencies.push('@feathersjs/authentication-local');
|
|
84
|
+
}
|
|
85
|
+
if (ctx.dependencies) {
|
|
86
|
+
return {
|
|
87
|
+
...ctx,
|
|
88
|
+
dependencies: [...ctx.dependencies, ...dependencies]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions))(ctx);
|
|
92
|
+
});
|
|
93
|
+
exports.generate = generate;
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,CAAC,GAAG,CAAC,cAAc;QACzB,OAAO,EAAE,kDAAkD;QAC3D,MAAM,EAAE,eAAK,CAAC,IAAI,CAAC,wDAAwD,CAAC;QAC5E,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,IAAI;aACd;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;aACjB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,OAAO;aACf;SACF;KACF;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO;QAClB,OAAO,EAAE,2CAA2C;QACpD,OAAO,EAAE,OAAO;KACjB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM;QACjB,OAAO,EAAE,yCAAyC;QAClD,MAAM,EAAE,eAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC;QACrE,OAAO,EAAE,MAAM;KAChB;CACF,CAAA;AAlDY,QAAA,OAAO,WAkDnB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAqC,EAAE,EAAE,CAChE,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,eAAM,EAAmE,eAAO,CAAC,CAAC;KACvF,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAClB,MAAM,cAAc,GAAG,MAAM,IAAA,gBAAgB,EAAC;QAC5C,GAAG,GAAG;QACN,IAAI,EAAE,GAAG,CAAC,OAAO;QACjB,IAAI,EAAE,GAAG,CAAC,OAAO;QACjB,eAAe,EAAE,IAAI;QACrB,IAAI,EAAE,IAAA,4BAAkB,EAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;KAChD,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,EAAiC,IAAA,qBAAW,EAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AACxG,CAAC,CAAC,CAAA;AAnCO,QAAA,QAAQ,YAmCf"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
|
|
3
|
+
import { addVersions, FeathersBaseContext, getDatabaseAdapter } from '../commons'
|
|
4
|
+
import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
|
|
5
|
+
|
|
6
|
+
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
7
|
+
service: string
|
|
8
|
+
entity: string
|
|
9
|
+
authStrategies: string[]
|
|
10
|
+
dependencies: string[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type AuthenticationGeneratorArguments = FeathersBaseContext &
|
|
14
|
+
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>
|
|
15
|
+
|
|
16
|
+
export const prompts = (ctx: AuthenticationGeneratorArguments) => [
|
|
17
|
+
{
|
|
18
|
+
type: 'checkbox',
|
|
19
|
+
name: 'authStrategies',
|
|
20
|
+
when: !ctx.authStrategies,
|
|
21
|
+
message: 'Which authentication methods do you want to use?',
|
|
22
|
+
suffix: chalk.grey(' Other methods and providers can be added at any time.'),
|
|
23
|
+
choices: [
|
|
24
|
+
{
|
|
25
|
+
name: 'Email + Password',
|
|
26
|
+
value: 'local',
|
|
27
|
+
checked: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Google',
|
|
31
|
+
value: 'google'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Facebook',
|
|
35
|
+
value: 'facebook'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Twitter',
|
|
39
|
+
value: 'twitter'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'GitHub',
|
|
43
|
+
value: 'github'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Auth0',
|
|
47
|
+
value: 'auth0'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'service',
|
|
53
|
+
type: 'input',
|
|
54
|
+
when: !ctx.service,
|
|
55
|
+
message: 'What is your authentication service name?',
|
|
56
|
+
default: 'users'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'entity',
|
|
60
|
+
type: 'input',
|
|
61
|
+
when: !ctx.entity,
|
|
62
|
+
message: 'What is your authenticated entity name?',
|
|
63
|
+
suffix: chalk.grey(' Will be available in params (e.g. params.user)'),
|
|
64
|
+
default: 'user'
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
export const generate = (ctx: AuthenticationGeneratorArguments) =>
|
|
69
|
+
generator(ctx)
|
|
70
|
+
.then(prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(prompts))
|
|
71
|
+
.then(async (ctx) => {
|
|
72
|
+
const serviceContext = await serviceGenerator({
|
|
73
|
+
...ctx,
|
|
74
|
+
name: ctx.service,
|
|
75
|
+
path: ctx.service,
|
|
76
|
+
isEntityService: true,
|
|
77
|
+
type: getDatabaseAdapter(ctx.feathers.database)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
...ctx,
|
|
82
|
+
...serviceContext
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.then(runGenerators(__dirname, 'templates'))
|
|
86
|
+
.then((ctx) => {
|
|
87
|
+
const dependencies: string[] = []
|
|
88
|
+
|
|
89
|
+
dependencies.push('@feathersjs/authentication-oauth')
|
|
90
|
+
|
|
91
|
+
if (ctx.authStrategies.includes('local')) {
|
|
92
|
+
dependencies.push('@feathersjs/authentication-local')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (ctx.dependencies) {
|
|
96
|
+
return {
|
|
97
|
+
...ctx,
|
|
98
|
+
dependencies: [...ctx.dependencies, ...dependencies]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return install<AuthenticationGeneratorContext>(addVersions(dependencies, ctx.dependencyVersions))(ctx)
|
|
103
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const commons_1 = require("../../commons");
|
|
6
|
+
const template = ({ authStrategies, feathers }) => `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
7
|
+
import { LocalStrategy } from '@feathersjs/authentication-local'
|
|
8
|
+
import { OAuthStrategy } from '@feathersjs/authentication-oauth'
|
|
9
|
+
${feathers.framework === 'express' ? `import { expressOauth } from '@feathersjs/authentication-oauth'` : ''}
|
|
10
|
+
import type { Application } from './declarations'
|
|
11
|
+
|
|
12
|
+
declare module './declarations' {
|
|
13
|
+
interface ServiceTypes {
|
|
14
|
+
'authentication': AuthenticationService
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const authentication = (app: Application) => {
|
|
19
|
+
const authentication = new AuthenticationService(app)
|
|
20
|
+
|
|
21
|
+
authentication.register('jwt', new JWTStrategy())
|
|
22
|
+
${authStrategies
|
|
23
|
+
.map((strategy) => ` authentication.register('${strategy}', ${strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`})`)
|
|
24
|
+
.join('\n')}
|
|
25
|
+
|
|
26
|
+
app.use('authentication', authentication)${feathers.framework === 'express'
|
|
27
|
+
? `
|
|
28
|
+
app.configure(expressOauth())`
|
|
29
|
+
: ''}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
const importTemplate = "import { authentication } from './authentication'";
|
|
33
|
+
const configureTemplate = 'app.configure(authentication)';
|
|
34
|
+
const toAppFile = (0, pinion_1.toFile)(({ lib, language }) => [lib, `app.${language}`]);
|
|
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, pinion_1.inject)((0, commons_1.getSource)(importTemplate), (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
38
|
+
.then((0, pinion_1.inject)((0, commons_1.getSource)(configureTemplate), (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
39
|
+
exports.generate = generate;
|
|
40
|
+
//# sourceMappingURL=authentication.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AACtE,2CAAuD;AAGvD,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,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAA;AAElG,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,eAAM,EAAC,IAAA,mBAAS,EAAC,cAAc,CAAC,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACtF,IAAI,CAAC,IAAA,eAAM,EAAC,IAAA,mBAAS,EAAC,iBAAiB,CAAC,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAThF,QAAA,QAAQ,YASwE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { generator, inject, before, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { getSource, renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({ authStrategies, feathers }: AuthenticationGeneratorContext) =>
|
|
6
|
+
`import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
7
|
+
import { LocalStrategy } from '@feathersjs/authentication-local'
|
|
8
|
+
import { OAuthStrategy } from '@feathersjs/authentication-oauth'
|
|
9
|
+
${feathers.framework === 'express' ? `import { expressOauth } from '@feathersjs/authentication-oauth'` : ''}
|
|
10
|
+
import type { Application } from './declarations'
|
|
11
|
+
|
|
12
|
+
declare module './declarations' {
|
|
13
|
+
interface ServiceTypes {
|
|
14
|
+
'authentication': AuthenticationService
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const authentication = (app: Application) => {
|
|
19
|
+
const authentication = new AuthenticationService(app)
|
|
20
|
+
|
|
21
|
+
authentication.register('jwt', new JWTStrategy())
|
|
22
|
+
${authStrategies
|
|
23
|
+
.map(
|
|
24
|
+
(strategy) =>
|
|
25
|
+
` authentication.register('${strategy}', ${
|
|
26
|
+
strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`
|
|
27
|
+
})`
|
|
28
|
+
)
|
|
29
|
+
.join('\n')}
|
|
30
|
+
|
|
31
|
+
app.use('authentication', authentication)${
|
|
32
|
+
feathers.framework === 'express'
|
|
33
|
+
? `
|
|
34
|
+
app.configure(expressOauth())`
|
|
35
|
+
: ''
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
const importTemplate = "import { authentication } from './authentication'"
|
|
41
|
+
const configureTemplate = 'app.configure(authentication)'
|
|
42
|
+
const toAppFile = toFile<AuthenticationGeneratorContext>(({ lib, language }) => [lib, `app.${language}`])
|
|
43
|
+
|
|
44
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
45
|
+
generator(ctx)
|
|
46
|
+
.then(
|
|
47
|
+
renderSource(
|
|
48
|
+
template,
|
|
49
|
+
toFile<AuthenticationGeneratorContext>(({ lib }) => lib, 'authentication')
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
.then(inject(getSource(importTemplate), before('import { services } from'), toAppFile))
|
|
53
|
+
.then(inject(getSource(configureTemplate), before('app.configure(services)'), toAppFile))
|
|
@@ -0,0 +1,46 @@
|
|
|
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).then((0, pinion_1.mergeJSON)(({ authStrategies }) => {
|
|
10
|
+
const authentication = {
|
|
11
|
+
entity: ctx.entity,
|
|
12
|
+
service: ctx.service,
|
|
13
|
+
secret: crypto_1.default.randomBytes(24).toString('base64'),
|
|
14
|
+
authStrategies: ['jwt'],
|
|
15
|
+
jwtOptions: {
|
|
16
|
+
header: {
|
|
17
|
+
typ: 'access'
|
|
18
|
+
},
|
|
19
|
+
audience: 'https://yourdomain.com',
|
|
20
|
+
algorithm: 'HS256',
|
|
21
|
+
expiresIn: '1d'
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
if (authStrategies.includes('local')) {
|
|
25
|
+
authentication.authStrategies.push('local');
|
|
26
|
+
authentication.local = {
|
|
27
|
+
usernameField: 'email',
|
|
28
|
+
passwordField: 'password'
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const oauthStrategies = authStrategies.filter((name) => name !== 'local');
|
|
32
|
+
if (oauthStrategies.length) {
|
|
33
|
+
authentication.oauth = oauthStrategies.reduce((oauth, name) => {
|
|
34
|
+
oauth[name] = {
|
|
35
|
+
key: '<Client ID>',
|
|
36
|
+
secret: '<Client secret>'
|
|
37
|
+
};
|
|
38
|
+
return oauth;
|
|
39
|
+
}, {
|
|
40
|
+
redirect: '/'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return { authentication };
|
|
44
|
+
}, (0, pinion_1.toFile)('config', 'default.json')));
|
|
45
|
+
exports.generate = generate;
|
|
46
|
+
//# sourceMappingURL=config.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAC,IAAI,CACjB,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,OAAO;QACpB,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,CAC3C,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACd,KAAK,CAAC,IAAI,CAAC,GAAG;gBACZ,GAAG,EAAE,aAAa;gBAClB,MAAM,EAAE,iBAAiB;aAC1B,CAAA;YAED,OAAO,KAAK,CAAA;QACd,CAAC,EACD;YACE,QAAQ,EAAE,GAAG;SACP,CACT,CAAA;KACF;IAED,OAAO,EAAE,cAAc,EAAE,CAAA;AAC3B,CAAC,EAAE,IAAA,eAAM,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CACrC,CAAA;AA9CU,QAAA,QAAQ,YA8ClB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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).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'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (authStrategies.includes('local')) {
|
|
24
|
+
authentication.authStrategies.push('local')
|
|
25
|
+
authentication.local = {
|
|
26
|
+
usernameField: 'email',
|
|
27
|
+
passwordField: 'password'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const oauthStrategies = authStrategies.filter((name) => name !== 'local')
|
|
32
|
+
|
|
33
|
+
if (oauthStrategies.length) {
|
|
34
|
+
authentication.oauth = oauthStrategies.reduce(
|
|
35
|
+
(oauth, name) => {
|
|
36
|
+
oauth[name] = {
|
|
37
|
+
key: '<Client ID>',
|
|
38
|
+
secret: '<Client secret>'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return oauth
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
redirect: '/'
|
|
45
|
+
} as any
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { authentication }
|
|
50
|
+
}, toFile('config', 'default.json'))
|
|
51
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
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, schemaPath }) => `import { ${upperName}Result } from './${schemaPath}'
|
|
6
|
+
`;
|
|
7
|
+
const paramsTemplate = ({ entity, upperName }) => `// Add the ${entity} as an optional property to all params
|
|
8
|
+
declare module '@feathersjs/feathers' {
|
|
9
|
+
interface Params {
|
|
10
|
+
${entity}?: ${upperName}Result
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/declarations.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAoF;AAGpF,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAkC,EAAE,EAAE,CACnF,YAAY,SAAS,oBAAoB,UAAU;CACpD,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,EACtB,MAAM,EACN,SAAS,EACsB,EAAE,EAAE,CAAC,cAAc,MAAM;;;MAGpD,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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { generator, inject, before, toFile, when, append } from '@feathershq/pinion'
|
|
2
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
3
|
+
|
|
4
|
+
const importTemplate = ({ upperName, schemaPath }: AuthenticationGeneratorContext) =>
|
|
5
|
+
`import { ${upperName}Result } from './${schemaPath}'
|
|
6
|
+
`
|
|
7
|
+
|
|
8
|
+
const paramsTemplate = ({
|
|
9
|
+
entity,
|
|
10
|
+
upperName
|
|
11
|
+
}: AuthenticationGeneratorContext) => `// Add the ${entity} as an optional property to all params
|
|
12
|
+
declare module '@feathersjs/feathers' {
|
|
13
|
+
interface Params {
|
|
14
|
+
${entity}?: ${upperName}Result
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
const toDeclarationFile = toFile<AuthenticationGeneratorContext>(({ lib }) => lib, 'declarations.ts')
|
|
20
|
+
|
|
21
|
+
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
22
|
+
generator(ctx)
|
|
23
|
+
.then(
|
|
24
|
+
when(
|
|
25
|
+
(ctx) => ctx.language === 'ts',
|
|
26
|
+
inject(importTemplate, before('export { NextFunction }'), toDeclarationFile)
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
.then(when((ctx) => ctx.language === 'ts', inject(paramsTemplate, append(), toDeclarationFile)))
|
|
@@ -0,0 +1,41 @@
|
|
|
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 = ({ kebabName, authStrategies }) => `import type { Knex } from 'knex'
|
|
7
|
+
|
|
8
|
+
export async function up(knex: Knex): Promise<void> {
|
|
9
|
+
await knex.schema.alterTable('${kebabName}', 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('${kebabName}', 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
|
+
.join(',\n')}
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)((ctx) => (0, commons_1.getDatabaseAdapter)(ctx.feathers.database) === 'knex', (0, commons_1.renderSource)(migrationTemplate, (0, pinion_1.toFile)((0, pinion_1.toFile)('migrations', () => {
|
|
35
|
+
const now = new Date();
|
|
36
|
+
const migrationDate = `${now.getUTCFullYear()}${now.getUTCMonth()}${now.getUTCDay()}` +
|
|
37
|
+
`${now.getUTCHours()}${now.getUTCMinutes()}${now.getUTCSeconds() + 1}`;
|
|
38
|
+
return `${migrationDate}_authentication`;
|
|
39
|
+
})))));
|
|
40
|
+
exports.generate = generate;
|
|
41
|
+
//# sourceMappingURL=knex.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;;;kCAGJ,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,MAAM,CAC3B;KACA,IAAI,CAAC,KAAK,CAAC;;;CAGjB,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,CAAC,IAAA,4BAAkB,EAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,MAAM,EAC7D,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EACJ,IAAA,eAAM,EAAiC,YAAY,EAAE,GAAG,EAAE;IACxD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,MAAM,aAAa,GACjB,GAAG,GAAG,CAAC,cAAc,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,EAAE,EAAE;QAC/D,GAAG,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,CAAA;IAExE,OAAO,GAAG,aAAa,iBAAiB,CAAA;AAC1C,CAAC,CAAC,CACH,CACF,CACF,CACF,CAAA;AAlBU,QAAA,QAAQ,YAkBlB"}
|