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: generate SPFx package #2367

Closed
waldekmastykarz opened this issue Apr 16, 2021 · 17 comments
Closed

New command: generate SPFx package #2367

waldekmastykarz opened this issue Apr 16, 2021 · 17 comments

Comments

@waldekmastykarz
Copy link
Member

waldekmastykarz commented Apr 16, 2021

Original idea by @wobba

Usage

spfx package generate [options]

Description

Generates SharePoint Framework solution package with a no-framework web part rendering the specified HTML snippet.

Options

Option Description
-t, --webPartTitle <webPartTitle> Title of the generated web part. Displayed in the web part toolbox
-d, --webPartDescription <webPartDescription> Description of the generated web part. Displayed in the web part toolbox
-n, --packageName <packageName> Name of the generated .sppkg file
--html <html> HTML to render in the web part
--enableForTeams [enableForTeams] Determines if the web part should be available as a Teams app. Allowed values tab, personalApp, all
--developerName [developerName] Name of your organization. Defaults to Contoso
--developerPrivacyUrl [developerPrivacyUrl] Privacy URL. Defaults to https://contoso.com/privacy
--developerTermsOfUseUrl [developerTermsOfUseUrl] Terms of use URL. Defaults to https://contoso.com/terms-of-use
--developerWebsiteUrl [developerWebsiteUrl] Website URL. Defaults to https://contoso.com/my-app
--developerMpnId [developerMpnId] Microsoft Partner ID. Defaults to 000000

Additional Information

This command is meant to quickly generate a SharePoint Framework solution package with a web part that renders the specified HTML fragment. It's meant for cases, when you want to embed a piece of HTML in Microsoft Teams or your SharePoint portal but don't want to create a whole SharePoint Framework project.

@waldekmastykarz waldekmastykarz added help wanted needs peer review Needs second pair of eyes to review the spec or PR new feature labels Apr 16, 2021
@waldekmastykarz
Copy link
Member Author

@pnp/cli-for-microsoft-365-maintainers I'd appreciate your feedback

@wobba
Copy link

wobba commented Apr 17, 2021

Should we have switches to isolate css, allow/disallow scripts?

@waldekmastykarz
Copy link
Member Author

Since the web part embeds the predefined HTML snippet and doesn't allow users to change it after adding the web part on the page, I don't think we need the requires custom script flag.

As for CSS, would you see users specify a separate link tag that would be added to the head section of the page or could they include it along with the HTML snippet and it would be added to the body?

@wobba
Copy link

wobba commented Apr 18, 2021

In many ways I think I envision wrapping the scripted wp - but at the same time adding options for isolation as we have in the markup for the search wp do make sense. The isolation spectrum is a scale sort of.

@waldekmastykarz
Copy link
Member Author

Ah, so you mean to introduce a flag that allows producing an isolated web part?

@wobba
Copy link

wobba commented Apr 18, 2021

That's an option...was more thinking css santization for onpage embedding. But multiple options to look at for sure.

@waldekmastykarz
Copy link
Member Author

How would you see us do CSS isolation?

@wobba
Copy link

wobba commented Apr 19, 2021

@waldekmastykarz For modern search we add a random container ID at the top, and merge whatever CSS you have in your below that parent. This ensures you cannot influence CSS upwards/outside from your markup.

@waldekmastykarz
Copy link
Member Author

Since we're not using .scss, wouldn't that mean though, that we need to update all CSS selectors to the web part div/parent container? Also, if you'd include a link element in the HTML snippet to embed, wouldn't that allow you to circumvent our escaping technique anyway?

@wobba
Copy link

wobba commented Apr 19, 2021

Good point, and it's input to what we could add. But for the first version let's do KISS :) There are multiple ways to handle links, you could let the browser handle them, or you parse them out and load them using code - giving you parsing control.

@waldekmastykarz
Copy link
Member Author

Like you said, let's start simple, gauge interest and evolve.

@garrytrinder
Copy link
Member

I like the spec, however I'm curious about the --enableTeams option what will this do? Is it adding TeamsTab or TeamsPersonalApp to the supportedHosts array in the web part manifest?

@wobba
Copy link

wobba commented Apr 23, 2021

@garrytrinder could be either one or both, so maybe some enum option.

@waldekmastykarz
Copy link
Member Author

Originally I thought about a simple switch to do both, like you mentioned @garrytrinder. Not sure if it's necessary for us to let users choose or if we simply offer them an easy way out. Whichever you think would be more valuable.

@garrytrinder
Copy link
Member

I think it's always good to give the user the option and be more explicit.

I agree with @wobba either one or both would be my preferred option.

@waldekmastykarz
Copy link
Member Author

I've updated the spec to let user specify how the web part should be exposed in Teams

@waldekmastykarz waldekmastykarz removed the needs peer review Needs second pair of eyes to review the spec or PR label May 4, 2021
@waldekmastykarz waldekmastykarz self-assigned this May 9, 2021
waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Jun 11, 2021
waldekmastykarz added a commit to waldekmastykarz/cli-microsoft365 that referenced this issue Jun 12, 2021
@waldekmastykarz waldekmastykarz added this to the v3.11 milestone Jun 14, 2021
@wobba
Copy link

wobba commented Jun 14, 2021

Awesome! :)

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.

3 participants