@pnp/cli-microsoft365 7.6.0 → 7.7.0-beta.7b57cf9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +1 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Command.js +1 -1
- package/dist/m365/commands/setup.js +1 -7
- package/dist/m365/entra/commands/app/app-add.js +7 -1
- package/dist/m365/entra/commands/app/app-set.js +32 -3
- package/dist/m365/entra/commands/pim/pim-role-assignment-add.js +233 -0
- package/dist/m365/entra/commands/pim/pim-role-assignment-list.js +122 -0
- package/dist/m365/entra/commands.js +2 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.0.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.1.3.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.10.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.11.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.12.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.12.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.13.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.13.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.14.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.16.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.3.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.4.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.18.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.19.0-beta.0.js +25 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.2.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.3.4.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.4.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.4.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.5.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.5.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.6.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.7.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.7.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.0.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.8.2.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.9.1.js +3 -1
- package/dist/m365/spfx/commands/project/project-doctor/generic-rules.js +0 -2
- package/dist/m365/spfx/commands/project/project-doctor/rules/FN021001_PKG_spfx_deps_versions_match_project_version.js +3 -2
- package/dist/m365/spfx/commands/project/project-doctor/rules/FN021013_PKG_spfx_devdeps_match_version.js +58 -0
- package/dist/m365/spfx/commands/project/project-doctor/spfx-deps.js +2 -0
- package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.19.0-beta.0.js +53 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +16 -13
- package/dist/m365/spfx/commands/spfx-doctor.js +15 -0
- package/dist/m365/spo/commands/contenttype/contenttype-sync.js +139 -0
- package/dist/m365/spo/commands/listitem/listitem-set.js +9 -156
- package/dist/m365/spo/commands/page/page-add.js +6 -24
- package/dist/m365/spo/commands/page/page-set.js +19 -43
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +8 -9
- package/dist/m365/spo/commands/site/site-hubsite-connect.js +3 -3
- package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +2 -5
- package/dist/m365/spo/commands.js +1 -0
- package/dist/utils/prompt.js +2 -0
- package/dist/utils/spo.js +188 -0
- package/dist/utils/validation.js +4 -0
- package/docs/docs/cmd/entra/app/app-add.mdx +9 -0
- package/docs/docs/cmd/entra/app/app-set.mdx +9 -0
- package/docs/docs/cmd/entra/pim/pim-role-assignment-add.mdx +230 -0
- package/docs/docs/cmd/entra/pim/pim-role-assignment-list.mdx +224 -0
- package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
- package/docs/docs/cmd/spo/contenttype/contenttype-sync.mdx +144 -0
- package/docs/docs/cmd/spo/page/page-set.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-apppermission-add.mdx +1 -1
- package/npm-shrinkwrap.json +140 -216
- package/package.json +15 -15
|
@@ -2,8 +2,9 @@ import { satisfies } from 'semver';
|
|
|
2
2
|
import { JsonRule } from '../../JsonRule.js';
|
|
3
3
|
import * as spfxDeps from '../spfx-deps.js';
|
|
4
4
|
export class FN021001_PKG_spfx_deps_versions_match_project_version extends JsonRule {
|
|
5
|
-
constructor() {
|
|
5
|
+
constructor(includeDevDeps = true) {
|
|
6
6
|
super();
|
|
7
|
+
this.includeDevDeps = includeDevDeps;
|
|
7
8
|
}
|
|
8
9
|
get id() {
|
|
9
10
|
return 'FN021001';
|
|
@@ -38,7 +39,7 @@ export class FN021001_PKG_spfx_deps_versions_match_project_version extends JsonR
|
|
|
38
39
|
findings
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
|
-
if (project.packageJson.devDependencies) {
|
|
42
|
+
if (this.includeDevDeps && project.packageJson.devDependencies) {
|
|
42
43
|
const projectDevDeps = Object.keys(project.packageJson.devDependencies);
|
|
43
44
|
this.validateDependencies({
|
|
44
45
|
dependencies: projectDevDeps,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { satisfies } from 'semver';
|
|
2
|
+
import { JsonRule } from '../../JsonRule.js';
|
|
3
|
+
import * as spfxDeps from '../spfx-deps.js';
|
|
4
|
+
export class FN021013_PKG_spfx_devdeps_match_version extends JsonRule {
|
|
5
|
+
constructor(version) {
|
|
6
|
+
super();
|
|
7
|
+
this.version = version;
|
|
8
|
+
}
|
|
9
|
+
get id() {
|
|
10
|
+
return 'FN021013';
|
|
11
|
+
}
|
|
12
|
+
get title() {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
get description() {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
get severity() {
|
|
19
|
+
return 'Required';
|
|
20
|
+
}
|
|
21
|
+
get file() {
|
|
22
|
+
return './package.json';
|
|
23
|
+
}
|
|
24
|
+
get resolutionType() {
|
|
25
|
+
return 'cmd';
|
|
26
|
+
}
|
|
27
|
+
visit(project, findings) {
|
|
28
|
+
if (!project.packageJson || !project.packageJson.devDependencies) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (project.packageJson.devDependencies) {
|
|
32
|
+
const projectDevDeps = Object.keys(project.packageJson.devDependencies);
|
|
33
|
+
this.validateDependencies({
|
|
34
|
+
dependencies: projectDevDeps,
|
|
35
|
+
spfxDeps: spfxDeps.devDeps,
|
|
36
|
+
project,
|
|
37
|
+
version: this.version,
|
|
38
|
+
findings
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
validateDependencies({ dependencies, spfxDeps, project, version, findings }) {
|
|
43
|
+
dependencies.forEach(dep => {
|
|
44
|
+
const depVersion = project.packageJson.devDependencies[dep];
|
|
45
|
+
if (!spfxDeps.includes(dep) ||
|
|
46
|
+
satisfies(version, depVersion)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const node = this.getAstNodeFromFile(project.packageJson, 'devDependencies');
|
|
50
|
+
this.addFindingWithCustomInfo(`${dep} doesn't match project version`, `${dep}@${depVersion} doesn't match the project version ${project.version}`, [{
|
|
51
|
+
file: this.file,
|
|
52
|
+
resolution: `installDev ${dep}@${project.version}`,
|
|
53
|
+
position: this.getPositionFromNode(node)
|
|
54
|
+
}], findings);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=FN021013_PKG_spfx_devdeps_match_version.js.map
|
|
@@ -69,7 +69,8 @@ class SpfxProjectDoctorCommand extends BaseProjectCommand {
|
|
|
69
69
|
'1.17.4',
|
|
70
70
|
'1.18.0',
|
|
71
71
|
'1.18.1',
|
|
72
|
-
'1.18.2'
|
|
72
|
+
'1.18.2',
|
|
73
|
+
'1.19.0-beta.0'
|
|
73
74
|
];
|
|
74
75
|
__classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initTelemetry).call(this);
|
|
75
76
|
__classPrivateFieldGet(this, _SpfxProjectDoctorCommand_instances, "m", _SpfxProjectDoctorCommand_initOptions).call(this);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FN001001_DEP_microsoft_sp_core_library } from './rules/FN001001_DEP_microsoft_sp_core_library.js';
|
|
2
|
+
import { FN001002_DEP_microsoft_sp_lodash_subset } from './rules/FN001002_DEP_microsoft_sp_lodash_subset.js';
|
|
3
|
+
import { FN001003_DEP_microsoft_sp_office_ui_fabric_core } from './rules/FN001003_DEP_microsoft_sp_office_ui_fabric_core.js';
|
|
4
|
+
import { FN001004_DEP_microsoft_sp_webpart_base } from './rules/FN001004_DEP_microsoft_sp_webpart_base.js';
|
|
5
|
+
import { FN001011_DEP_microsoft_sp_dialog } from './rules/FN001011_DEP_microsoft_sp_dialog.js';
|
|
6
|
+
import { FN001012_DEP_microsoft_sp_application_base } from './rules/FN001012_DEP_microsoft_sp_application_base.js';
|
|
7
|
+
import { FN001013_DEP_microsoft_decorators } from './rules/FN001013_DEP_microsoft_decorators.js';
|
|
8
|
+
import { FN001014_DEP_microsoft_sp_listview_extensibility } from './rules/FN001014_DEP_microsoft_sp_listview_extensibility.js';
|
|
9
|
+
import { FN001021_DEP_microsoft_sp_property_pane } from './rules/FN001021_DEP_microsoft_sp_property_pane.js';
|
|
10
|
+
import { FN001023_DEP_microsoft_sp_component_base } from './rules/FN001023_DEP_microsoft_sp_component_base.js';
|
|
11
|
+
import { FN001024_DEP_microsoft_sp_diagnostics } from './rules/FN001024_DEP_microsoft_sp_diagnostics.js';
|
|
12
|
+
import { FN001025_DEP_microsoft_sp_dynamic_data } from './rules/FN001025_DEP_microsoft_sp_dynamic_data.js';
|
|
13
|
+
import { FN001026_DEP_microsoft_sp_extension_base } from './rules/FN001026_DEP_microsoft_sp_extension_base.js';
|
|
14
|
+
import { FN001027_DEP_microsoft_sp_http } from './rules/FN001027_DEP_microsoft_sp_http.js';
|
|
15
|
+
import { FN001028_DEP_microsoft_sp_list_subscription } from './rules/FN001028_DEP_microsoft_sp_list_subscription.js';
|
|
16
|
+
import { FN001029_DEP_microsoft_sp_loader } from './rules/FN001029_DEP_microsoft_sp_loader.js';
|
|
17
|
+
import { FN001030_DEP_microsoft_sp_module_interfaces } from './rules/FN001030_DEP_microsoft_sp_module_interfaces.js';
|
|
18
|
+
import { FN001031_DEP_microsoft_sp_odata_types } from './rules/FN001031_DEP_microsoft_sp_odata_types.js';
|
|
19
|
+
import { FN001032_DEP_microsoft_sp_page_context } from './rules/FN001032_DEP_microsoft_sp_page_context.js';
|
|
20
|
+
import { FN001034_DEP_microsoft_sp_adaptive_card_extension_base } from './rules/FN001034_DEP_microsoft_sp_adaptive_card_extension_base.js';
|
|
21
|
+
import { FN002001_DEVDEP_microsoft_sp_build_web } from './rules/FN002001_DEVDEP_microsoft_sp_build_web.js';
|
|
22
|
+
import { FN002002_DEVDEP_microsoft_sp_module_interfaces } from './rules/FN002002_DEVDEP_microsoft_sp_module_interfaces.js';
|
|
23
|
+
import { FN002022_DEVDEP_microsoft_eslint_plugin_spfx } from './rules/FN002022_DEVDEP_microsoft_eslint_plugin_spfx.js';
|
|
24
|
+
import { FN002023_DEVDEP_microsoft_eslint_config_spfx } from './rules/FN002023_DEVDEP_microsoft_eslint_config_spfx.js';
|
|
25
|
+
import { FN010001_YORC_version } from './rules/FN010001_YORC_version.js';
|
|
26
|
+
export default [
|
|
27
|
+
new FN001001_DEP_microsoft_sp_core_library('1.19.0-beta.0'),
|
|
28
|
+
new FN001002_DEP_microsoft_sp_lodash_subset('1.19.0-beta.0'),
|
|
29
|
+
new FN001003_DEP_microsoft_sp_office_ui_fabric_core('1.19.0-beta.0'),
|
|
30
|
+
new FN001004_DEP_microsoft_sp_webpart_base('1.19.0-beta.0'),
|
|
31
|
+
new FN001011_DEP_microsoft_sp_dialog('1.19.0-beta.0'),
|
|
32
|
+
new FN001012_DEP_microsoft_sp_application_base('1.19.0-beta.0'),
|
|
33
|
+
new FN001014_DEP_microsoft_sp_listview_extensibility('1.19.0-beta.0'),
|
|
34
|
+
new FN001021_DEP_microsoft_sp_property_pane('1.19.0-beta.0'),
|
|
35
|
+
new FN001023_DEP_microsoft_sp_component_base('1.19.0-beta.0'),
|
|
36
|
+
new FN001024_DEP_microsoft_sp_diagnostics('1.19.0-beta.0'),
|
|
37
|
+
new FN001025_DEP_microsoft_sp_dynamic_data('1.19.0-beta.0'),
|
|
38
|
+
new FN001026_DEP_microsoft_sp_extension_base('1.19.0-beta.0'),
|
|
39
|
+
new FN001027_DEP_microsoft_sp_http('1.19.0-beta.0'),
|
|
40
|
+
new FN001028_DEP_microsoft_sp_list_subscription('1.19.0-beta.0'),
|
|
41
|
+
new FN001029_DEP_microsoft_sp_loader('1.19.0-beta.0'),
|
|
42
|
+
new FN001030_DEP_microsoft_sp_module_interfaces('1.19.0-beta.0'),
|
|
43
|
+
new FN001031_DEP_microsoft_sp_odata_types('1.19.0-beta.0'),
|
|
44
|
+
new FN001032_DEP_microsoft_sp_page_context('1.19.0-beta.0'),
|
|
45
|
+
new FN001013_DEP_microsoft_decorators('1.19.0-beta.0'),
|
|
46
|
+
new FN001034_DEP_microsoft_sp_adaptive_card_extension_base('1.19.0-beta.0'),
|
|
47
|
+
new FN002001_DEVDEP_microsoft_sp_build_web('1.20.1'),
|
|
48
|
+
new FN002002_DEVDEP_microsoft_sp_module_interfaces('1.20.1'),
|
|
49
|
+
new FN002022_DEVDEP_microsoft_eslint_plugin_spfx('1.20.1'),
|
|
50
|
+
new FN002023_DEVDEP_microsoft_eslint_config_spfx('1.20.1'),
|
|
51
|
+
new FN010001_YORC_version('1.19.0-beta.0')
|
|
52
|
+
];
|
|
53
|
+
//# sourceMappingURL=upgrade-1.19.0-beta.0.js.map
|
|
@@ -7,6 +7,8 @@ var _SpfxProjectUpgradeCommand_instances, _a, _SpfxProjectUpgradeCommand_initTel
|
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import os from 'os';
|
|
9
9
|
import path from 'path';
|
|
10
|
+
// uncomment to support upgrading to preview releases
|
|
11
|
+
import { prerelease } from 'semver';
|
|
10
12
|
import { CommandError } from '../../../../Command.js';
|
|
11
13
|
import { fsUtil } from '../../../../utils/fsUtil.js';
|
|
12
14
|
import { packageManager } from '../../../../utils/packageManager.js';
|
|
@@ -71,7 +73,8 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
|
|
|
71
73
|
'1.17.4',
|
|
72
74
|
'1.18.0',
|
|
73
75
|
'1.18.1',
|
|
74
|
-
'1.18.2'
|
|
76
|
+
'1.18.2',
|
|
77
|
+
'1.19.0-beta.0'
|
|
75
78
|
];
|
|
76
79
|
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initTelemetry).call(this);
|
|
77
80
|
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initOptions).call(this);
|
|
@@ -84,15 +87,15 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
|
|
|
84
87
|
}
|
|
85
88
|
this.toVersion = args.options.toVersion ? args.options.toVersion : this.supportedVersions[this.supportedVersions.length - 1];
|
|
86
89
|
// uncomment to support upgrading to preview releases
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
if (!args.options.toVersion &&
|
|
91
|
+
!args.options.preview &&
|
|
92
|
+
prerelease(this.toVersion)) {
|
|
93
|
+
// no version and no preview specified while the current version to
|
|
94
|
+
// upgrade to is a prerelease so let's grab the first non-preview version
|
|
95
|
+
// since we're supporting only one preview version, it's sufficient for
|
|
96
|
+
// us to take second to last version
|
|
97
|
+
this.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
|
|
98
|
+
}
|
|
96
99
|
this.packageManager = args.options.packageManager || 'npm';
|
|
97
100
|
this.shell = args.options.shell || 'bash';
|
|
98
101
|
if (this.supportedVersions.indexOf(this.toVersion) < 0) {
|
|
@@ -481,9 +484,9 @@ _a = SpfxProjectUpgradeCommand, _SpfxProjectUpgradeCommand_instances = new WeakS
|
|
|
481
484
|
preview: args.options.preview
|
|
482
485
|
});
|
|
483
486
|
// uncomment to support upgrading to preview releases
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
+
if (prerelease(this.telemetryProperties.toVersion) && !args.options.preview) {
|
|
488
|
+
this.telemetryProperties.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
|
|
489
|
+
}
|
|
487
490
|
});
|
|
488
491
|
}, _SpfxProjectUpgradeCommand_initOptions = function _SpfxProjectUpgradeCommand_initOptions() {
|
|
489
492
|
this.options.unshift({
|
|
@@ -568,6 +568,21 @@ class SpfxDoctorCommand extends BaseProjectCommand {
|
|
|
568
568
|
range: '^4 || ^5',
|
|
569
569
|
fix: 'npm i -g yo@5'
|
|
570
570
|
}
|
|
571
|
+
},
|
|
572
|
+
'1.19.0-beta.0': {
|
|
573
|
+
gulpCli: {
|
|
574
|
+
range: '^1 || ^2',
|
|
575
|
+
fix: 'npm i -g gulp-cli@2'
|
|
576
|
+
},
|
|
577
|
+
node: {
|
|
578
|
+
range: '>=18.17.1 <19.0.0',
|
|
579
|
+
fix: 'Install Node.js >=18.17.1 <19.0.0'
|
|
580
|
+
},
|
|
581
|
+
sp: SharePointVersion.SPO,
|
|
582
|
+
yo: {
|
|
583
|
+
range: '^4 || ^5',
|
|
584
|
+
fix: 'npm i -g yo@5'
|
|
585
|
+
}
|
|
571
586
|
}
|
|
572
587
|
};
|
|
573
588
|
__classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initTelemetry).call(this);
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _SpoContentTypeSyncCommand_instances, _SpoContentTypeSyncCommand_initTelemetry, _SpoContentTypeSyncCommand_initOptions, _SpoContentTypeSyncCommand_initValidators, _SpoContentTypeSyncCommand_initTypes, _SpoContentTypeSyncCommand_initOptionSets;
|
|
7
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
8
|
+
import request from '../../../../request.js';
|
|
9
|
+
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
11
|
+
import commands from '../../commands.js';
|
|
12
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
13
|
+
import { odata } from '../../../../utils/odata.js';
|
|
14
|
+
import { spo } from '../../../../utils/spo.js';
|
|
15
|
+
class SpoContentTypeSyncCommand extends SpoCommand {
|
|
16
|
+
get name() {
|
|
17
|
+
return commands.CONTENTTYPE_SYNC;
|
|
18
|
+
}
|
|
19
|
+
get description() {
|
|
20
|
+
return 'Adds a published content type from the content type hub to a site or syncs its latest changes';
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
_SpoContentTypeSyncCommand_instances.add(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpoContentTypeSyncCommand_instances, "m", _SpoContentTypeSyncCommand_initTelemetry).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoContentTypeSyncCommand_instances, "m", _SpoContentTypeSyncCommand_initOptions).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _SpoContentTypeSyncCommand_instances, "m", _SpoContentTypeSyncCommand_initValidators).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _SpoContentTypeSyncCommand_instances, "m", _SpoContentTypeSyncCommand_initTypes).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _SpoContentTypeSyncCommand_instances, "m", _SpoContentTypeSyncCommand_initOptionSets).call(this);
|
|
30
|
+
}
|
|
31
|
+
async commandAction(logger, args) {
|
|
32
|
+
const { listId, listTitle, listUrl, webUrl } = args.options;
|
|
33
|
+
const url = new URL(webUrl);
|
|
34
|
+
const baseUrl = 'https://graph.microsoft.com/v1.0/sites/';
|
|
35
|
+
try {
|
|
36
|
+
const siteUrl = url.pathname === '/' ? url.host : await spo.getSiteId(webUrl, logger, this.verbose);
|
|
37
|
+
const listPath = listId || listTitle || listUrl ? `/lists/${listId || listTitle || await this.getListIdByUrl(webUrl, listUrl, logger)}` : '';
|
|
38
|
+
const contentTypeId = await this.getContentTypeId(baseUrl, url, args.options, logger);
|
|
39
|
+
if (this.verbose) {
|
|
40
|
+
await logger.logToStderr(`Adding or syncing the content type...`);
|
|
41
|
+
}
|
|
42
|
+
const requestOptions = {
|
|
43
|
+
url: `${baseUrl}${siteUrl}${listPath}/contenttypes/addCopyFromContentTypeHub`,
|
|
44
|
+
headers: {
|
|
45
|
+
'accept': 'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false'
|
|
46
|
+
},
|
|
47
|
+
responseType: 'json',
|
|
48
|
+
data: {
|
|
49
|
+
contentTypeId: contentTypeId
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const response = await request.post(requestOptions);
|
|
53
|
+
// The endpoint only returns a response if the content type has been added for the first time
|
|
54
|
+
// When syncing, the response will be an empty string, which should not be logged.
|
|
55
|
+
if (typeof response === 'object') {
|
|
56
|
+
await logger.log(response);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
this.handleRejectedODataJsonPromise(err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async getContentTypeId(baseUrl, url, options, logger) {
|
|
64
|
+
if (options.id) {
|
|
65
|
+
return options.id;
|
|
66
|
+
}
|
|
67
|
+
const siteId = await spo.getSiteId(`${url.origin}/sites/contenttypehub`, logger, this.verbose);
|
|
68
|
+
if (this.verbose) {
|
|
69
|
+
await logger.logToStderr(`Retrieving content type Id by name...`);
|
|
70
|
+
}
|
|
71
|
+
const contentTypes = await odata.getAllItems(`${baseUrl}${siteId}/contenttypes?$filter=name eq '${options.name}'&$select=id,name`);
|
|
72
|
+
if (contentTypes.length === 0) {
|
|
73
|
+
throw `Content type with name ${options.name} not found.`;
|
|
74
|
+
}
|
|
75
|
+
return contentTypes[0].id;
|
|
76
|
+
}
|
|
77
|
+
async getListIdByUrl(webUrl, listUrl, logger) {
|
|
78
|
+
if (this.verbose) {
|
|
79
|
+
await logger.logToStderr(`Retrieving list id to sync the content type to...`);
|
|
80
|
+
}
|
|
81
|
+
const listServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, listUrl);
|
|
82
|
+
const requestOptions = {
|
|
83
|
+
url: `${webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=id`,
|
|
84
|
+
headers: {
|
|
85
|
+
'accept': 'application/json;odata=nometadata'
|
|
86
|
+
},
|
|
87
|
+
responseType: 'json'
|
|
88
|
+
};
|
|
89
|
+
const response = await request.get(requestOptions);
|
|
90
|
+
return response.Id;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_SpoContentTypeSyncCommand_instances = new WeakSet(), _SpoContentTypeSyncCommand_initTelemetry = function _SpoContentTypeSyncCommand_initTelemetry() {
|
|
94
|
+
this.telemetry.push((args) => {
|
|
95
|
+
Object.assign(this.telemetryProperties, {
|
|
96
|
+
id: typeof args.options.id !== 'undefined',
|
|
97
|
+
name: typeof args.options.name !== 'undefined',
|
|
98
|
+
listId: typeof args.options.listId !== 'undefined',
|
|
99
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
100
|
+
listUrl: typeof args.options.listUrl !== 'undefined'
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}, _SpoContentTypeSyncCommand_initOptions = function _SpoContentTypeSyncCommand_initOptions() {
|
|
104
|
+
this.options.unshift({
|
|
105
|
+
option: '-u, --webUrl <webUrl>'
|
|
106
|
+
}, {
|
|
107
|
+
option: '-i, --id [id]'
|
|
108
|
+
}, {
|
|
109
|
+
option: '-n, --name [name]'
|
|
110
|
+
}, {
|
|
111
|
+
option: '--listTitle [listTitle]'
|
|
112
|
+
}, {
|
|
113
|
+
option: '--listId [listId]'
|
|
114
|
+
}, {
|
|
115
|
+
option: '--listUrl [listUrl]'
|
|
116
|
+
});
|
|
117
|
+
}, _SpoContentTypeSyncCommand_initValidators = function _SpoContentTypeSyncCommand_initValidators() {
|
|
118
|
+
this.validators.push(async (args) => {
|
|
119
|
+
const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
|
|
120
|
+
if (isValidSharePointUrl !== true) {
|
|
121
|
+
return isValidSharePointUrl;
|
|
122
|
+
}
|
|
123
|
+
if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
|
|
124
|
+
return `${args.options.listId} is not a valid GUID`;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
});
|
|
128
|
+
}, _SpoContentTypeSyncCommand_initTypes = function _SpoContentTypeSyncCommand_initTypes() {
|
|
129
|
+
this.types.string.push('webUrl', 'id', 'name', 'listTitle', 'listId', 'listUrl');
|
|
130
|
+
}, _SpoContentTypeSyncCommand_initOptionSets = function _SpoContentTypeSyncCommand_initOptionSets() {
|
|
131
|
+
this.optionSets.push({
|
|
132
|
+
options: ['id', 'name']
|
|
133
|
+
}, {
|
|
134
|
+
options: ['listId', 'listTitle', 'listUrl'],
|
|
135
|
+
runsWhen: (args) => args.options.listId || args.options.listTitle || args.options.listUrl
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
export default new SpoContentTypeSyncCommand();
|
|
139
|
+
//# sourceMappingURL=contenttype-sync.js.map
|
|
@@ -4,8 +4,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _SpoListItemSetCommand_instances, _SpoListItemSetCommand_initTelemetry, _SpoListItemSetCommand_initOptions, _SpoListItemSetCommand_initValidators, _SpoListItemSetCommand_initTypes, _SpoListItemSetCommand_initOptionSets;
|
|
7
|
-
import os from 'os';
|
|
8
|
-
import config from '../../../../config.js';
|
|
9
7
|
import request from '../../../../request.js';
|
|
10
8
|
import { basic } from '../../../../utils/basic.js';
|
|
11
9
|
import { formatting } from '../../../../utils/formatting.js';
|
|
@@ -35,11 +33,9 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
35
33
|
}
|
|
36
34
|
async commandAction(logger, args) {
|
|
37
35
|
let contentTypeName = '';
|
|
38
|
-
let listId = '';
|
|
39
36
|
try {
|
|
40
37
|
let requestUrl = `${args.options.webUrl}/_api/web`;
|
|
41
38
|
if (args.options.listId) {
|
|
42
|
-
listId = args.options.listId;
|
|
43
39
|
requestUrl += `/lists(guid'${formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
44
40
|
}
|
|
45
41
|
else if (args.options.listTitle) {
|
|
@@ -49,20 +45,6 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
49
45
|
const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
50
46
|
requestUrl += `/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
51
47
|
}
|
|
52
|
-
if (args.options.systemUpdate && !args.options.listId) {
|
|
53
|
-
if (this.verbose) {
|
|
54
|
-
await logger.logToStderr(`Getting list id...`);
|
|
55
|
-
}
|
|
56
|
-
const listRequestOptions = {
|
|
57
|
-
url: `${requestUrl}?$select=Id`,
|
|
58
|
-
headers: {
|
|
59
|
-
'accept': 'application/json;odata=nometadata'
|
|
60
|
-
},
|
|
61
|
-
responseType: 'json'
|
|
62
|
-
};
|
|
63
|
-
const list = await request.get(listRequestOptions);
|
|
64
|
-
listId = list.Id;
|
|
65
|
-
}
|
|
66
48
|
if (args.options.contentType) {
|
|
67
49
|
if (this.verbose) {
|
|
68
50
|
await logger.logToStderr(`Getting content types for list...`);
|
|
@@ -101,94 +83,10 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
101
83
|
await logger.logToStderr(`using content type name: ${contentTypeName}`);
|
|
102
84
|
}
|
|
103
85
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
res = await spo.getRequestDigest(args.options.webUrl);
|
|
110
|
-
}
|
|
111
|
-
if (this.verbose) {
|
|
112
|
-
await logger.logToStderr(`Updating item in list ${args.options.listId || args.options.listTitle || args.options.listUrl} in site ${args.options.webUrl}...`);
|
|
113
|
-
}
|
|
114
|
-
const formDigestValue = args.options.systemUpdate ? res['FormDigestValue'] : '';
|
|
115
|
-
let objectIdentity = '';
|
|
116
|
-
if (args.options.systemUpdate) {
|
|
117
|
-
objectIdentity = await this.requestObjectIdentity(args.options.webUrl, logger, formDigestValue);
|
|
118
|
-
}
|
|
119
|
-
const additionalContentType = (args.options.systemUpdate && args.options.contentType && contentTypeName !== '') ? `
|
|
120
|
-
<Method Name="ParseAndSetFieldValue" Id="1" ObjectPathId="147">
|
|
121
|
-
<Parameters>
|
|
122
|
-
<Parameter Type="String">ContentType</Parameter>
|
|
123
|
-
<Parameter Type="String">${contentTypeName}</Parameter>
|
|
124
|
-
</Parameters>
|
|
125
|
-
</Method>`
|
|
126
|
-
: ``;
|
|
127
|
-
const requestBody = args.options.systemUpdate ?
|
|
128
|
-
`<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
|
|
129
|
-
<Actions>
|
|
130
|
-
${this.mapRequestBody(args.options).join('')}${additionalContentType}
|
|
131
|
-
<Method Name="SystemUpdate" Id="2" ObjectPathId="147" />
|
|
132
|
-
</Actions>
|
|
133
|
-
<ObjectPaths>
|
|
134
|
-
<Identity Id="147" Name="${objectIdentity}:list:${listId}:item:${args.options.id},1" />
|
|
135
|
-
</ObjectPaths>
|
|
136
|
-
</Request>`
|
|
137
|
-
: {
|
|
138
|
-
formValues: this.mapRequestBody(args.options)
|
|
139
|
-
};
|
|
140
|
-
if (args.options.contentType && contentTypeName !== '' && !args.options.systemUpdate) {
|
|
141
|
-
if (this.debug) {
|
|
142
|
-
await logger.logToStderr(`Specifying content type name [${contentTypeName}] in request body`);
|
|
143
|
-
}
|
|
144
|
-
requestBody.formValues.push({
|
|
145
|
-
FieldName: 'ContentType',
|
|
146
|
-
FieldValue: contentTypeName
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const requestOptions = args.options.systemUpdate ?
|
|
150
|
-
{
|
|
151
|
-
url: `${args.options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
152
|
-
headers: {
|
|
153
|
-
'Content-Type': 'text/xml',
|
|
154
|
-
'X-RequestDigest': formDigestValue
|
|
155
|
-
},
|
|
156
|
-
data: requestBody
|
|
157
|
-
} :
|
|
158
|
-
{
|
|
159
|
-
url: `${requestUrl}/items(${args.options.id})/ValidateUpdateListItem()`,
|
|
160
|
-
headers: {
|
|
161
|
-
'accept': 'application/json;odata=nometadata'
|
|
162
|
-
},
|
|
163
|
-
data: requestBody,
|
|
164
|
-
responseType: 'json'
|
|
165
|
-
};
|
|
166
|
-
const response = await request.post(requestOptions);
|
|
167
|
-
let itemId = 0;
|
|
168
|
-
if (args.options.systemUpdate) {
|
|
169
|
-
if (response.indexOf("ErrorMessage") > -1) {
|
|
170
|
-
throw `Error occurred in systemUpdate operation - ${response}`;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
itemId = Number(args.options.id);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
// Response is from /ValidateUpdateListItem POST call, perform get on updated item to get all field values
|
|
178
|
-
const fieldValues = response.value;
|
|
179
|
-
if (fieldValues.some(f => f.HasException)) {
|
|
180
|
-
throw `Updating the items has failed with the following errors: ${os.EOL}${fieldValues.filter(f => f.HasException).map(f => { return `- ${f.FieldName} - ${f.ErrorMessage}`; }).join(os.EOL)}`;
|
|
181
|
-
}
|
|
182
|
-
itemId = fieldValues[0].ItemId;
|
|
183
|
-
}
|
|
184
|
-
const requestOptionsItems = {
|
|
185
|
-
url: `${requestUrl}/items(${itemId})`,
|
|
186
|
-
headers: {
|
|
187
|
-
'accept': 'application/json;odata=nometadata'
|
|
188
|
-
},
|
|
189
|
-
responseType: 'json'
|
|
190
|
-
};
|
|
191
|
-
const item = await request.get(requestOptionsItems);
|
|
86
|
+
const properties = this.mapRequestBody(args.options);
|
|
87
|
+
const item = args.options.systemUpdate ?
|
|
88
|
+
await spo.systemUpdateListItem(requestUrl, args.options.id, logger, this.verbose, properties, contentTypeName)
|
|
89
|
+
: await spo.updateListItem(requestUrl, args.options.id, properties, contentTypeName);
|
|
192
90
|
delete item.ID;
|
|
193
91
|
await logger.log(item);
|
|
194
92
|
}
|
|
@@ -197,7 +95,7 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
197
95
|
}
|
|
198
96
|
}
|
|
199
97
|
mapRequestBody(options) {
|
|
200
|
-
const
|
|
98
|
+
const filteredData = {};
|
|
201
99
|
const excludeOptions = [
|
|
202
100
|
'listTitle',
|
|
203
101
|
'listId',
|
|
@@ -216,57 +114,12 @@ class SpoListItemSetCommand extends SpoCommand {
|
|
|
216
114
|
't',
|
|
217
115
|
'_'
|
|
218
116
|
];
|
|
219
|
-
Object.keys(options)
|
|
220
|
-
if (excludeOptions.
|
|
221
|
-
|
|
222
|
-
requestBody.push(`
|
|
223
|
-
<Method Name="ParseAndSetFieldValue" Id="1" ObjectPathId="147">
|
|
224
|
-
<Parameters>
|
|
225
|
-
<Parameter Type="String">${key}</Parameter>
|
|
226
|
-
<Parameter Type="String">${options[key].toString()}</Parameter>
|
|
227
|
-
</Parameters>
|
|
228
|
-
</Method>`);
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
requestBody.push({ FieldName: key, FieldValue: options[key].toString() });
|
|
232
|
-
}
|
|
117
|
+
for (const key of Object.keys(options)) {
|
|
118
|
+
if (!excludeOptions.includes(key)) {
|
|
119
|
+
filteredData[key] = options[key];
|
|
233
120
|
}
|
|
234
|
-
});
|
|
235
|
-
return requestBody;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Requests web object identity for the current web.
|
|
239
|
-
* This request has to be send before we can construct the property bag request.
|
|
240
|
-
* The response data looks like:
|
|
241
|
-
* _ObjectIdentity_=<GUID>|<GUID>:site:<GUID>:web:<GUID>
|
|
242
|
-
* _ObjectType_=SP.Web
|
|
243
|
-
* ServerRelativeUrl=/sites/contoso
|
|
244
|
-
* The ObjectIdentity is needed to create another request to retrieve the property bag or set property.
|
|
245
|
-
* @param webUrl web url
|
|
246
|
-
* @param cmd command cmd
|
|
247
|
-
*/
|
|
248
|
-
async requestObjectIdentity(webUrl, logger, formDigestValue) {
|
|
249
|
-
const requestOptions = {
|
|
250
|
-
url: `${webUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
251
|
-
headers: {
|
|
252
|
-
'X-RequestDigest': formDigestValue
|
|
253
|
-
},
|
|
254
|
-
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Query Id="1" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="ServerRelativeUrl" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`
|
|
255
|
-
};
|
|
256
|
-
const response = await request.post(requestOptions);
|
|
257
|
-
if (this.debug) {
|
|
258
|
-
await logger.logToStderr('Attempt to get _ObjectIdentity_ key values');
|
|
259
|
-
}
|
|
260
|
-
const json = JSON.parse(response);
|
|
261
|
-
const contents = json.find(x => { return x['ErrorInfo']; });
|
|
262
|
-
if (contents && contents.ErrorInfo) {
|
|
263
|
-
throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
|
|
264
|
-
}
|
|
265
|
-
const identityObject = json.find(x => { return x['_ObjectIdentity_']; });
|
|
266
|
-
if (identityObject) {
|
|
267
|
-
return identityObject['_ObjectIdentity_'];
|
|
268
121
|
}
|
|
269
|
-
|
|
122
|
+
return filteredData;
|
|
270
123
|
}
|
|
271
124
|
}
|
|
272
125
|
_SpoListItemSetCommand_instances = new WeakSet(), _SpoListItemSetCommand_initTelemetry = function _SpoListItemSetCommand_initTelemetry() {
|
|
@@ -4,7 +4,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _SpoPageAddCommand_instances, _SpoPageAddCommand_initTelemetry, _SpoPageAddCommand_initOptions, _SpoPageAddCommand_initValidators;
|
|
7
|
-
import { cli } from '../../../../cli/cli.js';
|
|
8
7
|
import request from '../../../../request.js';
|
|
9
8
|
import { formatting } from '../../../../utils/formatting.js';
|
|
10
9
|
import { spo } from '../../../../utils/spo.js';
|
|
@@ -12,8 +11,6 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
|
12
11
|
import { validation } from '../../../../utils/validation.js';
|
|
13
12
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
14
13
|
import commands from '../../commands.js';
|
|
15
|
-
import spoFileGetCommand from '../file/file-get.js';
|
|
16
|
-
import spoListItemSetCommand from '../listitem/listitem-set.js';
|
|
17
14
|
import { Page, supportedPageLayouts, supportedPromoteAs } from './Page.js';
|
|
18
15
|
class SpoPageAddCommand extends SpoCommand {
|
|
19
16
|
get name() {
|
|
@@ -64,7 +61,8 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
64
61
|
};
|
|
65
62
|
const template = await request.post(requestOptions);
|
|
66
63
|
itemId = template.UniqueId;
|
|
67
|
-
const
|
|
64
|
+
const file = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
|
|
65
|
+
const listItemId = file.Id;
|
|
68
66
|
const pageProps = await Page.checkout(pageName, args.options.webUrl, logger, this.debug, this.verbose);
|
|
69
67
|
if (pageProps) {
|
|
70
68
|
pageId = pageProps.Id;
|
|
@@ -93,15 +91,11 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
93
91
|
break;
|
|
94
92
|
case 'NewsPage':
|
|
95
93
|
const listItemSetOptions = {
|
|
96
|
-
|
|
97
|
-
listUrl: listServerRelativeUrl,
|
|
98
|
-
id: listItemId,
|
|
99
|
-
systemUpdate: true,
|
|
100
|
-
FirstPublishedDate: new Date().toISOString(),
|
|
101
|
-
verbose: this.verbose,
|
|
102
|
-
debug: this.debug
|
|
94
|
+
FirstPublishedDate: new Date().toISOString()
|
|
103
95
|
};
|
|
104
|
-
|
|
96
|
+
const listUrl = urlUtil.getServerRelativePath(args.options.webUrl, listServerRelativeUrl);
|
|
97
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listUrl)}')`;
|
|
98
|
+
await spo.systemUpdateListItem(requestUrl, listItemId, logger, this.verbose, listItemSetOptions);
|
|
105
99
|
break;
|
|
106
100
|
case 'Template':
|
|
107
101
|
requestOptions.url = `${args.options.webUrl}/_api/SitePages/Pages(${listItemId})/SavePageAsTemplate`;
|
|
@@ -212,18 +206,6 @@ class SpoPageAddCommand extends SpoCommand {
|
|
|
212
206
|
this.handleRejectedODataJsonPromise(err);
|
|
213
207
|
}
|
|
214
208
|
}
|
|
215
|
-
async getFileListItemId(webUrl, serverRelativeFileUrl) {
|
|
216
|
-
const fileGetOptions = {
|
|
217
|
-
webUrl: webUrl,
|
|
218
|
-
url: serverRelativeFileUrl,
|
|
219
|
-
asListItem: true,
|
|
220
|
-
verbose: this.verbose,
|
|
221
|
-
debug: this.debug
|
|
222
|
-
};
|
|
223
|
-
const fileGetOutput = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...fileGetOptions, _: [] } });
|
|
224
|
-
const fileGetOutputJson = JSON.parse(fileGetOutput.stdout);
|
|
225
|
-
return fileGetOutputJson.Id;
|
|
226
|
-
}
|
|
227
209
|
}
|
|
228
210
|
_SpoPageAddCommand_instances = new WeakSet(), _SpoPageAddCommand_initTelemetry = function _SpoPageAddCommand_initTelemetry() {
|
|
229
211
|
this.telemetry.push((args) => {
|