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