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

Move theming to its own package #2337

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ac06db9
feat(theming): move theming to its own package
plouc May 11, 2023
fc41a9c
feat(theming): use @nivo/theming in @nivo/line
plouc May 11, 2023
bd327d6
feat(theming): use @nivo/theming in @nivo/marimekko
plouc May 11, 2023
1e5a9e4
feat(theming): use @nivo/theming in @nivo/network
plouc May 11, 2023
83f5f2c
feat(theming): use @nivo/theming in @nivo/parallel-coordinates
plouc May 11, 2023
4ae429d
feat(theming): use @nivo/theming in @nivo/pie
plouc May 11, 2023
991186a
feat(theming): use @nivo/theming in @nivo/polar-axes
plouc May 11, 2023
9d8ea9c
feat(theming): use @nivo/theming in @nivo/radar
plouc May 11, 2023
c07fefd
feat(theming): use @nivo/theming in @nivo/radial-bar
plouc May 11, 2023
24c1549
feat(theming): use @nivo/theming in @nivo/sankey
plouc May 11, 2023
09bfc39
feat(theming): use @nivo/theming in @nivo/scatterplot
plouc May 11, 2023
7ede4e1
feat(theming): use @nivo/theming in @nivo/stream
plouc May 11, 2023
b8c88a8
feat(theming): use @nivo/theming in @nivo/sunburst
plouc May 11, 2023
59fef02
feat(theming): use @nivo/theming in @nivo/swarmplot
plouc May 11, 2023
add7dba
feat(theming): use @nivo/theming in @nivo/tooltip
plouc May 11, 2023
11040da
feat(theming): use @nivo/theming in @nivo/treemap
plouc May 11, 2023
e4d8972
feat(theming): use @nivo/theming in @nivo/voronoi
plouc May 11, 2023
5a302c5
feat(theming): use @nivo/theming in @nivo/waffle
plouc May 11, 2023
3407705
feat(theming): remove theming from @nivo/theming
plouc May 11, 2023
8c99061
feat(theming): adjust stories to use @nivo/theming
plouc May 11, 2023
befb622
feat(theming): adjust the website to use @nivo/theming
plouc May 11, 2023
318e0c1
feat(text): add a new text package to homogenize text styles
plouc May 12, 2023
e99c338
fix(imports): remove unused imports
plouc May 12, 2023
f120e77
fix(tooltip): remove extra theme properties from the tooltip wrapper …
plouc May 12, 2023
81be14e
fix(typings): fix type errors
plouc May 12, 2023
b5c41a9
feat(website): add canvas implementations to the theming demo
plouc May 12, 2023
6fe9990
fix(bar): grid now use inner dimensions
plouc May 12, 2023
b258e13
fix(line): update line snapshots due to the use if the new Text compo…
plouc May 12, 2023
767e98b
fix(bar): use @nivo/text for the canvas implementation
plouc May 12, 2023
bbdd755
feat(calendar): use @nivo/text for the canvas implementation
plouc May 12, 2023
12ed4d3
feat(chord): use @nivo/text for the canvas implementation
plouc May 13, 2023
da37c13
feat(text): use @nivo/text for drawing text in canvas implementations
plouc May 13, 2023
b179998
feat(website): remove the outline used for debugging the theme
plouc May 13, 2023
9822a1c
feat(infrastructure): define phony individually for each make target
plouc May 13, 2023
27ed974
feat(infrastructure): conditionally disable rollup size and visualize…
plouc May 13, 2023
7d3b6e8
feat(infrastructure): remove website & storybook build from tests on …
plouc May 13, 2023
2c7f17a
feat(infrastructure): disable package size stats for tests on CI
plouc May 13, 2023
ec14be9
fix(deploy): debugging vercel build
plouc May 13, 2023
07c4954
feat(api): mark express and uuid packages as external in @nivo/express
plouc May 13, 2023
911010f
feat(infrastructure): default install target uses a frozen lockfile
plouc May 13, 2023
1d37255
fix(deploy): debugging vercel build
plouc May 13, 2023
d9a9c97
feat(deps): upgrade d3-scale, d3-scale-chromatic and d3-interpolate
plouc May 14, 2023
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -25,12 +25,10 @@ jobs:
- run: pnpm install
- name: Build nivo packages
run: make pkgs-build
env:
SKIP_SIZE: true
- run: make pkgs-lint
- run: make pkgs-test
# Make sure that we can build the website
- run: make website-build
# Make sure that we can build storybook
- run: make storybook-build

