Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Jan 10, 2025
1 parent d102b60 commit 3c7c9ea
Show file tree
Hide file tree
Showing 40 changed files with 187 additions and 177 deletions.
16 changes: 8 additions & 8 deletions packages/wrangler/src/api/startDevWorker/ConfigController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import assert from "node:assert";
import path from "node:path";
import { watch } from "chokidar";
import {
DEFAULT_INSPECTOR_PORT,
DEFAULT_LOCAL_PORT,
getDevCompatibilityDate,
getRules,
getScriptName,
isLegacyEnv,
} from "../..";
import { getAssetsOptions, validateAssetsArgsAndConfig } from "../../assets";
import { readConfig } from "../../config";
import { getEntry } from "../../deployment-bundle/entry";
Expand All @@ -23,6 +15,14 @@ import { getLocalPersistencePath } from "../../dev/get-local-persistence-path";
import { UserError } from "../../errors";
import { logger } from "../../logger";
import { requireApiToken, requireAuth } from "../../user";
import {
DEFAULT_INSPECTOR_PORT,
DEFAULT_LOCAL_PORT,
} from "../../utils/constants";
import { getDevCompatibilityDate } from "../../utils/getDevCompatibilityDate";
import { getRules } from "../../utils/getRules";
import { getScriptName } from "../../utils/getScriptName";
import { isLegacyEnv } from "../../utils/isLegacyEnv";
import { memoizeGetPort } from "../../utils/memoizeGetPort";
import { printBindings } from "../../utils/print-bindings";
import { getZoneIdForPreview } from "../../zones";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/create.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import TOML from "@iarna/toml";
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { withConfig } from "../config";
import { UserError } from "../errors";
import { logger } from "../logger";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import { LOCATION_CHOICES } from "./constants";
import type {
CommonYargsArgv,
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/delete.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { withConfig } from "../config";
import { confirm } from "../dialogs";
import { logger } from "../logger";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import { Name } from "./options";
import { getDatabaseByNameOrBinding } from "./utils";
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import chalk from "chalk";
import md5File from "md5-file";
import { Miniflare } from "miniflare";
import { fetch } from "undici";
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { configFileName, readConfig } from "../config";
import { getLocalPersistencePath } from "../dev/get-local-persistence-path";
Expand All @@ -16,6 +15,7 @@ import { logger } from "../logger";
import { APIError, readFileSync } from "../parse";
import { readableRelative } from "../paths";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import * as options from "./options";
import splitSqlQuery from "./splitter";
import { getDatabaseByNameOrBinding, getDatabaseInfoFromConfig } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { spinner, spinnerWhile } from "@cloudflare/cli/interactive";
import chalk from "chalk";
import { Miniflare } from "miniflare";
import { fetch } from "undici";
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { configFileName, readConfig } from "../config";
import { getLocalPersistencePath } from "../dev/get-local-persistence-path";
Expand All @@ -13,6 +12,7 @@ import { logger } from "../logger";
import { APIError } from "../parse";
import { readableRelative } from "../paths";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import { Name } from "./options";
import { getDatabaseByNameOrBinding, getDatabaseInfoFromConfig } from "./utils";
import type { Config } from "../config";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/info.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import prettyBytes from "pretty-bytes";
import { printWranglerBanner } from "..";
import { fetchGraphqlResult } from "../cfetch";
import { withConfig } from "../config";
import { logger } from "../logger";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import { getDatabaseByNameOrBinding, getDatabaseInfoFromId } from "./utils";
import type {
CommonYargsArgv,
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/insights.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { printWranglerBanner } from "..";
import { fetchGraphqlResult } from "../cfetch";
import { withConfig } from "../config";
import { logger } from "../logger";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import { getDatabaseByNameOrBinding, getDatabaseInfoFromId } from "./utils";
import type {
CommonYargsArgv,
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/list.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { printWranglerBanner } from "..";
import { fetchResult } from "../cfetch";
import { withConfig } from "../config";
import { logger } from "../logger";
import { requireAuth } from "../user";
import { printWranglerBanner } from "../wrangler-banner";
import type {
CommonYargsArgv,
StrictYargsOptionsToInterface,
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/migrations/apply.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import assert from "node:assert";
import fs from "node:fs";
import path from "path";
import { printWranglerBanner } from "../..";
import { configFileName, withConfig } from "../../config";
import { confirm } from "../../dialogs";
import { UserError } from "../../errors";
import { isNonInteractiveOrCI } from "../../is-interactive";
import { logger } from "../../logger";
import { requireAuth } from "../../user";
import { printWranglerBanner } from "../../wrangler-banner";
import { createBackup } from "../backups";
import { DEFAULT_MIGRATION_PATH, DEFAULT_MIGRATION_TABLE } from "../constants";
import { executeSql } from "../execute";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/migrations/create.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from "node:fs";
import path from "path";
import { printWranglerBanner } from "../..";
import { configFileName, withConfig } from "../../config";
import { UserError } from "../../errors";
import { logger } from "../../logger";
import { printWranglerBanner } from "../../wrangler-banner";
import { DEFAULT_MIGRATION_PATH } from "../constants";
import { Database } from "../options";
import { getDatabaseInfoFromConfig } from "../utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/migrations/list.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from "path";
import { printWranglerBanner } from "../..";
import { configFileName, withConfig } from "../../config";
import { UserError } from "../../errors";
import { logger } from "../../logger";
import { requireAuth } from "../../user";
import { printWranglerBanner } from "../../wrangler-banner";
import { DEFAULT_MIGRATION_PATH, DEFAULT_MIGRATION_TABLE } from "../constants";
import { getDatabaseInfoFromConfig } from "../utils";
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/timeTravel/info.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { printWranglerBanner } from "../..";
import { withConfig } from "../../config";
import { logger } from "../../logger";
import { requireAuth } from "../../user";
import { printWranglerBanner } from "../../wrangler-banner";
import { Database } from "../options";
import { getDatabaseByNameOrBinding } from "../utils";
import { getBookmarkIdFromTimestamp, throwIfDatabaseIsAlpha } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/d1/timeTravel/restore.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { printWranglerBanner } from "../..";
import { fetchResult } from "../../cfetch";
import { withConfig } from "../../config";
import { confirm } from "../../dialogs";
import { UserError } from "../../errors";
import { logger } from "../../logger";
import { requireAuth } from "../../user";
import { printWranglerBanner } from "../../wrangler-banner";
import { Database } from "../options";
import { getDatabaseByNameOrBinding } from "../utils";
import { getBookmarkIdFromTimestamp, throwIfDatabaseIsAlpha } from "./utils";
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/src/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { deleteKVNamespace, listKVNamespaces } from "./kv/helpers";
import { logger } from "./logger";
import * as metrics from "./metrics";
import { requireAuth } from "./user";
import { getScriptName, printWranglerBanner } from "./index";
import { getScriptName } from "./utils/getScriptName";
import { printWranglerBanner } from "./wrangler-banner";
import type {
CommonYargsArgv,
StrictYargsOptionsToInterface,
Expand Down
10 changes: 4 additions & 6 deletions packages/wrangler/src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import { configFileName, readConfig } from "../config";
import { getEntry } from "../deployment-bundle/entry";
import { UserError } from "../errors";
import { run } from "../experimental-flags";
import {
getRules,
getScriptName,
isLegacyEnv,
printWranglerBanner,
} from "../index";
import { logger } from "../logger";
import { verifyWorkerMatchesCITag } from "../match-tag";
import * as metrics from "../metrics";
import { writeOutput } from "../output";
import { getLegacyAssetPaths, getSiteAssetPaths } from "../sites";
import { requireAuth } from "../user";
import { collectKeyValues } from "../utils/collectKeyValues";
import { getRules } from "../utils/getRules";
import { getScriptName } from "../utils/getScriptName";
import { isLegacyEnv } from "../utils/isLegacyEnv";
import { printWranglerBanner } from "../wrangler-banner";
import deploy from "./deploy";
import type { Config } from "../config";
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/deployment-bundle/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chalk from "chalk";
import { isLegacyEnv } from "..";
import { fetchResult } from "../cfetch";
import { createD1Database } from "../d1/create";
import { listDatabases } from "../d1/list";
Expand All @@ -8,6 +7,7 @@ import { FatalError, UserError } from "../errors";
import { createKVNamespace, listKVNamespaces } from "../kv/helpers";
import { logger } from "../logger";
import { createR2Bucket, listR2Buckets } from "../r2/helpers";
import { isLegacyEnv } from "../utils/isLegacyEnv";
import { printBindings } from "../utils/print-bindings";
import type { Config } from "../config";
import type { WorkerMetadataBinding } from "./create-worker-upload-form";
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/src/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { mapBindings } from "./init";
import { logger } from "./logger";
import * as metrics from "./metrics";
import { requireAuth } from "./user";
import { getScriptName, printWranglerBanner } from ".";
import { getScriptName } from "./utils/getScriptName";
import { printWranglerBanner } from "./wrangler-banner";
import type { Config } from "./config";
import type { WorkerMetadataBinding } from "./deployment-bundle/create-worker-upload-form";
import type { ServiceMetadataRes } from "./init";
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/dispatch-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readConfig } from "./config";
import { logger } from "./logger";
import * as metrics from "./metrics";
import { requireAuth } from "./user";
import { printWranglerBanner } from ".";
import { printWranglerBanner } from "./wrangler-banner";
import type { CommonYargsArgv, CommonYargsOptions } from "./yargs-types";
import type { CommandModule } from "yargs";

Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/generate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { execa } from "execa";
import { getC3CommandFromEnv } from "../environment-variables/misc-variables";
import { CommandLineArgsError, UserError } from "../errors";
import { cloneIntoDirectory, initializeGit } from "../git-client";
import { printWranglerBanner } from "../index";
import { initHandler } from "../init";
import { logger } from "../logger";
import { getPackageManager } from "../package-manager";
import * as shellquote from "../utils/shell-quote";
import { printWranglerBanner } from "../wrangler-banner";
import type {
CommonYargsArgv,
StrictYargsOptionsToInterface,
Expand Down
Loading

0 comments on commit 3c7c9ea

Please sign in to comment.