@famgia/omnify 1.0.97 → 1.0.99
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 +9 -9
- package/scripts/postinstall.js +74 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.99",
|
|
4
4
|
"description": "Schema-driven database migration system with TypeScript types and Laravel migrations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@famgia/omnify-cli": "0.0.
|
|
29
|
-
"@famgia/omnify-core": "0.0.
|
|
30
|
-
"@famgia/omnify-
|
|
31
|
-
"@famgia/omnify-typescript": "0.0.
|
|
32
|
-
"@famgia/omnify-
|
|
33
|
-
"@famgia/omnify-
|
|
34
|
-
"@famgia/omnify-
|
|
35
|
-
"@famgia/omnify-japan": "0.0.
|
|
28
|
+
"@famgia/omnify-cli": "0.0.95",
|
|
29
|
+
"@famgia/omnify-core": "0.0.89",
|
|
30
|
+
"@famgia/omnify-types": "0.0.87",
|
|
31
|
+
"@famgia/omnify-typescript": "0.0.77",
|
|
32
|
+
"@famgia/omnify-laravel": "0.0.98",
|
|
33
|
+
"@famgia/omnify-atlas": "0.0.83",
|
|
34
|
+
"@famgia/omnify-mcp": "0.0.75",
|
|
35
|
+
"@famgia/omnify-japan": "0.0.82"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"omnify",
|
package/scripts/postinstall.js
CHANGED
|
@@ -85,30 +85,31 @@ function getOmnifyTypescriptPath(projectRoot) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* Parse tsconfig.json content (handling comments)
|
|
89
89
|
*/
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
function parseTsconfig(content) {
|
|
91
|
+
// Remove single-line comments only (block comments can conflict with paths like @/*)
|
|
92
|
+
const jsonContent = content
|
|
93
|
+
.split('\n')
|
|
94
|
+
.map(line => {
|
|
95
|
+
const commentIdx = line.indexOf('//');
|
|
96
|
+
if (commentIdx === -1) return line;
|
|
97
|
+
// Simple check: if there's an odd number of quotes before //, it's inside a string
|
|
98
|
+
const beforeComment = line.slice(0, commentIdx);
|
|
99
|
+
const quoteCount = (beforeComment.match(/"/g) || []).length;
|
|
100
|
+
return quoteCount % 2 === 0 ? beforeComment : line;
|
|
101
|
+
})
|
|
102
|
+
.join('\n');
|
|
103
|
+
return JSON.parse(jsonContent);
|
|
104
|
+
}
|
|
93
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Update a single tsconfig.json with @omnify alias
|
|
108
|
+
*/
|
|
109
|
+
function updateTsconfigWithAlias(tsconfigPath, aliasPath) {
|
|
94
110
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// Remove single-line comments only (block comments can conflict with paths like @/*)
|
|
98
|
-
// Also handle trailing commas which are invalid in strict JSON
|
|
99
|
-
const jsonContent = content
|
|
100
|
-
.split('\n')
|
|
101
|
-
.map(line => {
|
|
102
|
-
// Remove // comments but not inside strings
|
|
103
|
-
const commentIdx = line.indexOf('//');
|
|
104
|
-
if (commentIdx === -1) return line;
|
|
105
|
-
// Simple check: if there's an odd number of quotes before //, it's inside a string
|
|
106
|
-
const beforeComment = line.slice(0, commentIdx);
|
|
107
|
-
const quoteCount = (beforeComment.match(/"/g) || []).length;
|
|
108
|
-
return quoteCount % 2 === 0 ? beforeComment : line;
|
|
109
|
-
})
|
|
110
|
-
.join('\n');
|
|
111
|
-
const tsconfig = JSON.parse(jsonContent);
|
|
111
|
+
const content = fs.readFileSync(tsconfigPath, 'utf-8');
|
|
112
|
+
const tsconfig = parseTsconfig(content);
|
|
112
113
|
|
|
113
114
|
// Initialize compilerOptions if not present
|
|
114
115
|
if (!tsconfig.compilerOptions) {
|
|
@@ -126,7 +127,7 @@ function setupTsconfigAlias(projectRoot, omnifyPath) {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
// Add @omnify alias
|
|
129
|
-
tsconfig.compilerOptions.paths['@omnify/*'] = [`${
|
|
130
|
+
tsconfig.compilerOptions.paths['@omnify/*'] = [`${aliasPath}/*`];
|
|
130
131
|
|
|
131
132
|
// Ensure baseUrl is set (required for paths to work)
|
|
132
133
|
if (!tsconfig.compilerOptions.baseUrl) {
|
|
@@ -141,6 +142,53 @@ function setupTsconfigAlias(projectRoot, omnifyPath) {
|
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Setup @omnify alias in tsconfig.json files
|
|
147
|
+
* Handles monorepo structures by finding tsconfig in the same directory tree as omnifyPath
|
|
148
|
+
*/
|
|
149
|
+
function setupTsconfigAlias(projectRoot, omnifyPath) {
|
|
150
|
+
const updated = [];
|
|
151
|
+
|
|
152
|
+
// Normalize omnify path (e.g., "./frontend/src/omnify" → "frontend/src/omnify")
|
|
153
|
+
const normalizedPath = omnifyPath.replace(/^\.\//, '');
|
|
154
|
+
|
|
155
|
+
// Find the directory containing omnify output
|
|
156
|
+
const omnifyDir = path.dirname(normalizedPath);
|
|
157
|
+
|
|
158
|
+
// Strategy: Look for tsconfig.json in:
|
|
159
|
+
// 1. Same directory as omnify output (e.g., frontend/src/tsconfig.json)
|
|
160
|
+
// 2. Parent directories up to the package root (e.g., frontend/tsconfig.json)
|
|
161
|
+
// 3. Project root (e.g., ./tsconfig.json)
|
|
162
|
+
|
|
163
|
+
const searchDirs = [];
|
|
164
|
+
let currentDir = omnifyDir;
|
|
165
|
+
while (currentDir && currentDir !== '.') {
|
|
166
|
+
searchDirs.push(currentDir);
|
|
167
|
+
currentDir = path.dirname(currentDir);
|
|
168
|
+
}
|
|
169
|
+
searchDirs.push('.'); // Add project root
|
|
170
|
+
|
|
171
|
+
for (const dir of searchDirs) {
|
|
172
|
+
const tsconfigPath = path.join(projectRoot, dir, 'tsconfig.json');
|
|
173
|
+
if (!fs.existsSync(tsconfigPath)) continue;
|
|
174
|
+
|
|
175
|
+
// Calculate relative path from tsconfig location to omnify
|
|
176
|
+
let relativePath;
|
|
177
|
+
if (dir === '.') {
|
|
178
|
+
relativePath = normalizedPath;
|
|
179
|
+
} else {
|
|
180
|
+
// Get relative path from tsconfig dir to omnify dir
|
|
181
|
+
relativePath = path.relative(dir, normalizedPath);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (updateTsconfigWithAlias(tsconfigPath, relativePath)) {
|
|
185
|
+
updated.push(path.join(dir, 'tsconfig.json'));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return updated;
|
|
190
|
+
}
|
|
191
|
+
|
|
144
192
|
/**
|
|
145
193
|
* Setup @omnify alias in vite.config.ts
|
|
146
194
|
*/
|
|
@@ -417,10 +465,11 @@ function main() {
|
|
|
417
465
|
|
|
418
466
|
// Setup @omnify alias in config files
|
|
419
467
|
const omnifyPath = getOmnifyTypescriptPath(projectRoot) || 'src/omnify';
|
|
420
|
-
|
|
468
|
+
|
|
421
469
|
try {
|
|
422
|
-
|
|
423
|
-
|
|
470
|
+
const updatedTsconfigs = setupTsconfigAlias(projectRoot, omnifyPath);
|
|
471
|
+
for (const file of updatedTsconfigs) {
|
|
472
|
+
results.push(`✓ Added @omnify alias to ${file}`);
|
|
424
473
|
}
|
|
425
474
|
} catch { /* ignore */ }
|
|
426
475
|
|