-
Notifications
You must be signed in to change notification settings - Fork 5
/
.cli-packages
160 lines (139 loc) · 5.36 KB
/
.cli-packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
# jhipster() {
# npx generator-jhipster "$@" --skip-cache --skip-git --skip-commit-hook
# }
create-mvn-app() {
if [ "$#" -ne 2 ]; then
cat <<-EOF
Usage: create-mvn-app <group-id> <artifact-id> [archetype-artifact-id] [archetype-version]
Options:
group-id which package it should belong i.e: info.nmrony.app.example
artifact-id name of the artifact
archetype-artifact-id maven archetypeArtifactId (optional) (default: maven-archetype-quickstart)
archetype-version maven archetypeArtifactId (optional) (default: 1.4)
EOF
return 1
fi
local group_id=${1}
local artifact_id=${2}
local archetype_id=${3:-maven-archetype-quickstart}
local archetype_version=${4:-1.4}
ARC_TYPE_ID=${3:-maven-archetype-quickstart}
ARC_TYPE_VERSION=${4:-1.4}
echo "Generating maven app '$artifact_id' using $archetype_id=$archetype_version..."
mvn archetype:generate \
-DgroupId="$group_id" \
-DinteractiveMode=false \
-DartifactId="$artifact_id" \
-DarchetypeArtifactId="$archetype_id" \
-DarchetypeVersion="$archetype_version"
}
npm-init() {
git init
npx license $(npm get init.license) -o "$(npm get init.author.name)" >LICENSE
npx gitignore node
npx covgen "$(npm get init.author.email)"
npm init -y
git add -A
git commit -m "Initial commit"
}
create-react-app() {
npx create-react-app "$@" --use-npm
}
ng() {
npx -p @angular/cli ng "$@"
}
cordova() {
npx cordova "$@"
}
# sls() {
# npx serverless "$@"
# }
ionic() {
npx ionic "$@"
}
nest() {
npx @nestjs/cli "$@"
}
npm-upgrade() {
npx npm-upgrade "$@"
}
create-scala-app() {
local NMR_SCALA_PROJECT_NAME
local NMR_SCALA_PROJECT_ORG
local NMR_SCALA_PROJECT_VERSION
local NMR_SCALA_PROJECT_SCALA_VERSION
vared -p 'Project Name?: [hello-world] ' -c NMR_SCALA_PROJECT_NAME
vared -p 'Organization version?: [info.nmrony] ' -c NMR_SCALA_PROJECT_ORG
vared -p 'Project version?: [v1.0.0-SNAPSHOT] ' -c NMR_SCALA_PROJECT_VERSION
vared -p 'Scala version?: [3.2.1] ' -c NMR_SCALA_PROJECT_SCALA_VERSION
NMR_SCALA_PROJECT_NAME=${NMR_SCALA_PROJECT_NAME:-hello-world}
NMR_SCALA_PROJECT_ORG=${NMR_SCALA_PROJECT_ORG:-info.nmrony}
NMR_SCALA_PROJECT_VERSION=${NMR_SCALA_PROJECT_VERSION:-v1.0.0-SNAPSHOT}
NMR_SCALA_PROJECT_SCALA_VERSION=${NMR_SCALA_PROJECT_SCALA_VERSION:-3.2.1}
if [ -d "$NMR_SCALA_PROJECT_NAME" ]; then
echo $NMR_SCALA_PROJECT_NAME ' directory is already exists.'
else
echo -n 'Creating necessary directories and files... '
mkdir -p $NMR_SCALA_PROJECT_NAME/src/{main/{java,resources,scala},test/{java,resources,scala}}
cd $NMR_SCALA_PROJECT_NAME >/dev/null &&
cat >./build.sbt <<-EOF
name := "$NMR_SCALA_PROJECT_NAME"
organization := "$NMR_SCALA_PROJECT_ORG"
version := "$NMR_SCALA_PROJECT_VERSION"
scalaVersion := "$NMR_SCALA_PROJECT_SCALA_VERSION"
// Library Dependencies
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.9.0",
"org.scalatest" %% "scalatest" % "3.2.14" % "test"
)
// Scala Compiler Options
scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding", "utf-8", // Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-language:implicitConversions", // Allow definition of implicit functions called views
"-language:higherKinds", // Allow higher-kinded types
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
)
EOF
cat >./scalafmt.conf <<-EOF
style = defaultWithAlign
danglingParentheses = true
indentOperator = spray
includeCurlyBraceInSelectChains = true
maxColumn = 120
project.excludeFilters = [sample]
rewrite.rules = [RedundantParens, SortImports, PreferCurlyFors]
spaces.inImportCurlyBraces = true
binPack.literalArgumentLists = false
unindentTopLevelOperators = true
EOF
mkdir -p ./project && echo 'sbt.version=1.8.0' >./project/build.properties
cat >./src/main/scala/HelloWorld.scala <<-EOF
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
EOF
echo ''
echo 'To run application...' && cd ..
echo ''
echo 'cd ' $NMR_SCALA_PROJECT_NAME ' && sbt clean run'
echo ''
fi
}
add-maven-wrapper() {
mvn -N wrapper:wrapper
}