Skip to content

Commit

Permalink
Merge pull request #87 from Fgerthoffert/develop
Browse files Browse the repository at this point in the history
Removed unneeded environment variable
  • Loading branch information
Fgerthoffert authored Feb 23, 2020
2 parents 826dbb1 + 3f1a10d commit 7fa095e
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 419 deletions.
21 changes: 3 additions & 18 deletions cli/src/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Command, { flags } from '@oclif/command';
import Command from '@oclif/command';
import * as fs from 'fs';
import * as fse from 'fs-extra';
import * as jsYaml from 'js-yaml';
Expand All @@ -7,16 +7,7 @@ import * as path from 'path';

import { IConfig } from './global';

export default abstract class Base extends Command {
static flags = {
env_user_config: flags.string({
required: false,
env: 'USER_CONFIG',
description:
'User Configuration passed as an environment variable, takes precedence over config file',
}),
};

export default abstract class extends Command {
userConfig = {
jira: {
username: 'username',
Expand Down Expand Up @@ -72,9 +63,6 @@ export default abstract class Base extends Command {
}

async init() {
const { flags } = this.parse(Base);
const { env_user_config } = flags;

if (process.env.CONFIG_DIR !== undefined) {
this.config.configDir = process.env.CONFIG_DIR;
}
Expand All @@ -83,10 +71,7 @@ export default abstract class Base extends Command {
fse.ensureDirSync(this.config.configDir + '/cache/');

// eslint-disable-next-line no-negated-condition
if (env_user_config !== undefined) {
this.setUserConfig(JSON.parse(env_user_config));
// eslint-disable-next-line no-negated-condition
} else if (!fs.existsSync(path.join(this.config.configDir, 'config.yml'))) {
if (!fs.existsSync(path.join(this.config.configDir, 'config.yml'))) {
fs.writeFileSync(
path.join(this.config.configDir, 'config.yml'),
jsYaml.safeDump(this.userConfig),
Expand Down
1 change: 0 additions & 1 deletion cli/src/commands/initiatives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export default class Roadmap extends Command {
cli.action.start('Forecasting future completion');
const emptyRoadmap = getEmptyRoadmap(
emptyCalendar[emptyCalendar.length - 1],
// tslint:disable-next-line: strict-type-predicates
userConfig.roadmap.forecastWeeks === undefined
? 26
: userConfig.roadmap.forecastWeeks,
Expand Down
12 changes: 9 additions & 3 deletions cli/src/utils/initiatives/getEmptyRoadmap.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@

import { getWeek, getYear, startOfWeek, endOfWeek, formatISO } from 'date-fns';
import { formatDate } from '../misc/dateUtils';

const getEmptyRoadmap = (lastCalendarWeek: any, futureWeeks: number) => {
// Sort the array by closedAt
const emptyWeeks: any = [];
let cptDays = 0;
const currentDate = formatDate(lastCalendarWeek.weekStart);
// We need to verify if the previous week is actually complete,
// if yes, we need to set the first date as the first day of of the current week.
const currentStartWeek = formatISO(startOfWeek(new Date()), {
representation: 'date',
});
const currentDate =
currentStartWeek === lastCalendarWeek.weekStart
? new Date(lastCalendarWeek.weekStart)
: startOfWeek(new Date());
while (cptDays < futureWeeks * 7) {
const weekEnd = formatISO(endOfWeek(currentDate), {
representation: 'date',
Expand Down
Loading

0 comments on commit 7fa095e

Please sign in to comment.