-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initial command stubs (#18)
* feat: generate stubs * fix: package.json * chore: update snapshots * chore: update schemas
- Loading branch information
Showing
17 changed files
with
518 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# summary | ||
|
||
Preview LWC component in insolation. | ||
|
||
# description | ||
|
||
Preview components, org, and sites. If no topic is specified, the default action is to preview the org. | ||
|
||
In dev preview mode, you can edit local files and see these changes to your Lightning Web Components (LWC) within your {org name} org: | ||
|
||
- Basic HTML and CSS edits | ||
- Importing new CSS-only LWC | ||
- JS edits in-service component library | ||
- JS method changes in the LWC component that don't alter its public API. | ||
|
||
Other local changes require deployment to your org. However, changes made directly in your org (like modifying component properties and saving) are immediately live and won't show in your local files until you retrieve them from the org. | ||
|
||
This feature enables developers to quickly iterate on their components and pages, seeing the impact of changes in real-time without needing to deploy or refresh manually. Live reload is enabled by default to automatically refresh the preview when source code changes are detected. | ||
|
||
Use the appropriate topic to preview specific aspects of the development environment. | ||
|
||
# flags.name.summary | ||
|
||
Description of a flag. | ||
|
||
# flags.name.description | ||
|
||
More information about a flag. Don't repeat the summary. | ||
|
||
# examples | ||
|
||
- <%= config.bin %> <%= command.id %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# summary | ||
|
||
Preview LWC components in context of your Salesforce Org. | ||
|
||
# description | ||
|
||
Preview components, org, and sites. If no topic is specified, the default action is to preview the org. | ||
|
||
In dev preview mode, you can edit local files and see these changes to your Lightning Web Components (LWC) within your {org name} org: | ||
|
||
- Basic HTML and CSS edits | ||
- Importing new CSS-only LWC | ||
- JS edits in-service component library | ||
- JS method changes in the LWC component that don't alter its public API. | ||
|
||
Other local changes require deployment to your org. However, changes made directly in your org (like modifying component properties and saving) are immediately live and won't show in your local files until you retrieve them from the org. | ||
|
||
This feature enables developers to quickly iterate on their components and pages, seeing the impact of changes in real-time without needing to deploy or refresh manually. Live reload is enabled by default to automatically refresh the preview when source code changes are detected. | ||
|
||
Use the appropriate topic to preview specific aspects of the development environment. | ||
|
||
# flags.name.summary | ||
|
||
Description of a flag. | ||
|
||
# flags.name.description | ||
|
||
More information about a flag. Don't repeat the summary. | ||
|
||
# examples | ||
|
||
- <%= config.bin %> <%= command.id %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# summary | ||
|
||
Preview LWC components in context of Experience Cloud on Experience Delivery site. | ||
|
||
# description | ||
|
||
Preview components, org, and sites. If no topic is specified, the default action is to preview the org. | ||
|
||
In dev preview mode, you can edit local files and see these changes to your Lightning Web Components (LWC) within your {org name} org: | ||
|
||
- Basic HTML and CSS edits | ||
- Importing new CSS-only LWC | ||
- JS edits in-service component library | ||
- JS method changes in the LWC component that don't alter its public API. | ||
|
||
Other local changes require deployment to your org. However, changes made directly in your org (like modifying component properties and saving) are immediately live and won't show in your local files until you retrieve them from the org. | ||
|
||
This feature enables developers to quickly iterate on their components and pages, seeing the impact of changes in real-time without needing to deploy or refresh manually. Live reload is enabled by default to automatically refresh the preview when source code changes are detected. | ||
|
||
Use the appropriate topic to preview specific aspects of the development environment. | ||
|
||
# flags.name.summary | ||
|
||
Description of a flag. | ||
|
||
# flags.name.description | ||
|
||
More information about a flag. Don't repeat the summary. | ||
|
||
# examples | ||
|
||
- <%= config.bin %> <%= command.id %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/LightningPreviewComponentResult", | ||
"definitions": { | ||
"LightningPreviewComponentResult": { | ||
"type": "object", | ||
"properties": { | ||
"path": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["path"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/LightningPreviewOrgResult", | ||
"definitions": { | ||
"LightningPreviewOrgResult": { | ||
"type": "object", | ||
"properties": { | ||
"path": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["path"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/LightningPreviewSiteResult", | ||
"definitions": { | ||
"LightningPreviewSiteResult": { | ||
"type": "object", | ||
"properties": { | ||
"path": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["path"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; | ||
import { Messages } from '@salesforce/core'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.component'); | ||
|
||
export type LightningPreviewComponentResult = { | ||
path: string; | ||
}; | ||
|
||
export default class LightningPreviewComponent extends SfCommand<LightningPreviewComponentResult> { | ||
public static readonly summary = messages.getMessage('summary'); | ||
public static readonly description = messages.getMessage('description'); | ||
public static readonly examples = messages.getMessages('examples'); | ||
|
||
public static readonly flags = { | ||
name: Flags.string({ | ||
summary: messages.getMessage('flags.name.summary'), | ||
description: messages.getMessage('flags.name.description'), | ||
char: 'n', | ||
required: false, | ||
}), | ||
}; | ||
|
||
public async run(): Promise<LightningPreviewComponentResult> { | ||
const { flags } = await this.parse(LightningPreviewComponent); | ||
|
||
const name = flags.name ?? 'world'; | ||
this.log(`hello ${name} from /Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/component.ts`); | ||
return { | ||
path: '/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/component.ts', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; | ||
import { Messages } from '@salesforce/core'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.org'); | ||
|
||
export type LightningPreviewOrgResult = { | ||
path: string; | ||
}; | ||
|
||
export default class LightningPreviewOrg extends SfCommand<LightningPreviewOrgResult> { | ||
public static readonly summary = messages.getMessage('summary'); | ||
public static readonly description = messages.getMessage('description'); | ||
public static readonly examples = messages.getMessages('examples'); | ||
|
||
public static readonly flags = { | ||
name: Flags.string({ | ||
summary: messages.getMessage('flags.name.summary'), | ||
description: messages.getMessage('flags.name.description'), | ||
char: 'n', | ||
required: false, | ||
}), | ||
}; | ||
|
||
public async run(): Promise<LightningPreviewOrgResult> { | ||
const { flags } = await this.parse(LightningPreviewOrg); | ||
|
||
const name = flags.name ?? 'world'; | ||
this.log(`hello ${name} from /Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/org.ts`); | ||
return { | ||
path: '/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/org.ts', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; | ||
import { Messages } from '@salesforce/core'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.site'); | ||
|
||
export type LightningPreviewSiteResult = { | ||
path: string; | ||
}; | ||
|
||
export default class LightningPreviewSite extends SfCommand<LightningPreviewSiteResult> { | ||
public static readonly summary = messages.getMessage('summary'); | ||
public static readonly description = messages.getMessage('description'); | ||
public static readonly examples = messages.getMessages('examples'); | ||
|
||
public static readonly flags = { | ||
name: Flags.string({ | ||
summary: messages.getMessage('flags.name.summary'), | ||
description: messages.getMessage('flags.name.description'), | ||
char: 'n', | ||
required: false, | ||
}), | ||
}; | ||
|
||
public async run(): Promise<LightningPreviewSiteResult> { | ||
const { flags } = await this.parse(LightningPreviewSite); | ||
|
||
const name = flags.name ?? 'world'; | ||
this.log(`hello ${name} from /Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/site.ts`); | ||
return { | ||
path: '/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/site.ts', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
|
||
describe('lightning preview component NUTs', () => { | ||
let session: TestSession; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ devhubAuthStrategy: 'NONE' }); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
it('should display provided name', () => { | ||
const name = 'World'; | ||
const command = `lightning preview component --name ${name}`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
expect(output).to.contain(name); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { TestContext } from '@salesforce/core/testSetup'; | ||
import { expect } from 'chai'; | ||
import { stubSfCommandUx } from '@salesforce/sf-plugins-core'; | ||
import LightningPreviewComponent from '../../../../src/commands/lightning/preview/component.js'; | ||
|
||
describe('lightning preview component', () => { | ||
const $$ = new TestContext(); | ||
let sfCommandStubs: ReturnType<typeof stubSfCommandUx>; | ||
|
||
beforeEach(() => { | ||
sfCommandStubs = stubSfCommandUx($$.SANDBOX); | ||
}); | ||
|
||
afterEach(() => { | ||
$$.restore(); | ||
}); | ||
|
||
it('runs hello', async () => { | ||
await LightningPreviewComponent.run([]); | ||
const output = sfCommandStubs.log | ||
.getCalls() | ||
.flatMap((c) => c.args) | ||
.join('\n'); | ||
expect(output).to.include('hello world'); | ||
}); | ||
|
||
it('runs hello with --json and no provided name', async () => { | ||
const result = await LightningPreviewComponent.run([]); | ||
expect(result.path).to.equal('/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/component.ts'); | ||
}); | ||
|
||
it('runs hello world --name Astro', async () => { | ||
await LightningPreviewComponent.run(['--name', 'Astro']); | ||
const output = sfCommandStubs.log | ||
.getCalls() | ||
.flatMap((c) => c.args) | ||
.join('\n'); | ||
expect(output).to.include('hello Astro'); | ||
}); | ||
}); |
Oops, something went wrong.