Skip to content

Commit e75a544

Browse files
committed
Initial commit
1 parent 87bbbdf commit e75a544

Some content is hidden

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

43 files changed

+17012
-1
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
dist/
3+
CHANGELOG.md
4+
.yarn_home/
5+
src/test/apps/
6+
src/test/types/
7+
src/tools/types/

.eslintrc.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": [
5+
"@typescript-eslint",
6+
],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"prettier",
11+
],
12+
"rules": {
13+
"no-extra-boolean-cast": "off",
14+
"@typescript-eslint/explicit-module-boundary-types": "off",
15+
},
16+
};

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src/test/apps/**/* linguist-documentation
2+
src/tools/types/**/* linguist-documentation
3+
.eslintrc.js linguist-documentation
4+
next.config.js linguist-documentation

.github/workflows/ci.yaml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
12+
test_lint:
13+
runs-on: ubuntu-latest
14+
if: ${{ !github.event.created && github.repository != 'garronej/ts-ci' }}
15+
steps:
16+
- uses: actions/[email protected]
17+
- uses: actions/[email protected]
18+
- uses: bahmutov/npm-install@v1
19+
- name: If this step fails run 'npm run lint' and 'npm run format' then commit again.
20+
run: |
21+
PACKAGE_MANAGER=npm
22+
if [ -f "./yarn.lock" ]; then
23+
PACKAGE_MANAGER=yarn
24+
fi
25+
$PACKAGE_MANAGER run lint:check
26+
$PACKAGE_MANAGER run format:check
27+
test:
28+
runs-on: ${{ matrix.os }}
29+
needs: test_lint
30+
strategy:
31+
matrix:
32+
node: [ '16' ]
33+
os: [ ubuntu-latest ]
34+
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }}
35+
steps:
36+
- name: Tell if project is using npm or yarn
37+
id: step1
38+
uses: garronej/[email protected]
39+
with:
40+
action_name: tell_if_project_uses_npm_or_yarn
41+
- uses: actions/[email protected]
42+
- uses: actions/[email protected]
43+
with:
44+
node-version: ${{ matrix.node }}
45+
- uses: bahmutov/npm-install@v1
46+
- if: steps.step1.outputs.npm_or_yarn == 'yarn'
47+
run: |
48+
yarn build
49+
# yarn test
50+
- if: steps.step1.outputs.npm_or_yarn == 'npm'
51+
run: |
52+
npm run build
53+
npm test
54+
check_if_version_upgraded:
55+
name: Check if version upgrade
56+
# We run this only if it's a push on the default branch or if it's a PR from a
57+
# branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.NPM_TOKEN is
58+
# defined but GitHub Action don't allow it yet.
59+
if: |
60+
github.event_name == 'push' ||
61+
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
62+
runs-on: ubuntu-latest
63+
needs: test
64+
outputs:
65+
from_version: ${{ steps.step1.outputs.from_version }}
66+
to_version: ${{ steps.step1.outputs.to_version }}
67+
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }}
68+
is_release_beta: ${{steps.step1.outputs.is_release_beta }}
69+
steps:
70+
- uses: garronej/[email protected]
71+
id: step1
72+
with:
73+
action_name: is_package_json_version_upgraded
74+
branch: ${{ github.head_ref || github.ref }}
75+
76+
create_github_release:
77+
runs-on: ubuntu-latest
78+
# We create a release only if the version have been upgraded and we are on a default branch
79+
# PR on the default branch can release beta but not real release
80+
if: |
81+
needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' &&
82+
(
83+
github.event_name == 'push' ||
84+
needs.check_if_version_upgraded.outputs.is_release_beta == 'true'
85+
)
86+
needs:
87+
- check_if_version_upgraded
88+
steps:
89+
- uses: softprops/[email protected]
90+
with:
91+
name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }}
92+
tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }}
93+
target_commitish: ${{ github.head_ref || github.ref }}
94+
generate_release_notes: true
95+
draft: false
96+
prerelease: ${{ needs.check_if_version_upgraded.outputs.is_release_beta == 'true' }}
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
publish_on_npm:
101+
runs-on: ubuntu-latest
102+
needs:
103+
- create_github_release
104+
- check_if_version_upgraded
105+
steps:
106+
- uses: actions/[email protected]
107+
with:
108+
ref: ${{ github.ref }}
109+
- uses: actions/[email protected]
110+
with:
111+
node-version: '15'
112+
registry-url: https://registry.npmjs.org/
113+
- uses: bahmutov/npm-install@v1
114+
- run: |
115+
PACKAGE_MANAGER=npm
116+
if [ -f "./yarn.lock" ]; then
117+
PACKAGE_MANAGER=yarn
118+
fi
119+
$PACKAGE_MANAGER run build
120+
- run: npx -y -p [email protected] enable_short_npm_import_path
121+
env:
122+
DRY_RUN: "0"
123+
- name: Publishing on NPM
124+
run: |
125+
if [ "$(npm show . version)" = "$VERSION" ]; then
126+
echo "This version is already published"
127+
exit 0
128+
fi
129+
if [ "$NODE_AUTH_TOKEN" = "" ]; then
130+
echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets"
131+
false
132+
fi
133+
EXTRA_ARGS=""
134+
if [ "$IS_BETA" = "true" ]; then
135+
EXTRA_ARGS="--tag beta"
136+
fi
137+
npm publish $EXTRA_ARGS
138+
env:
139+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
140+
VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }}
141+
IS_BETA: ${{ needs.check_if_version_upgraded.outputs.is_release_beta }}
142+
143+
github_pages:
144+
needs: test
145+
runs-on: ubuntu-latest
146+
if: github.event_name == 'push'
147+
steps:
148+
- uses: actions/checkout@v2
149+
- uses: actions/[email protected]
150+
with:
151+
node-version: '15'
152+
- uses: bahmutov/npm-install@v1
153+
- run: |
154+
yarn build
155+
yarn yarn_link
156+
cd src/test/apps/spa
157+
yarn build
158+
- run: git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git
159+
env:
160+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161+
- run: npx -y -p [email protected] gh-pages -d src/test/apps/cra/build --dest test --add -u "github-actions-bot <[email protected]>"

.gitignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history
38+
39+
.vscode
40+
41+
.DS_Store
42+
43+
/dist
44+
/.yarn_home
45+
/src/assets/gouvfr_dsfr_dist

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
/dist/
3+
/CHANGELOG.md
4+
/.yarn_home/
5+
/src/test/apps/
6+
/src/tools/types/

.prettierrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 4,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false,
7+
"quoteProps": "preserve",
8+
"trailingComma": "none",
9+
"bracketSpacing": true,
10+
"arrowParens": "avoid"
11+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 GitHub user u/garronej
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# react_dsfr
1+
<p align="center">
2+
<i>React implementation of the <a href="https://www.systeme-de-design.gouv.fr/">DSFR</a></i>
3+
</p>
4+
5+
WIP

package.json

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"name": "react_dsfr",
3+
"version": "0.0.1",
4+
"description": "React implementation of the DSFR",
5+
"repository": {
6+
"type": "git",
7+
"url": "git://github.com/codegouvfr/react_dsfr.git"
8+
},
9+
"main": "dist/index.js",
10+
"types": "dist/index.d.ts",
11+
"scripts": {
12+
"build": "rm -rf dist && ts-node src/bin/copy_gouvfr_dsfr_dist_in_assets.ts && tsc && cp -r src/assets dist",
13+
"start_cra": "yarn yarn_link && cd src/test/apps/cra && yarn start",
14+
"start_next": "yarn yarn_link && cd src/test/apps/next && yarn dev",
15+
"lint:check": "eslint . --ext .ts,.tsx",
16+
"lint": "yarn lint:check --fix",
17+
"_format": "prettier '**/*.{ts,tsx,json,md}'",
18+
"format": "yarn _format --write",
19+
"format:check": "yarn _format --list-different",
20+
"yarn_link": "ts-node src/bin/yarn_link.ts"
21+
},
22+
"lint-staged": {
23+
"*.{ts,tsx}": [
24+
"eslint --fix"
25+
],
26+
"*.{ts,tsx,json,md}": [
27+
"prettier --write"
28+
]
29+
},
30+
"husky": {
31+
"hooks": {
32+
"pre-commit": "lint-staged -v"
33+
}
34+
},
35+
"author": "u/garronej",
36+
"license": "MIT",
37+
"files": [
38+
"dist/",
39+
"!dist/test/",
40+
"!dist/esm/test/",
41+
"!dist/tsconfig.tsbuildinfo",
42+
"!dist/esm/tsconfig.tsbuildinfo",
43+
"!dist/package.json"
44+
],
45+
"keywords": [
46+
"dsfr",
47+
"tss-react",
48+
"design system",
49+
"react",
50+
"typescript"
51+
],
52+
"homepage": "https://github.com/codegouvfr/react_dsfr",
53+
"peerDependencies": {
54+
"@types/react": "^16.0.0 || ^17.0.0 || ^18.0.0",
55+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
56+
},
57+
"peerDependenciesMeta": {
58+
"@types/react": {
59+
"optional": true
60+
}
61+
},
62+
"dependencies": {
63+
"@gouvfr/dsfr": "1.7.2"
64+
},
65+
"devDependencies": {
66+
"@types/node": "^18.7.18",
67+
"@types/react": "18.0.9",
68+
"@types/react-dom": "18.0.4",
69+
"@typescript-eslint/eslint-plugin": "^4.24.0",
70+
"@typescript-eslint/parser": "^4.24.0",
71+
"eslint": "^7.26.0",
72+
"eslint-config-prettier": "^8.3.0",
73+
"husky": "^4.3.8",
74+
"lint-staged": "^11.0.0",
75+
"prettier": "^2.3.0",
76+
"react": "18.1.0",
77+
"ts-node": "^10.2.1",
78+
"typescript": "^4.8.3"
79+
}
80+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { join as pathJoin } from "path";
2+
import * as fs from "fs";
3+
4+
const projectDirPath = pathJoin(__dirname, "..", "..");
5+
6+
const destDirPath = pathJoin(projectDirPath, "src", "assets", "gouvfr_dsfr_dist");
7+
8+
{
9+
const assetsDirPath = pathJoin(destDirPath, "..");
10+
11+
if (!fs.existsSync(assetsDirPath)) {
12+
fs.mkdirSync(pathJoin(destDirPath, ".."), { "recursive": true });
13+
}
14+
}
15+
16+
fs.rmSync(destDirPath, { "recursive": true, "force": true });
17+
18+
fs.cpSync(pathJoin(projectDirPath, "node_modules", "@gouvfr", "dsfr", "dist"), destDirPath, {
19+
"recursive": true
20+
});

0 commit comments

Comments
 (0)