Skip to content

Commit b9b1651

Browse files
committed
Add 'styleguide/' from commit '78be725e01b8d511c244009cb8622f43f11f2547'
git-subtree-dir: styleguide git-subtree-mainline: a431203 git-subtree-split: 78be725
2 parents a431203 + 78be725 commit b9b1651

276 files changed

Lines changed: 34860 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

styleguide/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*.{ts,tsx,js}]
4+
indent_size = 2

styleguide/.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Slash Command Dispatch
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
slash-command-dispatch:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v3
12+
id: get-pr
13+
with:
14+
script: |
15+
const request = {
16+
owner: context.repo.owner,
17+
repo: context.repo.repo,
18+
pull_number: context.issue.number
19+
}
20+
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
21+
try {
22+
const result = await github.pulls.get(request)
23+
return result.data
24+
} catch (err) {
25+
core.setFailed(`Request failed with error ${err}`)
26+
}
27+
- name: Slash Command Dispatch
28+
uses: peter-evans/slash-command-dispatch@v2
29+
with:
30+
token: ${{ secrets.BOT_TOKEN }}
31+
reaction-token: ${{ secrets.BOT_TOKEN }}
32+
permission: write
33+
dispatch-type: workflow
34+
event-type-suffix: ""
35+
commands: |
36+
deploy
37+
static-args: |
38+
comment-id=${{ github.event.comment.id }}
39+
event-number=${{ github.event.issue.number }}
40+
ref=${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
41+
- name: Edit comment with error message
42+
if: steps.scd.outputs.error-message
43+
uses: peter-evans/create-or-update-comment@v1
44+
with:
45+
comment-id: ${{ github.event.comment.id }}
46+
body: |
47+
> ${{ steps.scd.outputs.error-message }}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Deploy Styleguide
2+
3+
concurrency: deploy
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- "src/**/*"
11+
- "package.json"
12+
- ".github/workflows/deploy.yml"
13+
- "tsconfig.json"
14+
workflow_dispatch:
15+
inputs:
16+
comment-id:
17+
description: "The comment-id of the slash command"
18+
required: true
19+
event-number:
20+
description: "The event-id of the slash command"
21+
required: true
22+
23+
permissions:
24+
id-token: write
25+
contents: read
26+
27+
jobs:
28+
deploy:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
persist-credentials: false
34+
ref: ${{ github.ref }}
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: 20
38+
registry-url: "https://registry.npmjs.org"
39+
- name: Cache pnpm modules
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.pnpm-store
43+
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-
46+
- uses: pnpm/action-setup@v2.1.0
47+
with:
48+
version: 9.0.6
49+
run_install: true
50+
- name: Metadata
51+
id: metadata
52+
run: echo "::set-output name=commit::$(git rev-parse HEAD)"
53+
- name: Find Release Comment
54+
uses: peter-evans/find-comment@v3
55+
id: find_comment
56+
if: ${{ github.ref != 'refs/heads/main' }}
57+
with:
58+
token: ${{ secrets.BOT_TOKEN }}
59+
issue-number: ${{ github.event.inputs.event-number }}
60+
comment-author: pythonitaliabot
61+
body-includes: "Pre-release"
62+
- name: Create or update comment
63+
id: initial-comment
64+
uses: peter-evans/create-or-update-comment@v4
65+
if: ${{ github.ref != 'refs/heads/main' }}
66+
with:
67+
token: ${{ secrets.BOT_TOKEN }}
68+
comment-id: ${{ steps.find_comment.outputs.comment-id }}
69+
issue-number: ${{ github.event.inputs.event-number }}
70+
body: |
71+
# Pre-release
72+
:wave:
73+
74+
Releasing commit [${{ steps.metadata.outputs.commit }}] to NPM as pre-release! :package:
75+
edit-mode: replace
76+
- name: Update version
77+
if: ${{ github.ref == 'refs/heads/main' }}
78+
run: pnpm version patch --no-git-tag-version
79+
- name: Update to pre-release version
80+
if: ${{ github.ref != 'refs/heads/main' }}
81+
run: |
82+
pnpm version patch --no-git-tag-version
83+
new_version=$(node -e "console.log(require('./package.json').version);")
84+
pnpm version $new_version-rc${{ steps.metadata.outputs.commit }} --no-git-tag-version
85+
- name: Build & Publish
86+
id: release
87+
run: |
88+
pnpm publish --tag ${{ fromJSON('["pr", "latest"]')[github.ref == 'refs/heads/main'] }} --no-git-checks
89+
new_version=$(node -e "console.log(require('./package.json').version);")
90+
echo "::set-output name=version::$new_version"
91+
- name: Commit version
92+
if: ${{ github.ref == 'refs/heads/main' }}
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
95+
run: |
96+
new_version=$(node -e "console.log(require('./package.json').version);")
97+
98+
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }}
99+
git config user.name "Python Italia [bot]"
100+
git config user.email "noreply@python.it"
101+
git add package.json
102+
git commit -m "🔨 Publish Styleguide v$new_version [skip ci]"
103+
git push
104+
- name: Create or update comment
105+
uses: peter-evans/create-or-update-comment@v3
106+
if: ${{ github.ref != 'refs/heads/main' }}
107+
with:
108+
token: ${{ secrets.BOT_TOKEN }}
109+
comment-id: ${{ steps.initial-comment.outputs.comment-id }}
110+
issue-number: ${{ github.event.inputs.event-number }}
111+
body: |
112+
# Pre-release
113+
:wave:
114+
115+
Pre-release **${{ steps.release.outputs.version }}** [${{ steps.metadata.outputs.commit }}] has been released on NPM! :rocket:
116+
You can try it by doing:
117+
```shell
118+
pnpm add @python-italia/pycon-styleguide@${{ steps.release.outputs.version }}
119+
```
120+
edit-mode: replace

styleguide/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
storybook-static/

styleguide/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
auto-install-peers = true
2+

styleguide/.storybook/main.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
stories: ["../src/**/*.stories.tsx"],
5+
addons: [
6+
"@storybook/addon-essentials",
7+
{
8+
name: "@storybook/addon-postcss",
9+
options: {
10+
postcssLoaderOptions: {
11+
implementation: require("postcss"),
12+
},
13+
},
14+
},
15+
],
16+
webpackFinal: async (config) => {
17+
config.module.rules.push({
18+
test: /\.(ts|tsx)$/,
19+
loader: require.resolve("babel-loader"),
20+
options: {
21+
presets: [["react-app", { flow: false, typescript: true }]],
22+
},
23+
});
24+
25+
config.module.rules.push({
26+
test: /\.mjs$/,
27+
include: /node_modules/,
28+
type: "javascript/auto",
29+
});
30+
31+
config.resolve.extensions.push(".ts", ".tsx", ".mjs");
32+
33+
return config;
34+
},
35+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<link rel="stylesheet" href="https://use.typekit.net/mbr7dqb.css" />

styleguide/.storybook/preview.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import "../src/base.css";
2+
import "../src/custom.css";
3+
import {IntlProvider} from 'react-intl'
4+
5+
export const parameters = {
6+
actions: { argTypesRegex: "^on[A-Z].*" },
7+
layout: "fullscreen",
8+
};
9+
10+
export const decorators = [
11+
(Story) => (
12+
<IntlProvider locale="en" defaultLocale="en">
13+
<Story />
14+
</IntlProvider>
15+
),
16+
];

styleguide/.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 18.17.1

0 commit comments

Comments
 (0)