Skip to content
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

chore(cli): make fs modules used in the CLI consistent #9746

Merged
merged 1 commit into from
Dec 23, 2023
Merged
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
3 changes: 2 additions & 1 deletion packages/cli/src/__tests__/fs.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
jest.mock('fs')

import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

const INITIAL_FS = {
file_a: 'content_a',
[path.join('fake_dir', 'mock_dir', 'made_up_file')]: 'made_up_content',
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/__tests__/plugin.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import fs from 'fs'

import fs from 'fs-extra'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/buildHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'

import execa from 'execa'
import fs from 'fs-extra'
import { Listr } from 'listr2'
import { rimraf } from 'rimraf'
import terminalLink from 'terminal-link'
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/consoleHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs'
import path from 'path'
import repl from 'repl'

import fs from 'fs-extra'

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

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/deploy/__tests__/nftPack.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

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

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/baremetal.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'

import toml from '@iarna/toml'
import boxen from 'boxen'
import fs from 'fs-extra'
import { Listr } from 'listr2'
import { env as envInterpolation } from 'string-env-interpolation'
import terminalLink from 'terminal-link'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy/serverless.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs'
import path from 'path'

import boxen from 'boxen'
import chalk from 'chalk'
import { config } from 'dotenv-defaults'
import execa from 'execa'
import fs from 'fs-extra'
import { Listr } from 'listr2'
import prompts from 'prompts'
import terminalLink from 'terminal-link'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jest.mock('@redwoodjs/structure', () => {
}
})

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock('../../../../lib', () => {
}
})

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jest.mock('../../../../lib', () => {
}
})

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock('../../../../lib', () => {
}
})

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock('../../../../lib', () => {
}
})

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock('../../../../lib', () => {
}
})

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
globalThis.__dirname = __dirname

import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

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

import { getPaths, getDefaultArgs } from '../../../../lib'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
globalThis.__dirname = __dirname

import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

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

import { getPaths, getDefaultArgs } from '../../../../lib'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
globalThis.__dirname = __dirname

import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
globalThis.__dirname = __dirname
import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/devHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import { argv } from 'process'

import concurrently from 'concurrently'
import fs from 'fs-extra'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
import { shutdownPort } from '@redwoodjs/internal/dist/dev'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'

import execa from 'execa'
import fs from 'fs-extra'
import { Listr } from 'listr2'

import { addApiPackages } from '@redwoodjs/cli-helpers'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/experimental/setupRscHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'

import { prettify } from '@redwoodjs/cli-helpers'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'

import { addApiPackages } from '@redwoodjs/cli-helpers'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'

import { addWebPackages } from '@redwoodjs/cli-helpers'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/experimental/studioHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'fs-extra'

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

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/experimental/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'

import chalk from 'chalk'
import fs from 'fs-extra'
import terminalLink from 'terminal-link'

import { getPaths } from '../../lib'
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/generate/__tests__/helpers.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

// Setup test mocks
globalThis.__dirname = __dirname
import '../../../lib/test'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'
import { paramCase } from 'param-case'
import terminalLink from 'terminal-link'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ global.__dirname = __dirname

jest.mock('fs')

import fs from 'fs'
import path from 'path'

// Load mocks
import '../../../../lib/test'

const realfs = jest.requireActual('fs')
import Enquirer from 'enquirer'
import fs from 'fs-extra'

import { getPaths } from '../../../../lib'
import * as dbAuth from '../dbAuth'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/generate/dbAuth/dbAuth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'

import { camelCase } from 'camel-case'
import Enquirer from 'enquirer'
import fs from 'fs-extra'
import { Listr } from 'listr2'
import terminalLink from 'terminal-link'
import { titleCase } from 'title-case'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/generate/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'
import { paramCase } from 'param-case'
import pascalcase from 'pascalcase'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ jest.mock('fs', () => {
}
})

import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

// Load mocks
import '../../../../lib/test'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
globalThis.__dirname = __dirname

import fs from 'fs'
import fs from 'fs-extra'

import '../../../../lib/test'
import { shouldUseTailwindCSS } from '../scaffold'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/generate/scaffold/scaffold.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'

import camelcase from 'camelcase'
import execa from 'execa'
import fs from 'fs-extra'
import humanize from 'humanize-string'
import { Listr } from 'listr2'
import { paramCase } from 'param-case'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/generate/script/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'
import terminalLink from 'terminal-link'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jest.mock('fs', () => {
}
})

import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import prompts from 'prompts'

// Load mocks
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/lint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs'

import execa from 'execa'
import fs from 'fs-extra'
import terminalLink from 'terminal-link'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/prerenderHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import { Listr } from 'listr2'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/prismaHandler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'

import boxen from 'boxen'
import execa from 'execa'
import fs from 'fs-extra'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
import { errorTelemetry } from '@redwoodjs/telemetry'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/serve.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'
import terminalLink from 'terminal-link'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/setup/cache/cacheHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'

import chalk from 'chalk'
import fs from 'fs-extra'
import { Listr } from 'listr2'

import { addEnvVarTask } from '@redwoodjs/cli-helpers'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'

import chalk from 'chalk'
import fs from 'fs-extra'
import { Listr } from 'listr2'

import { errorTelemetry } from '@redwoodjs/telemetry'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Automock fs using ../..../__mocks__/fs
jest.mock('fs')

import fs from 'fs'
import path from 'path'

import fs from 'fs-extra'

import { getPaths } from '../../../../lib'
import { updateApiURLTask } from '../helpers'
// Mock telemetry and other things
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/setup/deploy/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'

import execa from 'execa'
import fs from 'fs-extra'
import { Listr } from 'listr2'

import { getPaths, writeFilesTask } from '../../../../lib'
Expand Down
Loading
Loading