1
0
Fork 0

feat(sync): use config labels per project

This commit is contained in:
ssube 2020-08-12 19:33:53 -05:00 committed by Sean Sube
parent 28c9ee8865
commit 41be935a2f
6 changed files with 26 additions and 9 deletions

View File

@ -1,11 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [cautious-journey](./cautious-journey.md) &gt; [SyncOptions](./cautious-journey.syncoptions.md) &gt; [config](./cautious-journey.syncoptions.config.md)
[Home](./index.md) &gt; [cautious-journey](./cautious-journey.md) &gt; [SyncOptions](./cautious-journey.syncoptions.md) &gt; [flags](./cautious-journey.syncoptions.flags.md)
## SyncOptions.config property
## SyncOptions.flags property
<b>Signature:</b>
```typescript
config: ConfigData;
flags: Array<FlagLabel>;
```

View File

@ -14,7 +14,8 @@ export interface SyncOptions
| Property | Type | Description |
| --- | --- | --- |
| [config](./cautious-journey.syncoptions.config.md) | ConfigData | |
| [flags](./cautious-journey.syncoptions.flags.md) | Array&lt;[FlagLabel](./cautious-journey.flaglabel.md)<!-- -->&gt; | |
| [project](./cautious-journey.syncoptions.project.md) | string | |
| [remote](./cautious-journey.syncoptions.remote.md) | [Remote](./cautious-journey.remote.md) | |
| [states](./cautious-journey.syncoptions.states.md) | Array&lt;[StateLabel](./cautious-journey.statelabel.md)<!-- -->&gt; | |

View File

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [cautious-journey](./cautious-journey.md) &gt; [SyncOptions](./cautious-journey.syncoptions.md) &gt; [states](./cautious-journey.syncoptions.states.md)
## SyncOptions.states property
<b>Signature:</b>
```typescript
states: Array<StateLabel>;
```

View File

@ -68,6 +68,10 @@ export interface StateLabel extends BaseLabel, LabelSet {
values: Array<StateValue>;
}
/**
* Calculate the set of unique names for a list of flags and a list of states, with all state values
* qualified and included.
*/
export function getLabelNames(flags: Array<FlagLabel>, states: Array<StateLabel>): Set<string> {
const labels = [];

View File

@ -62,9 +62,10 @@ export async function main(argv: Array<string>): Promise<number> {
// mode switch
const options: SyncOptions = {
config,
flags: project.flags,
project: project.name,
remote,
states: project.states,
};
switch (mode) {
case Commands.ISSUES:

View File

@ -1,14 +1,14 @@
import { ConfigData } from './config';
import { getLabelNames } from './labels';
import { FlagLabel, getLabelNames, StateLabel } from './labels';
import { Remote } from './remote';
// TODO: turn this back on/remove the disable pragma
/* eslint-disable no-console */
export interface SyncOptions {
config: ConfigData;
flags: Array<FlagLabel>;
project: string;
remote: Remote;
states: Array<StateLabel>;
}
export async function syncIssues(options: SyncOptions): Promise<unknown> {
@ -29,7 +29,7 @@ export async function syncLabels(options: SyncOptions): Promise<unknown> {
});
const existingLabels = new Set(labels.map((l) => l.name));
const expectedLabels = getLabelNames(options.config.projects[0].flags, options.config.projects[0].states);
const expectedLabels = getLabelNames(options.flags, options.states);
for (const label of labels) {
const exists = existingLabels.has(label.name);