diff --git a/lib/controllers/migrate-controller.ts b/lib/controllers/migrate-controller.ts index 37247d473b..c296ce621a 100644 --- a/lib/controllers/migrate-controller.ts +++ b/lib/controllers/migrate-controller.ts @@ -337,7 +337,7 @@ export class MigrateController }); if (shouldMigrate) { this.$errors.fail( - `The current application is not compatible with NativeScript CLI 7.0.\n\nRun 'ns migrate' to migrate your project to NativeScript 7.\n\nAlternatively you may try running it with '--force' to skip this check.` + `The current application is not compatible with NativeScript CLI ${this.$staticConfig.version}.\n\nRun 'ns migrate' to migrate your project to the latest NativeScript version.\n\nAlternatively you may try running it with '--force' to skip this check.` ); } } @@ -1476,6 +1476,18 @@ export class MigrateController packageName: "vue-loader", shouldRemove: true, }, + { + packageName: "babel-loader", + shouldRemove: true, + }, + { + packageName: "@babel/core", + shouldRemove: true, + }, + { + packageName: "@babel/preset-env", + shouldRemove: true, + }, // remove any version of vue { packageName: "vue", @@ -1606,7 +1618,7 @@ export class MigrateController this.spinner.succeed(`Initialized new ${"webpack.config.js".yellow}`); const packageJSON = this.$fs.readJson(projectData.projectFilePath); - const currentMain = packageJSON.main; + const currentMain = packageJSON.main ?? "app.js"; const currentMainTS = currentMain.replace(/.js$/, ".ts"); const appPath = projectData.appDirectoryPath; @@ -1614,10 +1626,16 @@ export class MigrateController const possibleMains = [ `./${appPath}/${currentMain}`, `./${appPath}/${currentMainTS}`, + `./${appPath}/main.js`, + `./${appPath}/main.ts`, `./app/${currentMain}`, `./app/${currentMainTS}`, `./src/${currentMain}`, `./src/${currentMainTS}`, + `./app/main.js`, + `./app/main.ts`, + `./src/main.js`, + `./src/main.ts`, ]; const replacedMain = possibleMains.find((possibleMain) => { return this.$fs.exists(path.resolve(projectDir, possibleMain)); @@ -1640,16 +1658,29 @@ export class MigrateController } private async runESLint(projectDir: string) { - // todo: run @nativescript/eslint-plugin on project folder to update imports - // const childProcess = injector.resolve('childProcess') as IChildProcess; - // const args = [ - // 'npx', - // '--package typescript', - // '--package @nativescript/eslint-plugin', - // '-c eslint-plugin', - // projectDir - // ] - // await childProcess.exec(args.join(' ')) + this.spinner.start(`Running ESLint fixes`); + try { + const childProcess = injector.resolve("childProcess") as IChildProcess; + const npxVersion = await childProcess.exec("npx -v"); + + const npxFlags = []; + + if (semver.gt(semver.coerce(npxVersion), "7.0.0")) { + npxFlags.push("-y"); + } + + const args = [ + "npx", + ...npxFlags, + "@nativescript/eslint-plugin", + projectDir, + ]; + await childProcess.exec(args.join(" ")); + this.spinner.succeed(`Applied ESLint fixes`); + } catch (err) { + this.spinner.fail(`Failed to apply ESLint fixes`); + this.$logger.trace("Failed to apply ESLint fixes. Error is:", err); + } } } diff --git a/lib/data/prepare-data.ts b/lib/data/prepare-data.ts index 94a5a5de17..e51f7f3630 100644 --- a/lib/data/prepare-data.ts +++ b/lib/data/prepare-data.ts @@ -11,10 +11,25 @@ export class PrepareData extends ControllerDataBase { constructor(public projectDir: string, public platform: string, data: any) { super(projectDir, platform, data); + const env: any = {}; + + if (Array.isArray(data.env)) { + data.env.forEach((flag: string | object) => { + if (typeof flag === "string") { + env.env = flag; + return; + } + + Object.assign(env, flag); + }); + } else { + Object.assign(env, data.env); + } + this.release = data.release; this.hmr = data.hmr || data.useHotModuleReload; this.env = { - ...data.env, + ...env, hmr: data.hmr || data.useHotModuleReload, }; this.watch = data.watch; diff --git a/lib/services/marking-mode-service.ts b/lib/services/marking-mode-service.ts index 9f0a75d61f..47847de66e 100644 --- a/lib/services/marking-mode-service.ts +++ b/lib/services/marking-mode-service.ts @@ -14,7 +14,7 @@ const enum MarkingMode { } const MARKING_MODE_PROP = "markingMode"; -const MARKING_MODE_FULL_DEPRECATION_MSG = `In NativeScript 7.0 "${MARKING_MODE_PROP}:${MarkingMode.Full}" is no longer supported.`; +const MARKING_MODE_FULL_DEPRECATION_MSG = `In the current version of NativeScript "${MARKING_MODE_PROP}:${MarkingMode.Full}" is no longer supported.`; export class MarkingModeService implements IMarkingModeService { constructor( diff --git a/lib/services/project-config-service.ts b/lib/services/project-config-service.ts index 586f4df867..e17d926260 100644 --- a/lib/services/project-config-service.ts +++ b/lib/services/project-config-service.ts @@ -89,7 +89,7 @@ export default { return; } this.$logger.warn( - `You are using the deprecated ${CONFIG_NS_FILE_NAME} file. Just be aware that NativeScript 7 has an improved ${CONFIG_FILE_NAME_DISPLAY} file for when you're ready to upgrade this project.` + `You are using the deprecated ${CONFIG_NS_FILE_NAME} file. Just be aware that NativeScript now has an improved ${CONFIG_FILE_NAME_DISPLAY} file for when you're ready to upgrade this project.` ); }