@8ms/helpers 2.2.16 → 2.2.19

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,64 @@
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
+ // Also add .d.ts mapping for TypeScript
50
+ exports[`./${entry.name}/index.d.ts`] = {
51
+ types: `./${entry.name}/index.d.ts`,
52
+ default: `./${entry.name}/index.d.ts`
53
+ };
54
+ }
55
+ }
56
+ });
57
+
58
+ // Update package.json with new exports
59
+ packageJson.exports = exports;
60
+
61
+ // Write back to package.json
62
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, '\t') + '\n', 'utf8');
63
+
64
+ console.log(`Generated exports for ${Object.keys(exports).length} entries`);
@@ -9,27 +9,22 @@ jobs:
9
9
  contents: read
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v4.2.1
12
+ - uses: actions/checkout@v6.0.2
13
13
 
14
- - name: Enable Corepack
15
- run: corepack enable
16
-
17
- - name: Install pnpm
18
- uses: pnpm/action-setup@v4
19
- with:
20
- run_install: false
21
-
22
- - uses: actions/setup-node@v4.0.4
14
+ - uses: actions/setup-node@v6.2.0
23
15
  with:
24
16
  node-version: 24
25
- cache: 'pnpm'
17
+ cache: 'yarn'
26
18
  registry-url: 'https://registry.npmjs.org'
27
19
 
28
20
  - name: Install dependencies
29
- run: pnpm install --frozen-lockfile
21
+ run: yarn install --frozen-lockfile
30
22
 
31
23
  - name: Build
32
- run: pnpm build
24
+ run: yarn build
25
+
26
+ - name: Generate exports field
27
+ run: node .github/generate-exports.js
33
28
 
34
29
  - name: Publish to npm
35
30
  run: npm publish --access public
Binary file