openclaw-superpowers-plugin 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.
- package/lib/vendor.js +18 -10
- package/package.json +1 -1
package/lib/vendor.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const os = require('os');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const {
|
|
4
|
+
const { exec } = require('child_process');
|
|
5
|
+
const { promisify } = require('util');
|
|
6
|
+
|
|
7
|
+
const execAsync = promisify(exec);
|
|
5
8
|
|
|
6
9
|
function createVendorApi({ ROOT, CONFIG, VENDOR_DIR, CACHE_FILE, SKILLS_DIR }) {
|
|
7
10
|
function ensureDir(dir) {
|
|
@@ -12,8 +15,13 @@ function createVendorApi({ ROOT, CONFIG, VENDOR_DIR, CACHE_FILE, SKILLS_DIR }) {
|
|
|
12
15
|
return fs.existsSync(p);
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
function runCommand(command, cwd = ROOT) {
|
|
16
|
-
|
|
18
|
+
async function runCommand(command, cwd = ROOT) {
|
|
19
|
+
try {
|
|
20
|
+
const { stdout } = await execAsync(command, { cwd, encoding: 'utf8' });
|
|
21
|
+
return stdout.trim();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new Error(`Command failed: ${command}\n${error.stderr || error.message}`);
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
function safeRemove(target) {
|
|
@@ -35,12 +43,12 @@ function createVendorApi({ ROOT, CONFIG, VENDOR_DIR, CACHE_FILE, SKILLS_DIR }) {
|
|
|
35
43
|
return loadIndex()?.upstreamCommit || null;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
function withTempClone(callback) {
|
|
46
|
+
async function withTempClone(callback) {
|
|
39
47
|
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'superpowers-'));
|
|
40
48
|
const cloneDir = path.join(tempRoot, 'repo');
|
|
41
49
|
try {
|
|
42
|
-
runCommand(`git clone --depth 1 --branch ${CONFIG.defaultBranch} ${CONFIG.upstreamRepo} ${cloneDir}`);
|
|
43
|
-
const commit = runCommand('git rev-parse HEAD', cloneDir);
|
|
50
|
+
await runCommand(`git clone --depth 1 --branch ${CONFIG.defaultBranch} ${CONFIG.upstreamRepo} ${cloneDir}`);
|
|
51
|
+
const commit = await runCommand('git rev-parse HEAD', cloneDir);
|
|
44
52
|
return callback({ tempRoot, cloneDir, commit });
|
|
45
53
|
} finally {
|
|
46
54
|
safeRemove(tempRoot);
|
|
@@ -89,7 +97,7 @@ function createVendorApi({ ROOT, CONFIG, VENDOR_DIR, CACHE_FILE, SKILLS_DIR }) {
|
|
|
89
97
|
return payload;
|
|
90
98
|
}
|
|
91
99
|
|
|
92
|
-
function install() {
|
|
100
|
+
async function install() {
|
|
93
101
|
if (exists(VENDOR_DIR) && exists(SKILLS_DIR)) {
|
|
94
102
|
return {
|
|
95
103
|
ok: true,
|
|
@@ -99,7 +107,7 @@ function createVendorApi({ ROOT, CONFIG, VENDOR_DIR, CACHE_FILE, SKILLS_DIR }) {
|
|
|
99
107
|
};
|
|
100
108
|
}
|
|
101
109
|
|
|
102
|
-
return withTempClone(({ cloneDir, commit }) => {
|
|
110
|
+
return await withTempClone(async ({ cloneDir, commit }) => {
|
|
103
111
|
const gitDir = path.join(cloneDir, '.git');
|
|
104
112
|
if (exists(gitDir)) safeRemove(gitDir);
|
|
105
113
|
copyDir(cloneDir, VENDOR_DIR);
|
|
@@ -114,8 +122,8 @@ function createVendorApi({ ROOT, CONFIG, VENDOR_DIR, CACHE_FILE, SKILLS_DIR }) {
|
|
|
114
122
|
});
|
|
115
123
|
}
|
|
116
124
|
|
|
117
|
-
function update() {
|
|
118
|
-
return withTempClone(({ cloneDir, commit }) => {
|
|
125
|
+
async function update() {
|
|
126
|
+
return await withTempClone(async ({ cloneDir, commit }) => {
|
|
119
127
|
const gitDir = path.join(cloneDir, '.git');
|
|
120
128
|
if (exists(gitDir)) safeRemove(gitDir);
|
|
121
129
|
copyDir(cloneDir, VENDOR_DIR);
|