Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cjs/
File renamed without changes.
3 changes: 3 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'**/*.{js,json,md}?(x)': () => 'npm run reformat',
};
3 changes: 0 additions & 3 deletions .lintstagedrc.js

This file was deleted.

5 changes: 3 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"require": "ts-node/register,source-map-support/register",
"require": ["ts-node/register"],
"watch-extensions": "ts",
"watch-files": ["src", "test"],
"recursive": true,
"reporter": "spec",
"timeout": 440000
"timeout": 440000,
"node-option": ["loader=ts-node/esm"]
}
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
- [CLA](#cla)
- [Build](#build)
- [Commands](#commands)
- [`sf dev generate command`](#sf-dev-generate-command)
- [`sf dev generate flag`](#sf-dev-generate-flag)
- [`sf dev generate hook`](#sf-dev-generate-hook)
- [`sf dev generate library`](#sf-dev-generate-library)
- [`sf dev generate plugin`](#sf-dev-generate-plugin)
- [`sf dev hook HOOK`](#sf-dev-hook-hook)

## Install

Expand Down Expand Up @@ -86,7 +92,7 @@ git clone git@github.com:salesforcecli/plugin-dev
yarn && yarn build
```

To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
To use your plugin, run using the local `./bin/dev.js` or `./bin/dev.cmd` file.

```bash
# Run using local run file.
Expand All @@ -105,12 +111,24 @@ sf plugins
## Commands

<!-- commands -->
* [`sf dev generate command`](#sf-dev-generate-command)
* [`sf dev generate flag`](#sf-dev-generate-flag)
* [`sf dev generate hook`](#sf-dev-generate-hook)
* [`sf dev generate library`](#sf-dev-generate-library)
* [`sf dev generate plugin`](#sf-dev-generate-plugin)
* [`sf dev hook HOOK`](#sf-dev-hook-hook)

- [plugin-dev](#plugin-dev)
- [Install](#install)
- [Usage](#usage)
- [Generate a new `sf` plugin](#generate-a-new-sf-plugin)
- [Generate a new `sf` command in your plugin](#generate-a-new-sf-command-in-your-plugin)
- [Generate a hook that will be used for existing `sf` commands](#generate-a-hook-that-will-be-used-for-existing-sf-commands)
- [Issues](#issues)
- [Contributing](#contributing)
- [CLA](#cla)
- [Build](#build)
- [Commands](#commands)
- [`sf dev generate command`](#sf-dev-generate-command)
- [`sf dev generate flag`](#sf-dev-generate-flag)
- [`sf dev generate hook`](#sf-dev-generate-hook)
- [`sf dev generate library`](#sf-dev-generate-library)
- [`sf dev generate plugin`](#sf-dev-generate-plugin)
- [`sf dev hook HOOK`](#sf-dev-hook-hook)

## `sf dev generate command`

Expand Down Expand Up @@ -271,4 +289,5 @@ EXAMPLES

$ sf dev hook sf:env:list --plugin env
```

<!-- commandsstop -->
21 changes: 0 additions & 21 deletions bin/dev

This file was deleted.

4 changes: 2 additions & 2 deletions bin/dev.cmd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
set NODE_ENV=development
node "%~dp0\dev" %*

node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
8 changes: 8 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
// eslint-disable-next-line node/shebang
async function main() {
const { execute } = await import('@oclif/core');
await execute({ development: true, dir: import.meta.url });
}

await main();
5 changes: 0 additions & 5 deletions bin/run

This file was deleted.

9 changes: 9 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

// eslint-disable-next-line node/shebang
async function main() {
const { execute } = await import('@oclif/core');
await execute({ dir: import.meta.url });
}

await main();
File renamed without changes.
6 changes: 3 additions & 3 deletions messages/plugin.generator.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# info.start

Time to build an sf plugin! Version %s
Time to build an sf plugin!

# question.internal

Expand All @@ -26,9 +26,9 @@ The name must be a valid npm package name:
- All the characters in the package name must be lowercase i.e., no uppercase or mixed case names are allowed
- Package name can consist of hyphens
- Package name must not contain any non-url-safe characters (since name ends up being part of a URL)
- Package name should not start with . or _
- Package name should not start with . or \_
- Package name should not contain any spaces
- Package name should not contain any of the following characters: ~)('!*
- Package name should not contain any of the following characters: ~)('!\*
- Package name cannot be the same as a node.js/io.js core module nor a reserved/blacklisted name
- Package name length cannot exceed 214

Expand Down
77 changes: 28 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,42 @@
{
"name": "@salesforce/plugin-dev",
"description": "commands for sf plugin development",
"version": "1.3.3",
"version": "2.0.0",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^2.11.8",
"@oclif/core": "^3.12.0",
"@octokit/rest": "^19.0.13",
"@salesforce/core": "^5.3.14",
"@salesforce/kit": "^3.0.9",
"@salesforce/sf-plugins-core": "^3.1.20",
"@salesforce/ts-types": "^2.0.8",
"change-case": "^4.1.2",
"@salesforce/core": "^6.1.4",
"@salesforce/kit": "^3.0.15",
"@salesforce/sf-plugins-core": "^5.0.2",
"@salesforce/ts-types": "^2.0.9",
"change-case": "^5.2.0",
"fast-glob": "^3.3.2",
"graphology": "^0.25.1",
"graphology-types": "^0.24.7",
"js-yaml": "^4.1.0",
"lodash.defaultsdeep": "^4.6.1",
"replace-in-file": "^6.3.2",
"shelljs": "^0.8.5",
"tslib": "^2",
"yeoman-environment": "^3.19.3",
"yeoman-generator": "^5.8.0"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.16",
"@salesforce/cli-plugins-testkit": "^4.3.6",
"@salesforce/dev-config": "^4.1.0",
"@salesforce/dev-scripts": "^6.0.3",
"@salesforce/plugin-command-reference": "^3.0.45",
"@salesforce/prettier-config": "^0.0.3",
"@salesforce/ts-sinon": "1.4.12",
"@swc/core": "1.3.20",
"@oclif/plugin-command-snapshot": "^5.0.2",
"@salesforce/cli-plugins-testkit": "^5.0.4",
"@salesforce/dev-scripts": "^7.1.1",
"@salesforce/plugin-command-reference": "^3.0.47",
"@types/js-yaml": "^4.0.5",
"@types/lodash.defaultsdeep": "^4.6.7",
"@types/shelljs": "^0.8.14",
"@types/yeoman-generator": "^5.2.10",
"@types/yeoman-test": "^4.0.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"chai": "^4.3.10",
"eslint": "^8.52.0",
"eslint-config-prettier": "^8.10.0",
"eslint-config-salesforce": "^2.0.1",
"eslint-config-salesforce-license": "^0.2.0",
"eslint-config-salesforce-typescript": "^1.1.1",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "2.28.0",
"eslint-plugin-jsdoc": "^43.0.5",
"eslint-plugin-sf-plugin": "^1.16.5",
"husky": "^7.0.4",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"oclif": "^3.15.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"oclif": "^4.0.3",
"shx": "^0.3.3",
"sinon": "10.0.0",
"ts-node": "^10.4.0",
"typescript": "^4.9.5",
"wireit": "^0.14.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"yeoman-test": "^6.3.0"
},
"config": {
Expand All @@ -68,7 +45,7 @@
}
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"files": [
"/lib",
Expand All @@ -82,14 +59,13 @@
"keywords": [
"force",
"salesforce",
"sfdx",
"salesforcedx",
"sfdx-plugin",
"sf",
"sf-plugin",
"sf"
"sfdx",
"sfdx-plugin"
],
"license": "BSD-3-Clause",
"main": "lib/index.js",
"oclif": {
"commands": "./lib/commands",
"bin": "sf",
Expand Down Expand Up @@ -117,19 +93,20 @@
}
}
}
}
},
"flexibleTaxonomy": true
},
"repository": "salesforcecli/plugin-dev",
"scripts": {
"build": "wireit",
"clean": "sf-clean",
"clean-all": "sf-clean all",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json oclif.lock",
"compile": "wireit",
"docs": "sf-docs",
"format": "wireit",
"lint": "wireit",
"postpack": "shx rm -f oclif.manifest.json",
"postpack": "shx rm -f oclif.manifest.json oclif.lock",
"prepack": "sf-prepack",
"test": "wireit",
"test:nuts": "nyc mocha \"test/**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel --jobs 10",
Expand Down Expand Up @@ -215,7 +192,7 @@
"output": []
},
"test:command-reference": {
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
"command": "ts-node \"./bin/dev.js\" commandreference:generate --erroronwarnings",
"files": [
"src/**/*.ts",
"messages/**",
Expand All @@ -226,7 +203,7 @@
]
},
"test:deprecation-policy": {
"command": "\"./bin/dev\" snapshot:compare",
"command": "ts-node \"./bin/dev.js\" snapshot:compare",
"files": [
"src/**/*.ts"
],
Expand All @@ -236,12 +213,14 @@
]
},
"test:json-schema": {
"command": "\"./bin/dev\" schema:compare",
"command": "ts-node \"./bin/dev.js\" schema:compare",
"files": [
"src/**/*.ts",
"schemas"
],
"output": []
}
}
},
"exports": "./lib/index.js",
"type": "module"
}
11 changes: 6 additions & 5 deletions src/commands/dev/audit/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
* 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 * as fs from 'fs';
import { join, parse, relative, resolve } from 'path';
import fs from 'node:fs';
import { dirname, join, parse, relative, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { ensureString } from '@salesforce/ts-types';
import { Logger, Messages } from '@salesforce/core';
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { MultiDirectedGraph } from 'graphology';
import graphology from 'graphology';
import { Interfaces } from '@oclif/core';

export type AuditResults = {
Expand Down Expand Up @@ -49,7 +50,7 @@ type MessageRefNode = NodeType & {

type Node = FileNode | BundleNode | MessageNode | MessageRefNode | BundleRefNode;

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const messages = Messages.loadMessages('@salesforce/plugin-dev', 'audit.messages');

export default class AuditMessages extends SfCommand<AuditResults> {
Expand Down Expand Up @@ -94,7 +95,7 @@ export default class AuditMessages extends SfCommand<AuditResults> {
};
private package?: string;
private projectDir?: string;
private graph: MultiDirectedGraph<Node> = new MultiDirectedGraph<Node>();
private graph: graphology.MultiDirectedGraph<Node> = new graphology.MultiDirectedGraph<Node>();

public async run(): Promise<AuditResults> {
this.logger = Logger.childFromRoot(this.constructor.name);
Expand Down
6 changes: 4 additions & 2 deletions src/commands/dev/configure/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

// because github api isn't camelcased
/* eslint-disable camelcase */
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { Octokit } from '@octokit/rest';
import { OctokitError } from '../../../types';
import { OctokitError } from '../../../types.js';

Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const messages = Messages.loadMessages('@salesforce/plugin-dev', 'configure.repo');

export type ConfigureRepoResult = {
Expand Down
Loading