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

Initial implementation #1

Merged
merged 11 commits into from Jan 2, 2018
Merged

Initial implementation #1

merged 11 commits into from Jan 2, 2018

Conversation

umaar
Copy link
Member

@umaar umaar commented Dec 5, 2017

Type: feature

The following has been addressed in the PR:

Description:

This PR adds in a new command dojo create theme which the readme explains a bit more on.

Causes dojo/widgets#398

Copy link
Member

@tomdye tomdye left a comment

Choose a reason for hiding this comment

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

some initial thoughts

@@ -0,0 +1,48 @@
import renderFiles from '@dojo/cli-create-app/renderFiles';
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that we should be creating dependencies between different commands like this. Looks like you copied this approach from cli-create-widget. As this is now used in multiple places is it possible that renderFiles and the template functionality it uses should be moved elsewhere? A cli-util package or something? Worth raising an issue for.

Copy link
Member Author

Choose a reason for hiding this comment

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

True I did find it unusual to consume a repo in that manner, but yep I copied the approach so though it was an established pattern! Just two q's, did you mean raise an issue in this repository? I did that: #2

Also: is that something we should do now, before this PR is merged?

Copy link
Member Author

Choose a reason for hiding this comment

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

Matt replied super quickly! #2 (comment) and is saying we have a helper in the cli repo which can be used for that, so still wondering if you think we should do that before merging this pr

Copy link
Member Author

Choose a reason for hiding this comment

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

PR submitted! dojo/cli#180

src/questions.ts Outdated
message: 'What Package to do you want to theme?'
}];

function getFileQuestions(packageName: string, files: string[], cssDataFileExtension: string): inquirer.Question[] {
Copy link
Member

Choose a reason for hiding this comment

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

you can export these one by one, ie export function getFileQuestions()...

Copy link
Member Author

Choose a reason for hiding this comment

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

Just wondering, do you think that's better? I kind of like

export {
	packageQuestions,
	getFileQuestions,
	askForPackageNames,
	askForDesiredFiles
}

Because it's easy to scan for exports? But it's not a big thing, we can change it to export function getFileQuestions if desired 👍

const packageQuestions: inquirer.Question[] = [{
type: 'input',
name: 'package',
message: 'What Package to do you want to theme?'
Copy link
Member

Choose a reason for hiding this comment

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

can you change this to accept multiple package names please as per the POC?

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!

src/run.ts Outdated
const selectedWidgets = await askForDesiredFiles(fileQuestions);

const themedWidgets = selectedWidgets.map((selectedWidget: string): WidgetDataInterface => {
const [fileName] = basename(selectedWidget).split(cssDataFileExtension);
Copy link
Member

Choose a reason for hiding this comment

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

just a nit for code style, can you put spaces inside the array please? ie. const [ filename ] =

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!

@codecov
Copy link

codecov bot commented Dec 7, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@efab671). Click here to learn what that means.
The diff coverage is 95.29%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #1   +/-   ##
=========================================
  Coverage          ?   95.29%           
=========================================
  Files             ?        6           
  Lines             ?       85           
  Branches          ?        3           
=========================================
  Hits              ?       81           
  Misses            ?        3           
  Partials          ?        1
Impacted Files Coverage Δ
src/flattenArray.ts 100% <100%> (ø)
src/convertSelectorsToCSS.ts 100% <100%> (ø)
src/questions.ts 100% <100%> (ø)
src/run.ts 100% <100%> (ø)
src/main.ts 75% <75%> (ø)
src/createThemeFile.ts 85.71% <85.71%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efab671...b324abd. Read the comment docs.

@umaar
Copy link
Member Author

umaar commented Dec 12, 2017

@tomdye do you think this one is ok now?

@umaar umaar mentioned this pull request Dec 12, 2017
3 tasks
@umaar
Copy link
Member Author

umaar commented Dec 20, 2017

Let me know what you think! @matt-gadd @tomdye thank you :)

@umaar umaar requested a review from matt-gadd December 20, 2017 17:46
@dylans dylans modified the milestones: beta.5, rc.1 Dec 22, 2017
@umaar
Copy link
Member Author

umaar commented Jan 2, 2018

@tomdye @matt-gadd friendly reminder!

@umaar umaar merged commit a111a8f into dojo:master Jan 2, 2018
@umaar umaar deleted the initial-implementation branch January 2, 2018 16:18
@@ -0,0 +1,9 @@
function convertSelectorsToCSS(selectors: string[]): string {
Copy link
Member

Choose a reason for hiding this comment

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

as this is only used in one place does it really need to be in it's own 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.

Oops! I had merged seconds before you left this comment ha! Me personally I enjoy keeping small isolated modules/files but that's just a preference, would you rather it not be in it's own file?

const pkgDir: any = require('pkg-dir');
const packagePath = pkgDir.sync(__dirname);

async function createThemeFile({
Copy link
Member

Choose a reason for hiding this comment

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

not sure this needs to be an async function as it currently does not return anything

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,5 @@
export default function flattenArray(list: any[]): any[] {
Copy link
Member

Choose a reason for hiding this comment

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

only used in one place, does not need to be in it's own 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.

Removed the file anyway 👍

@@ -23,16 +23,34 @@
"url": "https://github.com/dojo/cli-create-theme.git"
},
"scripts": {
"test": "grunt test"
"test": "grunt test",
"build": "./node_modules/.bin/grunt release --pre-release-tag=rc --dry-run --skip-checks --initial --force"
Copy link
Member

Choose a reason for hiding this comment

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

not sure we have this anywhere else.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed, thought it could be useful for us while developing though

@@ -0,0 +1,69 @@
import { Helper } from '@dojo/interfaces/cli';
import * as fs from 'fs-extra';
Copy link
Member

Choose a reason for hiding this comment

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

does this need to be fs-extra anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah the reason is I had some problems with mockery and the native fs module, I also saw we did it in another test which is where I got the idea

};
});

allWidgets.push(themedWidgets);
Copy link
Member

Choose a reason for hiding this comment

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

if you change this to allWidgets.push(...themedWidgets); you can remove flattenArray altogether

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice! Done

allWidgets.push(themedWidgets);
}

await createThemeFile({
Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure this is working exactly as planned here as createThemeFile doesn't currently return a promise.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@umaar umaar mentioned this pull request Jan 2, 2018
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.

None yet

3 participants