-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-types.js
More file actions
74 lines (59 loc) · 2.06 KB
/
Copy pathbuild-types.js
File metadata and controls
74 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Build script to organize TypeScript definitions for shared components
* This script runs after the main Directus extension build to set up .d.ts files
*/
import { exec } from 'child_process';
import { promisify } from 'util';
import fs from 'fs';
const execAsync = promisify(exec);
async function buildTypeDefinitions() {
console.log('🔧 Setting up TypeScript definitions for shared components...');
try {
console.log('📦 Organizing type definitions...');
// Ensure dist/shared directory exists
if (!fs.existsSync('dist/shared')) {
fs.mkdirSync('dist/shared', { recursive: true });
}
// Copy manual TypeScript definitions
if (fs.existsSync('src/shared/types.d.ts')) {
await execAsync('cp src/shared/types.d.ts dist/shared/index.d.ts');
console.log('✅ Copied shared type definitions to dist/shared/index.d.ts');
}
// Create proper shared module exports
const sharedExportContent = `
/**
* Shared ItemSelector components for other extensions
*
* @example
* import { useItemSelector, ItemSelectorDrawer } from 'directus-extension-expandable-blocks/shared';
*/
// Export composables
export { useItemSelector } from '../index.js';
// Export components
export {
ItemSelectorDrawer,
ItemSearchPanel,
FieldDisplay,
UsagePopover,
FieldSettingsMenu,
ItemEditDrawer,
ItemSelectorTable
} from '../index.js';
// Export types
export {
DEFAULT_ITEM_SELECTOR_CONFIG
} from '../index.js';
// Export version info
export const SHARED_VERSION = '1.3.2';
`;
fs.writeFileSync('dist/shared/index.js', sharedExportContent.trim());
console.log('✅ Created shared module export at dist/shared/index.js');
console.log('✅ TypeScript definitions set up successfully!');
console.log('📁 Shared components available at: dist/shared/');
console.log('🔗 Import with: import { useItemSelector } from "directus-extension-expandable-blocks/shared"');
} catch (error) {
console.error('❌ Error setting up type definitions:', error);
process.exit(1);
}
}
buildTypeDefinitions();