Skip to content

Commit

Permalink
feat: bring wingdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
eladb committed Jun 20, 2024
1 parent 23d298a commit 0938081
Show file tree
Hide file tree
Showing 62 changed files with 21,256 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/canary.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .github/workflows/pull-request-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
tsoa
vite
websockets
wingdocs
subjectPattern: ^[^A-Z][^:]+[^.]$
subjectPatternError: Subject must start with a lowercase, should not include ':'
and should not end with a period
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/wingdocs-pull.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions .github/workflows/wingdocs-release.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .mergify.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ publishing them for you.
| [tsoa](./tsoa) | [@winglibs/tsoa](https://www.npmjs.com/package/@winglibs/tsoa) | sim |
| [vite](./vite) | [@winglibs/vite](https://www.npmjs.com/package/@winglibs/vite) | sim, tf-aws |
| [websockets](./websockets) | [@winglibs/websockets](https://www.npmjs.com/package/@winglibs/websockets) | awscdk, sim, tf-aws |
| [wingdocs](./wingdocs) | [@winglibs/wingdocs](https://www.npmjs.com/package/@winglibs/wingdocs) | sim |

_Generated with `mkrepo.sh`. To update the list of supported platforms for a winglib, please update the "wing" section in its package.json file._

Expand Down
2 changes: 2 additions & 0 deletions wingdocs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
node_modules/
3 changes: 3 additions & 0 deletions wingdocs/.gitigore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
node_modules

21 changes: 21 additions & 0 deletions wingdocs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Wing

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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.
66 changes: 66 additions & 0 deletions wingdocs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# wingdocs

A markdown-based documentation system. Unsurprisingly, great for stuff like [the Wing Documentation](https://winglang.io/docs).

## Prerequisites

* [winglang](https://winglang.io).

## Installation

```sh
npm i @winglibs/wingdocs
```

## Usage

Create `main.w`:

```js
bring wingdocs;

new wingdocs.Site(
source: "{@dirname}/docs", // location of your docs markdown tree
title: "Dokidokidocs",
// more configuration coming soon...
);
```

Create `docs/index.md`:

```md
Hello, I am your docs!
```

Run in the simulator:

```sh
wing it
```

Deploy to AWS (via CloudFront):

```sh
wing compile -t tf-aws
cd target/main.tfaws
terraform init
terraform apply
```

(You'll need AWS credentials)

## Roadmap

- Blog
- Additional sections ("contributing")
- Winglibs documentation (with API docs)
- Patterns
- Playground
- Multi-language
- Learn (guided tutorials)
- Patterns


## License

This library is licensed under the [MIT License](./LICENSE).
22 changes: 22 additions & 0 deletions wingdocs/base-template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader
.history

# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
21 changes: 21 additions & 0 deletions wingdocs/base-template/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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.
57 changes: 57 additions & 0 deletions wingdocs/base-template/auth0/notify-slack-action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const axios = require('axios');
const dayjs = require('dayjs');

const channelWebhook = 'https://hooks.slack.com/services/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';

/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
console.info('user_id: ', event.user.user_id);
console.info('client_id: ', event.client.client_id);

if (event.client.name !== 'Docs') {
console.info('Not logging into Docs, so not notifying anything');
return;
}

const user = event.user;
if (dayjs(event.user.created_at) < dayjs().subtract(1, 'minute') || event.stats.logins_count > 1) {
return;
}

const encodedUserUri = Buffer.from(encodeURIComponent(user.user_id)).toString('base64').replace(/=/gi, '');

console.info({user});
const prompt = `A new user, ${user.email}, has tried logging into the Docs site!`;
await axios.post(channelWebhook, {
text: prompt,
blocks: [
{
type: 'section',
text: {
type: 'plain_text',
text: 'Should this user have access to the Wing Alpha?'
}
},
{
type: 'section',
text: {
type: 'plain_text',
text: prompt
}
},
{
type: 'section',
text: {
type: 'mrkdwn',
text: `https://manage.auth0.com/dashboard/us/dev-9zrd68w6/users/${encodedUserUri}`
}
}
]
});

};
15 changes: 15 additions & 0 deletions wingdocs/base-template/auth0/roles-rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function addRoles(user, context, callback) {
const namespace = 'https://winglang.io';
const assignedRoles = (context.authorization || {}).roles;

let idTokenClaims = context.idToken || {};
let accessTokenClaims = context.accessToken || {};

idTokenClaims[`${namespace}/roles`] = assignedRoles;
accessTokenClaims[`${namespace}/roles`] = assignedRoles;

context.idToken = idTokenClaims;
context.accessToken = accessTokenClaims;

callback(null, user, context);
}
3 changes: 3 additions & 0 deletions wingdocs/base-template/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
3 changes: 3 additions & 0 deletions wingdocs/base-template/contributing_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"latest"
]
Loading

0 comments on commit 0938081

Please sign in to comment.