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

Release 12.0.0 #671

Merged
merged 210 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from 209 commits
Commits
Show all changes
210 commits
Select commit Hold shift + click to select a range
a7f8df0
add script to reorganize the monorepo
shawnbot Oct 25, 2018
c7b461f
don't exit
shawnbot Oct 25, 2018
097a211
move reset stuff from script/reorg => script/reorg-reset
shawnbot Oct 25, 2018
9270e09
add --help and --dry-run flags to script/reorg
shawnbot Oct 25, 2018
e07c5cc
fold reorg-reset into script/reorg
shawnbot Oct 25, 2018
3b7820c
clean up script/reorg
shawnbot Nov 22, 2018
bbf7c05
move lib/* up a directory
shawnbot Nov 22, 2018
eb22533
just delete the source module directory
shawnbot Nov 22, 2018
c945143
replace primer/primer with primer/css in tools
shawnbot Nov 22, 2018
7830f3c
reset tools, too
shawnbot Nov 22, 2018
484c12e
do more stuff
shawnbot Nov 23, 2018
e0870b2
rename "go" function to "__"
shawnbot Jan 22, 2019
0621d9e
refactor: delete tools/generator-primer-module :fire:
shawnbot Jan 26, 2019
e6bde01
fix: make sure we migrate all the markdown
shawnbot Jan 29, 2019
ce591bb
refactor: run script/reorg
shawnbot Jan 29, 2019
93f2bce
fix: get utility classes via @primer/css/build/utilities (TODO)
shawnbot Jan 26, 2019
d185586
chore: dependencies.primer-utilities -> peerDependencies.@primer/css
shawnbot Jan 26, 2019
49e6559
chore(module-build): get utilities from @primer/css
shawnbot Jan 26, 2019
96daf3d
chore: make sure all utilities get primer/selector-no-utility
shawnbot Jan 28, 2019
f3af913
chore: fix up marketing imports
shawnbot Jan 28, 2019
4508254
chore: update main package scripts
shawnbot Jan 28, 2019
635df54
chore: use correct @primer/css version
shawnbot Jan 28, 2019
8432372
chore: un-ignored scripts/build
shawnbot Jan 28, 2019
bd9b88c
build: bump version (temproraily?)
shawnbot Jan 28, 2019
9df7567
chore: install cssstats-cli
shawnbot Jan 28, 2019
32a0c86
chore: kill yo; bump node-sass to common version
shawnbot Jan 28, 2019
d7818f3
chore: bump to common node-sass version
shawnbot Jan 28, 2019
2774b6e
chore(stylelint): move @primer/css to devDependencies
shawnbot Jan 28, 2019
05bf046
chore(box): lint, use $border-width instead of 1px
shawnbot Jan 29, 2019
5a00460
chore(forms): fix linting error in form-controls
shawnbot Jan 29, 2019
9876a2e
chore(utilities): lint
shawnbot Jan 29, 2019
96e5902
chore: just run lint for testing
shawnbot Jan 29, 2019
f85f7c7
chore: pull docs from modules/primer/**/*.md
shawnbot Jan 29, 2019
748df56
add btn-transparent back in
gladwearefriends Jan 29, 2019
c940591
docs: remove reference to npm-run{,-all} in DEVELOP.md
shawnbot Feb 4, 2019
cff2658
deps(stylelint-config-primer): use local npm-run-all
shawnbot Feb 4, 2019
29e30cc
chore: nix script/npm-run{,-all}
shawnbot Feb 4, 2019
81c5a26
chore: delete tools/primer-module-build :fire:
shawnbot Feb 4, 2019
62165a5
chore: delete meta/scoreboard
shawnbot Feb 4, 2019
d0bb4cd
chore: rename @primer/css-docs -> @primer/css.docs
shawnbot Feb 4, 2019
ed4532a
docs: scrub references to scripts in DEVELOP.md
shawnbot Feb 4, 2019
81038f6
docs: update RELEASING.md
shawnbot Feb 4, 2019
3b65d3a
chore: update script/publish-storybook for actions
shawnbot Feb 4, 2019
199a4e4
chore: update script/selector-diff-report for reorg
shawnbot Feb 4, 2019
b7fee34
chore: remove lerna and related scripts
shawnbot Feb 4, 2019
6cae3a7
chore: rm -r tools/stylelint-config-primer
shawnbot Feb 4, 2019
c8559d0
chore: install stylelint-config-primer@4.0.0
shawnbot Feb 4, 2019
b24c5ac
chore: move all the docs stuff up
shawnbot Feb 4, 2019
880aa35
edit btn-outline-mktg to have transparent bg
gladwearefriends Feb 4, 2019
be08d23
chore: add doc-specific globs to .gitignore
shawnbot Feb 4, 2019
c406044
chore: fix path to package.json in index.md
shawnbot Feb 4, 2019
71be775
chore: move docs dependencies to /package.json
shawnbot Feb 4, 2019
dad693d
chore: move @primer/css metadata to package.json
shawnbot Feb 4, 2019
02e2f8d
chore: rebuild package-lock
shawnbot Feb 4, 2019
be1aa27
chore: move primer build script up
shawnbot Feb 4, 2019
cdfc908
chore: rename src/ -> docs/
shawnbot Feb 4, 2019
f9ae92d
chore: remove primer package .gitignore, postpublish.js
shawnbot Feb 4, 2019
dcfd4c1
chore: qualify "build/" in .gitignore
shawnbot Feb 4, 2019
a8ef055
chore: nix DOCS.md
shawnbot Feb 4, 2019
6ae7642
docs: merge modules/primer/README and DOCS.md into README.md
shawnbot Feb 4, 2019
b1da1f3
chore: remove modules/primer package.json, LICENSE, README
shawnbot Feb 4, 2019
795544d
refactor: git mv modules/primer/* .
shawnbot Feb 4, 2019
6a6adf0
chore: nix resolve alias for primer/index.scss
shawnbot Feb 4, 2019
c903b1a
chore: fix path to docs/utils.js in comment
shawnbot Feb 4, 2019
c54b4c7
chore: refactor now.json
shawnbot Feb 4, 2019
946d121
chore: fix SCSS path
shawnbot Feb 4, 2019
f55178b
chore: fix docs path in lint run-script
shawnbot Feb 4, 2019
3f4d58f
chore: get repository field from package.json
shawnbot Feb 4, 2019
368cf73
chore: move all the SCSS files to src/
shawnbot Feb 4, 2019
e1e2b9f
chore: be explicit about the src/ dir
shawnbot Feb 4, 2019
8895827
publish: copy all src/* before publishing, clean up post
shawnbot Feb 4, 2019
117d716
chore: clean up .gitignore
shawnbot Feb 4, 2019
0c5adcb
chore: add more stuff to .npmignore
shawnbot Feb 4, 2019
c726b59
ci: add Actions workflow
shawnbot Feb 4, 2019
41ed78b
fix: fix typo in package.json
shawnbot Feb 4, 2019
1c9698a
fix: fix build script, run-script
shawnbot Feb 4, 2019
1229e6c
fix: only lint the .scss files
shawnbot Feb 4, 2019
357cfa3
chore: rebuild package-lock
shawnbot Feb 4, 2019
26ff012
deps: downgrade to eslint@4
shawnbot Feb 4, 2019
78c2d11
ci: disable eslint for now
shawnbot Feb 4, 2019
ca3c97f
ci: delete .travis.yml
shawnbot Feb 4, 2019
dbcdbb4
docs: nix sentence
shawnbot Feb 4, 2019
36af904
ci: pass w/no tests, add fx, bump commit-status
shawnbot Feb 4, 2019
2f63e87
ci: add publish action
shawnbot Feb 4, 2019
1a5da38
publish: add script/publish
shawnbot Feb 4, 2019
c1208c2
chore: rework test scripts
shawnbot Feb 4, 2019
01cb8c7
publish: run pre- and post-scripts explicitly
shawnbot Feb 4, 2019
191e056
ci: resolve publish, add NOW_TOKEN secret
shawnbot Feb 4, 2019
51521cb
ci: use GH_STATUS_TOKEN for commit-status
shawnbot Feb 4, 2019
0e8ab9c
deploy: bring back now.json files list
shawnbot Feb 4, 2019
44155e0
ci: refactor dist, build, prepublish scripts
shawnbot Feb 4, 2019
94779a5
lint: whitespace in script/update-assets
shawnbot Feb 4, 2019
8105fcb
chore: tidy up .gitignore
shawnbot Feb 4, 2019
696bc5d
fix: fix path to index.scss in _app.js
shawnbot Feb 4, 2019
6d052cb
docs: sync({watch: !NODE_ENV})
shawnbot Feb 4, 2019
897ef7e
fix: run next w/npx
shawnbot Feb 4, 2019
de2cc17
chore: rename build run-script -> now-build
shawnbot Feb 4, 2019
59ab08a
deploy: add script dir to now.json files
shawnbot Feb 4, 2019
40db235
publish: fix paths to dist files, nix script/server
shawnbot Feb 4, 2019
9b505b8
chore: replace commit-status w/action-status
shawnbot Feb 5, 2019
6ce25b0
ci: add STATUS_CONTEXT env vars for deploy, publish
shawnbot Feb 5, 2019
2308cef
publish: run npm w/--unsafe-perms for pre- and post-scripts
shawnbot Feb 5, 2019
ceea4b9
publish: run action-status in prepublish, postpublish
shawnbot Feb 5, 2019
d9f688e
ci: test @primer/deploy.status.context override
shawnbot Feb 5, 2019
4228925
ci: rename STATUS_CONTEXT -> PUBLISH_STATUS_CONTEXT
shawnbot Feb 5, 2019
d804b2f
deploy: add GITHUB_TOKEN secret
shawnbot Feb 5, 2019
679818e
publish: prefix fx calls w/npx
shawnbot Feb 5, 2019
c9fe679
deploy: rename "deploy" to "docs" (required check)
shawnbot Feb 5, 2019
739c342
publish: use primer/publish --dry-run
shawnbot Feb 6, 2019
e016e8b
chore: delete script/publish :fire:
shawnbot Feb 6, 2019
d401d87
deploy: add @primer/deploy key to package.json
shawnbot Feb 6, 2019
02a2bdf
deploy: fix action name, ref primer/deploy@status-config-redux
shawnbot Feb 6, 2019
5b32bc6
ci: run "npm ci" instead of "npm install"
shawnbot Feb 6, 2019
715865c
ci: use primer/publish@8435e6f
shawnbot Feb 6, 2019
5272cd3
publish: add NPM_AUTH_TOKEN secret
shawnbot Feb 6, 2019
b1668d0
publish: rename "publish" to "npm publish primer"
shawnbot Feb 6, 2019
708154a
chore: pin actions/npm@v2.0.0
shawnbot Feb 6, 2019
846a958
chore: pin primer/deploy@v2.2.0
shawnbot Feb 6, 2019
2f283a0
publish: rework publish action
shawnbot Feb 6, 2019
57255aa
npmrc: set unsafe-perms, git-tag-version
shawnbot Feb 7, 2019
31b0541
publish: add prepublish action for debugging
shawnbot Feb 7, 2019
9c4e278
fix: speling
shawnbot Feb 7, 2019
2ffa1f8
publish: nix unsafe-perms from .npmrc
shawnbot Feb 7, 2019
ee1cb85
publish: add -- separator for npm args
shawnbot Feb 7, 2019
23c48e1
fix: use unsafe-perm (no "s")
shawnbot Feb 7, 2019
9db6eb8
npm: move unsafe-perm from .npmrc to args
shawnbot Feb 7, 2019
4290be9
dist: skip <index>.js (just do .json)
shawnbot Feb 8, 2019
d3406fc
publish: clean up pre-publish and post-publish scripts
shawnbot Feb 8, 2019
4481553
chore: add more files to .npmignore
shawnbot Feb 8, 2019
389b006
chore: rename publish-files.txt -> .log
shawnbot Feb 8, 2019
873e8de
chore: rm -r modules/
shawnbot Feb 8, 2019
f1efcd5
chore: add src/ to .npmignore
shawnbot Feb 8, 2019
54e2004
chore: re-add fonts/Inter-UI-*.woff
shawnbot Feb 8, 2019
9622336
docs: add MIGRATION.md
shawnbot Feb 8, 2019
49fb5a1
chore: rm script/reorg :boom:
shawnbot Feb 8, 2019
9b3f4e2
Merge pull request #666 from primer/reorg
shawnbot Feb 8, 2019
2812ba3
docs: update DEVELOP.md with new workflow
shawnbot Feb 9, 2019
1dad1b8
docs: move docs site docs to DEVELOP.md
shawnbot Feb 9, 2019
41b56fc
docs: remove docs site stuff from README, etc.
shawnbot Feb 9, 2019
1d37217
chore: npm uninstall eslint-plugin-prettier lerna-changelog
shawnbot Feb 11, 2019
0e4e8c3
lint: add prettier.config.js
shawnbot Feb 11, 2019
0524e78
chore: remove refs to extract-packages-json
shawnbot Feb 11, 2019
705f760
docs: update RELEASING.md
shawnbot Feb 11, 2019
4389295
lint: lint JS files
shawnbot Feb 11, 2019
10705d4
chore: bump package-lock
shawnbot Feb 11, 2019
7a36ebd
lint: add eslint configs
shawnbot Feb 11, 2019
fecf450
chore: lint lib/
shawnbot Feb 11, 2019
7417bd5
chore: lint docs/
shawnbot Feb 11, 2019
46f55ee
lint: run npm w/--unsafe-perm for lifecycle scripts
shawnbot Feb 11, 2019
3cdd10b
chore: tweak PR template
shawnbot Feb 11, 2019
d3d1ab0
chore: update CHANGELOG for 12.0.0
shawnbot Feb 11, 2019
3015227
chore: npm version 12.0.0
shawnbot Feb 11, 2019
d3e7b7e
dist: bring back dist/*.js
shawnbot Feb 11, 2019
481d796
dist: bring back dist/*.js
shawnbot Feb 11, 2019
5fa428a
docs: update links in PR snippet
shawnbot Feb 11, 2019
3fd7cf5
ci: prioritize publishing before deploying
shawnbot Feb 11, 2019
28a5db0
chore: rm -rf tools/
shawnbot Feb 11, 2019
8301138
chore: remove tools/ from .npmignore
shawnbot Feb 11, 2019
3b0aeee
build: add .browserslistrc
shawnbot Feb 12, 2019
0b11ae3
build: add back postcss, et al
shawnbot Feb 12, 2019
0fe5f10
fix: fix path to utilities in marketing/index.scss
shawnbot Feb 12, 2019
00c4d63
build: refactor script/dist w/postcss
shawnbot Feb 12, 2019
7245518
publish: remove .postcss.json from .npmignore
shawnbot Feb 12, 2019
6b64f84
build: rework where stats go (dist/stats/{name}.json)
shawnbot Feb 12, 2019
48b62d8
chore: make script/selector-diff-report work again
shawnbot Feb 12, 2019
4608007
build: make backwards-compatible build/ directory
shawnbot Feb 12, 2019
e8728e1
build: output dist/meta.json with useful metadata
shawnbot Feb 12, 2019
183f73f
rename selector-diff.txt -> .log
shawnbot Feb 12, 2019
1b82944
build: run selector diff report in prepublish
shawnbot Feb 12, 2019
08baeb2
deploy: include postcss.config.js in now.json
shawnbot Feb 12, 2019
fa7e31c
docs: mark /packages as removed
shawnbot Feb 12, 2019
adee9fa
chore: uninstall postcss + cssstats CLI packages
shawnbot Feb 12, 2019
fad4f76
fix: update how the docs site gets bundle metadata
shawnbot Feb 12, 2019
5841f42
chore: lint
shawnbot Feb 12, 2019
28461b4
build: output imports to dist/meta.json
shawnbot Feb 12, 2019
1459950
chore: nix packages.json
shawnbot Feb 12, 2019
fc9c7b8
Merge remote-tracking branch 'origin/reorg' into reorg
shawnbot Feb 12, 2019
e0cba2f
chore: whitespace
shawnbot Feb 12, 2019
4e0fc92
chore: clean up dist/meta.json import lists
shawnbot Feb 12, 2019
6951aa2
chore: npm uninstall node-sass
shawnbot Feb 12, 2019
9fac57a
docs: add bundle redirect page
shawnbot Feb 12, 2019
e8dd915
docs: rework package metadata helper to set "bundle" metadata
shawnbot Feb 12, 2019
e0f7dc6
chore: rename addPackageMeta -> addBundleMeta
shawnbot Feb 12, 2019
6b26367
docs: clean up meta-package components
shawnbot Feb 12, 2019
fb328ed
chore: lint
shawnbot Feb 12, 2019
5b8e729
Merge pull request #672 from primer/reorg-build
shawnbot Feb 12, 2019
1085ed6
ci: remove custom publish statuses
shawnbot Feb 12, 2019
5e301d3
deploy: nix @primer/deploy status "docs"
shawnbot Feb 12, 2019
180725e
docs: nix Travis badge
shawnbot Feb 12, 2019
5eb8aa5
Merge branch 'release-12.0.0' into add-btn-transparent-back
shawnbot Feb 13, 2019
1fd4a5f
Merge pull request #668 from primer/add-btn-transparent-back
shawnbot Feb 13, 2019
f46ae3a
docs: rename MIGRATION.md -> MIGRATING.md
shawnbot Feb 13, 2019
a414bca
docs: update import path migrations
shawnbot Feb 13, 2019
aa4db7c
docs: update link to $marketing-font-path
shawnbot Feb 13, 2019
45b932f
docs: add v12, migration labels to help link
shawnbot Feb 13, 2019
9591052
migrate: add primer-migrate binary, tests
shawnbot Feb 13, 2019
fc0b890
docs: add reference to primer-migrate
shawnbot Feb 13, 2019
3c79835
better file names in primer-migrate test script
shawnbot Feb 13, 2019
5a70749
docs: simplify primer-migrate section
shawnbot Feb 13, 2019
1c9a042
Merge pull request #677 from primer/primer-migrate
shawnbot Feb 14, 2019
ad1d942
Update DEVELOP.md
Feb 15, 2019
56e0f3b
Update DEVELOP.md
shawnbot Feb 15, 2019
45b379a
docs: nix "why Metalsmith?", document URL tests
shawnbot Feb 15, 2019
b756099
docs: tidy up RELEASING.md
shawnbot Feb 15, 2019
7ae37fe
docs: add more details to the Scripts section in DEVELOP.md
shawnbot Feb 15, 2019
79b1a1c
docs: reword "packages" -> "bundles"
shawnbot Feb 15, 2019
caf645b
docs: link to the site, develop.md for more info
shawnbot Feb 15, 2019
284b713
Update DEVELOP.md
shawnbot Feb 15, 2019
d72beab
docs: add migration guide link to README
shawnbot Feb 19, 2019
15dae52
add "npm run dev" alias for "npm start"
shawnbot Feb 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
> 5%
last 2 firefox versions
last 2 chrome versions
last 2 safari versions
last 2 edge versions
ie 11
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"plugin:github/es6",
"plugin:github/recommended"
],
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2017
}
}
42 changes: 42 additions & 0 deletions .github/main.workflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
workflow "lint, test, deploy, publish" {
on = "push"
resolves = [
"lint",
"test",
"publish",
"deploy",
]
}

action "install" {
uses = "actions/npm@v2.0.0"
args = ["install", "--unsafe-perm"]
}

action "lint" {
needs = "install"
uses = "actions/npm@v2.0.0"
args = ["--unsafe-perm", "run", "lint"]
}

action "test" {
needs = "install"
uses = "actions/npm@v2.0.0"
args = ["--unsafe-perm", "test"]
}

action "publish" {
needs = ["lint", "test"]
uses = "primer/publish@v1.0.0"
args = ["--", "--unsafe-perm"]
secrets = ["GITHUB_TOKEN", "NPM_AUTH_TOKEN"]
}

action "deploy" {
needs = "install"
uses = "primer/deploy@v2.2.0"
secrets = [
"GITHUB_TOKEN",
"NOW_TOKEN",
]
}
6 changes: 4 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
- [ ] First, briefly describe your proposal in the title.
First, briefly describe your proposal in the title and delete this line.

- [ ] Fixes: # (type an issue number after the # if applicable)
If your proposal fixes any issues, please list them below, then delete this line:

- Fixes: # (type an issue number after the # if applicable)

Finally, tell us more about the change here, in the description.

Expand Down
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
*.lerna_backup
*.log
*/*/package-lock.json
*.tgz
.DS_Store
.changelog
.next/
.sass-cache
_site
build
primer-version.txt
node_modules
build/
dist/
node_modules/
17 changes: 15 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
*.yml
.postcss.json
*.log
.github/
.next/
.storybook/
next.config.js
now.json
docs/
docs-test/
lib/
pages/
script/
# we ignore this because everything in src/ is copied out in script/prepublish
src/
static/
tests/
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
save=true
save-exact=true
no-package-lock=true
git-tag-version=false
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 12.0.0

