@feathersjs/generators 5.0.28 → 5.0.29

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/app/index.js +1 -2
  3. package/lib/app/index.js.map +1 -1
  4. package/lib/app/templates/gitignore.tpl.d.ts +5 -0
  5. package/lib/app/templates/gitignore.tpl.js +125 -0
  6. package/lib/app/templates/gitignore.tpl.js.map +1 -0
  7. package/package.json +20 -21
  8. package/lib/app/index.ts +0 -215
  9. package/lib/app/templates/app.test.tpl.ts +0 -50
  10. package/lib/app/templates/app.tpl.ts +0 -141
  11. package/lib/app/templates/channels.tpl.ts +0 -54
  12. package/lib/app/templates/client.test.tpl.ts +0 -28
  13. package/lib/app/templates/client.tpl.ts +0 -53
  14. package/lib/app/templates/configuration.tpl.ts +0 -89
  15. package/lib/app/templates/declarations.tpl.ts +0 -42
  16. package/lib/app/templates/index.html.tpl.ts +0 -44
  17. package/lib/app/templates/index.tpl.ts +0 -26
  18. package/lib/app/templates/logger.tpl.ts +0 -56
  19. package/lib/app/templates/package.json.tpl.ts +0 -78
  20. package/lib/app/templates/prettierrc.tpl.ts +0 -14
  21. package/lib/app/templates/readme.md.tpl.ts +0 -57
  22. package/lib/app/templates/services.tpl.ts +0 -20
  23. package/lib/app/templates/tsconfig.json.tpl.ts +0 -29
  24. package/lib/app/templates/validators.tpl.ts +0 -39
  25. package/lib/authentication/index.ts +0 -119
  26. package/lib/authentication/templates/authentication.tpl.ts +0 -52
  27. package/lib/authentication/templates/client.test.tpl.ts +0 -78
  28. package/lib/authentication/templates/config.tpl.ts +0 -60
  29. package/lib/authentication/templates/declarations.tpl.ts +0 -38
  30. package/lib/commons.ts +0 -346
  31. package/lib/connection/index.ts +0 -138
  32. package/lib/connection/templates/knex.tpl.ts +0 -73
  33. package/lib/connection/templates/mongodb.tpl.ts +0 -50
  34. package/lib/hook/index.ts +0 -52
  35. package/lib/hook/templates/hook.tpl.ts +0 -33
  36. package/lib/index.ts +0 -8
  37. package/lib/service/index.ts +0 -214
  38. package/lib/service/templates/client.tpl.ts +0 -33
  39. package/lib/service/templates/schema.json.tpl.ts +0 -143
  40. package/lib/service/templates/schema.typebox.tpl.ts +0 -131
  41. package/lib/service/templates/service.tpl.ts +0 -161
  42. package/lib/service/templates/shared.tpl.ts +0 -64
  43. package/lib/service/templates/test.tpl.ts +0 -33
  44. package/lib/service/type/custom.tpl.ts +0 -112
  45. package/lib/service/type/knex.tpl.ts +0 -105
  46. package/lib/service/type/mongodb.tpl.ts +0 -64
