@lark-apaas/openclaw-scripts-diagnose-cli 0.1.1-alpha.24 → 0.1.1-alpha.25
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.cjs +68 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -877,6 +877,74 @@ SecretsRule = __decorate([Rule({
|
|
|
877
877
|
skipWhen: ({ hasMiaoda, deps }) => !hasMiaoda || !deps.usesMiaodaSecretProvider
|
|
878
878
|
})], SecretsRule);
|
|
879
879
|
//#endregion
|
|
880
|
+
//#region src/rules/template-vars-unreplaced.ts
|
|
881
|
+
/**
|
|
882
|
+
* Placeholder format used by miaoda-openclaw-template and Go-side templateVars,
|
|
883
|
+
* e.g. `$$__FEISHU_APP_ID__`. Double underscores on both sides act as a natural
|
|
884
|
+
* boundary so split-join replacement can't accidentally overlap between keys.
|
|
885
|
+
*/
|
|
886
|
+
const PLACEHOLDER_RE = /\$\$__[A-Z0-9_]+__/g;
|
|
887
|
+
let TemplateVarsUnreplacedRule = class TemplateVarsUnreplacedRule extends DiagnoseRule {
|
|
888
|
+
validate(ctx) {
|
|
889
|
+
const found = /* @__PURE__ */ new Set();
|
|
890
|
+
collectPlaceholders(ctx.config, found);
|
|
891
|
+
if (found.size === 0) return { pass: true };
|
|
892
|
+
return {
|
|
893
|
+
pass: false,
|
|
894
|
+
message: "存在未替换的模板占位符: " + [...found].sort().join(", ")
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
repair(ctx) {
|
|
898
|
+
const map = ctx.templateVars;
|
|
899
|
+
if (!map || Object.keys(map).length === 0) return;
|
|
900
|
+
replaceInPlace(ctx.config, Object.entries(map));
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
TemplateVarsUnreplacedRule = __decorate([Rule({
|
|
904
|
+
key: "template_vars_unreplaced",
|
|
905
|
+
dependsOn: ["config_syntax_check"],
|
|
906
|
+
repairMode: "standard"
|
|
907
|
+
})], TemplateVarsUnreplacedRule);
|
|
908
|
+
function collectPlaceholders(value, found) {
|
|
909
|
+
if (typeof value === "string") {
|
|
910
|
+
const matches = value.match(PLACEHOLDER_RE);
|
|
911
|
+
if (matches) for (const m of matches) found.add(m);
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
if (Array.isArray(value)) {
|
|
915
|
+
for (const v of value) collectPlaceholders(v, found);
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (value && typeof value === "object") for (const v of Object.values(value)) collectPlaceholders(v, found);
|
|
919
|
+
}
|
|
920
|
+
function replaceInPlace(value, entries) {
|
|
921
|
+
if (Array.isArray(value)) {
|
|
922
|
+
for (let i = 0; i < value.length; i++) {
|
|
923
|
+
const el = value[i];
|
|
924
|
+
if (typeof el === "string") value[i] = applyVars(el, entries);
|
|
925
|
+
else replaceInPlace(el, entries);
|
|
926
|
+
}
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
if (value && typeof value === "object") {
|
|
930
|
+
const obj = value;
|
|
931
|
+
for (const key of Object.keys(obj)) {
|
|
932
|
+
const v = obj[key];
|
|
933
|
+
if (typeof v === "string") obj[key] = applyVars(v, entries);
|
|
934
|
+
else replaceInPlace(v, entries);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
/** Split-join replacement — matches the algorithm in reset.ts:120 and avoids regex-escaping `$$`. */
|
|
939
|
+
function applyVars(str, entries) {
|
|
940
|
+
let out = str;
|
|
941
|
+
for (const [placeholder, value] of entries) {
|
|
942
|
+
if (!value) continue;
|
|
943
|
+
if (out.includes(placeholder)) out = out.split(placeholder).join(value);
|
|
944
|
+
}
|
|
945
|
+
return out;
|
|
946
|
+
}
|
|
947
|
+
//#endregion
|
|
880
948
|
//#region src/rules/cleanup-install-backup-dirs.ts
|
|
881
949
|
const DIR_PREFIX = ".openclaw-install-";
|
|
882
950
|
function resolveExtensionsDir(configPath) {
|
package/package.json
CHANGED