From d0a81e76a8d14d1333279d2cb3c0a24cce5d0e8c Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 9 Jan 2023 19:39:56 +0800 Subject: [PATCH] refactor: remove unused files (#2877) --- packages/cli/src/commands/database/alteration/meta-url.ts | 4 ---- packages/cli/src/commands/database/alteration/utils.ts | 3 +-- packages/cli/src/meta-url.ts | 4 ---- packages/cli/src/utilities.ts | 4 +--- 4 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 packages/cli/src/commands/database/alteration/meta-url.ts delete mode 100644 packages/cli/src/meta-url.ts diff --git a/packages/cli/src/commands/database/alteration/meta-url.ts b/packages/cli/src/commands/database/alteration/meta-url.ts deleted file mode 100644 index 740bd697b..000000000 --- a/packages/cli/src/commands/database/alteration/meta-url.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Have to define this in a separate file since Jest sticks with CJS -// We need to mock this before running tests -// https://github.com/facebook/jest/issues/12952 -export const metaUrl = import.meta.url; diff --git a/packages/cli/src/commands/database/alteration/utils.ts b/packages/cli/src/commands/database/alteration/utils.ts index 5416f220b..660fcf26d 100644 --- a/packages/cli/src/commands/database/alteration/utils.ts +++ b/packages/cli/src/commands/database/alteration/utils.ts @@ -6,10 +6,9 @@ import path from 'path'; import { findPackage } from '@logto/shared'; import { getPathInModule } from '../../../utilities.js'; -import { metaUrl } from './meta-url.js'; import type { AlterationFile } from './type.js'; -const currentDirname = path.dirname(fileURLToPath(metaUrl)); +const currentDirname = path.dirname(fileURLToPath(import.meta.url)); const alterationFilenameRegex = /-(\d+)-?.*\.js$/; export const getTimestampFromFilename = (filename: string) => { diff --git a/packages/cli/src/meta-url.ts b/packages/cli/src/meta-url.ts deleted file mode 100644 index 740bd697b..000000000 --- a/packages/cli/src/meta-url.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Have to define this in a separate file since Jest sticks with CJS -// We need to mock this before running tests -// https://github.com/facebook/jest/issues/12952 -export const metaUrl = import.meta.url; diff --git a/packages/cli/src/utilities.ts b/packages/cli/src/utilities.ts index 50d35f400..60310ea61 100644 --- a/packages/cli/src/utilities.ts +++ b/packages/cli/src/utilities.ts @@ -15,8 +15,6 @@ import type { Options } from 'ora'; import ora from 'ora'; import { z } from 'zod'; -import { metaUrl } from './meta-url.js'; - export const safeExecSync = (command: string) => { try { return execSync(command, { encoding: 'utf8', stdio: 'pipe' }); @@ -87,7 +85,7 @@ export const downloadFile = async (url: string, destination: string) => { export const getPathInModule = (moduleName: string, relativePath = '/') => // https://stackoverflow.com/a/49455609/12514940 path.join( - path.dirname(createRequire(metaUrl).resolve(`${moduleName}/package.json`)), + path.dirname(createRequire(import.meta.url).resolve(`${moduleName}/package.json`)), relativePath );