Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC cli tool for scaffolding #197

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 186 additions & 0 deletions scaffolding/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Covers Maven specific
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
!/.mvn/wrapper/maven-wrapper.jar

# Covers Eclipse specific:
.settings/
.classpath
.project

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
.idea
*.iml

# Covers Netbeans:
**/nbproject/private/
**/nbproject/Makefile-*.mk
**/nbproject/Package-*.bash
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

# Visual Studio Code specific
.vscode/
*.coverage
*.coveragexml
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
*.suo
*.user
*.userosscache
*.sln.docstates
*.userprefs
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
2 changes: 2 additions & 0 deletions scaffolding/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Omits the resolved property (with specific reference to the npm repository) from the lockfile.
omit-lockfile-registry-resolved=true
64 changes: 64 additions & 0 deletions scaffolding/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import fs = require("fs");
import {replaceInFile} from "replace-in-file";
import {checkbox, input} from "@inquirer/prompts";


startpoint();
async function startpoint() {
const FRONTEND = "frontend";
const BACKEND = "backend";
const EAI = "eai";
await checkbox({
message: 'Select Project/s you want to generate with space',
choices: [
{name: FRONTEND, value: FRONTEND},
{name: BACKEND, value: BACKEND},
{name: EAI, value: EAI},
],
required: true,
}).then((result: string[]) => {
if (result.includes(BACKEND)) {
generateBackend();
}
});
}

async function generateBackend() {
const groupId = await input({
message: "Define value for property groupId (should match expression '^de\\.muenchen\\.[a-z0-9]+(\\.[a-z0-9]+)*$'): ",
validate(value) {
const pass = value.match(/^de\.muenchen\.[a-z0-9]+(\.[a-z0-9]+)*$/g);
return pass ? true : "GroupId name not valid";
},
required: true,
});
const artifactId = await input({message: "Define value for property artifactId:", required: true,});
const packageName = await input({message: "Define value for property package:",
default: groupId,
validate(value) {
const pass = value.match(/^de\.muenchen\.[a-z0-9]+(\.[a-z0-9]+)*$/g);
return pass ? true : "Package name not valid";
},
required: true,
});
const projectName = await input({message: "Define value for Project Name:", required: true});
const replacements = [{
files: "../refarch-backend/src/main/java/de/muenchen/refarch/**/*.java",
from: [/package de.muenchen.refarch/g, /import de.muenchen.refarch/g],
to: [`package ${packageName}`, `import ${packageName}`],
dry: true,
countMatches: true,
}, {
files: "../refarch-backend/pom.xml",
from: ["<groupId>de.muenchen.refarch</groupId>", "<artifactId>refarch-backend</artifactId>", "<name>refarch_backend</name>"],
to: [`<groupId>${groupId}</groupId>`, `<artifactId>${artifactId}</artifactId>`, `<name>${artifactId}</name>`],
dry: true,
countMatches: true,
}]
Promise.all(
replacements.map(options => replaceInFile(options))
).then(result => {
console.log(result)
fs.rename("../refarch-backend", `../${projectName}`, () => {});
});
}
Loading
Loading