Skip to content

Conversation

@pwolfert
Copy link
Contributor

@pwolfert pwolfert commented Mar 19, 2020

TODO

  • cmsds build-docs builds src and then builds the docs package into html pages
  • cmsds build-docs runs webpack statically after building src and docs
  • cmsds start runs webpack dev server and watches for changes to build the source package or the docs
  • Fix babel errors when using the build-docs script in child design systems.
  • Update or remove the unit tests for the script modules

Summary

  • Added the build-scripts command to the design-system-scripts package.
  • Refactored doc generation scripts to handle child design systems
  • Changed the yarn build script alias in package.json to execute the new build script
  • Temporarily removed test and lint scripts

How to test

Core CMSDS:

  1. Run yarn install
  2. Run yarn build to build design-system and design-system-docs
  3. Run yarn start to build, serve, and watch files for the doc site
  4. Test the site is reloaded correctly in the following scenarios:
    a. React component in design-system is updated
    b. React component prop documentation in design-system is updated
    c. HTML and React component examples in design-system are updated
    d. Documentation content design-system is updated (i.e. .docs.scss file)
    e. CSS in design-system is updated
    f. React component in design-system-docs is updated
    g. CSS in design-system-docs is updated

Child DS

  1. Download and extract
    child-design-system-example .zip

  2. Make sure child-design-system-example is in the same directory containing the core CMSDS repo, aka adjacent to the design-system repo folder.

  3. Run yarn install (This will also npm link the core ds packages)

  4. Go through the same tests listed above for the core CMSDS

  5. Additionally test these overrides:
    a. Overriding a core React component and prop docs, ensuring it is outputted in the dist (i.e. src/Button/Button.jsx)
    b. Overriding a core React documentation (i.e. src/Button/_Button.docs.scss)
    c. Overriding core DS css (i.e. src/Button/Button.scss)
    d. Adding new DS components, documentation and css (i.e. src/NewBadge)
    e. Overriding doc site css (i.e. docs/example.scss or docs/index.scss)

bernardwang and others added 30 commits February 27, 2020 16:26
* Process md files in the core package, add frontmatter attribute path

* Rename base to styles

* Move grid files to core

* Remove 'Layout' section from doc site

* Move color palette and layout doc files to docs package, update gulp tasks to support KSS in docs package

* Move support files to core and remove generics folder

* Stop using support in core and allow for absolute path css importing from core/src

* Remove support and layout directories

* Remove generator-cmsgov package

* Update developer files

* Remove sass add version gulp task and simplify gulp scripts

* Rename style to design

* Update backstop js files

* PR feedback

* Undo eslint change

* Move variables and mixins into settings folder

* Fix linter
* Removing Select files

* Remove right to left

* Remove deprecated props like fieldRef

* Fix dialog snap

