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

[icon-builder] Update to generate standalone package #6104

Merged
merged 4 commits into from
Feb 14, 2017
Merged

[icon-builder] Update to generate standalone package #6104

merged 4 commits into from
Feb 14, 2017

Conversation

mbrookes
Copy link
Member

@mbrookes mbrookes commented Feb 10, 2017

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

Closes #6074.

npm run build now follows a similar pattern the the Material-UI build process:

  • generate the icons in the build directory
  • generates a package.json
  • copies the LICENSE file

The icon file names are PascalCase in in a single flattened directory

The generated icons use an absolute path for the import, and the package.json has a dependancy in material-ui@>1.0.0.

Finally, the dependencies are updated, and some missing ones added.

@mbrookes
Copy link
Member Author

mbrookes commented Feb 10, 2017

Once this is published, I'll update the docs site to use the packaged icons, and remove any icons from material-ui/src that aren't otherwise needed by Material-UI components. Any that are left can go in internal/icons.

The docs will also need to reference the fact that the icons are now separate, and describe the naming convention. Thinking about it, the build dir needs a README too for npmjs.com to display.

One thing we need to decide on is the package name. It's mui-icons for now to be short and snappy, but I"m open to suggestions.

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon-builder is quite an old piece of code from material-ui.That remembers me the beginning 😬 .

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using the one at the root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a separate package technically? (And not like the files ever going to change). I can have the script reach outside it's walls for it though if you prefer.

"prebuild": "rimraf js jsx",
"build": "node build.js --output-dir ../../src/svg-icons --svg-dir ./node_modules/material-design-icons --glob '/**/production/*_24px.svg' --mui-require relative --renameFilter ./filters/rename/material-design-icons.js",
"test": "echo \"Error: no test specified\" && exit 1"
"name": "material-ui-icon-builder",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about renaming the folder: material-ui-svg-icons as well as the name here?
I don't think that we need to expose the builder tools. Shouldn't they be internal scripts that help us publishing it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need to expose the builder tools. Shouldn't they be internal scripts that help us publishing it?

Sorry, I don't understand. That's exactly what they are.

Copy link
Member

@oliviertassinari oliviertassinari Feb 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, but the branding & documentation make me think otherwise:

This tool generates Material-UI SvgIcon components for a set of svg icons.

Copy link
Member Author

@mbrookes mbrookes Feb 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see what you're getting at now. (It seemed - especially given your later comment about needing a React peerDepenency in this package's package.json - that you thought the scripts were being published as part of the npm package).

However, from the way they were written, it does appear that the intention was that this would be a toolset for users to be able to generate other icon libraries - in fact, I came across this one in the wild while looking at possible names for the generated icon set.

That we've now repurposed it to create a standalone build of the Material Design icons that happens to be published from here is kind of incidental to that I think, but tell me if I'm wrong - I often am!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does appear that the intention was that this would be a toolset for users to be able to generate other icon libraries

I agree with your analyze. I have come up with the same conclusion. As I was saying, I don't think that we should worry about that tool. It could be a devDependency or implemented here, that don't make much difference.
That's not our end goal. Our end goal is to published svg icons that can be used with material-ui.

By the way, I think that the generated icons should be stored in git. That would make thing simpler for using them with the documentation. Otherwise, we could be using Lerna to link them when developing.

"name": "material-ui-icon-builder",
"version": "0.2.0-alpha.1",
"description": "Material Design Svg Icons converted to Material-UI React components.",
"author": "Hai Nguyen",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Material-UI Team?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"devDependencies": {
"babel-cli": "^6.6.5",
"grunt": "^0.4.5",
"babel-cli": "^6.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we miss a yarn.lock file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea!

What is it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used yarn over npm to install our dependencies on cicleci. I can take care of that.

},
"peerDependencies": {},
Copy link
Member

@oliviertassinari oliviertassinari Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need a peer dependency on material-ui rather than a dependency?

Copy link
Member Author

@mbrookes mbrookes Feb 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad 👍 .

@@ -120,14 +118,14 @@ describe('--svg-dir, --innerPath, --fileSuffix', function() {
});

after(function() {
temp.cleanupSync();
// temp.cleanupSync();
});

it('script outputs to directory', function(done) {
builder.main(options, function() {
assert.ok(fs.lstatSync(tempPath).isDirectory());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate assert.ok. I don't think that truthy is good enough for tests. We need precision.
If you don't mind:

assert.strictEqual(fs.lstatSync(tempPath).isDirectory(), true);

@@ -186,15 +184,14 @@ describe('--mui-require', function() {
var relativeOptions = _.extend({}, options, { muiRequire: 'relative' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh var, it's some old school Javascript 🙈 .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, that's what I thought! But I wasn't going to start battle at this point.

There's lots about this package that is "old-school" (two-year-old school, crazy isn't it?!)

@@ -120,14 +118,14 @@ describe('--svg-dir, --innerPath, --fileSuffix', function() {
});

after(function() {
temp.cleanupSync();
// temp.cleanupSync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what it is for, but we can either remove it or uncomment it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be commented out - I was trying to view any artifacts from a failing test. I'll fix it.

@oliviertassinari oliviertassinari added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI and removed PR: Needs Review labels Feb 10, 2017
@mbrookes mbrookes removed the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Feb 11, 2017
@mbrookes
Copy link
Member Author

Fixed the tests.

@mbrookes
Copy link
Member Author

@oliviertassinari I think this is done, other than:

  • Agreeing on the generated MD icons package name (currently mui-icons, put perhaps mui-md-icons?
  • Agreeing to disagree on the directory name. 😆

@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 12, 2017

Agreeing to disagree on the directory name.

That's a good one. What's wrong with following the packages convention?

They all follow two patterns:

  • The name of the folder is the name of the published package.
  • The package names are all prefixed by the repository's name.

@mbrookes
Copy link
Member Author

Well then perhaps we have the npm build script generate ../packages/mui-icons (or whatever we end up calling it) rather than ./build?

@mbrookes
Copy link
Member Author

If there's no additional feedback, lets go ahead and merge - the important work is done. (Although it would be nice to get some feedback on the target package name).

@oliviertassinari
Copy link
Member

lets go ahead and merge - the important work is done.

👍 , we can agree on the name later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: icons Specific to @mui/icons
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[icons] Port icons
4 participants