esupgrade 2025.1.0 → 2025.2.0
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/AGENTS.md +3 -0
- package/README.md +48 -0
- package/bin/esupgrade.js +47 -30
- package/package.json +1 -1
- package/src/widelyAvailable.js +404 -0
- package/tests/cli.test.js +13 -17
- package/tests/widelyAvailable.test.js +1031 -0
package/tests/cli.test.js
CHANGED
|
@@ -41,7 +41,7 @@ describe("CLI", () => {
|
|
|
41
41
|
|
|
42
42
|
const transformedCode = fs.readFileSync(testFile, "utf8")
|
|
43
43
|
assert.match(transformedCode, /const x = 1/)
|
|
44
|
-
assert.match(result.stdout,
|
|
44
|
+
assert.match(result.stdout, /✓ 1 file\(s\) upgraded/)
|
|
45
45
|
assert.strictEqual(result.status, 0)
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -57,7 +57,6 @@ describe("CLI", () => {
|
|
|
57
57
|
const transformedCode = fs.readFileSync(testFile, "utf8")
|
|
58
58
|
assert.match(transformedCode, /const x = 1/)
|
|
59
59
|
assert.doesNotMatch(transformedCode, /Promise\.try/) // Promise.try not in widely-available
|
|
60
|
-
assert.match(result.stdout, /widely-available/)
|
|
61
60
|
assert.strictEqual(result.status, 0)
|
|
62
61
|
})
|
|
63
62
|
|
|
@@ -77,7 +76,6 @@ describe("CLI", () => {
|
|
|
77
76
|
const transformedCode = fs.readFileSync(testFile, "utf8")
|
|
78
77
|
assert.match(transformedCode, /const x = 1/)
|
|
79
78
|
assert.match(transformedCode, /Promise\.try/) // Promise.try in newly-available
|
|
80
|
-
assert.match(result.stdout, /newly-available/)
|
|
81
79
|
assert.strictEqual(result.status, 0)
|
|
82
80
|
})
|
|
83
81
|
|
|
@@ -108,7 +106,7 @@ describe("CLI", () => {
|
|
|
108
106
|
|
|
109
107
|
const fileContent = fs.readFileSync(testFile, "utf8")
|
|
110
108
|
assert.strictEqual(fileContent, originalCode) // File unchanged
|
|
111
|
-
assert.match(result.stdout, /All files are
|
|
109
|
+
assert.match(result.stdout, /All files are up to date/)
|
|
112
110
|
assert.strictEqual(result.status, 0)
|
|
113
111
|
})
|
|
114
112
|
|
|
@@ -128,8 +126,7 @@ describe("CLI", () => {
|
|
|
128
126
|
const transformedCode = fs.readFileSync(testFile, "utf8")
|
|
129
127
|
assert.match(transformedCode, /const x = 1/)
|
|
130
128
|
assert.match(result.stdout, /✗/)
|
|
131
|
-
assert.match(result.stdout, /Changes
|
|
132
|
-
assert.match(result.stdout, /1 file\(s\) upgraded/)
|
|
129
|
+
assert.match(result.stdout, /Changes have been written/)
|
|
133
130
|
assert.strictEqual(result.status, 1) // Still exit 1 with --check
|
|
134
131
|
})
|
|
135
132
|
|
|
@@ -150,7 +147,6 @@ describe("CLI", () => {
|
|
|
150
147
|
const transformed2 = fs.readFileSync(file2, "utf8")
|
|
151
148
|
assert.match(transformed1, /const x = 1/)
|
|
152
149
|
assert.match(transformed2, /const y = 2/)
|
|
153
|
-
assert.match(result.stdout, /Processing 2 file/)
|
|
154
150
|
assert.match(result.stdout, /2 file\(s\) upgraded/)
|
|
155
151
|
assert.strictEqual(result.status, 0)
|
|
156
152
|
})
|
|
@@ -172,7 +168,7 @@ describe("CLI", () => {
|
|
|
172
168
|
encoding: "utf8",
|
|
173
169
|
})
|
|
174
170
|
|
|
175
|
-
|
|
171
|
+
// Should only process file1 in tempDir, not in node_modules or .git
|
|
176
172
|
assert.strictEqual(result.status, 0)
|
|
177
173
|
})
|
|
178
174
|
|
|
@@ -191,7 +187,6 @@ describe("CLI", () => {
|
|
|
191
187
|
encoding: "utf8",
|
|
192
188
|
})
|
|
193
189
|
|
|
194
|
-
assert.match(result.stdout, /Processing 4 file/)
|
|
195
190
|
assert.match(result.stdout, /4 file\(s\) upgraded/)
|
|
196
191
|
assert.strictEqual(result.status, 0)
|
|
197
192
|
})
|
|
@@ -207,7 +202,6 @@ describe("CLI", () => {
|
|
|
207
202
|
encoding: "utf8",
|
|
208
203
|
})
|
|
209
204
|
|
|
210
|
-
assert.match(result.stdout, /Processing 2 file/)
|
|
211
205
|
assert.strictEqual(result.status, 0)
|
|
212
206
|
})
|
|
213
207
|
|
|
@@ -250,7 +244,6 @@ describe("CLI", () => {
|
|
|
250
244
|
})
|
|
251
245
|
|
|
252
246
|
assert.match(result.stdout, /var to const/)
|
|
253
|
-
assert.match(result.stdout, /line/)
|
|
254
247
|
assert.strictEqual(result.status, 1)
|
|
255
248
|
})
|
|
256
249
|
|
|
@@ -268,7 +261,7 @@ describe("CLI", () => {
|
|
|
268
261
|
const transformed2 = fs.readFileSync(file2, "utf8")
|
|
269
262
|
assert.match(transformed1, /const x = 1/)
|
|
270
263
|
assert.match(transformed2, /const y = 2/)
|
|
271
|
-
assert.match(result.stdout, /
|
|
264
|
+
assert.match(result.stdout, /2 file\(s\) upgraded/)
|
|
272
265
|
assert.strictEqual(result.status, 0)
|
|
273
266
|
})
|
|
274
267
|
|
|
@@ -283,7 +276,7 @@ describe("CLI", () => {
|
|
|
283
276
|
|
|
284
277
|
const fileContent = fs.readFileSync(testFile, "utf8")
|
|
285
278
|
assert.strictEqual(fileContent, originalCode)
|
|
286
|
-
assert.match(result.stdout, /All files are
|
|
279
|
+
assert.match(result.stdout, /All files are up to date/)
|
|
287
280
|
assert.strictEqual(result.status, 0)
|
|
288
281
|
})
|
|
289
282
|
|
|
@@ -296,7 +289,7 @@ describe("CLI", () => {
|
|
|
296
289
|
encoding: "utf8",
|
|
297
290
|
})
|
|
298
291
|
|
|
299
|
-
assert.match(result.stdout, /
|
|
292
|
+
assert.match(result.stdout, /All files are up to date/)
|
|
300
293
|
assert.strictEqual(result.status, 0)
|
|
301
294
|
})
|
|
302
295
|
|
|
@@ -322,7 +315,6 @@ describe("CLI", () => {
|
|
|
322
315
|
})
|
|
323
316
|
|
|
324
317
|
assert.match(result.stdout, /var to const/)
|
|
325
|
-
assert.match(result.stdout, /lines:/)
|
|
326
318
|
assert.strictEqual(result.status, 1)
|
|
327
319
|
})
|
|
328
320
|
|
|
@@ -335,7 +327,7 @@ describe("CLI", () => {
|
|
|
335
327
|
encoding: "utf8",
|
|
336
328
|
})
|
|
337
329
|
|
|
338
|
-
assert.match(result.stderr,
|
|
330
|
+
assert.match(result.stderr, /✗ Error:/)
|
|
339
331
|
assert.strictEqual(result.status, 0) // CLI continues despite errors
|
|
340
332
|
})
|
|
341
333
|
|
|
@@ -352,7 +344,11 @@ describe("CLI", () => {
|
|
|
352
344
|
encoding: "utf8",
|
|
353
345
|
})
|
|
354
346
|
|
|
355
|
-
|
|
347
|
+
const file1Content = fs.readFileSync(file1, "utf8")
|
|
348
|
+
const file2Content = fs.readFileSync(file2, "utf8")
|
|
349
|
+
assert.match(file1Content, /const x = 1/)
|
|
350
|
+
assert.match(file2Content, /const y = 2/)
|
|
351
|
+
assert.match(result.stdout, /2 file\(s\) upgraded/)
|
|
356
352
|
assert.strictEqual(result.status, 0)
|
|
357
353
|
})
|
|
358
354
|
})
|