@feathersjs/generators 5.0.0-pre.35
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 -0
- package/LICENSE +22 -0
- package/README.md +23 -0
- package/lib/app/index.d.ts +29 -0
- package/lib/app/index.js +146 -0
- package/lib/app/index.js.map +1 -0
- package/lib/app/index.ts +228 -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 +49 -0
- package/lib/app/templates/app.test.tpl.js.map +1 -0
- package/lib/app/templates/app.test.tpl.ts +50 -0
- package/lib/app/templates/app.tpl.d.ts +2 -0
- package/lib/app/templates/app.tpl.js +123 -0
- package/lib/app/templates/app.tpl.js.map +1 -0
- package/lib/app/templates/app.tpl.ts +138 -0
- package/lib/app/templates/channels.tpl.d.ts +2 -0
- package/lib/app/templates/channels.tpl.js +50 -0
- package/lib/app/templates/channels.tpl.js.map +1 -0
- package/lib/app/templates/channels.tpl.ts +56 -0
- package/lib/app/templates/client.test.tpl.d.ts +2 -0
- package/lib/app/templates/client.test.tpl.js +27 -0
- package/lib/app/templates/client.test.tpl.js.map +1 -0
- package/lib/app/templates/client.test.tpl.ts +26 -0
- package/lib/app/templates/client.tpl.d.ts +2 -0
- package/lib/app/templates/client.tpl.js +38 -0
- package/lib/app/templates/client.tpl.js.map +1 -0
- package/lib/app/templates/client.tpl.ts +45 -0
- package/lib/app/templates/configuration.tpl.d.ts +2 -0
- package/lib/app/templates/configuration.tpl.js +71 -0
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/configuration.tpl.ts +82 -0
- package/lib/app/templates/declarations.tpl.d.ts +2 -0
- package/lib/app/templates/declarations.tpl.js +28 -0
- package/lib/app/templates/declarations.tpl.js.map +1 -0
- package/lib/app/templates/declarations.tpl.ts +37 -0
- package/lib/app/templates/index.html.tpl.d.ts +2 -0
- package/lib/app/templates/index.html.tpl.js +45 -0
- package/lib/app/templates/index.html.tpl.js.map +1 -0
- package/lib/app/templates/index.html.tpl.ts +44 -0
- package/lib/app/templates/index.tpl.d.ts +2 -0
- package/lib/app/templates/index.tpl.js +22 -0
- package/lib/app/templates/index.tpl.js.map +1 -0
- package/lib/app/templates/index.tpl.ts +26 -0
- package/lib/app/templates/logger.tpl.d.ts +3 -0
- package/lib/app/templates/logger.tpl.js +45 -0
- package/lib/app/templates/logger.tpl.js.map +1 -0
- package/lib/app/templates/logger.tpl.ts +56 -0
- package/lib/app/templates/package.json.tpl.d.ts +2 -0
- package/lib/app/templates/package.json.tpl.js +58 -0
- package/lib/app/templates/package.json.tpl.js.map +1 -0
- package/lib/app/templates/package.json.tpl.ts +71 -0
- package/lib/app/templates/prettierrc.tpl.d.ts +2 -0
- package/lib/app/templates/prettierrc.tpl.js +11 -0
- package/lib/app/templates/prettierrc.tpl.js.map +1 -0
- package/lib/app/templates/prettierrc.tpl.ts +14 -0
- package/lib/app/templates/readme.md.tpl.d.ts +2 -0
- package/lib/app/templates/readme.md.tpl.js +54 -0
- package/lib/app/templates/readme.md.tpl.js.map +1 -0
- package/lib/app/templates/readme.md.tpl.ts +57 -0
- package/lib/app/templates/services.tpl.d.ts +2 -0
- package/lib/app/templates/services.tpl.js +15 -0
- package/lib/app/templates/services.tpl.js.map +1 -0
- package/lib/app/templates/services.tpl.ts +20 -0
- package/lib/app/templates/tsconfig.json.tpl.d.ts +2 -0
- package/lib/app/templates/tsconfig.json.tpl.js +22 -0
- package/lib/app/templates/tsconfig.json.tpl.js.map +1 -0
- package/lib/app/templates/tsconfig.json.tpl.ts +28 -0
- package/lib/app/templates/validators.tpl.d.ts +2 -0
- package/lib/app/templates/validators.tpl.js +36 -0
- package/lib/app/templates/validators.tpl.js.map +1 -0
- package/lib/app/templates/validators.tpl.ts +40 -0
- package/lib/authentication/index.d.ts +73 -0
- package/lib/authentication/index.js +107 -0
- package/lib/authentication/index.js.map +1 -0
- package/lib/authentication/index.ts +126 -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 +51 -0
- package/lib/authentication/templates/client.test.tpl.d.ts +2 -0
- package/lib/authentication/templates/client.test.tpl.js +62 -0
- package/lib/authentication/templates/client.test.tpl.js.map +1 -0
- package/lib/authentication/templates/client.test.tpl.ts +74 -0
- package/lib/authentication/templates/config.tpl.d.ts +2 -0
- package/lib/authentication/templates/config.tpl.js +50 -0
- package/lib/authentication/templates/config.tpl.js.map +1 -0
- package/lib/authentication/templates/config.tpl.ts +57 -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 +34 -0
- package/lib/authentication/templates/knex.tpl.d.ts +2 -0
- package/lib/authentication/templates/knex.tpl.js +45 -0
- package/lib/authentication/templates/knex.tpl.js.map +1 -0
- package/lib/authentication/templates/knex.tpl.ts +62 -0
- package/lib/authentication/templates/schema.json.tpl.d.ts +2 -0
- package/lib/authentication/templates/schema.json.tpl.js +103 -0
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.json.tpl.ts +124 -0
- package/lib/authentication/templates/schema.typebox.tpl.d.ts +3 -0
- package/lib/authentication/templates/schema.typebox.tpl.js +86 -0
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.ts +108 -0
- package/lib/commons.d.ts +150 -0
- package/lib/commons.js +198 -0
- package/lib/commons.js.map +1 -0
- package/lib/commons.ts +284 -0
- package/lib/connection/index.d.ts +55 -0
- package/lib/connection/index.js +88 -0
- package/lib/connection/index.js.map +1 -0
- package/lib/connection/index.ts +123 -0
- package/lib/connection/templates/knex.tpl.d.ts +2 -0
- package/lib/connection/templates/knex.tpl.js +48 -0
- package/lib/connection/templates/knex.tpl.js.map +1 -0
- package/lib/connection/templates/knex.tpl.ts +67 -0
- package/lib/connection/templates/mongodb.tpl.d.ts +2 -0
- package/lib/connection/templates/mongodb.tpl.js +34 -0
- package/lib/connection/templates/mongodb.tpl.js.map +1 -0
- package/lib/connection/templates/mongodb.tpl.ts +40 -0
- package/lib/hook/index.d.ts +22 -0
- package/lib/hook/index.js +43 -0
- package/lib/hook/index.js.map +1 -0
- package/lib/hook/index.ts +47 -0
- package/lib/hook/templates/hook.tpl.d.ts +2 -0
- package/lib/hook/templates/hook.tpl.js +22 -0
- package/lib/hook/templates/hook.tpl.js.map +1 -0
- package/lib/hook/templates/hook.tpl.ts +33 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/index.ts +8 -0
- package/lib/service/index.d.ts +64 -0
- package/lib/service/index.js +116 -0
- package/lib/service/index.js.map +1 -0
- package/lib/service/index.ts +191 -0
- package/lib/service/templates/client.tpl.d.ts +2 -0
- package/lib/service/templates/client.tpl.js +30 -0
- package/lib/service/templates/client.tpl.js.map +1 -0
- package/lib/service/templates/client.tpl.ts +56 -0
- package/lib/service/templates/schema.json.tpl.d.ts +2 -0
- package/lib/service/templates/schema.json.tpl.js +83 -0
- package/lib/service/templates/schema.json.tpl.js.map +1 -0
- package/lib/service/templates/schema.json.tpl.ts +98 -0
- package/lib/service/templates/schema.typebox.tpl.d.ts +2 -0
- package/lib/service/templates/schema.typebox.tpl.js +61 -0
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/service/templates/schema.typebox.tpl.ts +76 -0
- package/lib/service/templates/service.tpl.d.ts +3 -0
- package/lib/service/templates/service.tpl.js +112 -0
- package/lib/service/templates/service.tpl.js.map +1 -0
- package/lib/service/templates/service.tpl.ts +152 -0
- package/lib/service/templates/test.tpl.d.ts +2 -0
- package/lib/service/templates/test.tpl.js +25 -0
- package/lib/service/templates/test.tpl.js.map +1 -0
- package/lib/service/templates/test.tpl.ts +33 -0
- package/lib/service/type/custom.tpl.d.ts +3 -0
- package/lib/service/type/custom.tpl.js +98 -0
- package/lib/service/type/custom.tpl.js.map +1 -0
- package/lib/service/type/custom.tpl.ts +109 -0
- package/lib/service/type/knex.tpl.d.ts +3 -0
- package/lib/service/type/knex.tpl.js +71 -0
- package/lib/service/type/knex.tpl.js.map +1 -0
- package/lib/service/type/knex.tpl.ts +92 -0
- package/lib/service/type/mongodb.tpl.d.ts +3 -0
- package/lib/service/type/mongodb.tpl.js +50 -0
- package/lib/service/type/mongodb.tpl.js.map +1 -0
- package/lib/service/type/mongodb.tpl.ts +62 -0
- package/package.json +89 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Feathers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @feathersjs/generators
|
|
2
|
+
|
|
3
|
+
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
4
|
+
[](https://david-dm.org/feathersjs/feathers?path=packages/generators)
|
|
5
|
+
[](https://www.npmjs.com/package/@feathersjs/cli)
|
|
6
|
+
|
|
7
|
+
> Feathers core code generators used by the CLI powered by [Pinion](https://github.com/feathershq/pinion/)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @feathersjs/generators --save-dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
Refer to the [Feathers documentation](https://docs.feathersjs.com) for more details.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
22
|
+
|
|
23
|
+
Licensed under the [MIT license](LICENSE).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FeathersBaseContext, FeathersAppInfo } from '../commons';
|
|
2
|
+
export interface AppGeneratorData extends FeathersAppInfo {
|
|
3
|
+
/**
|
|
4
|
+
* The application name
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* A short description of the app
|
|
9
|
+
*/
|
|
10
|
+
description: string;
|
|
11
|
+
/**
|
|
12
|
+
* The selected user authentication strategies
|
|
13
|
+
*/
|
|
14
|
+
authStrategies: string[];
|
|
15
|
+
/**
|
|
16
|
+
* The database connection string
|
|
17
|
+
*/
|
|
18
|
+
connectionString: string;
|
|
19
|
+
/**
|
|
20
|
+
* The source folder where files are put
|
|
21
|
+
*/
|
|
22
|
+
lib: string;
|
|
23
|
+
}
|
|
24
|
+
export type AppGeneratorContext = FeathersBaseContext & AppGeneratorData & {
|
|
25
|
+
dependencies: string[];
|
|
26
|
+
devDependencies: string[];
|
|
27
|
+
};
|
|
28
|
+
export type AppGeneratorArguments = FeathersBaseContext & Partial<AppGeneratorData>;
|
|
29
|
+
export declare const generate: (ctx: AppGeneratorArguments) => Promise<AppGeneratorContext>;
|
package/lib/app/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
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 path_1 = require("path");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
10
|
+
const commons_1 = require("../commons");
|
|
11
|
+
const authentication_1 = require("../authentication");
|
|
12
|
+
const connection_1 = require("../connection");
|
|
13
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
14
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
15
|
+
.then((ctx) => ({
|
|
16
|
+
...ctx,
|
|
17
|
+
dependencies: [],
|
|
18
|
+
devDependencies: []
|
|
19
|
+
}))
|
|
20
|
+
.then((0, pinion_1.prompt)((ctx) => [
|
|
21
|
+
{
|
|
22
|
+
name: 'language',
|
|
23
|
+
type: 'list',
|
|
24
|
+
message: 'Do you want to use JavaScript or TypeScript?',
|
|
25
|
+
when: !ctx.language,
|
|
26
|
+
choices: [
|
|
27
|
+
{ name: 'TypeScript', value: 'ts' },
|
|
28
|
+
{ name: 'JavaScript', value: 'js' }
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'name',
|
|
33
|
+
type: 'input',
|
|
34
|
+
when: !ctx.name,
|
|
35
|
+
message: 'What is the name of your application?',
|
|
36
|
+
default: ctx.cwd.split(path_1.sep).pop(),
|
|
37
|
+
validate: (input) => {
|
|
38
|
+
if (ctx.dependencyVersions[input]) {
|
|
39
|
+
return `Application can not have the same name as a dependency`;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'description',
|
|
46
|
+
type: 'input',
|
|
47
|
+
when: !ctx.description,
|
|
48
|
+
message: 'Write a short description'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'list',
|
|
52
|
+
name: 'framework',
|
|
53
|
+
when: !ctx.framework,
|
|
54
|
+
message: 'Which HTTP framework do you want to use?',
|
|
55
|
+
choices: [
|
|
56
|
+
{ value: 'koa', name: `KoaJS ${chalk_1.default.grey('(recommended)')}` },
|
|
57
|
+
{ value: 'express', name: 'Express' }
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'checkbox',
|
|
62
|
+
name: 'transports',
|
|
63
|
+
when: !ctx.transports,
|
|
64
|
+
message: 'What APIs do you want to offer?',
|
|
65
|
+
choices: [
|
|
66
|
+
{ value: 'rest', name: 'HTTP (REST)', checked: true },
|
|
67
|
+
{ value: 'websockets', name: 'Real-time', checked: true }
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'packager',
|
|
72
|
+
type: 'list',
|
|
73
|
+
when: !ctx.packager,
|
|
74
|
+
message: 'Which package manager are you using?',
|
|
75
|
+
choices: [
|
|
76
|
+
{ value: 'npm', name: 'npm' },
|
|
77
|
+
{ value: 'yarn', name: 'Yarn' },
|
|
78
|
+
{ value: 'pnpm', name: 'pnpm' }
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'list',
|
|
83
|
+
name: 'schema',
|
|
84
|
+
when: !ctx.schema,
|
|
85
|
+
message: 'What is your preferred schema (model) definition format?',
|
|
86
|
+
choices: [
|
|
87
|
+
{ value: 'typebox', name: `TypeBox ${chalk_1.default.grey('(recommended)')}` },
|
|
88
|
+
{ value: 'json', name: 'JSON schema' }
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
...(0, connection_1.prompts)(ctx),
|
|
92
|
+
...(0, authentication_1.prompts)({
|
|
93
|
+
...ctx,
|
|
94
|
+
service: 'user',
|
|
95
|
+
path: 'users',
|
|
96
|
+
entity: 'user'
|
|
97
|
+
})
|
|
98
|
+
]))
|
|
99
|
+
.then((0, pinion_1.runGenerators)(__dirname, 'templates'))
|
|
100
|
+
.then((0, pinion_1.copyFiles)((0, pinion_1.fromFile)(__dirname, 'static'), (0, pinion_1.toFile)('.')))
|
|
101
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
102
|
+
.then(async (ctx) => {
|
|
103
|
+
const { dependencies } = await (0, connection_1.generate)(ctx);
|
|
104
|
+
return {
|
|
105
|
+
...ctx,
|
|
106
|
+
dependencies
|
|
107
|
+
};
|
|
108
|
+
})
|
|
109
|
+
.then((0, pinion_1.when)(({ authStrategies }) => authStrategies.length > 0, async (ctx) => {
|
|
110
|
+
const { dependencies } = await (0, authentication_1.generate)({
|
|
111
|
+
...ctx,
|
|
112
|
+
service: 'user',
|
|
113
|
+
path: 'users',
|
|
114
|
+
entity: 'user'
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
...ctx,
|
|
118
|
+
dependencies
|
|
119
|
+
};
|
|
120
|
+
}))
|
|
121
|
+
.then((0, pinion_1.install)(({ transports, framework, dependencyVersions, dependencies, schema }) => {
|
|
122
|
+
const hasSocketio = transports.includes('websockets');
|
|
123
|
+
dependencies.push('@feathersjs/feathers', '@feathersjs/errors', '@feathersjs/schema', '@feathersjs/configuration', '@feathersjs/transport-commons', '@feathersjs/adapter-commons', '@feathersjs/authentication', '@feathersjs/authentication-client', 'winston');
|
|
124
|
+
if (hasSocketio) {
|
|
125
|
+
dependencies.push('@feathersjs/socketio');
|
|
126
|
+
}
|
|
127
|
+
if (framework === 'koa') {
|
|
128
|
+
dependencies.push('@feathersjs/koa');
|
|
129
|
+
}
|
|
130
|
+
if (framework === 'express') {
|
|
131
|
+
dependencies.push('@feathersjs/express', 'compression');
|
|
132
|
+
}
|
|
133
|
+
if (schema === 'typebox') {
|
|
134
|
+
dependencies.push('@feathersjs/typebox');
|
|
135
|
+
}
|
|
136
|
+
return (0, commons_1.addVersions)(dependencies, dependencyVersions);
|
|
137
|
+
}, false, ({ packager }) => packager))
|
|
138
|
+
.then((0, pinion_1.install)(({ language, devDependencies, dependencyVersions }) => {
|
|
139
|
+
devDependencies.push('nodemon', 'axios', 'mocha', 'cross-env', 'prettier', '@feathersjs/cli', '@feathersjs/rest-client');
|
|
140
|
+
if (language === 'ts') {
|
|
141
|
+
devDependencies.push('@types/mocha', '@types/node', 'nodemon', 'ts-node', 'typescript', 'shx');
|
|
142
|
+
}
|
|
143
|
+
return (0, commons_1.addVersions)(devDependencies, dependencyVersions);
|
|
144
|
+
}, true, ({ packager }) => packager));
|
|
145
|
+
exports.generate = generate;
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],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B"}
|
package/lib/app/index.ts
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { sep } from 'path'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import {
|
|
4
|
+
generator,
|
|
5
|
+
prompt,
|
|
6
|
+
runGenerators,
|
|
7
|
+
fromFile,
|
|
8
|
+
install,
|
|
9
|
+
copyFiles,
|
|
10
|
+
toFile,
|
|
11
|
+
when
|
|
12
|
+
} from '@feathershq/pinion'
|
|
13
|
+
import { FeathersBaseContext, FeathersAppInfo, initializeBaseContext, addVersions } from '../commons'
|
|
14
|
+
import { generate as authenticationGenerator, prompts as authenticationPrompts } from '../authentication'
|
|
15
|
+
import { generate as connectionGenerator, prompts as connectionPrompts } from '../connection'
|
|
16
|
+
|
|
17
|
+
export interface AppGeneratorData extends FeathersAppInfo {
|
|
18
|
+
/**
|
|
19
|
+
* The application name
|
|
20
|
+
*/
|
|
21
|
+
name: string
|
|
22
|
+
/**
|
|
23
|
+
* A short description of the app
|
|
24
|
+
*/
|
|
25
|
+
description: string
|
|
26
|
+
/**
|
|
27
|
+
* The selected user authentication strategies
|
|
28
|
+
*/
|
|
29
|
+
authStrategies: string[]
|
|
30
|
+
/**
|
|
31
|
+
* The database connection string
|
|
32
|
+
*/
|
|
33
|
+
connectionString: string
|
|
34
|
+
/**
|
|
35
|
+
* The source folder where files are put
|
|
36
|
+
*/
|
|
37
|
+
lib: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type AppGeneratorContext = FeathersBaseContext &
|
|
41
|
+
AppGeneratorData & {
|
|
42
|
+
dependencies: string[]
|
|
43
|
+
devDependencies: string[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type AppGeneratorArguments = FeathersBaseContext & Partial<AppGeneratorData>
|
|
47
|
+
|
|
48
|
+
export const generate = (ctx: AppGeneratorArguments) =>
|
|
49
|
+
generator(ctx)
|
|
50
|
+
.then(initializeBaseContext())
|
|
51
|
+
.then((ctx) => ({
|
|
52
|
+
...ctx,
|
|
53
|
+
dependencies: [],
|
|
54
|
+
devDependencies: []
|
|
55
|
+
}))
|
|
56
|
+
.then(
|
|
57
|
+
prompt<AppGeneratorArguments, AppGeneratorContext>((ctx) => [
|
|
58
|
+
{
|
|
59
|
+
name: 'language',
|
|
60
|
+
type: 'list',
|
|
61
|
+
message: 'Do you want to use JavaScript or TypeScript?',
|
|
62
|
+
when: !ctx.language,
|
|
63
|
+
choices: [
|
|
64
|
+
{ name: 'TypeScript', value: 'ts' },
|
|
65
|
+
{ name: 'JavaScript', value: 'js' }
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'name',
|
|
70
|
+
type: 'input',
|
|
71
|
+
when: !ctx.name,
|
|
72
|
+
message: 'What is the name of your application?',
|
|
73
|
+
default: ctx.cwd.split(sep).pop(),
|
|
74
|
+
validate: (input) => {
|
|
75
|
+
if (ctx.dependencyVersions[input]) {
|
|
76
|
+
return `Application can not have the same name as a dependency`
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'description',
|
|
84
|
+
type: 'input',
|
|
85
|
+
when: !ctx.description,
|
|
86
|
+
message: 'Write a short description'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'list',
|
|
90
|
+
name: 'framework',
|
|
91
|
+
when: !ctx.framework,
|
|
92
|
+
message: 'Which HTTP framework do you want to use?',
|
|
93
|
+
choices: [
|
|
94
|
+
{ value: 'koa', name: `KoaJS ${chalk.grey('(recommended)')}` },
|
|
95
|
+
{ value: 'express', name: 'Express' }
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'checkbox',
|
|
100
|
+
name: 'transports',
|
|
101
|
+
when: !ctx.transports,
|
|
102
|
+
message: 'What APIs do you want to offer?',
|
|
103
|
+
choices: [
|
|
104
|
+
{ value: 'rest', name: 'HTTP (REST)', checked: true },
|
|
105
|
+
{ value: 'websockets', name: 'Real-time', checked: true }
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'packager',
|
|
110
|
+
type: 'list',
|
|
111
|
+
when: !ctx.packager,
|
|
112
|
+
message: 'Which package manager are you using?',
|
|
113
|
+
choices: [
|
|
114
|
+
{ value: 'npm', name: 'npm' },
|
|
115
|
+
{ value: 'yarn', name: 'Yarn' },
|
|
116
|
+
{ value: 'pnpm', name: 'pnpm' }
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'list',
|
|
121
|
+
name: 'schema',
|
|
122
|
+
when: !ctx.schema,
|
|
123
|
+
message: 'What is your preferred schema (model) definition format?',
|
|
124
|
+
choices: [
|
|
125
|
+
{ value: 'typebox', name: `TypeBox ${chalk.grey('(recommended)')}` },
|
|
126
|
+
{ value: 'json', name: 'JSON schema' }
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
...connectionPrompts(ctx),
|
|
130
|
+
...authenticationPrompts({
|
|
131
|
+
...ctx,
|
|
132
|
+
service: 'user',
|
|
133
|
+
path: 'users',
|
|
134
|
+
entity: 'user'
|
|
135
|
+
})
|
|
136
|
+
])
|
|
137
|
+
)
|
|
138
|
+
.then(runGenerators(__dirname, 'templates'))
|
|
139
|
+
.then(copyFiles(fromFile(__dirname, 'static'), toFile('.')))
|
|
140
|
+
.then(initializeBaseContext())
|
|
141
|
+
.then(async (ctx) => {
|
|
142
|
+
const { dependencies } = await connectionGenerator(ctx)
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
...ctx,
|
|
146
|
+
dependencies
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
.then(
|
|
150
|
+
when<AppGeneratorContext>(
|
|
151
|
+
({ authStrategies }) => authStrategies.length > 0,
|
|
152
|
+
async (ctx) => {
|
|
153
|
+
const { dependencies } = await authenticationGenerator({
|
|
154
|
+
...ctx,
|
|
155
|
+
service: 'user',
|
|
156
|
+
path: 'users',
|
|
157
|
+
entity: 'user'
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
...ctx,
|
|
162
|
+
dependencies
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
.then(
|
|
168
|
+
install<AppGeneratorContext>(
|
|
169
|
+
({ transports, framework, dependencyVersions, dependencies, schema }) => {
|
|
170
|
+
const hasSocketio = transports.includes('websockets')
|
|
171
|
+
|
|
172
|
+
dependencies.push(
|
|
173
|
+
'@feathersjs/feathers',
|
|
174
|
+
'@feathersjs/errors',
|
|
175
|
+
'@feathersjs/schema',
|
|
176
|
+
'@feathersjs/configuration',
|
|
177
|
+
'@feathersjs/transport-commons',
|
|
178
|
+
'@feathersjs/adapter-commons',
|
|
179
|
+
'@feathersjs/authentication',
|
|
180
|
+
'@feathersjs/authentication-client',
|
|
181
|
+
'winston'
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if (hasSocketio) {
|
|
185
|
+
dependencies.push('@feathersjs/socketio')
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (framework === 'koa') {
|
|
189
|
+
dependencies.push('@feathersjs/koa')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (framework === 'express') {
|
|
193
|
+
dependencies.push('@feathersjs/express', 'compression')
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (schema === 'typebox') {
|
|
197
|
+
dependencies.push('@feathersjs/typebox')
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return addVersions(dependencies, dependencyVersions)
|
|
201
|
+
},
|
|
202
|
+
false,
|
|
203
|
+
({ packager }) => packager
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
.then(
|
|
207
|
+
install<AppGeneratorContext>(
|
|
208
|
+
({ language, devDependencies, dependencyVersions }) => {
|
|
209
|
+
devDependencies.push(
|
|
210
|
+
'nodemon',
|
|
211
|
+
'axios',
|
|
212
|
+
'mocha',
|
|
213
|
+
'cross-env',
|
|
214
|
+
'prettier',
|
|
215
|
+
'@feathersjs/cli',
|
|
216
|
+
'@feathersjs/rest-client'
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
if (language === 'ts') {
|
|
220
|
+
devDependencies.push('@types/mocha', '@types/node', 'nodemon', 'ts-node', 'typescript', 'shx')
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return addVersions(devDependencies, dependencyVersions)
|
|
224
|
+
},
|
|
225
|
+
true,
|
|
226
|
+
({ packager }) => packager
|
|
227
|
+
)
|
|
228
|
+
)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
lerna-debug.log*
|
|
8
|
+
.pnpm-debug.log*
|
|
9
|
+
|
|
10
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
+
|
|
13
|
+
# Runtime data
|
|
14
|
+
pids
|
|
15
|
+
*.pid
|
|
16
|
+
*.seed
|
|
17
|
+
*.pid.lock
|
|
18
|
+
|
|
19
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
20
|
+
lib-cov
|
|
21
|
+
|
|
22
|
+
# Coverage directory used by tools like istanbul
|
|
23
|
+
coverage
|
|
24
|
+
*.lcov
|
|
25
|
+
|
|
26
|
+
# nyc test coverage
|
|
27
|
+
.nyc_output
|
|
28
|
+
|
|
29
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
30
|
+
.grunt
|
|
31
|
+
|
|
32
|
+
# Bower dependency directory (https://bower.io/)
|
|
33
|
+
bower_components
|
|
34
|
+
|
|
35
|
+
# node-waf configuration
|
|
36
|
+
.lock-wscript
|
|
37
|
+
|
|
38
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
39
|
+
build/Release
|
|
40
|
+
|
|
41
|
+
# Dependency directories
|
|
42
|
+
node_modules/
|
|
43
|
+
jspm_packages/
|
|
44
|
+
|
|
45
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
46
|
+
web_modules/
|
|
47
|
+
|
|
48
|
+
# TypeScript cache
|
|
49
|
+
*.tsbuildinfo
|
|
50
|
+
|
|
51
|
+
# Optional npm cache directory
|
|
52
|
+
.npm
|
|
53
|
+
|
|
54
|
+
# Optional eslint cache
|
|
55
|
+
.eslintcache
|
|
56
|
+
|
|
57
|
+
# Microbundle cache
|
|
58
|
+
.rpt2_cache/
|
|
59
|
+
.rts2_cache_cjs/
|
|
60
|
+
.rts2_cache_es/
|
|
61
|
+
.rts2_cache_umd/
|
|
62
|
+
|
|
63
|
+
# Optional REPL history
|
|
64
|
+
.node_repl_history
|
|
65
|
+
|
|
66
|
+
# Output of 'npm pack'
|
|
67
|
+
*.tgz
|
|
68
|
+
|
|
69
|
+
# Yarn Integrity file
|
|
70
|
+
.yarn-integrity
|
|
71
|
+
|
|
72
|
+
# dotenv environment variables file
|
|
73
|
+
.env
|
|
74
|
+
.env.test
|
|
75
|
+
.env.production
|
|
76
|
+
|
|
77
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
78
|
+
.cache
|
|
79
|
+
.parcel-cache
|
|
80
|
+
|
|
81
|
+
# Next.js build output
|
|
82
|
+
.next
|
|
83
|
+
out
|
|
84
|
+
|
|
85
|
+
# Nuxt.js build / generate output
|
|
86
|
+
.nuxt
|
|
87
|
+
dist
|
|
88
|
+
|
|
89
|
+
# Gatsby files
|
|
90
|
+
.cache/
|
|
91
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
92
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
93
|
+
# public
|
|
94
|
+
|
|
95
|
+
# vuepress build output
|
|
96
|
+
.vuepress/dist
|
|
97
|
+
|
|
98
|
+
# Serverless directories
|
|
99
|
+
.serverless/
|
|
100
|
+
|
|
101
|
+
# FuseBox cache
|
|
102
|
+
.fusebox/
|
|
103
|
+
|
|
104
|
+
# DynamoDB Local files
|
|
105
|
+
.dynamodb/
|
|
106
|
+
|
|
107
|
+
# TernJS port file
|
|
108
|
+
.tern-port
|
|
109
|
+
|
|
110
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
111
|
+
.vscode-test
|
|
112
|
+
|
|
113
|
+
# yarn v2
|
|
114
|
+
.yarn/cache
|
|
115
|
+
.yarn/unplugged
|
|
116
|
+
.yarn/build-state.yml
|
|
117
|
+
.yarn/install-state.gz
|
|
118
|
+
.pnp.*
|
|
119
|
+
.sqlite
|
|
120
|
+
|
|
121
|
+
lib/
|
|
@@ -0,0 +1,49 @@
|
|
|
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 = ({ lib }) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/app.test.html
|
|
7
|
+
import assert from 'assert'
|
|
8
|
+
import axios from 'axios'
|
|
9
|
+
import type { Server } from 'http'
|
|
10
|
+
import { app } from '../${lib}/app'
|
|
11
|
+
|
|
12
|
+
const port = app.get('port')
|
|
13
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
14
|
+
|
|
15
|
+
describe('Feathers application tests', () => {
|
|
16
|
+
let server: Server
|
|
17
|
+
|
|
18
|
+
before(async () => {
|
|
19
|
+
server = await app.listen(port)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
after(async () => {
|
|
23
|
+
await app.teardown()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('starts and shows the index page', async () => {
|
|
27
|
+
const { data } = await axios.get<string>(appUrl)
|
|
28
|
+
|
|
29
|
+
assert.ok(data.indexOf('<html lang="en">') !== -1)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('shows a 404 JSON error', async () => {
|
|
33
|
+
try {
|
|
34
|
+
await axios.get(\`\${appUrl}/path/to/nowhere\`, {
|
|
35
|
+
responseType: 'json'
|
|
36
|
+
})
|
|
37
|
+
assert.fail('should never get here')
|
|
38
|
+
} catch (error: any) {
|
|
39
|
+
const { response } = error
|
|
40
|
+
assert.strictEqual(response?.status, 404)
|
|
41
|
+
assert.strictEqual(response?.data?.code, 404)
|
|
42
|
+
assert.strictEqual(response?.data?.name, 'NotFound')
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
`;
|
|
47
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)('test', 'app.test')));
|
|
48
|
+
exports.generate = generate;
|
|
49
|
+
//# sourceMappingURL=app.test.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.test.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/app.test.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAChB,GAAG,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;0BAIV,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoC5B,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAY,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;AAD5D,QAAA,QAAQ,YACoD"}
|