or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mdconfiguration.mdenvironment.mdindex.mdnode-install.mdpackage-management.mdutilities.mdversion-management.md

version-management.mddocs/

0

# Version Management

1

2

Node.js version discovery, parsing, and selection functionality including fetching available versions from remote repositories and determining latest stable and LTS releases.

3

4

## Capabilities

5

6

### Version Discovery

7

8

Retrieves available Node.js versions from remote repositories for version selection and validation.

9

10

```python { .api }

11

def get_node_versions():

12

"""

13

Get list of available Node.js versions.

14

15

Returns:

16

list: Available Node.js version strings

17

18

Fetches version information from Node.js official repositories

19

and returns a list of all available versions. Used for version

20

validation and selection in environment creation.

21

22

Handles network requests with proper error handling and

23

caching to avoid repeated remote calls.

24

"""

25

```

26

27

### Version Display

28

29

Prints available Node.js versions in a formatted display for user selection.

30

31

```python { .api }

32

def print_node_versions():

33

"""

34

Print available Node.js versions to console.

35

36

Displays all available Node.js versions in a formatted layout

37

suitable for command-line display. Used by the --list option

38

to show users what versions are available for installation.

39

40

Formats versions in columns for readability and includes

41

indicators for LTS and latest releases when available.

42

"""

43

```

44

45

### Latest Stable Version

46

47

Determines the most recent stable Node.js release for automatic version selection.

48

49

```python { .api }

50

def get_last_stable_node_version():

51

"""

52

Get the latest stable Node.js version.

53

54

Returns:

55

str: Latest stable Node.js version string

56

57

Identifies and returns the most recent stable Node.js release.

58

Used when 'latest' is specified as the Node.js version or

59

when no specific version is provided.

60

61

Filters out pre-release versions and development builds

62

to ensure stability.

63

"""

64

```

65

66

### Latest LTS Version

67

68

Identifies the most recent Long Term Support Node.js release for production environments.

69

70

```python { .api }

71

def get_last_lts_node_version():

72

"""

73

Get the latest LTS (Long Term Support) Node.js version.

74

75

Returns:

76

str: Latest LTS Node.js version string

77

78

Identifies and returns the most recent Node.js LTS release.

79

Used when 'lts' is specified as the Node.js version for

80

production environments requiring long-term stability.

81

82

LTS versions provide:

83

- Extended support and maintenance

84

- Security updates and bug fixes

85

- Stability for production deployments

86

"""

87

```

88

89

### Version Parsing

90

91

Parses and normalizes version strings for comparison and validation.

92

93

```python { .api }

94

def parse_version(version_str):

95

"""

96

Parse version string into comparable components.

97

98

Parameters:

99

version_str (str): Version string (e.g., '16.20.0', 'v18.17.1')

100

101

Returns:

102

tuple: Parsed version components for comparison

103

104

Parses version strings into standardized format for:

105

- Version comparison and sorting

106

- Validation of version format

107

- Normalization of version prefixes (removes 'v' prefix)

108

- Support for semantic versioning comparisons

109

110

Handles various version string formats and edge cases.

111

"""

112

```

113

114

### Version Resolution from Arguments

115

116

Extracts and validates Node.js version from command-line arguments.

117

118

```python { .api }

119

def node_version_from_args(args):

120

"""

121

Extract Node.js version from parsed arguments.

122

123

Parameters:

124

args (argparse.Namespace): Parsed command-line arguments

125

126

Returns:

127

str: Resolved Node.js version string

128

129

Resolves version specification from arguments:

130

- 'latest' -> latest stable version

131

- 'lts' -> latest LTS version

132

- 'system' -> use system Node.js

133

- Specific version -> validates and returns

134

135

Performs version validation and provides error messages

136

for invalid version specifications.

137

"""

138

```

139

140

## Internal Version Management

141

142

### Version Data Fetching

143

144

```python { .api }

145

def _get_versions_json():

146

"""

147

Fetch Node.js version data from remote repository.

148

149

Returns:

150

dict: Raw version information from Node.js repository

151

152

Internal function that fetches version metadata from

153

the Node.js official repository. Handles caching and

154

network error recovery.

155

"""

156

```

157

158

## Usage Examples

159

160

### Get Available Versions

161

162

```python

163

import nodeenv

164

165

# Get list of all available versions

166

versions = nodeenv.get_node_versions()

167

print(f"Available versions: {len(versions)}")

168

print(f"Latest versions: {versions[-5:]}")

169

170

# Display versions to user

171

nodeenv.print_node_versions()

172

```

173

174

### Version Resolution

175

176

```python

177

import nodeenv

178

179

# Get latest stable version

180

latest = nodeenv.get_last_stable_node_version()

181

print(f"Latest stable: {latest}")

182

183

# Get latest LTS version

184

lts = nodeenv.get_last_lts_node_version()

185

print(f"Latest LTS: {lts}")

186

187

# Parse and compare versions

188

v1 = nodeenv.parse_version("16.20.0")

189

v2 = nodeenv.parse_version("v18.17.1")

190

print(f"v16.20.0 parsed: {v1}")

191

print(f"v18.17.1 parsed: {v2}")

192

print(f"18.17.1 > 16.20.0: {v2 > v1}")

193

```

194

195

### Version Selection in Environment Creation

196

197

```python

198

import nodeenv

199

from argparse import Namespace

200

201

# Create environment with latest LTS

202

args = Namespace(node='lts')

203

version = nodeenv.node_version_from_args(args)

204

print(f"Using Node.js version: {version}")

205

206

# Create environment with specific version

207

args = Namespace(node='16.20.0')

208

version = nodeenv.node_version_from_args(args)

209

print(f"Using Node.js version: {version}")

210

```

211

212

### Command Line Version Display

213

214

```python

215

import nodeenv

216

import sys

217

218

# Simulate --list command

219

sys.argv = ['nodeenv', '--list']

220

nodeenv.main() # Will call print_node_versions()

221

```