caylent-devcontainer-cli 0.1.0__tar.gz
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.
- caylent_devcontainer_cli-0.1.0/PKG-INFO +187 -0
- caylent_devcontainer_cli-0.1.0/README.md +161 -0
- caylent_devcontainer_cli-0.1.0/pyproject.toml +87 -0
- caylent_devcontainer_cli-0.1.0/setup.cfg +4 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/__init__.py +4 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/cli.py +59 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/__init__.py +1 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/code.py +61 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/env.py +64 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/install.py +100 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/setup.py +228 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/setup_interactive.py +340 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/commands/template.py +337 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/utils/__init__.py +1 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/utils/constants.py +10 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/utils/fs.py +97 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli/utils/ui.py +68 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli.egg-info/PKG-INFO +187 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli.egg-info/SOURCES.txt +21 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli.egg-info/dependency_links.txt +1 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli.egg-info/entry_points.txt +2 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli.egg-info/requires.txt +7 -0
- caylent_devcontainer_cli-0.1.0/src/caylent_devcontainer_cli.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: caylent-devcontainer-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI tool for managing Caylent devcontainers
|
|
5
|
+
Author-email: Caylent <solutions-owners@caylent.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/caylent-solutions/devcontainer
|
|
8
|
+
Project-URL: Issues, https://github.com/caylent-solutions/devcontainer/issues
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: black~=24.0
|
|
20
|
+
Requires-Dist: flake8~=7.0
|
|
21
|
+
Requires-Dist: isort~=6.0
|
|
22
|
+
Requires-Dist: pytest~=7.0
|
|
23
|
+
Requires-Dist: pytest-cov~=4.0
|
|
24
|
+
Requires-Dist: questionary~=2.0.0
|
|
25
|
+
Requires-Dist: semver~=3.0.0
|
|
26
|
+
|
|
27
|
+
# Caylent Devcontainer CLI
|
|
28
|
+
|
|
29
|
+
A command-line tool for managing Caylent devcontainer environments.
|
|
30
|
+
|
|
31
|
+
## Table of Contents
|
|
32
|
+
|
|
33
|
+
1. [Installation](#installation)
|
|
34
|
+
2. [Usage](#usage)
|
|
35
|
+
- [Commands](#commands)
|
|
36
|
+
- [Setting Up a Devcontainer](#setting-up-a-devcontainer)
|
|
37
|
+
- [Managing Templates](#managing-templates)
|
|
38
|
+
- [Launching VS Code](#launching-vs-code)
|
|
39
|
+
3. [Development](#development)
|
|
40
|
+
- [Setup](#setup)
|
|
41
|
+
- [Testing](#testing)
|
|
42
|
+
- [Linting and Formatting](#linting-and-formatting)
|
|
43
|
+
- [Building and Publishing](#building-and-publishing)
|
|
44
|
+
4. [License](#license)
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Install from PyPI (when available)
|
|
50
|
+
pip install caylent-devcontainer-cli
|
|
51
|
+
|
|
52
|
+
# Install from GitHub with a specific version tag
|
|
53
|
+
pip install git+https://github.com/caylent-solutions/devcontainer.git@0.1.0#subdirectory=caylent-devcontainer-cli
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cdevcontainer --help
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Commands
|
|
63
|
+
|
|
64
|
+
- `setup-devcontainer`: Set up a devcontainer in a project directory
|
|
65
|
+
- `code`: Launch VS Code with the devcontainer environment
|
|
66
|
+
- `env`: Manage environment variables
|
|
67
|
+
- `template`: Manage devcontainer templates
|
|
68
|
+
- `install`: Install the CLI tool to your PATH
|
|
69
|
+
- `uninstall`: Uninstall the CLI tool
|
|
70
|
+
|
|
71
|
+
### Setting Up a Devcontainer
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Interactive setup
|
|
75
|
+
cdevcontainer setup-devcontainer /path/to/your/project
|
|
76
|
+
|
|
77
|
+
# Manual setup (skip interactive prompts)
|
|
78
|
+
cdevcontainer setup-devcontainer --manual /path/to/your/project
|
|
79
|
+
|
|
80
|
+
# Update existing devcontainer files to the current CLI version
|
|
81
|
+
cdevcontainer setup-devcontainer --update /path/to/your/project
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The interactive setup will guide you through:
|
|
85
|
+
1. Using an existing template or creating a new one
|
|
86
|
+
2. Configuring environment variables
|
|
87
|
+
3. Setting up AWS profiles (if enabled)
|
|
88
|
+
|
|
89
|
+
### Managing Templates
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Save current environment as a template
|
|
93
|
+
cdevcontainer template save my-template
|
|
94
|
+
|
|
95
|
+
# List available templates
|
|
96
|
+
cdevcontainer template list
|
|
97
|
+
|
|
98
|
+
# Load a template into a project
|
|
99
|
+
cdevcontainer template load my-template
|
|
100
|
+
|
|
101
|
+
# Delete one or more templates
|
|
102
|
+
cdevcontainer template delete template1 template2
|
|
103
|
+
|
|
104
|
+
# Upgrade a template to the current CLI version
|
|
105
|
+
cdevcontainer template upgrade my-template
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
When using templates created with older versions of the CLI, the tool will automatically detect version mismatches and provide options to:
|
|
109
|
+
- Upgrade the profile to the current version
|
|
110
|
+
- Create a new profile from scratch
|
|
111
|
+
- Try to use the profile anyway (with a warning)
|
|
112
|
+
- Exit without making changes
|
|
113
|
+
|
|
114
|
+
### Launching VS Code
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Launch VS Code for the current project
|
|
118
|
+
cdevcontainer code
|
|
119
|
+
|
|
120
|
+
# Launch VS Code for a specific project
|
|
121
|
+
cdevcontainer code /path/to/your/project
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
### Setup
|
|
127
|
+
|
|
128
|
+
For development, we recommend using the devcontainer itself. See the [Contributing Guide](CONTRIBUTING.md) for detailed setup instructions.
|
|
129
|
+
|
|
130
|
+
### Testing
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Run unit tests
|
|
134
|
+
make unit-test
|
|
135
|
+
|
|
136
|
+
# Run functional tests
|
|
137
|
+
make functional-test
|
|
138
|
+
|
|
139
|
+
# Run all tests
|
|
140
|
+
make test
|
|
141
|
+
|
|
142
|
+
# Generate coverage report
|
|
143
|
+
make coverage
|
|
144
|
+
|
|
145
|
+
# View functional test coverage report
|
|
146
|
+
make functional-test-report
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Testing Requirements
|
|
150
|
+
|
|
151
|
+
- **Unit Tests**: Must maintain at least 90% code coverage
|
|
152
|
+
- **Functional Tests**: Must test CLI commands as they would be used by actual users
|
|
153
|
+
- All tests must pass before merging code
|
|
154
|
+
|
|
155
|
+
### Linting and Formatting
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Check code style
|
|
159
|
+
make lint
|
|
160
|
+
|
|
161
|
+
# Format code
|
|
162
|
+
make format
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Building and Publishing
|
|
166
|
+
|
|
167
|
+
The package is automatically published to PyPI when a new tag is pushed to GitHub.
|
|
168
|
+
|
|
169
|
+
To create a new release:
|
|
170
|
+
|
|
171
|
+
1. Ensure all tests pass (`make test`)
|
|
172
|
+
2. Perform the [manual tests](MANUAL_TESTING.md) to verify functionality
|
|
173
|
+
3. Create and push a new tag following semantic versioning:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
git tag -a 0.1.0 -m "Release 0.1.0"
|
|
177
|
+
git push origin 0.1.0
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The GitHub Actions workflow will:
|
|
181
|
+
1. Validate the tag follows semantic versioning (MAJOR.MINOR.PATCH)
|
|
182
|
+
2. Build the package using ASDF for Python version management
|
|
183
|
+
3. Publish the package to PyPI
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
Apache License 2.0
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Caylent Devcontainer CLI
|
|
2
|
+
|
|
3
|
+
A command-line tool for managing Caylent devcontainer environments.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Installation](#installation)
|
|
8
|
+
2. [Usage](#usage)
|
|
9
|
+
- [Commands](#commands)
|
|
10
|
+
- [Setting Up a Devcontainer](#setting-up-a-devcontainer)
|
|
11
|
+
- [Managing Templates](#managing-templates)
|
|
12
|
+
- [Launching VS Code](#launching-vs-code)
|
|
13
|
+
3. [Development](#development)
|
|
14
|
+
- [Setup](#setup)
|
|
15
|
+
- [Testing](#testing)
|
|
16
|
+
- [Linting and Formatting](#linting-and-formatting)
|
|
17
|
+
- [Building and Publishing](#building-and-publishing)
|
|
18
|
+
4. [License](#license)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install from PyPI (when available)
|
|
24
|
+
pip install caylent-devcontainer-cli
|
|
25
|
+
|
|
26
|
+
# Install from GitHub with a specific version tag
|
|
27
|
+
pip install git+https://github.com/caylent-solutions/devcontainer.git@0.1.0#subdirectory=caylent-devcontainer-cli
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cdevcontainer --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Commands
|
|
37
|
+
|
|
38
|
+
- `setup-devcontainer`: Set up a devcontainer in a project directory
|
|
39
|
+
- `code`: Launch VS Code with the devcontainer environment
|
|
40
|
+
- `env`: Manage environment variables
|
|
41
|
+
- `template`: Manage devcontainer templates
|
|
42
|
+
- `install`: Install the CLI tool to your PATH
|
|
43
|
+
- `uninstall`: Uninstall the CLI tool
|
|
44
|
+
|
|
45
|
+
### Setting Up a Devcontainer
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Interactive setup
|
|
49
|
+
cdevcontainer setup-devcontainer /path/to/your/project
|
|
50
|
+
|
|
51
|
+
# Manual setup (skip interactive prompts)
|
|
52
|
+
cdevcontainer setup-devcontainer --manual /path/to/your/project
|
|
53
|
+
|
|
54
|
+
# Update existing devcontainer files to the current CLI version
|
|
55
|
+
cdevcontainer setup-devcontainer --update /path/to/your/project
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The interactive setup will guide you through:
|
|
59
|
+
1. Using an existing template or creating a new one
|
|
60
|
+
2. Configuring environment variables
|
|
61
|
+
3. Setting up AWS profiles (if enabled)
|
|
62
|
+
|
|
63
|
+
### Managing Templates
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Save current environment as a template
|
|
67
|
+
cdevcontainer template save my-template
|
|
68
|
+
|
|
69
|
+
# List available templates
|
|
70
|
+
cdevcontainer template list
|
|
71
|
+
|
|
72
|
+
# Load a template into a project
|
|
73
|
+
cdevcontainer template load my-template
|
|
74
|
+
|
|
75
|
+
# Delete one or more templates
|
|
76
|
+
cdevcontainer template delete template1 template2
|
|
77
|
+
|
|
78
|
+
# Upgrade a template to the current CLI version
|
|
79
|
+
cdevcontainer template upgrade my-template
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When using templates created with older versions of the CLI, the tool will automatically detect version mismatches and provide options to:
|
|
83
|
+
- Upgrade the profile to the current version
|
|
84
|
+
- Create a new profile from scratch
|
|
85
|
+
- Try to use the profile anyway (with a warning)
|
|
86
|
+
- Exit without making changes
|
|
87
|
+
|
|
88
|
+
### Launching VS Code
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Launch VS Code for the current project
|
|
92
|
+
cdevcontainer code
|
|
93
|
+
|
|
94
|
+
# Launch VS Code for a specific project
|
|
95
|
+
cdevcontainer code /path/to/your/project
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
### Setup
|
|
101
|
+
|
|
102
|
+
For development, we recommend using the devcontainer itself. See the [Contributing Guide](CONTRIBUTING.md) for detailed setup instructions.
|
|
103
|
+
|
|
104
|
+
### Testing
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Run unit tests
|
|
108
|
+
make unit-test
|
|
109
|
+
|
|
110
|
+
# Run functional tests
|
|
111
|
+
make functional-test
|
|
112
|
+
|
|
113
|
+
# Run all tests
|
|
114
|
+
make test
|
|
115
|
+
|
|
116
|
+
# Generate coverage report
|
|
117
|
+
make coverage
|
|
118
|
+
|
|
119
|
+
# View functional test coverage report
|
|
120
|
+
make functional-test-report
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Testing Requirements
|
|
124
|
+
|
|
125
|
+
- **Unit Tests**: Must maintain at least 90% code coverage
|
|
126
|
+
- **Functional Tests**: Must test CLI commands as they would be used by actual users
|
|
127
|
+
- All tests must pass before merging code
|
|
128
|
+
|
|
129
|
+
### Linting and Formatting
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Check code style
|
|
133
|
+
make lint
|
|
134
|
+
|
|
135
|
+
# Format code
|
|
136
|
+
make format
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Building and Publishing
|
|
140
|
+
|
|
141
|
+
The package is automatically published to PyPI when a new tag is pushed to GitHub.
|
|
142
|
+
|
|
143
|
+
To create a new release:
|
|
144
|
+
|
|
145
|
+
1. Ensure all tests pass (`make test`)
|
|
146
|
+
2. Perform the [manual tests](MANUAL_TESTING.md) to verify functionality
|
|
147
|
+
3. Create and push a new tag following semantic versioning:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
git tag -a 0.1.0 -m "Release 0.1.0"
|
|
151
|
+
git push origin 0.1.0
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The GitHub Actions workflow will:
|
|
155
|
+
1. Validate the tag follows semantic versioning (MAJOR.MINOR.PATCH)
|
|
156
|
+
2. Build the package using ASDF for Python version management
|
|
157
|
+
3. Publish the package to PyPI
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
Apache License 2.0
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=78.1.1", "wheel>=0.40.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "caylent-devcontainer-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CLI tool for managing Caylent devcontainers"
|
|
9
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Caylent", email = "solutions-owners@caylent.com" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12"
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
dependencies = [
|
|
29
|
+
"black~=24.0",
|
|
30
|
+
"flake8~=7.0",
|
|
31
|
+
"isort~=6.0",
|
|
32
|
+
"pytest~=7.0",
|
|
33
|
+
"pytest-cov~=4.0",
|
|
34
|
+
"questionary~=2.0.0",
|
|
35
|
+
"semver~=3.0.0"
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
cdevcontainer = "caylent_devcontainer_cli.cli:main"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/caylent-solutions/devcontainer"
|
|
43
|
+
Issues = "https://github.com/caylent-solutions/devcontainer/issues"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
|
|
48
|
+
[tool.setuptools]
|
|
49
|
+
include-package-data = true
|
|
50
|
+
|
|
51
|
+
[tool.black]
|
|
52
|
+
line-length = 120
|
|
53
|
+
target-version = ["py38"]
|
|
54
|
+
|
|
55
|
+
[tool.isort]
|
|
56
|
+
profile = "black"
|
|
57
|
+
line_length = 120
|
|
58
|
+
|
|
59
|
+
[tool.semantic_release]
|
|
60
|
+
version_variable = "src/caylent_devcontainer_cli/__init__.py:__version__"
|
|
61
|
+
branch = "main"
|
|
62
|
+
upload_to_pypi = false
|
|
63
|
+
upload_to_release = false
|
|
64
|
+
build_command = "python -m build"
|
|
65
|
+
version_source = "commit"
|
|
66
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
67
|
+
tag_format = "{version}"
|
|
68
|
+
major_on_zero = true
|
|
69
|
+
commit_version_number = true
|
|
70
|
+
changelog_file = "CHANGELOG.md"
|
|
71
|
+
changelog_scope = false
|
|
72
|
+
|
|
73
|
+
[tool.semantic_release.commit_parser_options]
|
|
74
|
+
allowed_tags = [
|
|
75
|
+
"build",
|
|
76
|
+
"chore",
|
|
77
|
+
"ci",
|
|
78
|
+
"docs",
|
|
79
|
+
"feat",
|
|
80
|
+
"fix",
|
|
81
|
+
"perf",
|
|
82
|
+
"refactor",
|
|
83
|
+
"style",
|
|
84
|
+
"test"
|
|
85
|
+
]
|
|
86
|
+
minor_tags = ["feat"]
|
|
87
|
+
patch_tags = ["fix", "perf"]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Main CLI entry point for Caylent Devcontainer CLI."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
from caylent_devcontainer_cli import __version__
|
|
6
|
+
from caylent_devcontainer_cli.commands import code, env, install, setup, template
|
|
7
|
+
|
|
8
|
+
# Constants
|
|
9
|
+
CLI_NAME = "Caylent Devcontainer CLI"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
"""Main entry point for the CLI."""
|
|
14
|
+
# Create the main parser
|
|
15
|
+
parser = argparse.ArgumentParser(
|
|
16
|
+
description=f"{CLI_NAME} - Manage devcontainer environments",
|
|
17
|
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Add global options
|
|
21
|
+
parser.add_argument("-y", "--yes", action="store_true", help="Automatically answer yes to all prompts")
|
|
22
|
+
parser.add_argument("-v", "--version", action="version", version=f"{CLI_NAME} {__version__}")
|
|
23
|
+
|
|
24
|
+
# Create subparsers
|
|
25
|
+
subparsers = parser.add_subparsers(dest="command", help="Command to run")
|
|
26
|
+
|
|
27
|
+
# Register commands
|
|
28
|
+
code.register_command(subparsers)
|
|
29
|
+
env.register_command(subparsers)
|
|
30
|
+
template.register_command(subparsers)
|
|
31
|
+
install.register_command(subparsers)
|
|
32
|
+
setup.register_command(subparsers)
|
|
33
|
+
|
|
34
|
+
# Parse arguments
|
|
35
|
+
args = parser.parse_args()
|
|
36
|
+
|
|
37
|
+
# Show banner
|
|
38
|
+
from caylent_devcontainer_cli.utils.ui import log
|
|
39
|
+
|
|
40
|
+
log("INFO", f"Welcome to {CLI_NAME} {__version__}")
|
|
41
|
+
|
|
42
|
+
if not hasattr(args, "func"):
|
|
43
|
+
parser.print_help()
|
|
44
|
+
import sys as _sys
|
|
45
|
+
|
|
46
|
+
_sys.exit(1)
|
|
47
|
+
|
|
48
|
+
# Set global AUTO_YES flag if needed
|
|
49
|
+
if hasattr(args, "yes") and args.yes:
|
|
50
|
+
from caylent_devcontainer_cli.utils.ui import set_auto_yes
|
|
51
|
+
|
|
52
|
+
set_auto_yes(True)
|
|
53
|
+
|
|
54
|
+
# Execute the command
|
|
55
|
+
args.func(args)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Command modules for the Caylent Devcontainer CLI."""
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Code command for the Caylent Devcontainer CLI."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
|
|
6
|
+
from caylent_devcontainer_cli.utils.fs import find_project_root, generate_shell_env
|
|
7
|
+
from caylent_devcontainer_cli.utils.ui import log
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def register_command(subparsers):
|
|
11
|
+
"""Register the code command."""
|
|
12
|
+
code_parser = subparsers.add_parser("code", help="Launch VS Code with the devcontainer environment")
|
|
13
|
+
code_parser.add_argument(
|
|
14
|
+
"project_root",
|
|
15
|
+
nargs="?",
|
|
16
|
+
default=None,
|
|
17
|
+
help="Project root directory (default: current directory)",
|
|
18
|
+
)
|
|
19
|
+
code_parser.add_argument("-y", "--yes", action="store_true", help="Automatically answer yes to all prompts")
|
|
20
|
+
code_parser.set_defaults(func=handle_code)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def handle_code(args):
|
|
24
|
+
"""Handle the code command."""
|
|
25
|
+
project_root = find_project_root(args.project_root)
|
|
26
|
+
|
|
27
|
+
# Check if devcontainer-environment-variables.json exists
|
|
28
|
+
env_json = os.path.join(project_root, "devcontainer-environment-variables.json")
|
|
29
|
+
shell_env = os.path.join(project_root, "shell.env")
|
|
30
|
+
|
|
31
|
+
if not os.path.isfile(env_json):
|
|
32
|
+
log("ERR", f"Configuration file not found: {env_json}")
|
|
33
|
+
log("INFO", "Please create this file first:")
|
|
34
|
+
print("cp .devcontainer/example-container-env-values.json devcontainer-environment-variables.json")
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
sys.exit(1)
|
|
38
|
+
|
|
39
|
+
# Generate shell.env if needed
|
|
40
|
+
if not os.path.isfile(shell_env) or os.path.getmtime(env_json) > os.path.getmtime(shell_env):
|
|
41
|
+
log("INFO", "Generating environment variables...")
|
|
42
|
+
generate_shell_env(env_json, shell_env)
|
|
43
|
+
else:
|
|
44
|
+
log("INFO", "Using existing shell.env file")
|
|
45
|
+
|
|
46
|
+
# Launch VS Code
|
|
47
|
+
log("INFO", "Launching VS Code...")
|
|
48
|
+
|
|
49
|
+
# Create a command that sources the environment and runs VS Code
|
|
50
|
+
command = f"source {shell_env} && code {project_root}"
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
# Execute the command in a new shell
|
|
54
|
+
process = subprocess.Popen(command, shell=True, executable=os.environ.get("SHELL", "/bin/bash"))
|
|
55
|
+
process.wait()
|
|
56
|
+
log("OK", "VS Code launched. Accept the prompt to reopen in container when it appears.")
|
|
57
|
+
except Exception as e:
|
|
58
|
+
log("ERR", f"Failed to launch VS Code: {e}")
|
|
59
|
+
import sys
|
|
60
|
+
|
|
61
|
+
sys.exit(1)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Environment command for the Caylent Devcontainer CLI."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from caylent_devcontainer_cli.utils.fs import generate_shell_env
|
|
6
|
+
from caylent_devcontainer_cli.utils.ui import log
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def register_command(subparsers):
|
|
10
|
+
"""Register the env command."""
|
|
11
|
+
env_parser = subparsers.add_parser("env", help="Environment variable management")
|
|
12
|
+
env_subparsers = env_parser.add_subparsers(dest="env_command")
|
|
13
|
+
|
|
14
|
+
# 'env export' command
|
|
15
|
+
export_parser = env_subparsers.add_parser("export", help="Generate shell exports from JSON")
|
|
16
|
+
export_parser.add_argument("json_file", help="Path to JSON with 'containerEnv'")
|
|
17
|
+
export_parser.add_argument("-o", "--output", required=True, help="Output file for shell exports")
|
|
18
|
+
export_parser.add_argument("--no-export", action="store_true", help="Omit 'export' prefix (for .env files)")
|
|
19
|
+
export_parser.add_argument("-y", "--yes", action="store_true", help="Automatically answer yes to all prompts")
|
|
20
|
+
export_parser.set_defaults(func=handle_env_export)
|
|
21
|
+
|
|
22
|
+
# 'env load' command
|
|
23
|
+
load_parser = env_subparsers.add_parser("load", help="Load environment variables")
|
|
24
|
+
load_parser.add_argument("-p", "--project-root", help="Project root directory (default: current directory)")
|
|
25
|
+
load_parser.add_argument("-y", "--yes", action="store_true", help="Automatically answer yes to all prompts")
|
|
26
|
+
load_parser.set_defaults(func=handle_env_load)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def handle_env_export(args):
|
|
30
|
+
"""Handle the env export command."""
|
|
31
|
+
generate_shell_env(args.json_file, args.output, args.no_export)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def handle_env_load(args):
|
|
35
|
+
"""Handle the env load command."""
|
|
36
|
+
project_root = args.project_root or os.getcwd()
|
|
37
|
+
load_environment(project_root)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def load_environment(project_root):
|
|
41
|
+
"""Load environment variables from shell.env file."""
|
|
42
|
+
shell_env_path = os.path.join(project_root, "shell.env")
|
|
43
|
+
env_vars_json = os.path.join(project_root, "devcontainer-environment-variables.json")
|
|
44
|
+
|
|
45
|
+
# Generate shell.env if it doesn't exist
|
|
46
|
+
if not os.path.exists(shell_env_path):
|
|
47
|
+
if os.path.exists(env_vars_json):
|
|
48
|
+
log("INFO", f"Generating shell.env from {env_vars_json}")
|
|
49
|
+
generate_shell_env(env_vars_json, shell_env_path)
|
|
50
|
+
else:
|
|
51
|
+
log("ERR", f"Configuration file not found: {env_vars_json}")
|
|
52
|
+
import sys
|
|
53
|
+
|
|
54
|
+
sys.exit(1)
|
|
55
|
+
|
|
56
|
+
# Print instructions for sourcing the environment
|
|
57
|
+
from caylent_devcontainer_cli.utils.ui import COLORS
|
|
58
|
+
|
|
59
|
+
print(f"{COLORS['CYAN']}To load the environment variables, run:{COLORS['RESET']}")
|
|
60
|
+
print(f"source {shell_env_path}")
|
|
61
|
+
print(f"\n{COLORS['CYAN']}Or to load and launch VS Code in one command:{COLORS['RESET']}")
|
|
62
|
+
print(f"source {shell_env_path} && code {project_root}")
|
|
63
|
+
warning = f"\n{COLORS['YELLOW']}⚠️ IMPORTANT: Use a dedicated terminal for each project{COLORS['RESET']}"
|
|
64
|
+
print(warning)
|