Skip to content

Commit 2964c13

Browse files
Shinonilesya7
andauthored
W-20014590 "webapp" CLI commands scaffolding (#3)
* feat: implement webapp commands for One Runtime Apps with Agentforce Vibes - Add webapp:generate command with name, label, target, template, and wizard flags - Add webapp:deploy command with name and options (build/value) flags - Add webapp:retrieve command with name flag - Add webapp:dev command with optional name and port flags - Remove hello world example code - Add comprehensive unit tests and NUT tests (18 tests total, all passing) - Add message files with examples for all commands - Generate JSON schemas for all webapp commands - Update command snapshot for deprecation policy - Update package.json topics from 'hello' to 'webapp' All commands support JSON output and follow Salesforce CLI conventions. Commands include TODO comments for future business logic implementation. * docs: use generic context instead of Agentforce Vibes references - Update webapp:generate description to use generic web app language - Update webapp:deploy description to remove One Runtime App references - Make messaging product-agnostic * fix: change deploy options from 'value' to 'validate' - Update webapp:deploy --options flag to use 'build' or 'validate' - Update message file and test to reflect correct option - Regenerate JSON schemas * feat: add webapp version create command with optional version flag * feat: add --no-overwrite and --ignore flags to webapp retrieve command * feat: update webapp dev command with target, root-dir, host, and no-open flags * docs: simplify webapp generate description * docs: simplify webapp deploy description * docs: update webapp deploy description to avoid duplication * docs: revert webapp deploy description to match summary * docs: simplify webapp dev name flag description * docs: simplify webapp dev description * docs: add detailed description and validate example for webapp deploy * docs: refine webapp deploy description wording * docs: add detailed description for webapp generate * docs: simplify webapp generate description * docs: add .ignore file explanation to webapp retrieve * revert: remove .ignore file documentation from webapp retrieve * docs: add comprehensive command reference documentation * docs: align command documentation with spec requirements * docs: add proper description for webapp version topic * refactor: remove webapp version create command * refactor: update webapp commands - simplify generate and dev - Changed webapp generate: -t flag now for template (was target) - Removed target platform options from generate command - Updated webapp dev: simplified flags, default port to 5173 - Removed host/root-dir/no-open flags from dev command - Removed webapp deploy and retrieve commands for now - Updated all tests, schemas, and documentation - All tests passing --------- Co-authored-by: shinoni <lturanscaia@salesforce.com>
1 parent 8c5b614 commit 2964c13

14 files changed

Lines changed: 477 additions & 87 deletions

File tree

COMMANDS.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Commands
2+
3+
<!-- commands -->
4+
5+
- [`sf webapp dev`](#sf-webapp-dev)
6+
- [`sf webapp generate`](#sf-webapp-generate)
7+
8+
## `sf webapp dev`
9+
10+
Preview a web app locally without needing to deploy
11+
12+
```
13+
USAGE
14+
$ sf webapp dev -n <value> [--json] [--flags-dir <value>] [-t <value>] [-p <value>]
15+
16+
FLAGS
17+
-n, --name=<value> (required) Identifies the Web Application
18+
-p, --port=<value> [default: 5173] Port for the dev server
19+
-t, --target=<value> Selects which Web Application target to use for the preview (e.g., Lightning App, Site)
20+
21+
GLOBAL FLAGS
22+
--flags-dir=<value> Import flag values from a directory.
23+
--json Format output as json.
24+
25+
DESCRIPTION
26+
Preview a web app locally without needing to deploy
27+
28+
Starts a local development server for a Web Application, using the local project files. This enables rapid
29+
development with hot reloading and immediate feedback.
30+
31+
EXAMPLES
32+
Start the development server:
33+
34+
$ sf webapp dev --name myWebApp
35+
36+
Start the development server with a specific target:
37+
38+
$ sf webapp dev --name myWebApp --target "LightningApp"
39+
40+
Start the development server on a custom port:
41+
42+
$ sf webapp dev --name myWebApp --port 8080
43+
```
44+
45+
## `sf webapp generate`
46+
47+
Create a web app and associated metadata.
48+
49+
```
50+
USAGE
51+
$ sf webapp generate -n <value> -l <value> [--json] [--flags-dir <value>] [-t <value>] [-w]
52+
53+
FLAGS
54+
-l, --label=<value> (required) Human readable name of your web app
55+
-n, --name=<value> (required) Name of your web app
56+
-t, --template=<value> [default: empty] Template to use for web app generation (pulls from central solution)
57+
-w, --wizard Run in interactive wizard mode
58+
59+
GLOBAL FLAGS
60+
--flags-dir=<value> Import flag values from a directory.
61+
--json Format output as json.
62+
63+
DESCRIPTION
64+
Create a web app and associated metadata.
65+
66+
This command creates a new web app with the specified configuration, including the basic structure and metadata
67+
files.
68+
69+
EXAMPLES
70+
Create an empty web app:
71+
72+
$ sf webapp generate --name "myWebApp" --label "My first Web App"
73+
74+
Create a web app with a specific template:
75+
76+
$ sf webapp generate --name "myWebApp" --label "My Web App" --template "React app starter"
77+
78+
Create a web app using the wizard:
79+
80+
$ sf webapp generate --name "myWebApp" --label "My Web App" --wizard
81+
```
82+
83+
<!-- commandsstop -->

command-snapshot.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
[
22
{
33
"alias": [],
4-
"command": "hello:world",
4+
"command": "webapp:dev",
55
"flagAliases": [],
6-
"flagChars": ["n"],
7-
"flags": ["flags-dir", "json", "name"],
6+
"flagChars": ["n", "p", "t"],
7+
"flags": ["flags-dir", "json", "name", "port", "target"],
8+
"plugin": "@salesforce/plugin-webapp"
9+
},
10+
{
11+
"alias": [],
12+
"command": "webapp:generate",
13+
"flagAliases": [],
14+
"flagChars": ["l", "n", "t", "w"],
15+
"flags": ["flags-dir", "json", "label", "name", "template", "wizard"],
816
"plugin": "@salesforce/plugin-webapp"
917
}
1018
]

messages/hello.world.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

messages/webapp.dev.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# summary
2+
3+
Preview a web app locally without needing to deploy
4+
5+
# description
6+
7+
Starts a local development server for a Web Application, using the local project files. This enables rapid development with hot reloading and immediate feedback.
8+
9+
# flags.name.summary
10+
11+
Identifies the Web Application
12+
13+
# flags.target.summary
14+
15+
Selects which Web Application target to use for the preview (e.g., Lightning App, Site)
16+
17+
# flags.port.summary
18+
19+
Port for the dev server
20+
21+
# examples
22+
23+
- Start the development server:
24+
25+
<%= config.bin %> <%= command.id %> --name myWebApp
26+
27+
- Start the development server with a specific target:
28+
29+
<%= config.bin %> <%= command.id %> --name myWebApp --target "LightningApp"
30+
31+
- Start the development server on a custom port:
32+
33+
<%= config.bin %> <%= command.id %> --name myWebApp --port 8080

messages/webapp.generate.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# summary
2+
3+
Create a web app and associated metadata.
4+
5+
# description
6+
7+
This command creates a new web app with the specified configuration, including the basic structure and metadata files.
8+
9+
# flags.name.summary
10+
11+
Name of your web app
12+
13+
# flags.label.summary
14+
15+
Human readable name of your web app
16+
17+
# flags.template.summary
18+
19+
Template to use for web app generation (pulls from central solution)
20+
21+
# flags.wizard.summary
22+
23+
Run in interactive wizard mode
24+
25+
# examples
26+
27+
- Create an empty web app:
28+
29+
<%= config.bin %> <%= command.id %> --name "myWebApp" --label "My first Web App"
30+
31+
- Create a web app with a specific template:
32+
33+
<%= config.bin %> <%= command.id %> --name "myWebApp" --label "My Web App" --template "React app starter"
34+
35+
- Create a web app using the wizard:
36+
37+
<%= config.bin %> <%= command.id %> --name "myWebApp" --label "My Web App" --wizard

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"@salesforce/plugin-command-reference"
5353
],
5454
"topics": {
55-
"hello": {
56-
"description": "Commands to say hello."
55+
"webapp": {
56+
"description": "Work with Salesforce Web Apps"
5757
}
5858
},
5959
"flexibleTaxonomy": true
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$ref": "#/definitions/HelloWorldResult",
3+
"$ref": "#/definitions/WebappDevResult",
44
"definitions": {
5-
"HelloWorldResult": {
5+
"WebappDevResult": {
66
"type": "object",
77
"properties": {
88
"name": {
99
"type": "string"
1010
},
11-
"time": {
11+
"target": {
12+
"type": "string"
13+
},
14+
"url": {
1215
"type": "string"
1316
}
1417
},
15-
"required": ["name", "time"],
18+
"required": ["name", "url"],
1619
"additionalProperties": false
1720
}
1821
}

schemas/webapp-generate.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/WebappGenerateResult",
4+
"definitions": {
5+
"WebappGenerateResult": {
6+
"type": "object",
7+
"properties": {
8+
"name": {
9+
"type": "string"
10+
},
11+
"label": {
12+
"type": "string"
13+
},
14+
"template": {
15+
"type": "string"
16+
},
17+
"wizard": {
18+
"type": "boolean"
19+
}
20+
},
21+
"required": ["name", "label", "template", "wizard"],
22+
"additionalProperties": false
23+
}
24+
}
25+
}
Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,60 @@ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
1818
import { Messages } from '@salesforce/core';
1919

2020
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
21-
const messages = Messages.loadMessages('@salesforce/plugin-webapp', 'hello.world');
21+
const messages = Messages.loadMessages('@salesforce/plugin-webapp', 'webapp.dev');
2222

23-
export type HelloWorldResult = {
23+
export type WebappDevResult = {
2424
name: string;
25-
time: string;
25+
target?: string;
26+
url: string;
2627
};
2728

28-
export default class World extends SfCommand<HelloWorldResult> {
29+
export default class WebappDev extends SfCommand<WebappDevResult> {
2930
public static readonly summary = messages.getMessage('summary');
3031
public static readonly description = messages.getMessage('description');
3132
public static readonly examples = messages.getMessages('examples');
3233

3334
public static readonly flags = {
3435
name: Flags.string({
35-
char: 'n',
3636
summary: messages.getMessage('flags.name.summary'),
37-
description: messages.getMessage('flags.name.description'),
38-
default: 'World',
37+
char: 'n',
38+
required: true,
39+
}),
40+
target: Flags.string({
41+
summary: messages.getMessage('flags.target.summary'),
42+
char: 't',
43+
required: false,
44+
}),
45+
port: Flags.integer({
46+
summary: messages.getMessage('flags.port.summary'),
47+
char: 'p',
48+
default: 5173,
3949
}),
4050
};
4151

42-
public async run(): Promise<HelloWorldResult> {
43-
const { flags } = await this.parse(World);
44-
const time = new Date().toDateString();
45-
this.log(messages.getMessage('info.hello', [flags.name, time]));
52+
public async run(): Promise<WebappDevResult> {
53+
const { flags } = await this.parse(WebappDev);
54+
55+
this.log(`Starting development server for web app: ${flags.name}`);
56+
if (flags.target) {
57+
this.log(`Using target: ${flags.target}`);
58+
}
59+
60+
const url = `http://localhost:${flags.port}`;
61+
this.log(`Server running on ${url}`);
62+
this.log('Opening browser...');
63+
64+
// TODO: Implement dev server logic
65+
// This would typically involve:
66+
// 1. Starting a local development server
67+
// 2. Watching for file changes
68+
// 3. Hot reloading
69+
// 4. Opening browser
70+
4671
return {
4772
name: flags.name,
48-
time,
73+
target: flags.target,
74+
url,
4975
};
5076
}
5177
}

0 commit comments

Comments
 (0)