From 83bcefe10c53c19571ff45fc09979d4ba32ccf2f Mon Sep 17 00:00:00 2001 From: Wesley <100464352+ologbonowiwi@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:03:00 -0300 Subject: [PATCH] refactor: remove `.js` extension from cli package (#350) * refactor: remove `.js` extension from cli package * revert: rollback changes * revert: rollback unnecessary changes * Update createIntegration.ts --------- Co-authored-by: Eric Allam --- packages/cli/src/cli/index.ts | 12 +++++----- .../cli/src/commands/createIntegration.ts | 16 +++++++------- packages/cli/src/commands/dev.ts | 12 +++++----- packages/cli/src/commands/init.ts | 22 +++++++++---------- packages/cli/src/index.ts | 4 ++-- packages/cli/src/telemetry/telemetry.ts | 6 ++--- packages/cli/src/utils/addDependencies.ts | 2 +- packages/cli/src/utils/detectNextJsProject.ts | 2 +- packages/cli/src/utils/getUserPkgManager.ts | 2 +- packages/cli/src/utils/getVersion.ts | 4 ++-- packages/cli/src/utils/git.ts | 4 ++-- packages/cli/src/utils/installDependencies.ts | 4 ++-- packages/cli/src/utils/readPackageJson.ts | 2 +- packages/cli/src/utils/renderTitle.ts | 4 ++-- packages/cli/src/utils/templateRef.ts | 2 +- 15 files changed, 49 insertions(+), 49 deletions(-) diff --git a/packages/cli/src/cli/index.ts b/packages/cli/src/cli/index.ts index 97b519ec70..bea407672f 100644 --- a/packages/cli/src/cli/index.ts +++ b/packages/cli/src/cli/index.ts @@ -1,12 +1,12 @@ import { Command } from "commander"; import inquirer from "inquirer"; import pathModule from "node:path"; -import { createIntegrationCommand } from "../commands/createIntegration.js"; -import { devCommand } from "../commands/dev.js"; -import { initCommand } from "../commands/init.js"; -import { CLOUD_TRIGGER_URL, COMMAND_NAME } from "../consts.js"; -import { telemetryClient } from "../telemetry/telemetry.js"; -import { getVersion } from "../utils/getVersion.js"; +import { createIntegrationCommand } from "../commands/createIntegration"; +import { devCommand } from "../commands/dev"; +import { initCommand } from "../commands/init"; +import { CLOUD_TRIGGER_URL, COMMAND_NAME } from "../consts"; +import { telemetryClient } from "../telemetry/telemetry"; +import { getVersion } from "../utils/getVersion"; export const program = new Command(); diff --git a/packages/cli/src/commands/createIntegration.ts b/packages/cli/src/commands/createIntegration.ts index 680233b0be..370c2c4eac 100644 --- a/packages/cli/src/commands/createIntegration.ts +++ b/packages/cli/src/commands/createIntegration.ts @@ -2,14 +2,14 @@ import inquirer from "inquirer"; import pathModule from "node:path"; import ora from "ora"; import { z } from "zod"; -import { COMMAND_NAME } from "../consts.js"; -import { getLatestPackageVersion } from "../utils/addDependencies.js"; -import { createFile, pathExists, readJSONFile, writeJSONFile } from "../utils/fileSystem.js"; -import { generateIntegrationFiles } from "../utils/generateIntegrationFiles.js"; -import { getPackageName } from "../utils/getPackagName.js"; -import { installDependencies } from "../utils/installDependencies.js"; -import { logger } from "../utils/logger.js"; -import { resolvePath } from "../utils/parseNameAndPath.js"; +import { COMMAND_NAME } from "../consts"; +import { getLatestPackageVersion } from "../utils/addDependencies"; +import { createFile, pathExists, readJSONFile, writeJSONFile } from "../utils/fileSystem"; +import { generateIntegrationFiles } from "../utils/generateIntegrationFiles"; +import { getPackageName } from "../utils/getPackagName"; +import { installDependencies } from "../utils/installDependencies"; +import { logger } from "../utils/logger"; +import { resolvePath } from "../utils/parseNameAndPath"; const CLIOptionsSchema = z.object({ packageName: z.string().optional(), diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts index d6c97bc2db..8c4db7a043 100644 --- a/packages/cli/src/commands/dev.ts +++ b/packages/cli/src/commands/dev.ts @@ -8,12 +8,12 @@ import ora, { Ora } from "ora"; import pathModule from "path"; import util from "util"; import { z } from "zod"; -import { CLOUD_API_URL } from "../consts.js"; -import { telemetryClient } from "../telemetry/telemetry.js"; -import { pathExists, readFile } from "../utils/fileSystem.js"; -import { logger } from "../utils/logger.js"; -import { resolvePath } from "../utils/parseNameAndPath.js"; -import { TriggerApi } from "../utils/triggerApi.js"; +import { CLOUD_API_URL } from "../consts"; +import { telemetryClient } from "../telemetry/telemetry"; +import { pathExists, readFile } from "../utils/fileSystem"; +import { logger } from "../utils/logger"; +import { resolvePath } from "../utils/parseNameAndPath"; +import { TriggerApi } from "../utils/triggerApi"; const asyncExecFile = util.promisify(childProcess.execFile); diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 0e84f2e6bb..f6319c83a9 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -7,17 +7,17 @@ import { pathToRegexp } from "path-to-regexp"; import { simpleGit } from "simple-git"; import { parse } from "tsconfck"; import { pathToFileURL } from "url"; -import { promptApiKey, promptTriggerUrl } from "../cli/index.js"; -import { CLOUD_API_URL, CLOUD_TRIGGER_URL, COMMAND_NAME } from "../consts.js"; -import { TelemetryClient, telemetryClient } from "../telemetry/telemetry.js"; -import { addDependencies } from "../utils/addDependencies.js"; -import { detectNextJsProject } from "../utils/detectNextJsProject.js"; -import { pathExists, readJSONFile } from "../utils/fileSystem.js"; -import { logger } from "../utils/logger.js"; -import { resolvePath } from "../utils/parseNameAndPath.js"; -import { renderApiKey } from "../utils/renderApiKey.js"; -import { renderTitle } from "../utils/renderTitle.js"; -import { TriggerApi, WhoamiResponse } from "../utils/triggerApi.js"; +import { promptApiKey, promptTriggerUrl } from "../cli/index"; +import { CLOUD_API_URL, CLOUD_TRIGGER_URL, COMMAND_NAME } from "../consts"; +import { TelemetryClient, telemetryClient } from "../telemetry/telemetry"; +import { addDependencies } from "../utils/addDependencies"; +import { detectNextJsProject } from "../utils/detectNextJsProject"; +import { pathExists, readJSONFile } from "../utils/fileSystem"; +import { logger } from "../utils/logger"; +import { resolvePath } from "../utils/parseNameAndPath"; +import { renderApiKey } from "../utils/renderApiKey"; +import { renderTitle } from "../utils/renderTitle"; +import { TriggerApi, WhoamiResponse } from "../utils/triggerApi"; export type InitCommandOptions = { projectPath: string; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 9f70f9e00f..eabae4027b 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node -import { program } from "./cli/index.js"; -import { logger } from "./utils/logger.js"; +import { program } from "./cli/index"; +import { logger } from "./utils/logger"; const main = async () => { await program.parseAsync(); diff --git a/packages/cli/src/telemetry/telemetry.ts b/packages/cli/src/telemetry/telemetry.ts index ac624b84a6..fd2f3e6603 100644 --- a/packages/cli/src/telemetry/telemetry.ts +++ b/packages/cli/src/telemetry/telemetry.ts @@ -1,8 +1,8 @@ import { PostHog } from "posthog-node"; -import { InitCommandOptions } from "../commands/init.js"; +import { InitCommandOptions } from "../commands/init"; import { nanoid } from "nanoid"; -import { getVersion } from "../utils/getVersion.js"; -import { DevCommandOptions } from "../commands/dev.js"; +import { getVersion } from "../utils/getVersion"; +import { DevCommandOptions } from "../commands/dev"; const postHogApiKey = "phc_hwYmedO564b3Ik8nhA4Csrb5SueY0EwFJWCbseGwWW"; diff --git a/packages/cli/src/utils/addDependencies.ts b/packages/cli/src/utils/addDependencies.ts index 74a950620c..186d128d86 100644 --- a/packages/cli/src/utils/addDependencies.ts +++ b/packages/cli/src/utils/addDependencies.ts @@ -2,7 +2,7 @@ import chalk from "chalk"; import { execa } from "execa"; import ora, { type Ora } from "ora"; import pathModule from "path"; -import { getUserPackageManager, type PackageManager } from "./getUserPkgManager.js"; +import { getUserPackageManager, type PackageManager } from "./getUserPkgManager"; import fs from "fs/promises"; import fetch from "node-fetch"; import { z } from "zod"; diff --git a/packages/cli/src/utils/detectNextJsProject.ts b/packages/cli/src/utils/detectNextJsProject.ts index 9970b2c32c..664501f874 100644 --- a/packages/cli/src/utils/detectNextJsProject.ts +++ b/packages/cli/src/utils/detectNextJsProject.ts @@ -1,6 +1,6 @@ import fs from "fs/promises"; import pathModule from "path"; -import { readPackageJson } from "./readPackageJson.js"; +import { readPackageJson } from "./readPackageJson"; /** Detects if the project is a Next.js project at path */ export async function detectNextJsProject(path: string): Promise { diff --git a/packages/cli/src/utils/getUserPkgManager.ts b/packages/cli/src/utils/getUserPkgManager.ts index 27b9a90315..72879178b9 100644 --- a/packages/cli/src/utils/getUserPkgManager.ts +++ b/packages/cli/src/utils/getUserPkgManager.ts @@ -1,5 +1,5 @@ import pathModule from "path"; -import { pathExists } from "./fileSystem.js"; +import { pathExists } from "./fileSystem"; export type PackageManager = "npm" | "pnpm" | "yarn"; diff --git a/packages/cli/src/utils/getVersion.ts b/packages/cli/src/utils/getVersion.ts index 46d91f05a1..9466891056 100644 --- a/packages/cli/src/utils/getVersion.ts +++ b/packages/cli/src/utils/getVersion.ts @@ -1,7 +1,7 @@ import { type PackageJson } from "type-fest"; import path from "path"; -import { PKG_ROOT } from "../consts.js"; -import { readJSONFileSync } from "./fileSystem.js"; +import { PKG_ROOT } from "../consts"; +import { readJSONFileSync } from "./fileSystem"; export function getVersion() { const packageJsonPath = path.join(PKG_ROOT, "package.json"); diff --git a/packages/cli/src/utils/git.ts b/packages/cli/src/utils/git.ts index 6d56a1e9a7..8d08668336 100644 --- a/packages/cli/src/utils/git.ts +++ b/packages/cli/src/utils/git.ts @@ -4,8 +4,8 @@ import { execa } from "execa"; import inquirer from "inquirer"; import ora from "ora"; import path from "path"; -import { logger } from "./logger.js"; -import { pathExists, removeFile } from "./fileSystem.js"; +import { logger } from "./logger"; +import { pathExists, removeFile } from "./fileSystem"; const isGitInstalled = (dir: string): boolean => { try { diff --git a/packages/cli/src/utils/installDependencies.ts b/packages/cli/src/utils/installDependencies.ts index 1ab8b7ae07..78ba5ee509 100644 --- a/packages/cli/src/utils/installDependencies.ts +++ b/packages/cli/src/utils/installDependencies.ts @@ -1,5 +1,5 @@ -import { getUserPackageManager, type PackageManager } from "./getUserPkgManager.js"; -import { logger } from "./logger.js"; +import { getUserPackageManager, type PackageManager } from "./getUserPkgManager"; +import { logger } from "./logger"; import ora, { type Ora } from "ora"; import chalk from "chalk"; import { execa } from "execa"; diff --git a/packages/cli/src/utils/readPackageJson.ts b/packages/cli/src/utils/readPackageJson.ts index b91727b2f3..087eeb59fb 100644 --- a/packages/cli/src/utils/readPackageJson.ts +++ b/packages/cli/src/utils/readPackageJson.ts @@ -1,6 +1,6 @@ import pathModule from "path"; import { type PackageJson } from "type-fest"; -import { readJSONFile } from "./fileSystem.js"; +import { readJSONFile } from "./fileSystem"; export async function readPackageJson(directory: string): Promise { const packageJsonPath = pathModule.join(directory, "package.json"); diff --git a/packages/cli/src/utils/renderTitle.ts b/packages/cli/src/utils/renderTitle.ts index 67336e492e..1d27af0ac0 100644 --- a/packages/cli/src/utils/renderTitle.ts +++ b/packages/cli/src/utils/renderTitle.ts @@ -1,6 +1,6 @@ import gradient from "gradient-string"; -import { TITLE_TEXT } from "../consts.js"; -import { getUserPackageManager } from "./getUserPkgManager.js"; +import { TITLE_TEXT } from "../consts"; +import { getUserPackageManager } from "./getUserPkgManager"; // colors brought in from vscode poimandres theme const poimandresTheme = { diff --git a/packages/cli/src/utils/templateRef.ts b/packages/cli/src/utils/templateRef.ts index 23f812d67a..d82fba39fe 100644 --- a/packages/cli/src/utils/templateRef.ts +++ b/packages/cli/src/utils/templateRef.ts @@ -1,4 +1,4 @@ -import { TEMPLATE_ORGANIZATION } from "../consts.js"; +import { TEMPLATE_ORGANIZATION } from "../consts"; export function createTemplateRef(templateName: string): string { return `github:${TEMPLATE_ORGANIZATION}/${templateName}`;