taskninja 1.0.1 → 1.0.3

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.
Files changed (3) hide show
  1. package/README.md +233 -0
  2. package/app.js +10 -4
  3. package/package.json +4 -2
package/README.md ADDED
@@ -0,0 +1,233 @@
1
+ # TaskNinja
2
+
3
+ ![TaskNinja Logo](https://via.placeholder.com/150?text=TaskNinja) <!-- Optional: Replace with actual logo if available -->
4
+
5
+ A simple Command-Line Interface (CLI) application built with JavaScript for managing your to-do tasks. It allows users to add, list, update, and delete tasks interactively, with features like status tracking, priority levels, due dates, and descriptions. Tasks are stored in a local JSON file for persistence.
6
+
7
+ This project is designed for developers and users who prefer a lightweight, terminal-based task manager without the need for complex setups or databases.
8
+
9
+ ## Features
10
+
11
+ - **Add Tasks**: Create new tasks with title, status (todo, in-progress, done), priority (low, medium, high), due date, and optional description.
12
+ - **List Tasks**: View all tasks or filter by status in a tabular format.
13
+ - **Update Tasks**: Change the status of existing tasks via interactive selection.
14
+ - **Delete Tasks**: Remove tasks with confirmation to prevent accidental deletion.
15
+ - **Persistent Storage**: Tasks are saved to a local `todos.json` file.
16
+ - **Interactive Prompts**: Uses Inquirer for user-friendly input.
17
+ - **Validation**: Ensures valid statuses, priorities, and date formats.
18
+
19
+ ## Technologies Used
20
+
21
+ - **Node.js**: Runtime environment.
22
+ - **Commander**: For parsing command-line arguments and defining commands.
23
+ - **Inquirer**: For interactive CLI prompts.
24
+ - **fs/promises**: For asynchronous file system operations to handle task storage.
25
+ - **ECMAScript Modules (ESM)**: Modern JavaScript module system.
26
+
27
+ The application is written in pure JavaScript (ES6+), with no additional frameworks or databases required.
28
+
29
+ ## Installation
30
+
31
+ ### From npm
32
+
33
+ TaskNinja is published on npm as `taskninja`. Install it globally to use the CLI commands from anywhere:
34
+
35
+ ```bash
36
+ npm install -g taskninja
37
+ ```
38
+
39
+ After installation, you can run the CLI using the `dotask` command (as defined in `package.json`).
40
+
41
+ ### From Source
42
+
43
+ 1. Clone the repository:
44
+ ```bash
45
+ git clone https://github.com/yourusername/taskninja.git
46
+ cd taskninja
47
+ ```
48
+
49
+ 2. Install dependencies:
50
+ ```bash
51
+ npm install
52
+ ```
53
+
54
+ 3. Link the CLI globally (optional, for testing):
55
+ ```bash
56
+ npm link
57
+ ```
58
+
59
+ 4. Run the application:
60
+ ```bash
61
+ npm start
62
+ ```
63
+ Or directly:
64
+ ```bash
65
+ node app.js
66
+ ```
67
+
68
+ ## Usage
69
+
70
+ Run the CLI with the `dotask` command (after global installation) or `node app.js` from the source.
71
+
72
+ ### Commands
73
+
74
+ - **Add a Task**:
75
+ ```bash
76
+ dotask add
77
+ ```
78
+ - This will prompt you interactively for title, status, priority, due date, and description.
79
+ - Example output: "Task added successfully!"
80
+
81
+ - **List Tasks**:
82
+ ```bash
83
+ dotask list
84
+ ```
85
+ - Lists all tasks in a table format.
86
+ - Optional filter by status: `dotask list --status todo` (or `-s todo`).
87
+ - Aliases: `dotask ls`.
88
+
89
+ - **Update a Task**:
90
+ ```bash
91
+ dotask update
92
+ ```
93
+ - Prompts to select a task by ID and update its status.
94
+ - Displays the updated task in a table.
95
+ - Aliases: `dotask up`.
96
+
97
+ - **Delete a Task**:
98
+ ```bash
99
+ dotask delete
100
+ ```
101
+ - Prompts to select a task by ID and confirm deletion.
102
+ - Aliases: `dotask del`.
103
+
104
+ - **Help**:
105
+ ```bash
106
+ dotask --help
107
+ ```
108
+ - Shows all available commands and options.
109
+
110
+ - **Version**:
111
+ ```bash
112
+ dotask --version
113
+ ```
114
+ - Displays the current version (1.0.0).
115
+
116
+ ### Examples
117
+
118
+ 1. Adding a task:
119
+ ```
120
+ dotask add
121
+ ```
122
+ - Follow prompts: Enter "Buy groceries" as title, select "todo" status, "medium" priority, "2024-12-31" due date, and "Milk, eggs, bread" as description.
123
+
124
+ 2. Listing tasks filtered by status:
125
+ ```
126
+ dotask list -s in-progress
127
+ ```
128
+
129
+ 3. Updating a task:
130
+ ```
131
+ dotask update
132
+ ```
133
+ - Select task ID from the list and choose new status (e.g., "done").
134
+
135
+ 4. Deleting a task:
136
+ ```
137
+ dotask delete
138
+ ```
139
+ - Select task ID and confirm.
140
+
141
+ Tasks are stored in `./todos.json` relative to where the command is run. Ensure write permissions in the directory.
142
+
143
+ ## Configuration
144
+
145
+ - **Task File**: Defaults to `./todos.json`. You can modify `TASKS_FILE` in `app.js` if needed.
146
+ - **Statuses**: Limited to "todo", "in-progress", "done".
147
+ - **Priorities**: Limited to "low", "medium", "high".
148
+ - **Due Date Format**: YYYY-MM-DD (validated during input).
149
+
150
+ No external configuration files are required.
151
+
152
+ ## Development
153
+
154
+ To run in development mode:
155
+ ```bash
156
+ npm run dev
157
+ ```
158
+
159
+ This executes `node app.js` for quick testing.
160
+
161
+ ### Scripts
162
+
163
+ - `npm start`: Runs the app.
164
+ - `npm test`: Placeholder for tests (currently errors out; add tests as needed).
165
+
166
+ ## Contribution Guidelines
167
+
168
+ We welcome contributions to improve TaskNinja! Whether it's bug fixes, new features, or documentation enhancements, follow these steps:
169
+
170
+ ### How to Contribute
171
+
172
+ 1. **Fork the Repository**:
173
+ - Go to the [GitHub repo](https://github.com/yourusername/taskninja) and click "Fork".
174
+
175
+ 2. **Clone Your Fork**:
176
+ ```bash
177
+ git clone https://github.com/yourusername/taskninja.git
178
+ cd taskninja
179
+ ```
180
+
181
+ 3. **Create a Branch**:
182
+ - Use a descriptive name: `git checkout -b feature/new-feature` or `git checkout -b fix/bug-fix`.
183
+
184
+ 4. **Make Changes**:
185
+ - Follow the existing code style (ESLint can be added later for consistency).
186
+ - Add or update tests if applicable.
187
+ - Ensure your code handles errors gracefully and maintains validation logic.
188
+
189
+ 5. **Commit Changes**:
190
+ - Use clear commit messages: e.g., "feat: add search functionality" or "fix: resolve date validation issue".
191
+ - Reference issues if relevant: e.g., "Closes #123".
192
+
193
+ 6. **Push to Your Fork**:
194
+ ```bash
195
+ git push origin feature/new-feature
196
+ ```
197
+
198
+ 7. **Open a Pull Request (PR)**:
199
+ - Go to the original repo and click "New Pull Request".
200
+ - Provide a detailed description of your changes, including why they're needed and any relevant screenshots.
201
+ - Link to any related issues.
202
+
203
+ ### Guidelines
204
+
205
+ - **Code Style**: Use consistent indentation (2 spaces), semicolons, and follow ES6+ best practices.
206
+ - **Testing**: Add unit tests using a framework like Jest if expanding features. Currently, no tests are implemented—contributions here are encouraged!
207
+ - **Dependencies**: Keep them minimal. Justify any new additions.
208
+ - **Features**: New commands or options should align with the simple CLI philosophy. Discuss major changes in an issue first.
209
+ - **Documentation**: Update README.md with any new features or changes.
210
+ - **Issues**: Check for existing issues before creating a new one. Use labels like "bug", "enhancement", or "question".
211
+
212
+ ### Code of Conduct
213
+
214
+ - Be respectful and inclusive.
215
+ - No harassment or discrimination.
216
+ - Report issues to the maintainer (Mohamed Bakr).
217
+
218
+ By contributing, you agree that your contributions will be licensed under the ISC License.
219
+
220
+ ## License
221
+
222
+ This project is licensed under the ISC License.
223
+
224
+ ## Author
225
+
226
+ - **Mohamed Bakr** - Just a Developer - [GitHub Profile](https://github.com/MoBMoCaffeine)
227
+
228
+ ## Acknowledgments
229
+
230
+ - Inspired by simple CLI tools like Todoist CLI.
231
+ - Thanks to the open-source community for libraries like Commander and Inquirer.
232
+
233
+ If you encounter issues or have suggestions, open an issue on GitHub!
package/app.js CHANGED
@@ -214,14 +214,17 @@ program
214
214
  await saveTasks(tasks);
215
215
  console.log('Task updated successfully!');
216
216
 
217
- console.table([{
217
+ const tableData = tasks.map(task => ({
218
218
  ID: task.id,
219
219
  Title: task.title,
220
220
  Status: task.status,
221
221
  Priority: task.priority,
222
222
  DueDate: task.dueDate,
223
223
  Description: task.description || ''
224
- }]);
224
+ }));
225
+
226
+ // display all tasks in table format
227
+ console.table(tableData);
225
228
  });
226
229
 
227
230
  // use command 'delete' with task ID and action
@@ -262,14 +265,17 @@ program
262
265
  await saveTasks(newTasks);
263
266
  console.log('Task deleted successfully!');
264
267
 
265
- console.table([{
268
+ const tableData = tasks.map(task => ({
266
269
  ID: task.id,
267
270
  Title: task.title,
268
271
  Status: task.status,
269
272
  Priority: task.priority,
270
273
  DueDate: task.dueDate,
271
274
  Description: task.description || ''
272
- }]);
275
+ }));
276
+
277
+ // display all tasks in table format
278
+ console.table(tableData);
273
279
  });
274
280
 
275
281
  // parse command line arguments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskninja",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "a simple CLI application with JS as a (To-Do Application)",
5
5
  "main": "app.js",
6
6
  "type" : "module",
@@ -10,7 +10,9 @@
10
10
  "dev": "node app.js"
11
11
  },
12
12
  "bin" : {
13
- "dotask": "./app.js"
13
+ "dotask": "./app.js",
14
+ "taskninja": "./app.js",
15
+ "tn": "./app.js"
14
16
  },
15
17
  "author": "Moahmed Bakr",
16
18
  "license": "ISC",