@meistrari/tela-cli 1.12.0 → 1.12.1
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 +81 -46
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77680,56 +77680,69 @@ Run \`tela skills install ${slug} --force\` to replace it, or remove it by hand.
|
|
|
77680
77680
|
return { upgraded, unchanged, replaced, diagnostics };
|
|
77681
77681
|
const targets = normalizeTargets(upgradeOptions.targets ?? paths.targets, paths.installRoot);
|
|
77682
77682
|
const client = await resolveClient();
|
|
77683
|
-
|
|
77684
|
-
|
|
77685
|
-
|
|
77686
|
-
|
|
77687
|
-
|
|
77688
|
-
|
|
77683
|
+
const signal = upgradeOptions.signal;
|
|
77684
|
+
let currentSlug = "";
|
|
77685
|
+
try {
|
|
77686
|
+
for (const current of selected) {
|
|
77687
|
+
currentSlug = current.slug;
|
|
77688
|
+
signal?.throwIfAborted();
|
|
77689
|
+
const { ingredient, snapshot } = await (0, skills_1.fetchSkillFile)(client, current.slug);
|
|
77690
|
+
const replacementSlug = await resolveReplacementSlug(client, current.slug, ingredient);
|
|
77691
|
+
if (replacementSlug) {
|
|
77692
|
+
const installedReplacement = (await (0, tela_local_config_1.listInstalledSkills)(inventoryFile)).find((entry2) => entry2.slug === replacementSlug);
|
|
77693
|
+
const replacement = await installOne({
|
|
77694
|
+
client,
|
|
77695
|
+
diagnostics: emit,
|
|
77696
|
+
...installedReplacement ? { expectedCurrent: installedReplacement, operation: "upgrade" } : {},
|
|
77697
|
+
force: upgradeOptions.force ?? false,
|
|
77698
|
+
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77699
|
+
inventoryFile,
|
|
77700
|
+
paths,
|
|
77701
|
+
progress: options2.onInstallProgress,
|
|
77702
|
+
signal,
|
|
77703
|
+
slug: replacementSlug,
|
|
77704
|
+
targets
|
|
77705
|
+
});
|
|
77706
|
+
if (!replacement)
|
|
77707
|
+
continue;
|
|
77708
|
+
signal?.throwIfAborted();
|
|
77709
|
+
if (await uninstallOne({
|
|
77710
|
+
diagnostics: emit,
|
|
77711
|
+
entry: current,
|
|
77712
|
+
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77713
|
+
inventoryFile,
|
|
77714
|
+
operation: "upgrade",
|
|
77715
|
+
paths
|
|
77716
|
+
})) {
|
|
77717
|
+
replaced.push({ from: current.slug, to: replacement });
|
|
77718
|
+
}
|
|
77719
|
+
continue;
|
|
77720
|
+
}
|
|
77721
|
+
if (snapshot.sha === current.sha) {
|
|
77722
|
+
unchanged.push(current.slug);
|
|
77723
|
+
continue;
|
|
77724
|
+
}
|
|
77725
|
+
const entry = await installOne({
|
|
77689
77726
|
client,
|
|
77690
77727
|
diagnostics: emit,
|
|
77691
|
-
|
|
77728
|
+
expectedCurrent: current,
|
|
77692
77729
|
force: upgradeOptions.force ?? false,
|
|
77693
77730
|
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77694
77731
|
inventoryFile,
|
|
77732
|
+
operation: "upgrade",
|
|
77695
77733
|
paths,
|
|
77696
77734
|
progress: options2.onInstallProgress,
|
|
77697
|
-
|
|
77735
|
+
signal,
|
|
77736
|
+
slug: current.slug,
|
|
77698
77737
|
targets
|
|
77699
77738
|
});
|
|
77700
|
-
if (
|
|
77701
|
-
|
|
77702
|
-
if (await uninstallOne({
|
|
77703
|
-
diagnostics: emit,
|
|
77704
|
-
entry: current,
|
|
77705
|
-
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77706
|
-
inventoryFile,
|
|
77707
|
-
operation: "upgrade",
|
|
77708
|
-
paths
|
|
77709
|
-
})) {
|
|
77710
|
-
replaced.push({ from: current.slug, to: replacement });
|
|
77711
|
-
}
|
|
77712
|
-
continue;
|
|
77713
|
-
}
|
|
77714
|
-
if (snapshot.sha === current.sha) {
|
|
77715
|
-
unchanged.push(current.slug);
|
|
77716
|
-
continue;
|
|
77739
|
+
if (entry)
|
|
77740
|
+
upgraded.push(entry);
|
|
77717
77741
|
}
|
|
77718
|
-
|
|
77719
|
-
|
|
77720
|
-
|
|
77721
|
-
|
|
77722
|
-
force: upgradeOptions.force ?? false,
|
|
77723
|
-
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77724
|
-
inventoryFile,
|
|
77725
|
-
operation: "upgrade",
|
|
77726
|
-
paths,
|
|
77727
|
-
progress: options2.onInstallProgress,
|
|
77728
|
-
slug: current.slug,
|
|
77729
|
-
targets
|
|
77730
|
-
});
|
|
77731
|
-
if (entry)
|
|
77732
|
-
upgraded.push(entry);
|
|
77742
|
+
} catch (error48) {
|
|
77743
|
+
if (signal?.aborted)
|
|
77744
|
+
throw new SkillInstallCancelledError(currentSlug, upgraded);
|
|
77745
|
+
throw error48;
|
|
77733
77746
|
}
|
|
77734
77747
|
return { upgraded, unchanged, replaced, diagnostics };
|
|
77735
77748
|
},
|
|
@@ -386357,7 +386370,11 @@ var require_setup = __commonJS({
|
|
|
386357
386370
|
exports2.findAgentSetupOrganization = findAgentSetupOrganization;
|
|
386358
386371
|
exports2.validatePreparedAgentSetupInput = validatePreparedAgentSetupInput;
|
|
386359
386372
|
exports2.saveAgentContextSetup = saveAgentContextSetup;
|
|
386373
|
+
exports2.provisionForgejoUserWithSshKey = provisionForgejoUserWithSshKey;
|
|
386374
|
+
exports2.createUniqueSshKeyTitle = createUniqueSshKeyTitle;
|
|
386360
386375
|
exports2.completeAgentSetup = completeAgentSetup;
|
|
386376
|
+
var node_buffer_1 = require("node:buffer");
|
|
386377
|
+
var node_crypto_1 = require("node:crypto");
|
|
386361
386378
|
var node_fs_1 = require("node:fs");
|
|
386362
386379
|
var node_os_1 = require("node:os");
|
|
386363
386380
|
var node_path_1 = require("node:path");
|
|
@@ -386742,6 +386759,28 @@ var require_setup = __commonJS({
|
|
|
386742
386759
|
}
|
|
386743
386760
|
return savedSetup;
|
|
386744
386761
|
}
|
|
386762
|
+
var SSH_KEY_TITLE_CONFLICT = /ssh key title already belongs to a different key/i;
|
|
386763
|
+
async function provisionForgejoUserWithSshKey(organizationName, sshKey, config2, provisionFn, fetchFn) {
|
|
386764
|
+
try {
|
|
386765
|
+
return {
|
|
386766
|
+
response: await provisionFn({ organizationName, sshKey }, config2, fetchFn),
|
|
386767
|
+
title: sshKey.title
|
|
386768
|
+
};
|
|
386769
|
+
} catch (error48) {
|
|
386770
|
+
if (!(error48 instanceof agent_api_1.AgentApiError) || !SSH_KEY_TITLE_CONFLICT.test(error48.message))
|
|
386771
|
+
throw error48;
|
|
386772
|
+
}
|
|
386773
|
+
const title = createUniqueSshKeyTitle(sshKey);
|
|
386774
|
+
return {
|
|
386775
|
+
response: await provisionFn({ organizationName, sshKey: { ...sshKey, title } }, config2, fetchFn),
|
|
386776
|
+
title
|
|
386777
|
+
};
|
|
386778
|
+
}
|
|
386779
|
+
function createUniqueSshKeyTitle(sshKey, host = (0, node_os_1.hostname)()) {
|
|
386780
|
+
const blob = sshKey.key.split(/\s+/)[1] ?? sshKey.key;
|
|
386781
|
+
const fingerprint = (0, node_crypto_1.createHash)("sha256").update(node_buffer_1.Buffer.from(blob, "base64")).digest("base64").replace(/=+$/, "").slice(0, 12);
|
|
386782
|
+
return `${sshKey.title} (${host}, SHA256:${fingerprint})`;
|
|
386783
|
+
}
|
|
386745
386784
|
async function completeAgentSetup(input, options2 = {}) {
|
|
386746
386785
|
const credentials = (0, credentials_1.createAgentCredentialAdapter)(options2.env);
|
|
386747
386786
|
const config2 = await (0, config_1.resolveAgentConfig)({
|
|
@@ -386757,15 +386796,11 @@ var require_setup = __commonJS({
|
|
|
386757
386796
|
const sshKey = loadSshPublicKey(input.sshPublicKeyPath);
|
|
386758
386797
|
const gitSshKey = createGitSshKey(sshKey, input.sshPrivateKeyPath);
|
|
386759
386798
|
const cloneRoot = input.cloneRoot ? resolveCloneRootPath(input.cloneRoot) : config2.cloneRoot;
|
|
386760
|
-
const
|
|
386761
|
-
const response = await provisionFn({
|
|
386762
|
-
organizationName: organization.name,
|
|
386763
|
-
sshKey
|
|
386764
|
-
}, config2, options2.fetchFn);
|
|
386799
|
+
const { response, title } = await provisionForgejoUserWithSshKey(organization.name, sshKey, config2, options2.provisionFn ?? agent_api_1.provisionForgejoUser, options2.fetchFn);
|
|
386765
386800
|
const setup = await saveAgentContextSetup({
|
|
386766
386801
|
config: config2,
|
|
386767
386802
|
organization,
|
|
386768
|
-
gitSshKey,
|
|
386803
|
+
gitSshKey: { ...gitSshKey, title },
|
|
386769
386804
|
cloneRoot
|
|
386770
386805
|
});
|
|
386771
386806
|
return {
|