Skip to content

Commit

Permalink
v1.92 (#174)
Browse files Browse the repository at this point in the history
* feat: Better detection of projects without an ionic.config.json

* feat: handle ionic multi-app projects

* chore: update version
  • Loading branch information
dtarnawsky authored Aug 13, 2024
1 parent 928df07 commit 2ead0ae
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 9 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.92.0

- Better detection of projects without an ionic.config.json

### Version 1.91.0

- Configurations of development and production added for React and Vue builds.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.91.1",
"version": "1.92.0",
"icon": "media/ionic.png",
"publisher": "Ionic",
"keywords": [
Expand Down
39 changes: 34 additions & 5 deletions src/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@ export function isFolderBasedMonoRepo(rootFolder: string): Array<MonoFolder> {
result.push({ name: folder, packageJson: packageJson, path: join(rootFolder, folder) });
}
}
if (result.length == 0) {
// It could be an ionic multi-app config file
const configFile = join(rootFolder, 'ionic.config.json');
if (existsSync(configFile)) {
const json: any = readFileSync(configFile);
const data: any = JSON.parse(json);
if (data.projects) {
for (const key of Object.keys(data.projects)) {
const project = data.projects[key];
if (project.root) {
const packageJson = join(rootFolder, project.root, 'package.json');
if (existsSync(packageJson)) {
result.push({ name: project.name, packageJson: packageJson, path: join(rootFolder, project.root) });
}
} else {
const packageJson = join(rootFolder, 'package.json');
if (existsSync(packageJson)) {
result.push({ name: project.name, packageJson: packageJson, path: join(rootFolder) });
}
}
}
}
}
}
return result;
}

Expand Down Expand Up @@ -220,11 +244,16 @@ function getFolderBasedProjects(prj: Project): Array<MonoRepoProject> {
}
const rootFolderType = checkFolder(join(prj.folder, 'package.json'));
if (rootFolderType == FolderType.hasIonic) {
// Its definitely an Ionic or Capacitor project in the root but we have sub folders that look like Ionic projects so throw error
writeError(
`This folder has Capacitor/Ionic dependencies but there are subfolders that do too which will be ignored (eg ${exampleFolder})`,
);
return [];
if (prj.folder == projects[0].path) {
// Sub folder is the root folder (eg ionic multi-app without a root)
} else {
// Its definitely an Ionic or Capacitor project in the root but we have sub folders that look like Ionic projects so throw error
writeError(
`This folder has Capacitor/Ionic dependencies but there are subfolders that do too which will be ignored (eg ${exampleFolder})`,
);

return [];
}
}
result = result.sort((a, b) => (a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1));
if (rootFolderType == FolderType.hasDependencies) {
Expand Down
9 changes: 8 additions & 1 deletion src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getCapacitorConfigDistFolder } from './capacitor-config-file';
import { Command, ExtensionContext, TreeItemCollapsibleState, commands, window } from 'vscode';
import { join } from 'path';
import { existsSync } from 'fs';
import { write } from './logging';
import { write, writeError } from './logging';
import { Features } from './features';

export class Project {
Expand Down Expand Up @@ -707,6 +707,10 @@ function guessFramework(project: Project) {
project.frameworkType = 'vue';
} else if (exists('@angular/core')) {
project.frameworkType = 'angular';
} else if (exists('@angular/cli')) {
project.frameworkType = 'angular-standalone';
} else if (exists('@ionic/angular')) {
project.frameworkType = 'angular-standalone';
} else if (exists('react-scripts')) {
project.frameworkType = 'react';
} else if (exists('vite')) {
Expand All @@ -717,6 +721,9 @@ function guessFramework(project: Project) {
project.frameworkType = 'vue-vite';
}
}
if (!project.frameworkType) {
writeError(`Unable to determine the framework type for ${project.name}`);
}
}

function getPackageManager(folder: string): PackageManager {
Expand Down
13 changes: 13 additions & 0 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface IonicConfig {
version?: string;
type: string; // ionic.config.json type
sessionId: string; // Generated
projects?: any;
defaultProject?: string;
}

export function sendTelemetryEvent(folder: string, name: string, context: ExtensionContext) {
Expand Down Expand Up @@ -171,6 +173,17 @@ export function getIonicConfig(folder: string): IonicConfig {
config.type = data.type;
} else {
config.type = 'unknown';
if (data.projects) {
const keys = Object.keys(data.projects);
if (keys.length > 0) {
if (data.defaultProject) {
config.type = data.projects[data.defaultProject].type;
} else {
// Assume the first project type
config.type = data.projects[keys[0]].type;
}
}
}
}
}
config.sessionId = config['tokens.telemetry'];
Expand Down

0 comments on commit 2ead0ae

Please sign in to comment.