diff --git a/lib/services/project-service.ts b/lib/services/project-service.ts index 8e5addb6b0..a71156ee1d 100644 --- a/lib/services/project-service.ts +++ b/lib/services/project-service.ts @@ -4,6 +4,7 @@ import * as shelljs from "shelljs"; import { format } from "util"; import { exported } from "../common/decorators"; import { Hooks, TemplatesV2PackageJsonKeysToRemove } from "../constants"; +import * as temp from "temp"; export class ProjectService implements IProjectService { @@ -131,14 +132,16 @@ export class ProjectService implements IProjectService { private async ensureAppResourcesExist(projectDir: string): Promise { const projectData = this.$projectDataService.getProjectData(projectDir); - const appPath = projectData.getAppDirectoryPath(projectDir); const appResourcesDestinationPath = projectData.getAppResourcesDirectoryPath(projectDir); if (!this.$fs.exists(appResourcesDestinationPath)) { this.$fs.createDirectory(appResourcesDestinationPath); - + const tempDir = temp.mkdirSync("ns-default-template"); // the template installed doesn't have App_Resources -> get from a default template - await this.$pacoteService.extractPackage(constants.RESERVED_TEMPLATE_NAMES["default"], appPath, { filter: (name: string, entry: any) => entry.path.indexOf(constants.APP_RESOURCES_FOLDER_NAME) !== -1 }); + await this.$pacoteService.extractPackage(constants.RESERVED_TEMPLATE_NAMES["default"], tempDir); + const templateProjectData = this.$projectDataService.getProjectData(tempDir); + const templateAppResourcesDir = templateProjectData.getAppResourcesDirectoryPath(tempDir); + this.$fs.copyFile(path.join(templateAppResourcesDir, "*"), appResourcesDestinationPath); } } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d7c614ea19..d03661f709 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "4.2.0", + "version": "4.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cb894aa2d7..0f594a1488 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "4.2.0", + "version": "4.2.1", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": {