@hcmai/cli 0.21.6 → 0.21.7
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 +40 -0
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9782,6 +9782,9 @@ import {
|
|
|
9782
9782
|
inferMiniWritableTemplateOptionsFromModel,
|
|
9783
9783
|
listWorkspaceFiles,
|
|
9784
9784
|
loadWorkspaceFileContent,
|
|
9785
|
+
MINI_CONTEXT_FILE,
|
|
9786
|
+
MINI_PULL_MANIFEST_FILE,
|
|
9787
|
+
MINI_STATE_DIR,
|
|
9785
9788
|
pullMiniAppProject,
|
|
9786
9789
|
pushMiniAppProject,
|
|
9787
9790
|
runMiniSmokeChecks,
|
|
@@ -10342,6 +10345,7 @@ async function workspacePushCommand(args) {
|
|
|
10342
10345
|
try {
|
|
10343
10346
|
await withWorkspacePushProgress(async (bindHttp, assertRunning) => {
|
|
10344
10347
|
const rootDir = resolveRootDir(args.dir);
|
|
10348
|
+
await assertWorkspacePushRoot(rootDir);
|
|
10345
10349
|
const context = await requireWorkspaceContext(rootDir);
|
|
10346
10350
|
const miniApps = await discoverMiniApps(rootDir);
|
|
10347
10351
|
for (const app of miniApps) {
|
|
@@ -10544,6 +10548,42 @@ function removedMiniCommand() {
|
|
|
10544
10548
|
function resolveRootDir(dir) {
|
|
10545
10549
|
return path9.resolve(dir ?? ".");
|
|
10546
10550
|
}
|
|
10551
|
+
async function workspacePathExists(file) {
|
|
10552
|
+
try {
|
|
10553
|
+
await fs8.access(file);
|
|
10554
|
+
return true;
|
|
10555
|
+
} catch (e) {
|
|
10556
|
+
if (e.code === "ENOENT") return false;
|
|
10557
|
+
throw e;
|
|
10558
|
+
}
|
|
10559
|
+
}
|
|
10560
|
+
async function assertWorkspacePushRoot(rootDir) {
|
|
10561
|
+
const realRoot = await fs8.realpath(rootDir);
|
|
10562
|
+
let workspaceRoot;
|
|
10563
|
+
let insideMiniApp = false;
|
|
10564
|
+
let dir = realRoot;
|
|
10565
|
+
for (; ; ) {
|
|
10566
|
+
const parent = path9.dirname(dir);
|
|
10567
|
+
const appsDir = path9.basename(dir) === MINI_APPS_DIR ? dir : path9.basename(parent) === MINI_APPS_DIR ? parent : void 0;
|
|
10568
|
+
const miniDir = appsDir !== void 0 && (await workspacePathExists(path9.join(path9.dirname(appsDir), WORKSPACE_CONTEXT_FILE)) || appsDir === parent && await workspacePathExists(path9.join(dir, "manifest.json"))) || await workspacePathExists(path9.join(dir, MINI_CONTEXT_FILE)) || await workspacePathExists(path9.join(dir, MINI_STATE_DIR, MINI_PULL_MANIFEST_FILE));
|
|
10569
|
+
insideMiniApp ||= miniDir;
|
|
10570
|
+
if (!miniDir && await workspacePathExists(path9.join(dir, WORKSPACE_CONTEXT_FILE))) {
|
|
10571
|
+
workspaceRoot = dir;
|
|
10572
|
+
break;
|
|
10573
|
+
}
|
|
10574
|
+
if (parent === dir) break;
|
|
10575
|
+
dir = parent;
|
|
10576
|
+
}
|
|
10577
|
+
if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
|
|
10578
|
+
const target = workspaceRoot ? `'${workspaceRoot.replace(/'/g, "'\\''")}'` : "<workspace-root>";
|
|
10579
|
+
throw new CliError25({
|
|
10580
|
+
code: CliErrorCode26.INVALID_ARGUMENT,
|
|
10581
|
+
message: `workspace push \u5FC5\u987B\u4ECE workspace \u6839\u76EE\u5F55\u6267\u884C\uFF0C\u5F53\u524D\u76EE\u5F55 ${rootDir} \u662F${insideMiniApp ? "\u8F7B\u5E94\u7528\u76EE\u5F55\u6216\u5176\u5B50\u76EE\u5F55" : "\u5DE5\u4F5C\u533A\u5B50\u76EE\u5F55"}\uFF1B\u7EE7\u7EED\u4F1A\u8DF3\u8FC7\u8F7B\u5E94\u7528\u90E8\u7F72\u3002`,
|
|
10582
|
+
context: {
|
|
10583
|
+
nextStep: `${workspaceRoot ? `workspace \u6839\u76EE\u5F55\uFF1A${workspaceRoot}\u3002` : `\u672A\u627E\u5230\u4E0A\u5C42 ${WORKSPACE_CONTEXT_FILE}\uFF1B\u8BF7\u5148\u5B9A\u4F4D\u5305\u542B mini_apps/ \u7684 workspace \u6839\u76EE\u5F55\u3002`}\u6267\u884C hcm workspace push --dir ${target}\uFF0C\u4FDD\u7559\u539F\u6709 --env/--as \u7B49\u9009\u9879\u3002`
|
|
10584
|
+
}
|
|
10585
|
+
});
|
|
10586
|
+
}
|
|
10547
10587
|
function buildWorkspaceContext(args) {
|
|
10548
10588
|
return {
|
|
10549
10589
|
kind: WORKSPACE_CONTEXT_KIND,
|