@theholocron/cli 5.0.0-alpha.559 → 5.0.0-alpha.560
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 +53 -7
- package/dist/cli.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -28700,7 +28700,8 @@ async function runGithubAppCreate(input) {
|
|
|
28700
28700
|
}, COMMAND$2);
|
|
28701
28701
|
return { status: "fail" };
|
|
28702
28702
|
};
|
|
28703
|
-
|
|
28703
|
+
const collect = input.collect;
|
|
28704
|
+
if (!collect && (input.platform ?? process.platform) === "win32") return refuse("windows", "cannot make the credentials file private on Windows: its mode bits are not enforced");
|
|
28704
28705
|
let base;
|
|
28705
28706
|
try {
|
|
28706
28707
|
base = JSON.parse((input.readFile ?? ((path) => readFileSync(path, "utf8")))(resolve(input.dir, input.manifest)));
|
|
@@ -28717,11 +28718,14 @@ async function runGithubAppCreate(input) {
|
|
|
28717
28718
|
} catch (err) {
|
|
28718
28719
|
return refuse("manifest", errorMessage(err));
|
|
28719
28720
|
}
|
|
28720
|
-
|
|
28721
|
-
|
|
28722
|
-
|
|
28723
|
-
|
|
28724
|
-
|
|
28721
|
+
let file = "";
|
|
28722
|
+
if (!collect) {
|
|
28723
|
+
const target = resolveCredentialsFile(input.dir, input.file, input.makeDir);
|
|
28724
|
+
file = target.path;
|
|
28725
|
+
const git = (input.isIgnored ?? isGitIgnored)(file);
|
|
28726
|
+
if (git === "tracked" || git === "unknown") return refuse("not-ignored", git === "tracked" ? `refusing to write credentials to ${file}: git does not ignore it, so it could be committed` : `refusing to write credentials to ${file}: git could not say whether it ignores it`, ignoreAdvice(target.isDefault, "choose another path with --file"));
|
|
28727
|
+
if (!input.force && (input.exists ?? existsSync)(file)) return refuse("exists", `${file} is already there and is never overwritten`, "delete it, or pass --force to replace it");
|
|
28728
|
+
}
|
|
28725
28729
|
const state = input.state ?? randomBytes(16).toString("hex");
|
|
28726
28730
|
const action = input.org ? `https://github.com/organizations/${encodeURIComponent(input.org)}/settings/apps/new?state=${state}` : `https://github.com/settings/apps/new?state=${state}`;
|
|
28727
28731
|
const server = await (input.serve ?? serveAppManifest)({
|
|
@@ -28744,12 +28748,54 @@ async function runGithubAppCreate(input) {
|
|
|
28744
28748
|
server.close();
|
|
28745
28749
|
}
|
|
28746
28750
|
const settings = input.org ? `https://github.com/organizations/${input.org}/settings/apps/${app.slug}/advanced` : `https://github.com/settings/apps/${app.slug}/advanced`;
|
|
28751
|
+
const webhookSecretVar = input.webhookSecretVar || DEFAULT_WEBHOOK_SECRET_VAR;
|
|
28752
|
+
if (collect) {
|
|
28753
|
+
try {
|
|
28754
|
+
collect([
|
|
28755
|
+
{
|
|
28756
|
+
name: "SENTINEL_GITHUB_APP_ID",
|
|
28757
|
+
value: String(app.id)
|
|
28758
|
+
},
|
|
28759
|
+
{
|
|
28760
|
+
name: "SENTINEL_GITHUB_APP_PRIVATE_KEY",
|
|
28761
|
+
value: app.pem
|
|
28762
|
+
},
|
|
28763
|
+
{
|
|
28764
|
+
name: webhookSecretVar,
|
|
28765
|
+
value: app.webhookSecret
|
|
28766
|
+
}
|
|
28767
|
+
]);
|
|
28768
|
+
} catch (err) {
|
|
28769
|
+
logger.warn({
|
|
28770
|
+
status: "fail",
|
|
28771
|
+
reason: "collect",
|
|
28772
|
+
slug: app.slug
|
|
28773
|
+
}, COMMAND$2);
|
|
28774
|
+
for (const line of [`created ${app.slug}, but its credentials were not kept: ${errorMessage(err)}`, `they are shown once: delete the App (${settings}) and run this again`]) print(line);
|
|
28775
|
+
return {
|
|
28776
|
+
status: "fail",
|
|
28777
|
+
slug: app.slug,
|
|
28778
|
+
appId: app.id
|
|
28779
|
+
};
|
|
28780
|
+
}
|
|
28781
|
+
print(`created ${app.slug} (App id ${app.id}): ${app.htmlUrl}`);
|
|
28782
|
+
print(`install it on the repositories it should see: https://github.com/apps/${app.slug}/installations/new`);
|
|
28783
|
+
logger.info({
|
|
28784
|
+
status: "ok",
|
|
28785
|
+
slug: app.slug
|
|
28786
|
+
}, COMMAND$2);
|
|
28787
|
+
return {
|
|
28788
|
+
status: "ok",
|
|
28789
|
+
slug: app.slug,
|
|
28790
|
+
appId: app.id
|
|
28791
|
+
};
|
|
28792
|
+
}
|
|
28747
28793
|
let identity;
|
|
28748
28794
|
try {
|
|
28749
28795
|
const lines = [
|
|
28750
28796
|
dotenvLine("SENTINEL_GITHUB_APP_ID", String(app.id)),
|
|
28751
28797
|
dotenvLine("SENTINEL_GITHUB_APP_PRIVATE_KEY", app.pem),
|
|
28752
|
-
dotenvLine(
|
|
28798
|
+
dotenvLine(webhookSecretVar, app.webhookSecret)
|
|
28753
28799
|
];
|
|
28754
28800
|
if (lines.includes(null)) throw new Error("a value cannot be written as a dotenv line");
|
|
28755
28801
|
identity = (input.writeFile ?? writeCredentialsFile)(file, `${lines.join("\n")}\n`, input.force === true);
|