Giter Club home page Giter Club logo

azure / static-web-apps-cli Goto Github PK

View Code? Open in Web Editor NEW
572.0 17.0 103.0 14.53 MB

Azure Static Web Apps CLI ✨

Home Page: https://aka.ms/swa/cli-local-development

License: MIT License

JavaScript 28.28% Shell 1.51% HTML 8.83% TypeScript 44.79% Dockerfile 0.26% C# 0.78% CSS 6.51% Astro 1.42% Python 0.45% Svelte 1.49% Vue 1.99% EJS 0.03% Elm 0.06% Handlebars 1.27% Kotlin 0.01% Swift 0.03% Objective-C 0.01% Dart 0.42% CMake 0.60% C++ 1.27%
azure static web webapp authentication azure-functions serverless cli swa-emulator swa

static-web-apps-cli's Introduction

Azure Static Web Apps CLI

logo

The Static Web Apps CLI, also known as SWA CLI, serves as a local development tool for Azure Static Web Apps. It can:

  • Serve static app assets, or proxy to your app dev server
  • Serve API requests, or proxy to APIs running in Azure Functions Core Tools
  • Emulate authentication and authorization
  • Emulate Static Web Apps configuration, including routing and ACL roles
  • Deploy your app to Azure Static Web Apps

Important Notes

If you have suggestions or you encounter issues, please report them or help us fix them. Your contributions are very much appreciated. 🙏

The CLI emulates commonly used capabilities of the Azure Static Web Apps cloud service. Some differences are expected. Always deploy and test your apps in Azure to confirm behavior.

Quickstart

Installing the CLI with npm, yarn or pnpm:

  • To install the CLI globally, use:

    npm install -g @azure/static-web-apps-cli

    You can also install the SWA CLI inside a project (instead of globally) as a development dependency using npm install -D @azure/static-web-apps-cli. This is highly recommended.

Basic usage

  • Open a SWA app folder at the root (outside any /api or /app folders):

    cd my-awesome-swa-app
  • The best way to get started is to run the swa command alone and follow the interactive prompts:

    swa

It will generate a configuration for you, then build your project and ask if you want to deploy it to Azure.

See swa for more details.

Extended usage

Here are the currently supported swa commands. Use swa <command> --help to learn about options and usage for that particular command.

  • login: login into Azure
  • init: initialize a new static web app project
  • start: start the emulator from a directory or bind to a dev server
  • deploy: deploy the current project to Azure Static Web Apps
  • build: build your project

Using npx:

  • Open a SWA app folder at the root (outside any /api or /app folders):
cd my-awesome-swa-app
  • Create a configuration for your project:
npx @azure/static-web-apps-cli init
  • Start the emulator:
npx @azure/static-web-apps-cli start
  • Access your SWA app from http://localhost:4280

See all available commands and options.

Want to help?

Want to file a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the list: community-help.

static-web-apps-cli's People

Contributors

aaronpowell avatar alexweininger avatar allcontributors[bot] avatar anfibiacreativa avatar anthonychu avatar cjk7989 avatar danwatford avatar dependabot[bot] avatar devansu-yadav avatar georgeosddev avatar horihiro avatar kumaravel95 avatar manekinekko avatar mkarmark avatar neilmispelaar avatar nitya avatar reshmi-sriram avatar rupareddy5-21 avatar santoshyadavdev avatar sgollapudi77 avatar shmool avatar sikebe avatar simonfj20 avatar sinedied avatar snyk-bot avatar stuartleeks avatar sulabh-msft avatar thomasgauvin avatar timdeschryver avatar tush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

static-web-apps-cli's Issues

