-
Notifications
You must be signed in to change notification settings - Fork 12
feat: scaffolding for single component preview command @W-17803218 #336
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
Changes from all commits
81f5465
eebe556
311d6ad
ce1f9b6
7ef2850
c6a694a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# summary | ||
|
||
Preview LWC components in isolation. | ||
|
||
# description | ||
|
||
Preview LWC components in isolation. Replacement for: https://developer.salesforce.com/docs/platform/sfvscode-extensions/guide/lwclocaldev.html | ||
|
||
# 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 %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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'; | ||
import { cmpDev } from '@lwrjs/api'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.component'); | ||
|
||
export type LightningDevComponentResult = { | ||
path: string; | ||
}; | ||
|
||
export default class LightningDevComponent extends SfCommand<LightningDevComponentResult> { | ||
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, | ||
}), | ||
// TODO should this be required or optional? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i vote optional There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will let Brian decide based off what he has time to implement. If we don't make it required, will need to do some code scanning of the component u are attempting to preview, then error out if it needs data and you don't supply an authenticated org. Just added todo comment as a reminder |
||
// We don't technically need this if your components are simple / don't need any data from your org | ||
'target-org': Flags.requiredOrg(), | ||
}; | ||
|
||
public async run(): Promise<LightningDevComponentResult> { | ||
const { flags } = await this.parse(LightningDevComponent); | ||
|
||
const name = flags.name ?? 'world'; | ||
this.log(`preview component: ${name}`); | ||
|
||
// TODO implement me | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
await cmpDev({ | ||
componentName: name, | ||
}); | ||
|
||
return { | ||
path: '', | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these test files necessary? they don't do anything There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brian will add these tests. Just created the initial file structure |
||
* 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 | ||
*/ | ||
// TODO - add proper NUT tests | ||
/* | ||
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); | ||
}); | ||
}); | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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'; | ||
|
||
describe('lightning single component preview', () => { | ||
const $$ = new TestContext(); | ||
// let sfCommandStubs: ReturnType<typeof stubSfCommandUx>; | ||
|
||
beforeEach(() => { | ||
// sfCommandStubs = stubSfCommandUx($$.SANDBOX); | ||
}); | ||
|
||
afterEach(() => { | ||
$$.restore(); | ||
}); | ||
|
||
it('todo add unit tests', async () => {}); | ||
}); |
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.
is this supposed to be filled out?
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.
yeah, will be done by doc team