@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
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @feathersjs/cli
|
|
2
2
|
|
|
3
|
-
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
4
|
+
[](https://david-dm.org/feathersjs/feathers?path=packages/cli)
|
|
5
|
+
[](https://www.npmjs.com/package/@feathersjs/cli)
|
|
4
6
|
|
|
5
|
-
The command line interface for Feathers applications
|
|
7
|
+
> The command line interface for creating Feathers applications
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
|
-
```
|
|
11
|
+
```
|
|
10
12
|
npm install -g @feathersjs/cli
|
|
11
13
|
```
|
|
12
14
|
|
|
@@ -18,41 +20,14 @@ $ mkdir myproject
|
|
|
18
20
|
$ cd myproject
|
|
19
21
|
|
|
20
22
|
$ feathers help
|
|
21
|
-
|
|
22
|
-
Usage: feathers generate [type]
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Options:
|
|
26
|
-
|
|
27
|
-
-V, --version output the version number
|
|
28
|
-
-h, --help output usage information
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Commands:
|
|
32
|
-
|
|
33
|
-
generate|g [type] Run a generator. Type can be
|
|
34
|
-
• app - Create a new Feathers application in the current folder
|
|
35
|
-
• authentication - Set up authentication for the current application
|
|
36
|
-
• connection - Initialize a new database connection
|
|
37
|
-
• hook - Create a new hook
|
|
38
|
-
• middleware - Create an Express middleware
|
|
39
|
-
• service - Generate a new service
|
|
40
|
-
• plugin - Create a new Feathers plugin
|
|
41
|
-
|
|
42
|
-
upgrade|u Try to automatically upgrade to the latest Feathers version
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
$ feathers generate app
|
|
46
|
-
|
|
47
|
-
$ npm start
|
|
48
23
|
```
|
|
49
24
|
|
|
50
|
-
##
|
|
25
|
+
## Documentation
|
|
51
26
|
|
|
52
|
-
|
|
27
|
+
Refer to the [Feathers documentation](https://docs.feathersjs.com) for more details.
|
|
53
28
|
|
|
54
29
|
## License
|
|
55
30
|
|
|
56
|
-
Copyright (c)
|
|
31
|
+
Copyright (c) 2021 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
57
32
|
|
|
58
33
|
Licensed under the [MIT license](LICENSE).
|
package/bin/feathers
ADDED
|
@@ -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 declare type AppGeneratorContext = FeathersBaseContext & AppGeneratorData & {
|
|
25
|
+
dependencies: string[];
|
|
26
|
+
devDependencies: string[];
|
|
27
|
+
};
|
|
28
|
+
export declare type AppGeneratorArguments = FeathersBaseContext & Partial<AppGeneratorData>;
|
|
29
|
+
export declare const generate: (ctx: AppGeneratorArguments) => Promise<AppGeneratorContext>;
|
package/lib/app/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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((ctx) => ({
|
|
15
|
+
...ctx,
|
|
16
|
+
dependencies: [],
|
|
17
|
+
devDependencies: []
|
|
18
|
+
}))
|
|
19
|
+
.then((0, pinion_1.prompt)((ctx) => [
|
|
20
|
+
{
|
|
21
|
+
name: 'language',
|
|
22
|
+
type: 'list',
|
|
23
|
+
message: 'Do you want to use JavaScript or TypeScript?',
|
|
24
|
+
when: !ctx.language,
|
|
25
|
+
choices: [
|
|
26
|
+
{ name: 'TypeScript', value: 'ts' },
|
|
27
|
+
{ name: 'JavaScript', value: 'js' }
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'name',
|
|
32
|
+
type: 'input',
|
|
33
|
+
when: !ctx.name,
|
|
34
|
+
message: 'What is the name of your application?',
|
|
35
|
+
default: ctx.cwd.split(path_1.sep).pop()
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'description',
|
|
39
|
+
type: 'input',
|
|
40
|
+
when: !ctx.description,
|
|
41
|
+
message: 'Write a short description'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'list',
|
|
45
|
+
name: 'framework',
|
|
46
|
+
when: !ctx.framework,
|
|
47
|
+
message: 'Which HTTP framework do you want to use?',
|
|
48
|
+
choices: [
|
|
49
|
+
{ value: 'koa', name: `KoaJS ${chalk_1.default.grey('(recommended)')}` },
|
|
50
|
+
{ value: 'express', name: 'Express' }
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'checkbox',
|
|
55
|
+
name: 'transports',
|
|
56
|
+
when: !ctx.transports,
|
|
57
|
+
message: 'What APIs do you want to offer?',
|
|
58
|
+
choices: [
|
|
59
|
+
{ value: 'rest', name: 'HTTP (REST)', checked: true },
|
|
60
|
+
{ value: 'websockets', name: 'Real-time', checked: true }
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'packager',
|
|
65
|
+
type: 'list',
|
|
66
|
+
when: !ctx.packager,
|
|
67
|
+
message: 'Which package manager are you using?',
|
|
68
|
+
choices: [
|
|
69
|
+
{ value: 'npm', name: 'npm' },
|
|
70
|
+
{ value: 'yarn', name: 'Yarn' }
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
...(0, connection_1.prompts)(ctx),
|
|
74
|
+
...(0, authentication_1.prompts)({
|
|
75
|
+
...ctx,
|
|
76
|
+
service: 'users',
|
|
77
|
+
entity: 'user'
|
|
78
|
+
})
|
|
79
|
+
]))
|
|
80
|
+
.then((0, pinion_1.runGenerators)(__dirname, 'templates'))
|
|
81
|
+
.then((0, pinion_1.copyFiles)((0, pinion_1.fromFile)(__dirname, 'static'), (0, pinion_1.toFile)('.')))
|
|
82
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
83
|
+
.then((0, pinion_1.when)(({ authStrategies }) => authStrategies.length > 0, async (ctx) => {
|
|
84
|
+
const { dependencies } = await (0, connection_1.generate)(ctx);
|
|
85
|
+
return {
|
|
86
|
+
...ctx,
|
|
87
|
+
dependencies
|
|
88
|
+
};
|
|
89
|
+
}))
|
|
90
|
+
.then((0, pinion_1.when)(({ authStrategies }) => authStrategies.length > 0, async (ctx) => {
|
|
91
|
+
const { dependencies } = await (0, authentication_1.generate)({
|
|
92
|
+
...ctx,
|
|
93
|
+
service: 'users',
|
|
94
|
+
entity: 'user'
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
...ctx,
|
|
98
|
+
dependencies
|
|
99
|
+
};
|
|
100
|
+
}))
|
|
101
|
+
.then((0, pinion_1.install)(({ transports, framework, dependencyVersions, dependencies }) => {
|
|
102
|
+
const hasSocketio = transports.includes('websockets');
|
|
103
|
+
dependencies.push('@feathersjs/feathers', '@feathersjs/errors', '@feathersjs/schema', '@feathersjs/configuration', '@feathersjs/transport-commons', '@feathersjs/authentication', 'winston');
|
|
104
|
+
if (hasSocketio) {
|
|
105
|
+
dependencies.push('@feathersjs/socketio');
|
|
106
|
+
}
|
|
107
|
+
if (framework === 'koa') {
|
|
108
|
+
dependencies.push('@feathersjs/koa', 'koa-static');
|
|
109
|
+
}
|
|
110
|
+
if (framework === 'express') {
|
|
111
|
+
dependencies.push('@feathersjs/express', 'compression', 'helmet');
|
|
112
|
+
}
|
|
113
|
+
return (0, commons_1.addVersions)(dependencies, dependencyVersions);
|
|
114
|
+
}))
|
|
115
|
+
.then((0, pinion_1.install)(({ language, framework, devDependencies, dependencyVersions }) => {
|
|
116
|
+
devDependencies.push('nodemon', 'axios', 'mocha', 'cross-env');
|
|
117
|
+
if (language === 'ts') {
|
|
118
|
+
devDependencies.push('@types/mocha', framework === 'koa' ? '@types/koa-static' : '@types/compression', '@types/node', 'nodemon', 'ts-node', 'typescript', 'shx');
|
|
119
|
+
}
|
|
120
|
+
return (0, commons_1.addVersions)(devDependencies, dependencyVersions);
|
|
121
|
+
}, true));
|
|
122
|
+
exports.generate = generate;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA0B;AAC1B,kDAAyB;AACzB,+CAS2B;AAC3B,wCAAqG;AACrG,sDAAyG;AACzG,8CAA6F;AAiCtF,MAAM,QAAQ,GAAG,CAAC,GAA0B,EAAE,EAAE,CACrD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX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I,EAAE;QACrB,eAAe,CAAC,IAAI,CAClB,cAAc,EACd,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,oBAAoB,EAChE,aAAa,EACb,SAAS,EACT,SAAS,EACT,YAAY,EACZ,KAAK,CACN,CAAA;KACF;IAED,OAAO,IAAA,qBAAW,EAAC,eAAe,EAAE,kBAAkB,CAAC,CAAA;AACzD,CAAC,EAAE,IAAI,CAAC,CACT,CAAA;AAtJQ,QAAA,QAAQ,YAsJhB"}
|
package/lib/app/index.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
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((ctx) => ({
|
|
51
|
+
...ctx,
|
|
52
|
+
dependencies: [],
|
|
53
|
+
devDependencies: []
|
|
54
|
+
}))
|
|
55
|
+
.then(
|
|
56
|
+
prompt<AppGeneratorArguments, AppGeneratorContext>((ctx) => [
|
|
57
|
+
{
|
|
58
|
+
name: 'language',
|
|
59
|
+
type: 'list',
|
|
60
|
+
message: 'Do you want to use JavaScript or TypeScript?',
|
|
61
|
+
when: !ctx.language,
|
|
62
|
+
choices: [
|
|
63
|
+
{ name: 'TypeScript', value: 'ts' },
|
|
64
|
+
{ name: 'JavaScript', value: 'js' }
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'name',
|
|
69
|
+
type: 'input',
|
|
70
|
+
when: !ctx.name,
|
|
71
|
+
message: 'What is the name of your application?',
|
|
72
|
+
default: ctx.cwd.split(sep).pop()
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'description',
|
|
76
|
+
type: 'input',
|
|
77
|
+
when: !ctx.description,
|
|
78
|
+
message: 'Write a short description'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'list',
|
|
82
|
+
name: 'framework',
|
|
83
|
+
when: !ctx.framework,
|
|
84
|
+
message: 'Which HTTP framework do you want to use?',
|
|
85
|
+
choices: [
|
|
86
|
+
{ value: 'koa', name: `KoaJS ${chalk.grey('(recommended)')}` },
|
|
87
|
+
{ value: 'express', name: 'Express' }
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'checkbox',
|
|
92
|
+
name: 'transports',
|
|
93
|
+
when: !ctx.transports,
|
|
94
|
+
message: 'What APIs do you want to offer?',
|
|
95
|
+
choices: [
|
|
96
|
+
{ value: 'rest', name: 'HTTP (REST)', checked: true },
|
|
97
|
+
{ value: 'websockets', name: 'Real-time', checked: true }
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'packager',
|
|
102
|
+
type: 'list',
|
|
103
|
+
when: !ctx.packager,
|
|
104
|
+
message: 'Which package manager are you using?',
|
|
105
|
+
choices: [
|
|
106
|
+
{ value: 'npm', name: 'npm' },
|
|
107
|
+
{ value: 'yarn', name: 'Yarn' }
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
...connectionPrompts(ctx),
|
|
111
|
+
...authenticationPrompts({
|
|
112
|
+
...ctx,
|
|
113
|
+
service: 'users',
|
|
114
|
+
entity: 'user'
|
|
115
|
+
})
|
|
116
|
+
])
|
|
117
|
+
)
|
|
118
|
+
.then(runGenerators(__dirname, 'templates'))
|
|
119
|
+
.then(copyFiles(fromFile(__dirname, 'static'), toFile('.')))
|
|
120
|
+
.then(initializeBaseContext())
|
|
121
|
+
.then(
|
|
122
|
+
when<AppGeneratorContext>(
|
|
123
|
+
({ authStrategies }) => authStrategies.length > 0,
|
|
124
|
+
async (ctx) => {
|
|
125
|
+
const { dependencies } = await connectionGenerator(ctx)
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
...ctx,
|
|
129
|
+
dependencies
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
.then(
|
|
135
|
+
when<AppGeneratorContext>(
|
|
136
|
+
({ authStrategies }) => authStrategies.length > 0,
|
|
137
|
+
async (ctx) => {
|
|
138
|
+
const { dependencies } = await authenticationGenerator({
|
|
139
|
+
...ctx,
|
|
140
|
+
service: 'users',
|
|
141
|
+
entity: 'user'
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
...ctx,
|
|
146
|
+
dependencies
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
.then(
|
|
152
|
+
install<AppGeneratorContext>(({ transports, framework, dependencyVersions, dependencies }) => {
|
|
153
|
+
const hasSocketio = transports.includes('websockets')
|
|
154
|
+
|
|
155
|
+
dependencies.push(
|
|
156
|
+
'@feathersjs/feathers',
|
|
157
|
+
'@feathersjs/errors',
|
|
158
|
+
'@feathersjs/schema',
|
|
159
|
+
'@feathersjs/configuration',
|
|
160
|
+
'@feathersjs/transport-commons',
|
|
161
|
+
'@feathersjs/authentication',
|
|
162
|
+
'winston'
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
if (hasSocketio) {
|
|
166
|
+
dependencies.push('@feathersjs/socketio')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (framework === 'koa') {
|
|
170
|
+
dependencies.push('@feathersjs/koa', 'koa-static')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (framework === 'express') {
|
|
174
|
+
dependencies.push('@feathersjs/express', 'compression', 'helmet')
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return addVersions(dependencies, dependencyVersions)
|
|
178
|
+
})
|
|
179
|
+
)
|
|
180
|
+
.then(
|
|
181
|
+
install<AppGeneratorContext>(({ language, framework, devDependencies, dependencyVersions }) => {
|
|
182
|
+
devDependencies.push('nodemon', 'axios', 'mocha', 'cross-env')
|
|
183
|
+
|
|
184
|
+
if (language === 'ts') {
|
|
185
|
+
devDependencies.push(
|
|
186
|
+
'@types/mocha',
|
|
187
|
+
framework === 'koa' ? '@types/koa-static' : '@types/compression',
|
|
188
|
+
'@types/node',
|
|
189
|
+
'nodemon',
|
|
190
|
+
'ts-node',
|
|
191
|
+
'typescript',
|
|
192
|
+
'shx'
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return addVersions(devDependencies, dependencyVersions)
|
|
197
|
+
}, true)
|
|
198
|
+
)
|
|
@@ -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,48 @@
|
|
|
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 }) => `import assert from 'assert'
|
|
7
|
+
import axios from 'axios'
|
|
8
|
+
import type { Server } from 'http'
|
|
9
|
+
import { app } from '../${lib}/app'
|
|
10
|
+
|
|
11
|
+
const port = app.get('port')
|
|
12
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
13
|
+
|
|
14
|
+
describe('Feathers application tests', () => {
|
|
15
|
+
let server: Server
|
|
16
|
+
|
|
17
|
+
before(async () => {
|
|
18
|
+
server = await app.listen(port)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
after(done => {
|
|
22
|
+
server.close(done)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('starts and shows the index page', async () => {
|
|
26
|
+
const { data } = await axios.get<string>(appUrl)
|
|
27
|
+
|
|
28
|
+
assert.ok(data.indexOf('<html lang="en">') !== -1)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('shows a 404 JSON error', async () => {
|
|
32
|
+
try {
|
|
33
|
+
await axios.get(\`\${appUrl}/path/to/nowhere\`, {
|
|
34
|
+
responseType: 'json'
|
|
35
|
+
})
|
|
36
|
+
assert.fail('should never get here')
|
|
37
|
+
} catch (error: any) {
|
|
38
|
+
const { response } = error
|
|
39
|
+
assert.strictEqual(response?.status, 404)
|
|
40
|
+
assert.strictEqual(response?.data?.code, 404)
|
|
41
|
+
assert.strictEqual(response?.data?.name, 'NotFound')
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
`;
|
|
46
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)('test', 'app.test')));
|
|
47
|
+
exports.generate = generate;
|
|
48
|
+
//# 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,EAAE,GAAG,EAAuB,EAAE,EAAE,CAChD;;;0BAGwB,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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({ lib }: AppGeneratorContext) =>
|
|
6
|
+
`import assert from 'assert'
|
|
7
|
+
import axios from 'axios'
|
|
8
|
+
import type { Server } from 'http'
|
|
9
|
+
import { app } from '../${lib}/app'
|
|
10
|
+
|
|
11
|
+
const port = app.get('port')
|
|
12
|
+
const appUrl = \`http://\${app.get('host')}:\${port}\`
|
|
13
|
+
|
|
14
|
+
describe('Feathers application tests', () => {
|
|
15
|
+
let server: Server
|
|
16
|
+
|
|
17
|
+
before(async () => {
|
|
18
|
+
server = await app.listen(port)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
after(done => {
|
|
22
|
+
server.close(done)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('starts and shows the index page', async () => {
|
|
26
|
+
const { data } = await axios.get<string>(appUrl)
|
|
27
|
+
|
|
28
|
+
assert.ok(data.indexOf('<html lang="en">') !== -1)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('shows a 404 JSON error', async () => {
|
|
32
|
+
try {
|
|
33
|
+
await axios.get(\`\${appUrl}/path/to/nowhere\`, {
|
|
34
|
+
responseType: 'json'
|
|
35
|
+
})
|
|
36
|
+
assert.fail('should never get here')
|
|
37
|
+
} catch (error: any) {
|
|
38
|
+
const { response } = error
|
|
39
|
+
assert.strictEqual(response?.status, 404)
|
|
40
|
+
assert.strictEqual(response?.data?.code, 404)
|
|
41
|
+
assert.strictEqual(response?.data?.name, 'NotFound')
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
`
|
|
46
|
+
|
|
47
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
48
|
+
generator(ctx).then(renderSource(template, toFile('test', 'app.test')))
|