Skip to content

Commit

Permalink
chore: plugin-marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Aug 8, 2023
1 parent 74c79c4 commit 004413b
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 134 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.

```bash
# Run using local run file.
./bin/dev hello world
./bin/dev plugins world
```

There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
Expand Down
29 changes: 0 additions & 29 deletions messages/hello.world.md

This file was deleted.

15 changes: 15 additions & 0 deletions messages/plugins.discover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# summary

Summary of a command.

# description

Description of a command.

# flags.name.summary

Description of a flag.

# examples

- <%= config.bin %> <%= command.id %>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@salesforce/plugin-template-sf",
"name": "@salesforce/plugin-marketplace",
"description": "A template repository for sf plugins",
"version": "0.0.1",
"author": "Salesforce",
Expand All @@ -21,7 +21,7 @@
"@salesforce/ts-sinon": "1.4.8",
"@swc/core": "1.3.39",
"@types/inquirer": "^9.0.3",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"chai": "^4.3.7",
"eslint": "^8.45.0",
Expand Down
42 changes: 0 additions & 42 deletions src/commands/hello/world.ts

This file was deleted.

76 changes: 76 additions & 0 deletions src/commands/plugins/discover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import got from 'got';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-marketplace', 'plugins.discover');

type NpmInfo = {
name: string;
version: string;
description: string;
homepage: string;
repository: { url: string };
};

type StarInfo = {
downloads: string;
package: string;
};

export default class PluginsDiscover extends SfCommand<void> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');

// eslint-disable-next-line class-methods-use-this
public async run(): Promise<void> {
const packages = [
'@muenzpraeger/sfdx-plugin',
'sfdx-waw-plugin',
'mo-dx-plugin',
'sfdx-hardis',
'sfdx-affirm',
'expereo-sfdx-plugin',
'heat-sfdx-cli',
'bmsfdx',
'shane-sfdx-plugins',
'sfdx-cmdt-plugin',
'etcopydata',
'sfdx-migration-automatic',
'sfdx-devhub-pool',
'@dx-cli-toolbox/sfdx-toolbox-package-utils',
'@dxatscale/sfpowerscripts',
'soqlx-opener',
'sfdx-git-packager',
'texei-sfdx-plugin',
];

const npmData = await Promise.all(
packages.map((pkg) =>
Promise.all([
got<NpmInfo>(`https://registry.npmjs.org/${pkg}/latest`).json<NpmInfo>(),
got<StarInfo>(`https://api.npmjs.org/downloads/point/last-week/${pkg}`).json<StarInfo>(),
])
)
);

const combined = npmData
.map((y) => ({ ...y[0], ...y[1] }))
.sort((a, b) => (b.downloads > a.downloads ? 1 : -1))
.map((y) => ({ ...y, description: `${y.description.match(/(.{1,100})(?:\s|$)/g)?.join('\n')}` }));

this.table(combined, {
name: { header: 'Package' },
description: { header: 'Description' },
homepage: { header: 'Homepage' },
downloads: { header: 'Weekly Downloads' },
});
}
}
34 changes: 0 additions & 34 deletions test/commands/hello/world.nut.ts

This file was deleted.

12 changes: 6 additions & 6 deletions test/commands/hello/world.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import { TestContext } from '@salesforce/core/lib/testSetup';
import { expect } from 'chai';
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
import World from '../../../src/commands/hello/world';
import World from '../../../src/commands/plugins/discover';