end-to-end-tests:
runs-on: ubuntu-22.04
Expand All @@ -53,6 +51,8 @@ jobs:
runTests: false
- name: Build nivo packages
run: make pkgs-build
env:
SKIP_SIZE: true
- name: Cypress run
uses: cypress-io/github-action@v5
with:
Expand Down
69 changes: 50 additions & 19 deletions Makefile
Expand Up @@ -2,8 +2,6 @@ MAKEFLAGS += --no-print-directory

SOURCES = packages

.PHONY: help bootstrap init pkgs-build pkgs-publish clean-all website-install website website-build website-deploy storybook storybook-build storybook-deploy deploy-all e2e-open

########################################################################################################################
#
# HELP
Expand Down Expand Up @@ -32,6 +30,7 @@ HELP_HELPER = \
}; \
print "\n"; }

.PHONY: help
help: ##prints help
@perl -e '$(HELP_HELPER)' $(MAKEFILE_LIST)

Expand All @@ -43,14 +42,17 @@ help: ##prints help
#
########################################################################################################################

.PHONY: install
install: ##@0 global install
@pnpm install
pnpm install --frozen-lockfile

.PHONY: init
init: ##@0 global cleanup/install/bootstrap
@$(MAKE) clean-all
@$(MAKE) install
@$(MAKE) pkgs-build

.PHONY: fmt
fmt: ##@0 global format code using prettier (js, css, md)
@pnpm prettier --color --write \
"packages/*/{src,tests}/**/*.{js,ts,tsx}" \
Expand All @@ -63,6 +65,7 @@ fmt: ##@0 global format code using prettier (js, css, md)
"cypress/src/**/*.{js,ts,tsx}" \
"README.md"

.PHONY: fmt-check
fmt-check: ##@0 global check if files were all formatted using prettier
@echo "${YELLOW}Checking formatting${RESET}"
@pnpm prettier --color --list-different \
Expand All @@ -76,16 +79,20 @@ fmt-check: ##@0 global check if files were all formatted using prettier
"cypress/src/**/*.{js,ts,tsx}" \
"README.md"

.PHONY: test
test: ##@0 global run all checks/tests (packages, website)
@$(MAKE) fmt-check
@$(MAKE) lint
@$(MAKE) pkgs-test

.PHONY: vercel-build
vercel-build: ##@0 global Build the website and storybook to vercel
@$(MAKE) website-build
@$(MAKE) storybook-build
@echo "${YELLOW}Building the website and storybook${RESET}"
$(MAKE) website-build
$(MAKE) storybook-build
@cp -a storybook/storybook-static website/public/storybook

.PHONY: clean-all
clean-all: ##@0 global uninstall node modules, remove transpiled code & lock files
@rm -rf node_modules
@rm -rf package-lock.json
Expand All @@ -105,6 +112,7 @@ define clean-source-all
rm -rf $(1)/*/package-lock.json
endef


########################################################################################################################
#
# 1. PACKAGES
Expand All @@ -115,10 +123,12 @@ pkg-lint-%: ##@1 packages run eslint on package
@echo "${YELLOW}Running eslint on package ${WHITE}@nivo/${*}${RESET}"
@pnpm eslint ./packages/${*}/{src,tests}/**/*.{js,ts,tsx}

.PHONY: pkgs-lint
pkgs-lint: ##@1 packages run eslint on all packages
@echo "${YELLOW}Running eslint on all packages${RESET}"
@pnpm eslint "./packages/*/{src,tests}/**/*.{js,ts,tsx}"

.PHONY: pkgs-lint-fix
pkgs-lint-fix: ##@1 packages run eslint on all packages with a fix option
@echo "${YELLOW}Running eslint on all packages${RESET}"
@pnpm eslint "./packages/*/{src,tests}/**/*.{js,ts,tsx}" --fix
Expand All @@ -138,27 +148,38 @@ pkg-update-test-%: ##@1 packages run tests for a package and update its snapshot
pkg-watch-test-%: ##@1 packages run tests for a package and watch for changes
@export BABEL_ENV=development; pnpm jest -c ./packages/jest.config.js --rootDir . ./packages/${*}/tests --watch

