create-ifc-lite 1.7.0 → 1.9.0

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.
@@ -1,6 +1,15 @@
1
+ /**
2
+ * Fetch the latest published version of a specific npm package.
3
+ * Results are cached so repeated calls for the same package are free.
4
+ * Falls back to '^1.0.0' when the registry is unreachable.
5
+ */
6
+ export declare function getPackageVersion(packageName: string): string;
1
7
  /**
2
8
  * Fetch the latest published version of @ifc-lite/parser from npm.
3
9
  * Falls back to '^1.0.0' when the registry is unreachable.
10
+ *
11
+ * @deprecated Use getPackageVersion(packageName) to query each package
12
+ * individually and avoid version mismatches between packages.
4
13
  */
5
14
  export declare function getLatestVersion(): string;
6
15
  /**
@@ -4,19 +4,39 @@
4
4
  import { existsSync, readFileSync, writeFileSync, rmSync } from 'fs';
5
5
  import { join } from 'path';
6
6
  import { execSync } from 'child_process';
7
+ /** Cache of npm-resolved versions to avoid redundant registry queries. */
8
+ const versionCache = new Map();
7
9
  /**
8
- * Fetch the latest published version of @ifc-lite/parser from npm.
10
+ * Fetch the latest published version of a specific npm package.
11
+ * Results are cached so repeated calls for the same package are free.
9
12
  * Falls back to '^1.0.0' when the registry is unreachable.
10
13
  */
11
- export function getLatestVersion() {
14
+ export function getPackageVersion(packageName) {
15
+ if (versionCache.has(packageName)) {
16
+ return versionCache.get(packageName);
17
+ }
12
18
  try {
13
- const result = execSync('npm view @ifc-lite/parser version', { stdio: 'pipe' });
14
- return `^${result.toString().trim()}`;
19
+ const result = execSync(`npm view ${packageName} version`, { stdio: 'pipe' });
20
+ const version = `^${result.toString().trim()}`;
21
+ versionCache.set(packageName, version);
22
+ return version;
15
23
  }
16
24
  catch {
17
- return '^1.0.0'; // fallback
25
+ const fallback = '^1.0.0';
26
+ versionCache.set(packageName, fallback);
27
+ return fallback;
18
28
  }
19
29
  }
30
+ /**
31
+ * Fetch the latest published version of @ifc-lite/parser from npm.
32
+ * Falls back to '^1.0.0' when the registry is unreachable.
33
+ *
34
+ * @deprecated Use getPackageVersion(packageName) to query each package
35
+ * individually and avoid version mismatches between packages.
36
+ */
37
+ export function getLatestVersion() {
38
+ return getPackageVersion('@ifc-lite/parser');
39
+ }
20
40
  /**
21
41
  * Rewrite the viewer's package.json so it works as a standalone project:
22
42
  * - Set the project name
@@ -30,8 +50,9 @@ export function fixPackageJson(targetDir, projectName) {
30
50
  const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
31
51
  // Update name
32
52
  pkg.name = projectName;
33
- // Replace workspace protocol with latest npm version in all dependency fields
34
- const latestVersion = getLatestVersion();
53
+ // Replace workspace protocol with the actual published version of each package.
54
+ // Each @ifc-lite/* package is queried individually so a package that was not
55
+ // published in the latest release does not end up with a non-existent version.
35
56
  const depFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
36
57
  for (const field of depFields) {
37
58
  const deps = pkg[field];
@@ -39,7 +60,7 @@ export function fixPackageJson(targetDir, projectName) {
39
60
  continue;
40
61
  for (const [name, version] of Object.entries(deps)) {
41
62
  if (typeof version === 'string' && version.includes('workspace:')) {
42
- deps[name] = latestVersion;
63
+ deps[name] = getPackageVersion(name);
43
64
  }
44
65
  }
45
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ifc-lite",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Create IFC-Lite projects with one command",
5
5
  "type": "module",
6
6
  "bin": {