mirror of
https://github.com/valitydev/rbk-templator.git
synced 2024-11-06 08:45:16 +00:00
WIP
This commit is contained in:
parent
f7aac985a9
commit
55c1705ebb
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.idea
|
2602
package-lock.json
generated
Normal file
2602
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
package.json
Normal file
11
package.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@pospolitanv/rbk-templator",
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"plop": "plop"
|
||||
},
|
||||
"devDependencies": {
|
||||
"plop": "^2.2.0",
|
||||
"simple-git": "^1.107.0"
|
||||
}
|
||||
}
|
34
plop-templates/proto/proto-jenkinsfile
Normal file
34
plop-templates/proto/proto-jenkinsfile
Normal file
@ -0,0 +1,34 @@
|
||||
#!groovy
|
||||
// -*- mode: groovy -*-
|
||||
|
||||
build('{{lowerCase name}}-proto', 'docker-host') {
|
||||
checkoutRepo()
|
||||
loadBuildUtils()
|
||||
|
||||
def pipeDefault
|
||||
def gitUtils
|
||||
runStage('load pipeline') {
|
||||
env.JENKINS_LIB = "build_utils/jenkins_lib"
|
||||
pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy")
|
||||
gitUtils = load("${env.JENKINS_LIB}/gitUtils.groovy")
|
||||
}
|
||||
|
||||
pipeDefault() {
|
||||
|
||||
runStage('compile') {
|
||||
sh "make wc_compile"
|
||||
}
|
||||
|
||||
// Java
|
||||
runStage('Execute build container') {
|
||||
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
|
||||
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) {
|
||||
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} wc_java.deploy'
|
||||
} else {
|
||||
sh 'make SETTINGS_XML=${SETTINGS_XML} wc_java.compile'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
80
plop-templates/proto/proto-makefile
Normal file
80
plop-templates/proto/proto-makefile
Normal file
@ -0,0 +1,80 @@
|
||||
THRIFT = $(or $(shell which thrift), $(error "`thrift' executable missing"))
|
||||
REBAR = $(shell which rebar3 2>/dev/null || which ./rebar3)
|
||||
SUBMODULES = build_utils
|
||||
SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES))
|
||||
|
||||
UTILS_PATH := build_utils
|
||||
TEMPLATES_PATH := .
|
||||
|
||||
# Name of the service
|
||||
SERVICE_NAME := {{lowerCase name}}-proto
|
||||
|
||||
# Build image tag to be used
|
||||
BUILD_IMAGE_TAG := 55e987e74e9457191a5b4a7c5dc9e3838ae82d2b
|
||||
CALL_ANYWHERE := \
|
||||
all submodules compile clean distclean \
|
||||
java.compile java.deploy
|
||||
|
||||
CALL_W_CONTAINER := $(CALL_ANYWHERE)
|
||||
|
||||
all: compile
|
||||
|
||||
-include $(UTILS_PATH)/make_lib/utils_container.mk
|
||||
|
||||
.PHONY: $(CALL_W_CONTAINER)
|
||||
|
||||
# CALL_ANYWHERE
|
||||
$(SUBTARGETS): %/.git: %
|
||||
git submodule update --init $<
|
||||
touch $@
|
||||
|
||||
submodules: $(SUBTARGETS)
|
||||
|
||||
compile:
|
||||
$(REBAR) compile
|
||||
|
||||
clean:
|
||||
$(REBAR) clean
|
||||
|
||||
distclean:
|
||||
$(REBAR) clean -a
|
||||
rm -rfv _build
|
||||
|
||||
# Java
|
||||
|
||||
ifdef SETTINGS_XML
|
||||
DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML)
|
||||
DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML)
|
||||
endif
|
||||
|
||||
ifdef LOCAL_BUILD
|
||||
DOCKER_RUN_OPTS += -v $$HOME/.m2:/home/$(UNAME)/.m2:rw
|
||||
endif
|
||||
|
||||
COMMIT_HASH := $(shell git --no-pager log -1 --pretty=format:"%h")
|
||||
NUMBER_COMMITS := $(shell git rev-list --count HEAD)
|
||||
|
||||
JAVA_PKG_VERSION := 1.$(NUMBER_COMMITS)-$(COMMIT_HASH)
|
||||
|
||||
ifdef BRANCH_NAME
|
||||
ifeq "$(findstring epic,$(BRANCH_NAME))" "epic"
|
||||
JAVA_PKG_VERSION := $(JAVA_PKG_VERSION)-epic
|
||||
endif
|
||||
endif
|
||||
|
||||
MVN = mvn -s $(SETTINGS_XML) -Dpath_to_thrift="$(THRIFT)" -Dcommit.number="$(NUMBER_COMMITS)"
|
||||
|
||||
java.compile: java.settings
|
||||
$(MVN) compile
|
||||
|
||||
java.deploy: java.settings
|
||||
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \
|
||||
$(MVN) deploy
|
||||
|
||||
java.install: java.settings
|
||||
$(MVN) clean && \
|
||||
$(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \
|
||||
$(MVN) install
|
||||
|
||||
java.settings:
|
||||
$(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1)
|
3
plop-templates/proto/proto.thrift
Normal file
3
plop-templates/proto/proto.thrift
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
namespace java com.rbkmoney.damsel.{{lowerCase name}}
|
||||
namespace erlang com.rbkmoney.damsel.{{lowerCase name}}
|
85
plopfile.js
Normal file
85
plopfile.js
Normal file
@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (plop) {
|
||||
plop.setWelcomeMessage('CUSTOM'.red + ' Какой проект вам запилить?');
|
||||
plop.addHelper('pathHelper', function (p) {
|
||||
return p ? p + "/" : "";
|
||||
});
|
||||
// generators
|
||||
plop.setGenerator('java-proto', {
|
||||
description: 'Create a java protocol project structure',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Как называется ваш протокол? (без "-proto")',
|
||||
validate: function (value) {
|
||||
if (value.length === 0) { return "Вы не ввели имя!"; }
|
||||
if ((/.*-proto.*/).test(value)) { return "Вы ввели имя протокола с \"-proto\"!"; }
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'withBuildUtils',
|
||||
message: 'Хотите ли вы подключить build_utils?'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
{
|
||||
type: 'add',
|
||||
path: 'proto/{{lowerCase name}}.thrift',
|
||||
templateFile: 'plop-templates/proto/proto.thrift'
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'Jenkinsfile',
|
||||
templateFile: 'plop-templates/proto/proto-jenkinsfile'
|
||||
},
|
||||
(answers) => {
|
||||
if (answers.withBuildUtils) {
|
||||
let git = require('simple-git')("");
|
||||
git.subModule(["add", "-b", "master", "git@github.com:rbkmoney/build_utils.git", "build_utils"]);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'Makefile',
|
||||
templateFile: 'plop-templates/proto/proto-jenkinsfile'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
plop.setGenerator('java-service', {
|
||||
description: 'Create a java service project structure',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Как называется ваш протокол? (без "-proto")'
|
||||
}
|
||||
],
|
||||
actions: [
|
||||
(answers) => {
|
||||
console.log(`You choose: \n
|
||||
- name: ${answers.name}`);
|
||||
return '';
|
||||
},
|
||||
{
|
||||
type: 'add',
|
||||
path: 'app/tests/{{lowerCase path}}/{{lowerCase name}}.thrift',
|
||||
templateFile: 'plop-templates/modules/proto.thrift'
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user