Skip to content

Commit

Permalink
Merge pull request #227 from jaredwray/github-data-in-build
Browse files Browse the repository at this point in the history
github data in build
  • Loading branch information
jaredwray committed Jan 3, 2024
2 parents ada004b + b28a56c commit d5a9310
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Ecto} from 'ecto';
import {WritrOptions} from './options.js';
import {type GithubData} from './github.js';
import {type GithubData, Github, type GithubOptions} from './github.js';

export type WritrData = {
github: GithubData;
Expand All @@ -23,8 +23,8 @@ export class WritrBuilder {
// Validate the options
this.validateOptions(this.options);
// Get data from github

// get data of the site
const githubData = await this.getGithubData(this.options.githubPath);
// Get data of the site

// get the templates to use

Expand Down Expand Up @@ -57,4 +57,14 @@ export class WritrBuilder {
throw new Error('No site url options provided');
}
}

public async getGithubData(githubPath: string): Promise<GithubData> {
const paths = githubPath.split('/');
const options: GithubOptions = {
author: paths[0],
repo: paths[1],
};
const github = new Github(options);
return github.getData();
}
}
2 changes: 1 addition & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';

export type GithubOptions = {
api: string | undefined;
api?: string | undefined;
author: string;
repo: string;
};
Expand Down
5 changes: 5 additions & 0 deletions test/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ describe('WritrBuilder', () => {
expect(error.message).toBe('No site url options provided');
}
});
it('should get github data', async () => {
const builder = new WritrBuilder();
const githubData = await builder.getGithubData('jaredwray/writr');
expect(githubData).toBeTruthy();
});
});

0 comments on commit d5a9310

Please sign in to comment.