Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
devcontainer-features
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eazydevelop-devcontainer-temp
devcontainer-features
Commits
95a169b9
Unverified
Commit
95a169b9
authored
Aug 28, 2023
by
eitsupi
Committed by
GitHub
Aug 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[node] Install the latest version of nvm by default (#673)
feat(node): install the latest nvm by default
parent
0668db5e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
5 deletions
+71
-5
devcontainer-feature.json
src/node/devcontainer-feature.json
+7
-3
install.sh
src/node/install.sh
+41
-1
install_nvm_0.39.sh
test/node/install_nvm_0.39.sh
+14
-0
scenarios.json
test/node/scenarios.json
+9
-1
No files found.
src/node/devcontainer-feature.json
View file @
95a169b9
{
{
"id"
:
"node"
,
"id"
:
"node"
,
"version"
:
"1.
2.1
"
,
"version"
:
"1.
3.0
"
,
"name"
:
"Node.js (via nvm), yarn and pnpm"
,
"name"
:
"Node.js (via nvm), yarn and pnpm"
,
"documentationURL"
:
"https://github.com/devcontainers/features/tree/main/src/node"
,
"documentationURL"
:
"https://github.com/devcontainers/features/tree/main/src/node"
,
"description"
:
"Installs Node.js, nvm, yarn, pnpm, and needed dependencies."
,
"description"
:
"Installs Node.js, nvm, yarn, pnpm, and needed dependencies."
,
...
@@ -30,7 +30,11 @@
...
@@ -30,7 +30,11 @@
},
},
"nvmVersion"
:
{
"nvmVersion"
:
{
"type"
:
"string"
,
"type"
:
"string"
,
"default"
:
"0.39.2"
,
"proposals"
:
[
"latest"
,
"0.39"
],
"default"
:
"latest"
,
"description"
:
"Version of NVM to install."
"description"
:
"Version of NVM to install."
}
}
},
},
...
...
src/node/install.sh
View file @
95a169b9
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
# Maintainer: The Dev Container spec maintainers
# Maintainer: The Dev Container spec maintainers
export
NODE_VERSION
=
"
${
VERSION
:-
"lts"
}
"
export
NODE_VERSION
=
"
${
VERSION
:-
"lts"
}
"
export
NVM_VERSION
=
"
${
NVMVERSION
:-
"
0.39.2
"
}
"
export
NVM_VERSION
=
"
${
NVMVERSION
:-
"
latest
"
}
"
export
NVM_DIR
=
"
${
NVMINSTALLPATH
:-
"/usr/local/share/nvm"
}
"
export
NVM_DIR
=
"
${
NVMINSTALLPATH
:-
"/usr/local/share/nvm"
}
"
INSTALL_TOOLS_FOR_NODE_GYP
=
"
${
NODEGYPDEPENDENCIES
:-
true
}
"
INSTALL_TOOLS_FOR_NODE_GYP
=
"
${
NODEGYPDEPENDENCIES
:-
true
}
"
...
@@ -78,6 +78,40 @@ check_packages() {
...
@@ -78,6 +78,40 @@ check_packages() {
fi
fi
}
}
# Figure out correct version of a three part version number is not passed
find_version_from_git_tags
()
{
local
variable_name
=
$1
local
requested_version
=
${
!variable_name
}
if
[
"
${
requested_version
}
"
=
"none"
]
;
then return
;
fi
local
repository
=
$2
local
prefix
=
${
3
:-
"tags/v"
}
local
separator
=
${
4
:-
"."
}
local
last_part_optional
=
${
5
:-
"false"
}
if
[
"
$(
echo
"
${
requested_version
}
"
|
grep
-o
"."
|
wc
-l
)
"
!=
"2"
]
;
then
local
escaped_separator
=
${
separator
//./\\.
}
local
last_part
if
[
"
${
last_part_optional
}
"
=
"true"
]
;
then
last_part
=
"(
${
escaped_separator
}
[0-9]+)?"
else
last_part
=
"
${
escaped_separator
}
[0-9]+"
fi
local
regex
=
"
${
prefix
}
\\
K[0-9]+
${
escaped_separator
}
[0-9]+
${
last_part
}
$"
local
version_list
=
"
$(
git ls-remote
--tags
${
repository
}
|
grep
-oP
"
${
regex
}
"
|
tr
-d
' '
|
tr
"
${
separator
}
"
"."
|
sort
-rV
)
"
if
[
"
${
requested_version
}
"
=
"latest"
]
||
[
"
${
requested_version
}
"
=
"current"
]
||
[
"
${
requested_version
}
"
=
"lts"
]
;
then
declare
-g
${
variable_name
}
=
"
$(
echo
"
${
version_list
}
"
|
head
-n
1
)
"
else
set
+e
declare
-g
${
variable_name
}
=
"
$(
echo
"
${
version_list
}
"
|
grep
-E
-m
1
"^
${
requested_version
//./\\.
}
([
\\
.
\\
s]|
$)
"
)
"
set
-e
fi
fi
if
[
-z
"
${
!variable_name
}
"
]
||
!
echo
"
${
version_list
}
"
|
grep
"^
${
!variable_name//./\\.
}
$"
>
/dev/null 2>&1
;
then
echo
-e
"Invalid
${
variable_name
}
value:
${
requested_version
}
\n
Valid values:
\n
${
version_list
}
"
>
&2
exit
1
fi
echo
"
${
variable_name
}
=
${
!variable_name
}
"
}
# Ensure apt is in non-interactive to avoid prompts
# Ensure apt is in non-interactive to avoid prompts
export
DEBIAN_FRONTEND
=
noninteractive
export
DEBIAN_FRONTEND
=
noninteractive
...
@@ -92,6 +126,10 @@ fi
...
@@ -92,6 +126,10 @@ fi
# Install dependencies
# Install dependencies
check_packages apt-transport-https curl ca-certificates
tar
gnupg2 dirmngr
check_packages apt-transport-https curl ca-certificates
tar
gnupg2 dirmngr
if
!
type
git
>
/dev/null 2>&1
;
then
check_packages git
fi
# Install yarn
# Install yarn
if
type
yarn
>
/dev/null 2>&1
;
then
if
type
yarn
>
/dev/null 2>&1
;
then
echo
"Yarn already installed."
echo
"Yarn already installed."
...
@@ -112,6 +150,8 @@ elif [ "${NODE_VERSION}" = "latest" ]; then
...
@@ -112,6 +150,8 @@ elif [ "${NODE_VERSION}" = "latest" ]; then
export
NODE_VERSION
=
"node"
export
NODE_VERSION
=
"node"
fi
fi
find_version_from_git_tags NVM_VERSION
"https://github.com/nvm-sh/nvm"
# Install snipppet that we will run as the user
# Install snipppet that we will run as the user
nvm_install_snippet
=
"
$(
cat
<<
EOF
nvm_install_snippet
=
"
$(
cat
<<
EOF
set -e
set -e
...
...
test/node/install_nvm_0.39.sh
0 → 100755
View file @
95a169b9
#!/bin/bash
set
-e
# Optional: Import test library
source
dev-container-features-test-lib
# Definition specific tests
check
"version"
bash
-c
"node --version"
check
"pnpm"
pnpm
-v
check
"nvm version"
bash
-c
". /usr/local/share/nvm/nvm.sh && nvm --version | grep 0.39"
# Report result
reportResults
test/node/scenarios.json
View file @
95a169b9
...
@@ -44,5 +44,13 @@
...
@@ -44,5 +44,13 @@
"version"
:
"16"
"version"
:
"16"
}
}
}
}
},
"install_nvm_0.39"
:
{
"image"
:
"mcr.microsoft.com/devcontainers/base"
,
"features"
:
{
"node"
:
{
"nvmVersion"
:
"0.39"
}
}
}
}
}
}
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