cleanup(expo): replace fs-extra with node:fs (#28117)
This commit is contained in:
parent
28c12b50bd
commit
56eabffb2b
@ -50,6 +50,10 @@
|
||||
{
|
||||
"name": "chalk",
|
||||
"message": "Please use `picocolors` in place of `chalk` for rendering terminal colors"
|
||||
},
|
||||
{
|
||||
"name": "fs-extra",
|
||||
"message": "Please use equivalent utilities from `node:fs` instead."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
"@nx/web": "file:../web",
|
||||
"@nx/webpack": "file:../webpack",
|
||||
"enhanced-resolve": "^5.8.3",
|
||||
"fs-extra": "^11.1.0",
|
||||
"metro-config": "~0.80.4",
|
||||
"metro-resolver": "~0.80.4",
|
||||
"node-fetch": "^2.6.7",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { workspaceRoot } from '@nx/devkit';
|
||||
import { mergeConfig } from 'metro-config';
|
||||
import type { MetroConfig } from 'metro-config';
|
||||
import { existsSync, readdirSync, statSync } from 'fs-extra';
|
||||
import { existsSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { getResolveRequest } from './metro-resolver';
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import {
|
||||
detectPackageManager,
|
||||
ExecutorContext,
|
||||
getPackageManagerCommand,
|
||||
names,
|
||||
PackageManager,
|
||||
readJsonFile,
|
||||
writeJsonFile,
|
||||
} from '@nx/devkit';
|
||||
import { getLockFileName } from '@nx/js';
|
||||
import { copyFileSync, existsSync, removeSync, writeFileSync } from 'fs-extra';
|
||||
import { resolve as pathResolve } from 'path';
|
||||
import { ChildProcess, fork } from 'child_process';
|
||||
import { copyFileSync, existsSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { resolve as pathResolve } from 'path';
|
||||
import type { PackageJson } from 'nx/src/utils/package-json';
|
||||
|
||||
import { resolveEas } from '../../utils/resolve-eas';
|
||||
@ -144,10 +144,7 @@ function copyPackageJsonAndLock(
|
||||
projectPackageJson.devDependencies = rootPackageJsonDevDependencies;
|
||||
|
||||
// Copy dependencies from root package.json to project package.json
|
||||
writeFileSync(
|
||||
packageJsonProject,
|
||||
JSON.stringify(projectPackageJson, null, 2)
|
||||
);
|
||||
writeJsonFile(packageJsonProject, projectPackageJson);
|
||||
|
||||
// Copy lock file from root to project
|
||||
copyFileSync(lockFile, lockFileProject);
|
||||
@ -162,6 +159,6 @@ function copyPackageJsonAndLock(
|
||||
);
|
||||
|
||||
// Remove lock file from project
|
||||
removeSync(lockFileProject);
|
||||
rmSync(lockFileProject, { recursive: true, force: true });
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { ExecutorContext, names } from '@nx/devkit';
|
||||
import { join, resolve as pathResolve } from 'path';
|
||||
import { ChildProcess, fork } from 'child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { platform } from 'os';
|
||||
import { existsSync } from 'fs-extra';
|
||||
import { join, resolve as pathResolve } from 'path';
|
||||
|
||||
import { ExpoRunOptions } from './schema';
|
||||
import { prebuildAsync } from '../prebuild/prebuild.impl';
|
||||
|
||||
@ -4,7 +4,7 @@ import {
|
||||
getProjects,
|
||||
updateProjectConfiguration,
|
||||
} from '@nx/devkit';
|
||||
import { removeSync } from 'fs-extra';
|
||||
import { rmSync } from 'node:fs';
|
||||
|
||||
/**
|
||||
* Remove ensure-symlink target.
|
||||
@ -19,7 +19,7 @@ export default async function update(tree: Tree) {
|
||||
) {
|
||||
removeTargets(config.targets, 'ensure-symlink');
|
||||
updateProjectConfiguration(tree, projectName, config);
|
||||
removeSync(`${config.root}/node_modules`);
|
||||
rmSync(`${config.root}/node_modules`, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { Tree, getProjects } from '@nx/devkit';
|
||||
import { removeSync } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'os';
|
||||
import { join } from 'path';
|
||||
import { existsSync, mkdirSync, removeSync, writeFileSync } from 'fs-extra';
|
||||
import { ensureNodeModulesSymlink } from './ensure-node-modules-symlink';
|
||||
|
||||
const workspaceDir = join(tmpdir(), 'nx-react-native-test');
|
||||
@ -9,8 +9,9 @@ const appDirAbsolutePath = join(workspaceDir, appDir);
|
||||
|
||||
describe('ensureNodeModulesSymlink', () => {
|
||||
beforeEach(() => {
|
||||
if (existsSync(workspaceDir)) removeSync(workspaceDir);
|
||||
mkdirSync(workspaceDir);
|
||||
if (existsSync(workspaceDir))
|
||||
rmSync(workspaceDir, { recursive: true, force: true });
|
||||
mkdirSync(workspaceDir, { recursive: true });
|
||||
mkdirSync(appDirAbsolutePath, { recursive: true });
|
||||
mkdirSync(appDirAbsolutePath, { recursive: true });
|
||||
writeFileSync(
|
||||
@ -35,7 +36,8 @@ describe('ensureNodeModulesSymlink', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (existsSync(workspaceDir)) removeSync(workspaceDir);
|
||||
if (existsSync(workspaceDir))
|
||||
rmSync(workspaceDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('should create symlinks', () => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { join } from 'path';
|
||||
import { existsSync, rmSync, symlinkSync } from 'node:fs';
|
||||
import { platform } from 'os';
|
||||
import { existsSync, removeSync, symlinkSync } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
|
||||
/**
|
||||
* This function symlink workspace node_modules folder with app project's node_mdules folder.
|
||||
@ -24,7 +24,7 @@ export function ensureNodeModulesSymlink(
|
||||
const symlinkType = platform() === 'win32' ? 'junction' : 'dir';
|
||||
|
||||
if (existsSync(appNodeModulesPath)) {
|
||||
removeSync(appNodeModulesPath);
|
||||
rmSync(appNodeModulesPath, { recursive: true, force: true });
|
||||
}
|
||||
symlinkSync(worksapceNodeModulesPath, appNodeModulesPath, symlinkType);
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { execSync } from 'child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { platform } from 'os';
|
||||
import { join } from 'path';
|
||||
import * as pc from 'picocolors';
|
||||
import { GeneratorCallback, logger } from '@nx/devkit';
|
||||
import { existsSync } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
|
||||
const podInstallErrorMessage = `
|
||||
Running ${pc.bold('pod install')} failed, see above.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user