Skip to content

Commit

Permalink
chore: rename preview to dev (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrkruk authored Aug 8, 2024
1 parent 8b95781 commit 23cc45d
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 47 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions command-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
{
"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"],
"plugin": "@salesforce/plugin-lightning-dev"
},
{
"alias": [],
"command": "lightning:preview:site",
"command": "lightning:dev:site",
"flagAliases": [],
"flagChars": ["n", "o"],
"flags": ["debug", "flags-dir", "json", "name", "target-org"],
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"lightning": {
"external": true,
"subtopics": {
"preview": {
"dev": {
"description": "Preview applications and sites locally and in real-time, without deploying them."
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -55,7 +55,7 @@ class AppServerIdentityTokenService implements IdentityTokenService {
}
}

export default class LightningPreviewApp extends SfCommand<void> {
export default class LightningDevApp extends SfCommand<void> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
Expand Down Expand Up @@ -155,11 +155,11 @@ export default class LightningPreviewApp extends SfCommand<void> {
// eslint-disable-next-line no-console
console.log(message);

return LightningPreviewApp.waitForKeyPress();
return LightningDevApp.waitForKeyPress();
}

public async run(): Promise<void> {
const { flags } = await this.parse(LightningPreviewApp);
const { flags } = await this.parse(LightningDevApp);
const logger = await Logger.child(this.ctor.name);

const appName = flags['name'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LightningPreviewSiteResult> {
export default class LightningDevSite extends SfCommand<LightningDevSiteResult> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
Expand All @@ -36,8 +36,8 @@ export default class LightningPreviewSite extends SfCommand<LightningPreviewSite
'target-org': Flags.optionalOrg({ summary: messages.getMessage('flags.target-org.summary') }),
};

public async run(): Promise<LightningPreviewSiteResult> {
const { flags } = await this.parse(LightningPreviewSite);
public async run(): Promise<LightningDevSiteResult> {
const { flags } = await this.parse(LightningDevSite);
// Connect to Org
const connection = flags['target-org'].getConnection();

Expand Down Expand Up @@ -112,9 +112,9 @@ export default class LightningPreviewSite extends SfCommand<LightningPreviewSite
mrtBundleRoot: siteDir,
});
// const name = flags.name ?? 'world';
// this.log(`hello ${name} from /Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/site.ts`);
// this.log(`hello ${name} from /Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/dev/site.ts`);
return {
path: '/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/preview/site.ts',
path: '/Users/nkruk/git/plugin-lightning-dev/src/commands/lightning/dev/site.ts',
};
}
}
4 changes: 2 additions & 2 deletions src/shared/previewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// **********************************************************************************************
// * TODO: When we finalize the implementation for the preview commands and things settle down, *
// * TODO: When we finalize the implementation for the dev commands and things settle down, *
// * consider moving most of these into PreviewUtils of lwc-dev-mobile-core instead. *
// **********************************************************************************************

Expand Down Expand Up @@ -34,7 +34,7 @@ import fetch from 'node-fetch';
import { ConfigUtils, LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT } from './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');
const DevPreviewAuraMode = 'DEVPREVIEW';

export class PreviewUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
import { expect } from 'chai';
describe('lightning preview org NUTs', () => {
describe('lightning dev org NUTs', () => {
let session: TestSession;
before(async () => {
Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -73,14 +73,11 @@ describe('lightning preview app', () => {
$$.SANDBOX.stub(SfConfig.prototype, 'write').resolves();
$$.SANDBOX.stub(ConfigUtils, 'getOrCreateIdentityToken').resolves(fakeIdentityToken);

MockedLightningPreviewApp = await esmock<typeof LightningPreviewApp>(
'../../../../src/commands/lightning/preview/app.js',
{
'../../../../src/lwc-dev-server/index.js': {
startLWCServer: async () => ({ stopServer: () => {} }),
},
}
);
MockedLightningPreviewApp = await esmock<typeof LightningDevApp>('../../../../src/commands/lightning/dev/app.js', {
'../../../../src/lwc-dev-server/index.js': {
startLWCServer: async () => ({ stopServer: () => {} }),
},
});
});

afterEach(() => {
Expand Down Expand Up @@ -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');
});
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof stubSfCommandUx>;

Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/shared/previewUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 23cc45d

Please sign in to comment.