@pumpn/eslint-config 15.5.2 → 15.6.1

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.
@@ -0,0 +1,46 @@
1
+ import { join } from "@std/path";
2
+
3
+ const {
4
+ cwd,
5
+ readTextFile,
6
+ writeTextFile
7
+ } = Deno;
8
+
9
+ const importMapFilePath = join(cwd(), "deno.json");
10
+ const importMapFileContent = await readTextFile(importMapFilePath);
11
+ const importMap = JSON.parse(importMapFileContent);
12
+
13
+ const packageJsonFilePath = join(cwd(), "package.json");
14
+ const packageJsonFileContent = await readTextFile(packageJsonFilePath);
15
+ const packageJson = JSON.parse(packageJsonFileContent);
16
+
17
+ const collator = new Intl.Collator("en", {
18
+ numeric: true
19
+ });
20
+
21
+ const updatedPackageJson = {
22
+ ...packageJson,
23
+ dependencies: Object.fromEntries(
24
+ Object.entries(
25
+ importMap.imports
26
+ )
27
+ .filter(([specifier, url]) => url.startsWith("npm:"))
28
+ .map(([specificer, url]) => {
29
+ const version = url.replace(/^npm:.*?@(?<version>[^@]+)$/v, "$<version>");
30
+
31
+ return [specificer, version];
32
+ })
33
+ .toSorted((
34
+ [packageNameA],
35
+ [packageNameB]
36
+ ) => collator.compare(
37
+ packageNameA,
38
+ packageNameB
39
+ ))
40
+ )
41
+ };
42
+
43
+ await writeTextFile(
44
+ packageJsonFilePath,
45
+ JSON.stringify(updatedPackageJson, null, "\t")
46
+ );