* Fix snaps
… and docs path as arguments instead of hard-coding them or trying to compile all packages
…. Updated the scripts to send the output to docs/dist while respecting the `rootPath` override
…nly does cleaning, babel transpiling, and json copying right now, but the framework is here. I'm avoiding using the central `gulp/index.js` to create a shared config in favor of configuring tasks explicitly with command line arguments that we parse in the script that npx/yarn executes.
…use we're only going to have one now with different commands
…be outdated. Removed unused stuff and cleaned up the logging. Also cleaned up the task definitions for the build module
…pt to move fonts and images from src to dist. And when building child design systems (packages that aren't our core package), it will copy the fonts and images from the core package in node_modules into the child design system's dist folder.
…or the css stats function and added helpful error messaging around skiplatest functionality. Instead of just throwing a bunch of filesystem errors, it will say why it errored and suggest using `--skiplatest` if appropriate.
* Update readmes and documentation

* Reorganize CSS files

* Rename core folder to cmsds and update package.json

* Add back layout to docs package and fix broken links

* Add migration documentation

* PR feedback and other misc documentation changes

* Rename cmsds folder to design-system

* Remove core and layout dep from docs package
…e parameters. This makes it so much easier to compose them without having to preconfigure all the tasks with the right parameters, especially when certain parameters may or may not exist depending on which tasks you plan on using. This should be much simpler overall because it's just plain JavaScript. We still use gulp for the streaming transform pipelines, but at a high level, it's just JavaScript.

A note here that I had a lot of trouble figuring out how to consistently detect when a gulp stream had ended. It ended up being a combination of `{ readable: false, writeable: false }` for the `finished` function and placing the `pipe(count(...))` before the `pipe(gulp.dest(...))`. I tried a lot of different methods of detecting stream ends before I realized that it was a combination of those two things.
… print usage if you don't specify a command or specify an invalid one
… start changing them. Refactored the `gulp/webpack.js` module to not use gulp tasks
@bernardwang bernardwang force-pushed the pwolfert/new-build-docs-script branch from c30b9b4 to e753c0b Compare April 13, 2020 15:36
@bernardwang
Copy link
Contributor

@line47 @pwolfert I updated the description with details on how to test. This PR should now pass tests and should support child design systems as well.

@pwolfert
Copy link
Contributor Author

I downloaded your latest version of the child design system and ran yarn install, but there was a parsing error when trying to build:

ERROR in /Users/patrickwolfert/Projects/child-design-system-example/node_modules/@cmsgov/design-system-docs/src/index.jsx 9:15
Module parse failed: Unexpected token (9:15)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
| function render() {
>   const Page = <Docs page={window.page} routes={window.routes} />;
| 
|   if (process.env.NODE_ENV === 'production') {
 @ multi react-hot-loader/patch webpack-hot-middleware/client /Users/patrickwolfert/Projects/child-design-system-example/node_modules/@cmsgov/design-system-docs/src/index.jsx index[2]
ℹ 「wdm」: Failed to compile.

@line47
Copy link
Contributor

line47 commented Apr 13, 2020

☝️ I got the same error as Patrick did

@line47
Copy link
Contributor

line47 commented Apr 13, 2020

It looks like the docs.css is not working on the child ds like it does the core doc site.
.docs__sidebar is not applied in the same way and the left nav is wider for the child ds doc site.

changing the order of this index.scss fixes it but I don't think that's what we want to do

@import '@cmsgov/design-system-docs/src/index.scss';
// Use overriden css from child DS src
@import '../../src/index.scss';

@bernardwang
Copy link
Contributor

@line47 Could you elaborate on that? Do you mean overriding the default documentation isnt working for the child DS?

@bernardwang
Copy link
Contributor

@pwolfert Sorry for the last minute updates, but you need to pull dc85210 to fix that error. I also just pushed up some other fixes I found and uploaded an updated child DS example

@pwolfert
Copy link
Contributor Author

I love the override messages:

Screen Shot 2020-04-13 at 5 21 40 PM

I tried going to one of the component pages but got a bunch of errors. I've also tried spinning up a simple http server that serves the docs/dist folder, and I got similar JavaScript errors on component pages.

@line47
Copy link
Contributor

line47 commented Apr 14, 2020

@bernardwang this all for running a child ds.

  • I expected the left nav to be the same width as it is on design.cms.gov but the class docs__sidebar is being overridden. I think it might have to do with the ordering of CSS.

Here is a screenshot of the wide nav
Screen Shot 2020-04-14 at 9 49 28 AM

I also noticed that the css is not being minimized (should it be?) http://localhost:3000/index.css

@bernardwang bernardwang force-pushed the pwolfert/new-build-docs-script branch from 6104783 to 072a9b8 Compare April 14, 2020 17:25
@bernardwang
Copy link
Contributor

@pwolfert I think I know which error you are talking about, it should be fixed in the latest commit!

@line47 The CSS wont be minimized unless we pass in NODE_ENV = production, which by default only happens on yarn build. I'm not able to reproduce that wide nav in the child DS some reason... It looks like this for me on the default child design system example.
Screen Shot 2020-04-14 at 4 12 10 PM

@pwolfert
Copy link
Contributor Author

Child design system build and start scripts work! LGTM

@line47
Copy link
Contributor

line47 commented Apr 15, 2020

This is fantastic and working as expected! I can make all the modifications called out in the lists above for both the core and child DS.

The left nav is no longer an issue for me, not sure what was up there.

One small issue I found:
When I made changes to docs/src/example.scss there were no changes.

I do get the terminal message however the changes are not visible

2 Sass files processed in ./docs
[Browsersync] Reloading Browsers...

I was adding this to the example.scss file

.ds-display {
    font-style: italic !important;
}

@bernardwang
Copy link
Contributor

@line47 I tested it on the core and child DS and adding this seemed to work for me.

.ds-display {
    font-style: italic !important;
}

Screen Shot 2020-04-15 at 3 55 32 PM

Since I can't reproduce it I'm going to go ahead and merge! I can get any follow ups in a different PR

@bernardwang bernardwang merged commit e6a18df into master Apr 15, 2020
@bernardwang bernardwang deleted the pwolfert/new-build-docs-script branch May 15, 2020 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants