зеркало из
1
0
Форкнуть 0

chore: update repo config after migration to azure (#48)

* chore: update repo config after migration to azure
* docs: update license
* chore: remove release-it config
* fix: update tests

Closes #39
This commit is contained in:
Wassim Chegham 2021-01-29 16:00:39 +01:00 коммит произвёл GitHub
Родитель d01866820f
Коммит 26b54c4efa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 120 добавлений и 3493 удалений

Просмотреть файл

@ -1,29 +0,0 @@
{
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular"
}
},
"git": {
"commitMessage": "chore(release): v${version}",
"tagName": "v${version}",
"tagAnnotation": "Release ${version}",
"push": true,
"commit": true
},
"github": {
"release": true,
"preRelease": "alpha",
"releaseName": "v${version}",
"draft": true,
"tokenRef": "GITHUB_TOKEN"
},
"npm": {
"publish": false,
"publishConfig": {
"access": "public"
},
"publishPath": ".",
"tag": "alpha"
}
}

Просмотреть файл

@ -1 +0,0 @@
The SWA EMU project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Microsoft, or any of its subsidiaries or its affiliates.

Просмотреть файл

@ -1,7 +1,18 @@
# Contributing to this project
We would love for you to contribute to the SWA EMU project and help make it even better
than it is today! As a contributor, here are the guidelines we would like you
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
As a contributor, here are the guidelines we would like you
to follow:
- [Code of Conduct](#coc)
@ -13,7 +24,7 @@ to follow:
## <a name="coc"></a> Code of Conduct
You can read about the SWA EMU project code of conduct [here](https://github.com/manekinekko/swa-emulator/blob/master/CODE_OF_CONDUCT.md).
You can read about the SWA EMU project code of conduct [here](https://github.com/azure/static-web-apps-cli/blob/main/CODE_OF_CONDUCT.md).
## <a name="issue"></a> Found an Issue?
@ -44,18 +55,18 @@ We will be insisting on a minimal reproduce scenario in order to save maintainer
Unfortunately we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced.
You can file new issues by filling out our [new issue form](https://github.com/manekinekko/swa-emulator/issues/new).
You can file new issues by filling out our [new issue form](https://github.com/azure/static-web-apps-cli/issues/new).
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
Before you submit your Pull Request (PR) consider the following guidelines:
* Search [GitHub](https://github.com/manekinekko/swa-emulator/pulls) for an open or closed PR
* Search [GitHub](https://github.com/azure/static-web-apps-cli/pulls) for an open or closed PR
that relates to your submission. You don't want to duplicate effort.
* Make your changes in a new git branch:
```shell
git checkout -b my-fix-branch master
git checkout -b my-fix-branch main
```
* Create your patch, **including appropriate test cases**.
@ -77,14 +88,14 @@ Before you submit your Pull Request (PR) consider the following guidelines:
git push origin my-fix-branch
```
* In GitHub, send a pull request to `swa-emulator:master`.
* In GitHub, send a pull request to `static-web-apps-cli:main`.
* If we suggest changes then:
* Make the required updates.
* Re-run the test suites to ensure tests are still passing.
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
```shell
git rebase master -i
git rebase main -i
git push -f
```
@ -101,10 +112,10 @@ from the main (upstream) repository:
git push origin --delete my-fix-branch
```
* Check out the master branch:
* Check out the main branch:
```shell
git checkout master -f
git checkout main -f
```
* Delete the local branch:
@ -113,10 +124,10 @@ from the main (upstream) repository:
git branch -D my-fix-branch
```
* Update your master with the latest upstream version:
* Update your main with the latest upstream version:
```shell
git pull --ff upstream master
git pull --ff upstream main
```
## <a name="rules"></a> Coding Rules
@ -125,8 +136,6 @@ To ensure consistency throughout the source code, keep these rules in mind as yo
* All features or bug fixes **must be tested** by one or more specs (unit-tests or e2e-tests).
* All public API methods **must be documented**.
* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at
**100 characters**.
## <a name="commit"></a> Commit Message Guidelines
@ -208,8 +217,4 @@ reference GitHub issues that this commit **Closes**.
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
A detailed explanation can be found in this [document][commit-message-format].
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
[GitHub]: https://github.com/manekinekko/swa-emulator
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
[GitHub]: https://github.com/azure/static-web-apps-cli

Просмотреть файл

@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)
Copyright (c) 2020 Wassim Chegham
Copyright (c) 2021 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.

41
SECURITY.md Normal file
Просмотреть файл

@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/msrc/pgp-key-msrc).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/msrc/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->

3404
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,9 +1,8 @@
{
"name": "@manekinekko/swa-emu",
"name": "@azure/static-web-apps-cli",
"version": "0.0.1-alpha.7",
"description": "Azure Static Web Apps Emulator for Auth, API and static content",
"scripts": {
"release": "release-it --preRelease=alpha",
"pretest": "npm run build",
"test": "jest --detectOpenHandles --silent --verbose",
"build": "tsc",
@ -14,7 +13,7 @@
"swa": "./dist/cli.js",
"swa-emu": "./dist/cli.js"
},
"author": "Wassim Chegham <github@wassim.dev>",
"author": "Microsoft Corporation",
"dependencies": {
"blessed": "^0.1.81",
"commander": "^5.1.0",
@ -28,7 +27,6 @@
"yaml": "^1.10.0"
},
"devDependencies": {
"@release-it/conventional-changelog": "^1.1.4",
"@types/blessed": "^0.1.17",
"@types/cookie": "^0.4.0",
"@types/http-proxy": "^1.17.4",
@ -39,12 +37,11 @@
"@types/shelljs": "^0.8.8",
"jest": "^26.6.3",
"mock-fs": "^4.13.0",
"release-it": "^13.6.4",
"supertest": "^4.0.2",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2"
},
"homepage": "https://github.com/manekinekko/swa-emulator#readme",
"homepage": "https://github.com/azure/swa-emulator#readme",
"private": false,
"keywords": [
"azure",
@ -56,11 +53,11 @@
"staticwebapp"
],
"bugs": {
"url": "https://github.com/manekinekko/swa-emulator/issues"
"url": "https://github.com/azure/swa-emulator/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/manekinekko/swa-emulator.git"
"url": "https://github.com/azure/swa-emulator.git"
},
"license": "MIT"
}

Просмотреть файл

@ -1,32 +1,32 @@
<p align="center">
<h2 align="center">Azure Static Web Apps Emulator</h2>
<h2 align="center">Azure Static Web Apps CLI</h2>
</p>
<p align="center">
<img align="center" src="docs/swa-emu-icon.png" width="300">
</p>
Introducing SWA EMU, the Azure Static Web Apps Emulator that serves as a local emulator for [Azure Static Web Apps](https://bit.ly/2ZNcakP). It can:
Introducing Static Web Apps CLI, the Azure Static Web Apps CLI that serves as a local development tool for [Azure Static Web Apps](https://bit.ly/2ZNcakP). It can:
- Auto-build your local APP and API
- Auto-build the local static app and API
- Emulate Authentication
- Serve API requests
- Serve static APP assets
- Serve static static app assets
## High-level architecture
![swa emulator architecture](./docs/swa-emu-architecture.png)
![swa cli architecture](./docs/swa-emu-architecture.png)
The SWA EMU is built on top of the following components:
The Static Web Apps CLI is built on top of the following components:
- The Reverse Proxy: this is the heart of the SWA EMU, it's the piece that forwards all HTTP requests to the appropriate components:
- `/.auth/**` requests are forwarded to the Auth Emulator server.
- The Reverse Proxy: this is the heart of the Static Web Apps CLI, it's the piece that forwards all HTTP requests to the appropriate components:
- `/.auth/**` requests are forwarded to the Auth emulator server.
- `/api/**` requests are forwarded to the localhost API function (if available).
- `/**` all other requests are forwarded to the static assets server (serving the front-end app).
- The Auth Emulator server: emulates the whole authentication flow.
- The Auth emulator server: emulates the whole authentication flow.
- The Static content server: serves the local app static content.
- The Serverless API server (baked by the Azure Function App).
- The Serverless API server (served by the Azure Function App).
Before SWA EMU bootstraps, it also can read (using the `--build` options) the local SWA github workflow file (created by [Azure Static Web Apps](https://bit.ly/2ZNcakP)) and builds both the static app and the api according to the user's config. And pretty much like SWA, if the user isn't using an API, SWA EMU will skip the API build.
Before Static Web Apps CLI bootstraps, it also can read (using the `--build` options) the local SWA github workflow file (created by [Azure Static Web Apps](https://bit.ly/2ZNcakP)) and builds both the static app and the api according to the user's config. And pretty much like SWA, if the user isn't using an API, Static Web Apps CLI will skip the API build.
## Authentication emulation flow
@ -36,28 +36,28 @@ The Authentication flow is illustrated in the following sequence diagram (or [op
## Disclaimer
SWA EMU is still in developer preview and not yet ready for prime time. You will encounter issues, so please report them or help us fix them. Your contributions will be very appreciated 🙏
Static Web Apps CLI is still in developer preview and not yet ready for prime time. You will encounter issues, so please report them or help us fix them. Your contributions will be very appreciated 🙏
## Quick start
Using `npm` or `yarn`:
- Install the emulator: `npm install -g @manekinekko/swa-emu@latest`
- Install the cli: `npm install -g @azure/static-web-apps-cli@latest`
- Open a SWA app folder at the root (outside any /api or /app folders): `cd my-awesome-swa-app`
- Start the emulator: `swa`
- Start the cli: `swa`
- Access your SWA app from `http://localhost`
Using `npx`:
- Open a SWA app folder at the root (outside any /api or /app folders): `cd my-awesome-swa-app`
- Start the emulator: `npx @manekinekko/swa-emu@latest`
- Start the cli: `npx @azure/static-web-apps-cli@latest`
- Access your SWA app from `http://localhost`
### Start the emulator from a specific folder
### Start the cli from a specific folder
By default, SWA EMU will start from the current directory `./`. But if you have multiple SWA projects, you can start SWA EMU with a specific folder, and the emulator will use that folder as the `app_location`.
By default, Static Web Apps CLI will start from the current directory `./`. But if you have multiple SWA projects, you can start Static Web Apps CLI with a specific folder, and the cli will use that folder as the `app_location`.
If your SWA project is under `./my-app`, then run the SWA EMU and provide that folder:
If your SWA project is under `./my-app`, then run the Static Web Apps CLI and provide that folder:
```bash
swa ./my-app
@ -65,7 +65,7 @@ swa ./my-app
> Please also note, that running `swa ./my-app` is equivalent to `swa --app-location=./my-app`.
In case the SWA EMU cannot determine the right frontend application artifact (dist) folder to serve, you can override this configuration by providing the `--app-artifact-location` flag:
In case the Static Web Apps CLI cannot determine the right frontend application artifact (dist) folder to serve, you can override this configuration by providing the `--app-artifact-location` flag:
```bash
swa ./my-app --app-artifact-location ./my-app/dist/
@ -73,7 +73,7 @@ swa ./my-app --app-artifact-location ./my-app/dist/
### Use with a local API dev server
When developing locally on your back-end application, it might be useful to use your local API dev server, to serve your API content and benefit from the built-in features like debugging. In order to use SWA EMU with your local API dev server, follow these two steps:
When developing locally on your back-end application, it might be useful to use your local API dev server, to serve your API content and benefit from the built-in features like debugging. In order to use Static Web Apps CLI with your local API dev server, follow these two steps:
1. Start your local API dev server (as usual). For example: `func start host`.
1. Run `swa` with the `--use-api` flag of the URI provided by the API dev server, in the following format:
@ -86,7 +86,7 @@ swa --use-api=http://<api-dev-server-host>:<api-dev-server-port>
When developing locally on your front-end application, it might be useful to use your local application dev server, that comes with your application CLI, to serve your app content and benefit from the built-in feature like the livereload or HMR (hot module reload) features.
In order to use SWA EMU with your local dev server, follow these two steps:
In order to use Static Web Apps CLI with your local dev server, follow these two steps:
1. Start your local dev server (as usual). For example: `ng serve`
1. Run `swa` with the `--use-app` flag of the URI provided by the dev server, in the following format:
@ -118,7 +118,7 @@ Here is a list of the default ports used by popular dev servers:
## Configuration
SWA EMU binds to these default hosts:
Static Web Apps CLI binds to these default hosts:
- `http://localhost:4242`: for _emulated_ authentication.
- `http://localhost:7071`: for the API (baked by the Azure Function App)
@ -142,7 +142,7 @@ If you need to override the default values, provide the following options:
## Local Emulation
The emulator supports local authentication flow and mocks the following providers:
The cli supports local authentication flow and mocks the following providers:
| Provider | [Endpoint](https://docs.microsoft.com/azure/static-web-apps/authentication-authorization?WT.mc_id=javascript-0000-wachegha#login) | Local Emulation |
| -------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------- |
@ -152,7 +152,7 @@ The emulator supports local authentication flow and mocks the following provider
| Facebook | `.auth/login/facbook` | ✅ |
| AAD | `.auth/login/aad` | ✅ |
When requesting the `.auth/me` endpoint, a mocked user `clientPrincipal` will be returned by the emulator. Here is an example:
When requesting the `.auth/me` endpoint, a mocked user `clientPrincipal` will be returned by the cli. Here is an example:
```json
{
@ -165,25 +165,25 @@ When requesting the `.auth/me` endpoint, a mocked user `clientPrincipal` will be
}
```
> NOTE: user roles and ACL are not fully supported (see [#7](https://github.com/manekinekko/swa-emulator/issues/7)).
> NOTE: user roles and ACL are not fully supported (see [#7](https://github.com/azure/static-web-apps-cli/issues/7)).
## Caveats
- Custom routes are not yet supported (see [#6](https://github.com/manekinekko/swa-emulator/issues/6))
- Authorization and roles are not fully supported (see [#7](https://github.com/manekinekko/swa-emulator/issues/7)).
- The emulator is serving all traffic over HTTP (HTTPS support will be added soon) (see [#4](https://github.com/manekinekko/swa-emulator/issues/4)).
- Custom routes are not yet supported (see [#6](https://github.com/azure/static-web-apps-cli/issues/6))
- Authorization and roles are not fully supported (see [#7](https://github.com/azure/static-web-apps-cli/issues/7)).
- The cli is serving all traffic over HTTP (HTTPS support will be added soon) (see [#4](https://github.com/azure/static-web-apps-cli/issues/4)).
- When using GitHub, the OAuth client ID and client secret are provided as-is for dev purposes ONLY. You should create your own OAuth GitHub app!
## Troubleshooting
### Port 4242 is unavailable
This means that there is already an instance of Azure Functions Core Tools (assigned to the Auth Emulator) that is running and bound to the default port `4242`.
This means that there is already an instance of Azure Functions Core Tools (assigned to the Auth emulator) that is running and bound to the default port `4242`.
To fix it, either:
- close the other running instance, and run the emulator again.
- run the emulator using a different port: `--auth-uri=http://localhost:4243`
- close the other running instance, and run the cli again.
- run the cli using a different port: `--auth-uri=http://localhost:4243`
- force close the other instance by killing its processes: `lsof -t -i tcp:4242 | xargs kill`
### Error: listen EADDRINUSE: address already in use 0.0.0.0:4280
@ -196,7 +196,7 @@ To fix it, either:
- run the emulator using a different port: `--port=8081`
- force close the other instance by killing its processes: `lsof -t -i tcp:4280 | xargs kill`
## Want to help? [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/manekinekko/swa-emulator/issues)
## Want to help? [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/azure/static-web-apps-cli/issues)
Want to file a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for [contributing](https://github.com/manekinekko/swa-emulator/blob/master/CONTRIBUTING.md) and then check out one of our issues in the list: [community-help](https://github.com/manekinekko/swa-emulator/issues).
Want to file a bug, contribute some code, or improve the documentation? Excellent! Read up on our guidelines for [contributing](https://github.com/azure/static-web-apps-cli/blob/master/CONTRIBUTING.md) and then check out one of our issues in the list: [community-help](https://github.com/azure/static-web-apps-cli/issues).

Просмотреть файл

@ -26,7 +26,7 @@ describe("runtimeHost", () => {
});
expect(spyDetectRuntime).toHaveBeenCalledWith("./");
expect(rh.command).toContain(path.join("swa-emulator", "node_modules", ".bin", "http-server"));
expect(rh.command).toContain(path.join("static-web-apps-cli", "node_modules", ".bin", "http-server"));
expect(rh.args).toEqual(["./foobar", "--port", "8080", "--cache", "-1", "--proxy", "http://0.0.0.0:4242/?"]);
});
@ -37,7 +37,7 @@ describe("runtimeHost", () => {
});
expect(spyDetectRuntime).toHaveBeenCalledWith("./");
expect(rh.command).toContain(path.join("swa-emulator", "node_modules", ".bin", "http-server"));
expect(rh.command).toContain(path.join("static-web-apps-cli", "node_modules", ".bin", "http-server"));
expect(rh.args).toEqual(["./", "--port", "8080", "--cache", "-1", "--proxy", "http://0.0.0.0:4242/?"]);
});
@ -48,7 +48,7 @@ describe("runtimeHost", () => {
});
expect(spyDetectRuntime).toHaveBeenCalledWith("./");
expect(rh.command).toContain(path.join("swa-emulator", "node_modules", ".bin", "http-server"));
expect(rh.command).toContain(path.join("static-web-apps-cli", "node_modules", ".bin", "http-server"));
expect(rh.args).toEqual(["./", "--port", "8080", "--cache", "-1", "--proxy", "http://127.0.0.1:4242/?"]);
});
@ -59,7 +59,7 @@ describe("runtimeHost", () => {
});
expect(spyDetectRuntime).toHaveBeenCalledWith("./");
expect(rh.command).toContain(path.join("swa-emulator", "node_modules", ".bin", "http-server"));
expect(rh.command).toContain(path.join("static-web-apps-cli", "node_modules", ".bin", "http-server"));
expect(rh.args).toEqual(["./", "--port", "8080", "--cache", "-1", "--proxy", "http://0.0.0.0:3000/?"]);
});
@ -70,7 +70,7 @@ describe("runtimeHost", () => {
});
expect(spyDetectRuntime).toHaveBeenCalledWith("./foobar");
expect(rh.command).toContain(path.join("swa-emulator", "node_modules", ".bin", "http-server"));
expect(rh.command).toContain(path.join("static-web-apps-cli", "node_modules", ".bin", "http-server"));
expect(rh.args).toEqual(["./", "--port", "8080", "--cache", "-1", "--proxy", "http://0.0.0.0:4242/?"]);
});
});