@almadar/workspace 0.10.1 → 0.11.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/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path2 from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
2
|
+
import fs, { existsSync } from 'fs';
|
|
3
3
|
import { execFile } from 'child_process';
|
|
4
|
+
import dugite from 'dugite';
|
|
4
5
|
import { randomBytes, createHash } from 'crypto';
|
|
5
6
|
import { EmbeddingClient } from '@almadar/llm';
|
|
6
7
|
import os from 'os';
|
|
@@ -380,7 +381,10 @@ function createProjectOrbTemplate(projectName, appId) {
|
|
|
380
381
|
function serializeJson(value) {
|
|
381
382
|
return JSON.stringify(value, null, 2);
|
|
382
383
|
}
|
|
383
|
-
var
|
|
384
|
+
var { gitLocation: BUNDLED_GIT, env: BUNDLED_GIT_ENV } = dugite.setupEnvironment({});
|
|
385
|
+
var USE_BUNDLED = !process.env.ALMADAR_GIT_BINARY && existsSync(BUNDLED_GIT);
|
|
386
|
+
var GIT_BINARY = process.env.ALMADAR_GIT_BINARY || (USE_BUNDLED ? BUNDLED_GIT : "git");
|
|
387
|
+
var GIT_ENV = USE_BUNDLED ? { ...process.env, ...BUNDLED_GIT_ENV } : process.env;
|
|
384
388
|
var GitClient = class {
|
|
385
389
|
constructor(cwd, backend) {
|
|
386
390
|
this.cwd = cwd;
|
|
@@ -499,6 +503,8 @@ var GitClient = class {
|
|
|
499
503
|
/** Clone a bundle file into `targetDir` (hydrate a fresh workspace from the archive). */
|
|
500
504
|
async cloneBundle(bundleAbsPath, targetDir) {
|
|
501
505
|
await execGit(["clone", bundleAbsPath, targetDir], path2.dirname(bundleAbsPath));
|
|
506
|
+
await execGit(["remote", "remove", "origin"], targetDir).catch(() => {
|
|
507
|
+
});
|
|
502
508
|
}
|
|
503
509
|
exec(args) {
|
|
504
510
|
return execGit(args, this.cwd);
|
|
@@ -506,7 +512,7 @@ var GitClient = class {
|
|
|
506
512
|
};
|
|
507
513
|
function execGit(args, cwd) {
|
|
508
514
|
return new Promise((resolve, reject) => {
|
|
509
|
-
execFile(GIT_BINARY, args, { cwd, maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
|
|
515
|
+
execFile(GIT_BINARY, args, { cwd, env: GIT_ENV, maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
|
|
510
516
|
if (err) {
|
|
511
517
|
const message = stderr?.trim() || stdout?.trim() || err.message;
|
|
512
518
|
reject(new Error(`git ${args[0]}: ${message}`));
|
|
@@ -2209,10 +2215,14 @@ var WorkspaceServiceImpl = class {
|
|
|
2209
2215
|
await this.backend.rm(cloneDir, { recursive: true }).catch(() => {
|
|
2210
2216
|
});
|
|
2211
2217
|
await this.git.cloneBundle(bundlePath, cloneDir);
|
|
2212
|
-
|
|
2213
|
-
await this.backend.
|
|
2218
|
+
const dotGit = path2.join(this.workDir, ".git");
|
|
2219
|
+
await this.backend.rm(dotGit, { recursive: true }).catch(() => {
|
|
2220
|
+
});
|
|
2221
|
+
await this.backend.rename(path2.join(cloneDir, ".git"), dotGit);
|
|
2214
2222
|
return true;
|
|
2215
2223
|
} finally {
|
|
2224
|
+
await this.backend.rm(cloneDir, { recursive: true }).catch(() => {
|
|
2225
|
+
});
|
|
2216
2226
|
await this.backend.rm(bundlePath).catch(() => {
|
|
2217
2227
|
});
|
|
2218
2228
|
}
|