Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prettier, eslint and stylelint config and also enable automatic execution #530

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"presets": [
[ "@babel/preset-env", {
"targets": { "node": "10" }
} ]
],
"plugins": [ "@babel/plugin-transform-modules-commonjs" ],
"env": {
"test": {
"plugins": ["transform-require-context"]
}
"presets": [
[
"@babel/preset-env",
{
"targets": { "node": "10" }
}
]
],
"plugins": ["@babel/plugin-transform-modules-commonjs"],
"env": {
"test": {
"plugins": ["transform-require-context"]
}
}
}
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ module.exports = {
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
indent: ['error', 2],
'comma-dangle': ['error', 'always-multiline'],
'space-before-function-paren': ['warn', 'never'],
'vue/require-default-prop': 'off',
'vue/no-v-html': 'off',
},
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Use Node.js 14
uses: actions/setup-node@v4
with:
node-version: '14'
node-version: '14'

- name: Clean install NPM packages from package-lock.json
run: npm ci
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Test
run: npm run test:unit
env:
CI: true
CI: true

# https://github.com/cypress-io/github-action
- name: Cypress run
Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
coverage/
dist/
docs/
6 changes: 3 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
singleQuote: true,
semi: true,
trailingComma: 'all',
"singleQuote": true,
"semi": true,
"trailingComma": "all"
}
83 changes: 37 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@
![GitHub Repo stars](https://img.shields.io/github/stars/creativecommons/chooser?style=social)
![GitHub forks](https://img.shields.io/github/forks/creativecommons/chooser?style=social)


# Chooser

The Creative Commons License Chooser is meant to help people learn about CC licenses, and select the license that best fits their needs. The new version in this repo places greater importance on usability, and an educational experience of the six CC licenses.


## About

Repository containing the source code for the new Creative Commons License Chooser. The new chooser is still in beta, and a beta deployment can be found [here](https://chooser-beta.creativecommons.org/).

This site is built using [Vue.js](https://vuejs.org/) (and vue-cli).


### Roadmap

Tasks, issues, and discussion related to the release of the new chooser are tracked with the [`Launch Milestone`](https://github.com/creativecommons/chooser/milestone/1).


## Code of conduct

[`CODE_OF_CONDUCT.md`][org-coc]:

> The Creative Commons team is committed to fostering a welcoming community.
> This project and all other Creative Commons open source projects are governed
> by our [Code of Conduct][code_of_conduct]. Please report unacceptable
Expand All @@ -39,115 +36,112 @@ Tasks, issues, and discussion related to the release of the new chooser are trac
[code_of_conduct]: https://opensource.creativecommons.org/community/code-of-conduct/
[reporting_guide]: https://opensource.creativecommons.org/community/code-of-conduct/enforcement/


## Contributing

See [`CONTRIBUTING.md`][org-contrib].

[org-contrib]: https://github.com/creativecommons/.github/blob/main/CONTRIBUTING.md


## Using Docker


### Containers

The [`docker-compose.yml`](docker-compose.yml) file defines the following
containers:

1. **chooser-web** - simple NGINX container serving [`docs/`](docs)
- [localhost:8888](http://localhost:8888/)
2. **chooser-node** - Node14 container
- [localhost:8080](http://localhost:8080/)
- (requires **Run Node development server**, below)


### Docker desktop required

Before proceeding, ensure you have Docker installed on your local machine. If
not, download and install Docker Desktop by visiting [Docker's official
website](https://www.docker.com/products/docker-desktop) and follow the
installation instructions.


### Startup containers

The containers can be started with:

```shell
docker compose up
```

(See [Docker Compose overview | Docker Docs](https://docs.docker.com/compose/)
for more information on managing containes with `docker compose`.)


### Initial setup

Before the chooser-node container can be used effectively, a clean install of
NPM packages from `package-lock.json` is required:

```shell
docker compose exec chooser-node npm ci
```
**This step generally only needs to be done once.**

**This step generally only needs to be done once.**

### Run Node development server

1. Startup containers (see above)
2. Complete initial setup (see above)
3. Run Node development server
```shell
docker compose exec chooser-node npm run serve
```
```shell
docker compose exec chooser-node npm run serve
```
- [localhost:8080](http://localhost:8080/)


### Create production (standalone) build

1. Startup containers (see above)
2. Complete initial setup (see above)
3. Run Node development server
```shell
docker compose exec chooser-node npm run build
```
- (this automatically copies the generated files from [`dist/`](dist) to
[`docs/`](docs))
```shell
docker compose exec chooser-node npm run build
```
- (this automatically copies the generated files from [`dist/`](dist) to
[`docs/`](docs))

The chooser is deployed to GitHub Pages. The source files for the beta
deployment are contained in the `./docs/` dir, and are live. Any changes to
this directory's contents will be automatically deployed, so please take care
when making modifications to this location.


### Create standalone (production) build

1. Startup containers (see above)
2. Complete initial setup (see above)
3. Run Node development server
```shell
docker compose exec chooser-node npm run build
```
- (this automatically copies the generated files from [`dist/`](dist) to
[`docs/`](docs))
```shell
docker compose exec chooser-node npm run build
```
- (this automatically copies the generated files from [`dist/`](dist) to
[`docs/`](docs))

The chooser is deployed to GitHub Pages. The source files for the beta
deployment are contained in the `./docs/` dir, and are live. Any changes to
this directory's contents will be automatically deployed, so please take care
when making modifications to this location.

For an embedded standalone build (no header nor footer), run:

```shell
docker compose exec chooser-node VUE_APP_CC_OUTPUT=embedded npm run build
```
**(please _don't_ commit embedded builds to `docs/`)**

**(please _don't_ commit embedded builds to `docs/`)**

### Create a web component build

1. Startup containers (see above)
2. Complete initial setup (see above)
3. Run Node development server
```shell
docker compose exec chooser-node npm run build-component
```
```shell
docker compose exec chooser-node npm run build-component
```

This will create a file in the [`dist/`](dist) folder named
`license-chooser.min.js`. It can be used to load the web-component in any JS
Expand All @@ -168,41 +162,39 @@ example.
```

For an embedded web component build (no header nor footer), run:

```shell
docker compose exec chooser-node VUE_APP_CC_OUTPUT=embedded npm run build-component
```


## Perform unit tests on standalone or embedded build

1. Startup containers (see above)
2. Complete initial setup (see above)
2. Run unit tests
```shell
docker compose exec chooser-node npm run test:unit
```
3. Run unit tests
```shell
docker compose exec chooser-node npm run test:unit
```

## Perform unit tests on web-component build

1. Startup containers (see above)
2. Complete initial setup (see above)
3. Create a web component build (see above)
2. Run unit tests
```shell
docker compose exec chooser-node npm run test-component
```
4. Run unit tests
```shell
docker compose exec chooser-node npm run test-component
```
- It starts a server with the `dist/demo.html` on which tests can be run.


## Perform Cypress tests

1. Startup containers (see above)
2. Run Cypress tests
```shell
docker run -it -v $PWD:/e2e -w /e2e -e CYPRESS_baseUrl=http://host.docker.internal:8888 cypress/included:latest
```
- (This will download the cypress/included image when first run)

```shell
docker run -it -v $PWD:/e2e -w /e2e -e CYPRESS_baseUrl=http://host.docker.internal:8888 cypress/included:latest
```
- (This will download the cypress/included image when first run)

## CSS Build

Expand All @@ -213,7 +205,6 @@ can also be removed. If you find that the built site misses some styles, you
can manually add the necessary classes or Regex expressions to the `safelist`
array in the `postcss.config.js` file.


## Embedded screenshot

The site can be built in two different modes: `embedded` and `standalone`.
Expand Down
6 changes: 3 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { defineConfig } = require('cypress')
const { defineConfig } = require('cypress');

module.exports = defineConfig({
project: 'creativecommons-chooser',
Expand All @@ -9,10 +9,10 @@ module.exports = defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./tests/cypress/plugins/index.js')(on, config)
return require('./tests/cypress/plugins/index.js')(on, config);
},
baseUrl: 'http://localhost:8080/',
specPattern: 'tests/cypress/integration//**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'tests/cypress/support/index.js',
},
})
});
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
version: '2.4'

services:

chooser-web:
build: .
ports:
Expand Down