guess-js-deps-bash 0.1.69 → 0.1.70
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/guess-js-deps.sh +48 -33
- package/package.json +1 -1
package/guess-js-deps.sh
CHANGED
|
@@ -7,11 +7,11 @@ function guess_js_deps () {
|
|
|
7
7
|
|
|
8
8
|
local SELFPATH="$(readlink -m "$BASH_SOURCE"/..)"
|
|
9
9
|
#cd -- "$SELFPATH" || return $?
|
|
10
|
-
source "$SELFPATH"/lib_dict_util.sh --lib || exit $?
|
|
11
|
-
source "$SELFPATH"/lib_path_util.sh --lib || exit $?
|
|
10
|
+
source -- "$SELFPATH"/lib_dict_util.sh --lib || exit $?
|
|
11
|
+
source -- "$SELFPATH"/lib_path_util.sh --lib || exit $?
|
|
12
12
|
|
|
13
13
|
# import AUTOGUESS_SHEBANG_CMDS and AUTOGUESS_BUILD_UTIL_CMDS:
|
|
14
|
-
source "$SELFPATH"/autoguess_config.txt --lib || exit $?
|
|
14
|
+
source -- "$SELFPATH"/autoguess_config.txt --lib || exit $?
|
|
15
15
|
|
|
16
16
|
local DBGLV="${DEBUGLEVEL:-0}"
|
|
17
17
|
local COLORIZE_DIFF="$(can_haz_cmd colordiff)"
|
|
@@ -49,7 +49,7 @@ function guess_js_deps () {
|
|
|
49
49
|
why ) debug_why "$@"; return $?;;
|
|
50
50
|
manif ) read_json_subtree "$@"; return $?;;
|
|
51
51
|
|
|
52
|
-
list-files )
|
|
52
|
+
list-js-files ) find_project_files_with_potential_js_code; return $?;;
|
|
53
53
|
scan-all ) scan_all_scannable_files_in_project; return $?;;
|
|
54
54
|
scan-imports ) warn_no_args find_imports_in_files "$@"; return $?;;
|
|
55
55
|
scan-known ) scan_manifest_deps; return $?;;
|
|
@@ -234,16 +234,46 @@ function init_resolve_cache__forced_custom () {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
|
|
237
|
-
function
|
|
238
|
-
local
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
-o -name '*.html'
|
|
244
|
-
')'
|
|
237
|
+
function find_project_files_with_potential_js_code () {
|
|
238
|
+
local JS_FEXTS=(
|
|
239
|
+
html
|
|
240
|
+
js
|
|
241
|
+
jsm
|
|
242
|
+
mjs
|
|
245
243
|
)
|
|
246
|
-
|
|
244
|
+
find_project_files_with_fexts "${JS_FEXTS[@]}" || return $?
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
function find_project_files_with_fexts () {
|
|
249
|
+
local VAL=
|
|
250
|
+
if [ -f .git/config -o -f .git ]; then
|
|
251
|
+
VAL="$*"
|
|
252
|
+
VAL="${VAL// /'|'}"
|
|
253
|
+
# Let git deal with checking worktrees, ignored directories etc.
|
|
254
|
+
( git grep -lPe .
|
|
255
|
+
git status --porcelain -uall | cut --bytes=4-
|
|
256
|
+
) | grep -Pe '\.('"$VAL"')$' | LANG=C sort --version-sort --unique | grep .
|
|
257
|
+
return $?
|
|
258
|
+
fi
|
|
259
|
+
|
|
260
|
+
local FIND=(
|
|
261
|
+
-xdev
|
|
262
|
+
|
|
263
|
+
# Prunes:
|
|
264
|
+
'(' -false
|
|
265
|
+
-o -name .git
|
|
266
|
+
-o -name .svn
|
|
267
|
+
-o -name node_modules
|
|
268
|
+
-o -name bower_components
|
|
269
|
+
')' -prune ','
|
|
270
|
+
|
|
271
|
+
# Files we want:
|
|
272
|
+
-type f '(' -false )
|
|
273
|
+
for VAL in "$@"; do FIND+=( -o -name "*.$VAL" ); done
|
|
274
|
+
FIND+=( ')' )
|
|
275
|
+
find "${FIND[@]}"
|
|
276
|
+
return $?
|
|
247
277
|
}
|
|
248
278
|
|
|
249
279
|
|
|
@@ -255,7 +285,7 @@ function scan_all_scannable_files_in_project () {
|
|
|
255
285
|
fi
|
|
256
286
|
|
|
257
287
|
progress 'I: Searching for JavaScript files: '
|
|
258
|
-
readarray -t IMPORTS < <(
|
|
288
|
+
readarray -t IMPORTS < <(find_project_files_with_potential_js_code)
|
|
259
289
|
progress "found ${#IMPORTS[@]}"
|
|
260
290
|
|
|
261
291
|
progress 'I: Searching for require()s/imports: '
|
|
@@ -316,7 +346,7 @@ function find_imports_in_project () {
|
|
|
316
346
|
|
|
317
347
|
function find_manif_script_deps () {
|
|
318
348
|
local SCRIPTS=()
|
|
319
|
-
readarray -t SCRIPTS < <(
|
|
349
|
+
readarray -t SCRIPTS < <(find_project_files_with_fexts sh)
|
|
320
350
|
( </dev/null grep -HvPe '^\s*(#[^!]|$)' -- "${SCRIPTS[@]}"
|
|
321
351
|
read_json_subtree '' .scripts | sed -nre '
|
|
322
352
|
s~^\s*"([^"]+)": "~\v<manif>scripts/\1 ~p'
|
|
@@ -671,18 +701,6 @@ function node_detect_manif_version () {
|
|
|
671
701
|
}
|
|
672
702
|
|
|
673
703
|
|
|
674
|
-
function fastfind () {
|
|
675
|
-
local PRUNES=( '(' -false
|
|
676
|
-
-o -name .git
|
|
677
|
-
-o -name .svn
|
|
678
|
-
-o -name node_modules
|
|
679
|
-
-o -name bower_components
|
|
680
|
-
')' -prune ',' )
|
|
681
|
-
find -xdev "${PRUNES[@]}" "$@"
|
|
682
|
-
return $?
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
686
704
|
function find_imports_in_files () {
|
|
687
705
|
[ "$#" == 0 ] && return 0
|
|
688
706
|
eval "$(init_resolve_cache)"
|
|
@@ -731,12 +749,7 @@ function remove_paths_from_module_ids () {
|
|
|
731
749
|
|
|
732
750
|
function find_simple_html_script_deps () {
|
|
733
751
|
progress 'I: Searching for HTML files: ' >&2
|
|
734
|
-
|
|
735
|
-
-type f
|
|
736
|
-
'(' -name '*.html'
|
|
737
|
-
')'
|
|
738
|
-
)
|
|
739
|
-
readarray -t LIST < <(fastfind "${LIST[@]}")
|
|
752
|
+
readarray -t LIST < <(find_project_files_with_fexts html)
|
|
740
753
|
progress "found ${#LIST[@]}" >&2
|
|
741
754
|
[ "${#LIST[@]}" == 0 ] && return 0
|
|
742
755
|
local SRC_FN= TAGS= DEP=
|
|
@@ -870,6 +883,8 @@ function guess_one_dep_type () {
|
|
|
870
883
|
# as well as any subdir.
|
|
871
884
|
|
|
872
885
|
*[.-]test.%JS | \
|
|
886
|
+
*/.babelrc | \
|
|
887
|
+
*/test/* | \
|
|
873
888
|
*/webpack.config.%JS | \
|
|
874
889
|
. ) DEP_TYPE=devDep;;
|
|
875
890
|
esac
|
package/package.json
CHANGED