@hyperupcall/eslint-config 0.9.1 → 0.10.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/README.md +4 -1
- package/dist/eslintrc.cjs +43 -0
- package/dist/eslintrc.mjs +41 -0
- package/package.json +12 -4
- package/.editorconfig +0 -8
- package/.eslintrc.cjs +0 -27
- package/.eslintrc.mjs +0 -27
- package/.gitattributes +0 -5
- package/.hidden/index.js +0 -2
- package/.markdownlint.json +0 -3
- package/.prettierrc.json +0 -1
- package/Bakefile.sh +0 -12
- package/bake +0 -459
- package/project.toml +0 -2
package/README.md
CHANGED
|
@@ -5,7 +5,10 @@ Edwin's [ESLint](https://eslint.org) configuration.
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
pnpm i -D eslint
|
|
8
|
+
pnpm i -D eslint \
|
|
9
|
+
eslint-config-prettier \
|
|
10
|
+
eslint-plugin-import eslint-plugin-markdown eslint-plugin-promise eslint-plugin-n eslint-plugin-unicorn eslint-plugin-security @eslint-community/eslint-plugin-eslint-comments \
|
|
11
|
+
@hyperupcall/eslint-config
|
|
9
12
|
```
|
|
10
13
|
|
|
11
14
|
## Usage
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
function getDefaultExportFromCjs (x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var src = {
|
|
8
|
+
extends: [
|
|
9
|
+
'eslint:recommended',
|
|
10
|
+
'plugin:import/recommended',
|
|
11
|
+
'plugin:markdown/recommended',
|
|
12
|
+
'plugin:promise/recommended',
|
|
13
|
+
'plugin:n/recommended',
|
|
14
|
+
'plugin:unicorn/recommended',
|
|
15
|
+
// 'plugin:security/recommended-legacy',
|
|
16
|
+
"plugin:@eslint-community/eslint-comments/recommended",
|
|
17
|
+
'eslint-config-prettier'
|
|
18
|
+
],
|
|
19
|
+
env: {
|
|
20
|
+
'shared-node-browser': true,
|
|
21
|
+
es2022: true
|
|
22
|
+
},
|
|
23
|
+
parserOptions: {
|
|
24
|
+
ecmaVersion: 2022,
|
|
25
|
+
sourceType: 'module'
|
|
26
|
+
},
|
|
27
|
+
overrides: [
|
|
28
|
+
{
|
|
29
|
+
files: [
|
|
30
|
+
'*.cjs'
|
|
31
|
+
],
|
|
32
|
+
env: {
|
|
33
|
+
commonjs: true
|
|
34
|
+
},
|
|
35
|
+
parserOptions: {
|
|
36
|
+
sourceType: 'script'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
var index = /*@__PURE__*/ getDefaultExportFromCjs(src);
|
|
42
|
+
|
|
43
|
+
exports.default = index;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function getDefaultExportFromCjs (x) {
|
|
2
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
var src = {
|
|
6
|
+
extends: [
|
|
7
|
+
'eslint:recommended',
|
|
8
|
+
'plugin:import/recommended',
|
|
9
|
+
'plugin:markdown/recommended',
|
|
10
|
+
'plugin:promise/recommended',
|
|
11
|
+
'plugin:n/recommended',
|
|
12
|
+
'plugin:unicorn/recommended',
|
|
13
|
+
// 'plugin:security/recommended-legacy',
|
|
14
|
+
"plugin:@eslint-community/eslint-comments/recommended",
|
|
15
|
+
'eslint-config-prettier'
|
|
16
|
+
],
|
|
17
|
+
env: {
|
|
18
|
+
'shared-node-browser': true,
|
|
19
|
+
es2022: true
|
|
20
|
+
},
|
|
21
|
+
parserOptions: {
|
|
22
|
+
ecmaVersion: 2022,
|
|
23
|
+
sourceType: 'module'
|
|
24
|
+
},
|
|
25
|
+
overrides: [
|
|
26
|
+
{
|
|
27
|
+
files: [
|
|
28
|
+
'*.cjs'
|
|
29
|
+
],
|
|
30
|
+
env: {
|
|
31
|
+
commonjs: true
|
|
32
|
+
},
|
|
33
|
+
parserOptions: {
|
|
34
|
+
sourceType: 'script'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
};
|
|
39
|
+
var index = /*@__PURE__*/ getDefaultExportFromCjs(src);
|
|
40
|
+
|
|
41
|
+
export { index as default };
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperupcall/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"./dist/eslintrc.cjs",
|
|
6
|
+
"./dist/eslintrc.mjs"
|
|
7
|
+
],
|
|
4
8
|
"license": "MPL-2.0",
|
|
5
9
|
"exports": {
|
|
6
|
-
"import": "
|
|
7
|
-
"require": "
|
|
10
|
+
"import": "./dist/eslintrc.mjs",
|
|
11
|
+
"require": "./dist/eslintrc.cjs"
|
|
8
12
|
},
|
|
9
13
|
"peerDependencies": {
|
|
10
14
|
"eslint": ">=8.0.0",
|
|
@@ -13,10 +17,13 @@
|
|
|
13
17
|
"devDependencies": {
|
|
14
18
|
"@hyperupcall/markdownlint-config": "^0.3.2",
|
|
15
19
|
"@hyperupcall/prettier-config": "^0.7.0",
|
|
20
|
+
"bunchee": "^4.1.1",
|
|
16
21
|
"eslint": "^8.18.0",
|
|
17
22
|
"eslint-config-prettier": "^8.5.0",
|
|
23
|
+
"eslint-plugin-import": "^2.29.0",
|
|
24
|
+
"eslint-plugin-markdown": "^3.0.1",
|
|
18
25
|
"markdownlint": "^0.32.1",
|
|
19
|
-
"prettier": "^3.1.
|
|
26
|
+
"prettier": "^3.1.1",
|
|
20
27
|
"prettier-plugin-pkg": "^0.18.0"
|
|
21
28
|
},
|
|
22
29
|
"description": "Edwin's ESLint configuration.",
|
|
@@ -29,6 +36,7 @@
|
|
|
29
36
|
"url": "https://github.com/fox-land/eslint-config-hyperupcall.git"
|
|
30
37
|
},
|
|
31
38
|
"scripts": {
|
|
39
|
+
"build": "bunchee",
|
|
32
40
|
"lint": "eslint .",
|
|
33
41
|
"format": "prettier --check ."
|
|
34
42
|
}
|
package/.editorconfig
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
extends: [
|
|
4
|
-
'eslint:recommended',
|
|
5
|
-
'plugin:import/recommended',
|
|
6
|
-
'plugin:markdown/recommended',
|
|
7
|
-
'eslint-config-prettier',
|
|
8
|
-
],
|
|
9
|
-
env: {
|
|
10
|
-
'shared-node-browser': true,
|
|
11
|
-
es2022: true, // Supported by Node.js v18
|
|
12
|
-
},
|
|
13
|
-
parserOptions: {
|
|
14
|
-
sourceType: 'module',
|
|
15
|
-
},
|
|
16
|
-
overrides: [
|
|
17
|
-
{
|
|
18
|
-
files: ['*.cjs'],
|
|
19
|
-
env: {
|
|
20
|
-
commonjs: true,
|
|
21
|
-
},
|
|
22
|
-
parserOptions: {
|
|
23
|
-
sourceType: 'script',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
}
|
package/.eslintrc.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @type {import('eslint').ESLint.ConfigData} */
|
|
2
|
-
export default {
|
|
3
|
-
extends: [
|
|
4
|
-
'eslint:recommended',
|
|
5
|
-
'plugin:import/recommended',
|
|
6
|
-
'plugin:markdown/recommended',
|
|
7
|
-
'eslint-config-prettier',
|
|
8
|
-
],
|
|
9
|
-
env: {
|
|
10
|
-
'shared-node-browser': true,
|
|
11
|
-
es2022: true, // Supported by Node.js v18
|
|
12
|
-
},
|
|
13
|
-
parserOptions: {
|
|
14
|
-
sourceType: 'module',
|
|
15
|
-
},
|
|
16
|
-
overrides: [
|
|
17
|
-
{
|
|
18
|
-
files: ['*.cjs'],
|
|
19
|
-
env: {
|
|
20
|
-
commonjs: true,
|
|
21
|
-
},
|
|
22
|
-
parserOptions: {
|
|
23
|
-
sourceType: 'script',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
}
|
package/.gitattributes
DELETED
package/.hidden/index.js
DELETED
package/.markdownlint.json
DELETED
package/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"@hyperupcall/prettier-config"
|
package/Bakefile.sh
DELETED
package/bake
DELETED
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# @name Bake
|
|
4
|
-
# @brief Bake: A Bash-based Make alternative
|
|
5
|
-
# @description Bake is a dead-simple task runner used to quickly cobble together shell scripts
|
|
6
|
-
#
|
|
7
|
-
# In a few words, Bake lets you call the following 'print' task with './bake print'
|
|
8
|
-
#
|
|
9
|
-
# ```bash
|
|
10
|
-
# #!/usr/bin/env bash
|
|
11
|
-
# task.print() {
|
|
12
|
-
# printf '%s\n' 'Contrived example'
|
|
13
|
-
# }
|
|
14
|
-
# ```
|
|
15
|
-
#
|
|
16
|
-
# Learn more about it [on GitHub](https://github.com/hyperupcall/bake)
|
|
17
|
-
|
|
18
|
-
if [ "$0" != "${BASH_SOURCE[0]}" ] && [ "$BAKE_INTERNAL_CAN_SOURCE" != 'yes' ]; then
|
|
19
|
-
printf '%s\n' 'Error: This file should not be sourced' >&2
|
|
20
|
-
return 1
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
# @description Prints `$1` formatted as an error and the stacktrace to standard error,
|
|
24
|
-
# then exits with code 1
|
|
25
|
-
# @arg $1 string Text to print
|
|
26
|
-
bake.die() {
|
|
27
|
-
if [ -n "$1" ]; then
|
|
28
|
-
__bake_error "$1. Exiting"
|
|
29
|
-
else
|
|
30
|
-
__bake_error 'Exiting'
|
|
31
|
-
fi
|
|
32
|
-
__bake_print_big '<- ERROR'
|
|
33
|
-
|
|
34
|
-
__bake_print_stacktrace
|
|
35
|
-
|
|
36
|
-
exit 1
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
# @description Prints `$1` formatted as a warning to standard error
|
|
40
|
-
# @arg $1 string Text to print
|
|
41
|
-
bake.warn() {
|
|
42
|
-
if __bake_is_color; then
|
|
43
|
-
printf "\033[1;33m%s:\033[0m %s\n" 'Warn' "$1"
|
|
44
|
-
else
|
|
45
|
-
printf '%s: %s\n' 'Warn' "$1"
|
|
46
|
-
fi
|
|
47
|
-
} >&2
|
|
48
|
-
|
|
49
|
-
# @description Prints `$1` formatted as information to standard output
|
|
50
|
-
# @arg $1 string Text to print
|
|
51
|
-
bake.info() {
|
|
52
|
-
if __bake_is_color; then
|
|
53
|
-
printf "\033[0;34m%s:\033[0m %s\n" 'Info' "$1"
|
|
54
|
-
else
|
|
55
|
-
printf '%s: %s\n' 'Info' "$1"
|
|
56
|
-
fi
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
# @description Dies if any of the supplied variables are empty. Deprecated in favor of 'bake.assert_not_empty'
|
|
60
|
-
# @arg $@ string Names of variables to check for emptiness
|
|
61
|
-
# @see bake.assert_not_empty
|
|
62
|
-
bake.assert_nonempty() {
|
|
63
|
-
__bake_internal_warn "Function 'bake.assert_nonempty' is deprecated. Please use 'bake.assert_not_empty' instead"
|
|
64
|
-
bake.assert_not_empty "$@"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
# @description Dies if any of the supplied variables are empty
|
|
68
|
-
# @arg $@ string Names of variables to check for emptiness
|
|
69
|
-
bake.assert_not_empty() {
|
|
70
|
-
local variable_name=
|
|
71
|
-
for variable_name; do
|
|
72
|
-
local -n ____variable="$variable_name"
|
|
73
|
-
|
|
74
|
-
if [ -z "$____variable" ]; then
|
|
75
|
-
bake.die "Failed because variable '$variable_name' is empty"
|
|
76
|
-
fi
|
|
77
|
-
done; unset -v variable_name
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# @description Dies if a command cannot be found
|
|
81
|
-
# @arg $1 string Command name to test for existence
|
|
82
|
-
bake.assert_cmd() {
|
|
83
|
-
local cmd=$1
|
|
84
|
-
|
|
85
|
-
if [ -z "$cmd" ]; then
|
|
86
|
-
bake.die "Argument must not be empty"
|
|
87
|
-
fi
|
|
88
|
-
|
|
89
|
-
if ! command -v "$cmd" &>/dev/null; then
|
|
90
|
-
bake.die "Failed to find command '$cmd'. Please install it before continuing"
|
|
91
|
-
fi
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
# @description Change the behavior of Bake. See [guide.md](./docs/guide.md) for details
|
|
95
|
-
# @arg $1 string Name of config property to change
|
|
96
|
-
# @arg $2 string New value of config property
|
|
97
|
-
bake.cfg() {
|
|
98
|
-
local cfg="$1"
|
|
99
|
-
local value="$2"
|
|
100
|
-
|
|
101
|
-
case $cfg in
|
|
102
|
-
stacktrace)
|
|
103
|
-
case $value in
|
|
104
|
-
yes|no) __bake_cfg_stacktrace=$value ;;
|
|
105
|
-
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'yes' or 'no'" ;;
|
|
106
|
-
esac
|
|
107
|
-
;;
|
|
108
|
-
pedantic-task-cd)
|
|
109
|
-
case $value in
|
|
110
|
-
yes) trap '__bake_trap_debug' 'DEBUG' ;;
|
|
111
|
-
no) trap - 'DEBUG' ;;
|
|
112
|
-
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'yes' or 'no'" ;;
|
|
113
|
-
esac
|
|
114
|
-
;;
|
|
115
|
-
big-print)
|
|
116
|
-
case $value in
|
|
117
|
-
yes|no) ;;
|
|
118
|
-
*) __bake_internal_die2 "Config property '$cfg' accepts only either 'yes' or 'no'" ;;
|
|
119
|
-
esac
|
|
120
|
-
;;
|
|
121
|
-
*)
|
|
122
|
-
__bake_internal_die2 "No config property matched '$cfg'"
|
|
123
|
-
;;
|
|
124
|
-
esac
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
# @description Prints stacktrace
|
|
128
|
-
# @internal
|
|
129
|
-
__bake_print_stacktrace() {
|
|
130
|
-
if [ "$__bake_cfg_stacktrace" = 'yes' ]; then
|
|
131
|
-
if __bake_is_color; then
|
|
132
|
-
printf '\033[4m%s\033[0m\n' 'Stacktrace:'
|
|
133
|
-
else
|
|
134
|
-
printf '%s\n' 'Stacktrace:'
|
|
135
|
-
fi
|
|
136
|
-
|
|
137
|
-
local i=
|
|
138
|
-
for ((i=0; i<${#FUNCNAME[@]}-1; ++i)); do
|
|
139
|
-
local __bash_source="${BASH_SOURCE[$i]}"; __bash_source=${__bash_source##*/}
|
|
140
|
-
printf '%s\n' " in ${FUNCNAME[$i]} ($__bash_source:${BASH_LINENO[$i-1]})"
|
|
141
|
-
done; unset -v i __bash_source
|
|
142
|
-
fi
|
|
143
|
-
} >&2
|
|
144
|
-
|
|
145
|
-
# @description Function that is executed when the 'ERR' event is trapped
|
|
146
|
-
# @internal
|
|
147
|
-
__bake_trap_err() {
|
|
148
|
-
local error_code=$?
|
|
149
|
-
|
|
150
|
-
__bake_print_big "<- ERROR"
|
|
151
|
-
__bake_internal_error "Your Bakefile did not exit successfully (exit code $error_code)"
|
|
152
|
-
__bake_print_stacktrace
|
|
153
|
-
|
|
154
|
-
exit $error_code
|
|
155
|
-
} >&2
|
|
156
|
-
|
|
157
|
-
__global_bake_trap_debug_current_function=
|
|
158
|
-
__bake_trap_debug() {
|
|
159
|
-
local current_function="${FUNCNAME[1]}"
|
|
160
|
-
|
|
161
|
-
if [[ $current_function != "$__global_bake_trap_debug_current_function" \
|
|
162
|
-
&& $current_function == task.* ]]; then
|
|
163
|
-
if ! cd "$BAKE_ROOT"; then
|
|
164
|
-
__bake_internal_die "Failed to cd to \$BAKE_ROOT"
|
|
165
|
-
fi
|
|
166
|
-
fi
|
|
167
|
-
|
|
168
|
-
__global_bake_trap_debug_current_function=$current_function
|
|
169
|
-
} >&2
|
|
170
|
-
|
|
171
|
-
# @description Test whether color should be outputed
|
|
172
|
-
# @exitcode 0 if should print color
|
|
173
|
-
# @exitcode 1 if should not print color
|
|
174
|
-
# @internal
|
|
175
|
-
__bake_is_color() {
|
|
176
|
-
if [[ -v NO_COLOR || $TERM == dumb ]]; then
|
|
177
|
-
return 1
|
|
178
|
-
else
|
|
179
|
-
return 0
|
|
180
|
-
fi
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
# @description Calls `__bake_internal_error` and terminates with code 1
|
|
184
|
-
# @arg $1 string Text to print
|
|
185
|
-
# @internal
|
|
186
|
-
__bake_internal_die() {
|
|
187
|
-
__bake_internal_error "$1. Exiting"
|
|
188
|
-
exit 1
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
# @description Calls `__bake_internal_error` and terminates with code 1. Before
|
|
192
|
-
# doing so, it closes with "<- ERROR" big text
|
|
193
|
-
# @arg $1 string Text to print
|
|
194
|
-
# @internal
|
|
195
|
-
__bake_internal_die2() {
|
|
196
|
-
__bake_print_big '<- ERROR'
|
|
197
|
-
|
|
198
|
-
__bake_internal_error "$1. Exiting"
|
|
199
|
-
exit 1
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
# @description Prints `$1` formatted as an internal Bake error to standard error
|
|
203
|
-
# @arg $1 Text to print
|
|
204
|
-
# @internal
|
|
205
|
-
__bake_internal_error() {
|
|
206
|
-
if __bake_is_color; then
|
|
207
|
-
printf "\033[0;31m%s:\033[0m %s\n" "Error (bake)" "$1"
|
|
208
|
-
else
|
|
209
|
-
printf '%s: %s\n' 'Error (bake)' "$1"
|
|
210
|
-
fi
|
|
211
|
-
} >&2
|
|
212
|
-
|
|
213
|
-
# @description Prints `$1` formatted as an internal Bake warning to standard error
|
|
214
|
-
# @arg $1 Text to print
|
|
215
|
-
# @internal
|
|
216
|
-
__bake_internal_warn() {
|
|
217
|
-
if __bake_is_color; then
|
|
218
|
-
printf "\033[0;33m%s:\033[0m %s\n" "Warn (bake)" "$1"
|
|
219
|
-
else
|
|
220
|
-
printf '%s: %s\n' 'Warn (bake)' "$1"
|
|
221
|
-
fi
|
|
222
|
-
} >&2
|
|
223
|
-
|
|
224
|
-
# @description Prints `$1` formatted as an error to standard error. This is not called because
|
|
225
|
-
# I do not wish to surface a public 'bake.error' function. All errors should halt execution
|
|
226
|
-
# @arg $1 string Text to print
|
|
227
|
-
# @internal
|
|
228
|
-
__bake_error() {
|
|
229
|
-
if __bake_is_color; then
|
|
230
|
-
printf "\033[0;31m%s:\033[0m %s\n" 'Error' "$1"
|
|
231
|
-
else
|
|
232
|
-
printf '%s: %s\n' 'Error' "$1"
|
|
233
|
-
fi
|
|
234
|
-
} >&2
|
|
235
|
-
|
|
236
|
-
# @description Nicely prints all 'Bakefile.sh' tasks to standard output
|
|
237
|
-
# @internal
|
|
238
|
-
__bake_print_tasks() {
|
|
239
|
-
printf '%s\n' 'Tasks:'
|
|
240
|
-
local str=
|
|
241
|
-
|
|
242
|
-
# shellcheck disable=SC1007,SC2034
|
|
243
|
-
local regex="^(([[:space:]]*function[[:space:]]*)?task\.(.*?)\(\)).*"
|
|
244
|
-
local line=
|
|
245
|
-
while IFS= read -r line || [ -n "$line" ]; do
|
|
246
|
-
if [[ "$line" =~ $regex ]]; then
|
|
247
|
-
str+=" -> ${BASH_REMATCH[3]}"$'\n'
|
|
248
|
-
fi
|
|
249
|
-
done < "$BAKE_FILE"; unset -v line
|
|
250
|
-
|
|
251
|
-
if [ -z "$str" ]; then
|
|
252
|
-
if __bake_is_color; then
|
|
253
|
-
str=$' \033[3mNo tasks\033[0m\n'
|
|
254
|
-
else
|
|
255
|
-
str=$' No tasks\n'
|
|
256
|
-
fi
|
|
257
|
-
fi
|
|
258
|
-
|
|
259
|
-
printf '%s' "$str"
|
|
260
|
-
} >&2
|
|
261
|
-
|
|
262
|
-
# @description Prints text that takes up the whole terminal width
|
|
263
|
-
# @arg $1 string Text to print
|
|
264
|
-
# @internal
|
|
265
|
-
__bake_print_big() {
|
|
266
|
-
local print_text="$1"
|
|
267
|
-
|
|
268
|
-
if [ "$__bake_cfg_big_print" = 'no' ]; then
|
|
269
|
-
return
|
|
270
|
-
fi
|
|
271
|
-
|
|
272
|
-
# shellcheck disable=SC1007
|
|
273
|
-
local _stty_height= _stty_width=
|
|
274
|
-
read -r _stty_height _stty_width < <(
|
|
275
|
-
if command -v stty &>/dev/null; then
|
|
276
|
-
stty size
|
|
277
|
-
else
|
|
278
|
-
printf '%s\n' '20 80'
|
|
279
|
-
fi
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
local separator_text=
|
|
283
|
-
# shellcheck disable=SC2183
|
|
284
|
-
printf -v separator_text '%*s' $((_stty_width - ${#print_text} - 1))
|
|
285
|
-
printf -v separator_text '%s' "${separator_text// /=}"
|
|
286
|
-
if __bake_is_color; then
|
|
287
|
-
printf '\033[1m%s %s\033[0m\n' "$print_text" "$separator_text"
|
|
288
|
-
else
|
|
289
|
-
printf '%s %s\n' "$print_text" "$separator_text"
|
|
290
|
-
fi
|
|
291
|
-
} >&2
|
|
292
|
-
|
|
293
|
-
# @description Parses the arguments. This also includes setting the the 'BAKE_ROOT'
|
|
294
|
-
# and 'BAKE_FILE' variables
|
|
295
|
-
# @set REPLY Number of times to shift
|
|
296
|
-
# @internal
|
|
297
|
-
__bake_parse_args() {
|
|
298
|
-
unset REPLY; REPLY=
|
|
299
|
-
local -i total_shifts=0
|
|
300
|
-
|
|
301
|
-
# FIXME: bug for when passing -v to child task argument
|
|
302
|
-
local __bake_arg=
|
|
303
|
-
for arg; do case $arg in
|
|
304
|
-
-f)
|
|
305
|
-
BAKE_FILE=$2
|
|
306
|
-
if [ -z "$BAKE_FILE" ]; then
|
|
307
|
-
__bake_internal_die "A value was not specified for for flag '-f"
|
|
308
|
-
fi
|
|
309
|
-
((total_shifts += 2))
|
|
310
|
-
if ! shift 2; then
|
|
311
|
-
__bake_internal_die 'Failed to shift'
|
|
312
|
-
fi
|
|
313
|
-
|
|
314
|
-
if [ ! -e "$BAKE_FILE" ]; then
|
|
315
|
-
__bake_internal_die "Specified file '$BAKE_FILE' does not exist"
|
|
316
|
-
fi
|
|
317
|
-
if [ ! -f "$BAKE_FILE" ]; then
|
|
318
|
-
__bake_internal_die "Specified file '$BAKE_FILE' is not actually a file"
|
|
319
|
-
fi
|
|
320
|
-
;;
|
|
321
|
-
-v)
|
|
322
|
-
local bake_version='1.7.0'
|
|
323
|
-
printf '%s\n' "Version: $bake_version"
|
|
324
|
-
;;
|
|
325
|
-
-h)
|
|
326
|
-
local flag_help='yes'
|
|
327
|
-
if ! shift; then
|
|
328
|
-
__bake_internal_die 'Failed to shift'
|
|
329
|
-
fi
|
|
330
|
-
esac done
|
|
331
|
-
|
|
332
|
-
if [ -n "$BAKE_FILE" ]; then
|
|
333
|
-
BAKE_ROOT=$(
|
|
334
|
-
# shellcheck disable=SC1007
|
|
335
|
-
CDPATH= cd -- "${BAKE_FILE%/*}"
|
|
336
|
-
printf '%s\n' "$PWD"
|
|
337
|
-
)
|
|
338
|
-
BAKE_FILE="$BAKE_ROOT/${BAKE_FILE##*/}"
|
|
339
|
-
else
|
|
340
|
-
if ! BAKE_ROOT=$(
|
|
341
|
-
while [ ! -f './Bakefile.sh' ] && [ "$PWD" != / ]; do
|
|
342
|
-
if ! cd ..; then
|
|
343
|
-
exit 1
|
|
344
|
-
fi
|
|
345
|
-
done
|
|
346
|
-
|
|
347
|
-
if [ "$PWD" = / ]; then
|
|
348
|
-
exit 1
|
|
349
|
-
fi
|
|
350
|
-
|
|
351
|
-
printf '%s' "$PWD"
|
|
352
|
-
); then
|
|
353
|
-
__bake_internal_die "Failed to find 'Bakefile.sh'"
|
|
354
|
-
fi
|
|
355
|
-
BAKE_FILE="$BAKE_ROOT/Bakefile.sh"
|
|
356
|
-
fi
|
|
357
|
-
|
|
358
|
-
if [ "$flag_help" = 'yes' ]; then
|
|
359
|
-
cat <<-"EOF"
|
|
360
|
-
Usage: bake [-h|-v] [-f <Bakefile>] [var=value ...] <task> [args ...]
|
|
361
|
-
EOF
|
|
362
|
-
__bake_print_tasks
|
|
363
|
-
exit
|
|
364
|
-
fi
|
|
365
|
-
|
|
366
|
-
REPLY=$total_shifts
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
# @description Main function
|
|
370
|
-
# @internal
|
|
371
|
-
__bake_main() {
|
|
372
|
-
__bake_cfg_stacktrace='no'
|
|
373
|
-
__bake_cfg_big_print='yes'
|
|
374
|
-
|
|
375
|
-
# Environment boilerplate
|
|
376
|
-
set -ETeo pipefail
|
|
377
|
-
shopt -s dotglob extglob globasciiranges globstar lastpipe shift_verbose
|
|
378
|
-
export LANG='C' LC_CTYPE='C' LC_NUMERIC='C' LC_TIME='C' LC_COLLATE='C' \
|
|
379
|
-
LC_MONETARY='C' LC_MESSAGES='C' LC_PAPER='C' LC_NAME='C' LC_ADDRESS='C' \
|
|
380
|
-
LC_TELEPHONE='C' LC_MEASUREMENT='C' LC_IDENTIFICATION='C' LC_ALL='C'
|
|
381
|
-
trap '__bake_trap_err' 'ERR'
|
|
382
|
-
bake.cfg pedantic-task-cd 'no'
|
|
383
|
-
|
|
384
|
-
# Parse arguments
|
|
385
|
-
# Set `BAKE_{ROOT,FILE}`
|
|
386
|
-
BAKE_ROOT=; BAKE_FILE=
|
|
387
|
-
__bake_parse_args "$@"
|
|
388
|
-
if ! shift "$REPLY"; then
|
|
389
|
-
__bake_internal_die 'Failed to shift'
|
|
390
|
-
fi
|
|
391
|
-
|
|
392
|
-
# Set variables à la Make
|
|
393
|
-
# shellcheck disable=SC1007
|
|
394
|
-
local __bake_key= __bake_value=
|
|
395
|
-
local __bake_arg=
|
|
396
|
-
for __bake_arg; do case $__bake_arg in
|
|
397
|
-
*=*)
|
|
398
|
-
IFS='=' read -r __bake_key __bake_value <<< "$__bake_arg"
|
|
399
|
-
|
|
400
|
-
declare -g "$__bake_key"
|
|
401
|
-
local -n __bake_variable="$__bake_key"
|
|
402
|
-
__bake_variable="$__bake_value"
|
|
403
|
-
|
|
404
|
-
if ! shift; then
|
|
405
|
-
__bake_internal_die 'Failed to shift'
|
|
406
|
-
fi
|
|
407
|
-
;;
|
|
408
|
-
*) break
|
|
409
|
-
esac done; unset -v __bake_arg
|
|
410
|
-
unset -v __bake_key __bake_value
|
|
411
|
-
unset -vn __bake_variable
|
|
412
|
-
|
|
413
|
-
local __bake_task="$1"
|
|
414
|
-
if [ -z "$__bake_task" ]; then
|
|
415
|
-
__bake_internal_error "No valid task supplied"
|
|
416
|
-
__bake_print_tasks
|
|
417
|
-
exit 1
|
|
418
|
-
fi
|
|
419
|
-
if ! shift; then
|
|
420
|
-
__bake_internal_die 'Failed to shift'
|
|
421
|
-
fi
|
|
422
|
-
|
|
423
|
-
if ! cd "$BAKE_ROOT"; then
|
|
424
|
-
__bake_internal_die "Failed to cd"
|
|
425
|
-
fi
|
|
426
|
-
|
|
427
|
-
# shellcheck disable=SC2097,SC1007,SC1090
|
|
428
|
-
__bake_task= source "$BAKE_FILE"
|
|
429
|
-
|
|
430
|
-
if declare -f task."$__bake_task" >/dev/null 2>&1; then
|
|
431
|
-
local line=
|
|
432
|
-
local shouldTestNextLine='no'
|
|
433
|
-
while IFS= read -r line; do
|
|
434
|
-
if [ "$shouldTestNextLine" = 'yes' ]; then
|
|
435
|
-
if [[ $line == *'bake.cfg'*big-print*no* ]]; then
|
|
436
|
-
__bake_cfg_big_print='no'
|
|
437
|
-
fi
|
|
438
|
-
shouldTestNextLine='no'
|
|
439
|
-
fi
|
|
440
|
-
|
|
441
|
-
if [[ $line == @(task."$__bake_task"|init)*'('*')'*'{' ]]; then
|
|
442
|
-
shouldTestNextLine='yes'
|
|
443
|
-
fi
|
|
444
|
-
done < "$BAKE_FILE"; unset -v line shouldTestNextLine
|
|
445
|
-
|
|
446
|
-
__bake_print_big "-> RUNNING TASK '$__bake_task'"
|
|
447
|
-
if declare -f init >/dev/null 2>&1; then
|
|
448
|
-
init "$__bake_task"
|
|
449
|
-
fi
|
|
450
|
-
task."$__bake_task" "$@"
|
|
451
|
-
__bake_print_big "<- DONE"
|
|
452
|
-
else
|
|
453
|
-
__bake_internal_error "Task '$__bake_task' not found"
|
|
454
|
-
__bake_print_tasks
|
|
455
|
-
exit 1
|
|
456
|
-
fi
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
__bake_main "$@"
|
package/project.toml
DELETED