Skip to content

Commit

Permalink
Change src imports to relative (redwoodjs#3082)
Browse files Browse the repository at this point in the history
* change src imports to relative

* replace ttsc with tsc

* remove ttypescript

* Remove babel module resolver plugin for framework

* Remove all references to src/lib/test

* Add tests to ignore path for codeql

* Also ignore paths for push

* Remove module mapping from tsconfigs

* Try specified codeql paths with config file

* Remove path from jsconfig too

Co-authored-by: Daniel Choudhury <[email protected]>
  • Loading branch information
jtoar and dac09 authored Jul 22, 2021
1 parent 1fce07b commit f359de4
Show file tree
Hide file tree
Showing 121 changed files with 210 additions and 307 deletions.
7 changes: 7 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
paths:
- packages
paths-ignore:
- '**/*.test.js'
- '**/*.test.ts'
- '**/*/__tests__/*'
- '**/*.md'
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
Expand Down
8 changes: 0 additions & 8 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ module.exports = {
'@babel/typescript',
],
plugins: [
[
'babel-plugin-module-resolver',
{
alias: {
src: './src',
},
},
],
/**
* NOTE
* Experimental decorators are used in `@redwoodjs/structure`.
Expand Down
3 changes: 0 additions & 3 deletions packages/api-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"outDir": "dist",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["src", "ambient.d.ts"],
"references": [{ "path": "../internal" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"build": "yarn build:js && yarn build:types",
"prepublishOnly": "yarn cross-env NODE_ENV=production yarn build",
"build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"",
"build:types": "ttsc --build --verbose",
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
"test": "jest",
"test:watch": "yarn test --watch"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/auth/decoders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'
import type { GlobalContext } from '../../globalContext'

import { auth0 } from './auth0'
import { azureActiveDirectory } from './azureActiveDirectory'
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'
import type { GlobalContext } from '../globalContext'

import { decodeToken } from './decoders'

Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/functions/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import depthLimit from 'graphql-depth-limit'
import { BaseLogger } from 'pino'
import { v4 as uuidv4 } from 'uuid'

import type { AuthContextPayload } from 'src/auth'
import { getAuthenticationContext } from 'src/auth'
import type { AuthContextPayload } from '../auth'
import { getAuthenticationContext } from '../auth'
import {
GlobalContext,
setContext,
getPerRequestContext,
usePerRequestContext,
} from 'src/globalContext'
} from '../globalContext'

export type GetCurrentUser = (
decoded: AuthContextPayload[0],
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/makeMergedSchema/makeMergedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { GraphQLSchema, GraphQLFieldMap } from 'graphql'
import merge from 'lodash.merge'
import omitBy from 'lodash.omitby'

import { Services, GraphQLTypeWithFields } from 'src/types'
import { Services, GraphQLTypeWithFields } from '../types'

import * as rootSchema from './rootSchema'

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/makeMergedSchema/rootSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
import gql from 'graphql-tag'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - not inside the <rootDir>
import apiPackageJson from 'src/../package.json'

import type { GlobalContext } from 'src/globalContext'
import apiPackageJson from '../../package.json'
import type { GlobalContext } from '../globalContext'

const { prismaVersion } = require('@prisma/client')

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/webhooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
WebhookVerificationError,
DEFAULT_WEBHOOK_SECRET,
SupportedVerifierTypes,
} from 'src/auth/verifiers'
} from '../auth/verifiers'

export {
VerifyOptions,
WebhookVerificationError,
DEFAULT_WEBHOOK_SECRET,
} from 'src/auth/verifiers'
} from '../auth/verifiers'

export const DEFAULT_WEBHOOK_SIGNATURE_HEADER = 'RW-WEBHOOK-SIGNATURE'

Expand Down
3 changes: 0 additions & 3 deletions packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"outDir": "dist",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["src/**/*", "src/../package.json"],
"references": [
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build": "yarn build:js && yarn build:types",
"prepublishOnly": "yarn cross-env NODE_ENV=production yarn build",
"build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"",
"build:types": "ttsc --build --verbose",
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
"test": "jest",
"test:watch": "yarn test --watch"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,12 @@ But it's distinct from the others in that it's the only one that has a shebang a
We also use methods that we want to affect all commands here, like `demandCommand` and `strict`.
#### src/lib/colors.js
#### lib/colors.js
[colors.js](https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/lib/colors.js) provides a declarative way of coloring output to the console using [chalk](https://github.com/chalk/chalk#styles). You'll see it imported like:
```javascript
import c from 'src/lib/colors'
import c from '../lib/colors'
```
And used mainly in catch statements, like:
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"baseUrl": ".",
"rootDir": "src",
"outDir": "dist",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["src"],
"references": [
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/commands/__tests__/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ let mockedRedwoodConfig = {
browser: {},
}

jest.mock('src/lib', () => {
jest.mock('../../lib/', () => {
return {
...jest.requireActual('src/lib'),
...jest.requireActual('../../lib/'),
runCommandTask: jest.fn((commands) => {
return commands.map(({ cmd, args }) => `${cmd} ${args?.join(' ')}`)
}),
Expand All @@ -39,8 +39,7 @@ jest.mock('@redwoodjs/prerender/detection', () => {

import execa from 'execa'

import { runCommandTask } from 'src/lib'

import { runCommandTask } from '../../lib'
import { handler } from '../build'
import { getTasks as getPrerenderTasks } from '../prerender'

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/__tests__/test.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
global.__dirname = __dirname
import 'src/lib/test'
import '../../lib/test'

jest.mock('execa', () =>
jest.fn((cmd, params) => ({
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/commands/__tests__/type-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ let mockedRedwoodConfig = {
browser: {},
}

jest.mock('src/lib', () => {
jest.mock('../../lib', () => {
return {
...jest.requireActual('src/lib'),
...jest.requireActual('../../lib'),
runCommandTask: jest.fn((commands) => {
return commands.map(({ cmd, args }) => `${cmd} ${args?.join(' ')}`)
}),
Expand All @@ -37,8 +37,7 @@ import path from 'path'

import execa from 'execa'

import { runCommandTask } from 'src/lib'

import { runCommandTask } from '../../lib'
import { handler } from '../type-check'

afterEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import terminalLink from 'terminal-link'
import { getConfig } from '@redwoodjs/internal'
import { detectPrerenderRoutes } from '@redwoodjs/prerender/detection'

import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
import { generatePrismaClient } from 'src/lib/generatePrismaClient'
import { getPaths } from '../lib'
import c from '../lib/colors'
import { generatePrismaClient } from '../lib/generatePrismaClient'

import { getTasks as getPrerenderTasks } from './prerender'

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/check.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
import { getPaths } from '../lib'
import c from '../lib/colors'

export const command = 'check'
export const aliases = ['diagnostics']
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import repl from 'repl'

import babelRequireHook from '@babel/register'

import { getPaths } from 'src/lib'
import { getPaths } from '../lib'

export const command = 'console'
export const aliases = ['c']
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/dataMigrate/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import fs from 'fs-extra'
import Listr from 'listr'
import terminalLink from 'terminal-link'

import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
import { getPaths } from '../../lib'
import c from '../../lib/colors'

const MODEL = `model RW_DataMigration {
version String @id
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/dataMigrate/up.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Listr from 'listr'
import VerboseRenderer from 'listr-verbose-renderer'
import terminalLink from 'terminal-link'

import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
import { getPaths } from '../../lib'
import c from '../../lib/colors'

babelRequireHook({
extends: path.join(getPaths().api.base, '.babelrc.js'),
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/deploy/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import execa from 'execa'
import Listr from 'listr'
import terminalLink from 'terminal-link'

import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
import { getPaths } from '../../lib'
import c from '../../lib/colors'

export const command = 'aws [provider]'
export const description = 'Deploy to AWS using the selected provider'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import terminalLink from 'terminal-link'

import { getPaths } from '@redwoodjs/internal'

import c from 'src/lib/colors'
import c from '../../../lib/colors'

export const deployBuilder = (yargs) => {
yargs
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/render.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import execa from 'execa'
import terminalLink from 'terminal-link'

import { getPaths } from 'src/lib'
import { getPaths } from '../../lib'

export const command = 'render <side> [...commands]'
export const description = 'Build command for Render deploy'
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/destroy/cell/__tests__/cell.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
global.__dirname = __dirname

jest.mock('fs')
jest.mock('src/lib', () => {
jest.mock('../../../../lib', () => {
return {
...jest.requireActual('src/lib'),
...jest.requireActual('../../../../lib'),
generateTemplate: () => '',
}
})
Expand All @@ -18,7 +18,7 @@ jest.mock('@redwoodjs/structure', () => {

import fs from 'fs'

import 'src/lib/test'
import '../../../../lib/test'

import { files } from '../../../generate/cell/cell'
import { tasks } from '../cell'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
global.__dirname = __dirname
jest.mock('fs')
jest.mock('src/lib', () => {
jest.mock('../../../../lib', () => {
return {
...jest.requireActual('src/lib'),
...jest.requireActual('../../../../lib'),
generateTemplate: () => '',
}
})

import fs from 'fs'

import 'src/lib/test'
import '../../../../lib/test'

import { files } from '../../../generate/component/component'
import { tasks } from '../component'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
global.__dirname = __dirname
jest.mock('fs')
jest.mock('src/lib', () => {
jest.mock('../../../../lib', () => {
return {
...jest.requireActual('src/lib'),
...jest.requireActual('../../../../lib'),
generateTemplate: () => '',
}
})

import fs from 'fs'

import 'src/lib/test'
import '../../../../lib/test'

import { files } from '../../../generate/function/function'
import { tasks } from '../function'
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/src/commands/destroy/helpers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Listr from 'listr'

import { deleteFilesTask } from 'src/lib'
import c from 'src/lib/colors'

import { deleteFilesTask } from '../../lib'
import c from '../../lib/colors'
import { ensureUniquePlural } from '../generate/helpers'

const tasks = ({ componentName, filesFn, name }) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
global.__dirname = __dirname
jest.mock('fs')
jest.mock('src/lib', () => {
jest.mock('../../../../lib', () => {
return {
...jest.requireActual('src/lib'),
...jest.requireActual('../../../../lib'),
generateTemplate: () => '',
}
})

import fs from 'fs'

import 'src/lib/test'
import '../../../../lib/test'

import { files } from '../../../generate/layout/layout'
import { tasks } from '../layout'
Expand Down
Loading

0 comments on commit f359de4

Please sign in to comment.