@feathersjs/cli 5.0.0-pre.29 → 5.0.0-pre.30
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 +25 -39
- package/bin/feathers +3 -6
- package/lib/app/index.js +33 -10
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +81 -53
- package/lib/app/templates/app.test.tpl.js +1 -1
- package/lib/app/templates/app.test.tpl.js.map +1 -1
- package/lib/app/templates/app.test.tpl.ts +1 -2
- package/lib/app/templates/app.tpl.js +7 -7
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +7 -9
- package/lib/app/templates/channels.tpl.js +1 -1
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +1 -2
- package/lib/app/templates/client.tpl.js +2 -2
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +2 -3
- package/lib/app/templates/declarations.tpl.js +3 -3
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +5 -4
- package/lib/app/templates/index.html.tpl.js +12 -52
- package/lib/app/templates/index.html.tpl.js.map +1 -1
- package/lib/app/templates/index.html.tpl.ts +12 -53
- package/lib/app/templates/index.tpl.js +1 -1
- package/lib/app/templates/index.tpl.js.map +1 -1
- package/lib/app/templates/index.tpl.ts +1 -2
- package/lib/app/templates/logger.tpl.js +1 -1
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +2 -2
- package/lib/app/templates/package.json.tpl.js +4 -3
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -3
- package/lib/app/templates/readme.md.tpl.js +11 -7
- package/lib/app/templates/readme.md.tpl.js.map +1 -1
- package/lib/app/templates/readme.md.tpl.ts +15 -8
- package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
- package/lib/app/templates/schemas.tpl.js +76 -0
- package/lib/app/templates/schemas.tpl.js.map +1 -0
- package/lib/app/templates/schemas.tpl.ts +90 -0
- package/lib/app/templates/services.tpl.js +1 -1
- package/lib/app/templates/services.tpl.js.map +1 -1
- package/lib/app/templates/services.tpl.ts +1 -2
- package/lib/authentication/index.d.ts +4 -3
- package/lib/authentication/index.js +12 -3
- package/lib/authentication/index.js.map +1 -1
- package/lib/authentication/index.ts +23 -5
- package/lib/authentication/templates/authentication.tpl.js +1 -1
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +3 -2
- package/lib/authentication/templates/config.tpl.js +1 -1
- package/lib/authentication/templates/config.tpl.js.map +1 -1
- package/lib/authentication/templates/config.tpl.ts +1 -1
- package/lib/authentication/templates/declarations.tpl.js +3 -3
- package/lib/authentication/templates/declarations.tpl.js.map +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +9 -4
- package/lib/authentication/templates/knex.tpl.js +2 -2
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +2 -2
- package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/authentication/templates/schema.json.tpl.js +92 -0
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.json.tpl.ts +108 -0
- package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
- package/lib/authentication/templates/test.tpl.js +2 -2
- package/lib/authentication/templates/test.tpl.js.map +1 -1
- package/lib/authentication/templates/test.tpl.ts +6 -3
- package/lib/cli.d.ts +6 -0
- package/lib/cli.js +75 -0
- package/lib/cli.js.map +1 -0
- package/lib/cli.ts +68 -0
- package/lib/commons.d.ts +14 -1
- package/lib/commons.js +24 -4
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +29 -1
- package/lib/connection/index.d.ts +5 -3
- package/lib/connection/index.js +5 -3
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +19 -5
- package/lib/connection/templates/knex.tpl.js +2 -12
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -20
- package/lib/connection/templates/mongodb.tpl.js +1 -3
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +1 -12
- package/lib/hook/index.d.ts +1 -1
- package/lib/hook/index.js +3 -0
- package/lib/hook/index.js.map +1 -1
- package/lib/hook/index.ts +3 -1
- package/lib/hook/templates/hook.tpl.js +2 -3
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +5 -3
- package/lib/index.d.ts +2 -16
- package/lib/index.js +16 -24
- package/lib/index.js.map +1 -1
- package/lib/index.ts +2 -28
- package/lib/service/index.d.ts +10 -2
- package/lib/service/index.js +79 -41
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +54 -6
- package/lib/service/templates/client.tpl.js +19 -11
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +34 -17
- package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.json.tpl.js +73 -0
- package/lib/service/templates/schema.json.tpl.js.map +1 -0
- package/lib/service/templates/schema.json.tpl.ts +85 -0
- package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.typebox.tpl.js +58 -0
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/service/templates/schema.typebox.tpl.ts +70 -0
- package/lib/service/templates/service.tpl.d.ts +1 -0
- package/lib/service/templates/service.tpl.js +67 -15
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +98 -19
- package/lib/service/templates/test.tpl.js +1 -1
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +1 -2
- package/lib/service/type/custom.tpl.d.ts +1 -2
- package/lib/service/type/custom.tpl.js +32 -25
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +44 -35
- package/lib/service/type/knex.tpl.d.ts +1 -3
- package/lib/service/type/knex.tpl.js +33 -23
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +51 -29
- package/lib/service/type/mongodb.tpl.d.ts +1 -2
- package/lib/service/type/mongodb.tpl.js +30 -20
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +47 -29
- package/package.json +22 -23
- package/lib/app/templates/configuration.tpl.js +0 -45
- package/lib/app/templates/configuration.tpl.js.map +0 -1
- package/lib/app/templates/configuration.tpl.ts +0 -50
- package/lib/authentication/templates/user.resolver.tpl.js +0 -98
- package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
- package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
- package/lib/authentication/templates/user.schema.tpl.js +0 -79
- package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
- package/lib/authentication/templates/user.schema.tpl.ts +0 -87
- package/lib/service/templates/class.tpl.js +0 -63
- package/lib/service/templates/class.tpl.js.map +0 -1
- package/lib/service/templates/class.tpl.ts +0 -79
- package/lib/service/templates/resolver.tpl.js +0 -73
- package/lib/service/templates/resolver.tpl.js.map +0 -1
- package/lib/service/templates/resolver.tpl.ts +0 -78
- package/lib/service/templates/schema.tpl.d.ts +0 -2
- package/lib/service/templates/schema.tpl.js +0 -75
- package/lib/service/templates/schema.tpl.js.map +0 -1
- package/lib/service/templates/schema.tpl.ts +0 -80
package/lib/connection/index.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { generator, runGenerator, prompt, install, mergeJSON, toFile } from '@feathershq/pinion'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FeathersBaseContext,
|
|
5
|
+
DatabaseType,
|
|
6
|
+
getDatabaseAdapter,
|
|
7
|
+
addVersions,
|
|
8
|
+
checkPreconditions,
|
|
9
|
+
initializeBaseContext
|
|
10
|
+
} from '../commons'
|
|
4
11
|
|
|
5
12
|
export interface ConnectionGeneratorContext extends FeathersBaseContext {
|
|
13
|
+
name?: string
|
|
6
14
|
database: DatabaseType
|
|
7
15
|
connectionString: string
|
|
8
16
|
dependencies: string[]
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
export type ConnectionGeneratorArguments = FeathersBaseContext &
|
|
12
|
-
Partial<Pick<ConnectionGeneratorContext, 'database' | 'connectionString'>>
|
|
20
|
+
Partial<Pick<ConnectionGeneratorContext, 'database' | 'connectionString' | 'name'>>
|
|
13
21
|
|
|
14
22
|
export const defaultConnectionString = (type: DatabaseType, name: string) => {
|
|
15
23
|
const connectionStrings = {
|
|
@@ -23,7 +31,7 @@ export const defaultConnectionString = (type: DatabaseType, name: string) => {
|
|
|
23
31
|
return connectionStrings[type]
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
export const prompts = ({ database, connectionString, pkg }: ConnectionGeneratorArguments) => [
|
|
34
|
+
export const prompts = ({ database, connectionString, pkg, name }: ConnectionGeneratorArguments) => [
|
|
27
35
|
{
|
|
28
36
|
name: 'database',
|
|
29
37
|
type: 'list',
|
|
@@ -44,7 +52,7 @@ export const prompts = ({ database, connectionString, pkg }: ConnectionGenerator
|
|
|
44
52
|
when: !connectionString,
|
|
45
53
|
message: 'Enter your database connection string',
|
|
46
54
|
default: (answers: { name?: string; database: DatabaseType }) =>
|
|
47
|
-
defaultConnectionString(answers.database, answers.name || pkg.name)
|
|
55
|
+
defaultConnectionString(answers.database, answers.name || name || pkg.name)
|
|
48
56
|
}
|
|
49
57
|
]
|
|
50
58
|
|
|
@@ -60,6 +68,8 @@ export const getDatabaseClient = (database: DatabaseType) => DATABASE_CLIENTS[da
|
|
|
60
68
|
|
|
61
69
|
export const generate = (ctx: ConnectionGeneratorArguments) =>
|
|
62
70
|
generator(ctx)
|
|
71
|
+
.then(initializeBaseContext())
|
|
72
|
+
.then(checkPreconditions())
|
|
63
73
|
.then(prompt<ConnectionGeneratorArguments, ConnectionGeneratorContext>(prompts))
|
|
64
74
|
.then(
|
|
65
75
|
runGenerator<ConnectionGeneratorContext>(
|
|
@@ -105,5 +115,9 @@ export const generate = (ctx: ConnectionGeneratorArguments) =>
|
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
117
|
|
|
108
|
-
return install<ConnectionGeneratorContext>(
|
|
118
|
+
return install<ConnectionGeneratorContext>(
|
|
119
|
+
addVersions(dependencies, ctx.dependencyVersions),
|
|
120
|
+
false,
|
|
121
|
+
ctx.feathers.packager
|
|
122
|
+
)(ctx)
|
|
109
123
|
})
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ database }) => `import knex from 'knex'
|
|
6
|
+
const template = ({ database }) => /* ts */ `import knex from 'knex'
|
|
7
7
|
import type { Knex } from 'knex'
|
|
8
8
|
import type { Application } from './declarations'
|
|
9
9
|
|
|
@@ -20,25 +20,16 @@ export const ${database} = (app: Application) => {
|
|
|
20
20
|
app.set('${database}Client', db)
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
|
-
const knexfile = ({ lib, language, database }) => `
|
|
24
|
-
import { app } from './${lib}/app'
|
|
23
|
+
const knexfile = ({ lib, language, database }) => /* ts */ `import { app } from './${lib}/app'
|
|
25
24
|
|
|
26
25
|
// Load our database connection info from the app configuration
|
|
27
26
|
const config = app.get('${database}')
|
|
28
27
|
|
|
29
28
|
${language === 'js' ? 'export default config' : 'module.exports = config'}
|
|
30
29
|
`;
|
|
31
|
-
const configurationTemplate = ({ database }) => `${database}: {
|
|
32
|
-
type: 'object',
|
|
33
|
-
properties: {
|
|
34
|
-
client: { type: 'string' },
|
|
35
|
-
connection: { type: 'string' }
|
|
36
|
-
}
|
|
37
|
-
},`;
|
|
38
30
|
const importTemplate = ({ database }) => `import { ${database} } from './${database}'`;
|
|
39
31
|
const configureTemplate = ({ database }) => `app.configure(${database})`;
|
|
40
32
|
const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
|
|
41
|
-
const toConfig = (0, pinion_1.toFile)(({ lib }) => [lib, 'configuration']);
|
|
42
33
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
43
34
|
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib, database }) => [lib, database])))
|
|
44
35
|
.then((0, commons_1.renderSource)(knexfile, (0, pinion_1.toFile)('knexfile')))
|
|
@@ -49,7 +40,6 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
49
40
|
test: 'cross-env NODE_ENV=test npm run migrate && npm run mocha'
|
|
50
41
|
}
|
|
51
42
|
}, (0, pinion_1.toFile)('package.json')))
|
|
52
|
-
.then((0, commons_1.injectSource)(configurationTemplate, (0, pinion_1.before)('authentication: authenticationSettingsSchema'), toConfig, false))
|
|
53
43
|
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
54
44
|
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
55
45
|
exports.generate = generate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knex.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/knex.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAEzE,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAA8B,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"knex.tpl.js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AAE,qBAAqB;QAC9B,cAAc,EAAE,mBAAmB;QACnC,IAAI,EAAE,0DAA0D;KACjE;CACF,EACD,IAAA,eAAM,EAAC,cAAc,CAAC,CACvB,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAtB3E,QAAA,QAAQ,YAsBmE"}
|
|
@@ -2,8 +2,7 @@ import { generator, toFile, before, mergeJSON } from '@feathershq/pinion'
|
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
3
|
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const template = ({ database }: ConnectionGeneratorContext) =>
|
|
6
|
-
`import knex from 'knex'
|
|
5
|
+
const template = ({ database }: ConnectionGeneratorContext) => /* ts */ `import knex from 'knex'
|
|
7
6
|
import type { Knex } from 'knex'
|
|
8
7
|
import type { Application } from './declarations'
|
|
9
8
|
|
|
@@ -21,8 +20,11 @@ export const ${database} = (app: Application) => {
|
|
|
21
20
|
}
|
|
22
21
|
`
|
|
23
22
|
|
|
24
|
-
const knexfile = ({
|
|
25
|
-
|
|
23
|
+
const knexfile = ({
|
|
24
|
+
lib,
|
|
25
|
+
language,
|
|
26
|
+
database
|
|
27
|
+
}: ConnectionGeneratorContext) => /* ts */ `import { app } from './${lib}/app'
|
|
26
28
|
|
|
27
29
|
// Load our database connection info from the app configuration
|
|
28
30
|
const config = app.get('${database}')
|
|
@@ -30,19 +32,11 @@ const config = app.get('${database}')
|
|
|
30
32
|
${language === 'js' ? 'export default config' : 'module.exports = config'}
|
|
31
33
|
`
|
|
32
34
|
|
|
33
|
-
const configurationTemplate = ({ database }: ConnectionGeneratorContext) => `${database}: {
|
|
34
|
-
type: 'object',
|
|
35
|
-
properties: {
|
|
36
|
-
client: { type: 'string' },
|
|
37
|
-
connection: { type: 'string' }
|
|
38
|
-
}
|
|
39
|
-
},`
|
|
40
35
|
const importTemplate = ({ database }: ConnectionGeneratorContext) =>
|
|
41
36
|
`import { ${database} } from './${database}'`
|
|
42
37
|
const configureTemplate = ({ database }: ConnectionGeneratorContext) => `app.configure(${database})`
|
|
43
38
|
|
|
44
39
|
const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
|
|
45
|
-
const toConfig = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'configuration'])
|
|
46
40
|
|
|
47
41
|
export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
48
42
|
generator(ctx)
|
|
@@ -65,13 +59,5 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
|
65
59
|
toFile('package.json')
|
|
66
60
|
)
|
|
67
61
|
)
|
|
68
|
-
.then(
|
|
69
|
-
injectSource(
|
|
70
|
-
configurationTemplate,
|
|
71
|
-
before('authentication: authenticationSettingsSchema'),
|
|
72
|
-
toConfig,
|
|
73
|
-
false
|
|
74
|
-
)
|
|
75
|
-
)
|
|
76
62
|
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
|
77
63
|
.then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({}) => `import { MongoClient } from 'mongodb'
|
|
6
|
+
const template = ({}) => /* ts */ `import { MongoClient } from 'mongodb'
|
|
7
7
|
import type { Db } from 'mongodb'
|
|
8
8
|
import type { Application } from './declarations'
|
|
9
9
|
|
|
@@ -22,13 +22,11 @@ export const mongodb = (app: Application) => {
|
|
|
22
22
|
app.set('mongodbClient', mongoClient)
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
-
const configurationTemplate = ({ database }) => ` ${database}: { type: 'string' },`;
|
|
26
25
|
const importTemplate = "import { mongodb } from './mongodb'";
|
|
27
26
|
const configureTemplate = 'app.configure(mongodb)';
|
|
28
27
|
const toAppFile = (0, pinion_1.toFile)(({ lib }) => [lib, 'app']);
|
|
29
28
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
30
29
|
.then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'mongodb')))
|
|
31
|
-
.then((0, commons_1.injectSource)(configurationTemplate, (0, pinion_1.before)('authentication: authenticationSettingsSchema'), (0, pinion_1.toFile)(({ lib }) => [lib, 'configuration']), false))
|
|
32
30
|
.then((0, commons_1.injectSource)(importTemplate, (0, pinion_1.before)('import { services } from'), toAppFile))
|
|
33
31
|
.then((0, commons_1.injectSource)(configureTemplate, (0, pinion_1.before)('app.configure(services)'), toAppFile));
|
|
34
32
|
exports.generate = generate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAE9D,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAA8B,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"mongodb.tpl.js","sourceRoot":"","sources":["../../../src/connection/templates/mongodb.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAE9D,2CAA0D;AAE1D,MAAM,QAAQ,GAAG,CAAC,EAA8B,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;CAkB7D,CAAA;AAED,MAAM,cAAc,GAAG,qCAAqC,CAAA;AAC5D,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AAClD,MAAM,SAAS,GAAG,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAExE,MAAM,QAAQ,GAAG,CAAC,GAA+B,EAAE,EAAE,CAC1D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAA6B,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,CAAC,CAChE,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
|
|
@@ -2,8 +2,7 @@ import { generator, toFile, before } from '@feathershq/pinion'
|
|
|
2
2
|
import { ConnectionGeneratorContext } from '../index'
|
|
3
3
|
import { injectSource, renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const template = ({}: ConnectionGeneratorContext) =>
|
|
6
|
-
`import { MongoClient } from 'mongodb'
|
|
5
|
+
const template = ({}: ConnectionGeneratorContext) => /* ts */ `import { MongoClient } from 'mongodb'
|
|
7
6
|
import type { Db } from 'mongodb'
|
|
8
7
|
import type { Application } from './declarations'
|
|
9
8
|
|
|
@@ -23,8 +22,6 @@ export const mongodb = (app: Application) => {
|
|
|
23
22
|
}
|
|
24
23
|
`
|
|
25
24
|
|
|
26
|
-
const configurationTemplate = ({ database }: ConnectionGeneratorContext) =>
|
|
27
|
-
` ${database}: { type: 'string' },`
|
|
28
25
|
const importTemplate = "import { mongodb } from './mongodb'"
|
|
29
26
|
const configureTemplate = 'app.configure(mongodb)'
|
|
30
27
|
const toAppFile = toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'app'])
|
|
@@ -37,13 +34,5 @@ export const generate = (ctx: ConnectionGeneratorContext) =>
|
|
|
37
34
|
toFile<ConnectionGeneratorContext>(({ lib }) => lib, 'mongodb')
|
|
38
35
|
)
|
|
39
36
|
)
|
|
40
|
-
.then(
|
|
41
|
-
injectSource(
|
|
42
|
-
configurationTemplate,
|
|
43
|
-
before('authentication: authenticationSettingsSchema'),
|
|
44
|
-
toFile<ConnectionGeneratorContext>(({ lib }) => [lib, 'configuration']),
|
|
45
|
-
false
|
|
46
|
-
)
|
|
47
|
-
)
|
|
48
37
|
.then(injectSource(importTemplate, before('import { services } from'), toAppFile))
|
|
49
38
|
.then(injectSource(configureTemplate, before('app.configure(services)'), toAppFile))
|
package/lib/hook/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const generate: (ctx: HookGeneratorContext) => Promise<{
|
|
|
14
14
|
pkg: import("../commons").AppPackageJson;
|
|
15
15
|
lib: string;
|
|
16
16
|
test: string;
|
|
17
|
-
language: "
|
|
17
|
+
language: "ts" | "js";
|
|
18
18
|
dependencyVersions?: import("../commons").DependencyVersions;
|
|
19
19
|
cwd: string;
|
|
20
20
|
_?: (string | number)[];
|
package/lib/hook/index.js
CHANGED
|
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generate = void 0;
|
|
7
7
|
const pinion_1 = require("@feathershq/pinion");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const commons_1 = require("../commons");
|
|
9
10
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
11
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
12
|
+
.then((0, commons_1.checkPreconditions)())
|
|
10
13
|
.then((0, pinion_1.prompt)(({ type, name }) => [
|
|
11
14
|
{
|
|
12
15
|
type: 'input',
|
package/lib/hook/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hook/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAqE;AACrE,oDAAsB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot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} from '@feathershq/pinion'
|
|
2
2
|
import _ from 'lodash'
|
|
3
|
-
import { FeathersBaseContext } from '../commons'
|
|
3
|
+
import { checkPreconditions, FeathersBaseContext, initializeBaseContext } from '../commons'
|
|
4
4
|
|
|
5
5
|
export interface HookGeneratorContext extends FeathersBaseContext {
|
|
6
6
|
name: string
|
|
@@ -11,6 +11,8 @@ export interface HookGeneratorContext extends FeathersBaseContext {
|
|
|
11
11
|
|
|
12
12
|
export const generate = (ctx: HookGeneratorContext) =>
|
|
13
13
|
generator(ctx)
|
|
14
|
+
.then(initializeBaseContext())
|
|
15
|
+
.then(checkPreconditions())
|
|
14
16
|
.then(
|
|
15
17
|
prompt<HookGeneratorContext>(({ type, name }) => [
|
|
16
18
|
{
|
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const aroundTemplate = ({ camelName, name }) => `
|
|
7
|
-
import type { HookContext, NextFunction } from '../declarations'
|
|
6
|
+
const aroundTemplate = ({ camelName, name }) => /* ts */ `import type { HookContext, NextFunction } from '../declarations'
|
|
8
7
|
|
|
9
8
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
10
9
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
11
10
|
await next()
|
|
12
11
|
}
|
|
13
12
|
`;
|
|
14
|
-
const regularTemplate = ({ camelName, name }) => `import type { HookContext } from '../declarations'
|
|
13
|
+
const regularTemplate = ({ camelName, name }) => /* ts */ `import type { HookContext } from '../declarations'
|
|
15
14
|
|
|
16
15
|
export const ${camelName} = async (context: HookContext) => {
|
|
17
16
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"hook.tpl.js","sourceRoot":"","sources":["../../../src/hook/templates/hook.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AAEtD,2CAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,EACtB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;eAEtB,SAAS;+BACO,IAAI;;;CAGlC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,SAAS,EACT,IAAI,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;eAEtB,SAAS;+BACO,IAAI;EACjC,CAAA;AAEK,MAAM,QAAQ,GAAG,CAAC,GAAyB,EAAE,EAAE,CACpD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,EAC7E,IAAA,eAAM,EAAuB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAChF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -2,8 +2,10 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { HookGeneratorContext } from '../index'
|
|
3
3
|
import { renderSource } from '../../commons'
|
|
4
4
|
|
|
5
|
-
const aroundTemplate = ({
|
|
6
|
-
|
|
5
|
+
const aroundTemplate = ({
|
|
6
|
+
camelName,
|
|
7
|
+
name
|
|
8
|
+
}: HookGeneratorContext) => /* ts */ `import type { HookContext, NextFunction } from '../declarations'
|
|
7
9
|
|
|
8
10
|
export const ${camelName} = async (context: HookContext, next: NextFunction) => {
|
|
9
11
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
|
@@ -14,7 +16,7 @@ export const ${camelName} = async (context: HookContext, next: NextFunction) =>
|
|
|
14
16
|
const regularTemplate = ({
|
|
15
17
|
camelName,
|
|
16
18
|
name
|
|
17
|
-
}: HookGeneratorContext) => `import type { HookContext } from '../declarations'
|
|
19
|
+
}: HookGeneratorContext) => /* ts */ `import type { HookContext } from '../declarations'
|
|
18
20
|
|
|
19
21
|
export const ${camelName} = async (context: HookContext) => {
|
|
20
22
|
console.log(\`Running hook ${name} on \${context.path}\.\${context.method}\`)
|
package/lib/index.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { FeathersBaseContext } from './commons';
|
|
4
|
-
export declare const commandRunner: (yarg: any) => Promise<FeathersBaseContext & {
|
|
5
|
-
lib: string;
|
|
6
|
-
test: string;
|
|
7
|
-
language: "js" | "ts";
|
|
8
|
-
feathers: import("./commons").FeathersAppInfo;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const generate: (ctx: FeathersBaseContext) => Promise<FeathersBaseContext & {
|
|
11
|
-
lib: string;
|
|
12
|
-
test: string;
|
|
13
|
-
language: "js" | "ts";
|
|
14
|
-
feathers: import("./commons").FeathersAppInfo;
|
|
15
|
-
}>;
|
|
16
|
-
export declare const command: (yargs: Argv) => Argv<{}>;
|
|
1
|
+
export * from './cli';
|
|
2
|
+
export * from './commons';
|
package/lib/index.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
|
-
exports
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.then((0, pinion_1.runGenerator)(__dirname, (ctx) => `${ctx._[1]}`, 'index'));
|
|
16
|
-
exports.generate = generate;
|
|
17
|
-
const command = (yargs) => yargs
|
|
18
|
-
.command('generate', 'Run a generator', (yarg) => yarg
|
|
19
|
-
.command('app', 'Generate a new app', exports.commandRunner)
|
|
20
|
-
.command('service', 'Generate a service', exports.commandRunner)
|
|
21
|
-
.command('hook', 'Generate a hook', exports.commandRunner)
|
|
22
|
-
.command('connection', 'Connect to a different database', exports.commandRunner)
|
|
23
|
-
.command('authentication', 'Set up authentication with a custom entity', exports.commandRunner))
|
|
24
|
-
.usage('Usage: $0 <command> [options]')
|
|
25
|
-
.help();
|
|
26
|
-
exports.command = command;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cli"), exports);
|
|
18
|
+
__exportStar(require("./commons"), exports);
|
|
27
19
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,4CAAyB"}
|
package/lib/index.ts
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const commandRunner = (yarg: any) => {
|
|
5
|
-
const ctx = getContext<FeathersBaseContext>({
|
|
6
|
-
...yarg.argv
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
return generate(ctx)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const generate = (ctx: FeathersBaseContext) =>
|
|
13
|
-
generator(ctx)
|
|
14
|
-
.then(initializeBaseContext())
|
|
15
|
-
.then(runGenerator(__dirname, (ctx: FeathersBaseContext) => `${ctx._[1]}`, 'index'))
|
|
16
|
-
|
|
17
|
-
export const command = (yargs: Argv) =>
|
|
18
|
-
yargs
|
|
19
|
-
.command('generate', 'Run a generator', (yarg) =>
|
|
20
|
-
yarg
|
|
21
|
-
.command('app', 'Generate a new app', commandRunner)
|
|
22
|
-
.command('service', 'Generate a service', commandRunner)
|
|
23
|
-
.command('hook', 'Generate a hook', commandRunner)
|
|
24
|
-
.command('connection', 'Connect to a different database', commandRunner)
|
|
25
|
-
.command('authentication', 'Set up authentication with a custom entity', commandRunner)
|
|
26
|
-
)
|
|
27
|
-
.usage('Usage: $0 <command> [options]')
|
|
28
|
-
.help()
|
|
1
|
+
export * from './cli'
|
|
2
|
+
export * from './commons'
|
package/lib/service/index.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
40
40
|
* The chosen service type
|
|
41
41
|
*/
|
|
42
42
|
type: 'knex' | 'mongodb' | 'custom';
|
|
43
|
+
/**
|
|
44
|
+
* Which schema definition format to use
|
|
45
|
+
*/
|
|
46
|
+
schema: 'typebox' | 'json' | false;
|
|
43
47
|
/**
|
|
44
48
|
* Wether this service uses authentication
|
|
45
49
|
*/
|
|
@@ -52,7 +56,7 @@ export interface ServiceGeneratorContext extends FeathersBaseContext {
|
|
|
52
56
|
/**
|
|
53
57
|
* Parameters the generator is called with
|
|
54
58
|
*/
|
|
55
|
-
export declare type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService'>>;
|
|
59
|
+
export declare type ServiceGeneratorArguments = FeathersBaseContext & Partial<Pick<ServiceGeneratorContext, 'name' | 'path' | 'type' | 'authentication' | 'isEntityService' | 'schema'>>;
|
|
56
60
|
export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
57
61
|
/**
|
|
58
62
|
* The chosen service name
|
|
@@ -94,6 +98,10 @@ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
|
94
98
|
* The chosen service type
|
|
95
99
|
*/
|
|
96
100
|
type: 'knex' | 'mongodb' | 'custom';
|
|
101
|
+
/**
|
|
102
|
+
* Which schema definition format to use
|
|
103
|
+
*/
|
|
104
|
+
schema: 'typebox' | 'json' | false;
|
|
97
105
|
/**
|
|
98
106
|
* Wether this service uses authentication
|
|
99
107
|
*/
|
|
@@ -106,7 +114,7 @@ export declare const generate: (ctx: ServiceGeneratorArguments) => Promise<{
|
|
|
106
114
|
pkg: import("../commons").AppPackageJson;
|
|
107
115
|
lib: string;
|
|
108
116
|
test: string;
|
|
109
|
-
language: "
|
|
117
|
+
language: "ts" | "js";
|
|
110
118
|
dependencyVersions?: import("../commons").DependencyVersions;
|
|
111
119
|
cwd: string;
|
|
112
120
|
_?: (string | number)[];
|
package/lib/service/index.js
CHANGED
|
@@ -8,48 +8,86 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const pinion_1 = require("@feathershq/pinion");
|
|
9
9
|
const commons_1 = require("../commons");
|
|
10
10
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
11
|
-
.then((0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name: 'authentication',
|
|
27
|
-
type: 'confirm',
|
|
28
|
-
when: authentication === undefined && !isEntityService,
|
|
29
|
-
message: 'Does this service require authentication?'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'type',
|
|
33
|
-
type: 'list',
|
|
34
|
-
when: !type,
|
|
35
|
-
message: 'What kind of service is it?',
|
|
36
|
-
default: (0, commons_1.getDatabaseAdapter)(ctx.feathers.database),
|
|
37
|
-
choices: [
|
|
38
|
-
{
|
|
39
|
-
value: 'knex',
|
|
40
|
-
name: 'SQL'
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
value: 'mongodb',
|
|
44
|
-
name: 'MongoDB'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
value: 'custom',
|
|
48
|
-
name: 'A custom service'
|
|
11
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
12
|
+
.then((0, commons_1.checkPreconditions)())
|
|
13
|
+
.then((0, pinion_1.prompt)(({ name, path, type, schema, authentication, isEntityService }) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'name',
|
|
18
|
+
type: 'input',
|
|
19
|
+
when: !name,
|
|
20
|
+
message: 'What is the name of your service?',
|
|
21
|
+
validate: (input) => {
|
|
22
|
+
if (!input || input === 'authentication') {
|
|
23
|
+
return 'Invalid service name';
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
49
26
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'path',
|
|
30
|
+
type: 'input',
|
|
31
|
+
when: !path,
|
|
32
|
+
message: 'Which path should the service be registered on?',
|
|
33
|
+
default: (answers) => `${lodash_1.default.kebabCase(answers.name)}`,
|
|
34
|
+
validate: (input) => {
|
|
35
|
+
if (!input || input === 'authentication') {
|
|
36
|
+
return 'Invalid service path';
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'authentication',
|
|
43
|
+
type: 'confirm',
|
|
44
|
+
when: authentication === undefined && !isEntityService,
|
|
45
|
+
message: 'Does this service require authentication?'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'type',
|
|
49
|
+
type: 'list',
|
|
50
|
+
when: !type,
|
|
51
|
+
message: 'What kind of service is it?',
|
|
52
|
+
default: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database),
|
|
53
|
+
choices: [
|
|
54
|
+
{
|
|
55
|
+
value: 'knex',
|
|
56
|
+
name: 'SQL'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: 'mongodb',
|
|
60
|
+
name: 'MongoDB'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: 'custom',
|
|
64
|
+
name: 'A custom service'
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'schema',
|
|
70
|
+
type: 'list',
|
|
71
|
+
when: schema === undefined,
|
|
72
|
+
message: 'Which schema definition format do you want to use?',
|
|
73
|
+
default: ((_b = ctx.feathers) === null || _b === void 0 ? void 0 : _b.schema) || 'json',
|
|
74
|
+
choices: [
|
|
75
|
+
{
|
|
76
|
+
value: 'typebox',
|
|
77
|
+
name: 'TypeBox'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: 'json',
|
|
81
|
+
name: 'JSON schema'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: false,
|
|
85
|
+
name: 'No schema'
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
}))
|
|
53
91
|
.then(async (ctx) => {
|
|
54
92
|
const { name, path, type } = ctx;
|
|
55
93
|
const kebabName = lodash_1.default.kebabCase(name);
|
package/lib/service/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,+CAAmF;AAEnF,wCAKmB;AAiEZ,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAE,EAAE,CACzD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,+BAAqB,GAAE,CAAC;KAC7B,IAAI,CAAC,IAAA,4BAAkB,GAAE,CAAC;KAC1B,IAAI,CACH,IAAA,eAAM,EACJ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;;IAAC,OAAA;QACjE;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,CAAC,IAAI;YACX,OAAO,EAAE,mCAAmC;YAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAClB,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,gBAAgB,EAAE;oBACxC,OAAO,sBAAsB,CAAA;iBAC9B;gBAED,OAAO,IAAI,CAAA;YACb,CAAC;SACF;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,CAAC,IAAI;YACX,OAAO,EAAE,iDAAiD;YAC1D,OAAO,EAAE,CAAC,OAAkC,EAAE,EAAE,CAAC,GAAG,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC/E,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAClB,IAAI,CAAC,KAAK,IAAI,KAAK,K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