7495b957b133c48af75223a24c957a6af93dacc6 — Martin Angers 4 months ago 1fbbe8b
refactor kinds into constants
5 files changed, 26 insertions(+), 23 deletions(-)

M src/cmds/league_cmds/new.js
M src/constants.js
D src/kinds.js
M src/scripts/extract_cities.js
M src/team_names.js
M src/cmds/league_cmds/new.js => src/cmds/league_cmds/new.js +1 -2
@@ 1,7 1,6 @@
 import CFonts from 'cfonts'
 import inquirer from 'inquirer'
-import { TeamName } from '../../kinds'
-import { Constants } from '../../constants'
+import { Constants, TeamName } from '../../constants'
 import { teamsByKind, randomTeam } from '../../team_names'
 
 export const command = 'new'

M src/constants.js => src/constants.js +23 -0
@@ 2,6 2,29 @@
   teamsPerLeague: 12,
 })
 
+const PlayerName = Object.freeze ({
+  fullName: 0,
+  firstName: 1,
+  lastName: 2,
+  nhlPlayer: 3,
+})
+
+const TeamName = Object.freeze ({
+  currentNHL: 0,
+  legacyNHL: 1,
+  currentCHL: 2,
+  cityName: 3,
+  teamName: 4,
+})
+
+const LeagueState = Object.freeze ({
+  active: 0,
+  archived: 1,
+})
+
 export {
   Constants,
+  PlayerName,
+  TeamName,
+  LeagueState,
 }

D src/kinds.js => src/kinds.js +0 -19
@@ 1,19 0,0 @@
-const PlayerName = Object.freeze ({
-  fullName: 0,
-  firstName: 1,
-  lastName: 2,
-  nhlPlayer: 3,
-})
-
-const TeamName = Object.freeze ({
-  currentNHL: 0,
-  legacyNHL: 1,
-  currentCHL: 2,
-  cityName: 3,
-  teamName: 4,
-})
-
-export {
-  PlayerName,
-  TeamName,
-}

M src/scripts/extract_cities.js => src/scripts/extract_cities.js +1 -1
@@ 1,7 1,7 @@
 import { DB } from 'mymigrate'
 import bent from 'bent'
 import cheerio from 'cheerio'
-import { TeamName } from '../kinds'
+import { TeamName } from '../constants'
 
 async function ensureCountryExists (conn, country) {
   // wtf? See https://web.archive.org/web/20140110034752/http://mikefenwick.com/blog/insert-into-database-or-return-id-of-duplicate-row-in-mysql/

M src/team_names.js => src/team_names.js +1 -1
@@ 1,5 1,5 @@
 import { DB } from 'mymigrate'
-import { TeamName } from './kinds'
+import { TeamName } from './constants'
 
 export async function teamsByKind (kind, notIn = []) {
   const conn = await new DB ().connect ()