@profitlich/template-toolkit 2.7.4 → 2.9.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/scripts/deploy.js +32 -5
package/package.json
CHANGED
package/scripts/deploy.js
CHANGED
|
@@ -24,6 +24,7 @@ async function createClient(accessOptions) {
|
|
|
24
24
|
const client = new ftp.Client();
|
|
25
25
|
client.ftp.verbose = false;
|
|
26
26
|
await client.access(accessOptions);
|
|
27
|
+
client.ftp.socket.setKeepAlive(true, 10000);
|
|
27
28
|
return client;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -46,6 +47,7 @@ export async function runDeploy(mode, uploadTasks, options = {}) {
|
|
|
46
47
|
console.log(`🚀 Starting deployment for: ${modeUpper}`);
|
|
47
48
|
|
|
48
49
|
await mainClient.access(accessOptions);
|
|
50
|
+
mainClient.ftp.socket.setKeepAlive(true, 10000);
|
|
49
51
|
|
|
50
52
|
for (const task of uploadTasks) {
|
|
51
53
|
console.log(`\nProcessing Task: ${task.name}`);
|
|
@@ -64,13 +66,38 @@ export async function runDeploy(mode, uploadTasks, options = {}) {
|
|
|
64
66
|
// Determine which files are newer than their remote counterparts
|
|
65
67
|
process.stdout.write(` Checking ${files.length} files...`);
|
|
66
68
|
const filesToUpload = [];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
|
|
70
|
+
if (parallel <= 1) {
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
const relativeFile = path.relative(task.localBase, file);
|
|
73
|
+
const remotePath = path.join(task.remoteDir, relativeFile).replace(/\\/g, '/');
|
|
74
|
+
if (await isNewer(mainClient, file, remotePath)) {
|
|
75
|
+
filesToUpload.push({ file, remotePath });
|
|
76
|
+
}
|
|
72
77
|
}
|
|
78
|
+
} else {
|
|
79
|
+
const checkWorkerCount = Math.min(parallel, files.length);
|
|
80
|
+
const checkWorkers = await Promise.all(
|
|
81
|
+
Array.from({ length: checkWorkerCount }, () => createClient(accessOptions))
|
|
82
|
+
);
|
|
83
|
+
const checkQueue = [...files];
|
|
84
|
+
await Promise.all(checkWorkers.map(async (workerClient) => {
|
|
85
|
+
try {
|
|
86
|
+
while (true) {
|
|
87
|
+
const file = checkQueue.shift();
|
|
88
|
+
if (!file) break;
|
|
89
|
+
const relativeFile = path.relative(task.localBase, file);
|
|
90
|
+
const remotePath = path.join(task.remoteDir, relativeFile).replace(/\\/g, '/');
|
|
91
|
+
if (await isNewer(workerClient, file, remotePath)) {
|
|
92
|
+
filesToUpload.push({ file, remotePath });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} finally {
|
|
96
|
+
workerClient.close();
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
73
99
|
}
|
|
100
|
+
|
|
74
101
|
process.stdout.write(` ${filesToUpload.length} changed.\n`);
|
|
75
102
|
|
|
76
103
|
if (filesToUpload.length === 0) {
|