|
| 1 | +/* |
| 2 | + * Copyright (c) 2023, salesforce.com, inc. |
| 3 | + * All rights reserved. |
| 4 | + * Licensed under the BSD 3-Clause license. |
| 5 | + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
| 6 | + */ |
| 7 | + |
| 8 | +import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; |
| 9 | +import { Messages } from '@salesforce/core'; |
| 10 | +import { cmpDev } from '@lwrjs/api'; |
| 11 | + |
| 12 | +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); |
| 13 | +const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.component'); |
| 14 | + |
| 15 | +export type LightningDevComponentResult = { |
| 16 | + path: string; |
| 17 | +}; |
| 18 | + |
| 19 | +export default class LightningDevComponent extends SfCommand<LightningDevComponentResult> { |
| 20 | + public static readonly summary = messages.getMessage('summary'); |
| 21 | + public static readonly description = messages.getMessage('description'); |
| 22 | + public static readonly examples = messages.getMessages('examples'); |
| 23 | + |
| 24 | + public static readonly flags = { |
| 25 | + name: Flags.string({ |
| 26 | + summary: messages.getMessage('flags.name.summary'), |
| 27 | + description: messages.getMessage('flags.name.description'), |
| 28 | + char: 'n', |
| 29 | + required: false, |
| 30 | + }), |
| 31 | + // TODO should this be required or optional? |
| 32 | + // We don't technically need this if your components are simple / don't need any data from your org |
| 33 | + 'target-org': Flags.requiredOrg(), |
| 34 | + }; |
| 35 | + |
| 36 | + public async run(): Promise<LightningDevComponentResult> { |
| 37 | + const { flags } = await this.parse(LightningDevComponent); |
| 38 | + |
| 39 | + const name = flags.name ?? 'world'; |
| 40 | + this.log(`preview component: ${name}`); |
| 41 | + |
| 42 | + // TODO implement me |
| 43 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 44 | + await cmpDev({ |
| 45 | + componentName: name, |
| 46 | + }); |
| 47 | + |
| 48 | + return { |
| 49 | + path: '', |
| 50 | + }; |
| 51 | + } |
| 52 | +} |
0 commit comments