create-hedgeboard 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/index.js +19 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -145,12 +145,28 @@ async function main() {
145
145
  process.exit(1);
146
146
  }
147
147
 
148
- // 3. Extract
148
+ // 3. Extract to temp, then move to target dir
149
149
  const absDir = path.resolve(dir);
150
150
  process.stdout.write(` → Extracting to ${absDir}... `);
151
151
  try {
152
- extractZip(zipBuffer, path.dirname(absDir));
153
- // The ZIP contains hedgeboard/ so files land in the right place
152
+ const tmpDir = path.join(require("os").tmpdir(), `hb-extract-${Date.now()}`);
153
+ extractZip(zipBuffer, tmpDir);
154
+
155
+ // The ZIP contains hedgeboard/ folder — move its contents to target
156
+ const extractedDir = path.join(tmpDir, "hedgeboard");
157
+ if (fs.existsSync(extractedDir)) {
158
+ // Move extracted hedgeboard/ to the user's target dir
159
+ fs.mkdirSync(path.dirname(absDir), { recursive: true });
160
+ if (fs.existsSync(absDir)) {
161
+ // Merge into existing dir
162
+ const { execSync } = require("child_process");
163
+ execSync(`cp -r "${extractedDir}/"* "${absDir}/"`);
164
+ } else {
165
+ fs.renameSync(extractedDir, absDir);
166
+ }
167
+ }
168
+ // Cleanup temp
169
+ fs.rmSync(tmpDir, { recursive: true, force: true });
154
170
  console.log("✓");
155
171
  } catch (err) {
156
172
  console.log("✗");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-hedgeboard",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Set up a HedgeBoard financial intelligence workspace",
5
5
  "bin": {
6
6
  "create-hedgeboard": "./index.js"