Skip to content

Commit

Permalink
Monorepo (#231)
Browse files Browse the repository at this point in the history
* feat: add prettier config and test npm script
* fix: remove obsolete npm scripts for prettier
* fix: run prettier on packages/contrast-color/**
* fix: remove package-lock.json
* replaced yarn with pnpm everywhere
* make nodeJS version flexible
* fix: add husky pre-commit for git hook
* refactor: move lint-staged to pnpm script
* fix: added husky commitlint workflow
* chore: added changeset config
* fix: added pre-commit husky script
* fix: replace npx with pnpm in node scripts
* ci: added simple github workflow to running tests
* refactor: moved scripts to moon tasks to make it easy to test in CI
* chore: update moon config to use Node v20.11
* test: fix test input for contrast-colors
* chore: update copyright
* ci: added release automation

---------

Co-authored-by: Frank Karstens <[email protected]>
  • Loading branch information
GarthDB and karstens authored Mar 14, 2024
1 parent 80ae5af commit 342c9ca
Show file tree
Hide file tree
Showing 283 changed files with 19,056 additions and 45,406 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
8 changes: 8 additions & 0 deletions .changeset/proud-lies-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@adobe/leonardo-contrast-colors": patch
---

* Migrated from Lerna to Moon for monorepo management.
* Setting up Changeset for release management
* Setting up automated releases on NPM
* Migrate from Jest to Ava for better module support
14 changes: 8 additions & 6 deletions .github/ISSUE_TEMPLATE/---bug--npm-packages--.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,32 @@ about: Report a problem with the @leonardo-contrast-colors module
title: ''
labels: bug
assignees: ''

---

## Description
<!-- Describe the problem you're having -->

<!-- Describe the problem you're having -->

## Steps to reproduce
<!-- Include code examples or error messages if you have them -->

<!-- Include code examples or error messages if you have them -->

## Expected behavior
<!-- Describe what you expected to happen -->

<!-- Describe what you expected to happen -->

## Screenshots

<!-- If applicable, add screenshots to help explain the problem -->

## Leonardo package and version
<!--ie: **@leonardo-contrast-colors version:** 2.13.0 -->

<!--ie: **@leonardo-contrast-colors version:** 2.13.0 -->

## Environment
- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->

- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->

## Additional context

<!-- Provide any additional information that might help us debug the issue -->
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/--bug-web-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ about: Report a problem with the Leonardo web interface
title: ''
labels: UI, bug
assignees: ''

---

## Description
<!-- Describe the problem you're having -->

<!-- Describe the problem you're having -->

## Steps to reproduce

1. Go to http://leonardocolor.io/
2. Click on ...
3. Observe ...


## Expected behavior
<!-- Describe what you expected to happen -->

<!-- Describe what you expected to happen -->

## Screenshots
<!-- If applicable, add screenshots to help explain the problem -->

<!-- If applicable, add screenshots to help explain the problem -->

## Environment
- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->

- **Browser(s) and OS(s):** <!-- Chrome 75.0.3770.142 on Win 10 -->

## Additional context

<!-- Provide any additional information that might help us debug the issue -->
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/--feature-request--npm-packages-.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
---
name: "✨ Feature request [npm packages]"
name: '✨ Feature request [npm packages]'
about: Suggest a new feature for the Leonardo npm modules
title: ''
labels: enhancement, npm packages
assignees: ''

---

## Description
<!-- Describe your suggested feature in detail -->

<!-- Describe your suggested feature in detail -->

## Why do you need this feature?
<!-- Tell us what this solves or why this is important to your use case -->

<!-- Tell us what this solves or why this is important to your use case -->

## Leonardo package and version
<!--ie: **@leonardo-contrast-colors version:** 2.13.0 -->

<!--ie: **@leonardo-contrast-colors version:** 2.13.0 -->

## Additional context

<!-- Add any other context, workarounds, or screenshots about your request -->
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/--feature-web-tool.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
name: "✨ Feature request [Web Tool]"
name: '✨ Feature request [Web Tool]'
about: Suggest a new feature for the Leonardo web interface
title: ''
labels: UI, enhancement
assignees: ''

---

## Description
<!-- Describe your suggested feature in detail -->

<!-- Describe your suggested feature in detail -->

## Why do you need this feature?
<!-- Tell us what this solves or why this is important to your use case -->

<!-- Tell us what this solves or why this is important to your use case -->

## Additional context

<!-- Add any other context, workarounds, or screenshots about your request -->
8 changes: 5 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
<!-- Summarize your changes in the Title field -->

## Description

<!--
Note: Before sending a pull request, make sure there's an issue for what you're changing
- Search for issues: https://github.com/adobe/leonardo/issues
- If there's no issue, file it: https://github.com/adobe/leonardo/issues/new/choose
-->
<!-- Describe what you changed and link to the relevant issue(s) -->


## Motivation
<!-- How do your changes support this project's goals? -->

<!-- How do your changes support this project's goals? -->

## Screenshots
<!-- If applicable, add screenshots to show what you changed -->

<!-- If applicable, add screenshots to show what you changed -->

## To-do list

<!-- Put an "x" to indicate you've done each of the following -->

- [ ] I have read the [CONTRIBUTING document](/.github/CONTRIBUTING.md).
<!-- If this pull request isn't ready, add any remaining tasks here -->
- [ ] This pull request is ready to merge.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI
on: pull_request
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- run: moon ci
- uses: 'moonrepo/run-report-action@v1'
if: success() || failure()
with:
access-token: ${{ secrets.MOON_GH_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

permissions:
id-token: write

on:
push:
branches:
- main
- beta

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: moonrepo/setup-toolchain@v0
with:
auto-install: true
- run: moon run :build --query "projectSource~packages/*"
- name: Publish
id: changesets
uses: changesets/action@v1
with:
commit: 'chore: release'
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
dist/
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.nyc_output/
.cache/
.DS_Store
.DS_Store
# moon
.moon/cache
.moon/docker
.parcel-cache

# husky
.husky/_
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "packages/contrast-colors/SAPC-APCA"]
path = packages/contrast-colors/SAPC-APCA
url = [email protected]:Myndex/SAPC-APCA.git
[submodule "packages/ui/src/c3"]
path = packages/ui/src/c3
[submodule "docs/ui/src/c3"]
path = docs/ui/src/c3
url = [email protected]:StanfordHCI/c3.git
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/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm --no-install commitlint --edit ""
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"

pnpm run pre-commit
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"docs/**/*.{js,jsx,ts,tsx,json,yml,yaml,md}": ["prettier --write"],
"packages/**/*.{js,jsx,ts,tsx,json,yml,yaml,md}": ["prettier --write"]
}
41 changes: 41 additions & 0 deletions .moon/toolchain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# https://moonrepo.dev/docs/config/toolchain
$schema: 'https://moonrepo.dev/schemas/toolchain.json'

