@8ms/helpers 2.2.14 → 2.2.16
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,58 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
|
|
8
|
-
const projectRoot = path.join(__dirname, '..');
|
|
9
|
-
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
10
|
-
|
|
11
|
-
// Read package.json
|
|
12
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
13
|
-
|
|
14
|
-
// Find all directories in the project root (excluding specific ones)
|
|
15
|
-
const excludeDirs = ['node_modules', 'scripts', 'jest', 'src', '.git', '.github', '.idea'];
|
|
16
|
-
const entries = fs.readdirSync(projectRoot, {withFileTypes: true});
|
|
17
|
-
|
|
18
|
-
// Build exports object
|
|
19
|
-
const exports = {
|
|
20
|
-
'.': {
|
|
21
|
-
types: './index.d.ts',
|
|
22
|
-
import: './index.js',
|
|
23
|
-
require: './index.js',
|
|
24
|
-
default: './index.js'
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Add all directories that have an index.js file
|
|
29
|
-
entries.forEach(entry =>
|
|
30
|
-
{
|
|
31
|
-
if(entry.isDirectory() && !excludeDirs.includes(entry.name) && !entry.name.startsWith('.'))
|
|
32
|
-
{
|
|
33
|
-
const indexJsPath = path.join(projectRoot, entry.name, 'index.js');
|
|
34
|
-
const indexDtsPath = path.join(projectRoot, entry.name, 'index.d.ts');
|
|
35
|
-
|
|
36
|
-
if(fs.existsSync(indexJsPath))
|
|
37
|
-
{
|
|
38
|
-
const exportConfig = {
|
|
39
|
-
types: `./${entry.name}/index.d.ts`,
|
|
40
|
-
import: `./${entry.name}/index.js`,
|
|
41
|
-
require: `./${entry.name}/index.js`,
|
|
42
|
-
default: `./${entry.name}/index.js`
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Add both the directory path and explicit index.js path
|
|
46
|
-
exports[`./${entry.name}`] = exportConfig;
|
|
47
|
-
exports[`./${entry.name}/index.js`] = exportConfig;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Update package.json with new exports
|
|
53
|
-
packageJson.exports = exports;
|
|
54
|
-
|
|
55
|
-
// Write back to package.json
|
|
56
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, '\t') + '\n', 'utf8');
|
|
57
|
-
|
|
58
|
-
console.log(`Generated exports for ${Object.keys(exports).length} entries`);
|