Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: streamline devDeps into 2 buckets, provide defaults #240

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ To configure what this generates and controls, create a `.sfdevrc` file. Look at

## Config File Notes

By default, devScripts will try to keep your package.json aligned with its standards.

For example, devScripts will remove dependencies that it provides. If you want to keep yours, you'd add it in to the `sf-dev-rc`. Imagine you need to be on a higher or lower version of mocha that devScripts provides:

```json
{
"devDepOverrides": ["mocha", "@types/mocha"]
}
```

And it maintains the `scripts` and `wireit` properties. Imagine you want a different lint step in wireit, and a different test step:

```json
{
"scripts": {
"test": "yarn test:nuts"
},
"wireit": {
"lint": {
"command": "eslint src test --color",
"files": ["src/**/*.ts", "test/**/*.ts", "messages/**", "**/.eslint*", "**/tsconfig.json"],
"output": []
}
}
}
```

### tsconfig

The `include` section has to live in the repository's tsconfig file until there is a way to specify a base. We plan to remove this section when https://github.com/Microsoft/TypeScript/issues/25430 is fixed
21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@salesforce/dev-scripts",
"version": "5.12.2",
"version": "5.12.3-beta.0",
"description": "Standardize package.json scripts and config files for Salesforce projects.",
"repository": "forcedotcom/dev-scripts",
"bin": {
Expand Down Expand Up @@ -37,24 +37,16 @@
"@salesforce/prettier-config": "^0.0.3",
"@types/chai": "^4.2.11",
"@types/mocha": "^9.0.0",
"@types/node": "^15.6.1",
"@types/sinon": "10.0.11",
"@types/node": "^18",
"@types/sinon": "^10.0.20",
"chai": "^4.3.10",
"chalk": "^4.0.0",
"cosmiconfig": "^7.0.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-salesforce": "^2.0.1",
"eslint-config-salesforce-license": "^0.2.0",
"eslint-config-salesforce-typescript": "^2.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-prefer-arrow": "^1.2.1",
"eslint-config-salesforce-typescript": "^2.0.1-beta.0",
"husky": "^7.0.4",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.0",
"shelljs": "~0.8.4",
"sinon": "10.0.0",
Expand All @@ -67,5 +59,8 @@
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"eslint": "^8.52.0"
}
}
13 changes: 11 additions & 2 deletions sfdevrc.schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"title": "JSON schema for .sfdevrc.json config for @salesforce/dev-scripts",
"$schema": "http://json-schema.org/draft-04/schema#",

