Skip to content

Commit

Permalink
feat: windows commands for copy (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 committed Jan 9, 2024
2 parents 9e28856 + 5316e97 commit fb49d48
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Expand Up @@ -28,7 +28,7 @@ export const main = async (): Promise<void> => {
// set var
const npmName = !isProd() ? undefined : await getProjectName(_.kebabCase(defaultProjectName))

const { npm, gitLocation, repoOwner, repoName, website, type, node, vite, email, description, license, keywords, port } = await inquirer.prompt([{
const { npm, gitLocation, repoOwner, repoName, repoPrivateLocation, website, type, node, vite, email, description, license, keywords, port } = await inquirer.prompt([{
default: defaultProjectName,
name: 'npm',
message: 'Your Project NPM name?',
Expand Down Expand Up @@ -182,7 +182,7 @@ export const main = async (): Promise<void> => {
description,
gitIssues,
gitReadme,
gitUrl,
gitUrl: typeof repoPrivateLocation !== 'undefined' ? repoPrivateLocation : gitUrl,
license,
keywords
}, {
Expand Down
8 changes: 5 additions & 3 deletions src/modules/helpers.ts
Expand Up @@ -65,7 +65,7 @@ export const copyTemplateFile = async (
let contents = fs.readFileSync(`${resolvedSource}/${file}`, { encoding: 'utf8' })

// Figure out where we're writing this file.
let baseFile = file.replace(`${resolvedSource}/`, '')
let baseFile = file.replace(`${resolvedSource}`, '')

// make sure we remove ts-nocheck from files
if ((baseFile.substring(baseFile.length - 2, baseFile.length) === 'ts') || baseFile.substring(baseFile.length - 3, baseFile.length) === 'tsx') {
Expand Down Expand Up @@ -126,7 +126,7 @@ export const copyTemplateFiles = async (
let contents = fs.readFileSync(file, { encoding: 'utf8' })

// Figure out where we're writing this file.
let baseFile = file.replace(`${resolvedSource}/`, '')
let baseFile = file.replace(`${resolvedSource}`, '')

// make sure we remove ts-nocheck from files
if ((baseFile.substring(baseFile.length - 2, baseFile.length) === 'ts') || baseFile.substring(baseFile.length - 3, baseFile.length) === 'tsx') {
Expand Down Expand Up @@ -244,6 +244,8 @@ export const getProjectName = async (defaultProjectName: string): Promise<string
*/
export const installDeps = async (dependencies: string[], options: { dev?: boolean } = {}): Promise<void> => {
const args: string[] = ['install']
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';

if (options.dev === true) {
args.push('--save-dev')
}
Expand All @@ -257,7 +259,7 @@ export const installDeps = async (dependencies: string[], options: { dev?: boole
for (const depend of dependencies) {
value++
if (isProd()) {
await execFile('npm', [...args, depend])
await execFile(npmCmd, [...args, depend])
}
bar.update(value)
if (value >= bar.getTotal()) {
Expand Down
34 changes: 17 additions & 17 deletions template/fastify-graphql-controller/src/plugins/graphql.ts
Expand Up @@ -7,23 +7,23 @@ export default fp<MercuriusGatewayOptions>(async (fastify) => {
const GRAPHQL_HOST = accessEnv('GRAPHQL_HOST', 'localhost')
const GRAPHQL_PORT = parseInt(accessEnv('GRAPHQL_PORT', '3000'))

await fastify.register(mercuriusGateway, {
gateway: {
services: [{
name: '<%- npm %>',
collectors: {
collectHeaders: true
},
rewriteHeaders: (headers) => {
return headers
},
url: `http://${GRAPHQL_HOST}:${GRAPHQL_PORT}/graphql`,
keepAlive: 10
}]
},
graphiql: process.env.NODE_ENV !== 'production',
jit: 1
})
// await fastify.register(mercuriusGateway, {
// gateway: {
// services: [{
// name: '<%- npm %>',
// collectors: {
// collectHeaders: true
// },
// rewriteHeaders: (headers) => {
// return headers
// },
// url: `http://${GRAPHQL_HOST}:${GRAPHQL_PORT}/graphql`,
// keepAlive: 10
// }]
// },
// graphiql: process.env.NODE_ENV !== 'production',
// jit: 1
// })

void fastify.ready().then(() => {
fastify.log.debug('[<%- npm %>-graphql] Started GraphQL Gateway')
Expand Down
2 changes: 1 addition & 1 deletion template/fastify-graphql-controller/src/plugins/health.ts
Expand Up @@ -6,6 +6,6 @@ export default fp<CustomHealthCheckOptions>(async (fastify) => {
void fastify.register(customHealthCheck)

void fastify.ready().then(() => {
fastify.log.debug('[<%- npm %>--health] Started Health')
fastify.log.debug('[<%- npm %>-health] Started Health')
})
})
10 changes: 5 additions & 5 deletions template/fastify-graphql-microservice/src/plugins/database.ts
Expand Up @@ -5,11 +5,11 @@ import fastifyMongodb from '@fastify/mongodb'
import { accessEnv } from '../helpers/accessEnv.js'

export default fp<FastifyPluginOptions>(async (fastify, opts) => {
void fastify.register(fastifyMongodb, {
forceClose: process.env.NODE_ENV !== 'production',
url: accessEnv('MONGODB_URI', 'mongodb://localhost:27017/'),
database: accessEnv('MONGODB_DATABASE', '')
})
// void fastify.register(fastifyMongodb, {
// forceClose: process.env.NODE_ENV !== 'production',
// url: accessEnv('MONGODB_URI', 'mongodb://localhost:27017/'),
// database: accessEnv('MONGODB_DATABASE', '')
// })

void fastify.ready().then(() => {
fastify.log.debug('[<%- npm %>-database] Started Database: Starting Remote Connection')
Expand Down
12 changes: 6 additions & 6 deletions template/fastify-graphql-microservice/src/plugins/graphql.ts
Expand Up @@ -6,12 +6,12 @@ import { resolvers } from '../graphql/reporters.js'
import schema from '../graphql/schema.js'

export default fp<FastifyPluginOptions>(async (fastify, opts) => {
void fastify.register(mercuriusFederationPlugin, {
schema,
resolvers,
graphiql: process.env.NODE_ENV !== 'production',
jit: 1
})
// void fastify.register(mercuriusFederationPlugin, {
// schema,
// resolvers,
// graphiql: process.env.NODE_ENV !== 'production',
// jit: 1
// })

void fastify.ready().then(() => {
fastify.log.debug('[<%- npm %>-graphql] Started GraphQL')
Expand Down
Expand Up @@ -6,6 +6,6 @@ export default fp<CustomHealthCheckOptions>(async (fastify) => {
void fastify.register(customHealthCheck)

void fastify.ready().then(() => {
fastify.log.debug('[<%- npm %>--health] Started Health')
fastify.log.debug('[<%- npm %>-health] Started Health')
})
})
10 changes: 5 additions & 5 deletions template/fastify-graphql-microservice/src/plugins/rabbitmq.ts
Expand Up @@ -5,11 +5,11 @@ import fastifyRabbit from 'fastify-rabbitmq'
import { accessEnv } from '../helpers/accessEnv.js'

export default fp<FastifyPluginOptions>(async (fastify, opt) => {
const RABBIT_MQ = accessEnv('RABBIT_MQ', 'localhost')

void fastify.register(fastifyRabbit, {
connection: `amqp://guest:guest@${RABBIT_MQ}`
})
// const RABBIT_MQ = accessEnv('RABBIT_MQ', 'localhost')
//
// void fastify.register(fastifyRabbit, {
// connection: `amqp://guest:guest@${RABBIT_MQ}`
// })

void fastify.ready().then(async () => {
fastify.log.debug('[<%- npm %>-rabbitmq] Started RabbitMQ')
Expand Down

0 comments on commit fb49d48

Please sign in to comment.