Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(remix-dev): convert config.appDirectory to relative unix path #4709

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
readJSONSync,
realpathSync,
removeSync,
readFile,
} from "fs-extra";
import shell from "shelljs";
import stripAnsi from "strip-ansi";
Expand Down Expand Up @@ -98,6 +99,13 @@ const checkMigrationRanSuccessfully = async (projectDir: string) => {
expect(exportDefaultResult.stdout.trim()).toBe("");
expect(exportDefaultResult.stderr).toBeNull();
expect(exportDefaultResult.code).toBe(0);

let rootRouteContent = await readFile(
join(projectDir, "app", "root.jsx"),
"utf-8"
);

expect(rootRouteContent).not.toContain('require("@remix-run/react")');
};

const makeApp = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from "path";
import path from "path";
import glob from "fast-glob";

import { readConfig } from "../../../../config";
Expand All @@ -9,7 +9,7 @@ import { convertTSConfigs } from "./convertTSConfigs";
import { convertTSFilesToJS } from "./convertTSFilesToJS";
import { CliError } from "../../../error";

const TRANSFORM_PATH = join(__dirname, "transform");
const TRANSFORM_PATH = path.join(__dirname, "transform");

export const convertToJavaScript: MigrationFunction = async (
projectDir,
Expand All @@ -23,11 +23,20 @@ export const convertToJavaScript: MigrationFunction = async (
// 2. Remove @types/* & TypeScript dependencies + `typecheck` script from `package.json`
await cleanupPackageJson(config.rootDirectory);

// 3. Run codemod
// 3. cConvert appDirectory to relative and force unix style path
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
let relativeAppDirectory = path.relative(
config.rootDirectory,
config.appDirectory
);
let unixAppDirectory = path.posix.join(
...relativeAppDirectory.split(path.delimiter)
);

// 4. Run codemod
let files = glob.sync("**/*.+(ts|tsx)", {
absolute: true,
cwd: config.rootDirectory,
ignore: [`./${config.appDirectory}/**/*`, "**/node_modules/**"],
ignore: [`${unixAppDirectory}/**/*`, "**/node_modules/**"],
});
let codemodOk = await jscodeshift.run({
files,
Expand Down