From 0edbdea7d1b032c7842adf1d7a3c639d6c197281 Mon Sep 17 00:00:00 2001 From: ssube Date: Wed, 12 Aug 2020 00:12:57 -0500 Subject: [PATCH] feat: support multiple projects in one config --- ...ious-journey.githubremote._constructor_.md | 20 +++++++ docs/api/cautious-journey.githubremote.md | 6 +++ ...ious-journey.gitlabremote._constructor_.md | 20 +++++++ docs/api/cautious-journey.gitlabremote.md | 6 +++ src/config/index.ts | 53 ++++++++++++------- src/main.ts | 17 ++++-- 6 files changed, 97 insertions(+), 25 deletions(-) create mode 100644 docs/api/cautious-journey.githubremote._constructor_.md create mode 100644 docs/api/cautious-journey.gitlabremote._constructor_.md diff --git a/docs/api/cautious-journey.githubremote._constructor_.md b/docs/api/cautious-journey.githubremote._constructor_.md new file mode 100644 index 0000000..8445e81 --- /dev/null +++ b/docs/api/cautious-journey.githubremote._constructor_.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [cautious-journey](./cautious-journey.md) > [GithubRemote](./cautious-journey.githubremote.md) > [(constructor)](./cautious-journey.githubremote._constructor_.md) + +## GithubRemote.(constructor) + +Constructs a new instance of the `GithubRemote` class + +Signature: + +```typescript +constructor(options: RemoteOptions); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | [RemoteOptions](./cautious-journey.remoteoptions.md) | | + diff --git a/docs/api/cautious-journey.githubremote.md b/docs/api/cautious-journey.githubremote.md index fcc23c9..8952291 100644 --- a/docs/api/cautious-journey.githubremote.md +++ b/docs/api/cautious-journey.githubremote.md @@ -13,6 +13,12 @@ export declare class GithubRemote implements Remote ``` Implements: [Remote](./cautious-journey.remote.md) +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(options)](./cautious-journey.githubremote._constructor_.md) | | Constructs a new instance of the GithubRemote class | + ## Methods | Method | Modifiers | Description | diff --git a/docs/api/cautious-journey.gitlabremote._constructor_.md b/docs/api/cautious-journey.gitlabremote._constructor_.md new file mode 100644 index 0000000..fdb0275 --- /dev/null +++ b/docs/api/cautious-journey.gitlabremote._constructor_.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [cautious-journey](./cautious-journey.md) > [GitlabRemote](./cautious-journey.gitlabremote.md) > [(constructor)](./cautious-journey.gitlabremote._constructor_.md) + +## GitlabRemote.(constructor) + +Constructs a new instance of the `GitlabRemote` class + +Signature: + +```typescript +constructor(options: RemoteOptions); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | [RemoteOptions](./cautious-journey.remoteoptions.md) | | + diff --git a/docs/api/cautious-journey.gitlabremote.md b/docs/api/cautious-journey.gitlabremote.md index 97d7a53..897fb4b 100644 --- a/docs/api/cautious-journey.gitlabremote.md +++ b/docs/api/cautious-journey.gitlabremote.md @@ -13,6 +13,12 @@ export declare class GitlabRemote implements Remote ``` Implements: [Remote](./cautious-journey.remote.md) +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(options)](./cautious-journey.gitlabremote._constructor_.md) | | Constructs a new instance of the GitlabRemote class | + ## Methods | Method | Modifiers | Description | diff --git a/src/config/index.ts b/src/config/index.ts index 43526d9..1777258 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -5,25 +5,32 @@ import { RemoteOptions } from '../remote'; * Config data for the app, loaded from CLI or DOM. */ export interface ConfigData { - /** - * Color palette for labels without their own. - */ - colors: Array; + projects: Array<{ + /** + * Color palette for labels without their own. + */ + colors: Array; - /** - * Individual flag labels. - */ - flags: Array; + /** + * Individual flag labels. + */ + flags: Array; - /** - * Remote APIs. - */ - remotes: Array; + /** + * Project name or path. + */ + name: string; - /** - * Grouped state labels. - */ - states: Array; + /** + * Remote APIs. + */ + remote: RemoteOptions; + + /** + * Grouped state labels. + */ + states: Array; + }>; } /** @@ -33,9 +40,15 @@ export interface ConfigData { */ export function initConfig(): ConfigData { return { - colors: [], - flags: [], - remotes: [], - states: [], + projects: [{ + colors: [], + flags: [], + name: '', + remote: { + data: {}, + type: '', + }, + states: [], + }], }; } diff --git a/src/main.ts b/src/main.ts index 6cd691f..c30f5c9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import { InvalidArgumentError } from '@apextoaster/js-utils'; +import { ConfigData } from './config'; import { Commands, createParser } from './config/args'; import { GithubRemote } from './remote/github'; import { syncIssues, syncLabels, SyncOptions } from './sync'; @@ -21,11 +22,17 @@ export async function main(argv: Array): Promise { const args = parser.parse(argv.slice(SLICE_ARGS)); // load config - const config = { - colors: [], - flags: [], - remotes: [], - states: [], + const config: ConfigData = { + projects: [{ + colors: [], + flags: [], + name: '', + remote: { + data: {}, + type: '', + }, + states: [], + }], }; /* eslint-disable-next-line no-console */