pacman-contribution-graph 1.0.10 → 1.0.12

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.
package/README.md CHANGED
@@ -1,24 +1,151 @@
1
- # Pacman Contribution Graph Game
1
+ # Pac-Man Contribution Graph Game
2
2
 
3
- This JavaScript library transforms your GitHub or GitLab contribution graph into an interactive Pac-Man-style game. It offers a unique and engaging way to visualize your coding activity over the past year.
3
+ Transform your GitHub or GitLab contribution graph into an interactive Pac-Man game! This JavaScript library offers a unique and engaging way to visualize your coding activity over the past year.
4
4
 
5
- ![Pacman contribution graph](assets/packman-demo.png)
5
+ <picture>
6
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/abozanona/abozanona/output/pacman-contribution-graph-dark.svg">
7
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/abozanona/abozanona/output/pacman-contribution-graph.svg">
8
+ <img alt="pacman contribution graph" src="https://raw.githubusercontent.com/abozanona/abozanona/output/pacman-contribution-graph.svg">
9
+ </picture>
6
10
 
7
11
  ## Features
8
12
 
13
+ Elevate your GitHub profile with the Pac-Man Contribution Graph Game and add a playful touch to your coding journey!
14
+
9
15
  - **Contribution Visualization**: Converts your GitHub or GitLab contribution data into a colorful grid.
