Skip to content
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

New Command: Sync a content type from the content type hub to a site #5551

Closed
martinlingstuyl opened this issue Oct 7, 2023 · 8 comments
Closed
Assignees
Milestone

Comments

@martinlingstuyl
Copy link
Contributor

martinlingstuyl commented Oct 7, 2023

Usage

m365 spo contenttype sync [options]

Description

Adds a published content type from the content type hub to a site or syncs its latest changes

Options

Option Description
-u, --webUrl <webUrl> The site to sync the Content Type to.
-i, --id [id] The Id of the published Content Type to sync from the Content Type Hub. Specify either id or name.
-n, --name [name] The name of the published Content Type to sync from the Content Type Hub. Specify either id or name.
--listTitle [listTitle] Title of the list. Specify either listTitle, listId or listUrl. Omit to sync as a site content type.
--listId [listId] ID of the list. Specify either listTitle, listId or listUrl. Omit to sync as a site content type.
--listUrl [listUrl] Server- or site-relative URL of the list. Specify either listTitle, listId or listUrl. Omit to sync as a site content type.

Examples

Syncs a given published content type from the hub to the specified site.

m365 spo contenttype sync —webUrl https://contoso.sharepoint.com/sites/sales --id 0x01007926A45D687BA842B947286090B8F67D

Syncs a given published content type from the hub to the specified site and adds it to the specified list.

m365 spo contenttype sync —webUrl https://contoso.sharepoint.com/sites/sales --id 0x01007926A45D687BA842B947286090B8F67D --listTitle Contacts

Response

The api response should be returned

Additional info

The id property should be added to the types.strings array, to force minimist to parse it as string!

The following endpoint should be used:

https://learn.microsoft.com/en-us/graph/api/contenttype-addcopyfromcontenttypehub?view=graph-rest-1.0&tabs=http

@martinlingstuyl martinlingstuyl added new feature needs peer review Needs second pair of eyes to review the spec or PR labels Oct 7, 2023
@waldekmastykarz
Copy link
Member

Could we also allow syncing the content type by name?

@waldekmastykarz
Copy link
Member

Also, since contenttype is the last noun we can shorten contentTypeId to id

@waldekmastykarz
Copy link
Member

For the ID we need to force it to be treated as a string or bash will assume a hex digit because of the 0x prefix

@martinlingstuyl
Copy link
Contributor Author

Could we also allow syncing the content type by name?

A, good idea!

We'd need to get it from the hub first, but that should be possible.

@martinlingstuyl
Copy link
Contributor Author

martinlingstuyl commented Oct 8, 2023

Any other comments before we open this up? @pnp/cli-for-microsoft-365-maintainers

@Jwaegebaert
Copy link
Contributor

I've got nothing else to add. Good catch on this one!

@milanholemans
Copy link
Contributor

For the ID we need to force it to be treated as a string or bash will assume a hex digit because of the 0x prefix

As mentioned before, in fact, we should (for now) always parse all options as string. Image, for example, the option listId here, the user could provide a value like 123 as listId. Minimist will parse it as a number and the whole validation would fail because we assume the value is a string.
Therefore it's best that every option that is typed as string in the interface, is typed as string in the args parser as well. Otherwise, we have no guarantee that the option is actually a string and not something else.

@martinlingstuyl martinlingstuyl added help wanted hacktoberfest Issue perfect for hacktoberfest and removed needs peer review Needs second pair of eyes to review the spec or PR labels Oct 8, 2023
@milanholemans milanholemans removed the hacktoberfest Issue perfect for hacktoberfest label Nov 6, 2023
@MathijsVerbeeck
Copy link
Contributor

Can I work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants