Skip to content

Commit 8e0a7d6

Browse files
authored
Merge pull request MicrosoftDocs#2690 from MicrosoftDocs/master
Merges Master into Live. See commits for details.
2 parents 60e687f + ca41e76 commit 8e0a7d6

File tree

10 files changed

+98
-24
lines changed

10 files changed

+98
-24
lines changed

tools/office-cmdlet-updater/config/default.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Office cmdlet updater",
3-
"description": "Update documentation for modules in this repository",
3+
"description": "Update documentation for modules in this repository. Available Modules: teams, skype, sharepoint, whiteboard, exchange, staffhub",
44
"version": "0.0.3",
55
"platyPS": {
66
"credentials": {
@@ -23,11 +23,11 @@
2323
"path": "..\\..\\sharepoint\\sharepoint-ps\\sharepoint-online",
2424
"metaTags": []
2525
},
26-
// {
27-
// "name": "staffhub",
28-
// "path": "..\\..\\staffhub\\staffhub-ps\\staffhub",
29-
// "metaTags": []
30-
// },
26+
{
27+
"name": "staffhub",
28+
"path": "..\\..\\staffhub\\staffhub-ps\\staffhub",
29+
"metaTags": []
30+
},
3131
{
3232
"name": "whiteboard",
3333
"path": "..\\..\\whiteboard\\whiteboard-ps\\whiteboard",
@@ -41,7 +41,9 @@
4141
],
4242
"ignoreFiles": [
4343
"..\\..\\teams\\teams-ps\\teams\\teams.md",
44-
"..\\..\\whiteboard\\whiteboard-ps\\whiteboard\\whiteboard.md"
44+
"..\\..\\whiteboard\\whiteboard-ps\\whiteboard\\whiteboard.md",
45+
"..\\..\\sharepoint\\sharepoint-ps\\sharepoint-online\\sharepoint-online.md",
46+
"..\\..\\staffhub\\staffhub-ps\\staffhub\\staffhub.md"
4547
],
4648
"tempFolderPath": ".\\.local\\temp"
4749
},

tools/office-cmdlet-updater/constants/commands.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
module.exports = {
22
GET_TEAM: 'Get-Team',
3+
INSTALL_PS_GALLERY: 'Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted',
34
INSTALL_PACKAGE_PROVIDER: 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force',
45
INSTALL_MICROSOFT_TEAM: 'Install-Module MicrosoftTeams -SkipPublisherCheck -Force',
56
CONNECT_MICROSOFT_TEAM: 'Connect-MicrosoftTeams',
67
INSTALL_PLATYPS: 'Install-Module -Name platyPS -SkipPublisherCheck -Scope CurrentUser -Force',
78
IMPORT_PLATYPS: 'Import-Module platyPS',
89
UPDATE_MARKDOWN: 'Update-MarkdownHelp -Path "{}" -LogPath "{}" -Session $Session',
9-
SKYPE_SET_POLICY: 'Set-ExecutionPolicy RemoteSigned ',
10-
SKYPE_INSTALL_MODULE: 'Import-Module "C:\\\\Program Files\\\\Common Files\\\\Skype for Business Online\\\\Modules\\\\SkypeOnlineConnector\\\\SkypeOnlineConnector.psd1" -Force',
10+
SKYPE_ENABLE_WIN_RM: 'sc.exe start WinRM',
11+
SKYPE_INSTALL_LYNC_MODULE: 'Import-Module LyncOnlineConnector',
12+
SKYPE_INSTALL_MODULE: 'Import-Module SkypeOnlineConnector -Force',
1113
SKYPE_GET_CRED: '$cred = Get-Credential',
1214
SKYPE_CREATE_SESSION: '$session = New-CsOnlineSession -Credential $cred -Verbose',
13-
SKYPE_IMPORT_SESSION: 'Import-PSSession -Session $session',
15+
SKYPE_IMPORT_SESSION: 'Import-PSSession -Session $session -Verbose',
1416
SHAREPOINT_INSTALL_MODULE: 'Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking',
1517
WHITEBOARD_INSTALL_MODULE: 'Install-Module -Name WhiteboardAdmin -Force',
1618
EXCHANGE_INSTALL_MODULE: 'Install-Module -Name ExchangeOnlineShell -Force',

tools/office-cmdlet-updater/constants/errors.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module.exports.powerShellErrors = {
2+
PS_GALLERY_INSTALL_ERROR: "You should using x64 version of PowerShell",
23
DOC_PATH_DOESNT_EXIST: "Path to documentation folder doesn't exist",
34
INSTALL_PLATYPS_ERROR: "Can't install 'platyPS' module",
45
IMPORT_PLATYPS_ERROR: "Cant't import 'platyPS' module",
56
INSTALL_MICROSOFT_TEAM_ERROR: "Can't install 'Microsoft team' module",
6-
AUTH_MICROSOFT_TEAM_ERROR: "Can't auth into 'Microsoft team'"
7+
AUTH_MICROSOFT_TEAM_ERROR: "Can't auth into 'Microsoft team'",
8+
EMPTY_CONFIG_CREDENTIALS: "Empty credentials fields in a config file. Please, feel 'platyPS.credentials' section into a config file"
79
};
810

911
module.exports.markdownErrors = {

tools/office-cmdlet-updater/controllers/cli.controller.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { errorColor } = require('../helpers/colors');
2+
13
class CliController {
24
constructor(
35
cliService,
@@ -65,12 +67,18 @@ class CliController {
6567
createPr: isNeedPullRequest
6668
} = cli;
6769

68-
await this.markdownController.updateMarkdown({
69-
cliModuleName,
70-
cliCmdletName,
71-
isNeedPullRequest,
72-
isNeedEmail
73-
});
70+
await this.markdownController
71+
.updateMarkdown({
72+
cliModuleName,
73+
cliCmdletName,
74+
isNeedPullRequest,
75+
isNeedEmail
76+
})
77+
.catch((err) => {
78+
console.error(errorColor(err));
79+
80+
this.powerShellService.dispose();
81+
});
7482
});
7583
}
7684
}

