Skip to content

Commit

Permalink
refactor(cli/migrate): separate transform-related exports from the tr…
Browse files Browse the repository at this point in the history
…ansform

because jscodeshift does not have full typescript support for transforms
  • Loading branch information
pcattori committed Apr 11, 2022
1 parent a3f1a19 commit baa2183
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as colors from "../../../../colors";
import * as jscodeshift from "../../jscodeshift";
import type { MigrationFunction } from "../../types";
import { resolveTransformOptions } from "./resolveTransformOptions";
import type { Options } from "./transform";
import type { Options } from "./transform/options";
import type { Dependency } from "./dependency";
import { depsToObject, isRemixPackage, depsToEntries } from "./dependency";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import inquirer from "inquirer";
import type { PackageJson } from "@npmcli/package-json";

import * as colors from "../../../../colors";
import type { Options } from "./transform";
import { runtimes, isRuntime, isAdapter } from "./transform";
import type {
Adapter,
Runtime,
} from "./transform/mapNormalizedImports/packageExports";
import type { Options } from "./transform/options";
import { isAdapter } from "./transform/adapter";
import type { Adapter } from "./transform/adapter";
import type { Runtime } from "./transform/runtime";
import { runtimes, isRuntime } from "./transform/runtime";
import { depsToEntries, isRemixPackage } from "./dependency";
import { remixSetup, remixSetupRuntime } from "./remixSetup";
import { because, detected } from "./messages";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const adapters = [
"architect",
"cloudflare-pages",
"cloudflare-workers",
"express",
"netlify",
"vercel",
] as const;
export type Adapter = typeof adapters[number];
export const isAdapter = (maybe: string): maybe is Adapter => {
return (adapters as readonly string[]).includes(maybe);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Adapter } from "./adapter";
import type { Runtime } from "./runtime";

export interface Options {
runtime: Runtime;
adapter?: Adapter;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const runtimes = ["cloudflare", "node"] as const;
export type Runtime = typeof runtimes[number];
export const isRuntime = (maybe: string): maybe is Runtime => {
return (runtimes as readonly string[]).includes(maybe);
};

0 comments on commit baa2183

Please sign in to comment.