Skip to content

Commit 2d02c8d

Browse files
author
Murat
committed
fix(import): blacklist some folders when importing
fix #74
1 parent e0f18e9 commit 2d02c8d

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/__tests__/unit/utils/upgrade/runUpgradeTasks.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ imports:
119119
expect(result.didRun).toBeTruthy();
120120
expect(mockFs.lstatSync).not.toHaveBeenCalled();
121121
});
122+
it('should skip blacklisted upgrade.yml imports', async () => {
123+
mockFs.writeFileSync('/oldProject/android/some.file', 'random');
124+
mockFs.writeFileSync('/oldProject/node_modules/some.file', 'random');
125+
mockFs.writeFileSync(
126+
path.join(getProjectPath(), '.upgrade/upgrade.yml'),
127+
`
128+
imports:
129+
- android
130+
- node_modules/some.file`
131+
);
132+
mockFs.lstatSync.mockClear();
133+
const result = await runUpgradeTasks('/oldProject');
134+
135+
expect(result.didRun).toBeTruthy();
136+
expect(mockFs.lstatSync).not.toHaveBeenCalled();
137+
});
122138
it('should skip when no old project path specified', async () => {
123139
mockFs.writeFileSync(
124140
path.join(getProjectPath(), '.upgrade/upgrade.yml'),

src/utils/upgrade/other/importPackageJson.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ export async function getInstallCommand(projectPath: string) {
180180
const isPnpmLockPresent = fs.existsSync(
181181
path.join(projectPath, 'pnpm-lock.yaml')
182182
);
183-
const isBunLockPresent = fs.existsSync(path.join(projectPath, 'bun.lockb'));
183+
const isBunLockPresent =
184+
fs.existsSync(path.join(projectPath, 'bun.lockb')) ||
185+
fs.existsSync(path.join(projectPath, 'bun.lock'));
184186

185187
const options: SelectOption[] = [];
186188
if (isNpmLockPresent) options.push({ label: 'npm', value: 'npm install' });

src/utils/upgrade/runUpgradeTasks.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,34 @@ export async function runUpgradeTasks(
7070
startSpinner(`discovering files from ${color.yellow('old project')}`);
7171

7272
const filesToCopy: string[] = [];
73+
const blackListedPaths = [
74+
'android',
75+
'ios',
76+
'.upgrade/',
77+
'node_modules/',
78+
'package.json',
79+
'integrate-lock.json',
80+
];
7381
for (let i = 0; i < config.imports.length; i++) {
7482
updateSpinner(
7583
`discovering files from ${color.yellow('old project')} (${i + 1}/${config.imports.length})`
7684
);
7785
const relativePath = getText(config.imports[i]);
86+
if (
87+
blackListedPaths.some(p => {
88+
if (p.endsWith('/'))
89+
return (
90+
relativePath.startsWith(p) ||
91+
relativePath === p.substring(0, p.length - 1)
92+
);
93+
return relativePath === p;
94+
})
95+
) {
96+
logWarning(
97+
`skipped import of ${color.yellow(relativePath)}, this path is handled internally so you can remove it from imports list.`
98+
);
99+
continue;
100+
}
78101
const importPath = path.join(oldProjectPath, relativePath);
79102
if (!fs.existsSync(importPath)) {
80103
logWarning(

0 commit comments

Comments
 (0)