Skip to content

Commit 2463279

Browse files
Merge pull request #3791 from NativeScript/vladimirov/fix-project-creation
fix: remove keys from package.json after project is created
2 parents cd77446 + ed4b4bf commit 2463279

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class LiveSyncTrackActionNames {
5454
}
5555

5656
export const PackageJsonKeysToKeep: Array<String> = ["name", "main", "android", "version", "pluginsData"];
57+
export const TemplatesV2PackageJsonKeysToRemove: Array<String> = ["name", "version", "displayName", "templateType", "author", "keywords", "homepage", "bugs"];
5758

5859
export class SaveOptions {
5960
static PRODUCTION = "save";

lib/services/project-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from "path";
33
import * as shelljs from "shelljs";
44
import { format } from "util";
55
import { exported } from "../common/decorators";
6-
import { Hooks } from "../constants";
6+
import { Hooks, TemplatesV2PackageJsonKeysToRemove } from "../constants";
77

88
export class ProjectService implements IProjectService {
99

@@ -212,7 +212,7 @@ export class ProjectService implements IProjectService {
212212
const packageJsonData = this.$fs.readJson(projectFilePath);
213213

214214
// Remove the metadata keys from the package.json
215-
let updatedPackageJsonData = _.omitBy<any, any>(packageJsonData, (value: any, key: string) => _.startsWith(key, "_"));
215+
let updatedPackageJsonData = _.omitBy<any, any>(packageJsonData, (value: any, key: string) => _.startsWith(key, "_") || TemplatesV2PackageJsonKeysToRemove.indexOf(key) !== -1);
216216
updatedPackageJsonData = _.merge(updatedPackageJsonData, this.packageJsonDefaultData);
217217

218218
if (updatedPackageJsonData.nativescript && updatedPackageJsonData.nativescript.templateVersion) {

0 commit comments

Comments
 (0)