"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -13,7 +12,9 @@
"scripts": {
"description": "The scripts to add to the package.json",
"type": "object",
"additionalProperties": { "type": "string" },
"additionalProperties": {
"type": "string"
},
"properties": {
"clean": {
"description": "script used to clean a project",
Expand Down Expand Up @@ -87,6 +88,14 @@
"default": "**/*.test.ts"
}
}
},
"wireit": {
"description": "Overrides for the wireit section of package.json. Store changes here to prevent sf-install from setting them back to the default",
"type": "object"
},
"devDepOverrides": {
"description": "dev-scripts contains most dev dependencies. Add names of dependencies that you want it to leave the way your package.json has them",
"type": "array"
}
}
}
5 changes: 3 additions & 2 deletions utils/sf-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ const resolveConfig = (path) => {

// Allow users to override certain scripts
const config = Object.assign({}, defaults, configFromFile, {
scripts: Object.assign({}, defaults.scripts || {}, configFromFile.scripts || {}),
wireit: Object.assign({}, defaults.wireit || {}, configFromFile.wireit || {}),
scripts: Object.assign({}, defaults.scripts ?? {}, configFromFile.scripts ?? {}),
wireit: Object.assign({}, defaults.wireit ?? {}, configFromFile.wireit ?? {}),
devDepOverrides: configFromFile.devDepOverrides ?? [],
});

let excludeScripts = config['exclude-scripts'] || [];
Expand Down
58 changes: 29 additions & 29 deletions utils/write-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,43 +79,51 @@ module.exports = (projectPath) => {
};

const scripts = config.scripts;
const eslintConfigSfTsPjson = require('eslint-config-salesforce-typescript/package.json');

/** devDeps that *should* be in every repo dev-scripts touches. */
const requiredDeps = [
const requiredDeps = [];

/** These packages are provided to orgs via devScripts. They should not be in the pjson of the consumer
* If you don't like the devScripts version, you can specify your own in sf-dev-rc.json in the dependencies section.
*/
const providedByDevScripts = [
'@commitlint/cli',
'@commitlint/config-conventional',
'typedoc-plugin-missing-exports',
'source-map-support',
'typedoc',
'husky',
'pretty-quick',
'prettier',
'nyc',
'ts-node',
'mocha',
'sinon',
'chai',
'wireit',
'eslint-config-salesforce',
'eslint-config-salesforce-typescript',
'eslint-config-salesforce-license',
].concat(scripts.format ? ['prettier', '@salesforce/prettier-config'] : []);

/**
* if dev-scripts sees these in devDeps, they'll be removed
* some of these are in the devScripts Deps, but we don't want them in the target's devDeps (controlled by devScripts)
*/
const bannedDeps = [
'@commitlint/cli',
'@commitlint/config-conventional',
'source-map-support',
'typedoc',
'cz-conventional-changelog',
'lint-staged',
'tslint',
'@types/chai',
'@types/mocha',
'@types/node',
'@types/sinon',
'typedoc-plugin-missing-exports',
'eslint-plugin-prettier',
].concat(scripts.format ? [] : ['prettier', '@salesforce/prettier-config']);
'@salesforce/dev-config',
'@salesforce/prettier-config',
// this repo manages all things eslint. Its dependencies are in dev-scripts and therefore should be omitted
'eslint-config-salesforce-typescript',
...Object.keys(eslintConfigSfTsPjson.dependencies),
// leave these alone if the project has them
].filter((dep) => !new Set(config.devDepOverrides).has(dep));
/**
* We don't want these in any repo. This is a good way to clean up things en masse
*/
const bannedDeps = ['cz-conventional-changelog', 'lint-staged', 'tslint', 'eslint-plugin-prettier'].concat(
scripts.format ? [] : ['prettier', '@salesforce/prettier-config']
);

// removes go before adds because some are "added back"
providedByDevScripts.forEach((dep) => remove(dep));
bannedDeps.forEach((dep) => remove(dep));

// calling add will force it to exist
requiredDeps.forEach((dep) => add(dep));

Expand All @@ -127,14 +135,6 @@ module.exports = (projectPath) => {
}
});

const eslintPjson = require('eslint-config-salesforce-typescript/package.json');
const eslintHeaderPjson = require('eslint-config-salesforce-license/package.json');

// eslint and all plugins must be installed on a local basis, regardless of if it uses a shared config.
// https://eslint.org/docs/user-guide/getting-started
Object.entries(eslintPjson.devDependencies).forEach(([name, version]) => add(name, version));
Object.entries(eslintHeaderPjson.devDependencies).forEach(([name, version]) => add(name, version));

