Skip to content

Commit d1362ff

Browse files
Merge pull request #580 from dijitali/chore/add-dockerised-prettier
Chore/add dockerised prettier
2 parents 994f28d + af9ac2d commit d1362ff

File tree

5 files changed

+62
-5
lines changed

5 files changed

+62
-5
lines changed

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://prettier.io/docs/en/ignore.html
2+
3+
# Ignore Vocabulary files (formatting handled upstream)
4+
src/vocabulary/

.prettierrc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# https://prettier.io/docs/en/options.html#print-width
2+
printWidth: 79
3+
4+
# https://prettier.io/docs/en/options.html#bracket-line
5+
bracketSameLine: true
6+
7+
# https://prettier.io/docs/en/options.html#single-attribute-per-line
8+
singleAttributePerLine: true

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ Once changes are implemented here, they need to be updated within the `/chooser`
5353

5454
Final production changes are deployed within vocabulary-theme Releases, updated within [`index-dev-env`][index-dev-env], and finally deployed to `index__stage` and then `index__prod` environments; going LIVE at `https://creativecommons.org/chooser`.
5555

56-
57-
## Setup
58-
1. open the `src/index.html` file within a browser to view the Chooser.
59-
6056
[cc-legal-tools-app]: https://github.com/creativecommons/cc-legal-tools-app
6157
[cc-legal-tools-data]: https://github.com/creativecommons/cc-legal-tools-data
6258
[index-dev-env]: https://github.com/creativecommons/index-dev-env
@@ -65,11 +61,34 @@ Final production changes are deployed within vocabulary-theme Releases, updated
6561
[vocabulary-theme]: https://github.com/creativecommons/vocabulary-theme
6662

6763

64+
### Setting up the Project
65+
66+
For information on learning and installing the prerequisite technologies for this project, please see [Foundational technologies — Creative Commons Open Source][found-tech].
67+
68+
[found-tech]: https://opensource.creativecommons.org/contributing-code/foundational-tech/
69+
70+
1. open the `src/index.html` file within a browser to view the Chooser.
71+
72+
### Format with Prettier
73+
74+
Run the following command to format files with Prettier:
75+
76+
```shell
77+
docker compose run node prettier --write src/
78+
```
79+
80+
```shell
81+
## Or alternatively, if docker compose run is slow to run
82+
docker compose up --detach
83+
docker compose exec node prettier --write src/
84+
docker compose down
85+
```
86+
6887
## Structure
6988

7089
The initial markup is rendered via the `index.html` file. Visual display is derived from the `style.css` rules. Styles extend from `src/vocabulary`.
7190

72-
On initlialization the `scripts.js` functions set the correct fieldsets to default display; based on user provided actions through the stepper fieldsets will display or hide, exposing the relevant pathways to getting a `tool` recommendation. Correct pathways are located within the `rawStatePathRoutes` array. When a correct pathway matches the current `state`, the appropriate `tool` is matched and recommended, if the current state is not a known pathway the `tool` is set to `unknown` until the required input is given.
91+
On initialization the `scripts.js` functions set the correct fieldsets to default display; based on user provided actions through the stepper fieldsets will display or hide, exposing the relevant pathways to getting a `tool` recommendation. Correct pathways are located within the `rawStatePathRoutes` array. When a correct pathway matches the current `state`, the appropriate `tool` is matched and recommended, if the current state is not a known pathway the `tool` is set to `unknown` until the required input is given.
7392

7493
The main `tool` recommendation content is pulled via the appropriate `<template>` markup located within HTML. Additional information for the marking formats is also sourced from these `<template>` elements and the contents of the `Attribution Details` fields.
7594

dev/node/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://docs.docker.com/engine/reference/builder/
2+
3+
# https://hub.docker.com/_/node
4+
FROM node:bookworm-slim
5+
6+
RUN npm install --global prettier

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: chooser
2+
services:
3+
node:
4+
build:
5+
context: .
6+
dockerfile: dev/node/Dockerfile
7+
# Continue running until shutdown (this allows docker compose exec which is
8+
# much faster than docker compose run)
9+
# Thank you: https://serverfault.com/a/1084975
10+
command: /bin/sh -c "
11+
trap 'exit' TERM;
12+
echo 'Run the following command to format files with Prettier:';
13+
echo ' docker compose exec node prettier --write src/';
14+
while true; do sleep 1; done
15+
"
16+
container_name: cc-chooser-node
17+
volumes:
18+
# Mount repository to working directory
19+
- "./:/opt"
20+
working_dir: /opt

0 commit comments

Comments
 (0)