Skip to content

Commit 2ead0ae

Browse files
authored
v1.92 (#174)
* feat: Better detection of projects without an ionic.config.json * feat: handle ionic multi-app projects * chore: update version
1 parent 928df07 commit 2ead0ae

File tree

6 files changed

+62
-9
lines changed

6 files changed

+62
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog
22

3+
### Version 1.92.0
4+
5+
- Better detection of projects without an ionic.config.json
6+
37
### Version 1.91.0
48

59
- Configurations of development and production added for React and Vue builds.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ionic",
33
"displayName": "Ionic",
44
"description": "Official extension for Ionic and Capacitor development",
5-
"version": "1.91.1",
5+
"version": "1.92.0",
66
"icon": "media/ionic.png",
77
"publisher": "Ionic",
88
"keywords": [

src/monorepo.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,30 @@ export function isFolderBasedMonoRepo(rootFolder: string): Array<MonoFolder> {
162162
result.push({ name: folder, packageJson: packageJson, path: join(rootFolder, folder) });
163163
}
164164
}
165+
if (result.length == 0) {
166+
// It could be an ionic multi-app config file
167+
const configFile = join(rootFolder, 'ionic.config.json');
168+
if (existsSync(configFile)) {
169+
const json: any = readFileSync(configFile);
170+
const data: any = JSON.parse(json);
171+
if (data.projects) {
172+
for (const key of Object.keys(data.projects)) {
173+
const project = data.projects[key];
174+
if (project.root) {
175+
const packageJson = join(rootFolder, project.root, 'package.json');
176+
if (existsSync(packageJson)) {
177+
result.push({ name: project.name, packageJson: packageJson, path: join(rootFolder, project.root) });
178+
}
179+
} else {
180+
const packageJson = join(rootFolder, 'package.json');
181+
if (existsSync(packageJson)) {
182+
result.push({ name: project.name, packageJson: packageJson, path: join(rootFolder) });
183+
}
184+
}
185+
}
186+
}
187+
}
188+
}
165189
return result;
166190
}
167191

@@ -220,11 +244,16 @@ function getFolderBasedProjects(prj: Project): Array<MonoRepoProject> {
220244
}
221245
const rootFolderType = checkFolder(join(prj.folder, 'package.json'));
222246
if (rootFolderType == FolderType.hasIonic) {
223-
// Its definitely an Ionic or Capacitor project in the root but we have sub folders that look like Ionic projects so throw error
224-
writeError(
225-
`This folder has Capacitor/Ionic dependencies but there are subfolders that do too which will be ignored (eg ${exampleFolder})`,
226-
);
227-
return [];
247+
if (prj.folder == projects[0].path) {
248+
// Sub folder is the root folder (eg ionic multi-app without a root)
249+
} else {
250+
// Its definitely an Ionic or Capacitor project in the root but we have sub folders that look like Ionic projects so throw error
251+
writeError(
252+
`This folder has Capacitor/Ionic dependencies but there are subfolders that do too which will be ignored (eg ${exampleFolder})`,
253+
);
254+
255+
return [];
256+
}
228257
}
229258
result = result.sort((a, b) => (a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1));
230259
if (rootFolderType == FolderType.hasDependencies) {

src/project.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getCapacitorConfigDistFolder } from './capacitor-config-file';
1818
import { Command, ExtensionContext, TreeItemCollapsibleState, commands, window } from 'vscode';
1919
import { join } from 'path';
2020
import { existsSync } from 'fs';
21-
import { write } from './logging';
21+
import { write, writeError } from './logging';
2222
import { Features } from './features';
2323

2424
export class Project {
@@ -707,6 +707,10 @@ function guessFramework(project: Project) {
707707
project.frameworkType = 'vue';
708708
} else if (exists('@angular/core')) {
709709
project.frameworkType = 'angular';
710+
} else if (exists('@angular/cli')) {
711+
project.frameworkType = 'angular-standalone';
712+
} else if (exists('@ionic/angular')) {
713+
project.frameworkType = 'angular-standalone';
710714
} else if (exists('react-scripts')) {
711715
project.frameworkType = 'react';
712716
} else if (exists('vite')) {
@@ -717,6 +721,9 @@ function guessFramework(project: Project) {
717721
project.frameworkType = 'vue-vite';
718722
}
719723
}
724+
if (!project.frameworkType) {
725+
writeError(`Unable to determine the framework type for ${project.name}`);
726+
}
720727
}
721728

722729
function getPackageManager(folder: string): PackageManager {

src/telemetry.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export interface IonicConfig {
4040
version?: string;
4141
type: string; // ionic.config.json type
4242
sessionId: string; // Generated
43+
projects?: any;
44+
defaultProject?: string;
4345
}
4446

4547
export function sendTelemetryEvent(folder: string, name: string, context: ExtensionContext) {
@@ -171,6 +173,17 @@ export function getIonicConfig(folder: string): IonicConfig {
171173
config.type = data.type;
172174
} else {
173175
config.type = 'unknown';
176+
if (data.projects) {
177+
const keys = Object.keys(data.projects);
178+
if (keys.length > 0) {
179+
if (data.defaultProject) {
180+
config.type = data.projects[data.defaultProject].type;
181+
} else {
182+
// Assume the first project type
183+
config.type = data.projects[keys[0]].type;
184+
}
185+
}
186+
}
174187
}
175188
}
176189
config.sessionId = config['tokens.telemetry'];

0 commit comments

Comments
 (0)