npm package: @iron-tools/holiday
Description: A tool for adding current synchronized dates to the headlines of Days in index.yaml
Author: omardieh
Latest version: 1.1.2

# Holiday

A CLI tool for managing holiday insertions in course schedules defined in `index.yaml`.

## Table of Contents

- [Holiday](#holiday)
  - [Table of Contents](#table-of-contents)
  - [Overview](#overview)
  - [Features](#features)
  - [Installation](#installation)
  - [Usage](#usage)
    - [Options](#options)
    - [Examples](#examples)
  - [Error Handling](#error-handling)
  - [How It Works](#how-it-works)
  - [License](#license)

## Overview

The `holiday` package automates the process of inserting holidays into Ironhack course schedules. It marks specific days as holidays, redistributes content across weeks, and maintains sequential consistency in week and day numbering.

## Features

- Marks specific days as holidays in course schedules.
- Redistributes content across weeks to maintain balance.
- Renumbers weeks and days to ensure sequential consistency.
- Creates backups of the original file to prevent data loss.
- Provides detailed logs for transparency and debugging.

## Installation

Install the iron-tools CLI globally using npm:

```bash
npm install -g @iron-tools/cli
iron-tools --version
```

## Usage

In the same directory where the `index.yaml` file is located,
run the `holiday` tool using the `iron-tools` command:

```bash
iron-tools @holiday -f <index.yaml> -w <week> -d <day>
```

### Options

- `-w, --week <number>`: Week number where the holiday should be inserted.
- `-d, --day <number>`: Day number within the week to mark as a holiday.
- `-f, --file <filename>`: Path to the input YAML file (default: `index.yaml`).

### Examples

- In your terminal, insert a holiday on Week 2, Day 5 in the schedule:

```
  $: holidayzer -w 2 -d 5 -f ./index.yaml

  ✨ Holidayzer process started ✨

  • Validating arguments
    → validation for input file: "index.yaml", weekNum: 2, dayNum: 5
    ✓ arguments validation complete

  • Generating backup file
    → Creating backup of "index.yaml" to "backup-index.yaml"
    ✓ Backup created successfully

  • Reading and parsing input file
    → Successfully parsed 2578 lines from "index.yaml"
    ✓ File parsing complete

  • Identifying week blocks in course file
    → Located 11 week blocks in course structure
    ✓ Week identification complete

  • Extracting all day blocks from all weeks
    → Extracted 55 day blocks
    ✓ Day extraction complete

  • Inserting holiday at Week 2, Day 5
    → Inserted holiday at position 9 (total days now: 56)
    ✓ Holiday designation complete

  • Re-chunking days into weeks of 5 days each
    → Created 12 week blocks after re-chunking (1 additional weeks)
    ✓ Re-chunking complete

  • Building new week blocks from updated day lines
    → Built 12 week blocks with 56 days in total
    ✓ Week block building complete

  • Assembling final course structure with updated weeks and days
    → Composed output with 2702 lines
    ✓ Output composition complete

  • Identifying week blocks in course file
    → Located 12 week blocks in course structure
    ✓ Week identification complete

  • Updating week and day numbering for consistency
    → Renumbered 12 weeks and 56 days
    ✓ Renumbering complete

  • Writing updated schedule to "index.yaml"
    → Updated schedule saved to index.yaml
    ✓ File writing complete
```

- before and after `index.yaml` update

```
// before
# Week 2
- name: "Day 5" ##### M1 - W2 - D5 #####
  vertical:
    - name: ...
    - name: "DOM | Race Car Game"
    - name: "[LAB] LAB | DOM Race Car"
    - name: ...
# Week 3
- name: "Day 1" ##### M1 - W3 - D1 #####
  vertical:
    - name: ...
    - name: "CodeWars - Intro"
    - name: "[KATA] Code interview test: Anagrams"
    - name: ...
- name: "Day 2" ##### M1 - W3 - D2 #####
  vertical:
    - name: ...
    - name: "[KATA] Code interview test: Clocky Mc Clock-Face"
    - name: "[PROJECT] Project development"
    - name: ...
# !Week 11 (last week)
- name: "Day 5" ##### M4 - W11 - D5 #####
  vertical:
    - name: ...
    - name: "[PROJECT] Presentations - Project #4"
    - name: "[PROJECT] Project 4 Deliverables/GitHub repo-SERVER"
    - name: ...

// after // flagged the day as a Holiday
# Week 2
- name: "Day 5 [Holiday]" ##### M1 - W2 - D5 #####
  vertical:
    - name: ...
    - name: "DOM | Race Car Game"
    - name: "[LAB] LAB | DOM Race Car"
    - name: ...
# Week 3 // the same content as Week 2 day 5
- name: "Day 1" ##### M1 - W3 - D1 #####
  vertical:
    - ...
    - name: "DOM | Race Car Game"
    - name: "[LAB] LAB | DOM Race Car"
    - ...
- name: "Day 2" ##### M1 - W3 - D2 ##### // Week 3 day 1 shifted one day
  vertical:
    - ...
    - name: "CodeWars - Intro"
    - name: "[KATA] Code interview test: Anagrams"
    - ...
# !Week 12 (last week) // created a new week
- name: "Day 1" ##### M4 - W11 - D5 #####
  vertical:
    - name: ...
    - name: "[PROJECT] Presentations - Project #4"
    - name: "[PROJECT] Project 4 Deliverables/GitHub repo-SERVER"
    - name: ...
```

## Error Handling

The `holiday` tool provides detailed error messages for common issues, such as:

- Invalid file path or format.
- Invalid week or day number.
- Specified day is already marked as a holiday.
- Week number exceeds the total number of weeks in the course.

## How It Works

1. Parses the input `index.yaml` file to identify week and day blocks.
2. Marks the specified day as a holiday by adding `[Holiday]` to its name.
3. Redistributes remaining content across weeks to maintain 5 days per week.
4. Renumbers all weeks and days to ensure sequential consistency.
5. Creates a backup of the original file to ensure data safety.
6. Writes the updated schedule back to the file.

## License

This project is licensed under the MIT License. See the LICENSE file for details.

> **⚠️ This is a private proprietary package. Not intended for public use or redistribution.**