@bigbinary/neeto-audit-frontend 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -1
- package/common/.husky/widget/pre-push +7 -0
- package/common/eslint/widget/.eslintrc.js +9 -0
- package/common/prettier/widget/.prettierrc.js +16 -0
- package/dist/index.js +17 -4
- package/package.json +1 -1
- package/src/constants/index.js +1 -0
- package/src/verifiers/currentNodeVersion/index.js +5 -1
- package/src/verifiers/eslint/constants.js +1 -1
- package/src/verifiers/prettier/constants.js +2 -0
- package/src/verifiers/prettier/index.js +4 -2
- package/src/verifiers/recommendedPackageVersions/index.js +5 -1
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
1
|
# neeto-audit-frontend
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A package that audits neeto frontend packages for neeto-specific configuration and guidelines and suggests a fix.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
`neeto-audit-frontend` has 5 checks to ensure neeto guidelines are being followed:
|
|
8
|
+
|
|
9
|
+
- Checks whether the package uses the common ESlint configuration from `neeto-commons-frontend`.
|
|
10
|
+
- Checks whether the package uses the common prettier and tailwind configurations.
|
|
11
|
+
- Checks whether the package uses the same set of husky pre-commit and pre-push hooks.
|
|
12
|
+
- Checks whether the package uses the specified node version in `.node-version` and `.nvmrc` files.
|
|
13
|
+
- Checks whether the package uses the recommended versions of common npm packages including other neeto packages.
|
|
14
|
+
|
|
15
|
+
There are different types of frontend packages in neeto: nanos, widgets, extensions and frontend packages.`neeto-audit-frontend` maintains a local copy of the common configuration and a different local copy if any type of package follows a different configuration. For example, ESlint configuration is different for nanos, widgets and extensions. A local copy is maintained for each of these. The files in a package are tested against these versions to see if they match. If any check fails, it will provide the command that the user can run to fix that specific check before committing.
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add -D "@bigbinary/neeto-audit-frontend@latest"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Run the audit
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn neeto-audit-frontend
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Add CI check
|
|
30
|
+
|
|
31
|
+
Add the following lines to the neetoCI YAML file.
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
setup:
|
|
35
|
+
- yarn install
|
|
36
|
+
jobs:
|
|
37
|
+
- name: CiChecks
|
|
38
|
+
commands:
|
|
39
|
+
- yarn neeto-audit-frontend
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Making changes to the configuration
|
|
43
|
+
|
|
44
|
+
If any changes are made to the configuration files being checked by `neeto-audit-frontend`, the audit check will fail. If this change is necessary, we should make the same changes in the local copy maintained in `neeto-audit-frontend` to ensure the checks will pass.
|
|
45
|
+
|
|
46
|
+
## Development instructions
|
|
47
|
+
|
|
48
|
+
`neeto-audit-frontend` uses `pnpm` as the package manager. To setup the development environment run `pnpm install` after cloning the repository. After making changes to the verifiers, we can test the changes locally by using `yalc`. Follow the steps mentioned in [Testing frontend packages](https://neeto-engineering.neetokb.com/articles/testing-packages-locally-using-yalc) to test the changes.
|
|
49
|
+
|
|
50
|
+
If, for any reason, `yarn neeto-audit-frontend` command fails after pushing the changes using `yalc`, run `yarn install --check-files`.
|
|
51
|
+
|
|
52
|
+
## Building and Releasing
|
|
53
|
+
|
|
54
|
+
The `@bigbinary/neeto-audit-frontend` gets published to NPM when we merge a PR with `patch`, `minor` or `major` label to the main branch. The `patch` label is used for bug fixes, `minor` label is used for new features and `major` label is used for breaking changes. You can checkout the `Create and publish releases` workflow in GitHub Actions to get a live update. Please note that before publishing the package, you need to verify the functionality in some of the neeto web-apps locally using `yalc` package manager.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const defaultConfigurations = require("@bigbinary/neeto-commons-frontend/configs/nanos/eslint/index.js");
|
|
2
|
+
const { mergeDeepLeft } = require("ramda");
|
|
3
|
+
|
|
4
|
+
module.exports = mergeDeepLeft(
|
|
5
|
+
{
|
|
6
|
+
rules: { "@bigbinary/neeto/file-name-and-export-name-standards": "off" },
|
|
7
|
+
},
|
|
8
|
+
defaultConfigurations
|
|
9
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
tailwindConfig: "./tailwind.config.js",
|
|
3
|
+
trailingComma: "es5",
|
|
4
|
+
arrowParens: "avoid",
|
|
5
|
+
printWidth: 80,
|
|
6
|
+
tabWidth: 2,
|
|
7
|
+
useTabs: false,
|
|
8
|
+
semi: true,
|
|
9
|
+
quoteProps: "as-needed",
|
|
10
|
+
jsxSingleQuote: false,
|
|
11
|
+
singleQuote: false,
|
|
12
|
+
bracketSpacing: true,
|
|
13
|
+
bracketSameLine: false,
|
|
14
|
+
proseWrap: "always",
|
|
15
|
+
endOfLine: "lf",
|
|
16
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -18243,6 +18243,7 @@ const NANO_TYPE_MAP = {
|
|
|
18243
18243
|
nano: "nano",
|
|
18244
18244
|
frontend: "frontend",
|
|
18245
18245
|
extension: "extension",
|
|
18246
|
+
widget: "widget",
|
|
18246
18247
|
editor: "frontend",
|
|
18247
18248
|
molecules: "frontend",
|
|
18248
18249
|
};
|
|
@@ -18531,7 +18532,11 @@ const currentNodeVersion = async (debug) => {
|
|
|
18531
18532
|
});
|
|
18532
18533
|
|
|
18533
18534
|
if (!nodeVersionFileContent) {
|
|
18534
|
-
return {
|
|
18535
|
+
return {
|
|
18536
|
+
error: "No file or content found in the .nvmrc file.",
|
|
18537
|
+
status: STATUSES.FAIL,
|
|
18538
|
+
fix,
|
|
18539
|
+
};
|
|
18535
18540
|
}
|
|
18536
18541
|
|
|
18537
18542
|
const [major = 0, minor = 0, patch = 0] = getSemVer(nodeVersionFileContent);
|
|
@@ -18554,7 +18559,7 @@ const currentNodeVersion = async (debug) => {
|
|
|
18554
18559
|
|
|
18555
18560
|
const ESLINT_DESTINATION_DIRECTORY = path$1.resolve("./");
|
|
18556
18561
|
|
|
18557
|
-
const NANOS_TO_OVERRIDE = ["nano", "extension"];
|
|
18562
|
+
const NANOS_TO_OVERRIDE$1 = ["nano", "extension", "widget"];
|
|
18558
18563
|
|
|
18559
18564
|
const eslint = async (debug) => {
|
|
18560
18565
|
const { type, repoName } = await getNanoType();
|
|
@@ -18565,7 +18570,7 @@ const eslint = async (debug) => {
|
|
|
18565
18570
|
return { isSuccess: true, status: STATUSES.SKIPPED };
|
|
18566
18571
|
}
|
|
18567
18572
|
|
|
18568
|
-
const eslintCommonSource = NANOS_TO_OVERRIDE.includes(type) ? type : "common";
|
|
18573
|
+
const eslintCommonSource = NANOS_TO_OVERRIDE$1.includes(type) ? type : "common";
|
|
18569
18574
|
|
|
18570
18575
|
const eslintSourceDirectory = path$1.resolve(
|
|
18571
18576
|
`./node_modules/@bigbinary/neeto-audit-frontend/common/eslint/${eslintCommonSource}`
|
|
@@ -18671,6 +18676,8 @@ const husky = async (debug) => {
|
|
|
18671
18676
|
|
|
18672
18677
|
const PRETTIER_DESTINATION_PATH = path$1.resolve("./");
|
|
18673
18678
|
|
|
18679
|
+
const NANOS_TO_OVERRIDE = ["extension", "widget"];
|
|
18680
|
+
|
|
18674
18681
|
const prettier = async (debug) => {
|
|
18675
18682
|
const { type, repoName } = await getNanoType();
|
|
18676
18683
|
|
|
@@ -18680,7 +18687,9 @@ const prettier = async (debug) => {
|
|
|
18680
18687
|
return { isSuccess: true, status: STATUSES.SKIPPED };
|
|
18681
18688
|
}
|
|
18682
18689
|
|
|
18683
|
-
const prettierCommonSource = type
|
|
18690
|
+
const prettierCommonSource = NANOS_TO_OVERRIDE.includes(type)
|
|
18691
|
+
? type
|
|
18692
|
+
: "common";
|
|
18684
18693
|
|
|
18685
18694
|
const prettierSourceDirectory = path$1.resolve(
|
|
18686
18695
|
`./node_modules/@bigbinary/neeto-audit-frontend/common/prettier/${prettierCommonSource}`
|
|
@@ -19009,6 +19018,10 @@ const recommendedPackageVersions = async (debug) => {
|
|
|
19009
19018
|
|
|
19010
19019
|
const { type } = await getNanoType();
|
|
19011
19020
|
|
|
19021
|
+
if (type === NANO_TYPE_MAP.widget) {
|
|
19022
|
+
return { isSuccess: true, status: STATUSES.SKIPPED };
|
|
19023
|
+
}
|
|
19024
|
+
|
|
19012
19025
|
const recommendedVersions = mergeDeepRight$1(
|
|
19013
19026
|
recommendedDependencies["common"],
|
|
19014
19027
|
recommendedDependencies[type]
|
package/package.json
CHANGED
package/src/constants/index.js
CHANGED
|
@@ -18,7 +18,11 @@ const currentNodeVersion = async (debug) => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
if (!nodeVersionFileContent) {
|
|
21
|
-
return {
|
|
21
|
+
return {
|
|
22
|
+
error: "No file or content found in the .nvmrc file.",
|
|
23
|
+
status: STATUSES.FAIL,
|
|
24
|
+
fix,
|
|
25
|
+
};
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
const [major = 0, minor = 0, patch = 0] = getSemVer(nodeVersionFileContent);
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getNanoType,
|
|
7
7
|
identicalDirectoryFiles,
|
|
8
8
|
} from "../../utils";
|
|
9
|
-
import { PRETTIER_DESTINATION_PATH } from "./constants";
|
|
9
|
+
import { PRETTIER_DESTINATION_PATH, NANOS_TO_OVERRIDE } from "./constants";
|
|
10
10
|
import { STATUSES } from "../../constants";
|
|
11
11
|
|
|
12
12
|
const prettier = async (debug) => {
|
|
@@ -18,7 +18,9 @@ const prettier = async (debug) => {
|
|
|
18
18
|
return { isSuccess: true, status: STATUSES.SKIPPED };
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const prettierCommonSource = type
|
|
21
|
+
const prettierCommonSource = NANOS_TO_OVERRIDE.includes(type)
|
|
22
|
+
? type
|
|
23
|
+
: "common";
|
|
22
24
|
|
|
23
25
|
const prettierSourceDirectory = path.resolve(
|
|
24
26
|
`./node_modules/@bigbinary/neeto-audit-frontend/common/prettier/${prettierCommonSource}`
|
|
@@ -2,7 +2,7 @@ import { existsBy, isNotEmpty } from "@bigbinary/neeto-commons-frontend/pure";
|
|
|
2
2
|
import { mergeDeepRight, objOf } from "ramda";
|
|
3
3
|
|
|
4
4
|
import recommendedDependencies from "../../../common/recommendedDependencies";
|
|
5
|
-
import { PACKAGE_JSON_PATH, STATUSES } from "../../constants";
|
|
5
|
+
import { NANO_TYPE_MAP, PACKAGE_JSON_PATH, STATUSES } from "../../constants";
|
|
6
6
|
import {
|
|
7
7
|
createOrReplaceFile,
|
|
8
8
|
execute,
|
|
@@ -20,6 +20,10 @@ const recommendedPackageVersions = async (debug) => {
|
|
|
20
20
|
|
|
21
21
|
const { type } = await getNanoType();
|
|
22
22
|
|
|
23
|
+
if (type === NANO_TYPE_MAP.widget) {
|
|
24
|
+
return { isSuccess: true, status: STATUSES.SKIPPED };
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
const recommendedVersions = mergeDeepRight(
|
|
24
28
|
recommendedDependencies["common"],
|
|
25
29
|
recommendedDependencies[type]
|