Skip to content

Commit 606aabb

Browse files
committed
feat: support monorepo-aware package installation (#1)
1 parent 86c9f30 commit 606aabb

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

packages/setup/lib/commit-lint-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { execSync } from 'child_process';
22
import { COMMANDS } from 'const/commands.ts';
33
import { packageManagerInstallChoices } from 'const/packagesMng.ts';
44
import fs from 'fs';
5+
import checkIsMonorepo from 'lib/check-is-monorepo.js';
56
import detectPackageManager from 'lib/detect-package-manger.ts';
67
import getSettingFilePath from 'lib/get-setting-file-path.ts';
78
import path from 'path';
@@ -32,7 +33,7 @@ const installDependencies = async (): Promise<void> => {
3233
}
3334
}
3435
const installCommand = `${packageMng} ${dependencies.join(' ')}`;
35-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
36+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
3637
} catch (error) {
3738
console.error("🥲 🥲 🥲 Failed to install commitlint's dependencies...");
3839
process.exit(1);

packages/setup/lib/eslint-config.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { execSync } from 'child_process';
22
import { packageManagerInstallChoices } from 'const/packagesMng.ts';
33
import fs from 'fs';
4+
import checkIsMonorepo from 'lib/check-is-monorepo.js';
45
import detectPackageManager from 'lib/detect-package-manger.ts';
56
import getSettingFilePath from 'lib/get-setting-file-path.ts';
67
import path from 'path';
@@ -32,7 +33,7 @@ const installImportSortDependencies = async (): Promise<void> => {
3233
}
3334
}
3435
const installCommand = `${packageMng} ${dependencies}`;
35-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
36+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
3637
} catch (error) {
3738
console.error('🥲 🥲 🥲 Failed to install dependencies...');
3839
process.exit(1);
@@ -65,7 +66,7 @@ const installAirbnbDependencies = async (): Promise<void> => {
6566
}
6667
}
6768
const installCommand = `${packageMng} ${dependencies}`;
68-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
69+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
6970
} catch (error) {
7071
console.error('🥲 🥲 🥲 Failed to install dependencies...');
7172
process.exit(1);
@@ -97,7 +98,7 @@ const installGoogleDependencies = async (): Promise<void> => {
9798
}
9899
}
99100
const installCommand = `${packageMng} ${dependencies}`;
100-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
101+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
101102
} catch (error) {
102103
console.error('🥲 🥲 🥲 Failed to install dependencies...');
103104
process.exit(1);
@@ -129,7 +130,7 @@ const installXODependencies = async (): Promise<void> => {
129130
}
130131
}
131132
const installCommand = `${packageMng} ${dependencies}`;
132-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
133+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
133134
} catch (error) {
134135
console.error('🥲 🥲 🥲 Failed to install dependencies...');
135136
process.exit(1);

packages/setup/lib/husky-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from 'child_process';
22
import { packageManagerInstallChoices } from 'const/packagesMng.ts';
3+
import checkIsMonorepo from 'lib/check-is-monorepo.js';
34
import detectPackageManager from 'lib/detect-package-manger.ts';
45
import path from 'path';
56
import { select } from '@inquirer/prompts';
@@ -26,7 +27,7 @@ const installDependencies = async (): Promise<void> => {
2627
}
2728
}
2829
const installCommand = `${packageMng} ${dependencies}`;
29-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
30+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
3031
} catch (error) {
3132
console.error('🥲 🥲 🥲 Failed to install dependencies...');
3233
process.exit(1);

packages/setup/lib/prettier-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { execSync } from 'child_process';
22
import { COMMANDS } from 'const/commands.ts';
33
import { packageManagerInstallChoices } from 'const/packagesMng.ts';
44
import fs from 'fs';
5+
import checkIsMonorepo from 'lib/check-is-monorepo.js';
56
import detectPackageManager from 'lib/detect-package-manger.ts';
67
import getSettingFilePath from 'lib/get-setting-file-path.ts';
78
import path from 'path';
@@ -28,7 +29,7 @@ const installDependencies = async (): Promise<void> => {
2829
}
2930
}
3031
const installCommand = `${packageMng} ${dependencies}`;
31-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
32+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
3233
} catch (error) {
3334
console.error('🥲 Fail to install prettier dependencies.... to \n' + error);
3435
process.exit(1);

packages/setup/lib/typescript-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from 'child_process';
22
import { packageManagerInstallChoices } from 'const/packagesMng.ts';
3+
import checkIsMonorepo from 'lib/check-is-monorepo.js';
34
import detectPackageManager from 'lib/detect-package-manger.ts';
45
import { select } from '@inquirer/prompts';
56

@@ -28,7 +29,7 @@ const installDependencies = async (): Promise<void> => {
2829
}
2930
}
3031
const installCommand = `${packageMng} ${dependencies}`;
31-
execSync(`${installCommand} -D`, { stdio: 'inherit' });
32+
execSync(`${installCommand} -D ${checkIsMonorepo() ? '-w' : ''}`, { stdio: 'inherit' });
3233
} catch (error) {
3334
console.error('🥲 🥲 🥲 Failed to install dependencies...');
3435
process.exit(1);

0 commit comments

Comments
 (0)