Skip to content

Commit 54829de

Browse files
authored
chore: merge 8.0.0 patches (#5511)
fix: 8.0.0 patches
2 parents 0c01ddd + fa13c52 commit 54829de

File tree

4 files changed

+61
-15
lines changed

4 files changed

+61
-15
lines changed

lib/controllers/migrate-controller.ts

+43-12
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export class MigrateController
337337
});
338338
if (shouldMigrate) {
339339
this.$errors.fail(
340-
`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.`
340+
`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.`
341341
);
342342
}
343343
}
@@ -1476,6 +1476,18 @@ export class MigrateController
14761476
packageName: "vue-loader",
14771477
shouldRemove: true,
14781478
},
1479+
{
1480+
packageName: "babel-loader",
1481+
shouldRemove: true,
1482+
},
1483+
{
1484+
packageName: "@babel/core",
1485+
shouldRemove: true,
1486+
},
1487+
{
1488+
packageName: "@babel/preset-env",
1489+
shouldRemove: true,
1490+
},
14791491
// remove any version of vue
14801492
{
14811493
packageName: "vue",
@@ -1606,18 +1618,24 @@ export class MigrateController
16061618
this.spinner.succeed(`Initialized new ${"webpack.config.js".yellow}`);
16071619

16081620
const packageJSON = this.$fs.readJson(projectData.projectFilePath);
1609-
const currentMain = packageJSON.main;
1621+
const currentMain = packageJSON.main ?? "app.js";
16101622
const currentMainTS = currentMain.replace(/.js$/, ".ts");
16111623

16121624
const appPath = projectData.appDirectoryPath;
16131625

16141626
const possibleMains = [
16151627
`./${appPath}/${currentMain}`,
16161628
`./${appPath}/${currentMainTS}`,
1629+
`./${appPath}/main.js`,
1630+
`./${appPath}/main.ts`,
16171631
`./app/${currentMain}`,
16181632
`./app/${currentMainTS}`,
16191633
`./src/${currentMain}`,
16201634
`./src/${currentMainTS}`,
1635+
`./app/main.js`,
1636+
`./app/main.ts`,
1637+
`./src/main.js`,
1638+
`./src/main.ts`,
16211639
];
16221640
const replacedMain = possibleMains.find((possibleMain) => {
16231641
return this.$fs.exists(path.resolve(projectDir, possibleMain));
@@ -1640,16 +1658,29 @@ export class MigrateController
16401658
}
16411659

16421660
private async runESLint(projectDir: string) {
1643-
// todo: run @nativescript/eslint-plugin on project folder to update imports
1644-
// const childProcess = injector.resolve('childProcess') as IChildProcess;
1645-
// const args = [
1646-
// 'npx',
1647-
// '--package typescript',
1648-
// '--package @nativescript/eslint-plugin',
1649-
// '-c eslint-plugin',
1650-
// projectDir
1651-
// ]
1652-
// await childProcess.exec(args.join(' '))
1661+
this.spinner.start(`Running ESLint fixes`);
1662+
try {
1663+
const childProcess = injector.resolve("childProcess") as IChildProcess;
1664+
const npxVersion = await childProcess.exec("npx -v");
1665+
1666+
const npxFlags = [];
1667+
1668+
if (semver.gt(semver.coerce(npxVersion), "7.0.0")) {
1669+
npxFlags.push("-y");
1670+
}
1671+
1672+
const args = [
1673+
"npx",
1674+
...npxFlags,
1675+
"@nativescript/eslint-plugin",
1676+
projectDir,
1677+
];
1678+
await childProcess.exec(args.join(" "));
1679+
this.spinner.succeed(`Applied ESLint fixes`);
1680+
} catch (err) {
1681+
this.spinner.fail(`Failed to apply ESLint fixes`);
1682+
this.$logger.trace("Failed to apply ESLint fixes. Error is:", err);
1683+
}
16531684
}
16541685
}
16551686

lib/data/prepare-data.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,25 @@ export class PrepareData extends ControllerDataBase {
1111
constructor(public projectDir: string, public platform: string, data: any) {
1212
super(projectDir, platform, data);
1313

14+
const env: any = {};
15+
16+
if (Array.isArray(data.env)) {
17+
data.env.forEach((flag: string | object) => {
18+
if (typeof flag === "string") {
19+
env.env = flag;
20+
return;
21+
}
22+
23+
Object.assign(env, flag);
24+
});
25+
} else {
26+
Object.assign(env, data.env);
27+
}
28+
1429
this.release = data.release;
1530
this.hmr = data.hmr || data.useHotModuleReload;
1631
this.env = {
17-
...data.env,
32+
...env,
1833
hmr: data.hmr || data.useHotModuleReload,
1934
};
2035
this.watch = data.watch;

lib/services/marking-mode-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const enum MarkingMode {
1414
}
1515

1616
const MARKING_MODE_PROP = "markingMode";
17-
const MARKING_MODE_FULL_DEPRECATION_MSG = `In NativeScript 7.0 "${MARKING_MODE_PROP}:${MarkingMode.Full}" is no longer supported.`;
17+
const MARKING_MODE_FULL_DEPRECATION_MSG = `In the current version of NativeScript "${MARKING_MODE_PROP}:${MarkingMode.Full}" is no longer supported.`;
1818

1919
export class MarkingModeService implements IMarkingModeService {
2020
constructor(

lib/services/project-config-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default {
8989
return;
9090
}
9191
this.$logger.warn(
92-
`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.`
92+
`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.`
9393
);
9494
}
9595

0 commit comments

Comments
 (0)