Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

fix: apply needed changes to deps and structure #91

Merged
merged 4 commits into from
Jun 16, 2021
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
yarn.lock
package-lock.json
.idea
/.history
/.history
.DS_Store
57 changes: 32 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,56 @@
"bin": "./bin/run",
"bugs": "https://github.com/forcedotcom/sfdx-plugin-generate/issues",
"dependencies": {
"@oclif/command": "^1.5.8",
"@oclif/config": "^1.12.6",
"@oclif/errors": "^1.2.2",
"@oclif/command": "^1.8.0",
"@oclif/config": "^1.17.0",
"@oclif/errors": "^1.3.4",
"@oclif/fixpack": "^2.3.0",
"@oclif/plugin-help": "^2.1.6",
"@oclif/plugin-help": "^3.2.2",
"@oclif/plugin-not-found": "^1.2.2",
"@oclif/plugin-warn-if-update-available": "^1.5.4",
"debug": "^4.1.1",
"debug": "^4.3.1",
"eslint-config-xo": "^0.36.0",
"eslint-config-xo-space": "^0.27.0",
"lodash": "^4.17.20",
"nps-utils": "^1.7.0",
"sort-pjson": "^1.0.3",
"tslib": "^1.9.3",
"tslib": "^2.2.0",
"yeoman-environment": "2.4.0",
"yeoman-generator": "4.0.1",
"yosay": "^2.0.2"
},
"devDependencies": {
"@oclif/dev-cli": "^1.21.0",
"@oclif/dev-cli": "^1.26.0",
"@oclif/tslint": "^3.1.1",
"@salesforce/dev-scripts": "^0.6.2",
"@types/lodash": "^4.14.121",
"@types/read-pkg": "^3.0.0",
"@salesforce/dev-config": "^2.1.2",
"@salesforce/dev-scripts": "^0.9.15",
"@types/jsforce": "^1.9.29",
"@types/lodash": "^4.14.170",
"@types/read-pkg": "^5.1.0",
"@types/shelljs": "^0.8.3",
"@types/yeoman-generator": "^3.1.3",
"@types/yosay": "^0.0.29",
"chai": "^4.2.0",
"eslint": "^5.13.0",
"@types/yosay": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"chai": "^4.3.4",
"eslint": "^7.28.0",
"eslint-config-oclif": "^3.1.0",
"execa": "^1.0.0",
"fancy-test": "^1.4.3",
"fs-extra": "^7.0.1",
"globby": "^9.0.0",
"mocha": "^5.2.0",
"npm-run-path": "^2.0.2",
"nps": "^5.9.3",
"execa": "^5.1.1",
"fancy-test": "^1.4.10",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
"husky": "^4.3.8",
"mocha": "^9.0.0",
"npm-run-path": "^4.0.1",
"nps": "^5.10.0",
"shelljs": "^0.8.3",
"tmp": "^0.0.33",
"ts-node": "^8.0.2",
"tslint": "^5.12.1",
"typescript": "^3.3.3"
"tmp": "^0.2.1",
"ts-node": "^10.0.0",
"tslint": "^6.1.3",
"typescript": "^4.3.2"
},
"engines": {
"node": ">=8.4.0"
"node": ">=12.4.0"
},
"files": [
".oclif.manifest.json",
Expand Down
70 changes: 45 additions & 25 deletions src/generators/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class App extends Generator {
repository,
...this.pjson,
engines: {
node: '>=8.0.0',
node: '>=12.0.0',
...this.pjson.engines,
},
options: this.options,
Expand Down Expand Up @@ -241,11 +241,11 @@ class App extends Generator {
const sfdxPluginOptions = {
typescript: true,
mocha: true,
tslint: true,
tslint: false,
peternhale marked this conversation as resolved.
Show resolved Hide resolved
yarn: true,
circleci: true,
appveyor: true,
eslint: false,
eslint: true,
travisci: false
}
this.options = this.type === 'sfdx-plugin' ? sfdxPluginOptions : this.options
Expand Down Expand Up @@ -274,15 +274,16 @@ class App extends Generator {
this.pjson.scripts.posttest = 'eslint .'
}
if (this.mocha) {
this.pjson.scripts.test = `nyc ${this.ts ? '--extension .ts ' : ''}mocha --forbid-only "test/**/*.test.${this._ext}"`
this.pjson.scripts.test = `nyc ${this.ts ? '--extension .ts --require ts-node/register ' : ''}mocha --forbid-only "test/**/*.test.${this._ext}"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is typically in the mocha file, but shouldn't hurt.

} else {
this.pjson.scripts.test = 'echo NO TESTS'
}
if (this.ts) {
this.pjson.scripts.prepack = nps.series(`${rmrf} lib`, 'tsc -b')
}
if (['sfdx-plugin', 'plugin', 'multi'].includes(this.type)) {
this.pjson.scripts.lint = 'tslint --project . --config tslint.json --format stylish'
this.pjson.scripts.lint = 'eslint src/**/*.ts test/**/*.ts'
this.pjson.scripts.posttest = 'eslint src/**/*.ts test/**/*.ts'
this.pjson.scripts.prepack = nps.series(this.pjson.scripts.prepack, 'oclif-dev manifest', 'oclif-dev readme')
this.pjson.scripts.postpack = `${rmf} oclif.manifest.json`
this.pjson.scripts.version = nps.series('oclif-dev readme', 'git add README.md')
Expand Down Expand Up @@ -380,13 +381,13 @@ class App extends Generator {
}
}
}
if (this.eslint) {
if (this.eslint && this.type !== 'sfdx-plugin') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please excuse my ignorance but what does this do?
Does it make it so our standard eslintrc isn't added to our own plugins?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RodEsp This repo was a direct clone of the oclif version of plugin generate. The oclif version asked a bunch of question, such as JS or TS, yarn or npm, ... The interactive piece of this plugin was stripped down to be sfdx specific, including language === 'ts', packager mgr === 'yarn', etc. However, all of the logic that consumes the answers were not stripped down, but left in place. Logic like this.type !== 'sfdx-plugin' is looking for things to for a sfdx plugin.

this.fs.copyTpl(this.templatePath('eslintrc'), this.destinationPath('.eslintrc'), this)
const eslintignore = this._eslintignore()
if (eslintignore.trim()) this.fs.write(this.destinationPath('.eslintignore'), this._eslintignore())
}
if (this.mocha) {
this.fs.copyTpl(this.templatePath('test/mocha.opts'), this.destinationPath('test/mocha.opts'), this)
this.fs.copyTpl(this.templatePath('test/mocha.json'), this.destinationPath('test/mocha.json'), this)
}
if (this.fs.exists(this.destinationPath('./package.json'))) {
fixpack(this.destinationPath('./package.json'), require('@oclif/fixpack/config.json'))
Expand Down Expand Up @@ -445,7 +446,7 @@ class App extends Generator {
dependencies.push(
'@oclif/config@^1',
'@oclif/command@^1',
'@oclif/plugin-help@^2',
'@oclif/plugin-help@^3',
)
break
case 'plugin':
Expand All @@ -455,69 +456,87 @@ class App extends Generator {
)
devDependencies.push(
'@oclif/dev-cli@^1',
'@oclif/plugin-help@^2',
'globby@^8',
'@oclif/plugin-help@^3',
'globby@^11',
)
break
case 'sfdx-plugin':
dependencies.push(
'@oclif/command@^1',
'@oclif/config@^1',
'@oclif/errors@^1',
'@salesforce/command@^2',
'@salesforce/command@^3',
'@salesforce/core@^2'
)
devDependencies.push(
'@oclif/dev-cli@^1',
'@oclif/plugin-help@^2',
'globby@^8',
'@salesforce/[email protected]'
'@oclif/plugin-help@^3',
'globby@^11',
'@salesforce/dev-config@^2',
'@salesforce/dev-scripts@^0',
'@salesforce/prettier-config@^0',
'@salesforce/ts-sinon@^1',
'@types/jsforce@^1.9.29',
'@typescript-eslint/eslint-plugin@^4',
'@typescript-eslint/parser@^4',
'eslint-config-prettier@^8',
'eslint-config-salesforce@^0',
'eslint-config-salesforce-typescript@^0',
'eslint-plugin-header@^3',
'eslint-plugin-import@^2',
'eslint-plugin-jsdoc@^35',
'eslint-plugin-prettier@^3',
'eslint-plugin-typescript@^0',
'husky@^4',
'prettier@^2',
'pretty-quick@^3',
)
break
case 'multi':
dependencies.push(
'@oclif/config@^1',
'@oclif/command@^1',
'@oclif/plugin-help@^2',
'@oclif/plugin-help@^3',
)
devDependencies.push(
'@oclif/dev-cli@^1',
'globby@^8',
'globby@^11',
)
}
if (this.mocha) {
devDependencies.push(
'mocha@^5',
'nyc@^14',
'mocha@^8',
'nyc@^15',
'chai@^4',
'[email protected]'
)
if (this.type !== 'base') devDependencies.push(
'@oclif/test@^1',
)
}
if (this.ts) {
dependencies.push(
'tslib@^1',
'tslib@^2',
)
devDependencies.push(
'@types/node@^10',
'ts-node@^8',
'ts-node@^10',
'typescript@4'
)
if (this.mocha) {
devDependencies.push(
'@types/chai@^4',
'@types/mocha@^5',
'@types/mocha@^8',
)
}
if (this.tslint) {
devDependencies.push(
'tslint@^5',
'tslint@^6',
)
}
}
if (this.eslint) {
devDependencies.push(
'eslint@^5.13',
'eslint@^7',
'eslint-config-oclif@^3.1',
)
}
Expand Down Expand Up @@ -612,8 +631,9 @@ class App extends Generator {
this.fs.copyTpl(this.templatePath('bin/run.cmd'), this.destinationPath('bin/run.cmd'), opts)
this.fs.copyTpl(this.templatePath('sfdxPlugin/README.md.ejs'), this.destinationPath('README.md'), this)
this.fs.copy(this.templatePath('.images/vscodeScreenshot.png'), this.destinationPath('.images/vscodeScreenshot.png'), this)
this.fs.copyTpl(this.templatePath('sfdxPlugin/tslint.json'), this.destinationPath('tslint.json'), this)
this.fs.copyTpl(this.templatePath('sfdxPlugin/.eslintrc.js'), this.destinationPath('.eslintrc.js'), this)
this.fs.copyTpl(this.templatePath('sfdxPlugin/tsconfig.json'), this.destinationPath('tsconfig.json'), this)
this.fs.copyTpl(this.templatePath('sfdxPlugin/.prettierrc.json'), this.destinationPath('.prettierrc.json'), this)
if (!fs.existsSync('src/commands')) {
this.fs.copyTpl(this.templatePath(`src/sfdxCommand.${this._ext}.ejs`), this.destinationPath(`src/commands/${topic}/${sfdxExampleCommand}.${this._ext}`), {
...opts,
Expand Down
11 changes: 11 additions & 0 deletions templates/sfdxPlugin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2020, 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
*/

module.exports = {
extends: ["eslint-config-salesforce-typescript"],
parser: "@typescript-eslint/parser",
};
1 change: 1 addition & 0 deletions templates/sfdxPlugin/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@salesforce/prettier-config"
19 changes: 14 additions & 5 deletions templates/sfdxPlugin/test/command.test.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ import { ensureJsonMap, ensureString } from '@salesforce/ts-types';
describe('<%- topic %>:<%- name %>', () => {
test
.withOrg({ username: '[email protected]' }, true)
.withConnectionRequest(request => {
.withConnectionRequest((request) => {
const requestMap = ensureJsonMap(request);
if (ensureString(requestMap.url).match(/Organization/)) {
return Promise.resolve({ records: [ { Name: 'Super Awesome Org', TrialExpirationDate: '2018-03-20T23:24:11.000+0000'}] });
if (/Organization/.exec(ensureString(requestMap.url))) {
return Promise.resolve({
records: [
{
Name: 'Super Awesome Org',
TrialExpirationDate: '2018-03-20T23:24:11.000+0000',
},
],
});
}
return Promise.resolve({ records: [] });
})
.stdout()
.command(['<%- topic %>:<%- name %>', '--targetusername', '[email protected]'])
.it('runs <%- topic %>:<%- name %> --targetusername [email protected]', ctx => {
expect(ctx.stdout).to.contain('Hello world! This is org: Super Awesome Org and I will be around until Tue Mar 20 2018!');
.it('runs <%- topic %>:<%- name %> --targetusername [email protected]', (ctx) => {
expect(ctx.stdout).to.contain(
'Hello world! This is org: Super Awesome Org and I will be around until Tue Mar 20 2018!'
);
});
});
7 changes: 5 additions & 2 deletions templates/sfdxPlugin/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "../tsconfig"
"extends": "@salesforce/dev-config/tsconfig-test",
"include": ["./**/*.ts"],
"compilerOptions": {
"skipLibCheck": true
}
}

12 changes: 4 additions & 8 deletions templates/sfdxPlugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"extends": "./node_modules/@salesforce/dev-config/tsconfig",
"extends": "@salesforce/dev-config/tsconfig",
"compilerOptions": {
"declaration": true,
"outDir": "./lib",
"importHelpers": true,
"rootDir": "./src"
"outDir": "lib",
"rootDir": "src"
},
"include": [
"./src/**/*"
]
"include": ["./src/**/*.ts"]
}
4 changes: 0 additions & 4 deletions templates/sfdxPlugin/tslint.json

This file was deleted.

Loading