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

Allow generator registrations to specify a starting point #425

Merged
merged 19 commits into from
Jul 2, 2018

Conversation

johnsonr
Copy link
Contributor

@johnsonr johnsonr commented Jul 2, 2018

Builds on #424 - please review after that

Allow GeneratorRegistration to include a startingPoint, which can be a project or a seed repo. This is an alternative to using the source on the parameters object.

This clarifies how generators work - starting point + transformation - and allows the starting point to be created in memory if desired.

In future, generators will probably be expressed directly this way rather than in function wrappers as in the Spring pack. (They can use the functions provided in such packs for their transformation.)

Examples:

sdm.addGeneratorCommand<SeedDrivenGeneratorParameters & { path: string }>({
        name: "foo",
        intent: "create thing",
        startingPoint: InMemoryProject.of(
            new InMemoryFile("README.md", "some content")),
        parameters: {
            path: {},
        },
        transform: async (p, ctx, params) => {
            return p.addFile(params.path, "1");
        },
    });

and:

sdm.addGeneratorCommand<SeedDrivenGeneratorParameters & { path: string }>({
        name: "foo",
        intent: "create thing2",
        startingPoint: GitHubRepoRef.from({owner: "spring-team", repo: "spring-rest-seed"}),
        parameters: {
            path: {},
        },
        transform: async (p, ctx, params) => {
            return p.addFile(params.path, "1");
        },
    });

Backward compatible.

@johnsonr johnsonr changed the title Remove TODO Allow generator registrations to specify a starting point Jul 2, 2018
@johnsonr johnsonr requested a review from jessitron July 2, 2018 02:50
@cdupuis cdupuis added the changelog:added Add this issue or pull request to added changelog section label Jul 2, 2018
@cdupuis cdupuis merged commit ad178cb into master Jul 2, 2018
@cdupuis cdupuis deleted the gen-starting-point branch July 2, 2018 21:41
atomist-bot added a commit that referenced this pull request Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:added Add this issue or pull request to added changelog section
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants