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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some initial thoughts
src/createThemeFile.ts
Outdated
@@ -0,0 +1,48 @@ | |||
import renderFiles from '@dojo/cli-create-app/renderFiles'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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[] { |
There was a problem hiding this comment.
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()...
There was a problem hiding this comment.
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?' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 ] =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Codecov Report
@@ Coverage Diff @@
## master #1 +/- ##
=========================================
Coverage ? 95.29%
=========================================
Files ? 6
Lines ? 85
Branches ? 3
=========================================
Hits ? 81
Misses ? 3
Partials ? 1
Continue to review full report at Codecov.
|
@tomdye do you think this one is ok now? |
Let me know what you think! @matt-gadd @tomdye thank you :) |
@tomdye @matt-gadd friendly reminder! |
@@ -0,0 +1,9 @@ | |||
function convertSelectorsToCSS(selectors: string[]): string { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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[] { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
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