openclaw-superpowers-plugin 1.0.1 → 1.0.3
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/index.js +4 -4
- package/lib/vendor.js +18 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -128,12 +128,12 @@ module.exports = {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
if (action === 'install') {
|
|
131
|
-
const result = vendorApi.install();
|
|
131
|
+
const result = await vendorApi.install();
|
|
132
132
|
return { text: JSON.stringify(result, null, 2) };
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
if (action === 'update') {
|
|
136
|
-
const result = vendorApi.update();
|
|
136
|
+
const result = await vendorApi.update();
|
|
137
137
|
return { text: JSON.stringify(result, null, 2) };
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -190,7 +190,7 @@ module.exports = {
|
|
|
190
190
|
additionalProperties: false
|
|
191
191
|
},
|
|
192
192
|
async execute() {
|
|
193
|
-
const result = vendorApi.install();
|
|
193
|
+
const result = await vendorApi.install();
|
|
194
194
|
return textResult(JSON.stringify(result, null, 2), result);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
@@ -205,7 +205,7 @@ module.exports = {
|
|
|
205
205
|
additionalProperties: false
|
|
206
206
|
},
|
|
207
207
|
async execute() {
|
|
208
|
-
const result = vendorApi.update();
|
|
208
|
+
const result = await vendorApi.update();
|
|
209
209
|
return textResult(JSON.stringify(result, null, 2), result);
|
|
210
210
|
}
|
|
211
211
|
});
|
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);
|