Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature: Make "locator" Options required: owner and repository #70

Closed
2 tasks done
JoshuaKGoldberg opened this issue Dec 19, 2024 · 1 comment
Closed
2 tasks done
Assignees
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: feature New enhancement or request
Milestone

Comments

@JoshuaKGoldberg
Copy link
Owner

Bug Report Checklist

Overview

Creating a new repository on GitHub requires a "locator" consisting of:

  1. Owner: e.g. "JoshuaKGoldberg"
  2. Repository: e.g. "create"

Right now there is have some hardcoded logic to create a new repository in runPreset:

if (settings.mode === "initialize") {
// TODO: Hardcode owner and repository existing in options?
await createRepositoryOnGitHub(
options as unknown as CreationOptions,
system.runner,
preset.base.template,
);
}

if (settings.mode === "initialize") {
await createTrackingBranches(
options as unknown as CreationOptions,
system.runner,
);
}

That logic assumes owner and repository must exist on the Preset's Base's Options. Which, given that all Presets target GitHub repositories right now, is actually a fair assumption. And baking these in as automatically included, non-overridable Options would be a nice bit of work reduction for implementers.

Additional Info

In some far-off distant future, this engine will likely support repository creation targets other than GitHub. This will need to be revisited then. But for now, since create-typescript-app is the main feature goal and CTA only supports GitHub, this is fine.

💖

@JoshuaKGoldberg JoshuaKGoldberg added type: feature New enhancement or request status: accepting prs Please, send a pull request to resolve this! 🙏 labels Dec 19, 2024
@JoshuaKGoldberg JoshuaKGoldberg added this to the Ready to Launch milestone Dec 19, 2024
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Dec 19, 2024
@JoshuaKGoldberg
Copy link
Owner Author

I explored this in #72. It's really hacky to make them requested altogether, because otherwise Options are allowed to be any Record<string, ...> including default/optional types.

The compromise I went with is requiring the options exist when used to initialize:

for (const key of ["owner", "repository"]) {
if (typeof (options as Record<string, unknown>)[key] !== "string") {
throw new Error(
`To run with --mode initialize, the Template must have a --${key} Option of type string.`,
);
}

I haven't yet fleshed out migration mode. When that happens I might revisit this. But until then, declining.

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: feature New enhancement or request
Projects
None yet
Development

No branches or pull requests

1 participant