Skip to content

Commit

Permalink
fix: yarn monorepos
Browse files Browse the repository at this point in the history
  • Loading branch information
dtarnawsky committed Oct 22, 2024
1 parent 47f3339 commit 72e8d45
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### Version 1.97

- Fix for Modern yarn monorepos

### Version 1.96

- For build command use `--` to ensure parameters are passed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ionic",
"displayName": "Ionic",
"description": "Official extension for Ionic and Capacitor development",
"version": "1.96.1",
"version": "1.97.0",
"icon": "media/ionic.png",
"publisher": "Ionic",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/process-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Command, Tip, TipType } from './tip';
import { Project } from './project';
import { getRunOutput, getStringFrom, setAllStringIn, stripJSON, tEnd, tStart } from './utilities';
import { NpmDependency, NpmOutdatedDependency, NpmPackage, PackageType, PackageVersion } from './npm-model';
import { listCommand, outdatedCommand } from './node-commands';
import { listCommand, outdatedCommand, PackageManager } from './node-commands';
import {
CapProjectCache,
LastManifestCheck,
Expand All @@ -14,7 +14,7 @@ import {
import { join } from 'path';
import { ionicState } from './ionic-tree-provider';
import { write, writeError, writeWarning } from './logging';
import { fixYarnV1Outdated, fixModernYarnList, fixYarnOutdated } from './monorepo';
import { fixYarnV1Outdated, fixModernYarnList, fixYarnOutdated, MonoRepoType } from './monorepo';
import { ExtensionContext, window } from 'vscode';
import { existsSync, lstatSync, readFileSync, readdirSync } from 'fs';
import { execSync } from 'child_process';
Expand Down
15 changes: 12 additions & 3 deletions src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export async function inspectProject(

const project: Project = new Project('My Project');
project.folder = folder;
project.packageManager = getPackageManager(folder);
project.packageManager = getPackageManager(folder, project.repoType);
ionicState.packageManager = project.packageManager;
ionicState.rootFolder = folder;
ionicState.projectRef = project;
Expand All @@ -677,7 +677,8 @@ export async function inspectProject(

if (project.monoRepo?.folder) {
// Use the package manager from the monorepo project
project.packageManager = getPackageManager(project.monoRepo.folder);
project.packageManager = getPackageManager(project.monoRepo.folder, project.repoType);

ionicState.packageManager = project.packageManager;
}
if (project.monoRepo?.localPackageJson) {
Expand Down Expand Up @@ -726,7 +727,7 @@ function guessFramework(project: Project) {
}
}

function getPackageManager(folder: string): PackageManager {
function getPackageManager(folder: string, monoRepoType: MonoRepoType): PackageManager {
const yarnLock = join(folder, 'yarn.lock');
const pnpmLock = join(folder, 'pnpm-lock.yaml');
const bunLock = join(folder, 'bun.lockb');
Expand All @@ -737,5 +738,13 @@ function getPackageManager(folder: string): PackageManager {
} else if (existsSync(bunLock)) {
return PackageManager.bun;
}

if (monoRepoType == MonoRepoType.yarn) {
const packageLock = join(folder, 'package-lock.json');
if (!packageLock) {
// Its a yarn monorepo so use yarn as package manager
return PackageManager.yarn;
}
}
return PackageManager.npm;
}

0 comments on commit 72e8d45

Please sign in to comment.