Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct generate \
Aquí tienes un ejemplo de un archivo de configuración YAML:

```yaml
structure:
files:
- README.md:
content: |
# {{@ project_name @}}
Expand Down Expand Up @@ -223,7 +223,7 @@ como puedes ver, cada variable debe tener una descripción, un tipo y un valor p
Este filtro obtiene la versión más reciente de una release en un repositorio de GitHub. Toma el nombre del repositorio como argumento.

```yaml
structure:
files:
- README.md:
content: |
# MyProject
Expand All @@ -241,7 +241,7 @@ NOTA: puedes usar este filtro para obtener la última versión de un proveedor d
Este filtro convierte una cadena en un slug. Toma un argumento opcional para especificar el carácter separador (el valor predeterminado es `-`).

```yaml
structure:
files:
- README.md:
content: |
# {{@ project_name @}}
Expand All @@ -254,7 +254,7 @@ structure:
Este filtro obtiene el nombre de la rama predeterminada de un repositorio de GitHub. Toma el nombre del repositorio como argumento.

```yaml
structure:
files:
- README.md:
content: |
# MyProject
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ When defining your project structure in the YAML configuration file, you can use
Example:

```yaml
structure:
files:
- README.md:
skip: true
content: |
Expand Down Expand Up @@ -232,7 +232,7 @@ as you can see, the `author_name` variable is defined on the `variables` section
This filter fetches the latest release version of a GitHub repository. It takes the repository name as an argument.

```yaml
structure:
files:
- README.md:
content: |
# MyProject
Expand All @@ -250,7 +250,7 @@ NOTE: you can use this filter to get the latest release for a terraform provider
This filter converts a string into a slug. It takes an optional argument to specify the separator character (default is `-`).

```yaml
structure:
files:
- README.md:
content: |
# {{@ project_name @}}
Expand All @@ -263,7 +263,7 @@ structure:
This filter fetches the default branch name of a GitHub repository. It takes the repository name as an argument.

```yaml
structure:
files:
- README.md:
content: |
# MyProject
Expand Down
2 changes: 1 addition & 1 deletion example/structure.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- README.md:
skip: true
content: |
Expand Down
32 changes: 31 additions & 1 deletion struct-schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"structure": {
Expand All @@ -21,6 +21,36 @@
}
}
},
"files": {
"type": "array",
"items": {
"type": "object",
"patternProperties": {
".*": {
"type": "object",
"properties": {
"skip": {
"type": "boolean"
},
"skip_if_exists": {
"type": "boolean"
},
"content": {
"type": "string"
},
"permissions": {
"type": "string"
},
"file": {
"type": "string",
"format": "uri"
}
},
"additionalProperties": false
}
}
}
},
"folders": {
"type": "array",
"items": {
Expand Down
2 changes: 1 addition & 1 deletion struct_module/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _create_structure(self, args):
config = yaml.safe_load(f)

template_vars = dict(item.split('=') for item in args.vars.split(',')) if args.vars else None
config_structure = config.get('structure', [])
config_structure = config.get('files', config.get('structure', []))
config_folders = config.get('folders', [])
config_variables = config.get('variables', [])

Expand Down
6 changes: 3 additions & 3 deletions struct_module/commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _get_info(self, args):
print(f" 📌 Name: {args.structure_definition}\n")
print(f" 📌 Description: {config.get('description', 'No description')}\n")

if config.get('structure'):
print(f" 📌 Structure:")
for item in config.get('structure', []):
if config.get('files'):
print(f" 📌 Files:")
for item in config.get('files', []):
for name, content in item.items():
print(f" - {name} ")
# indent all lines of content
Expand Down
4 changes: 3 additions & 1 deletion struct_module/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def execute(self, args):
with open(args.yaml_file, 'r') as f:
config = yaml.safe_load(f)

self._validate_structure_config(config.get('structure', []))
if 'structure' in config and 'files' in config:
self.logger.warning("Both 'structure' and 'files' keys exist. Prioritizing 'structure'.")
self._validate_structure_config(config.get('structure') or config.get('files', []))
self._validate_folders_config(config.get('folders', []))
self._validate_variables_config(config.get('variables', []))

Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/ansible-playbook.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- main.yml:
content: |
- name: Example Playbook
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/chef-cookbook.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- recipes/default.rb:
content: |
package 'nginx' do
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/ci-cd-pipelines.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .gitlab-ci.yml:
content: |
stages:
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/cloudformation-files.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- template.yaml:
content: |
Resources:
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/configs/codeowners.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
structure:
files:
- CODEOWNERS: |
* @github_username
2 changes: 1 addition & 1 deletion struct_module/contribs/configs/devcontainer.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .devcontainer/devcontainer.json:
content: |
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/configs/editor-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
root = true
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/configs/eslint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .eslintrc.json:
content: |
{
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/configs/jshint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .jshintrc:
content: |
{
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/configs/prettier.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .prettierrc:
content: |
{
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/docker-files.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- Dockerfile:
content: |
FROM nginx:latest
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/documentation-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- README.md:
content: |
# {{@ project_name @}}
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/git-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .git/hooks/pre-commit:
permissions: 755
content: |
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/prompts/generic.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/prompts/generic.prompt.md:
content: |
Your prompt here
2 changes: 1 addition & 1 deletion struct_module/contribs/github/prompts/react-form.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/prompts/react-form.prompt.md:
content: |
Your goal is to generate a new React form component.
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/prompts/security-api.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/prompts/security-api.prompt.md:
content: |
Secure REST API review:
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/prompts/struct.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/prompts/struct.prompt.md:
content: |
# Struct Assistant
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/templates.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/PULL_REQUEST_TEMPLATE/bug_fix_template.md:
content: |
## Bug Fix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/workflows/execute-tf-{{@ app_name | slugify @}}.yaml:
content: |
name: 'execute-tf-{{@ app_name | slugify @}}'
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/workflows/labeler.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/labeler.yml:
content: |
# Add 'root' label to any root file changes
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/workflows/z-pre-commit.yaml:
content: |
name: z-pre-commit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/workflows/release-drafter.yaml:
content: |
name: release-drafter
Expand Down
4 changes: 2 additions & 2 deletions struct_module/contribs/github/workflows/run-struct.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/workflows/run-struct.yaml:
skip_if_exists: true
content: |
Expand All @@ -18,7 +18,7 @@ structure:
- .struct.yaml:
skip_if_exists: true
content: |
structure:
files:
- README.md:
content: |
# Sample content
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/github/workflows/stale.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .github/workflows/stale.yaml:
content: |
name: 'stale'
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/helm-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- Chart.yaml:
content: |
apiVersion: v2
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/kubernetes-manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- deployment.yaml:
content: |
apiVersion: apps/v1
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/generic.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .config/REMOVE_ME.md:
content: |
# .config Folder
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/go.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
# Editor configuration
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/java.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
# Editor configuration
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/nodejs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
# Editor configuration
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/python.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
# Editor configuration
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/ruby.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
# Editor configuration
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/project/rust.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- .editorconfig:
content: |
# Editor configuration
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/terraform/apps/generic.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- main.tf:
content: |
# This is the main Terraform app main file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- providers.yaml:
content: |
provider "github" {
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/terraform/modules/generic.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- main.tf:
content: |
resource "aws_instance" "example" {
Expand Down
2 changes: 1 addition & 1 deletion struct_module/contribs/vagrant-files.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
structure:
files:
- Vagrantfile:
content: |
Vagrant.configure("2") do |config|
Expand Down
Loading