|
- import {spawn} from './utils/process';
- import {mkdirp} from './utils/fs';
-
- export enum RepoVisibility {
- PRIVATE,
- INTERNAL,
- PUBLIC,
- }
-
- export enum OwnerType {
- USER,
- ORG,
- }
-
- type Owner = {
- name: string,
- type: OwnerType,
- }
-
- type CreateOptions = {
- name: string,
- owner: Owner,
- visibility: RepoVisibility,
- }
-
- const OWNER_TYPE_DIR_NAMES: Record<OwnerType, string> = {
- [OwnerType.USER]: 'users',
- [OwnerType.ORG]: 'orgs',
- }
-
- export const create = async (options: CreateOptions) => {
- const repoBasePath = `${OWNER_TYPE_DIR_NAMES[options.owner.type]}/${options.owner.name}/${options.name}`;
- await mkdirp(repoBasePath);
- return spawn(repoBasePath, 'git', ['init', '--bare']);
- }
|