Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9623eca
Add `new component` command
zeykafx Jan 29, 2026
f8b7458
Split new_component brick in 3: one brick for each component type
zeykafx Jan 30, 2026
27ba232
Added formatting of generated component
zeykafx Jan 31, 2026
94b3121
Merge branch 'schultek:main' into new-component-cli
zeykafx Feb 5, 2026
62c66df
Merge branch 'schultek:main' into new-component-cli
zeykafx Jul 15, 2026
7592086
Merge branch 'schultek:main' into new-component-cli
zeykafx Jul 21, 2026
5535a47
Merge branch 'schultek:main' into new-component-cli
zeykafx Jul 23, 2026
241c85a
Added support for test creation with new component, improved path han…
zeykafx Jul 23, 2026
66a384f
Removed unused brick
zeykafx Jul 23, 2026
2813d36
WIP: add ability to create FlutterEmbeddedView components (configures
zeykafx Jul 25, 2026
c095f5a
Completed FlutterEmbeddedView support in new command.
zeykafx Jul 26, 2026
a2c99bb
Refactor new_command into multiple files, fixed typos
zeykafx Jul 26, 2026
c8e33a1
Add support for new InheritedComponent in new cmd
zeykafx Jul 30, 2026
9c659dc
Add support for `jaspr new page ...`
zeykafx Jul 31, 2026
ce35c0b
Added tests for `new`: Components, FlutterEmbedView, and pages
zeykafx Aug 1, 2026
ca836d7
Include information about `new` command in agent skills
zeykafx Aug 1, 2026
7bf7c6d
Added information about `new` command in docs, updated changelog
zeykafx Aug 1, 2026
99ac4aa
jaspr-code: Added support for new component command
zeykafx Aug 8, 2026
92dd7f4
Merge branch 'main' into new-component-cli
zeykafx Aug 8, 2026
b5d5e7f
jaspr-code: Added support for `new page` command
zeykafx Aug 9, 2026
51c38b7
Fixed analysis issues
zeykafx Aug 9, 2026
6d1c534
Fixed formatting + test (hopefully)
zeykafx Aug 9, 2026
ace7dec
Fixed extension error...
zeykafx Aug 9, 2026
be8b988
Merge branch 'next' into new-component-cli
zeykafx Aug 21, 2026
b1ed1e0
Updated to analyzer 13 and new logger
zeykafx Aug 25, 2026
a3d619a
Merge branch 'main' into new-component-cli
schultek Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Simon Binder (simolus3) - Contributor
Mahdi Khodadadifard (xclud) - Contributor
Jamiu Okanlawon (developerjamiu) - Contributor
Harish Anbalagan (harishwarrior) - Contributor
Corentin Detry (zeykafx) - Contributor
Lewin Pauli (lewinpauli) - Contributor
Diego Alejandro López Camacho (diegolopezrm) - Contributor
Piotr Rogulski (PiotrRogulski) - Contributor
Expand Down
4 changes: 4 additions & 0 deletions docs/concepts/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ The following page and other documentation assumes, that you have already a basi

When building an app or website with **Jaspr** you will mostly use these **three** basic components:

<Info>
You can generate any of them from the terminal using the `jaspr new component` command. Read more about it [here](/dev/cli#creating-components-and-pages).
</Info>

## StatelessComponent

A custom component that does not require any mutable state and looks like this:
Expand Down
6 changes: 6 additions & 0 deletions docs/content/guides/adding_pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ This would create the following routes:
The url paths are based on the directory structure relative to the root content directory. The file name is used as the last part of the path, except for files named `index.*`, which are used to create a route for the directory they are in.
</Info>

Instead of creating these files by hand, you can also use the `jaspr new page` command, which creates the file in your content directory and fills in the frontmatter for you:

```shell
jaspr new page posts/post3
```

### Private Files

Files and folders starting with `_` or `.` are considered private and will be ignored. This is useful for files that are not meant to be publicly accessible, such as configuration files or template partials.
Expand Down
16 changes: 16 additions & 0 deletions docs/dev/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description: Create, serve and build projects using the Jaspr CLI.
Jaspr comes with a cli tool to create, serve and build your website.

- `jaspr create`: Create a new Jaspr project.
- `jaspr new`: Create a new component or content page inside an existing project.
- `jaspr serve`: Serve the project and automatically refresh when you make changes.
- `jaspr build`: Build the project according to the selected rendering mode.

Expand Down Expand Up @@ -87,6 +88,21 @@ Alternatively, you can select a pre-made template using the `--template` option,

- `docs`: A template for documentation websites using [`jaspr_content`](/content).

## Creating Components and Pages

Inside an existing project you can scaffold single files with:

```shell
jaspr new component ContactInfo
jaspr new page getting_started
```

By default `jaspr new component` creates a `StatelessComponent` in `lib/components/`. Use `--stateful`, `--async`, `--inherited` or `--flutter` to pick another component type, and `--client`, `--with-styles` or `--with-test` to extend the generated file.

`jaspr new page` creates a [`jaspr_content`](/content) page in your `content/` directory and fills in the frontmatter from options like `--title`, `--layout` or `--index`.

Both subcommands accept `--path` to choose where the file is created and `--dry-run` to preview the changes without writing anything.

## Development Server

You can start your Jaspr project in development mode using:
Expand Down
2 changes: 1 addition & 1 deletion docs/going_further/flutter_embedding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ To embed a Flutter app into your existing Jaspr website, you need the following

See the documentation of [FlutterEmbedView](/api/components/flutter_embed_view) for a description of all available properties.

New projects can be setup with Flutter embedding using `jaspr create`.
New projects can be setup with Flutter embedding using `jaspr create`. For existing projects, the `jaspr new component --flutter` command performs all of the steps above for you.

## Deferred loading

Expand Down
11 changes: 10 additions & 1 deletion modules/jaspr-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"command": "jaspr.doctor",
"title": "Doctor",
"category": "Jaspr"
},
{
"command": "jaspr.new",
"title": "New Component or Page",
"category": "Jaspr"
}
],
"menus": {
Expand All @@ -77,6 +82,10 @@
},
{
"command": "jaspr.doctor"
},
{
"command": "jaspr.new",
"when": "jaspr-code:anyJasprProjectLoaded"
}
]
},
Expand Down Expand Up @@ -165,4 +174,4 @@
"vscode-uri": "^3.1.0",
"yaml": "^2.7.0"
}
}
}
122 changes: 121 additions & 1 deletion modules/jaspr-code/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { checkJasprInstalled } from "./helpers/install_helper";
import { runJasprCommand, runJasprCommandInFolder } from "./helpers/process_helper";
import { getFolderToRunCommandIn } from "./helpers/project_helper";
import { JasprServeDaemon } from "./jaspr/serve_daemon";
import { JasprNewComponentOptions, JasprNewPageOption } from "./new_item";

export type JasprMode = "static" | "server" | "client";
export type JasprModeOption = JasprMode | "static:auto" | "server:auto";
Expand Down Expand Up @@ -86,4 +87,123 @@ export function jasprServe(context: ExtensionContext) {
args: !!input ? ['--input=' + input] : []
});
}
}
}

export async function jasprNewComponent(
projectDir: string,
completePath: string,
options: JasprNewComponentOptions,
name: string,
flutterAppName?: string,
): Promise<boolean> {
const isInstalled = await checkJasprInstalled();
if (!isInstalled) {
return false;
}

const args = ["new", "component"];

switch (options.type) {
case "stateless":
args.push("--stateless");
break;
case "stateful":
args.push("--stateful");
break;
case "async":
args.push("--async");
break;
case "flutter":
args.push("--flutter");
break;
case "inherited":
args.push("--inherited");
break;
}

// compatibility checks done here to avoid cli errors
if (options.componentOptions) {
for (const option of options.componentOptions) {
switch (option) {
case "client":
if (options.type === "stateless" || options.type === "stateful") {
args.push("--client");
}
break;
case "with-styles":
if (options.type !== "inherited") {
args.push("--with-styles");
}
break;
case "with-test":
if (options.type !== "inherited") {
args.push("--with-test");
}
break;
}
}
}

// Flutter embed options
if (options.type === "flutter") {
if (options.flutterEmbedOptions?.includes("with-sample-widget")) {
args.push("--with-sample-flutter-widget");
}
if (flutterAppName) {
args.push("--flutter-app-name", flutterAppName);
}
}

args.push("--path", completePath);

// always install dependencies
args.push("--install-deps");

args.push(name);

const exitCode = await runJasprCommandInFolder(projectDir, args, undefined);

return exitCode === 0;
}

export async function jasprNewPage(
projectDir: string,
completePath: string,
options: JasprNewPageOption,
name: string,
): Promise<boolean> {
const isInstalled = await checkJasprInstalled();
if (!isInstalled) {
return false;
}

const args = ["new", "page"];

args.push("--format", options.format);

if (options.layout) {
args.push("--layout", options.layout);
}

if (options.title) {
args.push("--title", options.title);
}
if (options.description) {
args.push("--description", options.description);
}
for (const option of options.options) {
args.push(`--${option}`)
}

args.push("--path", completePath);

args.push("--install-deps");
args.push("--ignore-prompts");

args.push(name);

const exitCode = await runJasprCommandInFolder(projectDir, args, undefined);

return exitCode === 0;
}

6 changes: 6 additions & 0 deletions modules/jaspr-code/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HtmlPasteProvider } from "./jaspr/html_paste_provider";
import { dartExtensionApi } from "./api";
import { ComponentCodeLensProvider } from "./code_lenses/component_code_lens";
import { ServeCodeLensProvider } from "./code_lenses/serve_code_lens";
import { createNewJasprItem } from "./new_item";

export async function activate(context: vscode.ExtensionContext) {
let projects = await findJasprProjectFolders();
Expand Down Expand Up @@ -65,6 +66,11 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand("jaspr.serve", jasprServe(context))
);

context.subscriptions.push(
vscode.commands.registerCommand("jaspr.new", createNewJasprItem)
);


context.subscriptions.push(
vscode.languages.registerCodeLensProvider(
{ language: "dart", scheme: "file" },
Expand Down
Loading
Loading