# Extend and inherit an external configuration file. Must be a valid HTTPS URL or file system path.
# extends: './shared/toolchain.yml'

# Configures Node.js within the toolchain. moon manages its own version of Node.js
# instead of relying on a version found on the host machine. This ensures deterministic
# and reproducible builds across any machine.
node:
# The version to use. Must be a semantic version that includes major, minor, and patch.
# We suggest using the latest active LTS version: https://nodejs.org/en/about/releases
version: '20.11'

# The package manager to use when managing dependencies.
# Accepts "npm" (default), "pnpm", or "yarn".
packageManager: 'pnpm'

# The version of the package manager (above) to use.
pnpm:
version: '8.15.4'

# Add `node.version` as a constraint in the root `package.json` `engines`.
addEnginesConstraint: true

# Dedupe dependencies after the lockfile has changed.
dedupeOnLockfileChange: true

# Version format to use when syncing dependencies within the project's `package.json`.
# dependencyVersionFormat: 'workspace'

# Infer and automatically create moon tasks from `package.json` scripts, per project.
# BEWARE: Tasks and scripts are not 1:1 in functionality, so please refer to the documentation.
inferTasksFromScripts: true

# Sync a project's `dependsOn` as dependencies within the project's `package.json`.
syncProjectWorkspaceDependencies: true

# Sync `node.version` to a 3rd-party version manager's config file.
# Accepts "nodenv" (.node-version), "nvm" (.nvmrc), or none.
# syncVersionManagerConfig: 'nvm'
29 changes: 29 additions & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# https://moonrepo.dev/docs/config/workspace
$schema: "https://moonrepo.dev/schemas/workspace.json"

# Require a specific version of moon while running commands, otherwise fail.
# versionConstraint: '>=1.0.0'

# Extend and inherit an external configuration file. Must be a valid HTTPS URL or file system path.
# extends: './shared/workspace.yml'

# REQUIRED: A map of all projects found within the workspace, or a list or file system globs.
# When using a map, each entry requires a unique project ID as the map key, and a file system
# path to the project folder as the map value. File paths are relative from the workspace root,
# and cannot reference projects located outside the workspace boundary.
projects:
- "docs/*"
- "packages/*"

# Configures the version control system to utilize within the workspace. A VCS
# is required for determining touched (added, modified, etc) files, calculating file hashes,
# computing affected files, and much more.
vcs:
# The client to use when managing the repository.
# Accepts "git". Defaults to "git".
manager: "git"

# The default branch (master/main/trunk) in the repository for comparing the
# local branch against. For git, this is is typically "master" or "main",
# and must include the remote prefix (before /).
defaultBranch: "monorepo"
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
*.min.js
*.map
*.snap
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"printWidth": 256,
"singleQuote": true,
"bracketSpacing": false,
"trailingComma": "none"
}
Loading

0 comments on commit 342c9ca

Please sign in to comment.