Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nurlan
eepm
Commits
433de5e9
Commit
433de5e9
authored
Oct 29, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
epm-restore: add require.json (npm) support
parent
f51b0d50
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
1 deletion
+74
-1
epm-restore
bin/epm-restore
+74
-1
No files found.
bin/epm-restore
View file @
433de5e9
...
@@ -110,6 +110,76 @@ __epm_restore_pip()
...
@@ -110,6 +110,76 @@ __epm_restore_pip()
docmd epm
install
$ilist
docmd epm
install
$ilist
}
}
__epm_print_npm_list
()
{
local
reqmacro
=
"
$1
"
local
req_file
=
"
$2
"
local
l
while
read
l
;
do
# "tap": "^14.10.7"
echo
"
$l
"
|
grep
-q
'"\(.*\)": "\(.*\)"'
||
continue
local
name
=
"
$(
echo
"
$l
"
|
sed
-e
's|.*"\(.*\)": ".*|\1|'
)
"
[
-z
"
$name
"
]
&&
continue
local
ver
=
"
$(
echo
"
$l
"
|
sed
-e
's|.*"\(.*\)": "\(.*\)".*|\2|'
)
"
#'
[
-z
"
$name
"
]
&&
continue
if
[
-n
"
$dryrun
"
]
;
then
local
pi
=
''
local
sign
if
echo
"
$ver
"
|
grep
-q
"^
\^
"
;
then
sign
=
">="
else
sign
=
"="
fi
ll
=
$(
echo
"
$ver
"
|
sed
-e
's|^[^~]||'
)
pi
=
"
$pi$reqmacro
node-
$name
$sign
$ll
"
# [ -n "$pi" ] && pi="$pi
#"
# [ -n "$pi" ] || pi="$pi$reqmacro: node-$t"
echo
"
$pi
"
continue
else
local
pi
=
"node-
$name
"
#echo " $l -> $name -> $pi"
fi
[
-n
"
$name
"
]
||
continue
ilist
=
"
$ilist
$pi
"
done
<
$req_file
[
-n
"
$dryrun
"
]
||
echo
"
$ilist
"
}
__epm_restore_npm
()
{
local
req_file
=
"
$1
"
epm assure jq
if
[
-n
"
$dryrun
"
]
;
then
local
lt
=
$(
mktemp
)
a
=
jq .dependencies <
$req_file
>
$lt
echo
echo
"# generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
"
__epm_print_npm_list
"Requires:"
$lt
echo
echo
"# devDependencies generated by epm --restore --dry-run from
$(
basename
$(
dirname
$(
realpath
$req_file
)))
/
$req_file
"
a
=
jq .devDependencies <
$req_file
>
$lt
__epm_print_npm_list
"BuildRequires:"
$lt
rm
-f
$lt
return
fi
info
"Install requirements from
$req_file
..."
local
lt
=
$(
mktemp
)
a
=
jq .dependencies <
$req_file
>
$lt
ilist
=
"
$(
__epm_print_npm_list
""
$lt
)
"
a
=
jq .devDependencies <
$req_file
>
$lt
ilist
=
"
$ilist
$(
__epm_print_npm_list
""
$lt
)
"
rm
-f
$lt
docmd epm
install
$ilist
}
__epm_restore_by
()
__epm_restore_by
()
{
{
local
req_file
=
"
$1
"
local
req_file
=
"
$1
"
...
@@ -132,6 +202,9 @@ __epm_restore_by()
...
@@ -132,6 +202,9 @@ __epm_restore_by()
requirements.txt|requirements_dev.txt|requires.txt
)
requirements.txt|requirements_dev.txt|requires.txt
)
[
-s
"
$req_file
"
]
&&
__epm_restore_pip
"
$req_file
"
[
-s
"
$req_file
"
]
&&
__epm_restore_pip
"
$req_file
"
;;
;;
package.json
)
[
-s
"
$req_file
"
]
&&
__epm_restore_npm
"
$req_file
"
;;
Gemfile|package.json
)
Gemfile|package.json
)
info
"
$req_file
support is not implemented yet"
info
"
$req_file
support is not implemented yet"
;;
;;
...
@@ -158,7 +231,7 @@ epm_restore()
...
@@ -158,7 +231,7 @@ epm_restore()
# TODO: nowhere works: python3 setup.py --requires
# TODO: nowhere works: python3 setup.py --requires
# if run with empty args
# if run with empty args
for
i
in
requirements.txt requirements_dev.txt Gemfile requires.txt
;
do
for
i
in
requirements.txt requirements_dev.txt Gemfile requires.txt
package.json
;
do
__epm_restore_by
$i
__epm_restore_by
$i
done
done
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment