@profitlich/template-toolkit 2.7.4 → 2.8.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/deploy.js +76 -72
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profitlich/template-toolkit",
3
- "version": "2.7.4",
3
+ "version": "2.8.4",
4
4
  "description": "Shared SCSS layout system, JS utilities, components and build scripts for profitlich template repos",
5
5
  "type": "module",
6
6
  "exports": {
package/scripts/deploy.js CHANGED
@@ -38,93 +38,99 @@ export async function runDeploy(mode, uploadTasks, options = {}) {
38
38
  secure: true
39
39
  };
40
40
 
41
- const mainClient = new ftp.Client();
42
- mainClient.ftp.verbose = false;
43
41
  let activeProgressBar = null;
44
42
 
45
43
  try {
46
44
  console.log(`šŸš€ Starting deployment for: ${modeUpper}`);
47
45
 
48
- await mainClient.access(accessOptions);
49
-
50
46
  for (const task of uploadTasks) {
51
47
  console.log(`\nProcessing Task: ${task.name}`);
52
48
 
53
- const files = await glob(task.localPattern, {
54
- nodir: true,
55
- dot: true,
56
- ignore: task.ignore
57
- });
49
+ const mainClient = new ftp.Client();
50
+ mainClient.ftp.verbose = false;
58
51
 
59
- if (files.length === 0) {
60
- console.log('No files found for this task.');
61
- continue;
62
- }
52
+ try {
53
+ await mainClient.access(accessOptions);
63
54
 
64
- // Determine which files are newer than their remote counterparts
65
- process.stdout.write(` Checking ${files.length} files...`);
66
- const filesToUpload = [];
67
- for (const file of files) {
68
- const relativeFile = path.relative(task.localBase, file);
69
- const remotePath = path.join(task.remoteDir, relativeFile).replace(/\\/g, '/');
70
- if (await isNewer(mainClient, file, remotePath)) {
71
- filesToUpload.push({ file, remotePath });
72
- }
73
- }
74
- process.stdout.write(` ${filesToUpload.length} changed.\n`);
55
+ const files = await glob(task.localPattern, {
56
+ nodir: true,
57
+ dot: true,
58
+ ignore: task.ignore
59
+ });
75
60
 
76
- if (filesToUpload.length === 0) {
77
- console.log(' All files are up to date, skipping.');
78
- continue;
79
- }
61
+ if (files.length === 0) {
62
+ console.log('No files found for this task.');
63
+ continue;
64
+ }
80
65
 
81
- const progressBar = new cliProgress.SingleBar({
82
- format: ' Upload |{bar}| {percentage}% {value}/{total} files {duration_formatted}',
83
- barCompleteChar: 'ā–ˆ',
84
- barIncompleteChar: 'ā–‘',
85
- hideCursor: true
86
- });
87
-
88
- activeProgressBar = progressBar;
89
- progressBar.start(filesToUpload.length, 0);
90
-
91
- if (parallel <= 1) {
92
- for (const { file, remotePath } of filesToUpload) {
93
- await mainClient.ensureDir(path.dirname(remotePath));
94
- await mainClient.uploadFrom(file, remotePath);
95
- progressBar.increment();
66
+ // Determine which files are newer than their remote counterparts
67
+ process.stdout.write(` Checking ${files.length} files...`);
68
+ const filesToUpload = [];
69
+ for (const file of files) {
70
+ const relativeFile = path.relative(task.localBase, file);
71
+ const remotePath = path.join(task.remoteDir, relativeFile).replace(/\\/g, '/');
72
+ if (await isNewer(mainClient, file, remotePath)) {
73
+ filesToUpload.push({ file, remotePath });
74
+ }
96
75
  }
97
- } else {
98
- // Pre-create all required remote directories with the main client
99
- const uniqueDirs = [...new Set(filesToUpload.map(({ remotePath }) => path.dirname(remotePath)))];
100
- for (const dir of uniqueDirs) {
101
- await mainClient.ensureDir(dir);
76
+ process.stdout.write(` ${filesToUpload.length} changed.\n`);
77
+
78
+ if (filesToUpload.length === 0) {
79
+ console.log(' All files are up to date, skipping.');
80
+ continue;
102
81
  }
103
82
 
104
- // Spawn parallel worker connections
105
- const workerCount = Math.min(parallel, filesToUpload.length);
106
- const workers = await Promise.all(
107
- Array.from({ length: workerCount }, () => createClient(accessOptions))
108
- );
109
-
110
- const queue = [...filesToUpload];
111
- await Promise.all(workers.map(async (workerClient) => {
112
- try {
113
- while (true) {
114
- const item = queue.shift();
115
- if (!item) break;
116
- await workerClient.uploadFrom(item.file, item.remotePath);
117
- progressBar.increment();
118
- }
119
- } finally {
120
- workerClient.close();
83
+ const progressBar = new cliProgress.SingleBar({
84
+ format: ' Upload |{bar}| {percentage}% {value}/{total} files {duration_formatted}',
85
+ barCompleteChar: 'ā–ˆ',
86
+ barIncompleteChar: 'ā–‘',
87
+ hideCursor: true
88
+ });
89
+
90
+ activeProgressBar = progressBar;
91
+ progressBar.start(filesToUpload.length, 0);
92
+
93
+ if (parallel <= 1) {
94
+ for (const { file, remotePath } of filesToUpload) {
95
+ await mainClient.ensureDir(path.dirname(remotePath));
96
+ await mainClient.uploadFrom(file, remotePath);
97
+ progressBar.increment();
98
+ }
99
+ } else {
100
+ // Pre-create all required remote directories with the main client
101
+ const uniqueDirs = [...new Set(filesToUpload.map(({ remotePath }) => path.dirname(remotePath)))];
102
+ for (const dir of uniqueDirs) {
103
+ await mainClient.ensureDir(dir);
121
104
  }
122
- }));
123
- }
124
105
 
125
- activeProgressBar.stop();
126
- activeProgressBar = null;
127
- await delay(50);
106
+ // Spawn parallel worker connections
107
+ const workerCount = Math.min(parallel, filesToUpload.length);
108
+ const workers = await Promise.all(
109
+ Array.from({ length: workerCount }, () => createClient(accessOptions))
110
+ );
111
+
112
+ const queue = [...filesToUpload];
113
+ await Promise.all(workers.map(async (workerClient) => {
114
+ try {
115
+ while (true) {
116
+ const item = queue.shift();
117
+ if (!item) break;
118
+ await workerClient.uploadFrom(item.file, item.remotePath);
119
+ progressBar.increment();
120
+ }
121
+ } finally {
122
+ workerClient.close();
123
+ }
124
+ }));
125
+ }
126
+
127
+ activeProgressBar.stop();
128
+ activeProgressBar = null;
129
+ await delay(50);
130
+
131
+ } finally {
132
+ mainClient.close();
133
+ }
128
134
  }
129
135
 
130
136
  console.log('\nāœ… Deployment completed successfully!');
@@ -134,8 +140,6 @@ export async function runDeploy(mode, uploadTasks, options = {}) {
134
140
  activeProgressBar.stop();
135
141
  }
136
142
  console.error('Deployment failed:', err);
137
- } finally {
138
- mainClient.close();
139
143
  }
140
144
  }
141
145