create-middag-ui 0.2.0 → 0.2.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/lib/scaffold.js +16 -3
- package/package.json +1 -1
package/lib/scaffold.js
CHANGED
|
@@ -5,10 +5,23 @@
|
|
|
5
5
|
* Every I/O operation is wrapped with error handling.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
9
|
-
import { join, basename } from "node:path";
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { join, basename, dirname } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
10
11
|
import { success, warn, error } from "./ui.js";
|
|
11
12
|
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
15
|
+
/** Read version from own package.json (synced from root by CI). */
|
|
16
|
+
function getLibVersion() {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
19
|
+
return pkg.version || "0.2.0";
|
|
20
|
+
} catch {
|
|
21
|
+
return "0.2.0";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
12
25
|
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
13
26
|
|
|
14
27
|
function writeFile(filePath, content, label) {
|
|
@@ -79,7 +92,7 @@ export function scaffoldPackageJson(targetDir, host, cwd) {
|
|
|
79
92
|
"lint:fix": "eslint . --fix",
|
|
80
93
|
},
|
|
81
94
|
dependencies: {
|
|
82
|
-
"@middag-io/react":
|
|
95
|
+
"@middag-io/react": `^${getLibVersion()}`,
|
|
83
96
|
},
|
|
84
97
|
devDependencies: {
|
|
85
98
|
"@types/react": "^19.0.0",
|