ai-project-manage-cli 8.1.8 → 8.1.9
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/worker-script.js +24 -16
- package/package.json +1 -1
package/dist/worker-script.js
CHANGED
|
@@ -4531,8 +4531,23 @@ async function syncWebIdeAttachments(cfg2, taskId, workdir, attachments) {
|
|
|
4531
4531
|
|
|
4532
4532
|
// src/commands/sync-webide-design.ts
|
|
4533
4533
|
import { createHash as createHash3 } from "crypto";
|
|
4534
|
-
import { existsSync as existsSync10, readdirSync as readdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
4534
|
+
import { existsSync as existsSync10, readdirSync as readdirSync4, readFileSync as readFileSync8, statSync as statSync5, writeFileSync as writeFileSync7 } from "fs";
|
|
4535
4535
|
import { join as join7 } from "path";
|
|
4536
|
+
|
|
4537
|
+
// src/opc-shared-types.ts
|
|
4538
|
+
function webIdeDesignObjectKey(taskId, fileName) {
|
|
4539
|
+
const safe = fileName.replace(/[/\\:*?"<>|]/g, "_").trim() || "index.html";
|
|
4540
|
+
return `tasks/${taskId.trim()}/design/${safe}`;
|
|
4541
|
+
}
|
|
4542
|
+
function isWebIdeDesignArtifactName(name) {
|
|
4543
|
+
const lower = name.trim().toLowerCase();
|
|
4544
|
+
return lower.endsWith(".html") || lower.endsWith(".css");
|
|
4545
|
+
}
|
|
4546
|
+
function webIdeDesignArtifactContentType(name) {
|
|
4547
|
+
return name.trim().toLowerCase().endsWith(".css") ? "text/css; charset=utf-8" : "text/html; charset=utf-8";
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
// src/commands/sync-webide-design.ts
|
|
4536
4551
|
var MANIFEST_FILE3 = ".sync-manifest.json";
|
|
4537
4552
|
function hashBuffer(buf) {
|
|
4538
4553
|
return createHash3("sha256").update(buf).digest("hex");
|
|
@@ -4580,7 +4595,7 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
|
|
|
4580
4595
|
const synced = [];
|
|
4581
4596
|
for (const art of artifacts) {
|
|
4582
4597
|
const name = art.name?.trim();
|
|
4583
|
-
if (!name || !name
|
|
4598
|
+
if (!name || !isWebIdeDesignArtifactName(name)) continue;
|
|
4584
4599
|
const localPath = join7(dir, name);
|
|
4585
4600
|
const entry = manifest.files[name];
|
|
4586
4601
|
if (entry?.contentHash === art.contentHash && existsSync10(localPath)) {
|
|
@@ -4594,13 +4609,14 @@ async function syncWebIdeDesign(cfg2, taskId, workdir, artifacts) {
|
|
|
4594
4609
|
saveManifest2(dir, manifest);
|
|
4595
4610
|
return synced;
|
|
4596
4611
|
}
|
|
4597
|
-
function
|
|
4612
|
+
function listLocalDesignArtifactFiles(taskId, workdir) {
|
|
4598
4613
|
const dir = webideDesignDir(taskId, workdir);
|
|
4599
4614
|
if (!existsSync10(dir)) return [];
|
|
4600
4615
|
const out = [];
|
|
4601
4616
|
for (const name of readdirSync4(dir)) {
|
|
4602
|
-
if (!name
|
|
4617
|
+
if (!isWebIdeDesignArtifactName(name)) continue;
|
|
4603
4618
|
const absPath = join7(dir, name);
|
|
4619
|
+
if (!statSync5(absPath).isFile()) continue;
|
|
4604
4620
|
const buf = readFileSync8(absPath);
|
|
4605
4621
|
if (buf.length === 0) continue;
|
|
4606
4622
|
out.push({ name, absPath, contentHash: hashBuffer(buf) });
|
|
@@ -4608,25 +4624,17 @@ function listLocalDesignHtmlFiles(taskId, workdir) {
|
|
|
4608
4624
|
return out;
|
|
4609
4625
|
}
|
|
4610
4626
|
|
|
4611
|
-
// src/opc-shared-types.ts
|
|
4612
|
-
function webIdeDesignObjectKey(taskId, fileName) {
|
|
4613
|
-
const safe = fileName.replace(/[/\\:*?"<>|]/g, "_").trim() || "index.html";
|
|
4614
|
-
return `tasks/${taskId.trim()}/design/${safe}`;
|
|
4615
|
-
}
|
|
4616
|
-
|
|
4617
4627
|
// src/commands/connect/upload-webide-design.ts
|
|
4618
4628
|
async function uploadWebIdeDesignArtifacts(cfg2, taskId, workdir) {
|
|
4619
|
-
const locals =
|
|
4620
|
-
if (locals.
|
|
4629
|
+
const locals = listLocalDesignArtifactFiles(taskId, workdir);
|
|
4630
|
+
if (!locals.some((file) => file.name.toLowerCase().endsWith(".html"))) {
|
|
4621
4631
|
throw new Error(
|
|
4622
4632
|
`\u8BBE\u8BA1\u76EE\u5F55\u65E0 HTML \u4EA7\u7269\uFF1A.apm/webide/${taskId}/design/\uFF08\u8BF7\u5199\u5165\u81F3\u5C11\u4E00\u4EFD .html\uFF09`
|
|
4623
4633
|
);
|
|
4624
4634
|
}
|
|
4625
4635
|
const api = createApmApiClient(cfg2);
|
|
4626
4636
|
const remote = await api.cli.webideListDesignArtifacts({ taskId }) ?? [];
|
|
4627
|
-
const remoteByName = new Map(
|
|
4628
|
-
remote.map((r) => [r.name, r])
|
|
4629
|
-
);
|
|
4637
|
+
const remoteByName = new Map(remote.map((r) => [r.name, r]));
|
|
4630
4638
|
const { client, bucket } = await createApmLogMinioClient(cfg2);
|
|
4631
4639
|
await client.ensureBucket(bucket);
|
|
4632
4640
|
let uploaded = 0;
|
|
@@ -4645,7 +4653,7 @@ async function uploadWebIdeDesignArtifacts(cfg2, taskId, workdir) {
|
|
|
4645
4653
|
continue;
|
|
4646
4654
|
}
|
|
4647
4655
|
await client.fPutObject(bucket, objectKey, file.absPath, {
|
|
4648
|
-
"Content-Type":
|
|
4656
|
+
"Content-Type": webIdeDesignArtifactContentType(file.name)
|
|
4649
4657
|
});
|
|
4650
4658
|
uploaded += 1;
|
|
4651
4659
|
artifacts.push({
|