tools/office-cmdlet-updater/controllers/markdown.controller.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class MarkdownController {
4848
return;
4949
}
5050

51+
this._printResultIntoConsole({ text: mailText });
52+
5153
if (isNeedEmail && !isNeedPullRequest) {
5254
this.notificationController.sendMailNotification({ mailText });
5355
}
@@ -96,6 +98,16 @@ class MarkdownController {
9698
});
9799
}
98100
}
101+
102+
_printResultIntoConsole({ text }) {
103+
const oldBreakSymbol = '<br>';
104+
const newBreakSymbol = '\n';
105+
106+
const consoleText = text.replace(new RegExp(oldBreakSymbol, 'g'), newBreakSymbol);
107+
108+
console.log(`Report: ${newBreakSymbol}`);
109+
console.log(consoleText);
110+
}
99111
}
100112

101113
module.exports = MarkdownController;

tools/office-cmdlet-updater/controllers/notification.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class NotificationController {
1616
for (let { module, parsedLogs } of parsedModules) {
1717
const {
1818
isModuleChange,
19-
moduleText
19+
mailText: moduleText
2020
} = this._generateMailTextForModule({
2121
parsedLogs,
2222
module
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const chalk = require('chalk');
2+
3+
const errorColor = chalk.red.bgBlack;
4+
5+
module.exports = {
6+
errorColor
7+
};

tools/office-cmdlet-updater/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"await-of": "^1.1.2",
2828
"awilix": "^3.0.9",
2929
"better-queue": "^3.8.10",
30+
"chalk": "^2.4.2",
3031
"commander": "^2.19.0",
3132
"config": "^2.0.1",
3233
"fs-extra": "^7.0.0",

tools/office-cmdlet-updater/services/cmdlet.dependencies.service.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const commands = require('../constants/commands');
2+
const errors = require('../constants/errors');
23
const format = require('string-format');
34

45
class CmdletDependenciesService {
@@ -8,7 +9,7 @@ class CmdletDependenciesService {
89
}
910

1011
async installDependencies({ cmdletName }) {
11-
await this.installPlatyPs();
12+
await this.installGlobalDependencies();
1213

1314
switch (cmdletName) {
1415
case 'teams': {
@@ -39,15 +40,31 @@ class CmdletDependenciesService {
3940
await this.preInstallStuffHub();
4041
break;
4142
}
43+
default: {
44+
45+
}
4246
}
4347
}
4448

49+
async installGlobalDependencies() {
50+
await this.installPsGallery();
51+
await this.installPlatyPs();
52+
}
53+
4554
async installPlatyPs() {
4655
await this.ps.invokeCommand(commands.INSTALL_PACKAGE_PROVIDER);
4756
await this.ps.invokeCommand(commands.INSTALL_PLATYPS);
4857
await this.ps.invokeCommand(commands.IMPORT_PLATYPS);
4958
}
5059

60+
async installPsGallery() {
61+
try {
62+
await this.ps.invokeCommand(commands.INSTALL_PS_GALLERY);
63+
} catch (e) {
64+
throw errors.powerShellErrors.PS_GALLERY_INSTALL_ERROR;
65+
}
66+
}
67+
5168
async preInstallTeams() {
5269
// TODO: check if user already auth
5370

@@ -62,7 +79,14 @@ class CmdletDependenciesService {
6279
async preInstallSkype({ login, pass }) {
6380
await this._createCredInPs({ login, pass });
6481

65-
// await this.ps.invokeCommand(commands.SKYPE_INSTALL_MODULE);
82+
await this.ps.invokeCommandAndIgnoreError({
83+
command: commands.SKYPE_ENABLE_WIN_RM,
84+
printError: true
85+
});
86+
87+
//await this.ps.invokeCommand(commands.SKYPE_GET_CRED);
88+
await this.ps.invokeCommand(commands.SKYPE_INSTALL_LYNC_MODULE);
89+
await this.ps.invokeCommand(commands.SKYPE_INSTALL_MODULE);
6690
await this.ps.invokeCommand(commands.SKYPE_CREATE_SESSION);
6791
await this.ps.invokeCommand(commands.SKYPE_IMPORT_SESSION);
6892
}
@@ -74,6 +98,11 @@ class CmdletDependenciesService {
7498
async preInstallExchange({ login, pass }) {
7599
await this._createCredInPs({ login, pass });
76100

101+
await this.ps.invokeCommandAndIgnoreError({
102+
command: commands.SKYPE_ENABLE_WIN_RM,
103+
printError: true
104+
});
105+
77106
//await this.ps.invokeCommand(commands.EXCHANGE_INSTALL_MODULE);
78107
await this.ps.invokeCommand(commands.EXCHANGE_GET_SESSION);
79108
await this.ps.invokeCommand(commands.EXCHANGE_SESSION_IMPORT);
@@ -88,7 +117,7 @@ class CmdletDependenciesService {
88117
const { login, pass } = this.config.get('platyPS.credentials');
89118

90119
if (!login || !pass) {
91-
throw new Error('Invalid credentials');
120+
throw new Error(errors.powerShellErrors.EMPTY_CONFIG_CREDENTIALS);
92121
}
93122

94123
return { login, pass };

tools/office-cmdlet-updater/services/power.shell.service.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ const Shell = require('node-powershell');
22
const of = require('await-of').default;
33
const commands = require('../constants/commands');
44
const format = require('string-format');
5+
const { errorColor } = require('../helpers/colors');
56

67
class PowerShellService {
78
constructor(config) {
89
this.config = config;
910
this.ps = new Shell({
10-
executionPolicy: 'Bypass',
11+
executionPolicy: 'Unrestricted',
1112
noProfile: true
1213
});
1314
}
@@ -24,14 +25,24 @@ class PowerShellService {
2425
const [output, err] = await of(this.ps.invoke());
2526

2627
if (err) {
27-
console.error(err);
28-
2928
throw new Error(err);
3029
}
3130

3231
return output;
3332
}
3433

34+
async invokeCommandAndIgnoreError({ command, printError = false }) {
35+
await this.ps.addCommand(command);
36+
37+
const [output, err] = await of(this.ps.invoke());
38+
39+
if (err && printError) {
40+
console.error(errorColor(err));
41+
}
42+
43+
return output;
44+
}
45+
3546
async dispose() {
3647
return await this.ps.dispose();
3748
}

0 commit comments

Comments
 (0)