Repository navigation
Conversation
Package Version ReportThe following packages have been updated: |
|
@schultek This is still a WIP, but I'd love some feedback on this. Do you think it could be used to generate the skills too? Do you think there are more things that it should generate? Should Thanks!! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #838 +/- ##
==========================================
- Coverage 69.21% 67.24% -1.97%
==========================================
Files 212 222 +10
Lines 11926 12309 +383
==========================================
+ Hits 8254 8277 +23
- Misses 3672 4032 +360 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Looking forward to this.
I prefer to keep the current install-skills command and keep this separate for now. |
Also moved the new component stuff to its own file
|
@schultek would it be better to try to integrate this directly into the |
|
The VSCode extension now supports the The extension currently doesn't prompt the user if they want to add missing dependencies and instead raises a flag to tell the CLI to add them directly, I was debating just warning the user that they must include the missing deps themselves but that didn't seem like it would be the outcome expected by a user. |
|
@schultek This PR is quite large, would you prefer if I split it in three parts? |
|
No need to split this up. But targeting the next branch would be great. Also fyi I probably won't get around to properly reviewing this for a few weeks due to vacation. |
|
The CI formatting check fails due to duplicate "analyzer" keys in |
Description
This PR implements the
jaspr newcommand as proposed in #736.The command can generate stateless, stateful, async, inherited or Flutter embedded view components from a mason brick (There is one brick per component type), but also
jaspr_contentpages:New component creation examples:
Options:
--path(-p): where the component is created, defaults to./lib/components(or./libfor inherited components)--stateless/--stateful/--async/--inherited/--flutter: component type, one allowed, defaults to stateless--client: makes it a client component (ignored with a warning for async and inherited components)--with-styles: adds acssstyles getter (ignored with a warning for inherited components)--with-test: generates a default test for the newly generated component, see below (not supported yet for inherited and flutter components, it is ignored with a warning)--dry-run: prints what would be generated without generating the files--flutter-app-name(or--app-name, and others): name of the Flutter widget to embed, only used with--flutter. If it is not given, the command prompts for it (defaults toMyFlutterApp).--with-sample-flutter-widget(or--with-flutter-widget, ...): also generates a sample Flutter widget with the name of the flutter app, only used with--flutter. The flag is negatable, and if it is not passed at all then the command prompts for it.The component name can be given in PascalCase, camelCase or snake_case (the name will be converted by mason). The name is also checked to be a valid dart identifier after being converted.
NOTE:
--with-testwill create a new test file under the "test" directory, the file location mirrors the component's location inlib/but intest/. E.g., Creating a componentlib/components/blog/about_us.dartwill create a test attest/components/blog/about_us_test.dart.The test uses
testComponentsfromjaspr_test(ortestServerforAsyncStatelessComponent) and imports the component via usingpackage:xyz/....If
jaspr_testis not found in the dev dependencies, then the command prompts the user to add it.Inherited components
--inheritedgenerates anInheritedComponentinstead of a regular component. The generated class has a sample data field with a TODO to indicate the user to replace the field, anofand amaybeOfstatic method, and anupdateShouldNotifyExample:
jaspr new component AppTheme --inherited # creates lib/app_theme.dartNOTE: inherited components are created under
lib/and notlib/components/, since they are not really component that will be renderedOther note:
--client,--with-stylesand--with-testare ignored with a warning for theseFlutter embedded view
Adding a FlutterEmbedView to a project requires multiple steps to be done (by hand today), but the command does the following:
--flutter-app-nameoption, then it prompts the user for oneflutterandjaspr_flutter_embedto the dependencies, andflutter_lintsandflutter_testto the dev dependencies, only if they are missingflutter: embeddedin thejasprblock of the pubspec file (if the flutter mode is already set toplugins, it prompts the user if they want to overwrite it or not)uses-material-design: truein theflutterblock of the pubspecweb/flutter_bootstrap.jsDocumentfound inlib/main.server.dartfor server and static, or inweb/index.htmlfor client. If the mode cannot be read, it warns the user and gives info on how to include it manually.FlutterEmbedView.deferredcomponent, with the@Import.onWebref to the widget and theViewConstraints--with-sample-flutter-app, it generates a sample Flutter widget underlib/widgets/, otherwise it prompts the user if they want a sample widgetExamples:
NOTE: the generated component is very similar to what
jaspr createproduces when flutter embedding is selectedNOTE:
--dry-runis quite useful here since this command modifies quite a few things: it lists every change (deps, pubspec blocks, bootstrap script, script ref, generated files) without writing anything.The command behaves in a similar manner to angular's
ng generate component [name] [options]command.Content pages
jaspr new page <name>generates a newjaspr_contentpage from a mason brick, with the frontmatter filled in from the options.Examples:
Options:
--path(-p),--format(defaults to md),--layout,--title(defaults to the name in Title Case),--description, and the flags--dry-run,--index,--sitemap,--sitemap-exclude,--metaand--frontmatter(can be negated, it is on by default).The command also reads the
ContentAppof the server entrypoint to check a few things:directoryargument, so that the page is created in the right place when it is notcontent(i.e., if the user has changed the content directory and has not provided a path for the new page, the command will place it in the custom directory instead ofcontent/)parsersto prompt the user when the requested format might not be parsable (e.g.,--format htmlwhile onlyMarkdownParser()is registered. Note that if the user wants another format than mdx/md/html this is ignored, of if the user has a custom parser we also ignore this warning)layoutsto prompt the user when the requested--layoutmay not be registeredNOTE: since jaspr_content can't run as a client side application, the command errors out for client projects. It also prompts to add
jaspr_contentto the dependencies when it is missing.VSCode extension support
The VSCode extension was updated to make use of the new CLI command to allow users to create new components or pages very easily.
The command is reachable from the command palette with "Jaspr: New component or page" and is split in two parts:
lib/components, `lib, or another directory (which the user browses to pick)contents,lib, or another directoryindex,meta,frontmatter,sitemap,sitemap-exclude(the extension warns the user (and exits) if they pick bothsitemapandsitemap-excludeat the same time).Type of Change
Ready Checklist
the semantic_changelog format.
///).