Skip to content

Commit

Permalink
feat: git working now
Browse files Browse the repository at this point in the history
* removed clean-publish #18
* linted all files
* git now does my git scheme and commits, clears, etc. correctly.
* more refactoring as well

Closes #18, #17
  • Loading branch information
Bugs5382 committed Dec 31, 2023
1 parent 6c10ef9 commit 70d1e9c
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 168 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/template/**/**
6 changes: 3 additions & 3 deletions release.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
"extends": "@the-rabbit-hole/semantic-release-config",
"branches": [
"main"
extends: '@the-rabbit-hole/semantic-release-config',
branches: [
'main'
]
}
16 changes: 9 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import path from 'node:path'
import { DEFAULT_NPM, isProd } from './modules/constants.js'
import { returnDependencies } from './modules/dependencies.js'
import * as git from './modules/git.js'
import { getProjectName, parseOptions } from './modules/helpers.js'
import { getProjectName, installDeps, parseOptions } from './modules/helpers.js'
import { generateLicense, licenseChoices } from './modules/license.js'
import { generatePackageJson, installDeps } from './modules/npm.js'
import { generatePackageJson } from './modules/npm.js'
import { generateTemplate } from './modules/template.js'

/**
Expand Down Expand Up @@ -138,17 +138,16 @@ export const main = async (): Promise<void> => {
type: 'list'
}]) as Partial<any>

const temp: string = process.env.NODE_ENV === 'test' ? 'temp/' : ''

// create folder
const temp: string = !isProd() ? 'temp/' : ''

// Create folder
const folder: string = typeof npmName !== 'undefined' ? npmName : npm
const cwd = path.join(process.cwd(), `${temp}/${folder}`)
fs.mkdirSync(cwd, { recursive: true })
process.chdir(cwd)

// git stuff
await git.init(cwd)
// GIT: Initial
await git.init(cwd, 'initial')
if (gitLocation === 'github' && typeof repoOwner !== 'undefined' && typeof repoName !== 'undefined') {
await git.addRemote(cwd, repoOwner, repoName)
}
Expand Down Expand Up @@ -208,6 +207,9 @@ export const main = async (): Promise<void> => {
vite
})

// GIT: Post Step
await git.init(cwd, 'post')

// Install Dependencies
await installDeps(packages.dependencies)
await installDeps(packages.devDependencies, { dev: true })
Expand Down
109 changes: 109 additions & 0 deletions src/modules/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Dependencies } from './types'

export const DEFAULT_NPM = {
author: {
name: 'Shane Froebel'
Expand All @@ -13,4 +15,111 @@ export const CLI_PROGRESS = (area: string): any => {
}
}

export const sharedDev: string[] = [
'@semantic-release/changelog',
'@semantic-release/commit-analyzer',
'@semantic-release/git',
'@semantic-release/release-notes-generator',
'@the-rabbit-hole/semantic-release-config',
'@types/node',
'npm-check-updates',
'npm-package-json-lint',
'pre-commit',
'semantic-release',
'snazzy',
'ts-node',
'ts-standard',
'tsd',
'typedoc',
'typescript'
]

export const FASTIFY_GRAPHQL_CONTROLLER: Dependencies = {
dependencies: [
'@fastify/autoload',
'@fastify/cors',
'@mercuriusjs/gateway',
'fastify',
'fastify-cli',
'fastify-custom-healthcheck',
'fastify-plugin'
],
devDependencies: [
...sharedDev
]
}

export const FASTIFY_GRAPHQL_MICROSERVICES: Dependencies = {
dependencies: [
'@fastify/autoload',
'@fastify/mongodb',
'@mercuriusjs/federation',
'fastify',
'fastify-cli',
'fastify-custom-healthcheck',
'fastify-plugin',
'fastify-rabbitmq',
'mercurius-codegen'
],
devDependencies: [
...sharedDev
]
}

export const FASTIFY_NPM_PACKAGE: Dependencies = {
dependencies: [
'@fastify/error',
'fastify-plugin'
],
devDependencies: [
...sharedDev,
'fastify',
'ts-jest',
'@types/jest',
'jest',
'jest-ts-webcompat-resolver'
]
}

export const NPM_PACKAGE: Dependencies = {
dependencies: [],
devDependencies: [
...sharedDev,
'ts-jest',
'@types/jest',
'jest',
'jest-ts-webcompat-resolver'
]
}

export const VITE_REACT_SWC: Dependencies = {
dependencies: [
'@apollo/client',
'@fortawesome/fontawesome-svg-core',
'@fortawesome/free-regular-svg-icons',
'@fortawesome/free-solid-svg-icons',
'@fortawesome/react-fontawesome',
'graphql',
'i18next',
'i18next-browser-languagedetector',
'i18next-http-backend',
'react',
'react-dom',
'react-i18next',
'react-router-dom',
'react-spinners',
'react-toastify'
],
devDependencies: [
...sharedDev,
'@types/react',
'@types/react-dom',
'@vitejs/plugin-react-swc',
'autoprefixer',
'prettier-plugin-tailwindcss',
'tailwindcss',
'vite'
]
}

export const isProd = (): boolean => process.env.NODE_ENV !== 'test'
115 changes: 7 additions & 108 deletions src/modules/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,113 +1,12 @@
import {
FASTIFY_GRAPHQL_CONTROLLER,
FASTIFY_GRAPHQL_MICROSERVICES,
FASTIFY_NPM_PACKAGE,
NPM_PACKAGE,
VITE_REACT_SWC
} from './constants.js'
import { Dependencies, GenerateInput } from './types.js'

const sharedDev: string[] = [
'@semantic-release/changelog',
'@semantic-release/commit-analyzer',
'@semantic-release/git',
'@semantic-release/release-notes-generator',
'@the-rabbit-hole/semantic-release-config',
'@types/node',
'clean-publish',
'npm-check-updates',
'npm-package-json-lint',
'pre-commit',
'semantic-release',
'snazzy',
'ts-node',
'ts-standard',
'tsd',
'typedoc',
'typescript'
]

const FASTIFY_GRAPHQL_CONTROLLER: Dependencies = {
dependencies: [
'@fastify/autoload',
'@fastify/cors',
'@mercuriusjs/gateway',
'fastify',
'fastify-cli',
'fastify-custom-healthcheck',
'fastify-plugin'
],
devDependencies: [
...sharedDev
]
}

const FASTIFY_GRAPHQL_MICROSERVICES: Dependencies = {
dependencies: [
'@fastify/autoload',
'@fastify/mongodb',
'@mercuriusjs/federation',
'fastify',
'fastify-cli',
'fastify-custom-healthcheck',
'fastify-plugin',
'fastify-rabbitmq',
'mercurius-codegen'
],
devDependencies: [
...sharedDev
]
}

const FASTIFY_NPM_PACKAGE: Dependencies = {
dependencies: [
'@fastify/error',
'fastify-plugin'
],
devDependencies: [
...sharedDev,
'fastify',
'ts-jest',
'@types/jest',
'jest',
'jest-ts-webcompat-resolver'
]
}

const NPM_PACKAGE: Dependencies = {
dependencies: [],
devDependencies: [
...sharedDev,
'ts-jest',
'@types/jest',
'jest',
'jest-ts-webcompat-resolver'
]
}

const VITE_REACT_SWC: Dependencies = {
dependencies: [
'@apollo/client',
'@fortawesome/fontawesome-svg-core',
'@fortawesome/free-regular-svg-icons',
'@fortawesome/free-solid-svg-icons',
'@fortawesome/react-fontawesome',
'graphql',
'i18next',
'i18next-browser-languagedetector',
'i18next-http-backend',
'react',
'react-dom',
'react-i18next',
'react-router-dom',
'react-spinners',
'react-toastify'
],
devDependencies: [
...sharedDev,
'@types/react',
'@types/react-dom',
'@vitejs/plugin-react-swc',
'autoprefixer',
'prettier-plugin-tailwindcss',
'tailwindcss',
'vite'
]
}

/**
* @since 1.0.0
* @param input
Expand Down
20 changes: 17 additions & 3 deletions src/modules/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@ const execFile = promisify(childProcess.execFile)
* Init Git
* @since 1.5.0
* @param folder
* @param step
*/
export async function init (folder: string): Promise<void> {
await execFile('git', ['init'], { cwd: folder })
export async function init (folder: string, step: string): Promise<void> {
switch (step) {
case 'initial': {
await execFile('git', ['init', '--initial-branch=develop'], { cwd: folder })
break
}
case 'post': {
await execFile('git', ['add', '.'], { cwd: folder })
await execFile('git', ['commit', '-m', '"chore: initial creation [ci skip]"'], { cwd: folder })
await execFile('git', ['switch', '--orphan', 'main'], { cwd: folder })
await execFile('git', ['commit', '--allow-empty', '-m', '"chore: initial creation [ci skip]"'], { cwd: folder })
break
}
}
}

/**
* Add Git Remote
* Add Git Remote for GitHub
* @since 1.5.0
* @param folder
* @param repoOwner
* @param repoName
Expand Down

0 comments on commit 70d1e9c

Please sign in to comment.