Skip to content

Commit

Permalink
refactor: remove .js extension from cli package (#350)
Browse files Browse the repository at this point in the history
* refactor: remove `.js` extension from cli package

* revert: rollback changes

* revert: rollback unnecessary changes

* Update createIntegration.ts

---------

Co-authored-by: Eric Allam <eallam@icloud.com>
  • Loading branch information
ologbonowiwi and ericallam authored Aug 17, 2023
1 parent 4ca9f18 commit 83bcefe
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 49 deletions.
12 changes: 6 additions & 6 deletions packages/cli/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/commands/createIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
22 changes: 11 additions & 11 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/addDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/detectNextJsProject.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/getUserPkgManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pathModule from "path";
import { pathExists } from "./fileSystem.js";
import { pathExists } from "./fileSystem";

export type PackageManager = "npm" | "pnpm" | "yarn";

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/utils/getVersion.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/utils/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/utils/installDependencies.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/readPackageJson.ts
Original file line number Diff line number Diff line change
@@ -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<PackageJson | undefined> {
const packageJsonPath = pathModule.join(directory, "package.json");
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/utils/renderTitle.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/templateRef.ts
Original file line number Diff line number Diff line change
@@ -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}`;
Expand Down

0 comments on commit 83bcefe

Please sign in to comment.