10
- - **Interactive Gameplay**: Navigate Pac-Man through your contribution graph, eating dots based on your actual commits.
11
- - **Platform Support**: Compatible with both GitHub and GitLab contribution data.
12
- - **Dynamic Grid**: The game grid adapts to your contribution history, with cell colors reflecting commit intensity.
13
- - **Month Labels**: Displays month names above the grid for easy time reference.
14
- - **Pac-Man Mechanics**:
15
- - Pac-Man moves autonomously towards the nearest contribution cell.
16
- - Mouth animation mimics the classic Pac-Man game.
17
- - **Ghost AI**:
18
- - Four ghosts with unique colors chase Pac-Man.
19
- - Ghosts have different behaviors when Pac-Man has a power-up.
20
- - **Power-Up System**: Pac-Man can activate a power-up after eating enough dots, turning ghosts blue and vulnerable.
21
- - **Scoring**: Points are awarded for eating contribution dots and ghosts.
22
- - **Game Over**: The game ends when all contribution dots are consumed, with an option to reset.
23
-
24
- [Click here to try it out](https://abozanona.github.io/pacman-contribution-graph/)
16
+ - **Interactive Gameplay**: Navigate Pac-Man through your contributions, evading ghosts and collecting pellets.
17
+ - **Multiple Themes**: Choose between different themes, such as GitHub Dark and GitLab Dark.
18
+ - **Customizable Settings**: Adjust game speed, sound preferences, and output format (Canvas or SVG).
19
+
20
+ ## Demo
21
+
22
+ Experience the game firsthand:
23
+
24
+ **Live Demo**: [Pac-Man Contribution Game](https://abozanona.github.io/pacman-contribution-graph/)
25
+
26
+ ## Installation
27
+
28
+ To integrate the Pac-Man Contribution Graph into your project, you can install it via npm:
29
+
30
+ ```bash
31
+ npm install pacman-contribution-graph
32
+ ```
33
+
34
+ Alternatively, include it directly in your HTML using jsDelivr:
35
+
36
+ ```html
37
+ <script src="https://cdn.jsdelivr.net/npm/pacman-contribution-graph@1.0.10/dist/index.min.js"></script>
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Here's how to set up and run the Pac-Man Contribution Graph:
43
+
44
+ 1. **Include the Library**: Ensure the library is included in your project, either via npm or a script tag.
45
+ 2. **Initialize the Game**: Use the following code to generate the game:
46
+
47
+ ```javascript
48
+ import { generatePacManGame } from 'pacman-contribution-graph';
49
+
50
+ generatePacManGame({
51
+ username: 'your_username',
52
+ platform: 'github', // or 'gitlab'
53
+ theme: 'github-dark', // or 'gitlab-dark'
54
+ speed: 2,
55
+ sound: true,
56
+ output: 'canvas' // or 'svg'
57
+ });
58
+ ```
59
+
60
+ 3. **Customize Settings**: Adjust the parameters as needed:
61
+ - `username`: Your GitHub or GitLab username.
62
+ - `platform`: Specify `'github'` or `'gitlab'`.
63
+ - `theme`: Choose between available themes.
64
+ - `speed`: Set the game speed (e.g., `1` for normal, `2` for fast).
65
+ - `sound`: Enable or disable sound (`true` or `false`).
66
+ - `output`: Select `'canvas'` for browser play or `'svg'` for a downloadable animated SVG.
67
+
68
+ ## Integrate into Your GitHub Profile
69
+
70
+ To showcase the Pac-Man game on your GitHub profile, follow these steps:
71
+
72
+ 1. **Create a Special Repository**:
73
+
74
+ - Name a new repository exactly as your GitHub username (e.g., `username/username`).
75
+ - This repository powers your GitHub profile page.
76
+
77
+ 2. **Set Up GitHub Actions**:
78
+
79
+ - In the repository, create a `.github/workflows/` directory.
80
+ - Add a `main.yml` file with the following content:
81
+
82
+ ```yaml
83
+ name: generate pacman game
84
+
85
+ on:
86
+ schedule: # Run automatically every 24 hours
87
+ - cron: "0 */24 * * *"
88
+ workflow_dispatch: # Allows manual triggering
89
+ push: # Runs on every push to the main branch
90
+ branches:
91
+ - main
92
+
93
+ jobs:
94
+ generate:
95
+ permissions:
96
+ contents: write
97
+ runs-on: ubuntu-latest
98
+ timeout-minutes: 5
99
+
100
+ steps:
101
+ - name: generate pacman-contribution-graph.svg
102
+ uses: abozanona/pacman-contribution-graph@main
103
+ with:
104
+ github_user_name: ${{ github.repository_owner }}
105
+
106
+ # Push the generated SVG to the output branch
107
+ - name: push pacman-contribution-graph.svg to the output branch
108
+ uses: crazy-max/ghaction-github-pages@v3.1.0
109
+ with:
110
+ target_branch: output
111
+ build_dir: dist
112
+ env:
113
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114
+ ```
115
+
116
+ 3. **Add to Profile README**:
117
+
118
+ - In your repository, create or edit the `README.md` file to include:
119
+
120
+ ```markdown
121
+ ## My Contribution Graph
122
+
123
+ <picture>
124
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/[USERNAME]/[USERNAME]/output/pacman-contribution-graph-dark.svg">
125
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/[USERNAME]/[USERNAME]/output/pacman-contribution-graph.svg">
126
+ <img alt="pacman contribution graph" src="https://raw.githubusercontent.com/[USERNAME]/[USERNAME]/output/pacman-contribution-graph.svg">
127
+ </picture>
128
+ ```
129
+
130
+ 4. **Commit and Push**:
131
+ - Push the changes to GitHub. The GitHub Actions workflow will run daily, updating the Pac-Man game on your profile.
132
+
133
+ For a detailed guide, refer to the blog post: [Integrate Pac-Man Contribution Graph into Your GitHub Profile](https://abozanona.me/integrate-pacman-contribution-graph-into-github/)
134
+
135
+ ## Contributing
136
+
137
+ Contributions are welcome! To contribute:
138
+
139
+ 1. Fork the repository.
140
+ 2. Create a new branch: `git checkout -b feature-name`.
141
+ 3. Make your changes and commit them: `git commit -m 'Add feature'`.
142
+ 4. Push to the branch: `git push origin feature-name`.
143
+ 5. Submit a pull request.
144
+
145
+ ## Acknowledgements
146
+
147
+ Inspired by the [snk](https://github.com/Platane/snk) project, which turns your GitHub contribution graph into a snake game. Special thanks to all contributors and the open-source community for their support.
148
+
149
+ ## Online tools that use Pac-Man Contribution Graph Game
150
+
151
+ - Profile Readme Generator: [Website](https://profile-readme-generator.com/) • [Pull Request](https://github.com/maurodesouza/profile-readme-generator/pull/98)
package/action.yml ADDED
@@ -0,0 +1,16 @@
1
+ name: 'generate-pacman-game-from-github-contribution-grid'
2
+ description: 'Generates a Pacman game from a github user contributions grid. Output the animation as svg'
3
+ author: 'abozanona'
4
+
5
+ runs:
6
+ using: node20
7
+ main: github-action/dist/index.js
8
+
9
+ inputs:
10
+ github_user_name:
11
+ description: 'github user name'
12
+ required: true
13
+ github_token:
14
+ description: 'github token used to fetch the contribution calendar. Default to the action token if empty.'
15
+ required: false
16
+ default: ${{ github.token }}
@@ -1570,7 +1570,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
1570
1570
 
1571
1571
  const getGitlabContribution = (store) => __awaiter(void 0, void 0, void 0, function* () {
1572
1572
  // const response = await fetch(`https://gitlab.com/users/${username}/calendar.json`);
1573
- const response = yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}`);
1573
+ const response = yield fetch(`https://v0-new-project-q1hhrdodoye-abozanona-gmailcoms-projects.vercel.app/api/contributions?username=${store.config.username}`, { cache: 'no-store' });
1574
1574
  const contributionsList = yield response.json();
1575
1575
  return Object.entries(contributionsList).map(([date, count]) => ({
1576
1576
  date: new Date(date),
@@ -1589,8 +1589,10 @@ const getGithubContribution = (store) => __awaiter(void 0, void 0, void 0, funct
1589
1589
  if ((_a = store.config.githubSettings) === null || _a === void 0 ? void 0 : _a.accessToken) {
1590
1590
  headers['Authorization'] = 'Bearer ' + store.config.githubSettings.accessToken;
1591
1591
  }
1592
+ headers['Cache-Control'] = 'no-cache';
1592
1593
  const response = yield fetch(`https://api.github.com/search/commits?q=author:${store.config.username}&sort=author-date&order=desc&page=${page}&per_page=1000`, {
1593
- headers
1594
+ headers,
1595
+ cache: 'no-store'
1594
1596
  });
1595
1597
  const contributionsList = yield response.json();
1596
1598
  isComplete = contributionsList.items.length === 0;