:rotating_light: **Starting with version 12.0.0, the `primer` package is now known as `@primer/css`**. See [MIGRATING.md](https://github.com/primer/css/tree/master/MIGRATING.md) for more info.

#### :boom: Breaking Change
* [#666](https://github.com/primer/css/pull/666) Reorganize into a single `@primer/css` package ([@shawnbot](https://github.com/shawnbot))

# 11.0.0

#### :boom: Breaking Change
Expand Down
146 changes: 100 additions & 46 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,107 @@
# Primer Development

If you've made it this far, **thank you**! We appreciate your contribution, and hope that this document helps you along the way.
If you've made it this far, **thank you**! We appreciate your contribution, and hope that this document helps you along the way. If you have any questions or problems, don't hesitate to [file an issue](https://github.com/primer/css/issues/new).

## Structure
The project is structured as a [monorepo] made up of lots of small npm modules, many of which depend on each other. We use [Lerna] to manage, version, and publish all of the packages together.
Primer CSS is published to [npm] as [@primer/css]. Each of Primer CSS's "modules" lives in a subfolder under `src/` with an `index.scss` in it. Generally speaking, the styles are divided into three primary themes:

* **Core** styles (in `core/`) are common dependencies, which include support variables, native element and typography styles, buttons, navigation, tooltips, etc.
* **Product** styles (in `product/`) are specific to github.com, and include components such as avatars, labels, markdown styles, popovers, and progress indicators.
* **Marketing** styles (in `marketing/`) are specific to GitHub marketing efforts, including international and event-focused sites as well as the more design-heavy feature pages on github.com. Marketing styles include new colors and button styles, and extend the core typography and whitespace scales.

### Paths
Here's what you need to know about how the files are structured in both git and in the published npm module:

* In git, all of the SCSS source files live in the `src/` directory.
* When published, all of the files in `src/` are "hoisted" to the package root so that you can import, say, utilities with:

```scss
@import "@primer/css/utilities/index.scss";
```

* All bundle interdependencies within Primer CSS are defined as relative imports (e.g. with `../`), so everything should work fine as long as the `@primer/css` directory is in one of your Sass include paths (i.e. `node_modules`).

The top-level `package.json` is not published, but tracks common dependencies for developing Primer, and hosts some useful npm [run-scripts]. See the [scripts section](#scripts) for more info.

## Workflow
The typical Primer workflow looks something like this:

1. [Install](#install)
2. [Start Storybook](#storybook)
3. Navigate to the module you're working on and modify the SCSS and/or markdown files.
4. Test your changes in Storybook.
5. Push your work to a new branch to test it on Travis and have it reviewed by the Primer "core" team.
1. `npm install` to install the development dependencies.
1. [Start Storybook](#storybook)
1. Navigate to the module you're working on and modify the SCSS and/or markdown files.
1. Test your changes in Storybook.
1. Push your work to a new branch.
1. Request a review from one of the Primer "core" team members.

## Install
Run `npm install` to install the npm dependencies and automatically run link all of the local packages together with `npm run bootstrap`.
Run `npm install` to install the npm dependencies.

### Troubleshooting install problems
If you run into trouble installing, it's always best to ensure that you're starting from a clean slate by running the following from the repository root directory:
## Docs site
The Primer CSS docs are built with React using [Primer Components](https://primer.style/components) and automatically deployed on every push to this repo using our [primer/deploy action](/primer/deploy). You can run the server locally with:

```sh
npm run fresh
npm start
```

If _that_ gives you problems, then you can try manually deleting everything and starting over:
Then visit http://localhost:3000/css to view the site.

```
rm -rf node_modules
rm -f package-lock.json */*/package-lock.json
npm install
```
:rotating_light: **Warning:** Next.js has a [long-running issue](https://github.com/zeit/next.js/issues/1189) with trailing slashes in URLs. Avoid visiting `http://localhost:3000/` if possible, as this may cause your development server to fail in less-than-graceful ways.


### Syncing the docs
Both before and while the Next dev server runs, all of the Markdown files within the `src/` directory are synced to Next's `pages/` directory and rewritten to include useful metadata.

If, for whatever reason, the dev server isn't syncing files from `src/` to `pages/`, you have two choices:

1. Stop the server (`ctrl-C`) and restart it (`npm start`), which will re-sync the files and clear Next's cache.
2. Run [script/sync](./script/sync) manually:

```sh
# in the docs directory
script/sync
```

**If you find yourself needing to do this often, please [file an issue](/primer/primer/issues/new) and tag `@shawnbot`**. :bow:

### The pages directory
The [pages directory](./pages/) contains all of the files that map to URLs on the site. Because we plan to host the site at `primer.style/css` (and because of the way that Now's path aliasing feature works), we nest all of our documentation under the [css subdirectory](./pages/css).

The sync task maintains a list of files copied from `src/` in `pages/css/.gitignore`, which ensures that none of these generated files are checked into git.

**You may need to do this whenever switching between branches with different dependencies, submodules, or versions of Node and/or npm.** The Primer core team generally uses the latest major version of Node (10 as of this writing), but our CI tests run Node 8 and npm 6. You can check which versions you're running with:
### Sync internals
We use [Metalsmith] to sync the source docs to the `pages` directory and transform them in the following ways:

1. We filter the list of files to only Markdown documents (`**/*.md`).
1. Many bundle `README.md`s wrap the actual documentation content in `<!-- %docs -->` HTML comments that usually include YAML frontmatter. In these instances, we extract the content that portion and reformat the frontmatter.
1. We filter out any Markdown files that _don't_ include a `path` frontmatter key, and rename the destination file to match the `path` (e.g. `path: foo/bar` writes to `pages/css/foo/bar.md`).
1. We set the `source` frontmatter key to a fully-qualified `github.com` URL for the source file so that we can link directly to it.
1. We read the list of files from `pages/css/.gitignore` and delete them from the filesystem, then write the new list of paths so that they aren't committed to git.

All of the logic for syncing the source docs (and transforming them in transit) is controlled in [`lib/sync.js`](./lib/sync.js), and each "step" in the transformation (as well as the watching) is implemented as a Metalsmith plugin.

### URL tests
We have a script that catches inadvertent URL changes caused by renaming or deleting Markdown docs:

```sh
npm --version
node --version
npm run test-urls
```

This script includes some exceptions for URLs that have been intentionally moved or removed in the process of moving away from the [GitHub Style Guide](https://styleguide.github.com/primer/), and which you will need to modify if you rename or remove either Markdown docs or their `path` frontmatter. See [#641](https://github.com/primer/css/pull/641) for more information.

## Storybook
Run `npm start` to start up [Storybook], then visit [localhost:3000](http://localhost:3000) to test your work. By default, all `html` code blocks of all `*.md` files in each module will be rendered as stories and listed under the module's name in the left-hand nav. File changes should trigger live reload automatically after a brief delay.
To borrow a [metaphor from Brad Frost](http://bradfrost.com/blog/post/the-workshop-and-the-storefront/), the [docs site](#docs-site) is Primer CSS's storefront, and [Storybook] is its workshop.

Our Storybook setup allows you to view every HTML code block in Primer CSS's Markdown docs in isolation. To get started, run the Storybook server with:

```sh
npm run start-storybook
```

Then visit http://localhost:8000 to test your work.

If the package you're working on has a `stories.js`, it probably includes a snippet like this:
### Code blocks
All `html` fenced code blocks in `src/**/*.md` will be rendered as stories and listed under the relevant module's name in the left-hand nav. File changes should trigger a live reload automatically (after a brief delay).

If the bundle you're working on has a `stories.js`, it probably includes a snippet like this:

```js
const stories = storiesOf('Module name', module)
Expand All @@ -55,34 +112,31 @@ storiesFromMarkdown(require.context('.', true, /\.md$/))
})
```

This is how we find all of the Markdown files in the package directory and generate stories from their code blocks. Storybook sections are labeled by the first argument to `storiesOf()` (in the above example, "Module name"), and individual stories get their titles from either the previous Markdown heading or the `title` attribute in the fenced code block. See the [`code-blocks` docs](https://npmjs.com/package/code-blocks) and the [`storiesFromMarkdown()` source](./.storybook/lib/storiesFromMarkdown.js) for more info.

## CSS packages
All of the Primer CSS packages live in the [modules](./modules) subdirectory, including the [`primer`](./modules/package) omnibus package.

## Tools
Many tools specific to development of Primer CSS live in the [tools](./tools) subdirectory.
This is how we find all of the Markdown files in the bundle directory and generate stories from their code blocks. Storybook sections are labeled by the first argument to `storiesOf()` (in the above example, "Module name"), and individual stories get their titles from either the previous Markdown heading or the `title` attribute in the fenced code block. See the [`code-blocks` docs](https://npmjs.com/package/code-blocks) and the [`storiesFromMarkdown()` source](./.storybook/lib/storiesFromMarkdown.js) for more info.

## Scripts
The [`script` directory](./script) houses a collection of scripts that we use to maintain, test, build, and publish packages. Some scripts of note:
Our [`package.json`](package.json) houses a collection of [run-scripts] that we use to maintain, test, build, and publish Primer CSS, notably:

* `script/check-imports` compares the list of Primer npm dependencies for each package with SCSS `@import` statements in its source, and warns if any mismatches (dependencies without corresponding imports, or vice-versa) are found.
* `script/compare-published` compares the latest published versions of each Primer CSS package with the `version` field in its local `package.json`, and reports any discrepancies.
* `script/get-packages` lists all of the package subdirectories from both `modules` and `tools` directories, and is useful for iterating in shell scripts:
* `dist` runs `script/dist`, which creates CSS bundles of all the `index.scss` files in `src/`.
* `check-links` runs a link checker on your local development server (`localhost:3000`, started with `npm start`).
* `lint` lints all of our SCSS source files.
* `lint-js` lints the docs site and supporting scripts.
* `now-build` and `now-start` are run on [Now] to build and start the docs site server.
* `sync` copies Markdown docs from `src/` to `pages/css/` and preps them for inclusion in the docs site.
* `test-urls` compares a (pre-generated) list of paths from the [Primer Style Guide](https://styleguide.github.com/primer/) to files in `pages/css`, and lets us know if we've inadvertently deleted or renamed anything.
* `test-migrate` tests the [`primer-migrate`](MIGRATING.md#primer-migrate) command line utility.
* `watch` runs the sync script in watch mode, copying files as they're changed from `src/` to `pages/css/`.

```sh
for pkg in $(script/get-packages); do
echo $pkg
done
```

If you're looking for more detail, you can also run `npx lerna ls`, which will list the packages by name along with their versions.

Scripts like `lint-scss`, `notify`, and `test-docs` are called from individual packages to run specific common tasks; `npm-run` and `npm-run-all` are used more generally to run monorepo-installed npm utilities within the package directory, and can probably be refactored to simply run [npx].
You can list all of the available scripts with:

```sh
npm run
```


[monorepo]: https://github.com/babel/babel/blob/master/doc/design/monorepo.md
[Lerna]: https://github.com/lerna/lerna
[@primer/css]: https://www.npmjs.com/package/@primer/css
[metalsmith]: https://metalsmith.io/
[run-scripts]: https://docs.npmjs.com/cli/run-script
[Storybook]: https://storybook.js.org/
[storybook]: https://storybook.js.org/
[npm]: https://www.npmjs.com/
[npx]: https://www.npmjs.com/package/npx
Loading