Skip to content

Commit

Permalink
feat: empty project template (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 committed Jan 15, 2024
2 parents bb478e9 + 9ba3fb8 commit 2ef8589
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion jest.config.ts
Expand Up @@ -4,7 +4,7 @@ const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node',
coveragePathIgnorePatterns: ["<rootDir>/__tests__/",],
testPathIgnorePatterns: ['/__hl7__/', '/__utils__/'],
testPathIgnorePatterns: ['/__utils__/'],
resolver: 'jest-ts-webcompat-resolver',
}

Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -71,10 +71,10 @@
"@types/lodash": "^4.14.202",
"@types/node": "^20.10.6",
"@types/yargs": "^17.0.32",
"npm-package-json-lint": "^7.1.0",
"precommit": "^1.2.2",
"jest": "^29.7.0",
"jest-ts-webcompat-resolver": "^1.0.0",
"npm-package-json-lint": "^7.1.0",
"precommit": "^1.2.2",
"semantic-release": "^22.0.12",
"snazzy": "^9.0.0",
"ts-jest": "^29.1.1",
Expand All @@ -86,8 +86,10 @@
},
"dependencies": {
"cli-progress": "^3.12.0",
"execa": "^8.0.1",
"inquirer": "^9.2.12",
"inquirer-npm-name": "^4.0.0",
"listr2": "^8.0.1",
"lodash": "^4.17.21",
"pino": "^8.17.2",
"pino-pretty": "^10.3.1",
Expand Down
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
2 changes: 1 addition & 1 deletion template/__shared__fastify__/Dockerfile
@@ -1,4 +1,4 @@
FROM node:20.5.0-alpine3.18
FROM node:20.10.0-alpine3.19

# set working directory in the image
WORKDIR /home/node/app
Expand Down

0 comments on commit 2ef8589

Please sign in to comment.