@qodalis/cli-todo 0.0.6 → 2.0.0-beta.1
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/package.json +14 -22
- package/public-api.d.mts +48 -0
- package/public-api.d.ts +48 -2
- package/public-api.js +521 -0
- package/public-api.js.map +1 -0
- package/public-api.mjs +512 -0
- package/public-api.mjs.map +1 -0
- package/umd/cli-entrypoint.global.js +3308 -0
- package/README.md +0 -34
- package/esm2022/lib/cli-todo.module.mjs +0 -19
- package/esm2022/lib/processors/cli-todo-command-processor.mjs +0 -181
- package/esm2022/lib/version.mjs +0 -3
- package/esm2022/public-api.mjs +0 -6
- package/esm2022/qodalis-cli-todo.mjs +0 -5
- package/fesm2022/qodalis-cli-todo.mjs +0 -210
- package/fesm2022/qodalis-cli-todo.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/cli-todo.module.d.ts +0 -6
- package/lib/processors/cli-todo-command-processor.d.ts +0 -23
- package/lib/version.d.ts +0 -1
- package/umd/index.js +0 -220
package/umd/index.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@qodalis/cli-core'), require('@angular/core')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['@qodalis/cli-core', '@angular/core'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.cliCore, global.ngCore));
|
|
5
|
-
})(this, (function (cliCore, core) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/******************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function __decorate(decorators, target, key, desc) {
|
|
25
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
27
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
28
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
-
var e = new Error(message);
|
|
33
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// Automatically generated during build
|
|
37
|
-
const LIBRARY_VERSION = '0.0.6';
|
|
38
|
-
|
|
39
|
-
let CliTodoCommandProcessor = class CliTodoCommandProcessor {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.command = 'todo';
|
|
42
|
-
this.description = 'A command-line tool for managing your tasks efficiently. Add, list, complete, and remove TODO items with simple commands.';
|
|
43
|
-
this.author = cliCore.DefaultLibraryAuthor;
|
|
44
|
-
this.version = LIBRARY_VERSION;
|
|
45
|
-
this.processors = [];
|
|
46
|
-
this.metadata = {
|
|
47
|
-
icon: '📝',
|
|
48
|
-
requiredCoreVersion: '0.0.16',
|
|
49
|
-
requiredCliVersion: '1.0.37',
|
|
50
|
-
};
|
|
51
|
-
this.stateConfiguration = {
|
|
52
|
-
initialState: {
|
|
53
|
-
todos: this.loadFromOldStorage() ?? [],
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
this.todos = [];
|
|
57
|
-
this.nextId = 1;
|
|
58
|
-
this.registerSubProcessors();
|
|
59
|
-
}
|
|
60
|
-
async processCommand(command, context) {
|
|
61
|
-
context.executor.showHelp(command, context);
|
|
62
|
-
}
|
|
63
|
-
writeDescription(context) {
|
|
64
|
-
const { writer } = context;
|
|
65
|
-
writer.writeln(this.description);
|
|
66
|
-
writer.writeln();
|
|
67
|
-
writer.writeln('📋 Commands:');
|
|
68
|
-
writer.writeln(` ${writer.wrapInColor('todo ls', cliCore.CliForegroundColor.Cyan)} 📃 List all TODO items`);
|
|
69
|
-
writer.writeln(` ${writer.wrapInColor('todo add <text>', cliCore.CliForegroundColor.Cyan)} ➕ Add a new TODO item`);
|
|
70
|
-
writer.writeln(` ${writer.wrapInColor('todo rm <id>', cliCore.CliForegroundColor.Cyan)} 🗑 Remove a TODO item by ID`);
|
|
71
|
-
writer.writeln(` ${writer.wrapInColor('todo rm --all', cliCore.CliForegroundColor.Cyan)} 🗑 Remove all TODO items`);
|
|
72
|
-
writer.writeln(` ${writer.wrapInColor('todo complete <id>', cliCore.CliForegroundColor.Cyan)} ✔ Mark a TODO as completed`);
|
|
73
|
-
writer.writeln();
|
|
74
|
-
writer.writeln('📝 Examples:');
|
|
75
|
-
writer.writeln(` todo add Buy milk ${writer.wrapInColor('# Add a new task', cliCore.CliForegroundColor.Green)}`);
|
|
76
|
-
writer.writeln(` todo ls ${writer.wrapInColor('# View all tasks', cliCore.CliForegroundColor.Green)}`);
|
|
77
|
-
writer.writeln(` todo complete 1 ${writer.wrapInColor('# Mark task #1 done', cliCore.CliForegroundColor.Green)}`);
|
|
78
|
-
writer.writeln(` todo rm 2 ${writer.wrapInColor('# Delete task #2', cliCore.CliForegroundColor.Green)}`);
|
|
79
|
-
}
|
|
80
|
-
async initialize(context) {
|
|
81
|
-
context.state
|
|
82
|
-
.select((x) => x['todos'])
|
|
83
|
-
.subscribe((todos) => {
|
|
84
|
-
this.todos = todos;
|
|
85
|
-
this.nextId =
|
|
86
|
-
this.todos.length > 0
|
|
87
|
-
? Math.max(...this.todos.map((t) => t.id)) + 1
|
|
88
|
-
: 1;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
lineThroughText(text) {
|
|
92
|
-
return text
|
|
93
|
-
.split('')
|
|
94
|
-
.map((char) => char + '\u0336')
|
|
95
|
-
.join('');
|
|
96
|
-
}
|
|
97
|
-
registerSubProcessors() {
|
|
98
|
-
this.processors = [
|
|
99
|
-
{
|
|
100
|
-
command: 'ls',
|
|
101
|
-
description: 'List all TODO items',
|
|
102
|
-
processCommand: async (_, context) => {
|
|
103
|
-
if (this.todos.length === 0) {
|
|
104
|
-
context.writer.writeWarning('No TODO items found.');
|
|
105
|
-
context.writer.writeln('Use "todo add <text>" to add a new TODO item.');
|
|
106
|
-
context.process.output(JSON.stringify(this.todos));
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
this.todos.forEach((todo) => {
|
|
110
|
-
context.writer.writeln(`[${todo.completed ? context.writer.wrapInColor(cliCore.CliIcon.CheckIcon, cliCore.CliForegroundColor.Green) : ' '}] #${todo.id} - ${todo.text}`);
|
|
111
|
-
});
|
|
112
|
-
context.process.output(this.todos);
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
command: 'add',
|
|
117
|
-
description: 'Add a new TODO item',
|
|
118
|
-
allowUnlistedCommands: true,
|
|
119
|
-
valueRequired: true,
|
|
120
|
-
processCommand: async (command, context) => {
|
|
121
|
-
const text = command.value;
|
|
122
|
-
if (!text) {
|
|
123
|
-
context.writer.writeError('Please provide a TODO description.');
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const newItem = {
|
|
127
|
-
id: this.nextId++,
|
|
128
|
-
text,
|
|
129
|
-
completed: false,
|
|
130
|
-
};
|
|
131
|
-
this.todos.push(newItem);
|
|
132
|
-
await this.saveToStorage(context);
|
|
133
|
-
context.writer.writeSuccess(`Added TODO: "${text}"`);
|
|
134
|
-
context.process.output(newItem.id.toString());
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
command: 'rm',
|
|
139
|
-
description: 'Remove a TODO item by ID',
|
|
140
|
-
allowUnlistedCommands: true,
|
|
141
|
-
parameters: [
|
|
142
|
-
{
|
|
143
|
-
name: 'all',
|
|
144
|
-
description: 'Remove all TODO items',
|
|
145
|
-
type: 'boolean',
|
|
146
|
-
defaultValue: false,
|
|
147
|
-
aliases: ['a'],
|
|
148
|
-
required: false,
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
processCommand: async (command, context) => {
|
|
152
|
-
if (command.args['all'] || command.args['a']) {
|
|
153
|
-
this.todos = [];
|
|
154
|
-
await this.saveToStorage(context);
|
|
155
|
-
context.writer.writeSuccess('Removed all TODO items.');
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const id = parseInt(command.value, 10);
|
|
159
|
-
if (isNaN(id)) {
|
|
160
|
-
context.writer.writeError('Please provide a valid TODO ID.');
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const index = this.todos.findIndex((todo) => todo.id === id);
|
|
164
|
-
if (index === -1) {
|
|
165
|
-
context.writer.writeInfo(`TODO item with ID ${id} not found.`);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.todos.splice(index, 1);
|
|
169
|
-
await this.saveToStorage(context);
|
|
170
|
-
context.writer.writeSuccess(`Removed TODO item with ID ${id}.`);
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
command: 'complete',
|
|
175
|
-
description: 'Mark a TODO item as completed by ID',
|
|
176
|
-
allowUnlistedCommands: true,
|
|
177
|
-
valueRequired: true,
|
|
178
|
-
processCommand: async (command, context) => {
|
|
179
|
-
const id = parseInt(command.value || '', 10);
|
|
180
|
-
if (isNaN(id)) {
|
|
181
|
-
context.writer.writeln('Please provide a valid TODO ID.');
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const todo = this.todos.find((todo) => todo.id === id);
|
|
185
|
-
if (!todo) {
|
|
186
|
-
context.writer.writeError(`TODO item with ID ${id} not found.`);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (todo.completed) {
|
|
190
|
-
context.writer.writeInfo(`TODO item with ID ${id} is already completed.`);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
todo.completed = true;
|
|
194
|
-
await this.saveToStorage(context);
|
|
195
|
-
context.writer.writeSuccess(`Marked TODO item with ID ${id} as completed.`);
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
];
|
|
199
|
-
}
|
|
200
|
-
loadFromOldStorage() {
|
|
201
|
-
const data = localStorage.getItem('todo-items');
|
|
202
|
-
return data ? JSON.parse(data) : [];
|
|
203
|
-
}
|
|
204
|
-
async saveToStorage(context) {
|
|
205
|
-
context.state.updateState({ todos: this.todos });
|
|
206
|
-
await context.state.persist();
|
|
207
|
-
localStorage.removeItem('todo-items');
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
CliTodoCommandProcessor = __decorate([
|
|
211
|
-
core.Injectable()
|
|
212
|
-
], CliTodoCommandProcessor);
|
|
213
|
-
|
|
214
|
-
const module = {
|
|
215
|
-
name: '@qodalis/cli-todo',
|
|
216
|
-
processors: [new CliTodoCommandProcessor()],
|
|
217
|
-
};
|
|
218
|
-
cliCore.bootUmdModule(module);
|
|
219
|
-
|
|
220
|
-
}));
|