Accessing /api/* when logged in sometimes crashes proxy

Describe the bug
image

To Reproduce
Steps to reproduce the behavior:

  1. Log in
  2. Navigate to any function /api/anything

Expected behavior
Request should succeed and the auth header should be set.

Actual
Crashes sometimes. See screenshot

Desktop (please complete the following information):

  • OS: macOS
  • SWA CLI version 0.1.0

[Auth Emulation] App doesn't show mocking UI

When I try to navigate to the auth emulation page that mocks a user account, the browser stays on the app and never renders the auth mocking UI.

Steps to reproduce

  1. Run swa start ./public
  2. Navigate to the app in the browser at http://127.0.0.1:4200/ (to verify the local server is working)
  3. Navigate to http://127.0.0.1:4200/.auth/login/github to attempt to emulate a login

Expected behavior

The app should display the auth mocking UI.

Environment

  • OS: Windows 10 Enterprise
  • Browser: Chrome
  • Version: 88.0.4324.190 (Official Build) (64-bit)

Logs

$ swa start ./public
INFO: Found SWA configuration file: C:\Users\cshoe\Documents\data\code\sandbox\swa-cli-demo\.github\workflows\azure-static-web-apps-ambitious-sand-004598a1e.yml
>> detected runtime: node.js
[auth] Auth server listening on http://0.0.0.0:4242
[ swa] SWA listening on http://0.0.0.0:4280        
[ app] Starting up http-server, serving C:\Users\cshoe\Documents\data\code\sandbox\swa-cli-demo\public
[ app] Available on:
[ app]   http://192.168.1.2:4200
[ app]   http://100.64.76.144:4200
[ app]   http://127.0.0.1:4200
[ app]   http://172.30.240.1:4200
[ app] Unhandled requests will be served from: http://0.0.0.0:4280/?
[ app] Hit CTRL-C to stop the server
[ app] [2021-02-25T14:44:36.621Z]  "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
[ app] (node:19428) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
[ app] [2021-02-25T14:44:37.299Z]  "GET /global.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
[ app] [2021-02-25T14:44:37.300Z]  "GET /build/bundle.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
[ app] [2021-02-25T14:44:38.038Z]  "GET /build/bundle.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
[ app] [2021-02-25T14:44:38.865Z]  "GET /favicon.png" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
[ app] [2021-02-25T14:44:58.896Z]  "GET /.auth/login/github" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/88.0.4324.190 Safari/537.36"
[ swa] proxy> GET 0.0.0.0:4280/?/.auth/login/github

WebSocket forwarding to dev server crashes proxy

Describe the bug
App dev server has hot reloading via WebSockets is not working.

To Reproduce

  1. Start a React dev server
  2. swa start http://localhost:3000/

Expected behavior
Hot reloading should work.

Actual behavior
image

proxy.js crashes

Some investigation finds that this is caused by an error triggered by a ws:// request, which executes the error handler that appears to be misconfigured.

proxyApp.on("error", function (err) {
console.log("app>>", req.method, target + req.url);
res.writeHead(500, {
"Content-Type": "text/plain",
});
res.end(err.toString());
});

Desktop (please complete the following information):

  • OS: macOS

remove --api-prefix

We should not allow changing the --api-prefix right now because the service doesn't support this.

Mocking credencial using file

Is your feature request related to a problem? Please describe.

I have to enter credencial every time when verify auth.

Describe the solution you'd like

I want to mock credencial using a file.

Describe alternatives you've considered

Register multiple credencial at once in the UI. However, this is not the root solution.

Additional context

none

Cannot start app without API if there's a folder named api

Describe the bug
When starting the CLI, if the current directory has a folder named api, it is assumed that it's a function app and the CLI attempts to start it.

To Reproduce

  1. Create a folder named api.
  2. swa start http://localhost:3000

Expected behavior
CLI should start without an API.

Actual behavior
CLI attempts to start Azure Functions Core Tools in the api folder.

Desktop (please complete the following information):

  • OS: macOS

Start without the github actions workflow file

Currently, you are required to have created a GitHub Actions workflow file before you're able to use the emulator.

This is because the emulator reads a bunch of stuff out of the workflow file, but it can make for a challenging development flow as you have to have deployed the application before you're able to use the emulator.

It'd be useful if there was a way that you could run the emulator without creating the workflow first.

Runs dotnet run when I don't want it to

Describe the bug
Detects .NET and runs build but I don't want it to do that.

To Reproduce
Steps to reproduce the behavior:

  1. In a folder that has a .csproj file, start the cli for another folder that contains static assets. For example: swa start static
  2. It thinks it's dotnet and runs dotnet run.

Expected behavior
It shouldn't run any kind of build, especially since the folder I'm passing to the CLI isn't even a dotnet app. Even if the folder is a dotnet app, should we automatically do dotnet run or just serve it like static files? I think the expectation is to serve static files. If we want an automatic build, maybe pass a flag.

Support HTTPS locally

Currently, the CLI serves the traffic over HTTP. We need to support HTTPS.

  • generate a valid SSL certificate for localhost (see scripts/cert.sh)
  • use HTTPS for the proxy

Run app with inspect/debug opened

Is your feature request related to a problem? Please describe.
For users to locally debug while running the local emulator, we'll need to expose the ports for debugging/inspecting.

Describe the solution you'd like
I think that for node.js, this should just be running the node process with the inspect flag and specify a port. For C#, we'll have to attach to the process via processId.

Additional context
I'm working on the Static Web Apps Extension and a core scenario for users is to run the emulator locally and then debug via VS Code. The emulator has been awesome so far! 🎉

Discussion - Startup commands

# serve static assets from disk at ./app_artifacts, no api
swa start app_artifacts

# proxy to (ng/react/vue etc) dev server that is already running, no api
swa start http://localhost:4200

# run with api project in ./api
swa start app_artifacts --api api

# run with api project in ./api, but serve api from http://localhost:<port>/functions
swa start app_artifacts --api api --api-prefix functions

# build app with default command (npm run build?) from ./app
# then serve as static assets from build output (./app_artifacts)
swa start app_artifacts --build-app app

# build app with specific command
swa start Client/bin/Debug/net5.0/publish/wwwroot --build-app Client --build-app-command "dotnet publish"

# run with settings in swa.config
swa start 

By default, it can try to search for routes.json or the new config file and use it.

  1. Use the file in the app artifacts folder (if supplied)
  2. Search recursively from current folder and use the first config file that it finds.

Optionally, allow specifying location of the routes/config file:

swa start http://localhost:5000 --config Client/wwwroot/routes.json

How VS Code might start the emulator:

swa start http://localhost:4200 --api api

Move auth and static servers into proxy as middleware logic

The CLI currently spawns multiple servers:

  • proxy server
  • auth server
  • static server

Having multiple servers to manage makes it hard to manage debugging and resources. This also introduces some unexpected behaviors like #96 and #94.

We need to move auth and static servers into proxy as middleware logic. This way we would have only one server to manage: the proxy.

Even if this is an internal change, tagging @craigshoemaker in case we need to update docs once this has been fixed.

Add swa.json config file

Describe the solution you'd like
As a user, I'd like to be able to start swa using a config file. All the CLI flags should be supported.

{
  "options": {
   // CLI flags
  }
}

File name options:

  • swa.json
  • swa.config.json
  • .swarc
  • swa property in package.json

Attempting to close CLI server does not stop all running services [Windows]

On Windows, attempting to close the CLI server using ctrl-c does not stop all running services. Additionally, sometimes a response is very delayed after pressing ctrl-c, and at times there is no response at all.

Steps to reproduce

  1. Start a SWA site with the swa start <APP_LOCATION>
  2. Type ctrl-c to stop the CLI server
  3. Try to start the site again with swa start <APP_LOCATION>
  4. See error 👇

Expected behavior

When you close the CLI server using ctrl-c, all services are stopped so you can start it again successfully.

Desktop

  • OS: Windows
  • Browser: n/a
  • Version: n/a

Error

$ swa start ./__sapper__/export

INFO: Found SWA configuration file: C:\Users\cshoe\Documents\data\code\projects\website\.github\workflows\azure-static-web-apps-red-bay-09fca812.yml
>> detected runtime: node.js
[ swa] SWA listening on http://0.0.0.0:4280
[auth] events.js:288
[auth]       throw er; // Unhandled 'error' event
[auth]       ^
[auth]
[auth] Error: listen EADDRINUSE: address already in use 0.0.0.0:4242
[auth]     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
[auth]     at listenInCluster (net.js:1357:12)
[auth]     at doListen (net.js:1496:7)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)
[auth] Emitted 'error' event on Server instance at:
[auth]     at emitErrorNT (net.js:1336:8)
[auth]     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
[auth]   code: 'EADDRINUSE',
[auth]   errno: 'EADDRINUSE',
[auth]   syscall: 'listen',
  address: '0.0.0.0',
  port: 4242
[auth] }
[ swa] events.js:288
      throw er; // Unhandled 'error' event
[ swa]       ^
[ swa]
[ swa] Error: listen EADDRINUSE: address already in use 0.0.0.0:4280
[ swa]     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
    at listenInCluster (net.js:1357:12)
[ swa]     at doListen (net.js:1496:7)
[ swa]     at processTicksAndRejections (internal/process/task_queues.js:85:21)
Emitted 'error' event on Server instance at:
[ swa]     at emitErrorNT (net.js:1336:8)
[ swa]     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
[ swa]   code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
[ swa]   address: '0.0.0.0',
[ swa]   port: 4280
[ swa] }
[ swa] node ../proxy/server.js exited with code 1
[ swa] node ../proxy/server.js restarted
[auth] node ../auth/server.js --host=0.0.0.0 --port=4242 exited with code 1
[auth] node ../auth/server.js --host=0.0.0.0 --port=4242 restarted
[ app] Starting up http-server, serving C:\Users\cshoe\Documents\data\code\projects\website\__sapper__\export
[ app] Available on:
[ app]   http://192.168.1.2:4200
[ app]   http://100.64.76.144:4200
[ app]   http://127.0.0.1:4200
[ app]   http://172.22.16.1:4200
[ app] Unhandled requests will be served from: http://0.0.0.0:4280/?
[ app] Hit CTRL-C to stop the server
[auth] events.js:288
      throw er; // Unhandled 'error' event
[auth]       ^
[auth]
[auth] Error: listen EADDRINUSE: address already in use 0.0.0.0:4242
[auth]     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
    at listenInCluster (net.js:1357:12)
    at doListen (net.js:1496:7)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)
[auth] Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1336:8)
[auth]     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
[auth]   code: 'EADDRINUSE',
[auth]   errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '0.0.0.0',
[auth]   port: 4242
[auth] }
[ swa] SWA listening on http://0.0.0.0:4280
[ swa] events.js:288
      throw er; // Unhandled 'error' event
[ swa]       ^
[ swa]
[ swa] Error: listen EADDRINUSE: address already in use 0.0.0.0:4280
[ swa]     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
    at listenInCluster (net.js:1357:12)
[ swa]     at doListen (net.js:1496:7)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)
[ swa] Emitted 'error' event on Server instance at:
[ swa]     at emitErrorNT (net.js:1336:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
[ swa]   code: 'EADDRINUSE',
[ swa]   errno: 'EADDRINUSE',
[ swa]   syscall: 'listen',
[ swa]   address: '0.0.0.0',
  port: 4280
[ swa] }
[auth] node ../auth/server.js --host=0.0.0.0 --port=4242 exited with code 1
[ swa] node ../proxy/server.js exited with code 1

Simulate authentication page

Describe the solution you'd like

Instead of directly integrating with all supported providers, use a simulated login page that allows a user to specify the provider, user info, and roles that they want to log in as.

When the app navigates to /.auth/<provider>/login, display the following screen:

image

(the anonymous and authenticated roles are always included when authenticated)

Upon "login", store the provided information in a cookie. When an API endpoint is accessed, add a x-ms-client-principal header using the identity from this cookie.

Accessing /.auth/me returns the info from this cookie.

/.auth/logout clears this cookie.

http-server silently bind to wrong port

If user already has a dev server running on port, eg., 4200, when starting the cli:

swa start dist/angular-web-bluetooth-starter

http-server will silently bind to existing dev server, hence serving the wrong content.

Unable to find concurrently

Describe the bug
When starting the CLI, it can't find concurrently.

To Reproduce

  1. Start react app cd frontend && npm start
  2. swa start http://localhost:3000

Expected behavior
CLI should start.

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Edge

Unable to start with Microsoft Learn sample

Describe the bug

Unable to use with the MSLearn sample.

To Reproduce
Steps to reproduce the behavior:

git clone https://github.com/MicrosoftDocs/mslearn-staticwebapp-api.git
cd mslearn-staticwebapp-api/
cd react-app/
npm i
npm run build
cd ..

Can't find the API:

swa --app-location react-app/build --api-location api-starter --api-prefix api
WARNING: SWA configuration not found.
>> detected runtime: unknown
[auth] Auth server listening on http://127.0.0.1:4242
[ api] No API found. Skipping.
[ app] Starting up http-server, serving /Users/antchu/source/temp/mslearn-staticwebapp-api/
[ app] Available on:
[ app]   http://127.0.0.1:4200
[ app]   http://192.168.187.204:4200
[ app]   http://192.168.187.218:4200
[ app] Unhandled requests will be served from: http://0.0.0.0:80/?
[ app] Hit CTRL-C to stop the server
[ api] ([ -d '/Users/antchu/source/temp/mslearn-staticwebapp-api/api' ] && (cd /Users/antchu/source/temp/mslearn-staticwebapp-api/api; func start --cors *)) || echo 'No API found. Skipping.' exited with code 0
[ swa] >> SWA listening on 0.0.0.0:80

Desktop (please complete the following information):

  • OS: macOS

Rewrite the Auth flow as a raw Node.js HTTP server

Is your feature request related to a problem? Please describe.
The current Auth flow implementation requires azure-functions-core-tools. We would like to remove this dependency.

Describe the solution you'd like
We would like to rewrite the current Auth flow and expose the API as raw Node.js HTTP server.

Providing app/api uri should prevent the emulator from starting its own

Let's say I want to run the APP and/or API myself (maybe they run a compiler like TypeScript), I would run the emulator like so:

$> swa --app-uri=http://localhost:3000 --api-uri=http://localhost:7071

But when it starts up, it'll attempt to run its own proxies for those, and in particular the API will fail as the port is already in use.

Since there's no need for these proxies to be run by the emulator, it should skip trying to start them if you provide the uri.

Prepare for repo migration under azure org repo

TODO

  • rename npm package to @azure/static-web-apps-cli
  • update the readme and rename SWA EMU to Static Web Apps CLI or SWA CLI.
  • change license authors
  • change authors in package.json
  • delete AFFILIATION_NOTICE.md
  • update CODE_OF_CONDUCT.md
  • replace all https://github.com/manekinekko/swa-emulator/ references with the new repo url
  • add repo files requires by Microsoft OSPO (SECURITY.md, ...)
  • rename repo to static-web-apps-cli (Blocked by #1)
  • update the release-it config (Blocked by #51)

CC @anthonychu please add any other items to this checklist.

Port forwarding is incorrect if passing URI for app or api

Describe the bug
If passing a URI of a running dev server or Functions Core Tools, the incorrect ports are used.

To Reproduce

  1. Start a react app
  2. swa start http://localhost:3000
  3. Open http://localhost:4200

Expected behavior
App works in browser

Actual behavior
CLI tries to forward to port 4200 instead of 3000

image

Desktop (please complete the following information):

  • OS: macOS

Serve existing app or api

By default, the emulator will serve api and app from the local folder.

This feature will allow developers to skip serving app and api from the local folder, and serve them from existing endpoints (useful if you are working on a dev version of either app or api).

  • serve from existing app (2b8b4f8)
  • serve from existing api

npm install output not showing

Describe the bug
when running swa --build --verbose. the output from the npm install command does not show up.

To Reproduce
Steps to reproduce the behavior:

  1. Go to your swa project
  2. run swa --build --verbose
  3. The emulator will start but there is no logs during the npm install. The logs will show up after npm finishes installing all the deps.

Expected behavior
when using --verbose, we should see the logs from the npm install command

Auth complete workflow doesn't match SWA

Description of bug

When the auth pipeline hits /.auth/complete the emulator responds with a 302 that sets the location header the emulator host.

Expected outcome

It should return a 200 response with a HTML chunk that does an auth redirect to the path provided in post_login_redirect_uri on the /.auth/login/<provider> query string.

Here's a sample HTML response:

<html><head><title>Working...</title></head><body><form method="GET" name="hiddenform" action="https://purple-plant-04c92a01e.azurestaticapps.net/authentication/login-callback/e71e4fa3-6298-4c01-ab1d-882ab0758110"><noscript><p>Script is disabled. Click Submit to continue.</p><input type = "submit" value = "Submit" /></noscript></form><script language = "javascript">document.forms[0].submit();</script></body></html>

Add project scaffolding

Describe the solution you'd like
As a user I'd like to be able to use swa to scaffold a new project structure.

Example: running swa init should produce the following project structure:

├── api
│   └── <azure functions project>
├── app
│   └── <front-end project>
└── swa.json

Other options/questions:

  • add an interactive mode (like in https://hexa.run)?
  • only scaffold the api folder?

Support monorepos

Is your feature request related to a problem? Please describe.
Currently, running swa inside a monorepo project such as shopathome (by @johnpapa) , will give unexpected behaviors.

Describe the solution you'd like
The emulator needs to support:

  • monorepo projects
  • multiple workflow GitHub files (one per sub-project)

Serve frontend from a folder

As a developer, I'd like to be able to start the emulator and serve the frontend content from a folder.
Example: swa ./app-artifact-location

Adding concurrently as a dependency breaks the emulator

I've installed the emulator as a local devDependency, but I also have concurrently as a local devDependency. Doing this results in the emulator failing to start as it's unable to find the concurrently executable.

It'd probably be better to have concurrently as a peerDependency and use npx to run it, rather than directly using it.

Proxy server process isn't stopped when stopping on ctrl-c

Describe the bug
When stopping the emulator, the proxy server process doesn't get stopped, and keeps running. As a consequence, when restarting the emulator again, we can't bind to port 80.

To Reproduce
Steps to reproduce the behavior:

  1. Start the emulator using the swa --ui command.
  2. Kill the emulator using ctrl-c
  3. Restart the emulator by running the swa command
  4. See error: Error: listen EADDRINUSE: address already in use 0.0.0.0:80

Expected behavior
When stopping the emulat, all servers should stop!

Unable to bind to port 80 on WSL

Describe the bug
When running the emulator in the WSL, an EACCESS error is thrown saying that permissions is denied on port 80. Inspection of the port with lsof will show that the port is free.

To Reproduce
Steps to reproduce the behavior:

  1. Open a terminal instance in WSL on a SWA project
  2. Run swa

image

Expected behavior
The emulator starts and is running on 0.0.0.0:80

Desktop (please complete the following information):

  • OS: Windows 10 v 19042.746
  • Version 0.0.1-alpha.7

Warning about workflow not found can be confusing

Describe the bug
When there's no workflow file in the repo, the CLI prints a warning.

INFO: Azure Static Web Apps configuration not found under ".github/workflows/"

This might mislead the user to believe that a workflow is required. Suggest removing the message. Instead, show a message that config was loaded from the workflow (it's already doing this).

--api flag not respected in Windows Powershell terminal

Describe the bug
Whenever I run swa start .\frontend\build --api .\api from the root of this repo https://github.com/microsoft/vscode-azureappservice/issues, it echoes No API found. Skipping. I've confirmed that this works on MacOS and I have Func Core CLI tools v3.0.3284 installed

To Reproduce
Steps to reproduce the behavior:

  1. Clone and npm install/npm build project https://github.com/microsoft/vscode-azureappservice/issues
  2. From root, run command swa start .\frontend\build --api .\api
  3. API not found error

Expected behavior
For the API folder to be recognized and start running the func core tools

Desktop (please complete the following information):

  • OS: Windows 10 Pro

Check if Azure Functions Core Tools is available before starting the api

Is your feature request related to a problem? Please describe.
When the swa cli tries to star the api project using the func cli (Azure Functions Core Tools). If func is not available, this would trigger an error, an the api won't be emulated.

Describe the solution you'd like
Check if the func cli is already installed. If not, show a warning message or abort the whole process.

Additional context
This should work across all supported platforms.

cc @anthonychu

remove --use-app and --use-api

The current CLI ergonomics are:

swa start ./dist-folder-or-server --api=./api-or-server

We don't anymore need --use-app and --use-api.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.