From 23cc45de5362934bd3febd2d659f7c0dfac8572c Mon Sep 17 00:00:00 2001 From: Nicolas Kruk Date: Thu, 8 Aug 2024 17:02:19 -0400 Subject: [PATCH] chore: rename preview to dev (#127) --- README.md | 4 +-- command-snapshot.json | 4 +-- ...ng.preview.app.md => lightning.dev.app.md} | 0 ....preview.site.md => lightning.dev.site.md} | 0 package.json | 2 +- ...view-site.json => lightning-dev-site.json} | 4 +-- .../lightning/{preview => dev}/app.ts | 8 +++--- .../lightning/{preview => dev}/site.ts | 14 +++++----- src/shared/previewUtils.ts | 4 +-- .../lightning/{preview => dev}/app.nut.ts | 4 +-- .../lightning/{preview => dev}/app.test.ts | 27 +++++++++---------- .../lightning/{preview => dev}/site.nut.ts | 4 +-- .../lightning/{preview => dev}/site.test.ts | 12 ++++----- test/shared/previewUtils.test.ts | 4 +-- 14 files changed, 44 insertions(+), 47 deletions(-) rename messages/{lightning.preview.app.md => lightning.dev.app.md} (100%) rename messages/{lightning.preview.site.md => lightning.dev.site.md} (100%) rename schemas/{lightning-preview-site.json => lightning-dev-site.json} (74%) rename src/commands/lightning/{preview => dev}/app.ts (98%) rename src/commands/lightning/{preview => dev}/site.ts (92%) rename test/commands/lightning/{preview => dev}/app.nut.ts (87%) rename test/commands/lightning/{preview => dev}/app.test.ts (97%) rename test/commands/lightning/{preview => dev}/site.nut.ts (87%) rename test/commands/lightning/{preview => dev}/site.test.ts (78%) diff --git a/README.md b/README.md index 07fc4af..938aaf6 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ sf org login web --instance-url ${orgfarmUrl} Then run the following for your environment: ```bash -./bin/dev.js lightning preview site +./bin/dev.js lightning dev site ``` or for debugging: ```bash -NODE_OPTIONS='--inspect-brk' ./bin/dev.js lightning preview site +NODE_OPTIONS='--inspect-brk' ./bin/dev.js lightning dev site ``` No need to recompile or watch typescript files as this happens automagically. diff --git a/command-snapshot.json b/command-snapshot.json index 86139e4..c819a2a 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -1,7 +1,7 @@ [ { "alias": [], - "command": "lightning:preview:app", + "command": "lightning:dev:app", "flagAliases": [], "flagChars": ["i", "n", "o", "t"], "flags": ["device-id", "device-type", "flags-dir", "json", "name", "target-org"], @@ -9,7 +9,7 @@ }, { "alias": [], - "command": "lightning:preview:site", + "command": "lightning:dev:site", "flagAliases": [], "flagChars": ["n", "o"], "flags": ["debug", "flags-dir", "json", "name", "target-org"], diff --git a/messages/lightning.preview.app.md b/messages/lightning.dev.app.md similarity index 100% rename from messages/lightning.preview.app.md rename to messages/lightning.dev.app.md diff --git a/messages/lightning.preview.site.md b/messages/lightning.dev.site.md similarity index 100% rename from messages/lightning.preview.site.md rename to messages/lightning.dev.site.md diff --git a/package.json b/package.json index 5072fdb..7e85703 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "lightning": { "external": true, "subtopics": { - "preview": { + "dev": { "description": "Preview applications and sites locally and in real-time, without deploying them." } } diff --git a/schemas/lightning-preview-site.json b/schemas/lightning-dev-site.json similarity index 74% rename from schemas/lightning-preview-site.json rename to schemas/lightning-dev-site.json index c7c523d..11c8013 100644 --- a/schemas/lightning-preview-site.json +++ b/schemas/lightning-dev-site.json @@ -1,8 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$ref": "#/definitions/LightningPreviewSiteResult", + "$ref": "#/definitions/LightningDevSiteResult", "definitions": { - "LightningPreviewSiteResult": { + "LightningDevSiteResult": { "type": "object", "properties": { "path": { diff --git a/src/commands/lightning/preview/app.ts b/src/commands/lightning/dev/app.ts similarity index 98% rename from src/commands/lightning/preview/app.ts rename to src/commands/lightning/dev/app.ts index 517404a..74b0f1f 100644 --- a/src/commands/lightning/preview/app.ts +++ b/src/commands/lightning/dev/app.ts @@ -24,7 +24,7 @@ import { PreviewUtils } from '../../../shared/previewUtils.js'; import { ConfigUtils, IdentityTokenService } from '../../../shared/configUtils.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.app'); +const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.app'); export const iOSSalesforceAppPreviewConfig = { name: 'Salesforce Mobile App', @@ -55,7 +55,7 @@ class AppServerIdentityTokenService implements IdentityTokenService { } } -export default class LightningPreviewApp extends SfCommand { +export default class LightningDevApp extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); @@ -155,11 +155,11 @@ export default class LightningPreviewApp extends SfCommand { // eslint-disable-next-line no-console console.log(message); - return LightningPreviewApp.waitForKeyPress(); + return LightningDevApp.waitForKeyPress(); } public async run(): Promise { - const { flags } = await this.parse(LightningPreviewApp); + const { flags } = await this.parse(LightningDevApp); const logger = await Logger.child(this.ctor.name); const appName = flags['name']; diff --git a/src/commands/lightning/preview/site.ts b/src/commands/lightning/dev/site.ts similarity index 92% rename from src/commands/lightning/preview/site.ts rename to src/commands/lightning/dev/site.ts index e55290e..cd07fad 100644 --- a/src/commands/lightning/preview/site.ts +++ b/src/commands/lightning/dev/site.ts @@ -13,13 +13,13 @@ import { PromptUtils } from '../../../shared/prompt.js'; import { OrgUtils } from '../../../shared/orgUtils.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.site'); +const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.site'); -export type LightningPreviewSiteResult = { +export type LightningDevSiteResult = { path: string; }; -export default class LightningPreviewSite extends SfCommand { +export default class LightningDevSite extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); @@ -36,8 +36,8 @@ export default class LightningPreviewSite extends SfCommand { - const { flags } = await this.parse(LightningPreviewSite); + public async run(): Promise { + const { flags } = await this.parse(LightningDevSite); // Connect to Org const connection = flags['target-org'].getConnection(); @@ -112,9 +112,9 @@ export default class LightningPreviewSite extends SfCommand { +describe('lightning dev org NUTs', () => { let session: TestSession; before(async () => { @@ -22,7 +22,7 @@ describe('lightning preview org NUTs', () => { it('should display provided name', () => { const name = 'World'; - const command = `lightning preview org --name ${name}`; + const command = `lightning dev org --name ${name}`; const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; expect(output).to.contain(name); }); diff --git a/test/commands/lightning/preview/app.test.ts b/test/commands/lightning/dev/app.test.ts similarity index 97% rename from test/commands/lightning/preview/app.test.ts rename to test/commands/lightning/dev/app.test.ts index 2f9449b..0c33726 100644 --- a/test/commands/lightning/preview/app.test.ts +++ b/test/commands/lightning/dev/app.test.ts @@ -19,18 +19,18 @@ import { stubSpinner, stubUx } from '@salesforce/sf-plugins-core'; import { expect } from 'chai'; import esmock from 'esmock'; import sinon from 'sinon'; -import LightningPreviewApp, { +import LightningDevApp, { androidSalesforceAppPreviewConfig, iOSSalesforceAppPreviewConfig, -} from '../../../../src/commands/lightning/preview/app.js'; +} from '../../../../src/commands/lightning/dev/app.js'; import { OrgUtils } from '../../../../src/shared/orgUtils.js'; import { PreviewUtils } from '../../../../src/shared/previewUtils.js'; import { ConfigUtils, LocalWebServerIdentityData } from '../../../../src/shared/configUtils.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -describe('lightning preview app', () => { - const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.app'); +describe('lightning dev app', () => { + const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.app'); const $$ = new TestContext(); const testOrgData = new MockTestOrgData(); const testAppId = '06m8b000002vpFSAAY'; @@ -51,7 +51,7 @@ describe('lightning preview app', () => { '34' ); const testEmulatorPort = 1234; - let MockedLightningPreviewApp: typeof LightningPreviewApp; + let MockedLightningPreviewApp: typeof LightningDevApp; const fakeIdentityToken = 'PFT1vw8v65aXd2b9HFvZ3Zu4OcKZwjI60bq7BEjj5k4='; const fakeEntityId = '1I9xx0000004ClkCAE'; @@ -73,14 +73,11 @@ describe('lightning preview app', () => { $$.SANDBOX.stub(SfConfig.prototype, 'write').resolves(); $$.SANDBOX.stub(ConfigUtils, 'getOrCreateIdentityToken').resolves(fakeIdentityToken); - MockedLightningPreviewApp = await esmock( - '../../../../src/commands/lightning/preview/app.js', - { - '../../../../src/lwc-dev-server/index.js': { - startLWCServer: async () => ({ stopServer: () => {} }), - }, - } - ); + MockedLightningPreviewApp = await esmock('../../../../src/commands/lightning/dev/app.js', { + '../../../../src/lwc-dev-server/index.js': { + startLWCServer: async () => ({ stopServer: () => {} }), + }, + }); }); afterEach(() => { @@ -120,7 +117,7 @@ describe('lightning preview app', () => { } }); - describe('desktop preview', () => { + describe('desktop dev', () => { it('runs org:open with proper flags when app name provided', async () => { await verifyOrgOpen(`lightning/app/${testAppId}`, 'Sales'); }); @@ -154,7 +151,7 @@ describe('lightning preview app', () => { } }); - describe('mobile preview', () => { + describe('mobile dev', () => { it('throws when environment setup requirements are not met', async () => { $$.SANDBOX.stub(OrgUtils, 'getAppId').resolves(testAppId); $$.SANDBOX.stub(PreviewUtils, 'generateWebSocketUrlForLocalDevServer').returns(testServerUrl); diff --git a/test/commands/lightning/preview/site.nut.ts b/test/commands/lightning/dev/site.nut.ts similarity index 87% rename from test/commands/lightning/preview/site.nut.ts rename to test/commands/lightning/dev/site.nut.ts index 5928f8f..c7b9adc 100644 --- a/test/commands/lightning/preview/site.nut.ts +++ b/test/commands/lightning/dev/site.nut.ts @@ -9,7 +9,7 @@ import { TestSession } from '@salesforce/cli-plugins-testkit'; import { expect } from 'chai'; -describe('lightning preview site NUTs', () => { +describe('lightning dev site NUTs', () => { let session: TestSession; before(async () => { @@ -22,7 +22,7 @@ describe('lightning preview site NUTs', () => { it('should display provided name', () => { const name = 'World'; - const command = `lightning preview site --name ${name}`; + const command = `lightning dev site --name ${name}`; const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; expect(output).to.contain(name); }); diff --git a/test/commands/lightning/preview/site.test.ts b/test/commands/lightning/dev/site.test.ts similarity index 78% rename from test/commands/lightning/preview/site.test.ts rename to test/commands/lightning/dev/site.test.ts index 3980da2..12499c6 100644 --- a/test/commands/lightning/preview/site.test.ts +++ b/test/commands/lightning/dev/site.test.ts @@ -7,10 +7,10 @@ import { TestContext } from '@salesforce/core/testSetup'; // import { expect } from 'chai'; // import { stubSfCommandUx } from '@salesforce/sf-plugins-core'; -// import LightningPreviewSite from '../../../../src/commands/lightning/preview/site.js'; +// import LightningDevSite from '../../../../src/commands/lightning/dev/site.js'; // TODO fix me once we have a fully working command -describe('lightning preview site', () => { +describe('lightning dev site', () => { const $$ = new TestContext(); // let sfCommandStubs: ReturnType; @@ -23,7 +23,7 @@ describe('lightning preview site', () => { }); it('runs hello', async () => { - // await LightningPreviewSite.run([]); + // await LightningDevSite.run([]); // const output = sfCommandStubs.log // .getCalls() // .flatMap((c) => c.args) @@ -32,12 +32,12 @@ describe('lightning preview site', () => { }); it('runs hello with --json and no provided name', async () => { - // const result = await LightningPreviewSite.run([]); - // expect(result.path).to.equal('/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/site.ts'); + // const result = await LightningDevSite.run([]); + // expect(result.path).to.equal('/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/dev/site.ts'); }); it('runs hello world --name Astro', async () => { - // await LightningPreviewSite.run(['--name', 'Astro']); + // await LightningDevSite.run(['--name', 'Astro']); // const output = sfCommandStubs.log // .getCalls() // .flatMap((c) => c.args) diff --git a/test/shared/previewUtils.test.ts b/test/shared/previewUtils.test.ts index 2e7d704..95eddb5 100644 --- a/test/shared/previewUtils.test.ts +++ b/test/shared/previewUtils.test.ts @@ -28,10 +28,10 @@ import { PreviewUtils } from '../../src/shared/previewUtils.js'; import { iOSSalesforceAppPreviewConfig, androidSalesforceAppPreviewConfig, -} from '../../src/commands/lightning/preview/app.js'; +} from '../../src/commands/lightning/dev/app.js'; describe('previewUtils', () => { - const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.preview.app'); + const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.app'); const $$ = new TestContext(); const testIOSDevice = new IOSSimulatorDevice(