Skip to content

Commit

Permalink
feat: empty project template
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 committed Jan 15, 2024
1 parent 891d4ae commit 9ba3fb8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -81,12 +81,13 @@ export const main = async (): Promise<void> => {
filter (val: string) { return val.toLowerCase() }
}, {
choices: [
{ name: 'Empty Project', value: 'empty-project' },
{ name: 'Fastify GraphQL Controller', value: 'fastify-graphql-controller' },
{ name: 'Fastify GraphQL Microservice', value: 'fastify-graphql-microservice' },
{ name: 'Fastify Standalone NPM Package', value: 'fastify-npm-package' },
{ name: 'Standalone NPM Package', value: 'npm-package' }
],
default: 1,
default: 0,
name: 'node',
message: 'What type of app are we creating today?',
type: 'list',
Expand Down
20 changes: 20 additions & 0 deletions src/modules/constants.ts
Expand Up @@ -15,6 +15,26 @@ export const CLI_PROGRESS = (area: string): any => {
}
}

export const EMPTY_PROJECT: Dependencies = {
dependencies: [],
devDependencies: [
'@types/node',
'@types/jest',
'npm-check-updates',
'npm-package-json-lint',
'pre-commit',
'jest',
'jest-ts-webcompat-resolver',
'snazzy',
'ts-node',
'ts-jest',
'ts-standard',
'tsd',
'typedoc',
'typescript'
]
}

export const sharedDev: string[] = [
'@semantic-release/changelog',
'@semantic-release/commit-analyzer',
Expand Down
3 changes: 3 additions & 0 deletions src/modules/dependencies.ts
@@ -1,4 +1,5 @@
import {
EMPTY_PROJECT,
FASTIFY_GRAPHQL_CONTROLLER,
FASTIFY_GRAPHQL_MICROSERVICES,
FASTIFY_NPM_PACKAGE,
Expand All @@ -15,6 +16,8 @@ export const returnDependencies = (input: GenerateInput): Dependencies => {
switch (input.type) {
case 'nodejs': {
switch (input.node) {
case 'empty-project':
return EMPTY_PROJECT
case 'fastify-graphql-controller':
return FASTIFY_GRAPHQL_CONTROLLER
case 'fastify-graphql-microservice':
Expand Down
2 changes: 1 addition & 1 deletion src/modules/helpers.ts
Expand Up @@ -244,7 +244,7 @@ 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';
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm'

if (options.dev === true) {
args.push('--save-dev')
Expand Down
19 changes: 12 additions & 7 deletions src/modules/template.ts
Expand Up @@ -23,17 +23,22 @@ export const generateTemplate = async (input: GenerateInput, replacement?: any):
]

// shared among all projects
await copyTemplateFiles(
path.join(dirName, '..', '..', 'template', '__shared__'),
process.cwd(),
{
replace: createReplace
}
)
if (input.node !== 'empty-project') {
await copyTemplateFiles(
path.join(dirName, '..', '..', 'template', '__shared__'),
process.cwd(),
{
replace: createReplace
}
)
}

switch (input.type) {
case 'nodejs': {
switch (input.node) {
case 'empty-project': {
return
}
case 'fastify-graphql-controller': {
// shared among all projects
await copyTemplateFiles(
Expand Down

0 comments on commit 9ba3fb8

Please sign in to comment.