Skip to content

Commit

Permalink
from dev - Bump version: 1.0.8 → 1.0.9 into test (#15)
Browse files Browse the repository at this point in the history
Automatically created pull request for release v1.0.9-dev into test
branch.
JuanVilla424 authored Oct 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 237346e + eba8996 commit 1125b6e
Showing 14 changed files with 1,615 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.8
current_version = 1.0.9
commit = True
tag = False

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -134,3 +134,4 @@ $RECYCLE.BIN/
*.sw?

scripts
*/certs/
17 changes: 12 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ repos:
hooks:
- id: yaml-format
name: yaml-format
entry: python scripts/format_yaml/main.py
entry: python format_yaml/main.py
language: system
types: [yaml]
files: \.(yaml)$
@@ -53,28 +53,35 @@ repos:
# # TODO: Solve error
# - id: yml-format
# name: yml-format
# entry: python scripts/format_yml/main.py
# entry: python format_yml/main.py
# language: system
# types: [yaml]
# files: \.(yml)$
# exclude: '.github/.*'
- id: docker-compose
name: docker-compose
entry: python scripts/validate_docker_compose/main.py
entry: python validate_docker_compose/main.py
language: system
types: [yaml]
files: ^docker-compose(\.dev|\.prod)?\.yml$
- id: commit-msg-version-check
name: commit-msg-version-check
entry: python scripts/commit_msg_version_bump/main.py
entry: python commit_msg_version_bump/main.py
always_run: true
language: system
args: [.git/COMMIT_EDITMSG]
stages: [pre-push]
- id: bump-year
name: bump-year
entry: python bump_year/main.py
always_run: true
pass_filenames: false
language: system
- id: generate-changelog
name: generate-changelog
entry: python scripts/generate_changelog/main.py
entry: python generate_changelog/main.py
always_run: true
pass_filenames: false
language: system
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ extension-pkg-whitelist=
fail-on=

# Specify a score threshold under which the program will exit with error.
fail-under=10
fail-under=8

# Interpret the stdin as a python script, whose filename needs to be passed as
# the module_or_package argument.
@@ -402,7 +402,7 @@ preferred-modules=

# The type of string formatting that logging methods do. `old` means using %
# formatting, `new` is for `{}` formatting.
logging-format-style=old
logging-format-style=new

# Logging modules to check that the string format arguments are in logging
# function parameter format.
73 changes: 68 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,78 @@
## [1.0.0] - 2024-10-23
## [1.0.8] - 2024-10-27

### Styles

- **core**: fixed confs (`patch candidate`)

### Other Changes

- rebased scripts
- feat: added scripts
- Initial commit
- from prod - from test - from dev - Bump version: 1.0.7 → 1.0.8 into test (#11)Automatically created pull request for release v1.0.8-dev into testbranch. into prod (#12)Automatically created pull request for release v1.0.8-test into prodbranch. into main (#13)
- from test - from dev - Bump version: 1.0.7 → 1.0.8 into test (#11)Automatically created pull request for release v1.0.8-dev into testbranch. into prod (#12)
- from dev - Bump version: 1.0.7 → 1.0.8 into test (#11)
- Bump version: 1.0.7 → 1.0.8
- Update CNAME
- Update CNAME
- Create CNAME

## [1.0.7] - 2024-10-27

### Styles

- **core**: fixed confs (`patch candidate`)
- **core**: fixed confs (`patch candidate`)
- **core**: fixed confs (`patch candidate`)
- **core**: fixed confs (`patch candidate`)

### Other Changes

- from prod - from test - from dev - Bump version: 1.0.6 → 1.0.7 into test (#8)Automatically created pull request for release v1.0.7-dev into testbranch. into prod (#9)Automatically created pull request for release v1.0.7-test into prodbranch. into main (#10)
- from test - from dev - Bump version: 1.0.6 → 1.0.7 into test (#8)Automatically created pull request for release v1.0.7-dev into testbranch. into prod (#9)
- from dev - Bump version: 1.0.6 → 1.0.7 into test (#8)
- Bump version: 1.0.6 → 1.0.7
- Bump version: 1.0.5 → 1.0.6
- Bump version: 1.0.4 → 1.0.5
- Bump version: 1.0.3 → 1.0.4

## [1.0.3] - 2024-10-27

### Styles

## [1.0.0] - 2024-10-23
- **core**: added readme file (`patch candidate`)
- **core**: added readme file (`patch candidate`)

### Other Changes

- from prod - from test - from dev - Bump version: 1.0.2 → 1.0.3 into test (#5)Automatically created pull request for release v1.0.3-dev into testbranch. into prod (#6)Automatically created pull request for release v1.0.3-test into prodbranch. into main (#7)
- from test - from dev - Bump version: 1.0.2 → 1.0.3 into test (#5)Automatically created pull request for release v1.0.3-dev into testbranch. into prod (#6)
- from dev - Bump version: 1.0.2 → 1.0.3 into test (#5)
- Bump version: 1.0.2 → 1.0.3
- Bump version: 1.0.1 → 1.0.2
- style(core): added readme file

## [1.0.1] - 2024-10-27

### Features

- **core**: add cicd flows (`patch candidate`)

### Other Changes

- from prod - from test - from dev - Bump version: 1.0.0 → 1.0.1 into test (#1)Automatically created pull request for release v1.0.1-dev into testbranch. into prod (#2)Automatically created pull request for release v1.0.1-test into prodbranch. into main (#3)
- from test - from dev - Bump version: 1.0.0 → 1.0.1 into test (#1)Automatically created pull request for release v1.0.1-dev into testbranch. into prod (#2)
- from dev - Bump version: 1.0.0 → 1.0.1 into test (#1)
- Bump version: 1.0.0 → 1.0.1
- feat(core): fix cicd flows
- feat(core): added cicd flows
- rebased scripts
- feat: added scripts
- Initial commit

## [Unreleased] - 2024-10-27

### Chores

- **style**: fixed bump year flow (`patch candidate`)

### Other Changes

- chore(core): added crypto controller
20 changes: 19 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# Install
## 🔨 Installation

1. Add the scripts repository as a submodule in your project:

```bash
git submodule add https://github.com/JuanVilla424/scripts.git
```

or, using branch

```bash
git submodule add -b <branch_name> https://github.com/JuanVilla424/scripts.git
```

2. Update the submodule when there are changes:

```bash
git submodule update --remote --merge
```
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
@@ -531,7 +531,7 @@ patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
or that patent license was granted, prior to 28 March 2024.

Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
scripts Copyright (C) 2024 Na0nh
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
209 changes: 168 additions & 41 deletions bump_year/main.py
Original file line number Diff line number Diff line change
@@ -4,64 +4,191 @@
A script to bump the year part of the version in pyproject.toml.
Resets major and minor versions to 0 when the year is incremented.
Additionally, updates the footers of specified Markdown files that contain the year.
Usage:
bump_year.py
python bump_year.py
python bump_year.py --md-files README.md CONTRIBUTING.md
python bump_year.py --md-dir docs/
"""

import argparse
import logging
import datetime
import toml
import sys
import os
import re
from typing import List
from logging.handlers import RotatingFileHandler

# Initialize the logger
logger = logging.getLogger(__name__)

def bump_year() -> None:

def parse_arguments() -> argparse.Namespace:
"""
Bumps the year in pyproject.toml and resets major and minor versions to 0.
Parses command-line arguments.
Returns:
argparse.Namespace: Parsed arguments.
"""
current_year = datetime.datetime.now().year
pyproject_path = "pyproject.toml"

try:
with open(pyproject_path, "r", encoding="utf-8") as file:
data = toml.load(file)
except FileNotFoundError:
print(f"Error: {pyproject_path} not found.")
sys.exit(1)
except toml.TomlDecodeError:
print(f"Error: Failed to parse {pyproject_path}.")
sys.exit(1)

try:
version = data["tool"]["poetry"]["version"]
year, major, minor = version.split(".")
except (KeyError, ValueError):
print("Error: Version format is incorrect in pyproject.toml.")
sys.exit(1)

if int(year) < current_year:
print(f"Updating year from {year} to {current_year}")
year = str(current_year)
major = "0"
minor = "0"
new_version = f"{year}.{major}.{minor}"
data["tool"]["poetry"]["version"] = new_version
parser = argparse.ArgumentParser(description="Update Markdown footers containing the year.")
parser.add_argument(
"--md-files",
nargs="*",
default=[
"README.md",
"CONTRIBUTING.md",
"SECURITY.md",
"CODE_OF_CONDUCT.md",
"VERSIONING.md",
"LICENSE",
],
help="List of Markdown files to update footers. Example: --md-files README.md CONTRIBUTING.md",
)
parser.add_argument(
"--md-dir",
type=str,
default=None,
help="Directory containing Markdown files to update footers. Example: --md-dir docs/",
)
parser.add_argument(
"--log-level",
choices=["INFO", "DEBUG"],
default="INFO",
help="Set the logging level. Default is INFO.",
)
return parser.parse_args()


def configure_logger(log_level: str) -> None:
"""
Configures logging for the script.
Args:
log_level (str): Logging level as a string (e.g., 'INFO', 'DEBUG').
"""
numeric_level = getattr(logging, log_level.upper(), None)
if not isinstance(numeric_level, int):
raise ValueError(f"Invalid log level: {log_level}")

logger.setLevel(numeric_level)

# Set up log rotation: max size 5MB, keep 5 backup files
file_handler = RotatingFileHandler("bump_year.log", maxBytes=5 * 1024 * 1024, backupCount=5)
console_handler = logging.StreamHandler()

formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
console_handler.setFormatter(formatter)

logger.handlers.clear()
logger.addHandler(file_handler)
logger.addHandler(console_handler)


def update_markdown_footers(md_files: List[str], current_year: int) -> None:
"""
Updates the footer year in specified Markdown files.
Args:
md_files (List[str]): List of Markdown file paths.
current_year (int): The current year.
"""
year_pattern = re.compile(r"(\b20\d{2}\b)") # Matches years from 2000 to 2099

for md_file in md_files:
if not os.path.isfile(md_file):
logger.warning(f"{md_file} does not exist. Skipping.")
continue

try:
with open(pyproject_path, "w", encoding="utf-8") as file:
toml.dump(data, file)
print(f"Year bumped to {new_version}")
with open(md_file, "r", encoding="utf-8") as file:
content = file.read()
except Exception as e:
print(f"Error writing to {pyproject_path}: {e}")
sys.exit(1)
else:
print("Year is up-to-date. No need to bump.")
logger.error(f"Error reading {md_file}: {e}")
continue

logger.debug(f"Current year: {current_year}")

# Find all years in the content
years_found = year_pattern.findall(content)
if not years_found:
logger.debug(f"No years found in {md_file}. Skipping.")
continue

for year in years_found:
logger.debug(f"Updating footer for year: {year} in {md_file}")
if int(year) == int(current_year):
logger.debug(f"No years to update found in {md_file}. Skipping.")
continue

# Replace the last occurrence of a year in the footer
# Assumption: The footer is at the end of the file
lines = content.strip().split("\n")
footer_updated = False

for i in range(len(lines) - 1, -1, -1):
line = lines[i]
if year_pattern.search(line) and line.__contains__(str(int(current_year) - 1)):
new_line = year_pattern.sub(str(current_year), line, count=1)
lines[i] = new_line
footer_updated = True
logger.info(f"Updated year in {md_file}: '{line}' -> '{new_line}'")
break

if footer_updated:
new_content = "\n".join(lines) + "\n"
try:
with open(md_file, "w", encoding="utf-8") as file:
file.write(new_content)
logger.info(f"Successfully updated {md_file}.")
except Exception as e:
logger.error(f"Error writing to {md_file}: {e}")
else:
logger.warning(f"No footer with a year to update found in {md_file}. Skipping.")


def collect_markdown_files(md_files: List[str], md_dir: str = None) -> List[str]:
"""
Collects Markdown files from specified files and/or directory.
Args:
md_files (List[str]): List of Markdown file paths.
md_dir (str, optional): Directory to search for Markdown files.
Returns:
List[str]: Combined list of Markdown file paths.
"""
collected_files = set(md_files)

if md_dir:
if not os.path.isdir(md_dir):
logger.warning(f"Directory {md_dir} does not exist. Skipping.")
else:
for root, _, files in os.walk(md_dir):
for file in files:
if file.lower().endswith(".md"):
collected_files.add(os.path.join(root, file))

return list(collected_files)


def main() -> None:
"""
Main function to execute the year bumping process.
Main function to execute the year bumping and Markdown footers updating process.
"""
bump_year()
current_year = datetime.datetime.now().year

# Collect Markdown files to update
markdown_files = collect_markdown_files(args.md_files, args.md_dir)

if markdown_files:
update_markdown_footers(markdown_files, current_year)
else:
logger.error("No Markdown files specified for footer update.")


if __name__ == "__main__":
args = parse_arguments()
configure_logger(args.log_level)
main()
620 changes: 620 additions & 0 deletions crypto_controller/main.py

Large diffs are not rendered by default.

450 changes: 328 additions & 122 deletions generate_changelog/main.py

Large diffs are not rendered by default.

376 changes: 376 additions & 0 deletions init_security_config/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,376 @@
import re
import sys
import random
import string
import os
import shutil


def generate_random_string(length, chars_type):
"""
Generates a random string based on the specified type.
Args:
length (int): The length of the generated string.
chars_type (str): The type of characters to include ('Chars' or 'Chars-with-specials').
Returns:
str: The generated random string.
"""
if chars_type == "Chars":
characters = string.ascii_letters + string.digits
elif chars_type == "Chars-with-specials":
# Exclude single quotes, double quotes, and backslashes, $, :, &, @, [], (), /, |
characters = string.ascii_letters + string.digits + "!#%*-_=+;,."
else:
characters = string.ascii_letters + string.digits # Default to 'Chars' if unknown

return "".join(random.choice(characters) for _ in range(length))


def replace_placeholders(line, variables):
"""
Replaces placeholders in a line based on defined patterns.
Args:
line (str): The line containing placeholders.
variables (dict): Dictionary of previously defined variables.
Returns:
str: The line with placeholders replaced.
"""
# Pattern for <number (Chars)> and <number (Chars-with-specials)>
placeholder_pattern = re.compile(r"<(\d+)\s*\((Chars(?:-with-specials)?)\)>")

def placeholder_replacer(match):
length = int(match.group(1))
chars_type = match.group(2)
return generate_random_string(length, chars_type)

# Replace all <number (Chars)> and <number (Chars-with-specials)> placeholders
line = placeholder_pattern.sub(placeholder_replacer, line)

# Pattern for variables like <VAR_NAME>
var_pattern = re.compile(r"<([A-Z_]+)>")

def var_replacer(match):
var_name = match.group(1)
if var_name in variables:
return variables[var_name]
print(f"[WARNING] Undefined variable '{var_name}' encountered. Placeholder left as-is.")
return match.group(0) # Leave the placeholder as-is if not defined

# Replace <VAR_NAME> placeholders with their corresponding values
line = var_pattern.sub(var_replacer, line)
return line


def remove_comments(line):
"""
Removes inline comments from a line. Leaves full-line comments intact.
Args:
line (str): The line from which to remove comments.
Returns:
str: The line without inline comments. Full-line comments are left intact.
"""
stripped_line = line.lstrip()
if stripped_line.startswith("#"):
return line # Leave full-line comments intact

result = []
in_single_quote = False
in_double_quote = False

for char in line:
if char == "'" and not in_double_quote:
in_single_quote = not in_single_quote
elif char == '"' and not in_single_quote:
in_double_quote = not in_double_quote
elif char == "#" and not in_single_quote and not in_double_quote:
break # Ignore the rest of the line after '#'
result.append(char)

return "".join(result).rstrip()


def clean_spaces(line):
"""
Cleans unnecessary spaces from a line.
Args:
line (str): The line to clean.
Returns:
str: The cleaned line.
"""
# Remove leading and trailing spaces
line = line.strip()
# Replace multiple spaces with a single space
line = re.sub(r"\s+", " ", line)
return line


def collect_variables(line, variables):
"""
Collects variable definitions from a line and updates the variables dictionary.
Args:
line (str): The line containing variable definition.
variables (dict): Dictionary to store variable names and their values.
Returns:
tuple:
str: The updated line with placeholders replaced.
bool: Indicates whether a variable was defined.
"""
# Pattern to capture lines like VAR_NAME=valor
var_def_pattern = re.compile(r'^([A-Z_]+)=["\']?(.*?)["\']?$')
match = var_def_pattern.match(line)
if match:
var_name = match.group(1)
var_value = match.group(2)
# Replace placeholders within the variable value
var_value_replaced = replace_placeholders(var_value, variables)
variables[var_name] = var_value_replaced
# Reconstruct the line with the replaced value
# Preserve the original quotes if they were present
if line.strip().startswith(var_name + "='") or line.strip().startswith(var_name + '="'):
quote_char = line.strip()[len(var_name) + 1]
line_final = f"{var_name}={quote_char}{var_value_replaced}{quote_char}"
else:
line_final = f"{var_name}={var_value_replaced}"
return line_final, True # Indicate that a variable was defined
return line, False # No variable defined


def format_env_file(file_path, variables):
"""
Formats a .env.example file by replacing placeholders, replacing variables,
removing inline comments, and cleaning spaces.
Args:
file_path (str): Path to the .env.example file.
variables (dict): Dictionary of previously defined variables.
Returns:
None
"""
try:
with open(file_path, "r", encoding="utf-8") as f:
lines = f.readlines()
except FileNotFoundError:
print(f"[ERROR] The file {file_path} does not exist.")
sys.exit(1)

formatted_lines = []

for i, line in enumerate(lines, start=1):
original_line = line.rstrip("\n")

# Step 1: Remove inline comments (leave full-line comments intact)
line_no_comments = remove_comments(original_line)

# Step 2: Clean unnecessary spaces
line_cleaned = clean_spaces(line_no_comments)

# Step 3: Check if the line is a variable definition and collect variables
line_processed, is_var_def = collect_variables(line_cleaned, variables)

if is_var_def:
# If it's a variable definition, add the updated line
if line_processed != original_line.strip():
print(f"[FORMAT] Modified variable definition on line {i} in {file_path}.")
formatted_lines.append(line_processed)
else:
# Step 4: Replace variable placeholders in non-variable lines
line_replaced = replace_placeholders(line_cleaned, variables)

if line_replaced != line_cleaned:
print(f"[FORMAT] Modified line {i} in {file_path}.")

# Step 5: Add the formatted line if it's not empty
if line_replaced:
formatted_lines.append(line_replaced)
else:
# If the line is empty after cleaning (e.g., was a comment-only line), do not add it
print(f"[FORMAT] Removed empty or comment-only line {i} in {file_path}.")

# Combine all formatted lines
formatted_content = "\n".join(formatted_lines) + "\n"

# Write the formatted content back to the file
with open(file_path, "w", newline="\n", encoding="utf-8") as f:
f.write(formatted_content)

print(f"[FORMAT] Formatted {file_path} successfully.")


def format_js_file(file_path, variables):
"""
Formats a JavaScript (.js) file by replacing placeholders, replacing variables,
removing inline comments, cleaning spaces, and ensuring proper indentation.
Args:
file_path (str): Path to the JavaScript file to format.
variables (dict): Dictionary of previously defined variables.
Returns:
None
"""
try:
with open(file_path, "r", encoding="utf-8") as f:
js_lines = f.readlines()
except FileNotFoundError:
print(f"[ERROR] The file {file_path} does not exist.")
return

formatted_lines = []
indent_level = 0
indent_size = 4 # Number of spaces for each indent level

for i, line in enumerate(js_lines, start=1):
original_line = line.rstrip("\n")

# Step 1: Remove inline comments (leave full-line comments intact)
line_no_comments = remove_comments(original_line)

# Step 2: Clean unnecessary spaces
line_cleaned = clean_spaces(line_no_comments)

# Step 3: Replace placeholders
line_replaced = replace_placeholders(line_cleaned, variables)

if line_replaced != line_cleaned:
print(f"[FORMAT] Modified line {i} in {file_path}.")

# Step 4: Determine if the line affects indentation
# Decrease indent level if the line starts with a closing brace
if line_replaced.startswith("}") and not line_replaced.endswith("},"):
indent_level = max(indent_level - 1, 0)
if line_replaced.startswith("}") and not line_replaced.endswith("],"):
indent_level = max(indent_level - 1, 0)

# Apply indentation
indented_line = " " * (indent_size * indent_level) + line_replaced
formatted_lines.append(indented_line)

# Step 5: Adjust indent level based on braces
# Avoid counting braces within strings
in_single_quote = False
in_double_quote = False
escape_char = False
for char in line_replaced:
if escape_char:
escape_char = False
continue
if char == "\\":
escape_char = True
continue
if char == "'" and not in_double_quote:
in_single_quote = not in_single_quote
continue
if char == '"' and not in_single_quote:
in_double_quote = not in_double_quote
continue
if in_single_quote or in_double_quote:
continue
if char == "{":
indent_level += 1
elif char == "}":
indent_level = max(indent_level - 1, 0)
if char == "[":
indent_level += 1
elif char == "]":
indent_level = max(indent_level - 1, 0)

# Combine all formatted lines
formatted_content = "\n".join(formatted_lines) + "\n"

# Write the formatted content back to the file
with open(file_path, "w", newline="\n", encoding="utf-8") as f:
f.write(formatted_content)

print(f"[FORMAT] Formatted {file_path} successfully.")


def ensure_js_file(default_js_path, template_js_path):
"""
Ensures that the JavaScript file exists. If not, creates it from the template.
Args:
default_js_path (str): The default path to the JavaScript file.
template_js_path (str): The path to the template JavaScript file.
Returns:
None
"""
if not os.path.exists(default_js_path):
if os.path.exists(template_js_path):
# Create directories if they do not exist
os.makedirs(os.path.dirname(default_js_path), exist_ok=True)
shutil.copyfile(template_js_path, default_js_path)
print(f"[INFO] Created JavaScript file from template: {default_js_path}")
else:
print(f"[ERROR] Template JavaScript file does not exist: {template_js_path}")
sys.exit(1)
else:
print(f"[INFO] JavaScript file already exists: {default_js_path}")


def format_file(file_path, variables):
"""
Determines the file type and applies appropriate formatting.
Args:
file_path (str): Path to the file to format.
variables (dict): Dictionary of previously defined variables.
Returns:
None
"""
if file_path.endswith(".env") or file_path.endswith(".env.example") or ".env." in file_path:
format_env_file(file_path, variables)
elif file_path.endswith(".js"):
format_js_file(file_path, variables)
else:
print(f"[INFO] Skipping unsupported file type: {file_path}")


def main():
"""
Main function to handle command-line arguments and initiate file formatting.
Usage:
python init_security_config.py <path_to_env.example> [<path_to_js_file>]
"""
if len(sys.argv) < 2:
print("Usage: python init_security_config.py <path_to_env.example> [<path_to_js_file>]")
sys.exit(1)

env_file_path = sys.argv[1]
if len(sys.argv) >= 3:
js_file_path = sys.argv[2]
else:
# Set default JavaScript file path
js_file_path = os.path.join("yoguis_tickets_database", "initdb.d", "mongo-init.js")
template_js_path = os.path.join(
"yoguis_tickets_database", "initdb.d", "mongo-init.example.js"
)
ensure_js_file(js_file_path, template_js_path)

variables = {}

# Process the .env.example file
print(f"\nProcessing file: {env_file_path}")
format_file(env_file_path, variables)

# Process the JavaScript file
if js_file_path:
print(f"\nProcessing file: {js_file_path}")
format_file(js_file_path, variables)


if __name__ == "__main__":
main()
Empty file added init_template/main.py
Empty file.
19 changes: 11 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scripts"
version = "1.0.8"
version = "1.0.9"
description = "CICD Core Scripts"
authors = ["B <g46327wsj1.marbling129@passinbox.com>"]
license = "Apache 2.0"
@@ -10,20 +10,23 @@ package-mode = false
[tool.poetry.dependencies]
python = "^3.12"
setuptools = "^75.2.0"
idna="^3.0"
certifi="^2024.8.30"
bump2version="^1.0.0"
idna = "^3.0"
certifi = "^2024.8.30"
bump2version = "^1.0.0"
python-dotenv = "^1.0.0"
cryptography = "^43.0.0"
requests = "^2.32.3"

[tool.poetry.group.dev.dependencies]
pre-commit = "^4.0.0"
pylint="^3.3.0"
yamllint="^1.35.0"
isort = "^5.12.0"
toml="^0.10.0"
black="^24.3.0"
toml = "^0.10.0"
black = "^24.3.0"
pytest = "^8.3.1"
httpx = { version = ">=0.24.0", optional = true }
pytest-cov = { version = "^5.0.0", optional = true }
pytest-cov = "^5.0.0"
coverage = "^7.2.5"

[tool.poetry.extras]
@@ -68,5 +71,5 @@ ensure_newline_before_comments = true
rcfile = ".pylintrc"

[build-system]
requires = ["poetry-core>=1.0.8"]
requires = ["poetry-core>=1.0.9"]
build-backend = "poetry.core.masonry.api"
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -25,3 +25,9 @@ pytest-cov>=5.0.0

# Coverage Reporting
coverage>=7.2.5

requests~=2.32.3

python-dotenv>=1.0.0

cryptography>=43.0.0

0 comments on commit 1125b6e

Please sign in to comment.