.PHONY: pkgs-test
pkgs-test: ##@1 packages run tests for all packages
@echo "${YELLOW}Running test suites for all packages${RESET}"
@export BABEL_ENV=development; pnpm jest -c ./packages/jest.config.js --workerThreads --rootDir . ./packages/*/tests

.PHONY: pkgs-watch-test
pkgs-watch-test: ##@1 packages run tests for all packages and watch for changes
@echo "${YELLOW}Running test suites watcher for all packages${RESET}"
@export BABEL_ENV=development; pnpm jest -c ./packages/jest.config.js --rootDir . ./packages/*/tests --watch

.PHONY: pkgs-test-cover
pkgs-test-cover: ##@1 packages run tests for all packages with code coverage
@echo "${YELLOW}Running test suites coverage for all packages${RESET}"
@export BABEL_ENV=development; pnpm jest -c ./packages/jest.config.js --rootDir . --coverage ./packages/*/tests

.PHONY: pkgs-build
pkgs-build: pkgs-types ##@1 packages build all packages
@# Using exit code 255 in case of error as it'll make xargs stop immediately.
@export SKIP_TYPES=TRUE;find ./packages -type d -maxdepth 1 ! -path ./packages \
@# Skipping type generation as it's already done via `pkgs-types` in one go.
@# | xargs -I '{}' sh -c '$(MAKE) pkg-build-{} || exit 255'
find ./packages -type d -maxdepth 1 ! -path ./packages | sed 's|^./packages/||' | sort | xargs -I '{}' sh -c 'echo "make pkg-build-{}"'
@export SKIP_TYPES=TRUE; find ./packages -type d -maxdepth 1 ! -path ./packages \
| sed 's|^./packages/||' \
| xargs -P 8 -I '{}' sh -c '$(MAKE) pkg-build-{} || exit 255'
| sort \
| xargs -I '{}' sh -c '$(MAKE) pkg-build-{}'
@echo "${GREEN}Packages built${RESET}"

.PHONY: pkgs-types
pkgs-types: ##@1 packages build all package types
@pnpm tsc --build ./tsconfig.monorepo.json

.PHONY: pkgs-types-clean
pkgs-types-clean: ##@1 packages clean all package types
@pnpm tsc --build --clean ./tsconfig.monorepo.json

Expand All @@ -175,12 +196,15 @@ pkg-types-%: ##@1 packages generate types for a specific package
fi;

pkg-build-%: pkg-types-% ##@1 packages build a package
@echo "${YELLOW}Building package ${WHITE}@nivo/${*}${RESET}"
@-rm -rf ./packages/${*}/dist/nivo-${*}*
@export PACKAGE=${*}; NODE_ENV=production BABEL_ENV=production ./node_modules/.bin/rollup -c conf/rollup.config.mjs

.PHONY: pkgs-screenshots
pkgs-screenshots: ##@1 packages generate screenshots for packages readme (website dev server must be running)
@node scripts/capture.mjs

.PHONY: pkgs-publish-dry-run
pkgs-publish-dry-run: ##@1 packages dry run for packages publication
#@$(MAKE) pkgs-build
@pnpm lerna publish \
Expand All @@ -191,12 +215,14 @@ pkgs-publish-dry-run: ##@1 packages dry run for packages publication
--registry "http://localhost:4873" \
--loglevel verbose

.PHONY: pkgs-publish
pkgs-publish: ##@1 packages publish all packages
@$(MAKE) pkgs-build

@echo "${YELLOW}Publishing packages${RESET}"
@pnpm lerna publish --exact

.PHONY: pkgs-publish-next
pkgs-publish-next: ##@1 packages publish all packages for @next npm tag
@$(MAKE) pkgs-build

Expand All @@ -208,72 +234,73 @@ pkg-dev-%: ##@1 packages build package (es flavor) on change, eg. `package-watch
@rm -rf ./packages/${*}/cjs
@export PACKAGE=${*}; NODE_ENV=development BABEL_ENV=development ./node_modules/.bin/rollup -c conf/rollup.config.mjs -w


########################################################################################################################
#
# 2. WEBSITE
#
########################################################################################################################

.PHONY: website-deps-up
website-deps-up: ##@2 website interactive upgrade of website's dependencies
@pnpm upgrade-interactive --latest

.PHONY: website
website: ##@2 website start website in dev mode
@echo "${YELLOW}Starting website dev server${RESET}"
@cd website && pnpm start

.PHONY: website-build
website-build: ##@2 website build website
@echo "${YELLOW}Building website${RESET}"
@-rm -rf website/.cache
@cd website && pnpm build

.PHONY: website-serve
website-serve: ##@2 website build & serve website
@$(MAKE) website-build
@cd website && pnpm serve

website-deploy: ##@2 website build & deploy website
@$(MAKE) website-build

@echo "${YELLOW}Deploying website${RESET}"
@pnpm gh-pages -d website/public -r git@github.com:plouc/nivo.git -b gh-pages

.PHONY: website-audit
website-audit: ##@2 website audit website build
@cd website && pnpm analyze

.PHONY: website-lint
website-lint: ##@2 website run eslint on the website code
@pnpm eslint ./website/src

.PHONY: website-sprites
website-sprites: ##@2 website build sprite sheet
@glue --img website/src/assets --css website/src/styles website/src/assets/icons


########################################################################################################################
#
# 3. STORYBOOK
#
########################################################################################################################

.PHONY: storybook
storybook: ##@3 storybook start storybook in dev mode on port 6006
@pnpm --filter storybook dev

.PHONY: storybook-build
storybook-build: ##@3 storybook build storybook
@echo "${YELLOW}Building storybook${RESET}"
@pnpm --filter storybook build

storybook-deploy: ##@3 storybook build and deploy storybook
@$(MAKE) storybook-build

@echo "${YELLOW}Deploying storybook${RESET}"
@pnpm gh-pages -d storybook/storybook-static -r git@github.com:plouc/nivo.git -b gh-pages -e storybook


########################################################################################################################
#
# 4. End-to-end tests
#
########################################################################################################################

.PHONY: end-to-end-open
end-to-end-open: ##@4 end-to-end open cypress
pnpm --filter nivo-e2e open

.PHONY: end-to-end-test
end-to-end-test: ##@4 end-to-end build
pnpm --filter nivo-e2e test

Expand All @@ -284,16 +311,20 @@ end-to-end-test: ##@4 end-to-end build
#
########################################################################################################################

.PHONY: api-dev
api-dev: ##@5 API run API in dev mode (watcher)
@echo "${YELLOW}Starting API in dev mode${RESET}"
@cd api && pnpm dev

.PHONY: api
api: ##@5 API run API in regular mode (no watcher)
@echo "${YELLOW}Starting API${RESET}"
@cd api && pnpm start

.PHONY: api-lint
api-lint: ##@5 API run eslint on the API code
@pnpm eslint ./api/src

.PHONY: api-deploy
api-deploy: ##@5 API Deploy API on heroku
git subtree push --prefix api heroku master
13 changes: 8 additions & 5 deletions conf/rollup.config.mjs
Expand Up @@ -5,10 +5,11 @@ import stripBanner from 'rollup-plugin-strip-banner'
import cleanup from 'rollup-plugin-cleanup'
import size from 'rollup-plugin-size'
import { visualizer } from 'rollup-plugin-visualizer'
import terser from "@rollup/plugin-terser"
import terser from '@rollup/plugin-terser'

const pkg = process.env.PACKAGE
const isWatching = process.env.ROLLUP_WATCH === 'true'
const skipSize = process.env.SKIP_SIZE === 'true'

const extensions = ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx']
const babelConfig = {
Expand All @@ -21,6 +22,8 @@ const babelConfig = {
const externals = [
'prop-types',
'joi',
'express',
'uuid',
]

let input = `./packages/${pkg}/src/index.js`
Expand Down Expand Up @@ -53,7 +56,7 @@ const commonPlugins = [
modulesOnly: true,
}),
babel(babelConfig),
!isWatching && terser(),
// !isWatching && terser(),
cleanup()
]

Expand All @@ -68,12 +71,12 @@ const configs = [
},
plugins: [
...commonPlugins,
!isWatching && size({
!skipSize && !isWatching && size({
filename: `stats/${pkg}-size.es.json`,
}),
!isWatching && visualizer({
!skipSize && !isWatching && visualizer({
template: 'raw-data',
filename: `stats/${pkg}-stats.es.json`,
json: true,
})
].filter(Boolean),
}
Expand Down