Skip to content

Commit 6123518

Browse files
committed
chore: added scripts and formated
1 parent efa98b5 commit 6123518

18 files changed

Lines changed: 1404 additions & 246 deletions

.nycrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"nyc": {
3+
"extends": "@salesforce/dev-config/nyc"
4+
}
5+
}

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

package.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@oclif/errors": "^1",
1111
"@salesforce/command": "^2",
1212
"@salesforce/core": "^2",
13+
"@salesforce/dev-scripts": "^0.4.1",
1314
"chalk": "^3.0.0",
1415
"handlebars": "^4.7.3",
1516
"tslib": "^1"
@@ -18,19 +19,11 @@
1819
"@oclif/dev-cli": "^1",
1920
"@oclif/plugin-help": "^2",
2021
"@oclif/test": "^1",
21-
"@salesforce/dev-config": "1.4.1",
22-
"@types/chai": "^4",
23-
"@types/mocha": "^5",
24-
"@types/node": "^10",
25-
"chai": "^4",
2622
"globby": "^8",
27-
"mocha": "^5",
28-
"nyc": "^14",
29-
"ts-node": "^8",
30-
"tslint": "^5"
23+
"husky": "^1"
3124
},
3225
"engines": {
33-
"node": ">=8.0.0"
26+
"node": ">=8.4.0"
3427
},
3528
"files": [
3629
"/lib",
@@ -59,10 +52,24 @@
5952
},
6053
"repository": "salesforcecli/plugin-command-reference",
6154
"scripts": {
55+
"build": "yarn sfdx-build",
56+
"clean": "yarn sfdx-clean",
57+
"clean-all": "yarn sfdx-clean all",
58+
"compile": "yarn sfdx-compile",
59+
"docs": "yarn sfdx-docs",
60+
"format": "yarn sfdx-format",
61+
"lint": "yarn sfdx-lint",
6262
"postpack": "rm -f oclif.manifest.json",
6363
"posttest": "tslint -p test -t stylish",
64-
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
65-
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
64+
"prepack": "yarn sfdx-build",
65+
"test": "yarn sfdx-test",
6666
"version": "oclif-dev readme && git add README.md"
67+
},
68+
"husky": {
69+
"hooks": {
70+
"commit-msg": "yarn sfdx-husky-commit-msg",
71+
"pre-commit": "yarn sfdx-husky-pre-commit",
72+
"pre-push": "yarn sfdx-husky-pre-push"
73+
}
6774
}
6875
}

src/commands/commandreference/generate.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ Messages.importMessagesDirectory(__dirname);
2222
const messages = Messages.loadMessages('@salesforce/plugin-command-reference', 'main');
2323

2424
export default class CommandReferenceGenerate extends SfdxCommand {
25-
2625
public static description = messages.getMessage('commandDescription');
2726

28-
public static args = [{name: 'file'}];
27+
public static args = [{ name: 'file' }];
2928

3029
protected static flagsConfig = {
3130
outputdir: flags.string({
@@ -38,24 +37,26 @@ export default class CommandReferenceGenerate extends SfdxCommand {
3837
description: messages.getMessage('pluginFlagDescription'),
3938
required: true
4039
}),
41-
hidden: flags.boolean({description: messages.getMessage('hiddenFlagDescription')}),
42-
erroronwarnings: flags.boolean({description: messages.getMessage('erroronwarningFlagDescription')})
40+
hidden: flags.boolean({ description: messages.getMessage('hiddenFlagDescription') }),
41+
erroronwarnings: flags.boolean({ description: messages.getMessage('erroronwarningFlagDescription') })
4342
};
4443

4544
public async run(): Promise<AnyJson> {
46-
const plugins = this.flags.plugins.map(plugin => plugin.trim()).map(name => {
47-
let pluginName = name;
48-
let plugin = this.getPlugin(pluginName);
45+
const plugins = this.flags.plugins
46+
.map(plugin => plugin.trim())
47+
.map(name => {
48+
let pluginName = name;
49+
let plugin = this.getPlugin(pluginName);
4950

50-
if (!plugin) {
51-
pluginName = `@salesforce/plugin-${pluginName}`;
52-
plugin = this.getPlugin(pluginName);
5351
if (!plugin) {
54-
throw new SfdxError(`Plugin ${name} or ${pluginName} not found. Is it installed?`);
52+
pluginName = `@salesforce/plugin-${pluginName}`;
53+
plugin = this.getPlugin(pluginName);
54+
if (!plugin) {
55+
throw new SfdxError(`Plugin ${name} or ${pluginName} not found. Is it installed?`);
56+
}
5557
}
56-
}
57-
return pluginName;
58-
});
58+
return pluginName;
59+
});
5960

6061
Ditamap.outputDir = this.flags.outputdir;
6162

@@ -65,12 +66,12 @@ export default class CommandReferenceGenerate extends SfdxCommand {
6566
const plugin = this.getPlugin(name);
6667
const version = plugin && plugin.version;
6768
if (!version) throw new Error(`No version found for plugin ${name}`);
68-
return {name, version};
69+
return { name, version };
6970
});
7071

7172
const docs = new Docs(Ditamap.outputDir, Ditamap.plugins, this.flags.hidden, this.loadTopicMetadata());
7273

73-
events.on('topic', ({topic}) => {
74+
events.on('topic', ({ topic }) => {
7475
this.log(chalk.green(`Generating topic '${topic}'`));
7576
});
7677

@@ -87,7 +88,7 @@ export default class CommandReferenceGenerate extends SfdxCommand {
8788
throw new SfdxError(`Found ${warnings.length} warnings.`);
8889
}
8990

90-
return {warnings};
91+
return { warnings };
9192
}
9293

9394
private pluginMap(plugins: string[]) {

src/ditamap/base-ditamap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {Ditamap} from './ditamap';
8+
import { Ditamap } from './ditamap';
99

1010
export class BaseDitamap extends Ditamap {
1111
constructor(topics: string[]) {

src/ditamap/cli-reference-topic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {join} from 'path';
9-
import {Ditamap} from './ditamap';
8+
import { join } from 'path';
9+
import { Ditamap } from './ditamap';
1010

1111
export class CLIReferenceTopic extends Ditamap {
1212
constructor(topic: string, longDescription: string) {

src/ditamap/cli-reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {Ditamap} from './ditamap';
8+
import { Ditamap } from './ditamap';
99

1010
export class CLIReference extends Ditamap {
1111
constructor() {

src/ditamap/command.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {asString, Dictionary, ensureJsonMap, ensureObject, ensureString, JsonMap} from '@salesforce/ts-types';
8+
import { asString, Dictionary, ensureJsonMap, ensureObject, ensureString, JsonMap } from '@salesforce/ts-types';
99
import chalk = require('chalk');
10-
import {join} from 'path';
10+
import { join } from 'path';
1111
import { events } from '../utils';
12-
import {Ditamap} from './ditamap';
12+
import { Ditamap } from './ditamap';
1313

1414
export class Command extends Ditamap {
1515
constructor(topic: string, subtopic: string, command: Dictionary, commandMeta: JsonMap = {}) {
@@ -21,19 +21,24 @@ export class Command extends Ditamap {
2121
super(filename, {});
2222

2323
const parameters = Object.entries(flags)
24-
.filter(([, flag]) => !flag.hidden)
25-
.map(([flagName, flag]) => {
26-
if (!flag.longDescription) {
27-
events.emit('warning', `No flag longDescription for command ${chalk.bold(command.id)} on flag ${flagName}. That command owner must add the longDescription to the flag definition.`);
28-
}
29-
return Object.assign(flag, {
30-
name: flagName,
31-
longDescriptionPs: this.formatParagraphs(flag.longDescription),
32-
optional: !flag.required,
33-
kind: flag.kind || flag.type,
34-
hasValue: flag.type !== 'boolean'
24+
.filter(([, flag]) => !flag.hidden)
25+
.map(([flagName, flag]) => {
26+
if (!flag.longDescription) {
27+
events.emit(
28+
'warning',
29+
`No flag longDescription for command ${chalk.bold(
30+
command.id
31+
)} on flag ${flagName}. That command owner must add the longDescription to the flag definition.`
32+
);
33+
}
34+
return Object.assign(flag, {
35+
name: flagName,
36+
longDescriptionPs: this.formatParagraphs(flag.longDescription),
37+
optional: !flag.required,
38+
kind: flag.kind || flag.type,
39+
hasValue: flag.type !== 'boolean'
40+
});
3541
});
36-
});
3742

3843
let trailblazerCommunityUrl;
3944
let trailblazerCommunityName;
@@ -44,7 +49,12 @@ export class Command extends Ditamap {
4449
}
4550

4651
if (!command.longDescription) {
47-
events.emit('warning', `No longDescription for command ${chalk.bold(command.id)}. That command owner must add the longDescription to the command definition.`);
52+
events.emit(
53+
'warning',
54+
`No longDescription for command ${chalk.bold(
55+
command.id
56+
)}. That command owner must add the longDescription to the command definition.`
57+
);
4858
}
4959

5060
let fullName: string;

src/ditamap/ditamap.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {fs} from '@salesforce/core';
9-
import {JsonMap} from '@salesforce/ts-types';
8+
import { fs } from '@salesforce/core';
9+
import { JsonMap } from '@salesforce/ts-types';
1010
import * as debugCreator from 'debug';
11-
import {compile, registerHelper} from 'handlebars';
12-
import {dirname, join} from 'path';
11+
import { compile, registerHelper } from 'handlebars';
12+
import { dirname, join } from 'path';
1313

1414
const debug = debugCreator('commandreference');
1515

@@ -67,7 +67,7 @@ export abstract class Ditamap {
6767
}
6868

6969
protected formatParagraphs(textToFormat?: string) {
70-
return (textToFormat) ? textToFormat.split('\n').filter(n => n !== '') : [];
70+
return textToFormat ? textToFormat.split('\n').filter(n => n !== '') : [];
7171
}
7272

7373
/**

src/ditamap/main-topic-intro.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {ensureJsonMap, JsonMap} from '@salesforce/ts-types';
8+
import { ensureJsonMap, JsonMap } from '@salesforce/ts-types';
99
import chalk = require('chalk');
10-
import {join} from 'path';
10+
import { join } from 'path';
1111
import { events } from '../utils';
12-
import {Ditamap} from './ditamap';
12+
import { Ditamap } from './ditamap';
1313

1414
export class MainTopicIntro extends Ditamap {
1515
constructor(topic: string, subtopic: string, subTopicMeta: JsonMap) {
@@ -24,7 +24,12 @@ export class MainTopicIntro extends Ditamap {
2424
}
2525

2626
if (!subTopicMeta.longDescription) {
27-
events.emit('warning', `No long description for topic ${chalk.bold(topic + ':' + subtopic)}. That topic owner must add a longDescription to the topic metadata in the oclif section in the package.json file within their plugin.`);
27+
events.emit(
28+
'warning',
29+
`No long description for topic ${chalk.bold(
30+
topic + ':' + subtopic
31+
)}. That topic owner must add a longDescription to the topic metadata in the oclif section in the package.json file within their plugin.`
32+
);
2833
}
2934

3035
super(filename, {

0 commit comments

Comments
 (0)