nolimit-x 1.0.28 → 1.0.30
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 +1 -1
- package/src/cli.js +87 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -5,6 +5,8 @@ const path = require('path');
|
|
|
5
5
|
const init = require("./init");
|
|
6
6
|
const nodemailer = require('nodemailer');
|
|
7
7
|
const { spawn } = require('child_process');
|
|
8
|
+
const ora = require("ora");
|
|
9
|
+
const getOra = ora.default || ora;
|
|
8
10
|
// const { send } = require("./sender"); // We'll use sendEmails for email mode
|
|
9
11
|
|
|
10
12
|
const program = new Command();
|
|
@@ -193,6 +195,55 @@ function validateEmailWorkspace(workspace = '.') {
|
|
|
193
195
|
console.log('Email workspace validated.');
|
|
194
196
|
}
|
|
195
197
|
|
|
198
|
+
function printBanner() {
|
|
199
|
+
console.log(`\n\x1b[36m` +
|
|
200
|
+
` _ _ _ _ _ _ _ \n| \\ | | ___ | | | __| (_)___| |_ \n| \\| |/ _ \\| | |/ _| | / __| __|\n| |\\ | (_) | | | (_| | \\__ \\ |_ \n|_| \\_|\\___/|_|_|\\__,_|_|___/\\__|\n` + '\x1b[0m');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function printSMSBanner() {
|
|
204
|
+
// Red color: \x1b[31m
|
|
205
|
+
console.log(`\n\x1b[31m` +
|
|
206
|
+
` _ _ _ _ _ _ _ \n| \\ | | ___ | | | __| (_)___| |_ \n| \\| |/ _ \\| | |/ _| | / __| __|\n| |\\ | (_) | | | (_| | \\__ \\ |_ \n|_| \\_|\\___/|_|_|\\__,_|_|___/\\__|\n` + '\x1b[0m');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function initSMSWorkspace(workspace) {
|
|
210
|
+
printBanner();
|
|
211
|
+
const spinner = getOra('Setting up workspace ...').start();
|
|
212
|
+
const fs = require('fs');
|
|
213
|
+
const path = require('path');
|
|
214
|
+
const dir = path.resolve(process.cwd(), workspace);
|
|
215
|
+
if (fs.existsSync(dir)) {
|
|
216
|
+
spinner.fail(`Directory ${workspace} already exists!`);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
221
|
+
fs.writeFileSync(path.join(dir, 'config.json'), JSON.stringify({
|
|
222
|
+
mode: "smtp_sms",
|
|
223
|
+
smtp_sms: true,
|
|
224
|
+
api: false,
|
|
225
|
+
system: { message_delay: 2, max_retries: 3 }
|
|
226
|
+
}, null, 2));
|
|
227
|
+
fs.writeFileSync(path.join(dir, 'numbers.txt'), "# List phone numbers here\n");
|
|
228
|
+
fs.writeFileSync(path.join(dir, 'messages.txt'), "# List SMS messages here\n");
|
|
229
|
+
fs.writeFileSync(path.join(dir, 'senders.txt'), "# List sender names or emails here\n");
|
|
230
|
+
fs.mkdirSync(path.join(dir, 'smtp-gateways'), { recursive: true });
|
|
231
|
+
fs.mkdirSync(path.join(dir, 'api'), { recursive: true });
|
|
232
|
+
fs.writeFileSync(path.join(dir, 'api', 'twilio.json'), JSON.stringify({
|
|
233
|
+
accountSid: "your_twilio_sid",
|
|
234
|
+
authToken: "your_twilio_token",
|
|
235
|
+
from: "+1234567890"
|
|
236
|
+
}, null, 2));
|
|
237
|
+
await new Promise(res => setTimeout(res, 2000));
|
|
238
|
+
spinner.text = 'Workspace ready';
|
|
239
|
+
await new Promise(res => setTimeout(res, 1000));
|
|
240
|
+
spinner.succeed('Template ready');
|
|
241
|
+
} catch (error) {
|
|
242
|
+
spinner.fail("Error during SMS workspace initialization.");
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
196
247
|
program
|
|
197
248
|
.name("nolimit")
|
|
198
249
|
.version("1.0.0")
|
|
@@ -207,15 +258,47 @@ program
|
|
|
207
258
|
init(projectName);
|
|
208
259
|
});
|
|
209
260
|
|
|
210
|
-
|
|
261
|
+
// Refactor SMS to use a nested subcommand for init
|
|
262
|
+
const sms = program
|
|
211
263
|
.command("sms")
|
|
212
|
-
.description("Switch to SMS mode
|
|
213
|
-
|
|
264
|
+
.description("Switch to SMS mode or manage SMS workspaces");
|
|
265
|
+
|
|
266
|
+
sms
|
|
267
|
+
.command("init <workspace>")
|
|
268
|
+
.description("Initialize a new SMS phonebook workspace")
|
|
269
|
+
.action((workspace) => {
|
|
270
|
+
initSMSWorkspace(workspace);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
sms
|
|
274
|
+
.action(() => {
|
|
275
|
+
const spinner = getOra('Switching to SMS mode...').start();
|
|
276
|
+
try {
|
|
277
|
+
validateSMSWorkspace();
|
|
278
|
+
setMode("sms");
|
|
279
|
+
spinner.succeed('Switched to SMS mode. Workspace ready.');
|
|
280
|
+
} catch (err) {
|
|
281
|
+
spinner.fail('Workspace missing required SMS files!');
|
|
282
|
+
printSMSBanner();
|
|
283
|
+
console.log("\x1b[31mSMS workspace not detected. Run 'nolimit sms init <workspace>' to create one.\x1b[0m");
|
|
284
|
+
}
|
|
285
|
+
});
|
|
214
286
|
|
|
215
287
|
program
|
|
216
288
|
.command("email")
|
|
217
289
|
.description("Switch to email mode (email campaign workspace)")
|
|
218
|
-
.action(() =>
|
|
290
|
+
.action(() => {
|
|
291
|
+
const spinner = getOra('Switching to Email mode...').start();
|
|
292
|
+
try {
|
|
293
|
+
validateEmailWorkspace();
|
|
294
|
+
setMode("email");
|
|
295
|
+
spinner.succeed('Switched to Email mode. Workspace ready.');
|
|
296
|
+
} catch (err) {
|
|
297
|
+
spinner.fail('Workspace missing required email files!');
|
|
298
|
+
printBanner();
|
|
299
|
+
console.log("\x1b[36mEmail workspace not detected. Run 'nolimit init <workspace>' to create one.\x1b[0m");
|
|
300
|
+
}
|
|
301
|
+
});
|
|
219
302
|
|
|
220
303
|
program
|
|
221
304
|
.command("send")
|