Skip to content

Commit 0675896

Browse files
authored
fix: default appPath in new projects (#5466)
1 parent fde4403 commit 0675896

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

lib/definitions/project.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ interface IProjectConfigService {
369369

370370
detectProjectConfigs(projectDir?: string): IProjectConfigInformation;
371371

372-
getDefaultTSConfig(appId: string): string;
372+
getDefaultTSConfig(appId: string, appPath: string): string;
373373

374374
writeDefaultConfig(projectDir?: string, appId?: string): boolean | string;
375375

lib/services/project-config-service.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ export class ProjectConfigService implements IProjectConfigService {
6464
return this.$injector.resolve("projectHelper");
6565
}
6666

67-
public getDefaultTSConfig(appId: string = "org.nativescript.app") {
67+
public getDefaultTSConfig(
68+
appId: string = "org.nativescript.app",
69+
appPath: string = "app"
70+
) {
6871
return `import { NativeScriptConfig } from '@nativescript/core';
6972
7073
export default {
7174
id: '${appId}',
75+
appPath: '${appPath}',
7276
appResourcesPath: 'App_Resources',
7377
android: {
7478
v8Flags: '--expose_gc',
@@ -274,7 +278,19 @@ export default {
274278
return false;
275279
}
276280

277-
this.$fs.writeFile(TSConfigPath, this.getDefaultTSConfig(appId));
281+
const possibleAppPaths = [
282+
path.resolve(projectDir, constants.SRC_DIR),
283+
path.resolve(projectDir, constants.APP_FOLDER_NAME),
284+
];
285+
286+
let appPath = possibleAppPaths.find((possiblePath) =>
287+
this.$fs.exists(possiblePath)
288+
);
289+
if (appPath) {
290+
appPath = path.relative(projectDir, appPath).replace(path.sep, "/");
291+
}
292+
293+
this.$fs.writeFile(TSConfigPath, this.getDefaultTSConfig(appId, appPath));
278294

279295
return TSConfigPath;
280296
}

test/stubs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,12 @@ export class ProjectConfigServiceStub implements IProjectConfigService {
622622
};
623623
}
624624

625-
getDefaultTSConfig(appId: string): string {
625+
getDefaultTSConfig(appId: string, appPath: string): string {
626626
return `import { NativeScriptConfig } from '@nativescript/core';
627627
628628
export default {
629629
id: '${appId}',
630+
appPath: '${appPath}'
630631
appResourcesPath: 'App_Resources',
631632
android: {
632633
v8Flags: '--expose_gc',

0 commit comments

Comments
 (0)