mirror of
https://github.com/feathersjs/feathers.git
synced 2025-12-08 19:46:22 +00:00
feat(generators): Move core code generators to shared generators package (#2982)
This commit is contained in:
parent
4b720f0588
commit
0328d22921
2
.gitignore
vendored
2
.gitignore
vendored
@ -41,6 +41,6 @@ dist/
|
|||||||
|
|
||||||
# TypeScript compiled files
|
# TypeScript compiled files
|
||||||
packages/**/lib
|
packages/**/lib
|
||||||
packages/cli/test/build/*.tgz
|
**/build/*.tgz
|
||||||
*.sqlite
|
*.sqlite
|
||||||
docs/.vitepress/cache
|
docs/.vitepress/cache
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"timeout": 20000,
|
"timeout": 30000,
|
||||||
"require": [ "ts-node/register", "source-map-support/register" ],
|
"require": ["ts-node/register", "source-map-support/register"],
|
||||||
"reporter": "Dot",
|
"reporter": "Dot",
|
||||||
"extension": ".test.ts",
|
"extension": ".test.ts",
|
||||||
"exit": true
|
"exit": true
|
||||||
|
|||||||
2311
docs/package-lock.json
generated
2311
docs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
2388
package-lock.json
generated
2388
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@
|
|||||||
"types": "lib/",
|
"types": "lib/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
"types": "lib/",
|
"types": "lib/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ts-node test/app",
|
"start": "ts-node test/app",
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"compile": "shx rm -rf lib/ && tsc && shx cp -r src/. lib/",
|
"compile": "shx rm -rf lib/ && tsc",
|
||||||
"mocha": "mocha --timeout 60000 --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
"mocha": "mocha --timeout 60000 --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
||||||
"test": "npm run compile && npm run mocha"
|
"test": "npm run compile && npm run mocha"
|
||||||
},
|
},
|
||||||
@ -52,11 +52,9 @@
|
|||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@feathershq/pinion": "^0.3.5",
|
|
||||||
"chalk": "^4.0.1",
|
|
||||||
"commander": "^9.4.1",
|
"commander": "^9.4.1",
|
||||||
"lodash": "^4.17.21",
|
"chalk": "^4.0.1",
|
||||||
"prettier": "^2.8.1"
|
"@feathersjs/generators": "^5.0.0-pre.34"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@feathersjs/adapter-commons": "^5.0.0-pre.34",
|
"@feathersjs/adapter-commons": "^5.0.0-pre.34",
|
||||||
|
|||||||
@ -1,68 +0,0 @@
|
|||||||
import chalk from 'chalk'
|
|
||||||
import { Command } from 'commander'
|
|
||||||
import { generator, runGenerator, getContext } from '@feathershq/pinion'
|
|
||||||
import { FeathersBaseContext, version } from './commons'
|
|
||||||
|
|
||||||
export * from 'commander'
|
|
||||||
export { chalk }
|
|
||||||
|
|
||||||
export const commandRunner = (name: string) => async (options: any) => {
|
|
||||||
const ctx = getContext<FeathersBaseContext>({
|
|
||||||
...options
|
|
||||||
})
|
|
||||||
|
|
||||||
await generator(ctx)
|
|
||||||
.then(runGenerator(__dirname, name, 'index'))
|
|
||||||
.catch((error) => {
|
|
||||||
const { logger } = ctx.pinion
|
|
||||||
|
|
||||||
logger.error(`Error: ${chalk.white(error.message)}`)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const program = new Command()
|
|
||||||
|
|
||||||
program
|
|
||||||
.name('feathers')
|
|
||||||
.description('The Feathers command line interface 🕊️')
|
|
||||||
.version(version)
|
|
||||||
.showHelpAfterError()
|
|
||||||
|
|
||||||
const generate = program.command('generate').alias('g')
|
|
||||||
|
|
||||||
generate
|
|
||||||
.command('app')
|
|
||||||
.description('Generate a new application')
|
|
||||||
.option('--name <name>', 'The name of the application')
|
|
||||||
.action(commandRunner('app'))
|
|
||||||
|
|
||||||
generate
|
|
||||||
.command('service')
|
|
||||||
.description('Generate a new service')
|
|
||||||
.option('--name <name>', 'The service name')
|
|
||||||
.option('--path <path>', 'The path to register the service on')
|
|
||||||
.option('--type <type>', 'The service type (knex, mongodb, custom)')
|
|
||||||
.action(commandRunner('service'))
|
|
||||||
|
|
||||||
generate
|
|
||||||
.command('hook')
|
|
||||||
.description('Generate a hook')
|
|
||||||
.option('--name <name>', 'The name of the hook')
|
|
||||||
.option('--type <type>', 'The hook type (around or regular)')
|
|
||||||
.action(commandRunner('hook'))
|
|
||||||
|
|
||||||
generate
|
|
||||||
.command('connection')
|
|
||||||
.description('Add a new database connection')
|
|
||||||
.action(commandRunner('connection'))
|
|
||||||
|
|
||||||
generate
|
|
||||||
.command('authentication')
|
|
||||||
.description('Add authentication to the application')
|
|
||||||
.action(commandRunner('authentication'))
|
|
||||||
|
|
||||||
generate.description(
|
|
||||||
`Run a generator. Currently available: \n ${generate.commands
|
|
||||||
.map((cmd) => `${chalk.blue(cmd.name())}: ${cmd.description()} `)
|
|
||||||
.join('\n ')}`
|
|
||||||
)
|
|
||||||
@ -1,2 +1,69 @@
|
|||||||
export * from './cli'
|
import chalk from 'chalk'
|
||||||
export * from './commons'
|
import { Command } from 'commander'
|
||||||
|
import { dirname } from 'path'
|
||||||
|
import { generator, runGenerator, getContext, FeathersBaseContext, version } from '@feathersjs/generators'
|
||||||
|
|
||||||
|
export * from 'commander'
|
||||||
|
export { chalk }
|
||||||
|
|
||||||
|
export const commandRunner = (name: string) => async (options: any) => {
|
||||||
|
const folder = dirname(require.resolve('@feathersjs/generators'))
|
||||||
|
const ctx = getContext<FeathersBaseContext>({
|
||||||
|
...options
|
||||||
|
})
|
||||||
|
|
||||||
|
await generator(ctx)
|
||||||
|
.then(runGenerator(folder, name, 'index'))
|
||||||
|
.catch((error) => {
|
||||||
|
const { logger } = ctx.pinion
|
||||||
|
|
||||||
|
logger.error(`Error: ${chalk.white(error.message)}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const program = new Command()
|
||||||
|
|
||||||
|
program
|
||||||
|
.name('feathers')
|
||||||
|
.description('The Feathers command line interface 🕊️')
|
||||||
|
.version(version)
|
||||||
|
.showHelpAfterError()
|
||||||
|
|
||||||
|
const generate = program.command('generate').alias('g')
|
||||||
|
|
||||||
|
generate
|
||||||
|
.command('app')
|
||||||
|
.description('Generate a new application')
|
||||||
|
.option('--name <name>', 'The name of the application')
|
||||||
|
.action(commandRunner('app'))
|
||||||
|
|
||||||
|
generate
|
||||||
|
.command('service')
|
||||||
|
.description('Generate a new service')
|
||||||
|
.option('--name <name>', 'The service name')
|
||||||
|
.option('--path <path>', 'The path to register the service on')
|
||||||
|
.option('--type <type>', 'The service type (knex, mongodb, custom)')
|
||||||
|
.action(commandRunner('service'))
|
||||||
|
|
||||||
|
generate
|
||||||
|
.command('hook')
|
||||||
|
.description('Generate a hook')
|
||||||
|
.option('--name <name>', 'The name of the hook')
|
||||||
|
.option('--type <type>', 'The hook type (around or regular)')
|
||||||
|
.action(commandRunner('hook'))
|
||||||
|
|
||||||
|
generate
|
||||||
|
.command('connection')
|
||||||
|
.description('Add a new database connection')
|
||||||
|
.action(commandRunner('connection'))
|
||||||
|
|
||||||
|
generate
|
||||||
|
.command('authentication')
|
||||||
|
.description('Add authentication to the application')
|
||||||
|
.action(commandRunner('authentication'))
|
||||||
|
|
||||||
|
generate.description(
|
||||||
|
`Run a generator. Currently available: \n ${generate.commands
|
||||||
|
.map((cmd) => `${chalk.blue(cmd.name())}: ${cmd.description()} `)
|
||||||
|
.join('\n ')}`
|
||||||
|
)
|
||||||
|
|||||||
8
packages/cli/test/cli.test.ts
Normal file
8
packages/cli/test/cli.test.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { strict } from 'assert'
|
||||||
|
import { program } from '../src'
|
||||||
|
|
||||||
|
describe('cli tests', () => {
|
||||||
|
it('exports the program', async () => {
|
||||||
|
strict.ok(program)
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -41,7 +41,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "NODE_CONFIG_DIR=./test/config mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "NODE_CONFIG_DIR=./test/config mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -47,7 +47,7 @@
|
|||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"version": "npm run write-version",
|
"version": "npm run write-version",
|
||||||
"publish": "npm run reset-version",
|
"publish": "npm run reset-version",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/"
|
"test": "mocha --config ../../.mocharc.json --recursive test/"
|
||||||
},
|
},
|
||||||
|
|||||||
23
packages/generators/README.md
Normal file
23
packages/generators/README.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# @feathersjs/generators
|
||||||
|
|
||||||
|
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
||||||
|
[](https://david-dm.org/feathersjs/feathers?path=packages/generators)
|
||||||
|
[](https://www.npmjs.com/package/@feathersjs/cli)
|
||||||
|
|
||||||
|
> Feathers core code generators used by the CLI powered by [Pinion](https://github.com/feathershq/pinion/)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install @feathersjs/generators --save-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Refer to the [Feathers documentation](https://docs.feathersjs.com) for more details.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
||||||
|
|
||||||
|
Licensed under the [MIT license](LICENSE).
|
||||||
89
packages/generators/package.json
Normal file
89
packages/generators/package.json
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"name": "@feathersjs/generators",
|
||||||
|
"version": "5.0.0-pre.34",
|
||||||
|
"description": "Feathers CLI core generators, powered by Pinion",
|
||||||
|
"homepage": "https://feathersjs.com",
|
||||||
|
"keywords": [
|
||||||
|
"feathers",
|
||||||
|
"pinion"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/daffl"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/feathersjs/feathers.git",
|
||||||
|
"directory": "packages/commons"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Feathers contributor",
|
||||||
|
"email": "hello@feathersjs.com",
|
||||||
|
"url": "https://feathersjs.com"
|
||||||
|
},
|
||||||
|
"contributors": [],
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/feathersjs/feathers/issues"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16"
|
||||||
|
},
|
||||||
|
"main": "lib/",
|
||||||
|
"types": "lib/",
|
||||||
|
"files": [
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md",
|
||||||
|
"lib/**",
|
||||||
|
"lib/app/static/.gitignore",
|
||||||
|
"*.d.ts",
|
||||||
|
"*.js"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"prepublish": "npm run compile",
|
||||||
|
"compile": "shx rm -rf lib/ && tsc && shx cp -r src/. lib/",
|
||||||
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@feathershq/pinion": "^0.3.5",
|
||||||
|
"chalk": "^4.0.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"prettier": "^2.8.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@feathersjs/adapter-commons": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/authentication": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/authentication-client": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/authentication-local": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/authentication-oauth": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/configuration": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/errors": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/express": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/feathers": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/knex": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/koa": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/mongodb": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/rest-client": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/schema": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/socketio": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/transport-commons": "^5.0.0-pre.34",
|
||||||
|
"@feathersjs/typebox": "^5.0.0-pre.34",
|
||||||
|
"@types/mocha": "^10.0.1",
|
||||||
|
"@types/node": "^18.11.18",
|
||||||
|
"@types/prettier": "^2.7.2",
|
||||||
|
"axios": "^1.2.2",
|
||||||
|
"mocha": "^10.2.0",
|
||||||
|
"shx": "^0.3.4",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
|
"type-fest": "^3.5.0",
|
||||||
|
"typescript": "^4.9.4"
|
||||||
|
},
|
||||||
|
"gitHead": "42cca600d00f0b3b9d89fa79be30fcd46bc50132"
|
||||||
|
}
|
||||||
@ -6,6 +6,7 @@ const template = ({
|
|||||||
language
|
language
|
||||||
}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/channels.html
|
}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/channels.html
|
||||||
import type { RealTimeConnection, Params } from '@feathersjs/feathers'
|
import type { RealTimeConnection, Params } from '@feathersjs/feathers'
|
||||||
|
import type { AuthenticationResult } from '@feathersjs/authentication'
|
||||||
import '@feathersjs/transport-commons'
|
import '@feathersjs/transport-commons'
|
||||||
import type { Application, HookContext } from './declarations'
|
import type { Application, HookContext } from './declarations'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
@ -16,14 +17,14 @@ export const channels = (app: Application) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn('Publishing all events to all authenticated users. See \`channels.${language}\` and https://docs.feathersjs.com/api/channels.html for more information.')
|
logger.warn('Publishing all events to all authenticated users. See \`channels.${language}\` and https://dove.feathersjs.com/api/channels.html for more information.')
|
||||||
|
|
||||||
app.on('connection', (connection: any) => {
|
app.on('connection', (connection: RealTimeConnection) => {
|
||||||
// On a new real-time connection, add it to the anonymous channel
|
// On a new real-time connection, add it to the anonymous channel
|
||||||
app.channel('anonymous').join(connection)
|
app.channel('anonymous').join(connection)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('login', (authResult: any, { connection }: Params) => {
|
app.on('login', (authResult: AuthenticationResult, { connection }: Params) => {
|
||||||
// connection can be undefined if there is no
|
// connection can be undefined if there is no
|
||||||
// real-time connection, e.g. when logging in via REST
|
// real-time connection, e.g. when logging in via REST
|
||||||
if(connection) {
|
if(connection) {
|
||||||
8
packages/generators/src/index.ts
Normal file
8
packages/generators/src/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export * from '@feathershq/pinion'
|
||||||
|
|
||||||
|
export * from './commons'
|
||||||
|
export * as app from './app'
|
||||||
|
export * as authentication from './authentication'
|
||||||
|
export * as connection from './connection'
|
||||||
|
export * as hook from './hook'
|
||||||
|
export * as service from './service'
|
||||||
@ -38,7 +38,7 @@ export const ${camelName}DataValidator = getDataValidator(${camelName}DataSchema
|
|||||||
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({})
|
export const ${camelName}DataResolver = resolve<${upperName}, HookContext>({})
|
||||||
|
|
||||||
// Schema for updating existing entries
|
// Schema for updating existing entries
|
||||||
export const ${camelName}PatchSchema = Type.Partial(${camelName}Schema, {
|
export const ${camelName}PatchSchema = Type.Partial(${camelName}DataSchema, {
|
||||||
$id: '${upperName}Patch'
|
$id: '${upperName}Patch'
|
||||||
})
|
})
|
||||||
export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
|
export type ${upperName}Patch = Static<typeof ${camelName}PatchSchema>
|
||||||
@ -29,7 +29,7 @@ const defaultCombination = {
|
|||||||
const combinations =
|
const combinations =
|
||||||
process.version > 'v16.0.0' ? (process.env.CI ? combinate(matrix as any) : [defaultCombination]) : []
|
process.version > 'v16.0.0' ? (process.env.CI ? combinate(matrix as any) : [defaultCombination]) : []
|
||||||
|
|
||||||
describe('@feathersjs/cli', () => {
|
describe('@feathersjs/generators', () => {
|
||||||
for (const { language, framework } of combinations) {
|
for (const { language, framework } of combinations) {
|
||||||
describe(`${language} ${framework} app`, () => {
|
describe(`${language} ${framework} app`, () => {
|
||||||
const name = `feathers_${language}_${framework}`
|
const name = `feathers_${language}_${framework}`
|
||||||
10
packages/generators/tsconfig.json
Normal file
10
packages/generators/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -40,7 +40,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
||||||
"test": "npm run compile && npm run mocha"
|
"test": "npm run compile && npm run mocha"
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
||||||
"test": "npm run mocha"
|
"test": "npm run mocha"
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"test": "npm run mocha",
|
"test": "npm run mocha",
|
||||||
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": "npm run compile",
|
"prepublish": "npm run compile",
|
||||||
"pack": "npm pack --pack-destination ../cli/test/build",
|
"pack": "npm pack --pack-destination ../generators/test/build",
|
||||||
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
||||||
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
||||||
"test": "npm run compile && npm run mocha"
|
"test": "npm run compile && npm run mocha"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user