describe('hello world', () => {
describe('plugins world', () => {
const $$ = new TestContext();
let sfCommandStubs: ReturnType<typeof stubSfCommandUx>;

Expand All @@ -21,7 +21,7 @@ describe('hello world', () => {
$$.restore();
});

it('runs hello world', async () => {
it('runs plugins world', async () => {
await World.run([]);
const output = sfCommandStubs.log
.getCalls()
Expand All @@ -30,12 +30,12 @@ describe('hello world', () => {
expect(output).to.include('Hello World');
});

it('runs hello world with --json and no provided name', async () => {
it('runs plugins world with --json and no provided name', async () => {
const result = await World.run([]);
expect(result.name).to.equal('World');
});

it('runs hello world --name Astro', async () => {
it('runs plugins world --name Astro', async () => {
await World.run(['--name', 'Astro']);
const output = sfCommandStubs.log
.getCalls()
Expand All @@ -44,7 +44,7 @@ describe('hello world', () => {
expect(output).to.include('Hello Astro');
});

it('runs hello world --name Astro --json', async () => {
it('runs plugins world --name Astro --json', async () => {
const result = await World.run(['--name', 'Astro', '--json']);
expect(result.name).to.equal('Astro');
});
Expand Down
83 changes: 63 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1383,17 +1383,17 @@
"@types/expect" "^1.20.4"
"@types/node" "*"

"@typescript-eslint/eslint-plugin@^5.59.11":
version "5.59.11"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.11.tgz#8d466aa21abea4c3f37129997b198d141f09e76f"
integrity sha512-XxuOfTkCUiOSyBWIvHlUraLw/JT/6Io1365RO6ZuI88STKMavJZPNMU0lFcUTeQXEhHiv64CbxYxBNoDVSmghg==
"@typescript-eslint/eslint-plugin@^5.61.0":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz#aeef0328d172b9e37d9bab6dbc13b87ed88977db"
integrity sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==
dependencies:
"@eslint-community/regexpp" "^4.4.0"
"@typescript-eslint/scope-manager" "5.59.11"
"@typescript-eslint/type-utils" "5.59.11"
"@typescript-eslint/utils" "5.59.11"
"@typescript-eslint/scope-manager" "5.62.0"
"@typescript-eslint/type-utils" "5.62.0"
"@typescript-eslint/utils" "5.62.0"
debug "^4.3.4"
grapheme-splitter "^1.0.4"
graphemer "^1.4.0"
ignore "^5.2.0"
natural-compare-lite "^1.4.0"
semver "^7.3.7"
Expand Down Expand Up @@ -1425,13 +1425,21 @@
"@typescript-eslint/types" "5.61.0"
"@typescript-eslint/visitor-keys" "5.61.0"

"@typescript-eslint/type-utils@5.59.11":
version "5.59.11"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.11.tgz#5eb67121808a84cb57d65a15f48f5bdda25f2346"
integrity sha512-LZqVY8hMiVRF2a7/swmkStMYSoXMFlzL6sXV6U/2gL5cwnLWQgLEG8tjWPpaE4rMIdZ6VKWwcffPlo1jPfk43g==
"@typescript-eslint/scope-manager@5.62.0":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz#d9457ccc6a0b8d6b37d0eb252a23022478c5460c"
integrity sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==
dependencies:
"@typescript-eslint/typescript-estree" "5.59.11"
"@typescript-eslint/utils" "5.59.11"
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/visitor-keys" "5.62.0"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz#286f0389c41681376cdad96b309cedd17d70346a"
integrity sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==
dependencies:
"@typescript-eslint/typescript-estree" "5.62.0"
"@typescript-eslint/utils" "5.62.0"
debug "^4.3.4"
tsutils "^3.21.0"

Expand All @@ -1445,6 +1453,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.61.0.tgz#e99ff11b5792d791554abab0f0370936d8ca50c0"
integrity sha512-ldyueo58KjngXpzloHUog/h9REmHl59G1b3a5Sng1GfBo14BkS3ZbMEb3693gnP1k//97lh7bKsp6/V/0v1veQ==

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==

"@typescript-eslint/[email protected]":
version "5.59.11"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.11.tgz#b2caaa31725e17c33970c1197bcd54e3c5f42b9f"
Expand All @@ -1471,7 +1484,34 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^5.59.11":
"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz#7d17794b77fabcac615d6a48fb143330d962eb9b"
integrity sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==
dependencies:
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/visitor-keys" "5.62.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86"
integrity sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.62.0"
"@typescript-eslint/types" "5.62.0"
"@typescript-eslint/typescript-estree" "5.62.0"
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/utils@^5.59.11":
version "5.59.11"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.11.tgz#9dbff49dc80bfdd9289f9f33548f2e8db3c59ba1"
integrity sha512-didu2rHSOMUdJThLk4aZ1Or8IcO3HzCw/ZvEjTTIfjIrcdd5cvSIwwDy2AOlE7htSNp7QIZ10fLMyRCveesMLg==
Expand Down Expand Up @@ -1501,6 +1541,14 @@
"@typescript-eslint/types" "5.61.0"
eslint-visitor-keys "^3.3.0"

"@typescript-eslint/[email protected]":
version "5.62.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz#2174011917ce582875954ffe2f6912d5931e353e"
integrity sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==
dependencies:
"@typescript-eslint/types" "5.62.0"
eslint-visitor-keys "^3.3.0"

"@ungap/[email protected]":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
Expand Down Expand Up @@ -3611,11 +3659,6 @@ graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.5, graceful-fs@^4.1.6,
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==

grapheme-splitter@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e"
integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==

graphemer@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6"
Expand Down

0 comments on commit 004413b

Please sign in to comment.