@@ -1,54 +0,0 @@
1
- import { toFile, when } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const template = ({
6
- language
7
- }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/channels.html
8
- import type { RealTimeConnection, Params } from '@feathersjs/feathers'
9
- import type { AuthenticationResult } from '@feathersjs/authentication'
10
- import '@feathersjs/transport-commons'
11
- import type { Application, HookContext } from './declarations'
12
- import { logger } from './logger'
13
-
14
- export const channels = (app: Application) => {
15
- logger.warn('Publishing all events to all authenticated users. See \`channels.${language}\` and https://dove.feathersjs.com/api/channels.html for more information.')
16
-
17
- app.on('connection', (connection: RealTimeConnection) => {
18
- // On a new real-time connection, add it to the anonymous channel
19
- app.channel('anonymous').join(connection)
20
- })
21
-
22
- app.on('login', (authResult: AuthenticationResult, { connection }: Params) => {
23
- // connection can be undefined if there is no
24
- // real-time connection, e.g. when logging in via REST
25
- if(connection) {
26
- // The connection is no longer anonymous, remove it
27
- app.channel('anonymous').leave(connection)
28
-
29
- // Add it to the authenticated user channel
30
- app.channel('authenticated').join(connection)
31
- }
32
- })
33
-
34
- // eslint-disable-next-line no-unused-vars
35
- app.publish((data: any, context: HookContext) => {
36
- // Here you can add event publishers to channels set up in \`channels.js\`
37
- // To publish only for a specific event use \`app.publish(eventname, () => {})\`
38
-
39
- // e.g. to publish all service events to all authenticated users use
40
- return app.channel('authenticated')
41
- })
42
- }
43
- `
44
-
45
- export const generate = (ctx: AppGeneratorContext) =>
46
- Promise.resolve(ctx).then(
47
- when<AppGeneratorContext>(
48
- ({ transports }) => transports.includes('websockets'),
49
- renderSource(
50
- template,
51
- toFile<AppGeneratorContext>(({ lib }) => lib, 'channels')
52
- )
53
- )
54
- )
@@ -1,28 +0,0 @@
1
- import { toFile, when } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const template = ({ lib }: AppGeneratorContext) => /* ts */ `import assert from 'assert'
6
- import axios from 'axios'
7
- import type { Server } from 'http'
8
- import { app } from '../${lib}/app'
9
- import { createClient } from '../${lib}/client'
10
-
11
- import rest from '@feathersjs/rest-client'
12
-
13
- const port = app.get('port')
14
- const appUrl = \`http://\${app.get('host')}:\${port}\`
15
-
16
- describe('client tests', () => {
17
- const client = createClient(rest(appUrl).axios(axios))
18
-
19
- it('initialized the client', () => {
20
- assert.ok(client)
21
- })
22
- })
23
- `
24
-
25
- export const generate = (ctx: AppGeneratorContext) =>
26
- Promise.resolve(ctx).then(
27
- when<AppGeneratorContext>((ctx) => ctx.client, renderSource(template, toFile('test', 'client.test')))
28
- )
@@ -1,53 +0,0 @@
1
- import { toFile, when } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const template = ({
6
- name,
7
- language
8
- }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/client.html
9
- import { feathers } from '@feathersjs/feathers'
10
- import type { TransportConnection, Application } from '@feathersjs/feathers'
11
- import authenticationClient from '@feathersjs/authentication-client'
12
- import type { AuthenticationClientOptions } from '@feathersjs/authentication-client'
13
-
14
- export interface Configuration {
15
- connection: TransportConnection<ServiceTypes>
16
- }
17
-
18
- export interface ServiceTypes {}
19
-
20
- export type ClientApplication = Application<ServiceTypes, Configuration>
21
-
22
- /**
23
- * Returns a ${language === 'ts' ? 'typed' : ''} client for the ${name} app.
24
- *
25
- * @param connection The REST or Socket.io Feathers client connection
26
- * @param authenticationOptions Additional settings for the authentication client
27
- * @see https://dove.feathersjs.com/api/client.html
28
- * @returns The Feathers client application
29
- */
30
- export const createClient = <Configuration = any> (
31
- connection: TransportConnection<ServiceTypes>,
32
- authenticationOptions: Partial<AuthenticationClientOptions> = {}
33
- ) => {
34
- const client: ClientApplication = feathers()
35
-
36
- client.configure(connection)
37
- client.configure(authenticationClient(authenticationOptions))
38
- client.set('connection', connection)
39
-
40
- return client
41
- }
42
- `
43
-
44
- export const generate = async (ctx: AppGeneratorContext) =>
45
- Promise.resolve(ctx).then(
46
- when<AppGeneratorContext>(
47
- (ctx) => ctx.client,
48
- renderSource(
49
- template,
50
- toFile<AppGeneratorContext>(({ lib }) => lib, 'client')
51
- )
52
- )
53
- )
@@ -1,89 +0,0 @@
1
- import { toFile, when, writeJSON } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const defaultConfig = ({}: AppGeneratorContext) => ({
6
- host: 'localhost',
7
- port: 3030,
8
- public: './public/',
9
- origins: ['http://localhost:3030'],
10
- paginate: {
11
- default: 10,
12
- max: 50
13
- }
14
- })
15
-
16
- const customEnvironment = {
17
- port: {
18
- __name: 'PORT',
19
- __format: 'number'
20
- },
21
- host: 'HOSTNAME',
22
- authentication: {
23
- secret: 'FEATHERS_SECRET'
24
- }
25
- }
26
-
27
- const testConfig = {
28
- port: 8998
29
- }
30
-
31
- const configurationJsonTemplate =
32
- ({}: AppGeneratorContext) => `import { defaultAppSettings, getValidator } from '@feathersjs/schema'
33
- import type { FromSchema } from '@feathersjs/schema'
34
-
35
- import { dataValidator } from './validators'
36
-
37
- export const configurationSchema = {
38
- $id: 'configuration',
39
- type: 'object',
40
- additionalProperties: false,
41
- required: [ 'host', 'port', 'public' ],
42
- properties: {
43
- ...defaultAppSettings,
44
- host: { type: 'string' },
45
- port: { type: 'number' },
46
- public: { type: 'string' }
47
- }
48
- } as const
49
-
50
- export const configurationValidator = getValidator(configurationSchema, dataValidator)
51
-
52
- export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
53
- `
54
-
55
- const configurationTypeboxTemplate =
56
- ({}: AppGeneratorContext) => `import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'
57
- import type { Static } from '@feathersjs/typebox'
58
-
59
- import { dataValidator } from './validators'
60
-
61
- export const configurationSchema = Type.Intersect([
62
- defaultAppConfiguration,
63
- Type.Object({
64
- host: Type.String(),
65
- port: Type.Number(),
66
- public: Type.String()
67
- })
68
- ])
69
-
70
- export type ApplicationConfiguration = Static<typeof configurationSchema>
71
-
72
- export const configurationValidator = getValidator(configurationSchema, dataValidator)
73
- `
74
-
75
- export const generate = (ctx: AppGeneratorContext) =>
76
- Promise.resolve(ctx)
77
- .then(writeJSON(defaultConfig, toFile('config', 'default.json')))
78
- .then(writeJSON(testConfig, toFile('config', 'test.json')))
79
- .then(writeJSON(customEnvironment, toFile('config', 'custom-environment-variables.json')))
80
- .then(
81
- when<AppGeneratorContext>(
82
- (ctx) => ctx.schema !== false,
83
- renderSource(
84
- async (ctx) =>
85
- ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx),
86
- toFile<AppGeneratorContext>(({ lib }) => lib, 'configuration')
87
- )
88
- )
89
- )
@@ -1,42 +0,0 @@
1
- import { toFile, when, renderTemplate } from '@featherscloud/pinion'
2
- import { AppGeneratorContext } from '../index.js'
3
-
4
- const template = ({
5
- framework,
6
- schema
7
- }: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/typescript.html
8
- import { HookContext as FeathersHookContext, NextFunction } from '@feathersjs/feathers'
9
- import { Application as FeathersApplication } from '@feathersjs/${framework}'
10
- ${
11
- schema === false
12
- ? `type ApplicationConfiguration = any`
13
- : `import { ApplicationConfiguration } from './configuration'`
14
- }
15
-
16
- export type { NextFunction }
17
-
18
- // The types for app.get(name) and app.set(name)
19
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
20
- export interface Configuration extends ApplicationConfiguration {}
21
-
22
- // A mapping of service names to types. Will be extended in service files.
23
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
24
- export interface ServiceTypes {}
25
-
26
- // The application instance type that will be used everywhere else
27
- export type Application = FeathersApplication<ServiceTypes, Configuration>
28
-
29
- // The context for hook functions - can be typed with a service class
30
- export type HookContext<S = any> = FeathersHookContext<Application, S>
31
- `
32
-
33
- export const generate = (ctx: AppGeneratorContext) =>
34
- Promise.resolve(ctx).then(
35
- when<AppGeneratorContext>(
36
- ({ language }) => language === 'ts',
37
- renderTemplate(
38
- template,
39
- toFile<AppGeneratorContext>(({ lib }) => lib, 'declarations.ts')
40
- )
41
- )
42
- )
@@ -1,44 +0,0 @@
1
- import { renderTemplate, toFile } from '@featherscloud/pinion'
2
- import { AppGeneratorContext } from '../index.js'
3
-
4
- const template = ({ name, description }: AppGeneratorContext) => /* html */ `<!DOCTYPE html>
5
- <html lang="en">
6
- <head>
7
- <title>${name}</title>
8
- <meta name="description" content="${description}">
9
- <meta name="viewport" content="width=device-width, initial-scale=1">
10
- <style>
11
- * {
12
- margin: 0;
13
- padding: 0;
14
- box-sizing: border-box;
15
- }
16
-
17
- html {
18
- height: 100%;
19
- }
20
-
21
- body {
22
- min-height: 100%;
23
- display: flex;
24
- align-items: center;
25
- }
26
-
27
- img.logo {
28
- display: block;
29
- margin: auto auto;
30
- width: 30%;
31
- max-width: 100%;
32
- max-height: 100%;
33
- }
34
- </style>
35
- </head>
36
- <body>
37
- <img class="logo" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUwMCIgaGVpZ2h0PSIyNTAwIiB2aWV3Qm94PSIwIDAgMjU2IDI1NiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+PHBhdGggZD0iTTEyOCA5LjEwMmM2NS42NjUgMCAxMTguODk4IDUzLjIzMyAxMTguODk4IDExOC44OTggMCA2NS42NjUtNTMuMjMzIDExOC44OTgtMTE4Ljg5OCAxMTguODk4QzYyLjMzNSAyNDYuODk4IDkuMTAyIDE5My42NjUgOS4xMDIgMTI4IDkuMTAyIDYyLjMzNSA2Mi4zMzUgOS4xMDIgMTI4IDkuMTAyTTEyOCAwQzU3LjQyMSAwIDAgNTcuNDIxIDAgMTI4YzAgNzAuNTc5IDU3LjQyMSAxMjggMTI4IDEyOCA3MC41NzkgMCAxMjgtNTcuNDIxIDEyOC0xMjhDMjU2IDU3LjQyMSAxOTguNTc5IDAgMTI4IDBtMjAuODMgMjUuNTI0Yy0xMC40My0xLjg5Ni0zNS42NTEgMzYuNDA5LTQzLjk5NCA1OS43MzQtLjYzNCAxLjc2OS0yLjA4NiA4LjI0OS0yLjA4NiA5Ljk1NSAwIDAgNi41MzEgMTQuMDU1IDguMzQzIDE3LjM1MS0zLjAzNC0xLjU4LTkuMzIzLTEzLjc1Ni05LjMyMy0xMy43NTYtMy4wMzQgNS43ODQtNS45NDIgMzIuMzQtNC45OTQgMzcuMjcxIDAgMCA2Ljc2MiAxMC4wNjIgOS4zODcgMTIuNTc4LTMuNjAzLTEuMjAxLTkuNjcxLTkuMzU1LTkuNjcxLTkuMzU1LTEuMTM4IDMuNTA4LS45MTYgMTAuODA3LS4zNzkgMTMuMjc0IDQuNTUxIDYuNjM3IDEwLjYxOSA3LjM5NiAxMC42MTkgNy4zOTZzLTYuNjM3IDY2LjE4MSAzLjQxMyA3MS4xMTFjNi4yNTgtMS4zMjcgNy43NzUtNzMuOTU2IDcuNzc1LTczLjk1NnM3LjU4NS41NjkgOS4yOTItMS4zMjdjMy44NTYtMi42NTUgMTIuODI2LTMwLjIyNCAxMi45NTgtMzQuMjAyIDAgMC0xMC40MSAxLjk1Mi0xNS40ODcgMy45MjQgMy44MjYtMy44IDE2LjA0OS02LjM1MiAxNi4wNDktNi4zNTIgMy4zMTUtMy45NzkgMTAuMjkxLTMxLjA0NyAxMC45OTQtMzkuMzkxLjE3Ni0yLjA5My41ODMtNC42NTcuMjY4LTguMzk4IDAgMC05Ljk0MSAyLjE3Ny0xMi4wMTQgMS40MjQgMi4xMDQtLjIzNyAxMi4yNjMtNC4xNCAxMi4yNjMtNC4xNCAxLjgwMS0xNi4yMTMgMi4zNTgtNDIuMDkxLTMuNDEzLTQzLjE0MXptLTM2LjM4IDE3MS42OTFjLS43OTUgMTkuNDk2LTEuMjk0IDI1LjAwNC0yLjExNSAyOS42MDEtLjM3OS44NTctLjc1OC45OTctMS4xMzgtLjA5NS0zLjQ3Ny0xNS45OTItMy4yMjQtMTM2LjQzOCAzNi40MDktMTkxLjI0MS0yMy4wNSA0Mi4wOTItMzMuNTM1IDEyMi44NjEtMzMuMTU2IDE2MS43MzV6IiBmaWxsPSIjMzMzIi8+PC9zdmc+" />
38
- </body>
39
- </html>
40
-
41
- `
42
-
43
- export const generate = (ctx: AppGeneratorContext) =>
44
- Promise.resolve(ctx).then(renderTemplate(template, toFile('public', 'index.html')))
@@ -1,26 +0,0 @@
1
- import { toFile } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const template = ({}: AppGeneratorContext) => /* ts */ `import { app } from './app'
6
- import { logger } from './logger'
7
-
8
- const port = app.get('port')
9
- const host = app.get('host')
10
-
11
- process.on('unhandledRejection', (reason) =>
12
- logger.error('Unhandled Rejection %O', reason)
13
- )
14
-
15
- app.listen(port).then(() => {
16
- logger.info(\`Feathers app listening on http://\${host}:\${port}\`)
17
- })
18
- `
19
-
20
- export const generate = (ctx: AppGeneratorContext) =>
21
- Promise.resolve(ctx).then(
22
- renderSource(
23
- template,
24
- toFile<AppGeneratorContext>(({ lib }) => lib, 'index')
25
- )
26
- )
@@ -1,56 +0,0 @@
1
- import { toFile } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const template =
6
- ({}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/logging.html
7
- import { createLogger, format, transports } from 'winston'
8
-
9
- // Configure the Winston logger. For the complete documentation see https://github.com/winstonjs/winston
10
- export const logger = createLogger({
11
- // To see more detailed errors, change this to 'debug'
12
- level: 'info',
13
- format: format.combine(
14
- format.splat(),
15
- format.simple()
16
- ),
17
- transports: [
18
- new transports.Console()
19
- ]
20
- })
21
- `
22
-
23
- export const logErrorTemplate = /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/log-error.html
24
- import type { HookContext, NextFunction } from '../declarations'
25
- import { logger } from '../logger'
26
-
27
- export const logError = async (context: HookContext, next: NextFunction) => {
28
- try {
29
- await next()
30
- } catch (error: any) {
31
- logger.error(error.stack)
32
-
33
- // Log validation errors
34
- if (error.data) {
35
- logger.error('Data: %O', error.data)
36
- }
37
-
38
- throw error
39
- }
40
- }
41
- `
42
-
43
- export const generate = (ctx: AppGeneratorContext) =>
44
- Promise.resolve(ctx)
45
- .then(
46
- renderSource(
47
- template,
48
- toFile<AppGeneratorContext>(({ lib }) => lib, 'logger')
49
- )
50
- )
51
- .then(
52
- renderSource(
53
- logErrorTemplate,
54
- toFile<AppGeneratorContext>(({ lib }) => lib, 'hooks', 'log-error')
55
- )
56
- )
@@ -1,78 +0,0 @@
1
- import { toFile, writeJSON } from '@featherscloud/pinion'
2
- import { AppGeneratorContext } from '../index.js'
3
-
4
- const jsPackageJson = (lib: string) => ({
5
- type: 'module',
6
- scripts: {
7
- start: `node ${lib}`,
8
- dev: `nodemon ${lib}/`,
9
- prettier: 'npx prettier "**/*.js" --write',
10
- mocha: 'cross-env NODE_ENV=test mocha test/ --recursive --exit',
11
- test: 'npm run mocha',
12
- 'bundle:client': 'npm pack --pack-destination ./public'
13
- }
14
- })
15
-
16
- const tsPackageJson = (lib: string) => ({
17
- scripts: {
18
- dev: `nodemon -x ts-node ${lib}/index.ts`,
19
- compile: 'shx rm -rf lib/ && tsc',
20
- start: 'node lib/',
21
- prettier: 'npx prettier "**/*.ts" --write',
22
- mocha:
23
- 'cross-env NODE_ENV=test mocha test/ --require ts-node/register --recursive --extension .ts --exit',
24
- test: 'npm run mocha',
25
- 'bundle:client': 'npm run compile && npm pack --pack-destination ./public'
26
- }
27
- })
28
-
29
- const packageJson = ({
30
- name,
31
- description,
32
- client,
33
- language,
34
- packager,
35
- database,
36
- framework,
37
- transports,
38
- lib,
39
- test,
40
- schema
41
- }: AppGeneratorContext) => ({
42
- name,
43
- description,
44
- version: '0.0.0',
45
- homepage: '',
46
- private: true,
47
- keywords: ['feathers'],
48
- author: {},
49
- contributors: [] as string[],
50
- bugs: {},
51
- engines: {
52
- node: `>= ${process.version.substring(1)}`
53
- },
54
- feathers: {
55
- language,
56
- packager,
57
- database,
58
- framework,
59
- transports,
60
- schema
61
- },
62
- directories: {
63
- lib,
64
- test
65
- },
66
- ...(client
67
- ? {
68
- files: ['lib/client.js', 'lib/**/*.d.ts', 'lib/**/*.shared.js'],
69
- main: language === 'ts' ? 'lib/client' : `${lib}/client`
70
- }
71
- : {
72
- main: 'lib/index'
73
- }),
74
- ...(language === 'ts' ? tsPackageJson(lib) : jsPackageJson(lib))
75
- })
76
-
77
- export const generate = (ctx: AppGeneratorContext) =>
78
- Promise.resolve(ctx).then(writeJSON(packageJson, toFile('package.json')))
@@ -1,14 +0,0 @@
1
- import { toFile, writeJSON } from '@featherscloud/pinion'
2
- import { AppGeneratorContext } from '../index.js'
3
- import { PRETTIERRC } from '../../commons.js'
4
-
5
- export const generate = (ctx: AppGeneratorContext) =>
6
- Promise.resolve(ctx).then(
7
- writeJSON<AppGeneratorContext>(
8
- (ctx) => ({
9
- ...PRETTIERRC,
10
- parser: ctx.language === 'ts' ? 'typescript' : 'babel'
11
- }),
12
- toFile('.prettierrc')
13
- )
14
- )
@@ -1,57 +0,0 @@
1
- import { renderTemplate, toFile } from '@featherscloud/pinion'
2
- import { AppGeneratorContext } from '../index.js'
3
-
4
- const template = ({ name, description, language, database }: AppGeneratorContext) => /* md */ `# ${name}
5
-
6
- > ${description}
7
-
8
- ## About
9
-
10
- This project uses [Feathers](http://feathersjs.com). An open source framework for building APIs and real-time applications.
11
-
12
- ## Getting Started
13
-
14
- 1. Make sure you have [NodeJS](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed.
15
- 2. Install your dependencies
16
-
17
- \`\`\`
18
- cd path/to/${name}
19
- npm install
20
- \`\`\`
21
-
22
- 3. Start your app
23
-
24
- \`\`\`${
25
- language === 'ts'
26
- ? `
27
- npm run compile # Compile TypeScript source`
28
- : ''
29
- }${
30
- database !== 'mongodb'
31
- ? `
32
- npm run migrate # Run migrations to set up the database`
33
- : ''
34
- }
35
- npm start
36
- \`\`\`
37
-
38
- ## Testing
39
-
40
- Run \`npm test\` and all your tests in the \`test/\` directory will be run.
41
-
42
- ## Scaffolding
43
-
44
- This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
45
-
46
- \`\`\`
47
- $ npx feathers help # Show all commands
48
- $ npx feathers generate service # Generate a new Service
49
- \`\`\`
50
-
51
- ## Help
52
-
53
- For more information on all the things you can do with Feathers visit [docs.feathersjs.com](http://docs.feathersjs.com).
54
- `
55
-
56
- export const generate = (ctx: AppGeneratorContext) =>
57
- Promise.resolve(ctx).then(renderTemplate(template, toFile('readme.md')))
@@ -1,20 +0,0 @@
1
- import { toFile } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const template =
6
- ({}: AppGeneratorContext) => /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions
7
- import type { Application } from '../declarations'
8
-
9
- export const services = (app: Application) => {
10
- // All services will be registered here
11
- }
12
- `
13
-
14
- export const generate = (ctx: AppGeneratorContext) =>
15
- Promise.resolve(ctx).then(
16
- renderSource(
17
- template,
18
- toFile<AppGeneratorContext>(({ lib }) => lib, 'services', 'index')
19
- )
20
- )
@@ -1,29 +0,0 @@
1
- import { toFile, when, writeJSON } from '@featherscloud/pinion'
2
- import { AppGeneratorContext } from '../index.js'
3
-
4
- export const generate = (ctx: AppGeneratorContext) =>
5
- Promise.resolve(ctx).then(
6
- when<AppGeneratorContext>(
7
- (ctx) => ctx.language === 'ts',
8
- writeJSON<AppGeneratorContext>(
9
- ({ lib }) => ({
10
- 'ts-node': {
11
- files: true
12
- },
13
- compilerOptions: {
14
- target: 'es2020',
15
- module: 'commonjs',
16
- outDir: './lib',
17
- rootDir: `./${lib}`,
18
- declaration: true,
19
- strict: true,
20
- esModuleInterop: true,
21
- sourceMap: true
22
- },
23
- include: [lib],
24
- exclude: ['test']
25
- }),
26
- toFile('tsconfig.json')
27
- )
28
- )
29
- )
@@ -1,39 +0,0 @@
1
- import { toFile } from '@featherscloud/pinion'
2
- import { renderSource } from '../../commons.js'
3
- import { AppGeneratorContext } from '../index.js'
4
-
5
- const validatorTemplate = /* ts */ `// For more information about this file see https://dove.feathersjs.com/guides/cli/validators.html
6
- import { Ajv, addFormats } from '@feathersjs/schema'
7
- import type { FormatsPluginOptions } from '@feathersjs/schema'
8
-
9
- const formats: FormatsPluginOptions = [
10
- 'date-time',
11
- 'time',
12
- 'date',
13
- 'email',
14
- 'hostname',
15
- 'ipv4',
16
- 'ipv6',
17
- 'uri',
18
- 'uri-reference',
19
- 'uuid',
20
- 'uri-template',
21
- 'json-pointer',
22
- 'relative-json-pointer',
23
- 'regex'
24
- ]
25
-
26
- export const dataValidator: Ajv = addFormats(new Ajv({}), formats)
27
-
28
- export const queryValidator: Ajv = addFormats(new Ajv({
29
- coerceTypes: true
30
- }), formats)
31
- `
32
-
33
- export const generate = (ctx: AppGeneratorContext) =>
34
- Promise.resolve(ctx).then(
35
- renderSource(
36
- validatorTemplate,
37
- toFile<AppGeneratorContext>(({ lib }) => lib, 'validators')
38
- )
39
- )