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

Static Apps\Sites #4192

Open
adamdriscoll opened this issue Jan 3, 2025 · 1 comment
Open

Static Apps\Sites #4192

adamdriscoll opened this issue Jan 3, 2025 · 1 comment
Labels
enhancement New feature or request PowerShell Universal Issue relates to PowerShell Universal.

Comments

@adamdriscoll
Copy link
Member

adamdriscoll commented Jan 3, 2025

Summary of the new feature / enhancement

It would be possible to utilize the existing App cmdlets and react client-side JavaScript to produce a static site generator with PSU. You could either host it in PSU or export it into a deployable ZIP that just contained the react app and one or more JSON files from the output of the cmdlets.

Static sites wouldn't support any interaction from PowerShell but could actually load data in a chunked manner to improve performance. Some components wouldn't make sense to provide in static sites (e.g. UDDataGrid) but it would be possible to inject a bit of JavaScript using New-UDEndpoint to allow basic interactivity from a client-side level.

PSU Hosting

In PSU, you could mark an app as static. The editor would load some custom PSScriptAnalyzer rules to ensure that users are aware of which cmdlets won't work. When the app is "started", it will just generate one or more JSON files that contain the output from the New-UD* cmdlets. PSU already hosts the React app, so it would just serve the JSON files rather than calling PowerShell at all.

If we built it right, you might be able to just call the PSU cmdlets without the server at all to generate the static site since the cmdlets already contain the React app.

Publish-PSUStaticApp -Content {
    New-UDApp -Content {
        "Hello, world!"
    }
} -Path .\mySite

There would then be a way to export the PSU app into a ZIP for hosting elsewhere.

External Hosting

Since static sites would just be JavaScript and JSON, it would be possible to host on very simple providers, like Azure Blob Storage. The ZIP could be extracted and served by these web servers without the need for any custom backend.

Caveats

Due to how PSU Apps are designed, it really wouldn't be a true static site, in terms of SEO. PSU Apps call back to the serve to get more data. Usually, this is done with PowerShell but in a static PSU app, it would just return JSON. Since this JSON isn't standard HTML until the JS renders it, web crawlers wouldn't (easily) discover the document contents.

Proposed technical implementation details (optional)

No response

@adamdriscoll adamdriscoll added enhancement New feature or request PowerShell Universal Issue relates to PowerShell Universal. labels Jan 3, 2025
@cdhunt
Copy link

cdhunt commented Jan 3, 2025

SEO is a valid concern along with caching and would potentially limit my personal use cases but would still be a very useful tool.

At $job[-1] we generate a lot of static reporting files from air-gapped environments: CSV; JSON; plain text; and Excel. In that scenario I want to define a "template" to generate a consistent artifact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PowerShell Universal Issue relates to PowerShell Universal.
Projects
None yet
Development

No branches or pull requests

2 participants