@famgia/omnify 1.0.95 → 1.0.97
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 +166 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.97",
|
|
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-
|
|
32
|
-
"@famgia/omnify-
|
|
33
|
-
"@famgia/omnify-
|
|
34
|
-
"@famgia/omnify-
|
|
35
|
-
"@famgia/omnify-japan": "0.0.
|
|
28
|
+
"@famgia/omnify-cli": "0.0.93",
|
|
29
|
+
"@famgia/omnify-core": "0.0.87",
|
|
30
|
+
"@famgia/omnify-laravel": "0.0.96",
|
|
31
|
+
"@famgia/omnify-typescript": "0.0.75",
|
|
32
|
+
"@famgia/omnify-types": "0.0.85",
|
|
33
|
+
"@famgia/omnify-mcp": "0.0.73",
|
|
34
|
+
"@famgia/omnify-atlas": "0.0.81",
|
|
35
|
+
"@famgia/omnify-japan": "0.0.80"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"omnify",
|
package/scripts/postinstall.js
CHANGED
|
@@ -58,6 +58,157 @@ Commands:
|
|
|
58
58
|
// Helper Functions
|
|
59
59
|
// ============================================================================
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Reads omnify.config.ts and extracts the TypeScript output path.
|
|
63
|
+
* Returns null if not found or on error.
|
|
64
|
+
*/
|
|
65
|
+
function getOmnifyTypescriptPath(projectRoot) {
|
|
66
|
+
const configPaths = [
|
|
67
|
+
path.join(projectRoot, 'omnify.config.ts'),
|
|
68
|
+
path.join(projectRoot, 'omnify.config.js'),
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
for (const configPath of configPaths) {
|
|
72
|
+
if (!fs.existsSync(configPath)) continue;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
76
|
+
// Simple regex to extract typescript.path
|
|
77
|
+
const match = content.match(/typescript\s*:\s*\{[^}]*path\s*:\s*['"]([^'"]+)['"]/);
|
|
78
|
+
if (match) {
|
|
79
|
+
return match[1].replace(/^\.\//, ''); // Remove leading ./
|
|
80
|
+
}
|
|
81
|
+
} catch { /* ignore */ }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Setup @omnify alias in tsconfig.json
|
|
89
|
+
*/
|
|
90
|
+
function setupTsconfigAlias(projectRoot, omnifyPath) {
|
|
91
|
+
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
|
|
92
|
+
if (!fs.existsSync(tsconfigPath)) return false;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
let content = fs.readFileSync(tsconfigPath, 'utf-8');
|
|
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);
|
|
112
|
+
|
|
113
|
+
// Initialize compilerOptions if not present
|
|
114
|
+
if (!tsconfig.compilerOptions) {
|
|
115
|
+
tsconfig.compilerOptions = {};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Initialize paths if not present
|
|
119
|
+
if (!tsconfig.compilerOptions.paths) {
|
|
120
|
+
tsconfig.compilerOptions.paths = {};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check if @omnify alias already exists
|
|
124
|
+
if (tsconfig.compilerOptions.paths['@omnify/*']) {
|
|
125
|
+
return false; // Already configured
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Add @omnify alias
|
|
129
|
+
tsconfig.compilerOptions.paths['@omnify/*'] = [`${omnifyPath}/*`];
|
|
130
|
+
|
|
131
|
+
// Ensure baseUrl is set (required for paths to work)
|
|
132
|
+
if (!tsconfig.compilerOptions.baseUrl) {
|
|
133
|
+
tsconfig.compilerOptions.baseUrl = '.';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Write back with proper formatting
|
|
137
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + '\n');
|
|
138
|
+
return true;
|
|
139
|
+
} catch {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Setup @omnify alias in vite.config.ts
|
|
146
|
+
*/
|
|
147
|
+
function setupViteAlias(projectRoot, omnifyPath) {
|
|
148
|
+
const vitePaths = [
|
|
149
|
+
path.join(projectRoot, 'vite.config.ts'),
|
|
150
|
+
path.join(projectRoot, 'vite.config.js'),
|
|
151
|
+
path.join(projectRoot, 'vite.config.mts'),
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
const viteConfigPath = vitePaths.find(p => fs.existsSync(p));
|
|
155
|
+
if (!viteConfigPath) return false;
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
let content = fs.readFileSync(viteConfigPath, 'utf-8');
|
|
159
|
+
|
|
160
|
+
// Check if @omnify alias already exists
|
|
161
|
+
if (content.includes('@omnify')) {
|
|
162
|
+
return false; // Already configured
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Check if resolve.alias exists
|
|
166
|
+
if (content.includes('resolve:') && content.includes('alias:')) {
|
|
167
|
+
// Add to existing alias object
|
|
168
|
+
const aliasMatch = content.match(/(alias\s*:\s*\{)/);
|
|
169
|
+
if (aliasMatch) {
|
|
170
|
+
const insertPos = content.indexOf(aliasMatch[0]) + aliasMatch[0].length;
|
|
171
|
+
const aliasLine = `\n '@omnify': path.resolve(__dirname, '${omnifyPath}'),`;
|
|
172
|
+
content = content.slice(0, insertPos) + aliasLine + content.slice(insertPos);
|
|
173
|
+
}
|
|
174
|
+
} else if (content.includes('resolve:')) {
|
|
175
|
+
// Add alias to existing resolve object
|
|
176
|
+
const resolveMatch = content.match(/(resolve\s*:\s*\{)/);
|
|
177
|
+
if (resolveMatch) {
|
|
178
|
+
const insertPos = content.indexOf(resolveMatch[0]) + resolveMatch[0].length;
|
|
179
|
+
const aliasBlock = `\n alias: {\n '@omnify': path.resolve(__dirname, '${omnifyPath}'),\n },`;
|
|
180
|
+
content = content.slice(0, insertPos) + aliasBlock + content.slice(insertPos);
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
// Add resolve.alias to defineConfig
|
|
184
|
+
const defineConfigMatch = content.match(/(defineConfig\s*\(\s*\{)/);
|
|
185
|
+
if (defineConfigMatch) {
|
|
186
|
+
const insertPos = content.indexOf(defineConfigMatch[0]) + defineConfigMatch[0].length;
|
|
187
|
+
const resolveBlock = `\n resolve: {\n alias: {\n '@omnify': path.resolve(__dirname, '${omnifyPath}'),\n },\n },`;
|
|
188
|
+
content = content.slice(0, insertPos) + resolveBlock + content.slice(insertPos);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Add path import if not present
|
|
193
|
+
if (!content.includes("import path from") && !content.includes("import * as path from") && !content.includes("const path = require")) {
|
|
194
|
+
if (content.startsWith('import ')) {
|
|
195
|
+
content = `import path from 'path';\n` + content;
|
|
196
|
+
} else {
|
|
197
|
+
// Find first import and add before it
|
|
198
|
+
const firstImport = content.indexOf('import ');
|
|
199
|
+
if (firstImport !== -1) {
|
|
200
|
+
content = content.slice(0, firstImport) + `import path from 'path';\n` + content.slice(firstImport);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
fs.writeFileSync(viteConfigPath, content);
|
|
206
|
+
return true;
|
|
207
|
+
} catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
61
212
|
function findProjectRoot() {
|
|
62
213
|
let dir = process.env.INIT_CWD || process.cwd();
|
|
63
214
|
const idx = dir.indexOf('node_modules');
|
|
@@ -264,6 +415,21 @@ function main() {
|
|
|
264
415
|
|
|
265
416
|
setupClaudeMcp();
|
|
266
417
|
|
|
418
|
+
// Setup @omnify alias in config files
|
|
419
|
+
const omnifyPath = getOmnifyTypescriptPath(projectRoot) || 'src/omnify';
|
|
420
|
+
|
|
421
|
+
try {
|
|
422
|
+
if (setupTsconfigAlias(projectRoot, omnifyPath)) {
|
|
423
|
+
results.push(`✓ Added @omnify alias to tsconfig.json → ${omnifyPath}`);
|
|
424
|
+
}
|
|
425
|
+
} catch { /* ignore */ }
|
|
426
|
+
|
|
427
|
+
try {
|
|
428
|
+
if (setupViteAlias(projectRoot, omnifyPath)) {
|
|
429
|
+
results.push(`✓ Added @omnify alias to vite.config`);
|
|
430
|
+
}
|
|
431
|
+
} catch { /* ignore */ }
|
|
432
|
+
|
|
267
433
|
for (const r of results) console.log(` ${r}`);
|
|
268
434
|
console.log('\n✅ Omnify setup complete!\n');
|
|
269
435
|
}
|