-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
add App_Resources from default template if missing #2513 #2609
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ export class ProjectService implements IProjectService { | |
let templatePath = await this.$projectTemplatesService.prepareTemplate(selectedTemplate, projectDir); | ||
await this.extractTemplate(projectDir, templatePath); | ||
|
||
await this.ensureAppResourcesExist(projectDir); | ||
|
||
let packageName = constants.TNS_CORE_MODULES_NAME; | ||
await this.$npm.install(packageName, projectDir, { save: true, "save-exact": true }); | ||
|
||
|
@@ -102,6 +104,27 @@ export class ProjectService implements IProjectService { | |
this.$fs.createDirectory(path.join(projectDir, "platforms")); | ||
} | ||
|
||
private async ensureAppResourcesExist(projectDir: string): Promise<void> { | ||
let appPath = path.join(projectDir, constants.APP_FOLDER_NAME), | ||
appResourcesDestinationPath = path.join(appPath, constants.APP_RESOURCES_FOLDER_NAME); | ||
|
||
if (!this.$fs.exists(appResourcesDestinationPath)) { | ||
this.$fs.createDirectory(appResourcesDestinationPath); | ||
|
||
// the template installed doesn't have App_Resources -> get from a default template | ||
let defaultTemplateName = constants.RESERVED_TEMPLATE_NAMES["default"]; | ||
await this.$npm.install(defaultTemplateName, projectDir, { save: true, }); | ||
let defaultTemplateAppResourcesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here - these could be |
||
defaultTemplateName, constants.APP_RESOURCES_FOLDER_NAME); | ||
|
||
if (this.$fs.exists(defaultTemplateAppResourcesPath)) { | ||
shelljs.cp('-R', defaultTemplateAppResourcesPath, appPath); | ||
} | ||
|
||
await this.$npm.uninstall(defaultTemplateName, { save: true }, projectDir); | ||
} | ||
} | ||
|
||
private removeMergedDependencies(projectDir: string, templatePackageJsonData: any): void { | ||
let extractedTemplatePackageJsonPath = path.join(projectDir, constants.APP_FOLDER_NAME, constants.PACKAGE_JSON_FILE_NAME); | ||
for (let key in templatePackageJsonData) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these could be
const
instead oflet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
const
is the better approach. I'll leave it aslet
now, following the whole style of the file - where all other same-constructed paths are withlet
. I'll take care to use const in the future :)