From 72e8d45191ec3afb4491b0f253210bbe8a0b0d64 Mon Sep 17 00:00:00 2001 From: "damian.ionic" Date: Tue, 22 Oct 2024 12:05:35 -0700 Subject: [PATCH 1/2] fix: yarn monorepos --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/process-packages.ts | 4 ++-- src/project.ts | 15 ++++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a12c5d..d87e2d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 2f35256..ea4c349 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/process-packages.ts b/src/process-packages.ts index f132490..ea20590 100755 --- a/src/process-packages.ts +++ b/src/process-packages.ts @@ -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, @@ -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'; diff --git a/src/project.ts b/src/project.ts index 705c8ee..d065f67 100755 --- a/src/project.ts +++ b/src/project.ts @@ -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; @@ -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) { @@ -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'); @@ -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; } From a237017c3adc030a540b8c90b17f94f85d079729 Mon Sep 17 00:00:00 2001 From: "damian.ionic" Date: Tue, 22 Oct 2024 12:51:58 -0700 Subject: [PATCH 2/2] fix: bug in package lock check --- package.json | 2 +- src/project.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ea4c349..ec2bcd3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ionic", "displayName": "Ionic", "description": "Official extension for Ionic and Capacitor development", - "version": "1.97.0", + "version": "1.97.1", "icon": "media/ionic.png", "publisher": "Ionic", "keywords": [ diff --git a/src/project.ts b/src/project.ts index d065f67..8d8fce4 100755 --- a/src/project.ts +++ b/src/project.ts @@ -741,7 +741,7 @@ function getPackageManager(folder: string, monoRepoType: MonoRepoType): PackageM if (monoRepoType == MonoRepoType.yarn) { const packageLock = join(folder, 'package-lock.json'); - if (!packageLock) { + if (!existsSync(packageLock)) { // Its a yarn monorepo so use yarn as package manager return PackageManager.yarn; }