jols 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.
jols-1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oliver Simner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
jols-1.0/MANIFEST.in ADDED
File without changes
jols-1.0/PKG-INFO ADDED
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: jols
3
+ Version: 1.0
4
+ Summary: JustOpenedLetsStart (JOLS) Is a template manager so you can start coding your project without having to make the same files over and over again
5
+ Author: Oliver Simner
6
+ Author-email: dev@oliversimner.com
7
+ License: MIT
8
+ Project-URL: Source, https://github.com/OliverSimner/JustOpenedLetsStart
9
+ Project-URL: Issues, https://github.com/OliverSimner/JustOpenedLetsStart/issues
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: license
21
+ Dynamic: license-file
22
+ Dynamic: project-url
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # JustOpenedLetsStart
27
+ JustOpenedLetsStart (JOLS) Is a template manager so you can start coding your project without having to make the same files over and over again
28
+
29
+ # Designed for windows
30
+
31
+ ## Starter templates
32
+
33
+ Install the local project with `py -m pip install -e .`. Then run a template
34
+ command in the directory where you want its files created:
35
+
36
+ ```text
37
+ jols --statichtml .
38
+ jols --node .
39
+ jols --react .
40
+ jols --rust .
41
+ jols --cpp .
42
+ jols --c .
43
+ jols --python .
44
+ jols --lua .
45
+ jols --github .
46
+ ```
47
+
48
+ Each command creates a small starter for that technology. React projects use
49
+ Vite; C and C++ projects use CMake; `--github` adds issue and pull request
50
+ templates. For Node.js, `--nodejs` is an alias for `--node`; for C++,
51
+ `--cxx` is an alias for `--cpp`.
52
+
53
+ The static HTML template creates `index.html`, `css/style.css`,
54
+ `js/script.js`, and an `images` folder. Existing files are left untouched.
55
+ Replace `.` with another path to create the starter elsewhere. Run
56
+ `jols --help` to see the available options.
57
+ Run `jols -v` to print the installed version.
58
+
59
+ The GitHub Actions workflow runs tests for pull requests and published
60
+ releases, then builds and checks the package. On a published release it also
61
+ uploads the distributions to PyPI using trusted publishing (no PyPI API token
62
+ is stored in GitHub).
63
+
64
+ To publish, create a GitHub environment named `pypi`, register the repository
65
+ as a PyPI trusted publisher, and publish a GitHub Release. After the first
66
+ release, install the package with:
67
+
68
+ ```text
69
+ pip install jols
70
+ ```
71
+
72
+ ### First PyPI release
73
+
74
+ 1. In GitHub repository settings, create an environment named `pypi`.
75
+ 2. On PyPI's **Publishing** page, add a pending GitHub publisher for project
76
+ `jols`, owner `OliverSimner`, repository `JustOpenedLetsStart`, workflow
77
+ `release-checks.yml`, and environment `pypi`.
78
+ 3. Publish a GitHub Release with the tag `v1.0`. The workflow tests and builds
79
+ the package, then publishes it to PyPI using OIDC.
jols-1.0/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # JustOpenedLetsStart
2
+ JustOpenedLetsStart (JOLS) Is a template manager so you can start coding your project without having to make the same files over and over again
3
+
4
+ # Designed for windows
5
+
6
+ ## Starter templates
7
+
8
+ Install the local project with `py -m pip install -e .`. Then run a template
9
+ command in the directory where you want its files created:
10
+
11
+ ```text
12
+ jols --statichtml .
13
+ jols --node .
14
+ jols --react .
15
+ jols --rust .
16
+ jols --cpp .
17
+ jols --c .
18
+ jols --python .
19
+ jols --lua .
20
+ jols --github .
21
+ ```
22
+
23
+ Each command creates a small starter for that technology. React projects use
24
+ Vite; C and C++ projects use CMake; `--github` adds issue and pull request
25
+ templates. For Node.js, `--nodejs` is an alias for `--node`; for C++,
26
+ `--cxx` is an alias for `--cpp`.
27
+
28
+ The static HTML template creates `index.html`, `css/style.css`,
29
+ `js/script.js`, and an `images` folder. Existing files are left untouched.
30
+ Replace `.` with another path to create the starter elsewhere. Run
31
+ `jols --help` to see the available options.
32
+ Run `jols -v` to print the installed version.
33
+
34
+ The GitHub Actions workflow runs tests for pull requests and published
35
+ releases, then builds and checks the package. On a published release it also
36
+ uploads the distributions to PyPI using trusted publishing (no PyPI API token
37
+ is stored in GitHub).
38
+
39
+ To publish, create a GitHub environment named `pypi`, register the repository
40
+ as a PyPI trusted publisher, and publish a GitHub Release. After the first
41
+ release, install the package with:
42
+
43
+ ```text
44
+ pip install jols
45
+ ```
46
+
47
+ ### First PyPI release
48
+
49
+ 1. In GitHub repository settings, create an environment named `pypi`.
50
+ 2. On PyPI's **Publishing** page, add a pending GitHub publisher for project
51
+ `jols`, owner `OliverSimner`, repository `JustOpenedLetsStart`, workflow
52
+ `release-checks.yml`, and environment `pypi`.
53
+ 3. Publish a GitHub Release with the tag `v1.0`. The workflow tests and builds
54
+ the package, then publishes it to PyPI using OIDC.
@@ -0,0 +1,9 @@
1
+ from .jols import TEMPLATES, __version__, create_static_html, create_template, main
2
+
3
+ __all__ = [
4
+ "TEMPLATES",
5
+ "__version__",
6
+ "create_static_html",
7
+ "create_template",
8
+ "main",
9
+ ]
@@ -0,0 +1,375 @@
1
+ import argparse
2
+ from pathlib import Path
3
+
4
+
5
+ __version__ = "1.0"
6
+
7
+
8
+ TEMPLATES = {
9
+ "statichtml": {
10
+ "index.html": """<!DOCTYPE html>
11
+ <html lang="en">
12
+ <head>
13
+ <meta charset="UTF-8">
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
15
+ <title>My Website</title>
16
+ <link rel="stylesheet" href="css/style.css">
17
+ </head>
18
+ <body>
19
+ <main>
20
+ <h1>Welcome</h1>
21
+ <p>Your static website starts here.</p>
22
+ </main>
23
+ <script src="js/script.js"></script>
24
+ </body>
25
+ </html>
26
+ """,
27
+ "css/style.css": """* {
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ body {
32
+ margin: 0;
33
+ padding: 2rem;
34
+ font-family: system-ui, sans-serif;
35
+ }
36
+ """,
37
+ "js/script.js": "// Add your JavaScript here.\n",
38
+ "images/.gitkeep": "",
39
+ },
40
+ "nodejs": {
41
+ "package.json": """{
42
+ "name": "my-node-app",
43
+ "version": "1.0.0",
44
+ "private": true,
45
+ "type": "module",
46
+ "scripts": {
47
+ "start": "node src/index.js"
48
+ }
49
+ }
50
+ """,
51
+ "src/index.js": """console.log("Hello from Node.js!");
52
+ """,
53
+ ".gitignore": "node_modules/\n.env\n",
54
+ "README.md": """# Node.js starter
55
+
56
+ Run `npm start` to start the application.
57
+ """,
58
+ },
59
+ "react": {
60
+ "package.json": """{
61
+ "name": "my-react-app",
62
+ "version": "1.0.0",
63
+ "private": true,
64
+ "type": "module",
65
+ "scripts": {
66
+ "dev": "vite",
67
+ "build": "vite build",
68
+ "preview": "vite preview"
69
+ },
70
+ "dependencies": {
71
+ "react": "^19.0.0",
72
+ "react-dom": "^19.0.0"
73
+ },
74
+ "devDependencies": {
75
+ "vite": "^7.0.0"
76
+ }
77
+ }
78
+ """,
79
+ "index.html": """<!doctype html>
80
+ <html lang="en">
81
+ <head>
82
+ <meta charset="UTF-8" />
83
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
84
+ <title>My React App</title>
85
+ </head>
86
+ <body>
87
+ <div id="root"></div>
88
+ <script type="module" src="/src/main.jsx"></script>
89
+ </body>
90
+ </html>
91
+ """,
92
+ "src/main.jsx": """import { StrictMode } from "react";
93
+ import { createRoot } from "react-dom/client";
94
+ import App from "./App.jsx";
95
+ import "./style.css";
96
+
97
+ createRoot(document.getElementById("root")).render(
98
+ <StrictMode>
99
+ <App />
100
+ </StrictMode>
101
+ );
102
+ """,
103
+ "src/App.jsx": """export default function App() {
104
+ return <h1>Welcome to React</h1>;
105
+ }
106
+ """,
107
+ "src/style.css": """body {
108
+ margin: 0;
109
+ padding: 2rem;
110
+ font-family: system-ui, sans-serif;
111
+ }
112
+ """,
113
+ ".gitignore": "node_modules/\ndist/\n.env\n",
114
+ "README.md": """# React starter
115
+
116
+ Run `npm install` once, then `npm run dev` to start the development server.
117
+ """,
118
+ },
119
+ "rust": {
120
+ "Cargo.toml": """[package]
121
+ name = "my-rust-app"
122
+ version = "0.1.0"
123
+ edition = "2021"
124
+
125
+ [dependencies]
126
+ """,
127
+ "src/main.rs": """fn main() {
128
+ println!("Hello from Rust!");
129
+ }
130
+ """,
131
+ ".gitignore": "/target\n",
132
+ "README.md": """# Rust starter
133
+
134
+ Run `cargo run` to build and start the application.
135
+ """,
136
+ },
137
+ "cpp": {
138
+ "CMakeLists.txt": """cmake_minimum_required(VERSION 3.16)
139
+ project(my_cpp_app LANGUAGES CXX)
140
+
141
+ set(CMAKE_CXX_STANDARD 17)
142
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
143
+
144
+ add_executable(my_cpp_app src/main.cpp)
145
+ """,
146
+ "src/main.cpp": """#include <iostream>
147
+
148
+ int main() {
149
+ std::cout << "Hello from C++!" << std::endl;
150
+ return 0;
151
+ }
152
+ """,
153
+ "README.md": """# C++ starter
154
+
155
+ Build with `cmake -S . -B build` and `cmake --build build`.
156
+ """,
157
+ },
158
+ "c": {
159
+ "CMakeLists.txt": """cmake_minimum_required(VERSION 3.16)
160
+ project(my_c_app LANGUAGES C)
161
+
162
+ set(CMAKE_C_STANDARD 11)
163
+ set(CMAKE_C_STANDARD_REQUIRED ON)
164
+
165
+ add_executable(my_c_app src/main.c)
166
+ """,
167
+ "src/main.c": """#include <stdio.h>
168
+
169
+ int main(void) {
170
+ puts("Hello from C!");
171
+ return 0;
172
+ }
173
+ """,
174
+ "README.md": """# C starter
175
+
176
+ Build with `cmake -S . -B build` and `cmake --build build`.
177
+ """,
178
+ },
179
+ "python": {
180
+ "pyproject.toml": """[build-system]
181
+ requires = ["setuptools>=61"]
182
+ build-backend = "setuptools.build_meta"
183
+
184
+ [project]
185
+ name = "my-python-app"
186
+ version = "0.1.0"
187
+ requires-python = ">=3.8"
188
+
189
+ [tool.setuptools]
190
+ py-modules = ["main"]
191
+ """,
192
+ "main.py": """def main():
193
+ print("Hello from Python!")
194
+
195
+
196
+ if __name__ == "__main__":
197
+ main()
198
+ """,
199
+ "tests/test_main.py": """import unittest
200
+
201
+ from main import main
202
+
203
+
204
+ class MainTests(unittest.TestCase):
205
+ def test_main_runs(self):
206
+ main()
207
+
208
+
209
+ if __name__ == "__main__":
210
+ unittest.main()
211
+ """,
212
+ ".gitignore": "__pycache__/\n*.py[cod]\n.venv/\nbuild/\ndist/\n",
213
+ "README.md": """# Python starter
214
+
215
+ Run `python main.py`. Run tests with `python -m unittest discover -s tests`.
216
+ """,
217
+ },
218
+ "lua": {
219
+ "main.lua": """print("Hello from Lua!")
220
+ """,
221
+ "README.md": """# Lua starter
222
+
223
+ Run `lua main.lua` to start the application.
224
+ """,
225
+ },
226
+ "github": {
227
+ ".github/ISSUE_TEMPLATE/bug_report.yml": """name: Bug report
228
+ description: Report a problem
229
+ title: "[Bug]: "
230
+ labels: ["bug"]
231
+ body:
232
+ - type: textarea
233
+ id: problem
234
+ attributes:
235
+ label: What happened?
236
+ description: Describe the problem and how to reproduce it.
237
+ validations:
238
+ required: true
239
+ """,
240
+ ".github/ISSUE_TEMPLATE/feature_request.yml": """name: Feature request
241
+ description: Suggest an improvement
242
+ title: "[Feature]: "
243
+ labels: ["enhancement"]
244
+ body:
245
+ - type: textarea
246
+ id: idea
247
+ attributes:
248
+ label: What would you like?
249
+ description: Describe the feature and why it would be useful.
250
+ validations:
251
+ required: true
252
+ """,
253
+ ".github/PULL_REQUEST_TEMPLATE.md": """## What changed?
254
+
255
+ ## How was it tested?
256
+ """,
257
+ ".gitignore": ".env\n.DS_Store\n",
258
+ },
259
+ }
260
+
261
+
262
+ def create_template(template, destination):
263
+ destination = Path(destination)
264
+ destination.mkdir(parents=True, exist_ok=True)
265
+
266
+ for relative_path, contents in TEMPLATES[template].items():
267
+ file_path = destination / relative_path
268
+ file_path.parent.mkdir(parents=True, exist_ok=True)
269
+ try:
270
+ with file_path.open("x", encoding="utf-8") as output_file:
271
+ output_file.write(contents)
272
+ except FileExistsError:
273
+ print("Skipped existing file: {}".format(file_path))
274
+ else:
275
+ print("Created: {}".format(file_path))
276
+
277
+
278
+ def create_static_html(destination):
279
+ create_template("statichtml", destination)
280
+
281
+
282
+ def main(argv=None):
283
+ parser = argparse.ArgumentParser(
284
+ description="Create starter files for a project."
285
+ )
286
+ parser.add_argument(
287
+ "-v",
288
+ "--version",
289
+ action="version",
290
+ version="jols {}".format(__version__),
291
+ )
292
+ template_options = parser.add_mutually_exclusive_group()
293
+ template_options.add_argument(
294
+ "--statichtml",
295
+ dest="template",
296
+ action="store_const",
297
+ const="statichtml",
298
+ help="create a static HTML, CSS, JavaScript, and images starter",
299
+ )
300
+ template_options.add_argument(
301
+ "--node",
302
+ "--nodejs",
303
+ dest="template",
304
+ action="store_const",
305
+ const="nodejs",
306
+ help="create a Node.js starter",
307
+ )
308
+ template_options.add_argument(
309
+ "--react",
310
+ dest="template",
311
+ action="store_const",
312
+ const="react",
313
+ help="create a React and Vite starter",
314
+ )
315
+ template_options.add_argument(
316
+ "--rust",
317
+ dest="template",
318
+ action="store_const",
319
+ const="rust",
320
+ help="create a Rust starter",
321
+ )
322
+ template_options.add_argument(
323
+ "--cpp",
324
+ "--cxx",
325
+ dest="template",
326
+ action="store_const",
327
+ const="cpp",
328
+ help="create a C++ and CMake starter",
329
+ )
330
+ template_options.add_argument(
331
+ "--c",
332
+ dest="template",
333
+ action="store_const",
334
+ const="c",
335
+ help="create a C and CMake starter",
336
+ )
337
+ template_options.add_argument(
338
+ "--python",
339
+ dest="template",
340
+ action="store_const",
341
+ const="python",
342
+ help="create a Python starter",
343
+ )
344
+ template_options.add_argument(
345
+ "--lua",
346
+ dest="template",
347
+ action="store_const",
348
+ const="lua",
349
+ help="create a Lua starter",
350
+ )
351
+ template_options.add_argument(
352
+ "--github",
353
+ dest="template",
354
+ action="store_const",
355
+ const="github",
356
+ help="create GitHub issue and pull request templates",
357
+ )
358
+ parser.add_argument(
359
+ "directory",
360
+ nargs="?",
361
+ default=".",
362
+ help="directory to create the starter files in (default: current directory)",
363
+ )
364
+ args = parser.parse_args(argv)
365
+
366
+ if args.template is None:
367
+ parser.print_help()
368
+ return 0
369
+
370
+ create_template(args.template, args.directory)
371
+ return 0
372
+
373
+
374
+ if __name__ == "__main__":
375
+ raise SystemExit(main())
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: jols
3
+ Version: 1.0
4
+ Summary: JustOpenedLetsStart (JOLS) Is a template manager so you can start coding your project without having to make the same files over and over again
5
+ Author: Oliver Simner
6
+ Author-email: dev@oliversimner.com
7
+ License: MIT
8
+ Project-URL: Source, https://github.com/OliverSimner/JustOpenedLetsStart
9
+ Project-URL: Issues, https://github.com/OliverSimner/JustOpenedLetsStart/issues
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: license
21
+ Dynamic: license-file
22
+ Dynamic: project-url
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # JustOpenedLetsStart
27
+ JustOpenedLetsStart (JOLS) Is a template manager so you can start coding your project without having to make the same files over and over again
28
+
29
+ # Designed for windows
30
+
31
+ ## Starter templates
32
+
33
+ Install the local project with `py -m pip install -e .`. Then run a template
34
+ command in the directory where you want its files created:
35
+
36
+ ```text
37
+ jols --statichtml .
38
+ jols --node .
39
+ jols --react .
40
+ jols --rust .
41
+ jols --cpp .
42
+ jols --c .
43
+ jols --python .
44
+ jols --lua .
45
+ jols --github .
46
+ ```
47
+
48
+ Each command creates a small starter for that technology. React projects use
49
+ Vite; C and C++ projects use CMake; `--github` adds issue and pull request
50
+ templates. For Node.js, `--nodejs` is an alias for `--node`; for C++,
51
+ `--cxx` is an alias for `--cpp`.
52
+
53
+ The static HTML template creates `index.html`, `css/style.css`,
54
+ `js/script.js`, and an `images` folder. Existing files are left untouched.
55
+ Replace `.` with another path to create the starter elsewhere. Run
56
+ `jols --help` to see the available options.
57
+ Run `jols -v` to print the installed version.
58
+
59
+ The GitHub Actions workflow runs tests for pull requests and published
60
+ releases, then builds and checks the package. On a published release it also
61
+ uploads the distributions to PyPI using trusted publishing (no PyPI API token
62
+ is stored in GitHub).
63
+
64
+ To publish, create a GitHub environment named `pypi`, register the repository
65
+ as a PyPI trusted publisher, and publish a GitHub Release. After the first
66
+ release, install the package with:
67
+
68
+ ```text
69
+ pip install jols
70
+ ```
71
+
72
+ ### First PyPI release
73
+
74
+ 1. In GitHub repository settings, create an environment named `pypi`.
75
+ 2. On PyPI's **Publishing** page, add a pending GitHub publisher for project
76
+ `jols`, owner `OliverSimner`, repository `JustOpenedLetsStart`, workflow
77
+ `release-checks.yml`, and environment `pypi`.
78
+ 3. Publish a GitHub Release with the tag `v1.0`. The workflow tests and builds
79
+ the package, then publishes it to PyPI using OIDC.
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ setup.py
5
+ jols/jols/__init__.py
6
+ jols/jols/jols.py
7
+ jols/jols.egg-info/PKG-INFO
8
+ jols/jols.egg-info/SOURCES.txt
9
+ jols/jols.egg-info/dependency_links.txt
10
+ jols/jols.egg-info/entry_points.txt
11
+ jols/jols.egg-info/top_level.txt
12
+ tests/test_jols.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ jols = jols.jols:main
@@ -0,0 +1 @@
1
+ jols
jols-1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
jols-1.0/setup.py ADDED
@@ -0,0 +1,30 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ setup(
4
+ name="jols",
5
+ version="1.0",
6
+ include_package_data=True,
7
+ python_requires='>=3.8',
8
+ packages=find_packages(where="jols"),
9
+ package_dir={"": "jols"},
10
+ license="MIT",
11
+ license_files=["LICENSE"],
12
+ author="Oliver Simner",
13
+ author_email="dev@oliversimner.com",
14
+ description="JustOpenedLetsStart (JOLS) Is a template manager so you can start coding your project without having to make the same files over and over again",
15
+ long_description=open('README.md').read(),
16
+ long_description_content_type="text/markdown",
17
+ project_urls={
18
+ "Source": "https://github.com/OliverSimner/JustOpenedLetsStart",
19
+ "Issues": "https://github.com/OliverSimner/JustOpenedLetsStart/issues",
20
+ },
21
+ entry_points={
22
+ "console_scripts": [
23
+ "jols=jols.jols:main",
24
+ ],
25
+ },
26
+ classifiers=[
27
+ "Programming Language :: Python :: 3.8",
28
+ "Operating System :: OS Independent",
29
+ ],
30
+ )
@@ -0,0 +1,82 @@
1
+ from contextlib import redirect_stdout
2
+ from io import StringIO
3
+ import tempfile
4
+ import unittest
5
+ from pathlib import Path
6
+
7
+ from jols.jols import TEMPLATES, create_static_html, create_template, main
8
+
9
+
10
+ class TemplateCliTests(unittest.TestCase):
11
+ def test_version_option_reports_current_version(self):
12
+ for option in ("-v", "--version"):
13
+ with self.subTest(option=option):
14
+ output = StringIO()
15
+ with redirect_stdout(output):
16
+ with self.assertRaises(SystemExit) as exception:
17
+ main([option])
18
+
19
+ self.assertEqual(exception.exception.code, 0)
20
+ self.assertEqual(output.getvalue(), "jols 1.0\n")
21
+
22
+ def test_creates_expected_files_for_each_template(self):
23
+ expected_files = {
24
+ "statichtml": "index.html",
25
+ "nodejs": "src/index.js",
26
+ "react": "src/main.jsx",
27
+ "rust": "src/main.rs",
28
+ "cpp": "src/main.cpp",
29
+ "c": "src/main.c",
30
+ "python": "main.py",
31
+ "lua": "main.lua",
32
+ "github": ".github/PULL_REQUEST_TEMPLATE.md",
33
+ }
34
+ for template, expected_file in expected_files.items():
35
+ with self.subTest(template=template):
36
+ with tempfile.TemporaryDirectory() as temporary_directory:
37
+ destination = Path(temporary_directory)
38
+
39
+ create_template(template, destination)
40
+
41
+ self.assertTrue((destination / expected_file).is_file())
42
+
43
+ def test_creates_static_site_structure(self):
44
+ with tempfile.TemporaryDirectory() as temporary_directory:
45
+ destination = Path(temporary_directory)
46
+
47
+ create_static_html(destination)
48
+
49
+ self.assertTrue((destination / "index.html").is_file())
50
+ self.assertTrue((destination / "css" / "style.css").is_file())
51
+ self.assertTrue((destination / "js" / "script.js").is_file())
52
+ self.assertTrue((destination / "images").is_dir())
53
+ self.assertIn(
54
+ 'href="css/style.css"',
55
+ (destination / "index.html").read_text(encoding="utf-8"),
56
+ )
57
+
58
+ def test_does_not_overwrite_existing_files(self):
59
+ with tempfile.TemporaryDirectory() as temporary_directory:
60
+ destination = Path(temporary_directory)
61
+ index_file = destination / "index.html"
62
+ index_file.write_text("keep this", encoding="utf-8")
63
+
64
+ create_static_html(destination)
65
+
66
+ self.assertEqual(index_file.read_text(encoding="utf-8"), "keep this")
67
+
68
+ def test_creates_each_supported_template(self):
69
+ for template in TEMPLATES:
70
+ with self.subTest(template=template):
71
+ with tempfile.TemporaryDirectory() as temporary_directory:
72
+ destination = Path(temporary_directory)
73
+
74
+ create_template(template, destination)
75
+
76
+ self.assertTrue(
77
+ any(path.is_file() for path in destination.rglob("*"))
78
+ )
79
+
80
+
81
+ if __name__ == "__main__":
82
+ unittest.main()