donbot-cli 1.0.8 → 1.0.10

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/cli/access.js CHANGED
@@ -156,4 +156,81 @@ const createKey = async (user, app, description, expiration, options) => {
156
156
 
157
157
  };
158
158
 
159
- module.exports = { createKey, registry };
159
+ const createKeyProd = async (user, app, TOKEN_KEY, description, expiration, options) => {
160
+
161
+ console.log(`
162
+ _____ _______ __ _ ______ _______ _______
163
+ | | | || | | || _ | | || |
164
+ | _ | | _ || || || | | | | _ ||_ _|
165
+ | | | || | | || || | | | | | | |
166
+ | |_| | | |_| || _ || _ | | |_| | | |
167
+ | | | || | | || |_| | | | | |
168
+ |____| |_______||_| |___||_____| |_______| |___|
169
+
170
+ DonBot CLI - Herramienta para operaciones automatizadas.
171
+ `);
172
+
173
+ console.log("Crear llave...");
174
+
175
+ if (!user || !app || !TOKEN_KEY || !description || !expiration) {
176
+ console.error('❌ Verifique que los siguientes valores estén definidos: mail, first_name, last_name, password.');
177
+ process.exit(1);
178
+ }
179
+
180
+
181
+ let today = new Date().toISOString();
182
+
183
+ const payload = {
184
+ user: user,
185
+ app: app,
186
+ creationDate: today,
187
+ expiresIn: expiration
188
+ };
189
+
190
+ let expiresobj;
191
+ let expiresday;
192
+ if(expiration == "noexpire"){
193
+ expiresobj = "";
194
+ expiresday = expiration;
195
+ }else{
196
+ expiresobj = {
197
+ expiresIn: expiration
198
+ };
199
+ expiresday = expiration;
200
+ }
201
+
202
+ const access_token = jwt.sign(payload, TOKEN_KEY, expiresobj);
203
+
204
+ let keydata = {
205
+ user: user,
206
+ app: app,
207
+ description: description,
208
+ key: access_token,
209
+ creationDate: today,
210
+ expirationDate: expiresday,
211
+ active: true
212
+ };
213
+
214
+ try {
215
+ console.log("Inserta este registro en la coleccion accesstokens");
216
+ console.log(keydata);
217
+ } catch (error) {
218
+ console.error("❌ Error en la creación de usuario:", error.message);
219
+ process.exit(1);
220
+ }
221
+
222
+ let keyreso = {
223
+ user: keydata.user,
224
+ app: app,
225
+ description: keydata.description,
226
+ key: keydata.key
227
+ };
228
+
229
+ console.log("✅ Usuario creado exitosamente el usuario " + user + ".");
230
+ console.table(keyreso);
231
+
232
+ process.exit(0);
233
+
234
+ };
235
+
236
+ module.exports = { createKey, createKeyProd, registry };
package/cli/deploy.js CHANGED
@@ -111,4 +111,28 @@ const uploadCodeToServer = async (uploadCodeToServer, options) => {
111
111
  });
112
112
  };
113
113
 
114
- module.exports = { uploadCodeToServer };
114
+ const validCode_donbot = async (uploadCodeToServer, options) => {
115
+ console.log(`
116
+ _____ _______ __ _ ______ _______ _______
117
+ | | | || | | || _ | | || |
118
+ | _ | | _ || || || | | | | _ ||_ _|
119
+ | | | || | | || || | | | | | | |
120
+ | |_| | | |_| || _ || _ | | |_| | | |
121
+ | | | || | | || |_| | | | | |
122
+ |____| |_______||_| |___||_____| |_______| |___|
123
+
124
+ DonBot CLI - Herramienta para operaciones automatizadas.
125
+ `);
126
+
127
+ try {
128
+ console.log("Validando código...");
129
+ await validCode();
130
+ console.log("✅ Código válido.");
131
+ } catch (err) {
132
+ console.log("❌ El código no es válido.");
133
+ console.error(err.stdout?.toString() || err.message);
134
+ process.exit(1);
135
+ }
136
+ };
137
+
138
+ module.exports = { uploadCodeToServer, validCode_donbot };
package/donbot.js CHANGED
@@ -43,6 +43,14 @@ program.
43
43
  access.createKey(user, app, description, expiration, options);
44
44
  });
45
45
 
46
+ program.
47
+ command("prodaccess <user> <app> <TOKEN_KEY> <description> <expiration>").
48
+ alias("pac").
49
+ description("Crea un App Key que se debera usar en prod , para una key sin expiracion enviar el valor noexpire en lugar del numero de dias u horas (2 days, 10h, 7d)").
50
+ action((user, app, TOKEN_KEY, description, expiration, options) => {
51
+ access.createKeyProd(user, app, TOKEN_KEY, description, expiration, options);
52
+ });
53
+
46
54
 
47
55
  //Lectura de archivo
48
56
  /*program.
@@ -73,6 +81,14 @@ program.
73
81
  deploy.uploadCodeToServer(type_deploy, options);
74
82
  });
75
83
 
84
+ program.
85
+ command("validcode").
86
+ alias("vc").
87
+ description(`Ejecuta una validacion del codigo en el proyecto.`).
88
+ action(() => {
89
+ deploy.validCode_donbot();
90
+ });
91
+
76
92
  // Flow
77
93
 
78
94
  program.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "donbot-cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Cli de donbot",
5
5
  "main": "donbot.js",
6
6
  "bin": {