@mrpelz/boilerplate-common 8.0.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.shellcheckrc +1 -0
- package/{config/.vscode → .vscode}/settings.json +1 -1
- package/{config/Makefile → Makefile} +29 -11
- package/package.json +13 -4
- package/scripts/bootstrap.sh +56 -238
- package/scripts/common-post.sh +50 -0
- package/scripts/common-pre.sh +16 -0
- package/scripts/utils.sh +129 -0
- package/{config/dev.sh → scripts/watch-dev.sh} +1 -1
- package/{config → scripts}/watch.sh +1 -1
- package/{config/tsconfig.base.json → tsconfig.json} +1 -0
- package/tsconfig.meta.json +11 -0
- package/config/tsconfig.meta.json +0 -9
- /package/{config/.editorconfig → .editorconfig} +0 -0
- /package/{config/.husky → .husky}/commit-msg +0 -0
- /package/{config/.vscode → .vscode}/extensions.json +0 -0
- /package/{config/commitlint.config.mjs → commitlint.config.mjs} +0 -0
- /package/{config/eslint.config.js → eslint.config.js} +0 -0
- /package/{config/jest.config.js → jest.config.js} +0 -0
package/.shellcheckrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
external-sources=true
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
transform_clear \
|
|
17
17
|
transform_lint \
|
|
18
18
|
transform_package_json \
|
|
19
|
+
transform_package_json_fix \
|
|
19
20
|
transform_package_json_name \
|
|
20
21
|
transform_package_json_sort \
|
|
21
22
|
transform_package_json_version \
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
transform_typescript \
|
|
24
25
|
util_clear \
|
|
25
26
|
util_edit \
|
|
27
|
+
util_get_package_json \
|
|
26
28
|
util_get_version \
|
|
27
29
|
util_install_git_hooks \
|
|
28
30
|
watch \
|
|
@@ -64,15 +66,17 @@ SUB_RUN = \
|
|
|
64
66
|
\
|
|
65
67
|
echo "parent:$(@)";
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
70
|
+
|
|
71
|
+
PKG_NAME := $(shell npm pkg get --workspaces=false name 2>/dev/null | sed -nr 's/^"@(.+)"$$/\1/p' 2>/dev/null)
|
|
68
72
|
GIT_NAME := $(shell git remote get-url origin 2>/dev/null | sed -nr 's/^(https|git)(:\/\/|@)(.+@)?([^\/:]+)[\/:]([^\/:]+)\/(.+)\.git$$/\5\/\6/p' 2>/dev/null)
|
|
69
73
|
|
|
70
|
-
PKG_VERSION := $(shell npm pkg get version 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
|
|
74
|
+
PKG_VERSION := $(shell npm pkg get --workspaces=false version 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
|
|
71
75
|
GIT_VERSION := $(shell git describe --tag --abbrev=0 2>/dev/null | sed -nr 's/^v(.+)$$/\1/p' 2>/dev/null)
|
|
72
76
|
|
|
73
|
-
PKG_REPO_TYPE := $(shell npm pkg get repository.type 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
|
|
74
|
-
PKG_REPO_NAME := $(shell npm pkg get repository.url 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null | sed -nr 's/^(https|git)(:\/\/|@)(.+@)?([^\/:]+)[\/:]([^\/:]+)\/(.+)\.git$$/\5\/\6/p' 2>/dev/null)
|
|
75
|
-
PKG_REPO_DIRECTORY := $(shell npm pkg get repository.directory 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
|
|
77
|
+
PKG_REPO_TYPE := $(shell npm pkg get --workspaces=false repository.type 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
|
|
78
|
+
PKG_REPO_NAME := $(shell npm pkg get --workspaces=false repository.url 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null | sed -nr 's/^(https|git)(:\/\/|@)(.+@)?([^\/:]+)[\/:]([^\/:]+)\/(.+)\.git$$/\5\/\6/p' 2>/dev/null)
|
|
79
|
+
PKG_REPO_DIRECTORY := $(shell npm pkg get --workspaces=false repository.directory 2>/dev/null | sed -nr 's/^"(.+)"$$/\1/p' 2>/dev/null)
|
|
76
80
|
|
|
77
81
|
ESLINT_ARGS := --ignore-pattern "dist/**/*" --ignore-pattern "node_modules/**/*" --ignore-pattern "$(SUB_PACKAGE_DIR)/**/*"
|
|
78
82
|
|
|
@@ -101,6 +105,7 @@ check_lint:
|
|
|
101
105
|
eslint $(ESLINT_ARGS) .
|
|
102
106
|
|
|
103
107
|
check_package_json: \
|
|
108
|
+
util_get_package_json \
|
|
104
109
|
check_package_json_sort \
|
|
105
110
|
check_package_json_repository \
|
|
106
111
|
check_package_json_name \
|
|
@@ -196,7 +201,13 @@ transform_lint:
|
|
|
196
201
|
transform_package_json: \
|
|
197
202
|
transform_package_json_sort \
|
|
198
203
|
transform_package_json_name \
|
|
199
|
-
transform_package_json_version
|
|
204
|
+
transform_package_json_version \
|
|
205
|
+
transform_package_json_fix
|
|
206
|
+
|
|
207
|
+
transform_package_json_fix:
|
|
208
|
+
$(SUB_RUN)
|
|
209
|
+
|
|
210
|
+
npm pkg fix --workspaces=false
|
|
200
211
|
|
|
201
212
|
transform_package_json_name:
|
|
202
213
|
$(SUB_RUN)
|
|
@@ -204,7 +215,7 @@ transform_package_json_name:
|
|
|
204
215
|
if [[ -n "$(PKG_REPO_DIRECTORY)" ]]; then \
|
|
205
216
|
echo "is sub-package, not applying repository name"; \
|
|
206
217
|
else \
|
|
207
|
-
npm pkg set "name=@$(GIT_NAME)"; \
|
|
218
|
+
npm pkg set --workspaces=false "name=@$(GIT_NAME)"; \
|
|
208
219
|
fi
|
|
209
220
|
|
|
210
221
|
transform_package_json_sort:
|
|
@@ -215,7 +226,7 @@ transform_package_json_sort:
|
|
|
215
226
|
transform_package_json_version:
|
|
216
227
|
$(SUB_RUN)
|
|
217
228
|
|
|
218
|
-
npm pkg set "version=$(GIT_VERSION)"
|
|
229
|
+
npm pkg set --workspaces=false "version=$(GIT_VERSION)"
|
|
219
230
|
|
|
220
231
|
transform_prod: \
|
|
221
232
|
util_clear \
|
|
@@ -236,6 +247,12 @@ util_edit:
|
|
|
236
247
|
|
|
237
248
|
code .
|
|
238
249
|
|
|
250
|
+
util_get_package_json:
|
|
251
|
+
$(SUB_RUN)
|
|
252
|
+
|
|
253
|
+
source "$(ROOT_DIR)/scripts/utils.sh"; \
|
|
254
|
+
display "$$(npm pkg get --workspaces=false)" "json";
|
|
255
|
+
|
|
239
256
|
util_get_version:
|
|
240
257
|
@echo $(PKG_VERSION)
|
|
241
258
|
|
|
@@ -249,11 +266,12 @@ watch_config:
|
|
|
249
266
|
tsc --project tsconfig.meta.json --watch
|
|
250
267
|
|
|
251
268
|
watch_dev:
|
|
252
|
-
scripts/dev.sh
|
|
269
|
+
scripts/watch-dev.sh
|
|
253
270
|
|
|
254
271
|
watch_lint:
|
|
255
|
-
|
|
256
|
-
--
|
|
272
|
+
nodemon --watch "**/*" --watch "src/**/*" --ignore "dist/**/*" --ignore "node_modules/**/*" --ignore "*.d.ts" --ext "js,mjs,ts" \
|
|
273
|
+
--exec 'eslint $(ESLINT_ARGS) .'; \
|
|
274
|
+
exit 0;
|
|
257
275
|
|
|
258
276
|
watch_test:
|
|
259
277
|
jest --watch .
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrpelz/boilerplate-common",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/mrpelz/boilerplate.git",
|
|
@@ -17,8 +17,17 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/**/*.{js,map,ts}",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
".editorconfig",
|
|
21
|
+
".husky/**/*",
|
|
22
|
+
".shellcheckrc",
|
|
23
|
+
".vscode/**/*.json",
|
|
24
|
+
"commitlint.config.mjs",
|
|
25
|
+
"eslint.config.js",
|
|
26
|
+
"jest.config.js",
|
|
27
|
+
"Makefile",
|
|
28
|
+
"scripts/**/*.sh",
|
|
29
|
+
"tsconfig.json",
|
|
30
|
+
"tsconfig.meta.json"
|
|
22
31
|
],
|
|
23
32
|
"dependencies": {
|
|
24
33
|
"@commitlint/cli": "latest",
|
|
@@ -29,7 +38,6 @@
|
|
|
29
38
|
"@typescript-eslint/eslint-plugin": "latest",
|
|
30
39
|
"@typescript-eslint/parser": "latest",
|
|
31
40
|
"@typescript-eslint/types": "latest",
|
|
32
|
-
"chokidar-cli": "latest",
|
|
33
41
|
"eslint": "latest",
|
|
34
42
|
"eslint-import-resolver-typescript": "latest",
|
|
35
43
|
"eslint-plugin-import": "latest",
|
|
@@ -38,6 +46,7 @@
|
|
|
38
46
|
"eslint-plugin-unicorn": "latest",
|
|
39
47
|
"husky": "latest",
|
|
40
48
|
"jest": "latest",
|
|
49
|
+
"nodemon": "latest",
|
|
41
50
|
"prettier": "latest",
|
|
42
51
|
"sort-package-json": "latest",
|
|
43
52
|
"ts-jest": "latest",
|
package/scripts/bootstrap.sh
CHANGED
|
@@ -2,235 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
## ENVIRONMENT
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
BOILERPLATE_MODULE_NAME="@mrpelz/boilerplate-common"
|
|
6
|
+
BOILERPLATE_MODULE_PATH="$(realpath --relative-to=. "$(npm ls --parseable --silent "$BOILERPLATE_MODULE_NAME" 2>/dev/null)")"
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
BOILERPLATE_MODULE_NAME=$BOILERPLATE_MODULE_IDENTIFIER
|
|
10
|
-
BOILERPLATE_MODULE_PATH="$(realpath --relative-to=. "$(npm root)")/$BOILERPLATE_MODULE_IDENTIFIER/"
|
|
11
|
-
|
|
12
|
-
FORMAT_BOLD=$(tput bold)
|
|
13
|
-
FORMAT_NORMAL=$(tput sgr0)
|
|
14
|
-
|
|
15
|
-
## UTILS
|
|
16
|
-
|
|
17
|
-
check_response() {
|
|
18
|
-
local CHECK_PROMPT=$1
|
|
19
|
-
local DEFAULT_RESPONSE=$2
|
|
20
|
-
|
|
21
|
-
echo "❓ $CHECK_PROMPT"
|
|
22
|
-
|
|
23
|
-
local CHECK_SUFFIX
|
|
24
|
-
|
|
25
|
-
case $DEFAULT_RESPONSE in
|
|
26
|
-
y | Y) CHECK_SUFFIX="[Y/n]" ;;
|
|
27
|
-
n | N) CHECK_SUFFIX="[y/N]" ;;
|
|
28
|
-
*) CHECK_SUFFIX="[y/n]" ;;
|
|
29
|
-
esac
|
|
30
|
-
|
|
31
|
-
case $OVERRIDE in
|
|
32
|
-
y | Y) CHOICE=y ;;
|
|
33
|
-
n | N) CHOICE=n ;;
|
|
34
|
-
d | D) CHOICE=$DEFAULT_RESPONSE ;;
|
|
35
|
-
*) read -r -p "❔ $CHECK_SUFFIX " CHOICE ;;
|
|
36
|
-
esac
|
|
37
|
-
|
|
38
|
-
if [[ -z "$CHOICE" ]]; then
|
|
39
|
-
CHOICE=$DEFAULT_RESPONSE
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
echo "❗ $CHOICE"
|
|
43
|
-
|
|
44
|
-
case "$CHOICE" in
|
|
45
|
-
y | Y) return 0 ;;
|
|
46
|
-
n | N) return 1 ;;
|
|
47
|
-
*) return 1 ;;
|
|
48
|
-
esac
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
check_command() {
|
|
52
|
-
local COMMAND=$1
|
|
53
|
-
|
|
54
|
-
if command -v "$COMMAND" &>/dev/null; then
|
|
55
|
-
return 0
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
return 1
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
check_non_existent() {
|
|
62
|
-
local FILE_PATH=$1
|
|
63
|
-
local OVERRIDE_PROMPT=$2
|
|
64
|
-
|
|
65
|
-
if [[ -e "$FILE_PATH" ]]; then
|
|
66
|
-
echo "💾 file already exists"
|
|
67
|
-
|
|
68
|
-
if check_response "$OVERRIDE_PROMPT" n; then
|
|
69
|
-
return 0
|
|
70
|
-
fi
|
|
71
|
-
|
|
72
|
-
return 1
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
return 0
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
display() {
|
|
79
|
-
local CONTENT=$1
|
|
80
|
-
local SYNTAX=$2
|
|
81
|
-
|
|
82
|
-
if check_command highlight; then
|
|
83
|
-
echo "$CONTENT" | highlight --out-format=xterm256 --syntax="$SYNTAX"
|
|
84
|
-
else
|
|
85
|
-
echo "$CONTENT"
|
|
86
|
-
fi
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
make_ln() {
|
|
90
|
-
local TARGET_PATH=$1
|
|
91
|
-
local LINK_PATH=$2
|
|
92
|
-
|
|
93
|
-
local LINK_NAME
|
|
94
|
-
LINK_NAME=$(basename "$LINK_PATH")
|
|
95
|
-
|
|
96
|
-
local LINK_DIR
|
|
97
|
-
LINK_DIR=$(dirname "$LINK_PATH")
|
|
98
|
-
|
|
99
|
-
echo "[SYMBOLIC LINK] \"${FORMAT_BOLD}${LINK_NAME}${FORMAT_NORMAL}\""
|
|
100
|
-
|
|
101
|
-
if ! check_response "🔗 add symbolic link \"$LINK_PATH\" (pointing to target \"$TARGET_PATH\") to \"$LINK_DIR\" in \"$PWD\"?" y; then
|
|
102
|
-
return
|
|
103
|
-
fi
|
|
104
|
-
|
|
105
|
-
if check_non_existent "$LINK_PATH" "🪠 overwrite with link?"; then
|
|
106
|
-
mkdir -p "$LINK_DIR"
|
|
107
|
-
ln -f -r -s "$PWD/$TARGET_PATH" "$LINK_PATH"
|
|
108
|
-
fi
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
make_config() {
|
|
112
|
-
local FILE_PATH=$1
|
|
113
|
-
local FILE_CONTENT=$2
|
|
114
|
-
|
|
115
|
-
local FILE_NAME
|
|
116
|
-
FILE_NAME=$(basename "$FILE_PATH")
|
|
117
|
-
|
|
118
|
-
local FILE_DIR
|
|
119
|
-
FILE_DIR=$(dirname "$FILE_PATH")
|
|
120
|
-
|
|
121
|
-
echo "[CONFIG FILE] \"${FORMAT_BOLD}${FILE_NAME}${FORMAT_NORMAL}\""
|
|
122
|
-
|
|
123
|
-
echo "🆕 new file contents:"
|
|
124
|
-
display "$FILE_CONTENT" "${FILE_NAME##*.}"
|
|
125
|
-
|
|
126
|
-
if ! check_response "📄 add config file \"$FILE_PATH\" to \"$FILE_DIR\" in \"$PWD\"?" y; then
|
|
127
|
-
return
|
|
128
|
-
fi
|
|
129
|
-
|
|
130
|
-
if check_non_existent "$FILE_PATH" "🪠 overwrite with new contents?"; then
|
|
131
|
-
mkdir -p "$FILE_DIR"
|
|
132
|
-
echo "$FILE_CONTENT" >"$FILE_PATH"
|
|
133
|
-
fi
|
|
134
|
-
}
|
|
8
|
+
SCRIPT_PATH="$(dirname "$(realpath "$0")")"
|
|
9
|
+
source "${SCRIPT_PATH}/utils.sh"
|
|
135
10
|
|
|
136
11
|
## FLOW
|
|
137
12
|
|
|
138
|
-
|
|
139
|
-
echo "📍 running within \"$BOILERPLATE_MODULE_IDENTIFIER\""
|
|
140
|
-
|
|
141
|
-
BOILERPLATE_MODULE_NAME="."
|
|
142
|
-
BOILERPLATE_MODULE_PATH="./"
|
|
143
|
-
else
|
|
144
|
-
echo "ℹ️ running with \"$BOILERPLATE_MODULE_IDENTIFIER\" as dependency"
|
|
145
|
-
fi
|
|
146
|
-
|
|
147
|
-
if ! check_command make; then
|
|
148
|
-
echo "❌ \"make\" is not available, aborting"
|
|
149
|
-
exit 1
|
|
150
|
-
fi
|
|
151
|
-
|
|
152
|
-
if ! check_command sed; then
|
|
153
|
-
echo "❌ \"sed\" is not available, aborting"
|
|
154
|
-
exit 1
|
|
155
|
-
fi
|
|
13
|
+
source "${SCRIPT_PATH}/common-pre.sh"
|
|
156
14
|
|
|
157
|
-
if
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
fi
|
|
15
|
+
if [[ $SKIP_FILES -ne 1 ]]; then
|
|
16
|
+
if check_response "🖇 install symbolic links referencing files in \"$BOILERPLATE_MODULE_NAME\"?" y; then
|
|
17
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/.editorconfig" .editorconfig
|
|
161
18
|
|
|
162
|
-
|
|
163
|
-
make_ln "${BOILERPLATE_MODULE_PATH}config/.editorconfig" .editorconfig
|
|
19
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/.shellcheckrc" .shellcheckrc
|
|
164
20
|
|
|
165
|
-
|
|
166
|
-
|
|
21
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/.vscode/extensions.json" .vscode/extensions.json
|
|
22
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/.vscode/settings.json" .vscode/settings.json
|
|
167
23
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
fi
|
|
24
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/scripts/watch.sh" scripts/watch.sh
|
|
25
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/scripts/watch-dev.sh" scripts/watch-dev.sh
|
|
26
|
+
fi
|
|
171
27
|
|
|
172
|
-
if check_response "📃 install bare config files extending base files in
|
|
28
|
+
if check_response "📃 install bare config files extending base files in \"$BOILERPLATE_MODULE_NAME\"?" y; then
|
|
173
29
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
30
|
+
# no indent
|
|
31
|
+
make_config .gitignore "$(
|
|
32
|
+
cat <<EOF
|
|
177
33
|
.DS_Store
|
|
178
34
|
dist
|
|
179
35
|
node_modules
|
|
180
36
|
secrets.txt
|
|
181
37
|
EOF
|
|
182
|
-
|
|
38
|
+
)"
|
|
183
39
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
40
|
+
make_config Makefile "$(
|
|
41
|
+
cat <<EOF
|
|
42
|
+
BASE_FILE := \$(shell npm ls --parseable --silent "$BOILERPLATE_MODULE_NAME" 2>/dev/null)
|
|
43
|
+
|
|
44
|
+
include \$(BASE_FILE)/Makefile
|
|
187
45
|
EOF
|
|
188
|
-
|
|
46
|
+
)"
|
|
189
47
|
|
|
190
|
-
|
|
191
|
-
|
|
48
|
+
make_config commitlint.config.mjs "$(
|
|
49
|
+
cat <<EOF
|
|
192
50
|
// @ts-ignore
|
|
193
|
-
import config from '$BOILERPLATE_MODULE_NAME/
|
|
51
|
+
import config from '$BOILERPLATE_MODULE_NAME/commitlint.config.mjs';
|
|
194
52
|
|
|
195
53
|
/** @type {import('@commitlint/types').UserConfig} */
|
|
196
54
|
export default config;
|
|
197
55
|
EOF
|
|
198
|
-
|
|
56
|
+
)"
|
|
199
57
|
|
|
200
|
-
|
|
201
|
-
|
|
58
|
+
make_config eslint.config.js "$(
|
|
59
|
+
cat <<EOF
|
|
202
60
|
// @ts-ignore
|
|
203
|
-
import config from '$BOILERPLATE_MODULE_NAME/
|
|
61
|
+
import config from '$BOILERPLATE_MODULE_NAME/eslint.config.js';
|
|
204
62
|
|
|
205
63
|
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
206
64
|
export default config;
|
|
207
65
|
EOF
|
|
208
|
-
|
|
66
|
+
)"
|
|
209
67
|
|
|
210
|
-
|
|
211
|
-
|
|
68
|
+
make_config jest.config.js "$(
|
|
69
|
+
cat <<EOF
|
|
212
70
|
// @ts-ignore
|
|
213
|
-
import config from '$BOILERPLATE_MODULE_NAME/
|
|
71
|
+
import config from '$BOILERPLATE_MODULE_NAME/jest.config.js';
|
|
214
72
|
|
|
215
73
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
216
74
|
export default config;
|
|
217
75
|
EOF
|
|
218
|
-
|
|
76
|
+
)"
|
|
219
77
|
|
|
220
|
-
|
|
221
|
-
|
|
78
|
+
make_config tsconfig.json "$(
|
|
79
|
+
cat <<EOF
|
|
222
80
|
{
|
|
223
81
|
"compilerOptions": {
|
|
224
82
|
"outDir": "dist",
|
|
225
83
|
},
|
|
226
|
-
"extends": "$BOILERPLATE_MODULE_NAME/
|
|
84
|
+
"extends": "$BOILERPLATE_MODULE_NAME/tsconfig.json",
|
|
227
85
|
"include": ["src/**/*"]
|
|
228
86
|
}
|
|
229
87
|
EOF
|
|
230
|
-
|
|
88
|
+
)"
|
|
231
89
|
|
|
232
|
-
|
|
233
|
-
|
|
90
|
+
make_config tsconfig.build.json "$(
|
|
91
|
+
cat <<EOF
|
|
234
92
|
{
|
|
235
93
|
"compilerOptions": {
|
|
236
94
|
"noEmit": false
|
|
@@ -240,70 +98,30 @@ EOF
|
|
|
240
98
|
"include": ["src/**/*"]
|
|
241
99
|
}
|
|
242
100
|
EOF
|
|
243
|
-
|
|
101
|
+
)"
|
|
244
102
|
|
|
245
|
-
|
|
246
|
-
|
|
103
|
+
make_config tsconfig.meta.json "$(
|
|
104
|
+
cat <<EOF
|
|
247
105
|
{
|
|
248
106
|
"exclude": ["dist/**/*", "node_modules/**/*", "packages/**/*", "src/**/*"],
|
|
249
|
-
"extends": "$BOILERPLATE_MODULE_NAME/
|
|
107
|
+
"extends": "$BOILERPLATE_MODULE_NAME/tsconfig.meta.json",
|
|
250
108
|
"include": ["**/*.js", "**/*.mjs"]
|
|
251
109
|
}
|
|
252
110
|
EOF
|
|
253
|
-
|
|
111
|
+
)"
|
|
254
112
|
|
|
255
|
-
|
|
256
|
-
|
|
113
|
+
make_config .gitlab-ci.yml "$(
|
|
114
|
+
cat <<EOF
|
|
257
115
|
include:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
EOF
|
|
263
|
-
else
|
|
264
|
-
cat <<EOF
|
|
265
|
-
include: "/gitlab/.gitlab-ci.yml"
|
|
266
|
-
# include: "/gitlab/.monorepo.gitlab-ci.yml"
|
|
116
|
+
- project: "mrpelz/boilerplate"
|
|
117
|
+
ref: main
|
|
118
|
+
file: "/gitlab/.gitlab-ci.yml"
|
|
119
|
+
# file: "/gitlab/.monorepo.gitlab-ci.yml"
|
|
267
120
|
EOF
|
|
268
|
-
|
|
269
|
-
fi
|
|
270
|
-
|
|
271
|
-
if check_response "💱 apply changes to \"package.json\"?" y; then
|
|
272
|
-
npm pkg set \
|
|
273
|
-
"license=UNLICENSED" \
|
|
274
|
-
"author=Lennart Pelz <mail@mrpelz.de>" \
|
|
275
|
-
"type=module" \
|
|
276
|
-
"main=dist/main.js" \
|
|
277
|
-
"module=dist/main.js" \
|
|
278
|
-
"types=dist/main.d.ts" \
|
|
279
|
-
"files[0]=dist/**/*.{js,map,ts}"
|
|
280
|
-
fi
|
|
281
|
-
|
|
282
|
-
if check_response "🕳 run npm install?" y; then
|
|
283
|
-
npm install
|
|
284
|
-
fi
|
|
285
|
-
|
|
286
|
-
if check_response "📂 create \"src\" directory (this will *not* overwrite/empty out existing directories)?" y; then
|
|
287
|
-
mkdir -p src
|
|
288
|
-
fi
|
|
289
|
-
|
|
290
|
-
if check_response "📂 create \"dist\" directory (this will *not* overwrite/empty out existing directories)?" y; then
|
|
291
|
-
mkdir -p dist
|
|
292
|
-
fi
|
|
293
|
-
|
|
294
|
-
if check_command git; then
|
|
295
|
-
if [[ -d ".git" ]]; then
|
|
296
|
-
if check_response "🪝 install git hooks?" y; then
|
|
297
|
-
make_ln "${BOILERPLATE_MODULE_PATH}config/.husky/commit-msg" .husky/commit-msg
|
|
298
|
-
make util_install_git_hooks
|
|
299
|
-
fi
|
|
300
|
-
else
|
|
301
|
-
echo "❌ \"$PWD\" does not seem to be a git repository, not installing git hooks"
|
|
121
|
+
)"
|
|
302
122
|
fi
|
|
303
|
-
else
|
|
304
|
-
echo "❌ \"git\" is not available, not istalling git hooks"
|
|
305
123
|
fi
|
|
306
124
|
|
|
307
|
-
|
|
125
|
+
source "${SCRIPT_PATH}/common-post.sh"
|
|
308
126
|
|
|
309
127
|
echo "✅ done"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
if check_response "💱 apply changes to \"package.json\"?" y; then
|
|
4
|
+
npm pkg set --workspaces=false \
|
|
5
|
+
"license=UNLICENSED" \
|
|
6
|
+
"type=module" \
|
|
7
|
+
"main=dist/main.js" \
|
|
8
|
+
"module=dist/main.js" \
|
|
9
|
+
"types=dist/main.d.ts" \
|
|
10
|
+
"files[0]=dist/**/*.{js,map,ts}"
|
|
11
|
+
|
|
12
|
+
if check_command git; then
|
|
13
|
+
USER_NAME=$(git config user.name)
|
|
14
|
+
USER_EMAIL=$(git config user.email)
|
|
15
|
+
|
|
16
|
+
if [[ -n "$USER_NAME" && -n "$USER_EMAIL" ]]; then
|
|
17
|
+
npm pkg set --workspaces=false \
|
|
18
|
+
"author=${USER_NAME} <${USER_EMAIL}>"
|
|
19
|
+
fi
|
|
20
|
+
fi
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
if check_response "🕳 run npm install?" y; then
|
|
24
|
+
npm install
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
if check_response "📂 create \"src\" directory (this will *not* overwrite/empty out existing directories)?" y; then
|
|
28
|
+
mkdir -p src
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if check_response "📂 create \"dist\" directory (this will *not* overwrite/empty out existing directories)?" y; then
|
|
32
|
+
mkdir -p dist
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if check_command git; then
|
|
36
|
+
if [[ -d ".git" ]]; then
|
|
37
|
+
if check_response "🪝 install git hooks?" y; then
|
|
38
|
+
if [[ $SKIP_FILES -ne 1 ]]; then
|
|
39
|
+
make_ln "${BOILERPLATE_MODULE_PATH}/.husky/commit-msg" .husky/commit-msg
|
|
40
|
+
fi
|
|
41
|
+
make util_install_git_hooks
|
|
42
|
+
fi
|
|
43
|
+
else
|
|
44
|
+
echo "❌ \"$PWD\" does not seem to be a git repository, not installing git hooks"
|
|
45
|
+
fi
|
|
46
|
+
else
|
|
47
|
+
echo "❌ \"git\" is not available, not istalling git hooks"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
make transform_package_json_sort
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
for COMMAND in make head pidwait sed tmux xargs; do
|
|
4
|
+
if ! check_command "$COMMAND"; then
|
|
5
|
+
echo "❌ \"$COMMAND\" is not available, aborting"
|
|
6
|
+
exit 1
|
|
7
|
+
fi
|
|
8
|
+
done
|
|
9
|
+
|
|
10
|
+
if [[ "$(npm pkg get --workspaces=false name)" == "\"$BOILERPLATE_MODULE_NAME\"" ]]; then
|
|
11
|
+
echo "📍 running within \"$BOILERPLATE_MODULE_NAME\""
|
|
12
|
+
# shellcheck disable=SC2034
|
|
13
|
+
SKIP_FILES=1
|
|
14
|
+
else
|
|
15
|
+
echo "ℹ️ running with \"$BOILERPLATE_MODULE_NAME\" as dependency"
|
|
16
|
+
fi
|
package/scripts/utils.sh
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
## ENVIRONMENT
|
|
4
|
+
|
|
5
|
+
OVERRIDE=$1
|
|
6
|
+
|
|
7
|
+
FORMAT_BOLD=$(tput bold)
|
|
8
|
+
FORMAT_NORMAL=$(tput sgr0)
|
|
9
|
+
|
|
10
|
+
## UTILS
|
|
11
|
+
|
|
12
|
+
check_response() {
|
|
13
|
+
local CHECK_PROMPT=$1
|
|
14
|
+
local DEFAULT_RESPONSE=$2
|
|
15
|
+
|
|
16
|
+
echo "❓ $CHECK_PROMPT"
|
|
17
|
+
|
|
18
|
+
local CHECK_SUFFIX
|
|
19
|
+
|
|
20
|
+
case $DEFAULT_RESPONSE in
|
|
21
|
+
y | Y) CHECK_SUFFIX="[Y/n]" ;;
|
|
22
|
+
n | N) CHECK_SUFFIX="[y/N]" ;;
|
|
23
|
+
*) CHECK_SUFFIX="[y/n]" ;;
|
|
24
|
+
esac
|
|
25
|
+
|
|
26
|
+
case $OVERRIDE in
|
|
27
|
+
y | Y) CHOICE=y ;;
|
|
28
|
+
n | N) CHOICE=n ;;
|
|
29
|
+
d | D) CHOICE=$DEFAULT_RESPONSE ;;
|
|
30
|
+
*) read -r -p "❔ $CHECK_SUFFIX " CHOICE ;;
|
|
31
|
+
esac
|
|
32
|
+
|
|
33
|
+
if [[ -z "$CHOICE" ]]; then
|
|
34
|
+
CHOICE=$DEFAULT_RESPONSE
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
echo "❗ $CHOICE"
|
|
38
|
+
|
|
39
|
+
case "$CHOICE" in
|
|
40
|
+
y | Y) return 0 ;;
|
|
41
|
+
n | N) return 1 ;;
|
|
42
|
+
*) return 1 ;;
|
|
43
|
+
esac
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
check_command() {
|
|
47
|
+
local COMMAND=$1
|
|
48
|
+
|
|
49
|
+
if command -v "$COMMAND" &>/dev/null; then
|
|
50
|
+
return 0
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
return 1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
check_non_existent() {
|
|
57
|
+
local FILE_PATH=$1
|
|
58
|
+
local OVERRIDE_PROMPT=$2
|
|
59
|
+
|
|
60
|
+
if [[ -e "$FILE_PATH" ]]; then
|
|
61
|
+
echo "💾 file already exists"
|
|
62
|
+
|
|
63
|
+
if check_response "$OVERRIDE_PROMPT" n; then
|
|
64
|
+
return 0
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
return 1
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
return 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
display() {
|
|
74
|
+
local CONTENT=$1
|
|
75
|
+
local SYNTAX=$2
|
|
76
|
+
|
|
77
|
+
if check_command highlight; then
|
|
78
|
+
echo "$CONTENT" | highlight --out-format=xterm256 --syntax="$SYNTAX"
|
|
79
|
+
else
|
|
80
|
+
echo "$CONTENT"
|
|
81
|
+
fi
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
make_ln() {
|
|
85
|
+
local TARGET_PATH=$1
|
|
86
|
+
local LINK_PATH=$2
|
|
87
|
+
|
|
88
|
+
local LINK_NAME
|
|
89
|
+
LINK_NAME=$(basename "$LINK_PATH")
|
|
90
|
+
|
|
91
|
+
local LINK_DIR
|
|
92
|
+
LINK_DIR=$(dirname "$LINK_PATH")
|
|
93
|
+
|
|
94
|
+
echo "[SYMBOLIC LINK] \"${FORMAT_BOLD}${LINK_NAME}${FORMAT_NORMAL}\""
|
|
95
|
+
|
|
96
|
+
if ! check_response "🔗 add symbolic link \"$LINK_PATH\" (pointing to target \"$TARGET_PATH\") to \"$LINK_DIR\" in \"$PWD\"?" y; then
|
|
97
|
+
return
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
if check_non_existent "$LINK_PATH" "🪠 overwrite with link?"; then
|
|
101
|
+
mkdir -p "$LINK_DIR"
|
|
102
|
+
ln -f -r -s "$PWD/$TARGET_PATH" "$LINK_PATH"
|
|
103
|
+
fi
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
make_config() {
|
|
107
|
+
local FILE_PATH=$1
|
|
108
|
+
local FILE_CONTENT=$2
|
|
109
|
+
|
|
110
|
+
local FILE_NAME
|
|
111
|
+
FILE_NAME=$(basename "$FILE_PATH")
|
|
112
|
+
|
|
113
|
+
local FILE_DIR
|
|
114
|
+
FILE_DIR=$(dirname "$FILE_PATH")
|
|
115
|
+
|
|
116
|
+
echo "[CONFIG FILE] \"${FORMAT_BOLD}${FILE_NAME}${FORMAT_NORMAL}\""
|
|
117
|
+
|
|
118
|
+
echo "🆕 new file contents:"
|
|
119
|
+
display "$FILE_CONTENT" "${FILE_NAME##*.}"
|
|
120
|
+
|
|
121
|
+
if ! check_response "📄 add config file \"$FILE_PATH\" to \"$FILE_DIR\" in \"$PWD\"?" y; then
|
|
122
|
+
return
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
if check_non_existent "$FILE_PATH" "🪠 overwrite with new contents?"; then
|
|
126
|
+
mkdir -p "$FILE_DIR"
|
|
127
|
+
echo "$FILE_CONTENT" >"$FILE_PATH"
|
|
128
|
+
fi
|
|
129
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
tmux \
|
|
4
4
|
new-session "make -s watch_lint" \; \
|
|
5
|
-
bind-key -n C-d
|
|
5
|
+
bind-key -n C-d run-shell "tmux list-panes -s -F \"#{l:#{pane_pid}}\" -f \"#{l:#{pane_start_command}}\" | xargs kill; tmux kill-session" \; \
|
|
6
6
|
bind-key -n C-Down "select-pane -D" \; \
|
|
7
7
|
bind-key -n C-Left "select-pane -L" \; \
|
|
8
8
|
bind-key -n C-Right "select-pane -R" \; \
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
tmux \
|
|
4
4
|
new-session "make -s watch_lint" \; \
|
|
5
|
-
bind-key -n C-d
|
|
5
|
+
bind-key -n C-d run-shell "tmux list-panes -s -F \"#{l:#{pane_pid}}\" -f \"#{l:#{pane_start_command}}\" | xargs kill; tmux kill-session" \; \
|
|
6
6
|
bind-key -n C-Down "select-pane -D" \; \
|
|
7
7
|
bind-key -n C-Left "select-pane -L" \; \
|
|
8
8
|
bind-key -n C-Right "select-pane -R" \; \
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"incremental": false,
|
|
4
|
+
"moduleResolution": "Node",
|
|
5
|
+
"module": "None",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
},
|
|
8
|
+
"exclude": ["dist/**/*", "node_modules/**/*", "packages/**/*", "src/**/*"],
|
|
9
|
+
"extends": "./tsconfig.json",
|
|
10
|
+
"include": ["**/*.js", "**/*.mjs"]
|
|
11
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|