@theholocron/cli 5.0.0-alpha.594 → 5.0.0-alpha.595
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/cli.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import yargs from "yargs";
|
|
|
14
14
|
import { hideBin } from "yargs/helpers";
|
|
15
15
|
import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
16
16
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
17
|
-
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
17
|
+
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, deferCredentials, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
18
18
|
import { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, postAggregate, readWorkspacePackages, recordDeploys, requiredChecks, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
19
19
|
import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
|
|
20
20
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
@@ -3071,6 +3071,29 @@ async function tryEnvironments(candidates, attempt) {
|
|
|
3071
3071
|
missing
|
|
3072
3072
|
};
|
|
3073
3073
|
}
|
|
3074
|
+
// src/credentials-environments/try-environments-sync/try-environments-sync.ts
|
|
3075
|
+
/**
|
|
3076
|
+
* `tryEnvironments()` for an `attempt` that is synchronous, which a deferred credentials read must be (the token
|
|
3077
|
+
* resolvers that trigger it cannot wait). A 404 is a miss; any other error is thrown. A missing optional Environment
|
|
3078
|
+
* is silent; a missing required one is reported by name.
|
|
3079
|
+
*/
|
|
3080
|
+
function tryEnvironmentsSync(candidates, attempt) {
|
|
3081
|
+
const found = [];
|
|
3082
|
+
const missing = [];
|
|
3083
|
+
for (const candidate of candidates) try {
|
|
3084
|
+
found.push({
|
|
3085
|
+
name: candidate.name,
|
|
3086
|
+
result: attempt(candidate.name)
|
|
3087
|
+
});
|
|
3088
|
+
} catch (err) {
|
|
3089
|
+
if (err?.status !== 404) throw err;
|
|
3090
|
+
if (!candidate.optional) missing.push(candidate.name);
|
|
3091
|
+
}
|
|
3092
|
+
return {
|
|
3093
|
+
found,
|
|
3094
|
+
missing
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3074
3097
|
// src/credentials-environments/unsynced-layer/unsynced-layer.ts
|
|
3075
3098
|
/**
|
|
3076
3099
|
* The layers this machine reads for itself (`agent` is the one an agent's process reads, spec `tech-agent-secrets`). They
|
|
@@ -4413,6 +4436,8 @@ function assertPluginsResolvable(loader, command) {
|
|
|
4413
4436
|
* `importer` is injectable so tests don't need real network or
|
|
4414
4437
|
* sibling packages installed.
|
|
4415
4438
|
*/
|
|
4439
|
+
/** The prefix of the key a deferred read of a `credentials` provider is kept under. */
|
|
4440
|
+
const LAZY = "lazy:";
|
|
4416
4441
|
const system = createPluginSystem({
|
|
4417
4442
|
packagePrefix: "@theholocron/holocron-plugin-",
|
|
4418
4443
|
communityPrefix: "holocron-plugin-",
|
|
@@ -4448,15 +4473,31 @@ const system = createPluginSystem({
|
|
|
4448
4473
|
const impl = await api.loadOne("credentials", tuple);
|
|
4449
4474
|
impls.push(impl);
|
|
4450
4475
|
if (options?.readCredentials === false) continue;
|
|
4451
|
-
const
|
|
4476
|
+
const candidates = await resolveEnvironments(tuple.provider, explicit, {
|
|
4452
4477
|
repoRoot: context.repoRoot,
|
|
4453
4478
|
...options?.env ? { env: options.env } : {},
|
|
4454
4479
|
...options?.gitExec ? { gitExec: options.gitExec } : {}
|
|
4455
|
-
})
|
|
4480
|
+
});
|
|
4481
|
+
const missingError = (missing) => new LoaderError(`${tuple.provider} has no Environment named ${missing.map((n) => `"${n}"`).join(", ")}`);
|
|
4482
|
+
if (impl.readSync) {
|
|
4483
|
+
const read = impl.readSync.bind(impl);
|
|
4484
|
+
deferCredentials(`${LAZY}${tuple.provider}:${candidates.map((c) => c.name).join("|")}`, () => {
|
|
4485
|
+
try {
|
|
4486
|
+
const { missing } = tryEnvironmentsSync(candidates, (name) => {
|
|
4487
|
+
setCredentials(`${tuple.provider}:${name}`, read(name));
|
|
4488
|
+
});
|
|
4489
|
+
if (missing.length > 0) throw missingError(missing);
|
|
4490
|
+
} catch (err) {
|
|
4491
|
+
api.fail("credentials", tuple, err);
|
|
4492
|
+
}
|
|
4493
|
+
});
|
|
4494
|
+
continue;
|
|
4495
|
+
}
|
|
4496
|
+
const { missing } = await tryEnvironments(candidates, async (name) => {
|
|
4456
4497
|
const sourceName = `${tuple.provider}:${name}`;
|
|
4457
4498
|
if (!hasCredentials(sourceName)) setCredentials(sourceName, await impl.read(name));
|
|
4458
4499
|
});
|
|
4459
|
-
if (missing.length > 0) throw
|
|
4500
|
+
if (missing.length > 0) throw missingError(missing);
|
|
4460
4501
|
} catch (err) {
|
|
4461
4502
|
api.fail("credentials", tuple, err);
|
|
4462
4503
|
}
|