nolimit-x 1.0.2 → 1.0.4
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/init.js +7 -20
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -3,23 +3,20 @@ const path = require("path");
|
|
|
3
3
|
|
|
4
4
|
function printBanner() {
|
|
5
5
|
console.log(`\n\x1b[36m` +
|
|
6
|
-
` _ _ _ _ _ _ _ \n| \ | | ___ | | | __| (_)___| |_ \n| \| |/ _ \| | |/ _
|
|
6
|
+
` _ _ _ _ _ _ _ \n| \ | | ___ | | | __| (_)___| |_ \n| \| |/ _ \| | |/ _| | / __| __|\n| |\ | (_) | | | (_| | \__ \ |_ \n|_| \_|\___/|_|_|\__,_|_|___/\__|\n` + '\x1b[0m');
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function copyTemplate(src, dest) {
|
|
10
10
|
try {
|
|
11
11
|
const srcPath = path.join(__dirname, "../templates", src);
|
|
12
12
|
const destPath = path.join(dest, src);
|
|
13
|
-
console.log(`Copying from ${srcPath} to ${destPath}`);
|
|
14
13
|
fs.copyFileSync(srcPath, destPath);
|
|
15
14
|
} catch (err) {
|
|
16
|
-
console.error(`Failed to copy template ${src}:`, err);
|
|
17
15
|
throw err;
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
function fixConfigPaths(configPath, workspace) {
|
|
22
|
-
// Read config, update all file paths to be relative to workspace
|
|
23
20
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
24
21
|
if (config.emails_list) config.emails_list.path = "emails.txt";
|
|
25
22
|
if (config.senders_list) config.senders_list.path = "senders.txt";
|
|
@@ -36,40 +33,30 @@ async function init(projectName) {
|
|
|
36
33
|
printBanner();
|
|
37
34
|
process.stdout.write('Setting up workspace...');
|
|
38
35
|
const projectPath = path.resolve(process.cwd(), projectName);
|
|
39
|
-
console.log("Project path:", projectPath);
|
|
40
|
-
|
|
41
36
|
if (fs.existsSync(projectPath)) {
|
|
42
37
|
console.error(`\nDirectory ${projectName} already exists.`);
|
|
43
38
|
process.exit(1);
|
|
44
39
|
}
|
|
45
|
-
|
|
46
40
|
try {
|
|
47
41
|
fs.mkdirSync(projectPath);
|
|
48
|
-
console.log("Created directory:", projectPath);
|
|
49
|
-
|
|
50
|
-
// Create attachments dir if needed
|
|
51
42
|
const attachmentsDir = path.join(projectPath, "attachments");
|
|
52
43
|
if (!fs.existsSync(attachmentsDir)) fs.mkdirSync(attachmentsDir);
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
const files = ["config.json", "emails.txt", "senders.txt", "messages.html"];
|
|
45
|
+
files.forEach(file => {
|
|
55
46
|
copyTemplate(file, projectPath);
|
|
56
|
-
console.log("Copied template:", file);
|
|
57
47
|
});
|
|
58
|
-
|
|
59
|
-
// Fix config paths
|
|
60
48
|
fixConfigPaths(path.join(projectPath, "config.json"), projectPath);
|
|
61
|
-
|
|
62
49
|
// Simulate progress
|
|
63
50
|
await new Promise(res => setTimeout(res, 800));
|
|
64
51
|
process.stdout.clearLine();
|
|
65
52
|
process.stdout.cursorTo(0);
|
|
66
|
-
console.log("
|
|
67
|
-
console.log("Template
|
|
68
|
-
|
|
53
|
+
console.log("Workspace ready!");
|
|
54
|
+
console.log("Template ready ..");
|
|
55
|
+
files.forEach(file => {
|
|
69
56
|
console.log(` - ${file}`);
|
|
70
57
|
});
|
|
71
58
|
console.log(" - attachments/ (directory)");
|
|
72
|
-
console.log(
|
|
59
|
+
console.log(`Initialized new campaign in '${projectName}'`);
|
|
73
60
|
} catch (error) {
|
|
74
61
|
console.error("Error during initialization:", error);
|
|
75
62
|
process.exit(1);
|