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

configuration.mddocs/

0

# Configuration Management

1

2

Configuration system for managing default settings, loading configuration files, and handling environment-specific options for nodeenv operations.

3

4

## Capabilities

5

6

### Configuration Class

7

8

The Config class provides centralized configuration management with default values and file-based configuration loading.

9

10

```python { .api }

11

class Config(object):

12

"""

13

Configuration namespace with defaults and loading capabilities.

14

15

Attributes:

16

node (str): Default Node.js version ('latest')

17

npm (str): Default npm version ('latest')

18

with_npm (bool): Whether to install npm by default (False)

19

jobs (str): Number of parallel jobs for compilation ('2')

20

without_ssl (bool): Disable SSL support (False)

21

debug (bool): Enable debug output (False)

22

profile (bool): Enable profiling (False)

23

make (str): Make command to use ('make')

24

prebuilt (bool): Use prebuilt binaries by default (True)

25

ignore_ssl_certs (bool): Ignore SSL certificate errors (False)

26

"""

27

28

# Default configuration values

29

node = 'latest'

30

npm = 'latest'

31

with_npm = False

32

jobs = '2'

33

without_ssl = False

34

debug = False

35

profile = False

36

make = 'make'

37

prebuilt = True

38

ignore_ssl_certs = False

39

mirror = None

40

```

41

42

### Configuration Loading

43

44

Loads configuration from external files to customize default behavior.

45

46

```python { .api }

47

@classmethod

48

def _load(cls, configfiles, verbose=False):

49

"""

50

Load configuration from files.

51

52

Parameters:

53

configfiles (str or list): Path(s) to configuration file(s)

54

verbose (bool): Enable verbose logging during load (default: False)

55

56

Loads configuration values from external file to override

57

default settings. Supports various configuration file formats

58

and provides validation of configuration values.

59

60

Configuration files can specify:

61

- Default Node.js and npm versions

62

- Build and compilation options

63

- SSL and security settings

64

- Mirror and download URLs

65

"""

66

```

67

68

### Configuration Export

69

70

Exports current configuration values for debugging and documentation purposes.

71

72

```python { .api }

73

@classmethod

74

def _dump(cls):

75

"""

76

Dump current configuration values.

77

78

Outputs current configuration state for debugging and

79

documentation purposes. Used by the --dump-config-defaults

80

command-line option to show effective configuration.

81

82

Displays all configuration attributes and their current

83

values in a structured format.

84

"""

85

```

86

87

## Global Configuration Variables

88

89

nodeenv maintains several global configuration variables that affect operation:

90

91

```python { .api }

92

# SSL Certificate Handling

93

ignore_ssl_certs: bool

94

"""Global flag to ignore SSL certificate validation during downloads."""

95

96

# Download Source Configuration

97

src_base_url: str

98

"""Base URL for Node.js downloads, configurable via mirrors."""

99

```

100

101

## Configuration File Format

102

103

Configuration files use standard INI format with sections for different configuration areas:

104

105

```ini

106

[nodeenv]

107

node = 16.20.0

108

npm = 8.19.0

109

with_npm = true

110

jobs = 4

111

without_ssl = false

112

113

[build]

114

debug = false

115

profile = false

116

117

[network]

118

mirror = https://npm.taobao.org/mirrors/node

119

ignore_ssl_certs = false

120

```

121

122

## Usage Examples

123

124

### Using Default Configuration

125

126

```python

127

import nodeenv

128

129

# Configuration is automatically loaded with defaults

130

print(f"Default Node.js version: {nodeenv.Config.node}")

131

print(f"Default npm version: {nodeenv.Config.npm}")

132

print(f"Install npm by default: {nodeenv.Config.with_npm}")

133

print(f"Default parallel jobs: {nodeenv.Config.jobs}")

134

```

135

136

### Loading Custom Configuration

137

138

```python

139

import nodeenv

140

141

# Load configuration from file

142

nodeenv.Config._load('/path/to/nodeenv.conf', verbose=True)

143

144

# Configuration values are now updated

145

print(f"Configured Node.js version: {nodeenv.Config.node}")

146

print(f"Configured npm version: {nodeenv.Config.npm}")

147

```

148

149

### Dumping Configuration

150

151

```python

152

import nodeenv

153

154

# Display current configuration

155

nodeenv.Config._dump()

156

```

157

158

### Command Line Configuration Override

159

160

```python

161

import nodeenv

162

import sys

163

164

# Dump configuration defaults (used by --dump-config-defaults)

165

sys.argv = ['nodeenv', '--dump-config-defaults']

166

nodeenv.main() # Will call Config._dump()

167

```

168

169

### Global Configuration Settings

170

171

```python

172

import nodeenv

173

174

# Configure global settings

175

nodeenv.ignore_ssl_certs = True # Disable SSL verification

176

nodeenv.src_base_url = 'https://npm.taobao.org/mirrors/node' # Use mirror

177

178

# These affect all subsequent operations

179

versions = nodeenv.get_node_versions() # Uses configured mirror and SSL settings

180

```

181

182

### Environment-Specific Configuration

183

184

```python

185

import nodeenv

186

from argparse import Namespace

187

188

# Create environment with configuration override

189

args = Namespace(

190

config_file='/path/to/custom.conf',

191

verbose=True,

192

node=None, # Will use value from config file

193

npm=None, # Will use value from config file

194

with_npm=None, # Will use value from config file

195

jobs=None # Will use value from config file

196

)

197

198

# Configuration loaded during argument parsing

199

parsed_args = nodeenv.parse_args()

200

nodeenv.create_environment('/path/to/env', parsed_args)

201

```

202

203

## Configuration Precedence

204

205

Configuration values are resolved in the following order (highest to lowest precedence):

206

207

1. Command-line arguments

208

2. Configuration file values (loaded via `--config-file`)

209

3. Default values from Config class

210

4. Environment variables (where applicable)

211

212

This allows for flexible configuration management with appropriate override capabilities for different use cases.