Skip to content

chore(cli): Add .js to relative imports (ESM prep) #12020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli/src/__tests__/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { hideBin } from 'yargs/helpers'

import { getConfig, getPaths } from '@redwoodjs/project-config'

import * as pluginLib from '../lib/plugin'
import { loadPlugins } from '../plugin'
import * as pluginLib from '../lib/plugin.js'
import { loadPlugins } from '../plugin.js'

vi.mock('fs-extra')
vi.mock('@redwoodjs/project-config', async (importOriginal) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/__tests__/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ vi.mock('execa', () => ({
})),
}))

import { handler } from '../build'
import { handler } from '../build.js'

afterEach(() => {
vi.clearAllMocks()
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/__tests__/dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ import { vi, describe, afterEach, it, expect } from 'vitest'

import { getConfig } from '@redwoodjs/project-config'

import { generatePrismaClient } from '../../lib/generatePrismaClient'
import { handler } from '../dev'
import { generatePrismaClient } from '../../lib/generatePrismaClient.js'
import { handler } from '../dev.js'

describe('yarn rw dev', () => {
afterEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/__tests__/exec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import path from 'node:path'
import { fs as memfs, vol } from 'memfs'
import { vi, afterEach, beforeEach, describe, it, expect } from 'vitest'

import { runScriptFunction } from '../../lib/exec'
import { runScriptFunction } from '../../lib/exec.js'
import '../../lib/mockTelemetry'
import { handler } from '../execHandler'
import { handler } from '../execHandler.js'

vi.mock('@redwoodjs/babel-config', () => ({
getWebSideDefaultBabelConfig: () => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/__tests__/info.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '../../lib/mockTelemetry'

import { vi, afterEach, beforeEach, describe, it, expect } from 'vitest'

import { handler } from '../info'
import { handler } from '../info.js'

vi.mock('envinfo', () => ({ default: { run: () => '' } }))
vi.mock('@redwoodjs/project-config', () => ({ getPaths: () => ({}) }))
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/__tests__/prisma.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ vi.mock('fs-extra', async (importOriginal) => {
import execa from 'execa'
import { vi, beforeEach, afterEach, test, expect } from 'vitest'

import { handler } from '../prisma'
import { handler } from '../prisma.js'

beforeEach(() => {
vi.spyOn(console, 'info').mockImplementation(() => {})
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/__tests__/serve.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import yargs from 'yargs/yargs'
import * as apiServerCLIConfig from '@redwoodjs/api-server/dist/apiCLIConfig'
import * as bothServerCLIConfig from '@redwoodjs/api-server/dist/bothCLIConfig'

import { builder } from '../serve'
import { builder } from '../serve.js'

globalThis.__dirname = __dirname

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/__tests__/studioHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vi.mock('fs-extra', () => ({

import { vi, describe, it, afterEach, afterAll, expect } from 'vitest'

import { assertRedwoodVersion } from '../studioHandler'
import { assertRedwoodVersion } from '../studioHandler.js'

describe('studioHandler', () => {
describe('assertRedwoodVersion', () => {
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
Expand Up @@ -11,7 +11,7 @@ vi.mock('execa', () => ({
import execa from 'execa'
import { vi, afterEach, test, expect } from 'vitest'

import { handler } from '../test'
import { handler } from '../test.js'

vi.mock('@redwoodjs/structure', () => {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/__tests__/type-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ import concurrently from 'concurrently'
import execa from 'execa'
import { vi, beforeEach, afterEach, test, expect } from 'vitest'

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

beforeEach(() => {
vi.spyOn(console, 'info').mockImplementation(() => {})
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import terminalLink from 'terminal-link'

import c from '../lib/colors'
import { exitWithError } from '../lib/exit'
import { sides } from '../lib/project'
import { checkNodeVersion } from '../middleware/checkNodeVersion'
import c from '../lib/colors.js'
import { exitWithError } from '../lib/exit.js'
import { sides } from '../lib/project.js'
import { checkNodeVersion } from '../middleware/checkNodeVersion.js'

export const command = 'build [side..]'
export const description = 'Build for production'
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/buildHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { loadAndValidateSdls } from '@redwoodjs/internal/dist/validateSchema'
import { detectPrerenderRoutes } from '@redwoodjs/prerender/detection'
import { timedTelemetry } from '@redwoodjs/telemetry'

import { getPaths, getConfig } from '../lib'
import { generatePrismaCommand } from '../lib/generatePrismaClient'
import { generatePrismaCommand } from '../lib/generatePrismaClient.js'
import { getPaths, getConfig } from '../lib/index.js'

export const handler = async ({
side = ['api', 'web'],
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,7 +1,7 @@
import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { getPaths } from '../lib'
import c from '../lib/colors'
import c from '../lib/colors.js'
import { getPaths } from '../lib/index.js'

export const command = 'check'
export const aliases = ['diagnostics']
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/consoleHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fs from 'fs-extra'
import { registerApiSideBabelHook } from '@redwoodjs/babel-config'
import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { getPaths } from '../lib'
import { getPaths } from '../lib/index.js'

const paths = getPaths()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vi.mock('@redwoodjs/project-config', async (importOriginal) => {
}
})

import * as baremetal from '../baremetal'
import * as baremetal from '../baremetal.js'

describe('verifyConfig', () => {
it('throws an error if no environment specified', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vi, describe, it, expect, beforeEach, type Mock } from 'vitest'
import yargs from 'yargs'

import { handler, builder } from '../flightcontrol'
import { handler, builder } from '../flightcontrol.js'

vi.mock('path')
vi.mock('execa')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/__tests__/nftPack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { vi, test, expect } from 'vitest'

import { findApiDistFunctions } from '@redwoodjs/internal/dist/files'

import * as nftPacker from '../packing/nft'
import * as nftPacker from '../packing/nft.js'

vi.mock('@vercel/nft', () => {
return {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/deploy/baremetal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { titleCase } from 'title-case'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { getPaths } from '../../lib'
import c from '../../lib/colors'
import c from '../../lib/colors.js'
import { getPaths } from '../../lib/index.js'

import { SshExecutor } from './baremetal/SshExecutor'
import { SshExecutor } from './baremetal/SshExecutor.js'

const CONFIG_FILENAME = 'deploy.toml'
const SYMLINK_FLAGS = '-nsf'
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/project-config'

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

export const deployBuilder = (yargs) => {
yargs
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/netlify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { deployBuilder, deployHandler } from './helpers/helpers'
import { deployBuilder, deployHandler } from './helpers/helpers.js'

export const command = 'netlify [...commands]'
export const description = 'Build command for Netlify deploy'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/packing/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fse from 'fs-extra'
import { findApiDistFunctions } from '@redwoodjs/internal/dist/files'
import { ensurePosixPath, getPaths } from '@redwoodjs/project-config'

import * as nftPacker from '../packing/nft'
import * as nftPacker from '../packing/nft.js'

const ZIPBALL_DIR = './api/dist/zipball'

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/deploy/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import terminalLink from 'terminal-link'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { getPaths } from '../../lib'
import c from '../../lib/colors'
import c from '../../lib/colors.js'
import { getPaths } from '../../lib/index.js'

export const command = 'serverless'
export const aliases = ['aws serverless', 'sls']
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/vercel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { deployBuilder, deployHandler } from './helpers/helpers'
import { deployBuilder, deployHandler } from './helpers/helpers.js'

export const command = 'vercel [...commands]'
export const description = 'Build command for Vercel deploy'
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/destroy/cell/__tests__/cell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { vi, beforeEach, afterEach, test, expect } from 'vitest'

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

import { files } from '../../../generate/cell/cell'
import { tasks } from '../cell'
import { files } from '../../../generate/cell/cell.js'
import { tasks } from '../cell.js'

beforeEach(() => {
vi.spyOn(console, 'info').mockImplementation(() => {})
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/destroy/cell/cell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { files as cellFiles } from '../../generate/cell/cell'
import { createYargsForComponentDestroy } from '../helpers'
import { files as cellFiles } from '../../generate/cell/cell.js'
import { createYargsForComponentDestroy } from '../helpers.js'

export const { command, description, builder, handler, tasks } =
createYargsForComponentDestroy({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { vi, beforeEach, afterEach, test, expect } from 'vitest'

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

import { files } from '../../../generate/component/component'
import { tasks } from '../component'
import { files } from '../../../generate/component/component.js'
import { tasks } from '../component.js'

beforeEach(async () => {
vol.fromJSON(await files({ name: 'About' }))
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/destroy/component/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { files as componentFiles } from '../../generate/component/component'
import { createYargsForComponentDestroy } from '../helpers'
import { files as componentFiles } from '../../generate/component/component.js'
import { createYargsForComponentDestroy } from '../helpers.js'

export const description = 'Destroy a component'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { vi, beforeEach, afterEach, test, expect } from 'vitest'

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

import { files } from '../../../generate/directive/directive'
import { tasks } from '../directive'
import { files } from '../../../generate/directive/directive.js'
import { tasks } from '../directive.js'

beforeEach(() => {
vol.fromJSON(files({ name: 'require-admin', type: 'validator', tests: true }))
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/destroy/directive/directive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { files as directiveFiles } from '../../generate/directive/directive'
import { createYargsForComponentDestroy } from '../helpers'
import { files as directiveFiles } from '../../generate/directive/directive.js'
import { createYargsForComponentDestroy } from '../helpers.js'

export const description = 'Destroy a directive'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { vi, beforeEach, afterEach, test, expect } from 'vitest'

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

import { files } from '../../../generate/function/function'
import { tasks } from '../function'
import { files } from '../../../generate/function/function.js'
import { tasks } from '../function.js'

beforeEach(async () => {
vol.fromJSON(files({ name: 'sendMail' }))
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/destroy/function/function.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { files as functionFiles } from '../../generate/function/function'
import { createYargsForComponentDestroy } from '../helpers'
import { files as functionFiles } from '../../generate/function/function.js'
import { createYargsForComponentDestroy } from '../helpers.js'

export const description = 'Destroy a Function'

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/destroy/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Listr } from 'listr2'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { deleteFilesTask } from '../../lib'
import { deleteFilesTask } from '../../lib/index.js'

const tasks = ({ componentName, filesFn, name }) =>
new Listr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { vi, beforeEach, afterEach, test, expect } from 'vitest'

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

import { files } from '../../../generate/layout/layout'
import { tasks } from '../layout'
import { files } from '../../../generate/layout/layout.js'
import { tasks } from '../layout.js'

beforeEach(() => {
vol.fromJSON(files({ name: 'Blog' }))
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/destroy/layout/layout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { files as layoutFiles } from '../../generate/layout/layout'
import { createYargsForComponentDestroy } from '../helpers'
import { files as layoutFiles } from '../../generate/layout/layout.js'
import { createYargsForComponentDestroy } from '../helpers.js'

export const { command, description, builder, handler, tasks } =
createYargsForComponentDestroy({
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/destroy/page/__tests__/page.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ vi.mock('@redwoodjs/internal/dist/generate/generate', () => {
}
})

import { getPaths } from '../../../../lib'
import { files } from '../../../generate/page/page'
import { tasks } from '../page'
import { getPaths } from '../../../../lib/index.js'
import { files } from '../../../generate/page/page.js'
import { tasks } from '../page.js'

beforeEach(async () => {
const f = await files({ name: 'About' })
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/src/commands/destroy/page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { Listr } from 'listr2'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'

import { deleteFilesTask, removeRoutesFromRouterTask } from '../../../lib'
import c from '../../../lib/colors'
import { pathName } from '../../generate/helpers'
import c from '../../../lib/colors.js'
import {
deleteFilesTask,
removeRoutesFromRouterTask,
} from '../../../lib/index.js'
import { pathName } from '../../generate/helpers.js'
import {
files as pageFiles,
paramVariants as templateVars,
} from '../../generate/page/page'
} from '../../generate/page/page.js'

export const command = 'page <name> [path]'
export const description = 'Destroy a page and route component'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { vi, test, describe, beforeEach, afterEach, expect } from 'vitest'

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

import { getPaths, getDefaultArgs } from '../../../../lib'
import { getPaths, getDefaultArgs } from '../../../../lib/index.js'
import {
yargsDefaults as defaults,
customOrDefaultTemplatePath,
} from '../../../generate/helpers'
import { files } from '../../../generate/scaffold/scaffold'
import { tasks } from '../scaffold'
} from '../../../generate/helpers.js'
import { files } from '../../../generate/scaffold/scaffold.js'
import { tasks } from '../scaffold.js'

vi.mock('fs', async () => ({ default: (await import('memfs')).fs }))
vi.mock('fs-extra')
Expand Down
Loading
Loading