From 9a771dc669a23a9551966b2f6c68c5f38d531cda Mon Sep 17 00:00:00 2001 From: Nicolas Kruk Date: Thu, 8 Aug 2024 14:15:43 -0400 Subject: [PATCH] chore: remove component command --- command-snapshot.json | 8 ---- messages/lightning.preview.component.md | 32 ------------- schemas/lightning-preview-component.json | 16 ------- src/commands/lightning/preview/component.ts | 41 ----------------- .../lightning/preview/component.nut.ts | 30 ------------ .../lightning/preview/component.test.ts | 46 ------------------- 6 files changed, 173 deletions(-) delete mode 100644 messages/lightning.preview.component.md delete mode 100644 schemas/lightning-preview-component.json delete mode 100644 src/commands/lightning/preview/component.ts delete mode 100644 test/commands/lightning/preview/component.nut.ts delete mode 100644 test/commands/lightning/preview/component.test.ts diff --git a/command-snapshot.json b/command-snapshot.json index fd8a3f20..86139e43 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -7,14 +7,6 @@ "flags": ["device-id", "device-type", "flags-dir", "json", "name", "target-org"], "plugin": "@salesforce/plugin-lightning-dev" }, - { - "alias": [], - "command": "lightning:preview:component", - "flagAliases": [], - "flagChars": ["n"], - "flags": ["flags-dir", "json", "name"], - "plugin": "@salesforce/plugin-lightning-dev" - }, { "alias": [], "command": "lightning:preview:site", diff --git a/messages/lightning.preview.component.md b/messages/lightning.preview.component.md deleted file mode 100644 index d2362900..00000000 --- a/messages/lightning.preview.component.md +++ /dev/null @@ -1,32 +0,0 @@ -# summary - -Preview LWC component in insolation. - -# description - -Preview components, apps, 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 %> diff --git a/schemas/lightning-preview-component.json b/schemas/lightning-preview-component.json deleted file mode 100644 index a8a2392d..00000000 --- a/schemas/lightning-preview-component.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$ref": "#/definitions/LightningPreviewComponentResult", - "definitions": { - "LightningPreviewComponentResult": { - "type": "object", - "properties": { - "path": { - "type": "string" - } - }, - "required": ["path"], - "additionalProperties": false - } - } -} diff --git a/src/commands/lightning/preview/component.ts b/src/commands/lightning/preview/component.ts deleted file mode 100644 index d3dab814..00000000 --- a/src/commands/lightning/preview/component.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { - 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 { - 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', - }; - } -} diff --git a/test/commands/lightning/preview/component.nut.ts b/test/commands/lightning/preview/component.nut.ts deleted file mode 100644 index ba288d28..00000000 --- a/test/commands/lightning/preview/component.nut.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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); - }); -}); -*/ diff --git a/test/commands/lightning/preview/component.test.ts b/test/commands/lightning/preview/component.test.ts deleted file mode 100644 index aa7a75c2..00000000 --- a/test/commands/lightning/preview/component.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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; - - 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'); - }); -});