Skip to content

fix: 8.0.0 patches #5511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 43 additions & 12 deletions lib/controllers/migrate-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
}
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1606,18 +1618,24 @@ 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;

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));
Expand All @@ -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);
}
}
}

Expand Down
17 changes: 16 additions & 1 deletion lib/data/prepare-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/services/marking-mode-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion lib/services/project-config-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
}

Expand Down