// update any non-devDeps to their minimum versions if devScripts specifies one
const dependencies = pjson.get('dependencies');
Object.entries(dependencies).forEach(([dep, depVersion]) => {
Expand Down
81 changes: 28 additions & 53 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,6 @@
esquery "^1.5.0"
jsdoc-type-pratt-parser "~4.0.0"

"@es-joy/jsdoccomment@~0.40.1":
version "0.40.1"
resolved "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz#13acd77fb372ed1c83b7355edd865a3b370c9ec4"
integrity sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==
dependencies:
comment-parser "1.4.0"
esquery "^1.5.0"
jsdoc-type-pratt-parser "~4.0.0"

"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
version "4.4.0"
resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
Expand Down Expand Up @@ -609,10 +600,12 @@
resolved "https://registry.npmjs.org/@types/node/-/node-20.2.3.tgz#b31eb300610c3835ac008d690de6f87e28f9b878"
integrity sha512-pg9d0yC4rVNWQzX8U7xb4olIOFuuVL9za3bzMT2pu2SU0SNEi66i2qrvhE2qt0HvkhuCaWJu7pLNOt/Pj8BIrw==

"@types/node@^15.6.1":
version "15.14.9"
resolved "https://registry.npmjs.org/@types/node/-/node-15.14.9.tgz#bc43c990c3c9be7281868bbc7b8fdd6e2b57adfa"
integrity sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==
"@types/node@^18":
version "18.18.7"
resolved "https://registry.npmjs.org/@types/node/-/node-18.18.7.tgz#bb3a7068dc4ba421b6968f2a259298b3a4e129e8"
integrity sha512-bw+lEsxis6eqJYW8Ql6+yTqkE6RuFtsQPSe5JxXbqYRFQEER5aJA9a5UH9igqDWm3X4iLHIKOHlnAXLM4mi7uQ==
dependencies:
undici-types "~5.26.4"

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
Expand All @@ -629,10 +622,10 @@
resolved "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz#0a41252ad431c473158b22f9bfb9a63df7541cff"
integrity sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==

"@types/[email protected].11":
version "10.0.11"
resolved "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz#8245827b05d3fc57a6601bd35aee1f7ad330fc42"
integrity sha512-dmZsHlBsKUtBpHriNjlK0ndlvEh8dcb9uV9Afsbt89QIyydpC7NcR+nWlAhASfy3GHnxTl4FX/aKE7XZUt/B4g==
"@types/sinon@^10.0.20":
version "10.0.20"
resolved "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.20.tgz#f1585debf4c0d99f9938f4111e5479fb74865146"
integrity sha512-2APKKruFNCAZgx3daAyACGzWuJ028VVCUDk6o2rw/Z4PXT0ogwdV4KUegW0MwVs0Zu59auPXbbuBJHF12Sx1Eg==
dependencies:
"@types/sinonjs__fake-timers" "*"

Expand Down Expand Up @@ -1188,11 +1181,6 @@ [email protected]:
resolved "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.1.tgz#3d7ea3adaf9345594aedee6563f422348f165c1b"
integrity sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==

[email protected]:
version "1.4.0"
resolved "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz#0f8c560f59698193854f12884c20c0e39a26d32c"
integrity sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==

commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
Expand Down Expand Up @@ -1520,7 +1508,7 @@ escape-string-regexp@^1.0.5:
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==

eslint-config-prettier@^8.10.0, eslint-config-prettier@^8.8.0:
eslint-config-prettier@^8.10.0:
version "8.10.0"
resolved "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz#3a06a662130807e2502fc3ff8b4143d8a0658e11"
integrity sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg==
Expand All @@ -1530,21 +1518,23 @@ eslint-config-salesforce-license@^0.2.0:
resolved "https://registry.npmjs.org/eslint-config-salesforce-license/-/eslint-config-salesforce-license-0.2.0.tgz#323193f1aa15dd33fbf108d25fc1210afc11065e"
integrity sha512-DJdBvgj82Erum82YMe+YvG/o6ukna3UA++lRl0HSTldj0VlBl3Q8hzCp97nRXZHra6JH1I912yievZzklXDw6w==

eslint-config-salesforce-typescript@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/eslint-config-salesforce-typescript/-/eslint-config-salesforce-typescript-2.0.0.tgz#df6cd54c7d5254158e0c175a8a3526d3f9510b56"
integrity sha512-1gq4ChEamP3VaDXoMJdEUX92fOdNMjX9/xOfByOO5AsQJnakRE/P4LWQrw5QqQQGWU8YnnM/OADFI9otD002aQ==
eslint-config-salesforce-typescript@^2.0.1-beta.0:
version "2.0.1-beta.0"
resolved "https://registry.npmjs.org/eslint-config-salesforce-typescript/-/eslint-config-salesforce-typescript-2.0.1-beta.0.tgz#c52763b6c045371d1884446e36b57a7140ecf98e"
integrity sha512-XnZa2FrH4TLbkdQ/NGaFBITZfobyIh7LZPdSMqeeDtTfp/HXuzk6P+zkcYeqxABIoat6ZYYdAAu7eANMp2JiIw==
dependencies:
"@typescript-eslint/eslint-plugin" "^5.62.0"
"@typescript-eslint/parser" "^5.62.0"
eslint "^8.52.0"
eslint-config-prettier "^8.10.0"
eslint-config-salesforce "^2.0.2"
eslint-config-salesforce-license "^0.2.0"
eslint-plugin-header "^3.1.1"
eslint-plugin-import "^2.28.1"
eslint-plugin-jsdoc "^43.0.5"
eslint-plugin-unicorn "^48.0.1"

eslint-config-salesforce@^2.0.1, eslint-config-salesforce@^2.0.2:
eslint-config-salesforce@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/eslint-config-salesforce/-/eslint-config-salesforce-2.0.2.tgz#38eb2d8eb2824c66967ed9b45bc92082eba2f225"
integrity sha512-3jbrI+QFu/KaQbPYIBxItB3okqUtA4EBCGiR6s2kcUMIZBLBBGAURW0k62f9WAv1EagR3eUoO0m9ru7LTj2F5Q==
Expand All @@ -1570,7 +1560,7 @@ eslint-plugin-header@^3.1.1:
resolved "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz#6ce512432d57675265fac47292b50d1eff11acd6"
integrity sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==

eslint-plugin-import@^2.27.5, eslint-plugin-import@^2.28.1:
eslint-plugin-import@^2.28.1:
version "2.29.0"
resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.0.tgz#8133232e4329ee344f2f612885ac3073b0b7e155"
integrity sha512-QPOO5NO6Odv5lpoTkddtutccQjysJuFxoPS7fAHO+9m9udNHvTCPSAMW9zGAYj8lAIdr40I8yPCdUYrncXtrwg==
Expand Down Expand Up @@ -1607,26 +1597,6 @@ eslint-plugin-jsdoc@^43.0.5:
semver "^7.5.0"
spdx-expression-parse "^3.0.1"

eslint-plugin-jsdoc@^46.8.2:
version "46.8.2"
resolved "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.8.2.tgz#3e6b1c93e91e38fe01874d45da121b56393c54a5"
integrity sha512-5TSnD018f3tUJNne4s4gDWQflbsgOycIKEUBoCLn6XtBMgNHxQFmV8vVxUtiPxAQq8lrX85OaSG/2gnctxw9uQ==
dependencies:
"@es-joy/jsdoccomment" "~0.40.1"
are-docs-informative "^0.0.2"
comment-parser "1.4.0"
debug "^4.3.4"
escape-string-regexp "^4.0.0"
esquery "^1.5.0"
is-builtin-module "^3.2.1"
semver "^7.5.4"
spdx-expression-parse "^3.0.1"

eslint-plugin-prefer-arrow@^1.2.1:
version "1.2.3"
resolved "https://registry.npmjs.org/eslint-plugin-prefer-arrow/-/eslint-plugin-prefer-arrow-1.2.3.tgz#e7fbb3fa4cd84ff1015b9c51ad86550e55041041"
integrity sha512-J9I5PKCOJretVuiZRGvPQxCbllxGAV/viI20JO3LYblAodofBxyMnZAJ+WGeClHgANnSJberTNoFWWjrWKBuXQ==

eslint-plugin-unicorn@^48.0.1:
version "48.0.1"
resolved "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-48.0.1.tgz#a6573bc1687ae8db7121fdd8f92394b6549a6959"
Expand Down Expand Up @@ -3204,10 +3174,10 @@ prelude-ls@^1.2.1:
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier@^2.7.1:
version "2.7.1"
resolved "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
prettier@^2.8.8:
version "2.8.8"
resolved "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

pretty-quick@^3.1.0:
version "3.1.3"
Expand Down Expand Up @@ -3928,6 +3898,11 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
Expand Down