@arkyn/shared 3.0.1-beta.148 → 3.0.1-beta.150

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/generate-exports.ts +57 -0
  2. package/package.json +109 -2
@@ -0,0 +1,57 @@
1
+ import { resolve } from "node:path";
2
+ import Bun from "bun";
3
+
4
+ interface ExportEntry {
5
+ import: string;
6
+ types?: string;
7
+ }
8
+
9
+ interface PackageJson {
10
+ exports?: Record<string, ExportEntry>;
11
+ [key: string]: unknown;
12
+ }
13
+
14
+ const root = process.cwd();
15
+
16
+ const indexContent = await Bun.file(resolve(root, "src/index.ts")).text();
17
+
18
+ const packageJson = (await Bun.file(
19
+ resolve(root, "package.json"),
20
+ ).json()) as PackageJson;
21
+
22
+ const exportsMap: Record<string, ExportEntry> = {};
23
+
24
+ const regex =
25
+ /export\s+(?:\*|\{[\s\S]*?\}|type\s+\{[\s\S]*?\})\s+from\s+["'](.+)["']/g;
26
+
27
+ for (const match of indexContent.matchAll(regex)) {
28
+ let importPath = match[1];
29
+
30
+ if (!importPath.startsWith(".")) continue;
31
+
32
+ importPath = importPath.replace(/^\.\//, "");
33
+
34
+ const exportName = importPath.split("/").pop()!;
35
+
36
+ exportsMap[`./${exportName}`] = {
37
+ import: `./dist/${importPath}/index.js`,
38
+ types: `./dist/${importPath}/index.d.ts`,
39
+ };
40
+ }
41
+
42
+ packageJson.exports = {
43
+ ".": {
44
+ import: "./dist/bundle.js",
45
+ types: "./dist/index.d.ts",
46
+ },
47
+ ...Object.fromEntries(
48
+ Object.entries(exportsMap).sort(([a], [b]) => a.localeCompare(b)),
49
+ ),
50
+ };
51
+
52
+ await Bun.write(
53
+ resolve(root, "package.json"),
54
+ JSON.stringify(packageJson, null, 2) + "\n",
55
+ );
56
+
57
+ console.log(`Added ${Object.keys(exportsMap).length + 2} exports.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/shared",
3
- "version": "3.0.1-beta.148",
3
+ "version": "3.0.1-beta.150",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./dist/bundle.js",
6
6
  "type": "module",
@@ -25,8 +25,115 @@
25
25
  "url": "git+https://github.com/Lucas-Eduardo-Goncalves/arkyn.git",
26
26
  "directory": "packages/shared"
27
27
  },
28
+ "sideEffects": false,
29
+ "exports": {
30
+ ".": {
31
+ "import": "./dist/bundle.js",
32
+ "types": "./dist/index.d.ts"
33
+ },
34
+ "./calculateCardInstallment": {
35
+ "import": "./dist/utilities/calculateCardInstallment/index.js",
36
+ "types": "./dist/utilities/calculateCardInstallment/index.d.ts"
37
+ },
38
+ "./ensureQuotes": {
39
+ "import": "./dist/utilities/ensureQuotes/index.js",
40
+ "types": "./dist/utilities/ensureQuotes/index.d.ts"
41
+ },
42
+ "./findCountryMask": {
43
+ "import": "./dist/utilities/findCountryMask/index.js",
44
+ "types": "./dist/utilities/findCountryMask/index.d.ts"
45
+ },
46
+ "./formatDate": {
47
+ "import": "./dist/formats/formatDate/index.js",
48
+ "types": "./dist/formats/formatDate/index.d.ts"
49
+ },
50
+ "./formatJsonObject": {
51
+ "import": "./dist/formats/formatJsonObject/index.js",
52
+ "types": "./dist/formats/formatJsonObject/index.d.ts"
53
+ },
54
+ "./formatJsonString": {
55
+ "import": "./dist/formats/formatJsonString/index.js",
56
+ "types": "./dist/formats/formatJsonString/index.d.ts"
57
+ },
58
+ "./formatToCapitalizeFirstWordLetter": {
59
+ "import": "./dist/formats/formatToCapitalizeFirstWordLetter/index.js",
60
+ "types": "./dist/formats/formatToCapitalizeFirstWordLetter/index.d.ts"
61
+ },
62
+ "./formatToCep": {
63
+ "import": "./dist/formats/formatToCep/index.js",
64
+ "types": "./dist/formats/formatToCep/index.d.ts"
65
+ },
66
+ "./formatToCnpj": {
67
+ "import": "./dist/formats/formatToCnpj/index.js",
68
+ "types": "./dist/formats/formatToCnpj/index.d.ts"
69
+ },
70
+ "./formatToCpf": {
71
+ "import": "./dist/formats/formatToCpf/index.js",
72
+ "types": "./dist/formats/formatToCpf/index.d.ts"
73
+ },
74
+ "./formatToCurrency": {
75
+ "import": "./dist/formats/formatToCurrency/index.js",
76
+ "types": "./dist/formats/formatToCurrency/index.d.ts"
77
+ },
78
+ "./formatToEllipsis": {
79
+ "import": "./dist/formats/formatToEllipsis/index.js",
80
+ "types": "./dist/formats/formatToEllipsis/index.d.ts"
81
+ },
82
+ "./formatToHiddenDigits": {
83
+ "import": "./dist/formats/formatToHiddenDigits/index.js",
84
+ "types": "./dist/formats/formatToHiddenDigits/index.d.ts"
85
+ },
86
+ "./formatToPhone": {
87
+ "import": "./dist/formats/formatToPhone/index.js",
88
+ "types": "./dist/formats/formatToPhone/index.d.ts"
89
+ },
90
+ "./generateColorByString": {
91
+ "import": "./dist/generators/generateColorByString/index.js",
92
+ "types": "./dist/generators/generateColorByString/index.d.ts"
93
+ },
94
+ "./generateId": {
95
+ "import": "./dist/generators/generateId/index.js",
96
+ "types": "./dist/generators/generateId/index.d.ts"
97
+ },
98
+ "./generateSlug": {
99
+ "import": "./dist/generators/generateSlug/index.js",
100
+ "types": "./dist/generators/generateSlug/index.d.ts"
101
+ },
102
+ "./isHtml": {
103
+ "import": "./dist/utilities/isHtml/index.js",
104
+ "types": "./dist/utilities/isHtml/index.d.ts"
105
+ },
106
+ "./parseLargeFields": {
107
+ "import": "./dist/parsers/parseLargeFields/index.js",
108
+ "types": "./dist/parsers/parseLargeFields/index.d.ts"
109
+ },
110
+ "./parseSensitiveData": {
111
+ "import": "./dist/parsers/parseSensitiveData/index.js",
112
+ "types": "./dist/parsers/parseSensitiveData/index.d.ts"
113
+ },
114
+ "./parseToDate": {
115
+ "import": "./dist/parsers/parseToDate/index.js",
116
+ "types": "./dist/parsers/parseToDate/index.d.ts"
117
+ },
118
+ "./removeCurrencySymbols": {
119
+ "import": "./dist/utilities/removeCurrencySymbols/index.js",
120
+ "types": "./dist/utilities/removeCurrencySymbols/index.d.ts"
121
+ },
122
+ "./removeNonNumeric": {
123
+ "import": "./dist/utilities/removeNonNumeric/index.js",
124
+ "types": "./dist/utilities/removeNonNumeric/index.d.ts"
125
+ },
126
+ "./stripHtmlTags": {
127
+ "import": "./dist/utilities/stripHtmlTags/index.js",
128
+ "types": "./dist/utilities/stripHtmlTags/index.d.ts"
129
+ },
130
+ "./validateDateService": {
131
+ "import": "./dist/services/validateDateService/index.js",
132
+ "types": "./dist/services/validateDateService/index.d.ts"
133
+ }
134
+ },
28
135
  "scripts": {
29
- "build": "bunx vite build && tsc",
136
+ "build": "bunx vite build && tsc && bun ./generate-exports.ts",
30
137
  "test": "vitest --config vitest.config.ts",
31
138
  "typecheck": "bunx tsc --project tsconfig.json --noEmit"
32
139
  },