Skip to content

Commit d1729cf

Browse files
committed
feat: improved migrations for app path and resource paths
1 parent 5d8f4ec commit d1729cf

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

lib/controllers/migrate-controller.ts

+53-4
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
113113
private migrationDependencies: IMigrationDependency[] = [
114114
{
115115
packageName: constants.SCOPED_TNS_CORE_MODULES,
116-
verifiedVersion: "7.0.0-rc.57",
116+
verifiedVersion: "7.0.0",
117117
shouldAddIfMissing: true,
118118
},
119119
{
@@ -122,13 +122,13 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
122122
},
123123
{
124124
packageName: "@nativescript/types",
125-
verifiedVersion: "7.0.0-rc.0",
125+
verifiedVersion: "7.0.0",
126126
isDev: true,
127127
},
128128
{
129129
packageName: "tns-platform-declarations",
130130
replaceWith: "@nativescript/types",
131-
verifiedVersion: "7.0.0-rc.0",
131+
verifiedVersion: "7.0.0",
132132
isDev: true,
133133
},
134134
{
@@ -141,7 +141,7 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
141141
},
142142
{
143143
packageName: constants.WEBPACK_PLUGIN_NAME,
144-
verifiedVersion: "3.0.0-rc.2",
144+
verifiedVersion: "3.0.0",
145145
shouldAddIfMissing: true,
146146
isDev: true,
147147
},
@@ -879,6 +879,55 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
879879
delete rootPackageJsonData.nativescript;
880880
}
881881

882+
// detect path to src and App_Resources
883+
const possibleAppPaths = [
884+
path.resolve(projectData.projectDir, constants.SRC_DIR),
885+
path.resolve(projectData.projectDir, constants.APP_FOLDER_NAME),
886+
];
887+
888+
const appPath = possibleAppPaths.find((possiblePath) =>
889+
this.$fs.exists(possiblePath)
890+
);
891+
if (appPath) {
892+
const relativeAppPath = path
893+
.relative(projectData.projectDir, appPath)
894+
.replace(path.sep, "/");
895+
this.$logger.trace(
896+
`Found app source at '${appPath}'. Writing '${relativeAppPath}' to config.`
897+
);
898+
const ok = await this.$projectConfigService.setValue(
899+
"appPath",
900+
relativeAppPath.toString()
901+
);
902+
this.$logger.trace(ok ? `Ok...` : "Could not write...");
903+
}
904+
905+
const possibleAppResourcesPaths = [
906+
path.resolve(
907+
projectData.projectDir,
908+
appPath,
909+
constants.APP_RESOURCES_FOLDER_NAME
910+
),
911+
path.resolve(projectData.projectDir, constants.APP_RESOURCES_FOLDER_NAME),
912+
];
913+
914+
const appResourcesPath = possibleAppResourcesPaths.find((possiblePath) =>
915+
this.$fs.exists(possiblePath)
916+
);
917+
if (appResourcesPath) {
918+
const relativeAppResourcesPath = path
919+
.relative(projectData.projectDir, appResourcesPath)
920+
.replace(path.sep, "/");
921+
this.$logger.trace(
922+
`Found App_Resources at '${appResourcesPath}'. Writing '${relativeAppResourcesPath}' to config.`
923+
);
924+
const ok = await this.$projectConfigService.setValue(
925+
"appResourcesPath",
926+
relativeAppResourcesPath.toString()
927+
);
928+
this.$logger.trace(ok ? `Ok...` : "Could not write...");
929+
}
930+
882931
// save root package.json
883932
this.$fs.writeJson(rootPackageJsonPath, rootPackageJsonData);
884933

0 commit comments

Comments
 (0)