@famgia/omnify-react 0.0.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.
- package/README.md +178 -0
- package/dist/components/index.cjs +686 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +95 -0
- package/dist/components/index.d.ts +95 -0
- package/dist/components/index.js +657 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.cjs +81 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +20 -0
- package/dist/hooks/index.d.ts +20 -0
- package/dist/hooks/index.js +54 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.cjs +1005 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +947 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/index.cjs +479 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/index.d.cts +209 -0
- package/dist/lib/index.d.ts +209 -0
- package/dist/lib/index.js +425 -0
- package/dist/lib/index.js.map +1 -0
- package/package.json +110 -0
- package/scripts/postinstall.cjs +121 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @famgia/omnify-react postinstall script
|
|
3
|
+
*
|
|
4
|
+
* This script runs after npm install to:
|
|
5
|
+
* 1. Check if we're in a project with omnify.config.ts
|
|
6
|
+
* 2. Run `npx omnify generate` to generate TypeScript types
|
|
7
|
+
*
|
|
8
|
+
* The generated types are placed in node_modules/.omnify/
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { execSync } = require('child_process');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
// Skip in CI environments unless explicitly enabled
|
|
16
|
+
if (process.env.CI && !process.env.OMNIFY_GENERATE_IN_CI) {
|
|
17
|
+
console.log('[@famgia/omnify-react] Skipping postinstall in CI environment');
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Skip if OMNIFY_SKIP_POSTINSTALL is set
|
|
22
|
+
if (process.env.OMNIFY_SKIP_POSTINSTALL) {
|
|
23
|
+
console.log('[@famgia/omnify-react] Skipping postinstall (OMNIFY_SKIP_POSTINSTALL is set)');
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Find project root by looking for omnify.config.ts or omnify.config.js
|
|
29
|
+
*/
|
|
30
|
+
function findProjectRoot(startDir) {
|
|
31
|
+
let dir = startDir;
|
|
32
|
+
const root = path.parse(dir).root;
|
|
33
|
+
|
|
34
|
+
while (dir !== root) {
|
|
35
|
+
// Check for omnify config files
|
|
36
|
+
const tsConfig = path.join(dir, 'omnify.config.ts');
|
|
37
|
+
const jsConfig = path.join(dir, 'omnify.config.js');
|
|
38
|
+
|
|
39
|
+
if (fs.existsSync(tsConfig) || fs.existsSync(jsConfig)) {
|
|
40
|
+
return dir;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Also check for package.json with omnify dependency (fallback)
|
|
44
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
45
|
+
if (fs.existsSync(pkgPath)) {
|
|
46
|
+
try {
|
|
47
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
48
|
+
const deps = {
|
|
49
|
+
...pkg.dependencies,
|
|
50
|
+
...pkg.devDependencies,
|
|
51
|
+
};
|
|
52
|
+
if (deps['@famgia/omnify'] || deps['omnify']) {
|
|
53
|
+
return dir;
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// Ignore JSON parse errors
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
dir = path.dirname(dir);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if omnify CLI is available
|
|
68
|
+
*/
|
|
69
|
+
function isOmnifyAvailable(projectRoot) {
|
|
70
|
+
try {
|
|
71
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
72
|
+
if (!fs.existsSync(pkgPath)) return false;
|
|
73
|
+
|
|
74
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
75
|
+
const deps = {
|
|
76
|
+
...pkg.dependencies,
|
|
77
|
+
...pkg.devDependencies,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return !!(deps['@famgia/omnify'] || deps['omnify']);
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Main execution
|
|
87
|
+
try {
|
|
88
|
+
// Start from current working directory
|
|
89
|
+
const startDir = process.cwd();
|
|
90
|
+
const projectRoot = findProjectRoot(startDir);
|
|
91
|
+
|
|
92
|
+
if (!projectRoot) {
|
|
93
|
+
// Not in an omnify project, skip silently
|
|
94
|
+
process.exit(0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check if omnify is available
|
|
98
|
+
if (!isOmnifyAvailable(projectRoot)) {
|
|
99
|
+
console.log('[@famgia/omnify-react] @famgia/omnify not found, skipping generation');
|
|
100
|
+
process.exit(0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log('[@famgia/omnify-react] Running omnify generate...');
|
|
104
|
+
|
|
105
|
+
// Run omnify generate
|
|
106
|
+
execSync('npx omnify generate', {
|
|
107
|
+
cwd: projectRoot,
|
|
108
|
+
stdio: 'inherit',
|
|
109
|
+
env: {
|
|
110
|
+
...process.env,
|
|
111
|
+
// Prevent infinite recursion
|
|
112
|
+
OMNIFY_SKIP_POSTINSTALL: '1',
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
console.log('[@famgia/omnify-react] Generation complete');
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// Don't fail the install if generation fails
|
|
119
|
+
console.warn('[@famgia/omnify-react] Warning: Generation failed:', error.message);
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|