@feathersjs/generators 5.0.0-pre.37 → 5.0.0
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 +13 -0
- package/README.md +0 -1
- package/lib/app/index.d.ts +38 -5
- package/lib/app/index.js +11 -21
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +18 -41
- package/lib/app/templates/app.tpl.js +10 -9
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +12 -9
- package/lib/app/templates/channels.tpl.js +1 -6
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +7 -9
- package/lib/app/templates/client.test.tpl.js +1 -1
- package/lib/app/templates/client.test.tpl.js.map +1 -1
- package/lib/app/templates/client.test.tpl.ts +4 -2
- package/lib/app/templates/client.tpl.js +1 -1
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +7 -4
- package/lib/app/templates/configuration.tpl.js +7 -4
- package/lib/app/templates/configuration.tpl.js.map +1 -1
- package/lib/app/templates/configuration.tpl.ts +14 -8
- package/lib/app/templates/declarations.tpl.js +4 -2
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +7 -2
- package/lib/app/templates/package.json.tpl.js +9 -3
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +9 -2
- package/lib/authentication/index.d.ts +3 -38
- package/lib/authentication/index.js +8 -23
- package/lib/authentication/index.js.map +1 -1
- package/lib/authentication/index.ts +58 -75
- package/lib/authentication/templates/authentication.tpl.js +4 -4
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +2 -1
- package/lib/authentication/templates/client.test.tpl.js +5 -5
- package/lib/authentication/templates/client.test.tpl.js.map +1 -1
- package/lib/authentication/templates/client.test.tpl.ts +11 -7
- package/lib/commons.d.ts +19 -3
- package/lib/commons.js +19 -1
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +24 -3
- package/lib/connection/index.d.ts +3 -20
- package/lib/connection/index.js +13 -10
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +58 -50
- package/lib/connection/templates/knex.tpl.js +10 -1
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -0
- package/lib/connection/templates/mongodb.tpl.js +8 -8
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +11 -9
- package/lib/service/index.d.ts +4 -0
- package/lib/service/index.js +82 -73
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +94 -74
- package/lib/service/templates/client.tpl.js +1 -3
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +7 -5
- package/lib/service/templates/schema.json.tpl.js +43 -22
- package/lib/service/templates/schema.json.tpl.js.map +1 -1
- package/lib/service/templates/schema.json.tpl.ts +56 -22
- package/lib/service/templates/schema.typebox.tpl.js +46 -11
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -1
- package/lib/service/templates/schema.typebox.tpl.ts +63 -11
- package/lib/service/templates/service.tpl.d.ts +1 -1
- package/lib/service/templates/service.tpl.js +6 -2
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +11 -2
- package/lib/service/templates/shared.tpl.js +2 -2
- package/lib/service/templates/shared.tpl.js.map +1 -1
- package/lib/service/templates/shared.tpl.ts +13 -10
- package/lib/service/type/custom.tpl.js +1 -1
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +1 -1
- package/lib/service/type/knex.tpl.js +13 -3
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +19 -3
- package/lib/service/type/mongodb.tpl.js +1 -1
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +1 -1
- package/package.json +24 -24
- package/lib/authentication/templates/knex.tpl.d.ts +0 -2
- package/lib/authentication/templates/knex.tpl.js +0 -37
- package/lib/authentication/templates/knex.tpl.js.map +0 -1
- package/lib/authentication/templates/knex.tpl.ts +0 -56
- package/lib/authentication/templates/schema.json.tpl.d.ts +0 -2
- package/lib/authentication/templates/schema.json.tpl.js +0 -109
- package/lib/authentication/templates/schema.json.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.json.tpl.ts +0 -132
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +0 -3
- package/lib/authentication/templates/schema.typebox.tpl.js +0 -87
- package/lib/authentication/templates/schema.typebox.tpl.js.map +0 -1
- package/lib/authentication/templates/schema.typebox.tpl.ts +0 -109
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generator, toFile, writeJSON } from '@feathershq/pinion'
|
|
1
|
+
import { generator, toFile, when, writeJSON } from '@feathershq/pinion'
|
|
2
2
|
import { renderSource } from '../../commons'
|
|
3
3
|
import { AppGeneratorContext } from '../index'
|
|
4
4
|
|
|
@@ -18,7 +18,10 @@ const customEnvironment = {
|
|
|
18
18
|
__name: 'PORT',
|
|
19
19
|
__format: 'number'
|
|
20
20
|
},
|
|
21
|
-
host: 'HOSTNAME'
|
|
21
|
+
host: 'HOSTNAME',
|
|
22
|
+
authentication: {
|
|
23
|
+
secret: 'FEATHERS_SECRET'
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
const testConfig = {
|
|
@@ -26,7 +29,7 @@ const testConfig = {
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
const configurationJsonTemplate =
|
|
29
|
-
({}: AppGeneratorContext) =>
|
|
32
|
+
({}: AppGeneratorContext) => `import { defaultAppSettings, getValidator } from '@feathersjs/schema'
|
|
30
33
|
import type { FromSchema } from '@feathersjs/schema'
|
|
31
34
|
|
|
32
35
|
import { dataValidator } from './validators'
|
|
@@ -50,7 +53,7 @@ export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
|
|
|
50
53
|
`
|
|
51
54
|
|
|
52
55
|
const configurationTypeboxTemplate =
|
|
53
|
-
({}: AppGeneratorContext) =>
|
|
56
|
+
({}: AppGeneratorContext) => `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
54
57
|
import type { Static } from '@feathersjs/typebox'
|
|
55
58
|
|
|
56
59
|
import { dataValidator } from './validators'
|
|
@@ -75,9 +78,12 @@ export const generate = (ctx: AppGeneratorContext) =>
|
|
|
75
78
|
.then(writeJSON(testConfig, toFile('config', 'test.json')))
|
|
76
79
|
.then(writeJSON(customEnvironment, toFile('config', 'custom-environment-variables.json')))
|
|
77
80
|
.then(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
when<AppGeneratorContext>(
|
|
82
|
+
(ctx) => ctx.schema !== false,
|
|
83
|
+
renderSource(
|
|
84
|
+
async (ctx) =>
|
|
85
|
+
ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx),
|
|
86
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'configuration')
|
|
87
|
+
)
|
|
82
88
|
)
|
|
83
89
|
)
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const template = ({ framework }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/typescript.html
|
|
5
|
+
const template = ({ framework, schema }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/typescript.html
|
|
6
6
|
import { HookContext as FeathersHookContext, NextFunction } from '@feathersjs/feathers'
|
|
7
7
|
import { Application as FeathersApplication } from '@feathersjs/${framework}'
|
|
8
|
-
|
|
8
|
+
${schema === false
|
|
9
|
+
? `type ApplicationConfiguration = any`
|
|
10
|
+
: `import { ApplicationConfiguration } from './configuration'`}
|
|
9
11
|
|
|
10
12
|
export { NextFunction }
|
|
11
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/declarations.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4E;AAG5E,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,
|
|
1
|
+
{"version":3,"file":"declarations.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/declarations.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4E;AAG5E,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,MAAM,EACc,EAAE,EAAE,CAAC,QAAQ,CAAC;;kEAE8B,SAAS;EAEzE,MAAM,KAAK,KAAK;IACd,CAAC,CAAC,qCAAqC;IACvC,CAAC,CAAC,4DACN;;;;;;;;;;;;;;;;;CAiBC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,EACnC,IAAA,uBAAc,EACZ,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,CACjE,CACF,CACF,CAAA;AATU,QAAA,QAAQ,YASlB"}
|
|
@@ -2,11 +2,16 @@ import { generator, toFile, when, renderTemplate } from '@feathershq/pinion'
|
|
|
2
2
|
import { AppGeneratorContext } from '../index'
|
|
3
3
|
|
|
4
4
|
const template = ({
|
|
5
|
-
framework
|
|
5
|
+
framework,
|
|
6
|
+
schema
|
|
6
7
|
}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/typescript.html
|
|
7
8
|
import { HookContext as FeathersHookContext, NextFunction } from '@feathersjs/feathers'
|
|
8
9
|
import { Application as FeathersApplication } from '@feathersjs/${framework}'
|
|
9
|
-
|
|
10
|
+
${
|
|
11
|
+
schema === false
|
|
12
|
+
? `type ApplicationConfiguration = any`
|
|
13
|
+
: `import { ApplicationConfiguration } from './configuration'`
|
|
14
|
+
}
|
|
10
15
|
|
|
11
16
|
export { NextFunction }
|
|
12
17
|
|
|
@@ -24,7 +24,7 @@ const tsPackageJson = (lib) => ({
|
|
|
24
24
|
'bundle:client': 'npm run compile && npm pack --pack-destination ./public'
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
const packageJson = ({ name, description, language, packager, database, framework, transports, lib, test, schema }) => ({
|
|
27
|
+
const packageJson = ({ name, description, client, language, packager, database, framework, transports, lib, test, schema }) => ({
|
|
28
28
|
name,
|
|
29
29
|
description,
|
|
30
30
|
version: '0.0.0',
|
|
@@ -49,8 +49,14 @@ const packageJson = ({ name, description, language, packager, database, framewor
|
|
|
49
49
|
lib,
|
|
50
50
|
test
|
|
51
51
|
},
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
...(client
|
|
53
|
+
? {
|
|
54
|
+
files: ['lib/client.js', 'lib/**/*.d.ts', 'lib/**/*.shared.js'],
|
|
55
|
+
main: language === 'ts' ? 'lib/client' : `${lib}/client`
|
|
56
|
+
}
|
|
57
|
+
: {
|
|
58
|
+
main: 'lib/index'
|
|
59
|
+
}),
|
|
54
60
|
...(language === 'ts' ? tsPackageJson(lib) : jsPackageJson(lib))
|
|
55
61
|
});
|
|
56
62
|
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.writeJSON)(packageJson, (0, pinion_1.toFile)('package.json')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/package.json.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAiE;AAGjE,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC;IACtC,IAAI,EAAE,QAAQ;IACd,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QACV,MAAM;KACP;IACD,WAAW,EAAE;QACX,GAAG;QACH,IAAI;KACL;IACD,GAAG,CAAC,MAAM;QACR,CAAC,CAAC;YACE,KAAK,EAAE,CAAC,eAAe,EAAE,eAAe,EAAE,oBAAoB,CAAC;YAC/D,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,GAAG,SAAS;SACzD;QACH,CAAC,CAAC;YACE,IAAI,EAAE,WAAW;SAClB,CAAC;IACN,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;CACjE,CAAC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,kBAAS,EAAC,WAAW,EAAE,IAAA,eAAM,EAAC,cAAc,CAAC,CAAC,CAAC,CAAA;AADxD,QAAA,QAAQ,YACgD"}
|
|
@@ -29,6 +29,7 @@ const tsPackageJson = (lib: string) => ({
|
|
|
29
29
|
const packageJson = ({
|
|
30
30
|
name,
|
|
31
31
|
description,
|
|
32
|
+
client,
|
|
32
33
|
language,
|
|
33
34
|
packager,
|
|
34
35
|
database,
|
|
@@ -62,8 +63,14 @@ const packageJson = ({
|
|
|
62
63
|
lib,
|
|
63
64
|
test
|
|
64
65
|
},
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
...(client
|
|
67
|
+
? {
|
|
68
|
+
files: ['lib/client.js', 'lib/**/*.d.ts', 'lib/**/*.shared.js'],
|
|
69
|
+
main: language === 'ts' ? 'lib/client' : `${lib}/client`
|
|
70
|
+
}
|
|
71
|
+
: {
|
|
72
|
+
main: 'lib/index'
|
|
73
|
+
}),
|
|
67
74
|
...(language === 'ts' ? tsPackageJson(lib) : jsPackageJson(lib))
|
|
68
75
|
})
|
|
69
76
|
|
|
@@ -6,42 +6,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
|
|
|
6
6
|
authStrategies: string[];
|
|
7
7
|
dependencies: string[];
|
|
8
8
|
}
|
|
9
|
-
export type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | '
|
|
10
|
-
export declare const localTemplate: (authStrategies: string[], content: string) => string;
|
|
11
|
-
export declare const oauthTemplate: (authStrategies: string[], content: string) => string;
|
|
12
|
-
export declare const prompts: (ctx: AuthenticationGeneratorArguments) => ({
|
|
13
|
-
type: string;
|
|
14
|
-
name: string;
|
|
15
|
-
when: boolean;
|
|
16
|
-
message: string;
|
|
17
|
-
suffix: string;
|
|
18
|
-
choices: ({
|
|
19
|
-
name: string;
|
|
20
|
-
value: string;
|
|
21
|
-
checked: boolean;
|
|
22
|
-
} | {
|
|
23
|
-
name: string;
|
|
24
|
-
value: string;
|
|
25
|
-
checked?: undefined;
|
|
26
|
-
})[];
|
|
27
|
-
default?: undefined;
|
|
28
|
-
} | {
|
|
29
|
-
name: string;
|
|
30
|
-
type: string;
|
|
31
|
-
when: boolean;
|
|
32
|
-
message: string;
|
|
33
|
-
default: string;
|
|
34
|
-
suffix?: undefined;
|
|
35
|
-
choices?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
name: string;
|
|
38
|
-
type: string;
|
|
39
|
-
when: boolean;
|
|
40
|
-
message: string;
|
|
41
|
-
suffix: string;
|
|
42
|
-
default: string;
|
|
43
|
-
choices?: undefined;
|
|
44
|
-
})[];
|
|
9
|
+
export type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'path' | 'schema' | 'type'>>;
|
|
45
10
|
export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promise<{
|
|
46
11
|
dependencies: string[];
|
|
47
12
|
name: string;
|
|
@@ -58,6 +23,7 @@ export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promis
|
|
|
58
23
|
schema: false | "typebox" | "json";
|
|
59
24
|
authentication: boolean;
|
|
60
25
|
isEntityService?: boolean;
|
|
26
|
+
authStrategies: string[];
|
|
61
27
|
feathers: import("../commons").FeathersAppInfo;
|
|
62
28
|
pkg: import("../commons").AppPackageJson;
|
|
63
29
|
lib: string;
|
|
@@ -67,7 +33,6 @@ export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promis
|
|
|
67
33
|
cwd: string;
|
|
68
34
|
_?: (string | number)[];
|
|
69
35
|
pinion: import("@feathershq/pinion").Configuration;
|
|
70
|
-
service: string;
|
|
71
36
|
entity: string;
|
|
72
|
-
|
|
37
|
+
service: string;
|
|
73
38
|
}>;
|
|
@@ -3,16 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generate =
|
|
6
|
+
exports.generate = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const pinion_1 = require("@feathershq/pinion");
|
|
9
9
|
const commons_1 = require("../commons");
|
|
10
10
|
const index_1 = require("../service/index");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const prompts = (ctx) => [
|
|
11
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
12
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
13
|
+
.then((0, commons_1.checkPreconditions)())
|
|
14
|
+
.then((0, pinion_1.prompt)((ctx) => [
|
|
16
15
|
{
|
|
17
16
|
type: 'checkbox',
|
|
18
17
|
name: 'authStrategies',
|
|
@@ -60,31 +59,17 @@ const prompts = (ctx) => [
|
|
|
60
59
|
when: !ctx.path,
|
|
61
60
|
message: 'What path should the service be registered on?',
|
|
62
61
|
default: 'users'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'entity',
|
|
66
|
-
type: 'input',
|
|
67
|
-
when: !ctx.entity,
|
|
68
|
-
message: 'What is your authenticated entity name?',
|
|
69
|
-
suffix: chalk_1.default.grey(' Will be available in params (e.g. params.user)'),
|
|
70
|
-
default: 'user'
|
|
71
62
|
}
|
|
72
|
-
]
|
|
73
|
-
exports.prompts = prompts;
|
|
74
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
75
|
-
.then((0, commons_1.initializeBaseContext)())
|
|
76
|
-
.then((0, commons_1.checkPreconditions)())
|
|
77
|
-
.then((0, pinion_1.prompt)(exports.prompts))
|
|
63
|
+
]))
|
|
78
64
|
.then(async (ctx) => {
|
|
79
|
-
var _a;
|
|
80
65
|
const serviceContext = await (0, index_1.generate)({
|
|
81
66
|
...ctx,
|
|
82
67
|
name: ctx.service,
|
|
83
|
-
isEntityService: true
|
|
84
|
-
type: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database)
|
|
68
|
+
isEntityService: true
|
|
85
69
|
});
|
|
86
70
|
return {
|
|
87
71
|
...ctx,
|
|
72
|
+
entity: ctx.service,
|
|
88
73
|
...serviceContext
|
|
89
74
|
};
|
|
90
75
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+CAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+CAA8E;AAC9E,wCAAwG;AACxG,4CAAwF;AAYjF,MAAM,QAAQ,GAAG,CAAC,GAAqC,EAAE,EAAE,CAChE,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAAI,CAAC,IAAA,4BAAkB,GAAE,CAAC;KAC1B,I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G,cAAc;KAClB,CAAA;AACH,CAAC,CAAC;KACD,IAAI,CAAC,IAAA,sBAAa,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KAC3C,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;IACZ,MAAM,YAAY,GAAa,EAAE,CAAA;IAEjC,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;IAErD,IAAI,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACxC,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;KACtD;IAED,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,OAAO;YACL,GAAG,GAAG;YACN,YAAY,EAAE,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC;SACrD,CAAA;KACF;IAED,OAAO,IAAA,gBAAO,EACZ,IAAA,qBAAW,EAAC,YAAY,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjD,KAAK,EACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACtB,CAAC,GAAG,CAAC,CAAA;AACR,CAAC,CAAC,CAAA;AA7FO,QAAA,QAAQ,YA6Ff"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
|
|
3
|
-
import {
|
|
4
|
-
addVersions,
|
|
5
|
-
checkPreconditions,
|
|
6
|
-
FeathersBaseContext,
|
|
7
|
-
getDatabaseAdapter,
|
|
8
|
-
initializeBaseContext
|
|
9
|
-
} from '../commons'
|
|
3
|
+
import { addVersions, checkPreconditions, FeathersBaseContext, initializeBaseContext } from '../commons'
|
|
10
4
|
import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
|
|
11
5
|
|
|
12
6
|
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
@@ -17,87 +11,76 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
|
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
export type AuthenticationGeneratorArguments = FeathersBaseContext &
|
|
20
|
-
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | '
|
|
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
|
-
]
|
|
14
|
+
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'path' | 'schema' | 'type'>>
|
|
85
15
|
|
|
86
16
|
export const generate = (ctx: AuthenticationGeneratorArguments) =>
|
|
87
17
|
generator(ctx)
|
|
88
18
|
.then(initializeBaseContext())
|
|
89
19
|
.then(checkPreconditions())
|
|
90
|
-
.then(
|
|
20
|
+
.then(
|
|
21
|
+
prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(
|
|
22
|
+
(ctx: AuthenticationGeneratorArguments) => [
|
|
23
|
+
{
|
|
24
|
+
type: 'checkbox',
|
|
25
|
+
name: 'authStrategies',
|
|
26
|
+
when: !ctx.authStrategies,
|
|
27
|
+
message: 'Which authentication methods do you want to use?',
|
|
28
|
+
suffix: chalk.grey(' Other methods and providers can be added at any time.'),
|
|
29
|
+
choices: [
|
|
30
|
+
{
|
|
31
|
+
name: 'Email + Password',
|
|
32
|
+
value: 'local',
|
|
33
|
+
checked: true
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Google',
|
|
37
|
+
value: 'google'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Facebook',
|
|
41
|
+
value: 'facebook'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Twitter',
|
|
45
|
+
value: 'twitter'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'GitHub',
|
|
49
|
+
value: 'github'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Auth0',
|
|
53
|
+
value: 'auth0'
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'service',
|
|
59
|
+
type: 'input',
|
|
60
|
+
when: !ctx.service,
|
|
61
|
+
message: 'What is your authentication service name?',
|
|
62
|
+
default: 'user'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'path',
|
|
66
|
+
type: 'input',
|
|
67
|
+
when: !ctx.path,
|
|
68
|
+
message: 'What path should the service be registered on?',
|
|
69
|
+
default: 'users'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
)
|
|
73
|
+
)
|
|
91
74
|
.then(async (ctx) => {
|
|
92
75
|
const serviceContext = await serviceGenerator({
|
|
93
76
|
...ctx,
|
|
94
77
|
name: ctx.service,
|
|
95
|
-
isEntityService: true
|
|
96
|
-
type: getDatabaseAdapter(ctx.feathers?.database)
|
|
78
|
+
isEntityService: true
|
|
97
79
|
})
|
|
98
80
|
|
|
99
81
|
return {
|
|
100
82
|
...ctx,
|
|
83
|
+
entity: ctx.service,
|
|
101
84
|
...serviceContext
|
|
102
85
|
}
|
|
103
86
|
})
|
|
@@ -3,11 +3,11 @@ 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
|
|
6
|
+
const commons_2 = require("../../commons");
|
|
7
7
|
const template = ({ authStrategies }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/authentication.html
|
|
8
8
|
import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
9
|
-
${(0,
|
|
10
|
-
${(0,
|
|
9
|
+
${(0, commons_2.localTemplate)(authStrategies, `import { LocalStrategy } from '@feathersjs/authentication-local'`)}
|
|
10
|
+
${(0, commons_2.oauthTemplate)(authStrategies, `import { oauth, OAuthStrategy } from '@feathersjs/authentication-oauth'`)}
|
|
11
11
|
|
|
12
12
|
import type { Application } from './declarations'
|
|
13
13
|
|
|
@@ -26,7 +26,7 @@ export const authentication = (app: Application) => {
|
|
|
26
26
|
.join('\n')}
|
|
27
27
|
|
|
28
28
|
app.use('authentication', authentication)
|
|
29
|
-
${(0,
|
|
29
|
+
${(0, commons_2.oauthTemplate)(authStrategies, `app.configure(oauth())`)}
|
|
30
30
|
}
|
|
31
31
|
`;
|
|
32
32
|
const importTemplate = "import { authentication } from './authentication'";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;
|
|
1
|
+
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAE1D,2CAA4D;AAE5D,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;EAE7C,IAAA,uBAAa,EAAC,cAAc,EAAE,kEAAkE,CAAC;EACjG,IAAA,uBAAa,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,uBAAa,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,6 +1,7 @@
|
|
|
1
1
|
import { generator, before, toFile } from '@feathershq/pinion'
|
|
2
2
|
import { injectSource, renderSource } from '../../commons'
|
|
3
|
-
import { AuthenticationGeneratorContext
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
import { localTemplate, oauthTemplate } from '../../commons'
|
|
4
5
|
|
|
5
6
|
const template = ({
|
|
6
7
|
authStrategies
|
|
@@ -3,16 +3,16 @@ 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
|
|
6
|
+
const commons_2 = require("../../commons");
|
|
7
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
8
|
import assert from 'assert'
|
|
9
9
|
import axios from 'axios'
|
|
10
10
|
|
|
11
11
|
import rest from '@feathersjs/rest-client'
|
|
12
|
-
${(0,
|
|
12
|
+
${(0, commons_2.localTemplate)(authStrategies, `import authenticationClient from '@feathersjs/authentication-client'`)}
|
|
13
13
|
import { app } from '../${lib}/app'
|
|
14
14
|
import { createClient } from '../${lib}/client'
|
|
15
|
-
${(0,
|
|
15
|
+
${(0, commons_2.localTemplate)(authStrategies, `import type { ${upperName}Data } from '../${lib}/client'`)}
|
|
16
16
|
|
|
17
17
|
const port = app.get('port')
|
|
18
18
|
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
@@ -32,7 +32,7 @@ describe('application client tests', () => {
|
|
|
32
32
|
assert.ok(client)
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
${(0,
|
|
35
|
+
${(0, commons_2.localTemplate)(authStrategies, `
|
|
36
36
|
it('creates and authenticates a user with email and password', async () => {
|
|
37
37
|
const userData: ${upperName}Data = {
|
|
38
38
|
email: 'someone@example.com',
|
|
@@ -57,6 +57,6 @@ describe('application client tests', () => {
|
|
|
57
57
|
})`)}
|
|
58
58
|
})
|
|
59
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 }));
|
|
60
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ lib, language }) => (0, commons_1.fileExists)(lib, `client.${language}`), (0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ test }) => test, 'client.test'), { force: true })));
|
|
61
61
|
exports.generate = generate;
|
|
62
62
|
//# sourceMappingURL=client.test.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"client.test.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/client.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,2CAAwD;AAExD,2CAA6C;AAE7C,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACd,SAAS,EACT,IAAI,EACJ,GAAG,EAC4B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;EAK7C,IAAA,uBAAa,EAAC,cAAc,EAAE,sEAAsE,CAAC;0BAC7E,GAAG;mCACM,GAAG;EACpC,IAAA,uBAAa,EAAC,cAAc,EAAE,iBAAiB,SAAS,mBAAmB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;IAoBvF,IAAA,uBAAa,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,aAAI,EACF,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,IAAA,oBAAU,EAAC,GAAG,EAAE,UAAU,QAAQ,EAAE,CAAC,EAC5D,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,CACF,CAAA;AAVU,QAAA,QAAQ,YAUlB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
-
import { renderSource } from '../../commons'
|
|
3
|
-
import { AuthenticationGeneratorContext
|
|
1
|
+
import { generator, toFile, when } from '@feathershq/pinion'
|
|
2
|
+
import { fileExists, renderSource } from '../../commons'
|
|
3
|
+
import { AuthenticationGeneratorContext } from '../index'
|
|
4
|
+
import { localTemplate } from '../../commons'
|
|
4
5
|
|
|
5
6
|
const template = ({
|
|
6
7
|
authStrategies,
|
|
@@ -66,9 +67,12 @@ describe('application client tests', () => {
|
|
|
66
67
|
|
|
67
68
|
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
68
69
|
generator(ctx).then(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
when<AuthenticationGeneratorContext>(
|
|
71
|
+
({ lib, language }) => fileExists(lib, `client.${language}`),
|
|
72
|
+
renderSource(
|
|
73
|
+
template,
|
|
74
|
+
toFile<AuthenticationGeneratorContext>(({ test }) => test, 'client.test'),
|
|
75
|
+
{ force: true }
|
|
76
|
+
)
|
|
73
77
|
)
|
|
74
78
|
)
|
package/lib/commons.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export declare const version: any;
|
|
|
6
6
|
export type DependencyVersions = {
|
|
7
7
|
[key: string]: string;
|
|
8
8
|
};
|
|
9
|
+
export declare const DATABASE_TYPES: readonly ["mongodb", "mysql", "postgresql", "sqlite", "mssql", "other"];
|
|
9
10
|
/**
|
|
10
11
|
* The database types supported by this generator
|
|
11
12
|
*/
|
|
12
|
-
export type DatabaseType =
|
|
13
|
+
export type DatabaseType = (typeof DATABASE_TYPES)[number];
|
|
13
14
|
/**
|
|
14
15
|
* Returns the name of the Feathers database adapter for a supported database type
|
|
15
16
|
*
|
|
@@ -29,7 +30,7 @@ export type FeathersAppInfo = {
|
|
|
29
30
|
/**
|
|
30
31
|
* The package manager used
|
|
31
32
|
*/
|
|
32
|
-
packager: 'yarn' | 'npm';
|
|
33
|
+
packager: 'yarn' | 'npm' | 'pnpm';
|
|
33
34
|
/**
|
|
34
35
|
* A list of all chosen transports
|
|
35
36
|
*/
|
|
@@ -41,7 +42,7 @@ export type FeathersAppInfo = {
|
|
|
41
42
|
/**
|
|
42
43
|
* The main schema definition format
|
|
43
44
|
*/
|
|
44
|
-
schema: 'typebox' | 'json';
|
|
45
|
+
schema: 'typebox' | 'json' | false;
|
|
45
46
|
};
|
|
46
47
|
export interface AppPackageJson extends PackageJson {
|
|
47
48
|
feathers?: FeathersAppInfo;
|
|
@@ -153,3 +154,18 @@ export declare const fileExists: (...filenames: string[]) => boolean;
|
|
|
153
154
|
* @returns The current date and time in the format `YYYYMMDDHHMMSS`
|
|
154
155
|
*/
|
|
155
156
|
export declare const yyyymmddhhmmss: (offset?: number) => string;
|
|
157
|
+
/**
|
|
158
|
+
* Render a template if `local` authentication strategy has been selected
|
|
159
|
+
* @param authStrategies The list of selected authentication strategies
|
|
160
|
+
* @param content The content to render if `local` is selected
|
|
161
|
+
* @param alt The content to render if `local` is not selected
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
export declare const localTemplate: (authStrategies: string[], content: string, alt?: string) => string;
|
|
165
|
+
/**
|
|
166
|
+
* Render a template if an `oauth` authentication strategy has been selected
|
|
167
|
+
* @param authStrategies
|
|
168
|
+
* @param content
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
export declare const oauthTemplate: (authStrategies: string[], content: string) => string;
|