Skip to content

Commit

Permalink
Merge pull request #98 from osstotalsoft/bugfix/MissingImports
Browse files Browse the repository at this point in the history
Bugfix/missing imports
  • Loading branch information
DCosti committed Oct 18, 2022
2 parents 54a64a4 + 1915dfc commit 70d4640
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 31 deletions.
55 changes: 33 additions & 22 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = class extends Generator {
constructor(args, opts) {
super(args, { ...opts, skipRegenerate: true, ignoreWhitespace: true, force: true, skipLocalCache: false })
this.registerClientTransforms()
this.ignoreFiles = []
}

async prompting() {
Expand Down Expand Up @@ -65,11 +66,11 @@ module.exports = class extends Generator {
const templatePath = this.templatePath('infrastructure/**/*')
const destinationPath = this.destinationPath()

let ignoreFiles = ['**/.npmignore', '**/.gitignore-template', '**/helm/**']
this.ignoreFiles = ['**/.npmignore', '**/.gitignore-template', '**/helm/gql/**']

if (dataLayer === 'knex') ignoreFiles = concat(['**/prisma/**'], ignoreFiles)
if (dataLayer === 'knex') this.ignoreFiles = concat(['**/prisma/**'], this.ignoreFiles)
if (dataLayer === 'prisma')
ignoreFiles = concat(
this.ignoreFiles = concat(
[
'**/src/db/**',
'**/middleware/db/**',
Expand All @@ -81,21 +82,15 @@ module.exports = class extends Generator {
'**/tracing/knexTracer.js',
'**/utils/sqlDataSource.js'
],
ignoreFiles
this.ignoreFiles
)
if (dataLayer === 'knex' && withMultiTenancy)
ignoreFiles = concat(
[
'**/db/dbInstanceFactory.js',
'**/startup/middleware'
],
ignoreFiles
)
if (!addSubscriptions) ignoreFiles = concat(['**/pubSub/**', '**/subscriptions/**'], ignoreFiles)
if (!addMessaging) ignoreFiles = append('**/messaging/**', ignoreFiles)
this.ignoreFiles = concat(['**/db/dbInstanceFactory.js', '**/startup/middleware'], this.ignoreFiles)
if (!addSubscriptions) this.ignoreFiles = concat(['**/pubSub/**', '**/subscriptions/**'], this.ignoreFiles)
if (!addMessaging) this.ignoreFiles = append('**/messaging/**', this.ignoreFiles)

if (!withMultiTenancy)
ignoreFiles = concat(
this.ignoreFiles = concat(
[
'**/features/tenant/**',
'**/multiTenancy/**',
Expand All @@ -104,19 +99,28 @@ module.exports = class extends Generator {
'**/prisma/tenancyFilter.js',
'**/pubSub/middleware/tenantPublish.js'
],
ignoreFiles
this.ignoreFiles
)
if (!hasSharedDb)
ignoreFiles = concat(['**/db/multiTenancy/tenancyFilter.js', '**/prisma/tenancyFilter.js'], ignoreFiles)
if (!addTracing) ignoreFiles = concat(['**/tracing/**', '**/startup/middleware/tracing.js', '**/pubSub/middlware/tracingPublish.js', '**/__mocks__/opentracing.js'], ignoreFiles)
this.ignoreFiles = concat(['**/db/multiTenancy/tenancyFilter.js', '**/prisma/tenancyFilter.js'], this.ignoreFiles)
if (!addTracing)
this.ignoreFiles = concat(
[
'**/tracing/**',
'**/startup/middleware/tracing.js',
'**/pubSub/middlware/tracingPublish.js',
'**/__mocks__/opentracing.js'
],
this.ignoreFiles
)
if (!withRights)
ignoreFiles = concat(
this.ignoreFiles = concat(
['**/middleware/permissions/**', '**/constants/permissions.js', '**/constants/identityUserRoles.js'],
ignoreFiles
this.ignoreFiles
)

if (!addQuickStart)
ignoreFiles = concat(
this.ignoreFiles = concat(
[
'**/features/common/dbGenerators.js',
'**/features/tenant/**',
Expand All @@ -125,9 +129,11 @@ module.exports = class extends Generator {
'**/middleware/permissions/__tests__/**',
'**/README.md'
],
ignoreFiles
this.ignoreFiles
)

if (!addHelm) this.ignoreFiles = concat(['**/helm/**'], this.ignoreFiles)

const packageManagerVersion =
packageManager === 'npm' ? NPM_MIN_VERSION : packageManager === 'yarn' ? YARN_MIN_VERSION : NPM_MIN_VERSION
const packageManagerLockFile = packageManager === 'yarn' ? 'yarn.lock' : 'package-lock.json'
Expand All @@ -137,7 +143,7 @@ module.exports = class extends Generator {
destinationPath,
{ ...this.answers, packageManagerVersion, packageManagerLockFile },
{},
{ globOptions: { ignore: ignoreFiles, dot: true } }
{ globOptions: { ignore: this.ignoreFiles, dot: true } }
)

const gitignorePath = this.templatePath('infrastructure/.gitignore-template')
Expand All @@ -157,6 +163,11 @@ module.exports = class extends Generator {
}
}

conflicts() {
if (!this.isLatest) return
this.ignoreFiles.map(f => this.deleteDestination(f, { globOptions: { onlyFiles: false, dot: true, silent: true } }))
}

install() {
if (!this.isLatest) return

Expand Down
5 changes: 2 additions & 3 deletions generators/app/templates/infrastructure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@graphql-tools/schema": "^8.5.0",
"@koa/cors": "^3.3.0",
"@koa/router": "^11.0.1",
"koa-ignore": "^1.0.1",
<%_ if(dataLayer === "prisma") {_%>
"@prisma/client": "^4.1.1",
"prisma": "^4.1.1",
Expand All @@ -53,7 +54,6 @@
"@totalsoft/pino-mssqlserver": "^1.1.0",
<%_ if(withMultiTenancy) {_%>
"object-path": "^0.11.8",
"koa-ignore": "^1.0.1",
<%_ if(addQuickStart) {_%>
"datasource-sql": "^2.0.1",
<%_}_%>
Expand All @@ -76,6 +76,7 @@
"apollo-datasource": "^3.3.2",
"apollo-datasource-rest": "^3.6.1",
"apollo-server": "^3.10.0",
"apollo-server-core": "^3.10.0",
"apollo-server-koa": "^3.10.0",
"async-mutex": "^0.3.2",
"bluebird": "3.7.2",
Expand All @@ -84,7 +85,6 @@
"dotenv": "16.0.1",
"graphql": "15.8.0",
<%_ if(addSubscriptions){ _%>
"apollo-server-core": "^3.10.0",
"graphql-redis-subscriptions": "^2.5.0",
"graphql-subscriptions": "^2.0.0",
"graphql-ws": "^5.9.1",
Expand All @@ -109,7 +109,6 @@
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-jwt": "^4.0.3",
"lodash.merge": "^4.6.2",
"mime-types": "^2.1.35",
"numeral": "^2.0.6",
"path": "^0.12.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const generateKnexConfig = ({
})

const getDbConfig = <% if(withMultiTenancy){ %>async ( tenantId )<%} else { %>()<%}%> => {
<%_ if(withMultiTenancy){ _%>
let connectionInfo
<%_ if(withMultiTenancy){ _%>

if (isMultiTenant) {
connectionInfo = await tenantConfiguration.getConnectionInfo(tenantId, '<%= dbConnectionName %>')
Expand Down
11 changes: 7 additions & 4 deletions generators/app/templates/infrastructure/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ const
metrics = require("./monitoring/metrics"),
metricsPlugin = require("./plugins/metrics/metricsPlugin")


const { publicRoute } = require('./utils/functions'),
ignore = require('koa-ignore')
<%_ if(withMultiTenancy){ _%>
// MultiTenancy
const { publicRoute } = require('./utils/functions'),
ignore = require('koa-ignore'),
{ tenantService<% if(dataLayer == "knex") {%>, tenantContextAccessor<%}%> } = require("@totalsoft/multitenancy-core"),
,{ tenantService<% if(dataLayer == "knex") {%>, tenantContextAccessor<%}%> } = require("@totalsoft/multitenancy-core"),
isMultiTenant = JSON.parse(process.env.IS_MULTITENANT || 'false')
<%_}_%>

Expand Down Expand Up @@ -291,9 +290,13 @@ msgHost

async function cleanup() {
await configMonitor?.close();
<%_ if(addMessaging) {_%>
await msgHost?.stop();
<%_}_%>
await apolloServer?.stop();
<%_ if(addTracing) {_%>
defaultTracer?.close();
<%_}_%>
}

const { gracefulShutdown } = require('@totalsoft/graceful-shutdown');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { dbInstanceFactory } = require('../../db')
<%_ if(withMultiTenancy){ _%>
const { tenantContextAccessor } = require('@totalsoft/multitenancy-core')
<%_}_%>

const contextDbInstance = () => async (ctx, next) => {
<%_ if(withMultiTenancy){ _%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { makeExecutableSchema } = require('@graphql-tools/schema')
const merge = require('lodash.merge');

const { loadTypedefsSync } = require('@graphql-tools/load'),
{ loadFilesSync } = require('@graphql-tools/load-files'),
Expand Down

0 comments on commit 70d4640

Please sign in to comment.