-
Notifications
You must be signed in to change notification settings - Fork 17
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
Added tour response for Upgrade and Validate actions, Closes #188 #323
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||
import { readFileSync, writeFileSync } from 'fs'; | ||||||
import { Folders } from '../check/Folders'; | ||||||
import { commands, Progress, ProgressLocation, Uri, window, workspace } from 'vscode'; | ||||||
import { commands, Progress, ProgressLocation, Uri, window, workspace, WorkspaceFolder } from 'vscode'; | ||||||
import { Commands, WebViewType, WebviewCommand, WorkflowType } from '../../constants'; | ||||||
import { GenerateWorkflowCommandInput, SiteAppCatalog, SolutionAddResult, Subscription } from '../../models'; | ||||||
import { Extension } from '../dataType/Extension'; | ||||||
|
@@ -15,6 +15,8 @@ import { PnPWebview } from '../../webview/PnPWebview'; | |||||
import { parseYoRc } from '../../utils/parseYoRc'; | ||||||
import { CertificateActions } from './CertificateActions'; | ||||||
import path = require('path'); | ||||||
import * as fs from 'fs'; | ||||||
import { getExtensionSettings } from '../../utils/getExtensionSettings'; | ||||||
|
||||||
|
||||||
export class CliActions { | ||||||
|
@@ -273,21 +275,21 @@ export class CliActions { | |||||
cancellable: true | ||||||
}, async (progress: Progress<{ message?: string; increment?: number }>) => { | ||||||
try { | ||||||
const result = await CliExecuter.execute('spfx project upgrade', 'md'); | ||||||
|
||||||
if (result.stdout) { | ||||||
// Create a file to allow the Markdown preview to correctly open the linked/referenced files | ||||||
let savePath = wsFolder?.uri.fsPath; | ||||||
|
||||||
if (savePath && TeamsToolkitIntegration.isTeamsToolkitProject) { | ||||||
savePath = join(savePath, 'src'); | ||||||
} | ||||||
|
||||||
const filePath = join(savePath || '', 'spfx.upgrade.md'); | ||||||
writeFileSync(filePath, result.stdout); | ||||||
await commands.executeCommand('markdown.showPreview', Uri.file(filePath)); | ||||||
} else if (result.stderr) { | ||||||
Notifications.error(result.stderr); | ||||||
const projectUpgradeOutputMode: string = getExtensionSettings('projectUpgradeOutputMode', 'both'); | ||||||
let resultMd: any; | ||||||
|
||||||
if (projectUpgradeOutputMode === 'markdown') { | ||||||
resultMd = await CliExecuter.execute('spfx project upgrade', 'md'); | ||||||
CliActions.handleMarkdownResult(resultMd,wsFolder); | ||||||
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.
Suggested change
|
||||||
} else if (projectUpgradeOutputMode === 'code tour') { | ||||||
await CliExecuter.execute('spfx project upgrade', 'tour'); | ||||||
commands.executeCommand('codetour.startTour'); | ||||||
} else { | ||||||
resultMd = await CliExecuter.execute('spfx project upgrade', 'md'); | ||||||
await CliExecuter.execute('spfx project upgrade', 'tour'); | ||||||
|
||||||
CliActions.handleMarkdownResult(resultMd, wsFolder); | ||||||
commands.executeCommand('codetour.startTour'); | ||||||
} | ||||||
} catch (e: any) { | ||||||
const message = e?.error?.message; | ||||||
|
@@ -452,21 +454,22 @@ export class CliActions { | |||||
cancellable: true | ||||||
}, async (progress: Progress<{ message?: string; increment?: number }>) => { | ||||||
try { | ||||||
const result = await CliExecuter.execute('spfx project doctor', 'md'); | ||||||
|
||||||
if (result.stdout) { | ||||||
// Create a file to allow the Markdown preview to correctly open the linked/referenced files | ||||||
let savePath = wsFolder?.uri.fsPath; | ||||||
|
||||||
if (savePath && TeamsToolkitIntegration.isTeamsToolkitProject) { | ||||||
savePath = join(savePath, 'src'); | ||||||
} | ||||||
|
||||||
const filePath = join(savePath || '', 'spfx.validate.md'); | ||||||
writeFileSync(filePath, result.stdout); | ||||||
await commands.executeCommand('markdown.showPreview', Uri.file(filePath)); | ||||||
} else if (result.stderr) { | ||||||
Notifications.error(result.stderr); | ||||||
const projectValidateOutputMode: string = getExtensionSettings('projectValidateOutputMode', 'both'); | ||||||
let resultMd: any; | ||||||
|
||||||
if (projectValidateOutputMode === 'markdown') { | ||||||
resultMd = await CliExecuter.execute('spfx project doctor', 'md'); | ||||||
CliActions.handleMarkdownResult(resultMd,wsFolder); | ||||||
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.
Suggested change
|
||||||
} else if (projectValidateOutputMode === 'code tour') { | ||||||
await CliExecuter.execute('spfx project doctor', 'tour'); | ||||||
commands.executeCommand('codetour.startTour'); | ||||||
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. the problem with this approach is that it will run code tour even if nothing was found. in this case we see a picker to run tour but there is non to run. this may be very confusing and I suggest we should run the code tour command only when something was created, so the CLI command did return something The same applies to the Upgrade report |
||||||
} else { | ||||||
resultMd = await CliExecuter.execute('spfx project doctor', 'md'); | ||||||
await CliExecuter.execute('spfx project doctor', 'tour'); | ||||||
|
||||||
// Handle both results | ||||||
CliActions.handleMarkdownResult(resultMd, wsFolder); | ||||||
commands.executeCommand('codetour.startTour'); | ||||||
} | ||||||
} catch (e: any) { | ||||||
const message = e?.error?.message; | ||||||
|
@@ -582,4 +585,25 @@ export class CliActions { | |||||
} | ||||||
}); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Handles the Markdown result | ||||||
* @param result The result of the (CLI) command execution | ||||||
* @param wsFolder The workspace folder | ||||||
*/ | ||||||
private static handleMarkdownResult(result: any, wsFolder: WorkspaceFolder | undefined) { | ||||||
if (result?.stdout) { | ||||||
let savePath = wsFolder?.uri.fsPath; | ||||||
|
||||||
if (savePath && TeamsToolkitIntegration.isTeamsToolkitProject) { | ||||||
savePath = join(savePath, 'src'); | ||||||
} | ||||||
|
||||||
const filePath = join(savePath || '', 'spfx.upgrade.md'); | ||||||
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. We should pass the markdown file name as param. Currently, we will get the same file name for both upgrade and validate action and it will be |
||||||
writeFileSync(filePath, result.stdout); | ||||||
commands.executeCommand('markdown.showPreview', Uri.file(filePath)); | ||||||
} else if (result?.stderr) { | ||||||
Notifications.error(result.stderr); | ||||||
} | ||||||
} | ||||||
} |
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.
is this import actually needed?