Skip to content

Commit

Permalink
Revert "refactor: remove .js ext from ALL local imports across the co…
Browse files Browse the repository at this point in the history
…debase (#361)" (#363)

This reverts commit db3b348.
  • Loading branch information
enapupe committed Nov 13, 2023
1 parent db3b348 commit 2e9f04c
Show file tree
Hide file tree
Showing 115 changed files with 400 additions and 416 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,25 @@ on:
push:
branches:
- develop
- test
pull_request:

jobs:
build:
runs-on: 'ubuntu-latest'


steps:
- name: 'Checkout Project'
uses: 'actions/checkout@v4'

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16.15'
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable
- name: 'Checkout Project'
uses: 'actions/checkout@v3'
with:
fetch-depth: 1

- name: Lint code
run: yarn lint
- name: Install Dependencies and lint code
run: yarn install && yarn lint

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.8.0
Expand All @@ -48,8 +44,8 @@ jobs:
run: |
docker container restart mongodb
- name: Run tests
run: yarn test --ci
- name: Build and run tests
run: yarn test
env:
NODE_OPTIONS: --experimental-vm-modules

- name: Build files/check types
run: yarn build-release --noEmit
8 changes: 2 additions & 6 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', './build/'],
testMatch: [
'<rootDir>/**/__tests__/*.ts'
'<rootDir>/build/**/__tests__/*.js'
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"scripts": {
"lint": "yarn ts-standard",
"fix": "yarn ts-standard --fix",
"test": "jest --runInBand",
"test": "yarn build && cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --runInBand",
"build": "tsc -p tsconfig.json",
"build-release": "tsc -p tsconfig.release.json",
"clean": "tsc -b --clean && rm -rf build/*",
Expand Down
2 changes: 1 addition & 1 deletion src/GradeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getScale, GradeScales, GradeScalesTypes } from '@openbeta/sandbag'
import isoCountries from 'i18n-iso-countries'
import { DisciplineType, ClimbGradeContextType } from './db/ClimbTypes'
import { DisciplineType, ClimbGradeContextType } from './db/ClimbTypes.js'

/**
* Grade systems have minor variations between countries. gradeContext is a
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/areas.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ApolloServer } from 'apollo-server'
import muuid from 'uuid-mongodb'
import { jest } from '@jest/globals'
import MutableAreaDataSource from '../model/MutableAreaDataSource'
import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource'
import { AreaType } from '../db/AreaTypes'
import { OrgType, OrganizationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes'
import { queryAPI, setUpServer } from '../utils/testUtils'
import { muuidToString } from '../utils/helpers'
import MutableAreaDataSource from '../model/MutableAreaDataSource.js'
import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource.js'
import { AreaType } from '../db/AreaTypes.js'
import { OrgType, OrganizationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes.js'
import { queryAPI, setUpServer } from '../utils/testUtils.js'
import { muuidToString } from '../utils/helpers.js'

jest.setTimeout(60000)

Expand Down
12 changes: 2 additions & 10 deletions src/__tests__/gradeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { DisciplineType } from '../db/ClimbTypes'
import { sanitizeDisciplines, createGradeObject, gradeContextToGradeScales } from '../GradeUtils'

beforeAll(() => {
console.warn = jest.fn()
})

afterAll(() => {
jest.mocked(console.warn).mockReset()
})
import { DisciplineType } from '../db/ClimbTypes.js'
import { sanitizeDisciplines, createGradeObject, gradeContextToGradeScales } from '../GradeUtils.js'

describe('Test grade utilities', () => {
it('sanitizes bad discipline object', () => {
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/history.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ApolloServer } from 'apollo-server'
import muuid from 'uuid-mongodb'
import { jest } from '@jest/globals'
import MutableAreaDataSource from '../model/MutableAreaDataSource'
import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource'
import MutableClimbDataSource from '../model/MutableClimbDataSource'
import { AreaType } from '../db/AreaTypes'
import { OrgType, OrganizationType } from '../db/OrganizationTypes'
import { muuidToString } from '../utils/helpers'
import { queryAPI, setUpServer } from '../utils/testUtils'
import MutableAreaDataSource from '../model/MutableAreaDataSource.js'
import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource.js'
import MutableClimbDataSource from '../model/MutableClimbDataSource.js'
import { AreaType } from '../db/AreaTypes.js'
import { OrgType, OrganizationType } from '../db/OrganizationTypes.js'
import { muuidToString } from '../utils/helpers.js'
import { queryAPI, setUpServer } from '../utils/testUtils.js'

jest.setTimeout(60000)

Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/organizations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ApolloServer } from 'apollo-server'
import muuid from 'uuid-mongodb'
import { jest } from '@jest/globals'
import MutableAreaDataSource from '../model/MutableAreaDataSource'
import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource'
import { AreaType } from '../db/AreaTypes'
import { OrgType, OrganizationType, OperationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes'
import { changelogDataSource } from '../model/ChangeLogDataSource'
import { queryAPI, setUpServer } from '../utils/testUtils'
import { muuidToString } from '../utils/helpers'
import MutableAreaDataSource from '../model/MutableAreaDataSource.js'
import MutableOrganizationDataSource from '../model/MutableOrganizationDataSource.js'
import { AreaType } from '../db/AreaTypes.js'
import { OrgType, OrganizationType, OperationType, OrganizationEditableFieldsType } from '../db/OrganizationTypes.js'
import { changelogDataSource } from '../model/ChangeLogDataSource.js'
import { queryAPI, setUpServer } from '../utils/testUtils.js'
import { muuidToString } from '../utils/helpers.js'
import { validate as validateMuuid } from 'uuid'

jest.setTimeout(60000)
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/ticks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ApolloServer } from 'apollo-server'
import muuid from 'uuid-mongodb'
import { jest } from '@jest/globals'
import { queryAPI, setUpServer } from '../utils/testUtils'
import { muuidToString } from '../utils/helpers'
import { TickInput } from '../db/TickTypes'
import TickDataSource from '../model/TickDataSource'
import UserDataSource from '../model/UserDataSource'
import { UpdateProfileGQLInput } from '../db/UserTypes'
import { queryAPI, setUpServer } from '../utils/testUtils.js'
import { muuidToString } from '../utils/helpers.js'
import { TickInput } from '../db/TickTypes.js'
import TickDataSource from '../model/TickDataSource.js'
import UserDataSource from '../model/UserDataSource.js'
import { UpdateProfileGQLInput } from '../db/UserTypes.js'

jest.setTimeout(60000)

Expand Down
4 changes: 2 additions & 2 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import permissions from './permissions'
import { createContext } from './middleware'
import permissions from './permissions.js'
import { createContext } from './middleware.js'
export { permissions, createContext }
6 changes: 3 additions & 3 deletions src/auth/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import muid from 'uuid-mongodb'
import { AuthUserType } from '../types'
import { verifyJWT } from './util'
import { logger } from '../logger'
import { AuthUserType } from '../types.js'
import { verifyJWT } from './util.js'
import { logger } from '../logger.js'

/**
* Create a middleware context for Apollo server
Expand Down
2 changes: 1 addition & 1 deletion src/auth/permissions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { shield, allow, and, or } from 'graphql-shield'
import { isEditor, isUserAdmin, isOwner, isValidEmail, isMediaOwner } from './rules'
import { isEditor, isUserAdmin, isOwner, isValidEmail, isMediaOwner } from './rules.js'

const permissions = shield({
Query: {
Expand Down
4 changes: 2 additions & 2 deletions src/auth/rules.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { rule, inputRule } from 'graphql-shield'

import MediaDataSource from '../model/MutableMediaDataSource'
import { MediaObjectGQLInput } from '../db/MediaObjectTypes'
import MediaDataSource from '../model/MutableMediaDataSource.js'
import { MediaObjectGQLInput } from '../db/MediaObjectTypes.js'

export const isEditor = rule()(async (parent, args, ctx, info) => {
return _hasUserUuid(ctx) && ctx.user.roles.includes('editor')
Expand Down
2 changes: 1 addition & 1 deletion src/auth/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jwksClient from 'jwks-rsa'
import jwt from 'jsonwebtoken'

import { checkVar } from '../db/index'
import { checkVar } from '../db/index.js'

const auth0Domain = checkVar('AUTH0_DOMAIN')
const auth0Kid = checkVar('AUTH0_KID')
Expand Down
8 changes: 4 additions & 4 deletions src/db/AreaSchema.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import mongoose from 'mongoose'
import muuid from 'uuid-mongodb'

import { AreaType, IAreaContent, IAreaMetadata, AggregateType, CountByGroupType, CountByDisciplineType, CountByGradeBandType, DisciplineStatsType, OperationType } from './AreaTypes'
import { PointSchema } from './ClimbSchema'
import { ChangeRecordMetadataType } from './ChangeLogType'
import { GradeContexts } from '../GradeUtils'
import { AreaType, IAreaContent, IAreaMetadata, AggregateType, CountByGroupType, CountByDisciplineType, CountByGradeBandType, DisciplineStatsType, OperationType } from './AreaTypes.js'
import { PointSchema } from './ClimbSchema.js'
import { ChangeRecordMetadataType } from './ChangeLogType.js'
import { GradeContexts } from '../GradeUtils.js'

const { Schema, connection } = mongoose

Expand Down
10 changes: 5 additions & 5 deletions src/db/AreaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import mongoose from 'mongoose'
import { MUUID } from 'uuid-mongodb'

import { BBox, Point } from '@turf/helpers'
import { ClimbType } from './ClimbTypes'
import { ChangeRecordMetadataType } from './ChangeLogType'
import { GradeContexts } from '../GradeUtils'
import { ExperimentalAuthorType } from './UserTypes'
import { AuthorMetadata } from '../types'
import { ClimbType } from './ClimbTypes.js'
import { ChangeRecordMetadataType } from './ChangeLogType.js'
import { GradeContexts } from '../GradeUtils.js'
import { ExperimentalAuthorType } from './UserTypes.js'
import { AuthorMetadata } from '../types.js'

/**
* Areas are a grouping mechanism in the OpenBeta data model that allow
Expand Down
4 changes: 2 additions & 2 deletions src/db/ChangeLogSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose'

import { ChangeLogType, SupportedCollectionTypes } from './ChangeLogType'
import { OperationType } from './AreaTypes'
import { ChangeLogType, SupportedCollectionTypes } from './ChangeLogType.js'
import { OperationType } from './AreaTypes.js'

const { Schema, connection } = mongoose

Expand Down
6 changes: 3 additions & 3 deletions src/db/ChangeLogType.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mongose from 'mongoose'
import { MUUID } from 'uuid-mongodb'

import { OperationType as AreaOpType, AreaType } from './AreaTypes'
import { ClimbEditOperationType, ClimbType } from './ClimbTypes'
import { OperationType as OrganizationOpType, OrganizationType } from './OrganizationTypes'
import { OperationType as AreaOpType, AreaType } from './AreaTypes.js'
import { ClimbEditOperationType, ClimbType } from './ClimbTypes.js'
import { OperationType as OrganizationOpType, OrganizationType } from './OrganizationTypes.js'

export type DBOperation = 'insert' | 'update' | 'delete'
export enum DocumentKind {
Expand Down
8 changes: 4 additions & 4 deletions src/db/ClimbHistorySchema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mongoose from 'mongoose'
import muuid from 'uuid-mongodb'
import { ClimbSchema } from './ClimbSchema'
import { AreaSchema } from './AreaSchema'
import ClimbHistoryType, { AreaHistoryType } from './ClimbHistoryType'
import ChangeEventType from './ChangeEventType'
import { ClimbSchema } from './ClimbSchema.js'
import { AreaSchema } from './AreaSchema.js'
import ClimbHistoryType, { AreaHistoryType } from './ClimbHistoryType.js'
import ChangeEventType from './ChangeEventType.js'
import { ClimbType } from './ClimbTypes'
import { AreaType } from './AreaTypes'

Expand Down
6 changes: 3 additions & 3 deletions src/db/ClimbSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import muuid from 'uuid-mongodb'
import { Point } from '@turf/helpers'
import { GradeScalesTypes } from '@openbeta/sandbag'

import { ClimbType, IClimbMetadata, IClimbContent, SafetyType, ClimbEditOperationType } from './ClimbTypes'
import { GradeContexts } from '../GradeUtils'
import { ChangeRecordMetadataType } from './ChangeLogType'
import { ClimbType, IClimbMetadata, IClimbContent, SafetyType, ClimbEditOperationType } from './ClimbTypes.js'
import { GradeContexts } from '../GradeUtils.js'
import { ChangeRecordMetadataType } from './ChangeLogType.js'

const { Schema } = mongoose

Expand Down
4 changes: 2 additions & 2 deletions src/db/ClimbTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Point } from '@turf/helpers'
import { GradeScalesTypes } from '@openbeta/sandbag'

import { ChangeRecordMetadataType } from './ChangeLogType'
import { GradeContexts } from '../GradeUtils'
import { AreaType } from './AreaTypes'
import { GradeContexts } from '../GradeUtils.js'
import { AreaType } from './AreaTypes.js'

// For search climb by id queries
// Additional fields allow client to build breadcrumbs
Expand Down
4 changes: 2 additions & 2 deletions src/db/MediaObjectSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose'

import { MediaObject, EntityTag } from './MediaObjectTypes'
import { PointSchema } from './ClimbSchema'
import { MediaObject, EntityTag } from './MediaObjectTypes.js'
import { PointSchema } from './ClimbSchema.js'

const { Schema } = mongoose

Expand Down
4 changes: 2 additions & 2 deletions src/db/OrganizationSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import mongoose from 'mongoose'
import muuid from 'uuid-mongodb'

import { OrganizationType, OrgType, IOrganizationContent, OperationType } from './OrganizationTypes'
import { ChangeRecordMetadataType } from './ChangeLogType'
import { OrganizationType, OrgType, IOrganizationContent, OperationType } from './OrganizationTypes.js'
import { ChangeRecordMetadataType } from './ChangeLogType.js'

const { Schema, connection } = mongoose

Expand Down
2 changes: 1 addition & 1 deletion src/db/OrganizationTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose'
import { MUUID } from 'uuid-mongodb'

import { ChangeRecordMetadataType } from './ChangeLogType'
import { ChangeRecordMetadataType } from './ChangeLogType.js'

/**
* Organizations are OpenBeta accounts that are owned by organizations
Expand Down
4 changes: 2 additions & 2 deletions src/db/PostSchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import mongoose from 'mongoose'
import mongooseLeanVirtuals from 'mongoose-lean-virtuals'
import muuid from 'uuid-mongodb'
import { PostType } from './PostTypes'
import { XMediaSchema } from './XMediaSchema'
import { PostType } from './PostTypes.js'
import { XMediaSchema } from './XMediaSchema.js'

const { Schema } = mongoose

Expand Down
2 changes: 1 addition & 1 deletion src/db/TagSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mongoose from 'mongoose'
import mongooseLeanVirtuals from 'mongoose-lean-virtuals'
import muuid from 'uuid-mongodb'

import { TagType, RefModelType } from './TagTypes'
import { TagType, RefModelType } from './TagTypes.js'

const { Schema } = mongoose

Expand Down
2 changes: 1 addition & 1 deletion src/db/UserSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose'
import muuid from 'uuid-mongodb'

import { ExperimentalUserType, User, UsernameInfo } from './UserTypes'
import { ExperimentalUserType, User, UsernameInfo } from './UserTypes.js'

const { Schema } = mongoose

Expand Down
2 changes: 1 addition & 1 deletion src/db/UserTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MUUID } from 'uuid-mongodb'
import { UserMedia } from './MediaObjectTypes'
import { UserMedia } from './MediaObjectTypes.js'
export interface ExperimentalUserType {
_id: MUUID
displayName: string
Expand Down
2 changes: 1 addition & 1 deletion src/db/XMediaSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mongoose from 'mongoose'
import mongooseLeanVirtuals from 'mongoose-lean-virtuals'
import muuid from 'uuid-mongodb'

import { XMediaType } from './XMediaTypes'
import { XMediaType } from './XMediaTypes.js'

const { Schema } = mongoose

Expand Down
Loading

0 comments on commit 2e9f04c

Please sign in to comment.