Skip to content

Commit 48cc070

Browse files
feat(cli): conditionally add workspace packages
1 parent 12ab01a commit 48cc070

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

apps/cli/src/helpers/core/workspace-setup.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,21 @@ export async function setupWorkspaceDependencies(
5151

5252
const serverPackageDir = path.join(projectDir, "apps/server");
5353
if (await fs.pathExists(serverPackageDir)) {
54+
const serverDeps: Record<string, string> = {};
55+
if (await fs.pathExists(apiPackageDir)) {
56+
serverDeps[`@${projectName}/api`] = workspaceVersion;
57+
}
58+
if (await fs.pathExists(authPackageDir)) {
59+
serverDeps[`@${projectName}/auth`] = workspaceVersion;
60+
}
61+
if (await fs.pathExists(dbPackageDir)) {
62+
serverDeps[`@${projectName}/db`] = workspaceVersion;
63+
}
64+
5465
await addPackageDependency({
5566
dependencies: commonDeps,
5667
devDependencies: commonDevDeps,
57-
customDependencies: {
58-
[`@${projectName}/api`]: workspaceVersion,
59-
[`@${projectName}/auth`]: workspaceVersion,
60-
[`@${projectName}/db`]: workspaceVersion,
61-
},
68+
customDependencies: serverDeps,
6269
projectDir: serverPackageDir,
6370
});
6471
}
@@ -67,9 +74,12 @@ export async function setupWorkspaceDependencies(
6774

6875
if (await fs.pathExists(webPackageDir)) {
6976
const webDeps: Record<string, string> = {};
70-
71-
webDeps[`@${projectName}/api`] = workspaceVersion;
72-
webDeps[`@${projectName}/auth`] = workspaceVersion;
77+
if (await fs.pathExists(apiPackageDir)) {
78+
webDeps[`@${projectName}/api`] = workspaceVersion;
79+
}
80+
if (await fs.pathExists(authPackageDir)) {
81+
webDeps[`@${projectName}/auth`] = workspaceVersion;
82+
}
7383

7484
if (Object.keys(webDeps).length > 0) {
7585
await addPackageDependency({
@@ -83,8 +93,9 @@ export async function setupWorkspaceDependencies(
8393

8494
if (await fs.pathExists(nativePackageDir)) {
8595
const nativeDeps: Record<string, string> = {};
86-
87-
nativeDeps[`@${projectName}/api`] = workspaceVersion;
96+
if (await fs.pathExists(apiPackageDir)) {
97+
nativeDeps[`@${projectName}/api`] = workspaceVersion;
98+
}
8899

89100
if (Object.keys(nativeDeps).length > 0) {
90101
await addPackageDependency({

0 commit comments

Comments
 (0)