create-ifc-lite 1.1.3 → 1.1.5
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/dist/index.js +74 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,15 @@ const TEMPLATES = {
|
|
|
10
10
|
};
|
|
11
11
|
const REPO_URL = 'https://github.com/louistrue/ifc-lite';
|
|
12
12
|
const VIEWER_PATH = 'apps/viewer';
|
|
13
|
+
function getLatestVersion() {
|
|
14
|
+
try {
|
|
15
|
+
const result = execSync('npm view @ifc-lite/parser version', { stdio: 'pipe' });
|
|
16
|
+
return `^${result.toString().trim()}`;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return '^1.0.0'; // fallback
|
|
20
|
+
}
|
|
21
|
+
}
|
|
13
22
|
function printUsage() {
|
|
14
23
|
console.log(`
|
|
15
24
|
create-ifc-lite - Create IFC-Lite projects instantly
|
|
@@ -83,18 +92,14 @@ function fixPackageJson(targetDir, projectName) {
|
|
|
83
92
|
let pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
84
93
|
// Update name
|
|
85
94
|
pkg.name = projectName;
|
|
86
|
-
// Replace workspace:* with npm
|
|
95
|
+
// Replace workspace:* with latest npm version
|
|
96
|
+
const latestVersion = getLatestVersion();
|
|
87
97
|
const deps = pkg.dependencies || {};
|
|
88
98
|
for (const [name, version] of Object.entries(deps)) {
|
|
89
99
|
if (version === 'workspace:*' && name.startsWith('@ifc-lite/')) {
|
|
90
|
-
deps[name] =
|
|
100
|
+
deps[name] = latestVersion;
|
|
91
101
|
}
|
|
92
102
|
}
|
|
93
|
-
// Remove internal dependencies that aren't published
|
|
94
|
-
delete deps['@ifc-lite/cache'];
|
|
95
|
-
delete deps['@ifc-lite/export'];
|
|
96
|
-
delete deps['@ifc-lite/query'];
|
|
97
|
-
delete deps['@ifc-lite/spatial'];
|
|
98
103
|
// Remove git directory if present
|
|
99
104
|
const gitDir = join(targetDir, '.git');
|
|
100
105
|
if (existsSync(gitDir)) {
|
|
@@ -102,6 +107,64 @@ function fixPackageJson(targetDir, projectName) {
|
|
|
102
107
|
}
|
|
103
108
|
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
104
109
|
}
|
|
110
|
+
function fixTsConfig(targetDir) {
|
|
111
|
+
const tsconfigPath = join(targetDir, 'tsconfig.json');
|
|
112
|
+
// Write standalone tsconfig without monorepo references
|
|
113
|
+
const tsconfig = {
|
|
114
|
+
compilerOptions: {
|
|
115
|
+
target: 'ES2022',
|
|
116
|
+
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
117
|
+
module: 'ESNext',
|
|
118
|
+
moduleResolution: 'bundler',
|
|
119
|
+
jsx: 'react-jsx',
|
|
120
|
+
strict: true,
|
|
121
|
+
esModuleInterop: true,
|
|
122
|
+
skipLibCheck: true,
|
|
123
|
+
noEmit: true,
|
|
124
|
+
baseUrl: '.',
|
|
125
|
+
paths: {
|
|
126
|
+
'@/*': ['./src/*']
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
include: ['src/**/*'],
|
|
130
|
+
exclude: ['node_modules']
|
|
131
|
+
};
|
|
132
|
+
writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
|
|
133
|
+
}
|
|
134
|
+
function fixViteConfig(targetDir) {
|
|
135
|
+
const viteConfigPath = join(targetDir, 'vite.config.ts');
|
|
136
|
+
// Write standalone vite config - packages resolve from node_modules
|
|
137
|
+
const viteConfig = `import { defineConfig } from 'vite';
|
|
138
|
+
import react from '@vitejs/plugin-react';
|
|
139
|
+
import path from 'path';
|
|
140
|
+
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
plugins: [react()],
|
|
143
|
+
resolve: {
|
|
144
|
+
alias: {
|
|
145
|
+
'@': path.resolve(__dirname, './src'),
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
server: {
|
|
149
|
+
port: 3000,
|
|
150
|
+
open: true,
|
|
151
|
+
},
|
|
152
|
+
build: {
|
|
153
|
+
target: 'esnext',
|
|
154
|
+
},
|
|
155
|
+
optimizeDeps: {
|
|
156
|
+
exclude: ['@duckdb/duckdb-wasm'],
|
|
157
|
+
},
|
|
158
|
+
assetsInclude: ['**/*.wasm'],
|
|
159
|
+
});
|
|
160
|
+
`;
|
|
161
|
+
writeFileSync(viteConfigPath, viteConfig);
|
|
162
|
+
}
|
|
163
|
+
function fixViewerTemplate(targetDir, projectName) {
|
|
164
|
+
fixPackageJson(targetDir, projectName);
|
|
165
|
+
fixTsConfig(targetDir);
|
|
166
|
+
fixViteConfig(targetDir);
|
|
167
|
+
}
|
|
105
168
|
async function main() {
|
|
106
169
|
const args = process.argv.slice(2);
|
|
107
170
|
if (args.includes('--help') || args.includes('-h')) {
|
|
@@ -137,7 +200,7 @@ async function main() {
|
|
|
137
200
|
// Download the actual viewer from GitHub
|
|
138
201
|
const success = await downloadViewer(targetDir, projectName);
|
|
139
202
|
if (success) {
|
|
140
|
-
|
|
203
|
+
fixViewerTemplate(targetDir, projectName);
|
|
141
204
|
}
|
|
142
205
|
else {
|
|
143
206
|
console.error(' Failed to download viewer. Creating minimal fallback...');
|
|
@@ -161,17 +224,18 @@ async function main() {
|
|
|
161
224
|
console.log();
|
|
162
225
|
}
|
|
163
226
|
function createBasicTemplate(targetDir, projectName) {
|
|
227
|
+
const latestVersion = getLatestVersion();
|
|
164
228
|
// package.json
|
|
165
229
|
writeFileSync(join(targetDir, 'package.json'), JSON.stringify({
|
|
166
230
|
name: projectName,
|
|
167
|
-
version: '1.1.
|
|
231
|
+
version: '1.1.4',
|
|
168
232
|
type: 'module',
|
|
169
233
|
scripts: {
|
|
170
234
|
parse: 'npx tsx src/index.ts',
|
|
171
235
|
build: 'tsc',
|
|
172
236
|
},
|
|
173
237
|
dependencies: {
|
|
174
|
-
'@ifc-lite/parser':
|
|
238
|
+
'@ifc-lite/parser': latestVersion,
|
|
175
239
|
},
|
|
176
240
|
devDependencies: {
|
|
177
241
|
typescript: '^5.3.0',
|