declapract-typescript-ehmpathy 0.23.0 → 0.23.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/dist/practices/cicd-package/best-practice/package.json +6 -0
- package/dist/practices/cicd-package/best-practice/package.json.declapract.ts +4 -0
- package/dist/practices/config/bad-practices/divergent-config-shapes/config/dev.json.declapract.ts +1 -4
- package/dist/practices/config/bad-practices/divergent-config-shapes/config/prod.json.declapract.ts +1 -4
- package/dist/practices/format/best-practice/package.json.declapract.ts +31 -2
- package/dist/practices/testing/best-practice/jest.unit.env.ts.declapract.ts +33 -0
- package/dist/utils/readFile.ts +5 -0
- package/package.json +2 -2
- package/dist/practices/format/best-practice/package.json +0 -6
package/dist/practices/config/bad-practices/divergent-config-shapes/config/dev.json.declapract.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { FileCheckFunction } from 'declapract';
|
|
2
2
|
import flatten from 'flat';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import util from 'util';
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
util.promisify(fs.readFile)(filePath, 'utf-8');
|
|
4
|
+
import { readFile } from '../../../../../utils/readFile';
|
|
8
5
|
|
|
9
6
|
export const check: FileCheckFunction = async (contents, context) => {
|
|
10
7
|
if (!contents) throw new Error('its fine'); // ... yeah, i know, todo: eliminate this weird "throw an error if its fine" pattern
|
package/dist/practices/config/bad-practices/divergent-config-shapes/config/prod.json.declapract.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { FileCheckFunction } from 'declapract';
|
|
2
2
|
import flatten from 'flat';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import util from 'util';
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
util.promisify(fs.readFile)(filePath, 'utf-8');
|
|
4
|
+
import { readFile } from '../../../../../utils/readFile';
|
|
8
5
|
|
|
9
6
|
export const check: FileCheckFunction = async (contents, context) => {
|
|
10
7
|
if (!contents) throw new Error('its fine'); // ... yeah, i know, todo: eliminate this weird "throw an error if its fine" pattern
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
import { FileCheckType } from 'declapract';
|
|
1
|
+
import { FileCheckType, FileContentsFunction } from 'declapract/dist/domain';
|
|
2
|
+
import { isPresent } from 'type-fns';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* declare the expected contents
|
|
6
|
+
*/
|
|
7
|
+
export const contents: FileContentsFunction = (context) => {
|
|
8
|
+
const formatters = [
|
|
9
|
+
'prettier',
|
|
10
|
+
context.projectPractices.includes('terraform') ? 'terraform' : null, // only include the terraform formatter if terraform practice is used
|
|
11
|
+
].filter(isPresent);
|
|
12
|
+
|
|
13
|
+
return JSON.stringify(
|
|
14
|
+
{
|
|
15
|
+
scripts: {
|
|
16
|
+
'fix:format': formatters
|
|
17
|
+
.map((formatter) => `npm run fix:format:${formatter}`)
|
|
18
|
+
.join(' && '),
|
|
19
|
+
'test:format': formatters
|
|
20
|
+
.map((formatter) => `npm run test:format:${formatter}`)
|
|
21
|
+
.join(' && '),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
null,
|
|
25
|
+
2,
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* check that they're contained in the file
|
|
31
|
+
*/
|
|
32
|
+
export const check: FileCheckType = FileCheckType.CONTAINS;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import { FileCheckType } from 'declapract';
|
|
3
|
+
import { FileContentsFunction } from 'declapract/dist/domain';
|
|
4
|
+
|
|
5
|
+
import { readFile } from '../../../utils/readFile';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* declare the expected contents
|
|
9
|
+
*/
|
|
10
|
+
export const contents: FileContentsFunction = async (context) => {
|
|
11
|
+
// grab the superset of best practices content
|
|
12
|
+
const contentsSuperset = await readFile(`${__dirname}/jest.unit.env.ts`);
|
|
13
|
+
|
|
14
|
+
// remove things that are irrelevant, based on other practices in use in project
|
|
15
|
+
let contents = contentsSuperset;
|
|
16
|
+
if (!context.projectPractices.includes('config'))
|
|
17
|
+
contents = contents.replace(
|
|
18
|
+
`
|
|
19
|
+
jest.mock('./src/utils/config/getConfig', () => ({
|
|
20
|
+
getConfig: jest.fn().mockImplementation(() => require('./config/test.json')), // mock that getConfig just returns plaintext test env config in unit tests
|
|
21
|
+
}));
|
|
22
|
+
`,
|
|
23
|
+
'',
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// return the narrowed contents
|
|
27
|
+
return contents;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* check that they're contained in the file
|
|
32
|
+
*/
|
|
33
|
+
export const check: FileCheckType = FileCheckType.CONTAINS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "declapract-typescript-ehmpathy",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "declapract best practices declarations for typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"uuid": "3.4.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"declapract": "~0.
|
|
43
|
+
"declapract": "~0.11.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@commitlint/cli": "13.1.0",
|