Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 75b3584

Browse files
committed
Dev Tools Upgrades
- Changed pipeline build/tests to support Node 12 (LTS) and 13 (current) - Dropped Node 10 - Added Node 13 - Added ESLint pre-commit hook - `eslint --fix` now runs for JS/TS files before being committed. If any staged files fail linting, commit will fail. - Added `eslint-config-prettier` - Helps minimize conflicts between eslint and prettier configurations. - Upgrade to TypeScript 3.8. - No breaking changes. - View changes here: <https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/> - Upgrade to Jest 25 - No breaking changes. - View changes here: <https://jestjs.io/blog/2020/01/21/jest-25> - Upgrade to Prettier 2 - No Breaking changes. - Default of `trailingComma`, `arrowParens`, and `endOfLine` have been changed. Prettier has been run on the codebase to adjust for these changes. - View changes here: <https://prettier.io/blog/2020/03/21/2.0.0.html>
1 parent 7f38950 commit 75b3584

File tree

116 files changed

+2491
-2024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2491
-2024
lines changed

.eslintrc.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
module.exports = {
22
root: true,
3+
env: {
4+
node: true,
5+
},
36
parser: "@typescript-eslint/parser",
47
plugins: ["@typescript-eslint"],
58
extends: [
69
"eslint:recommended",
710
"plugin:@typescript-eslint/eslint-recommended",
8-
"plugin:@typescript-eslint/recommended"
9-
]
11+
"plugin:@typescript-eslint/recommended",
12+
"prettier",
13+
"prettier/@typescript-eslint",
14+
],
1015
};

azure-pipelines.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ pr:
66

77
strategy:
88
matrix:
9-
node_10_x:
10-
node_version: 10.x
119
node_12_x:
1210
node_version: 12.x
11+
node_13_x:
12+
node_version: 13.x
1313
maxParallel: 2
1414

1515
pool:
@@ -55,7 +55,7 @@ steps:
5555
- task: PublishTestResults@2
5656
inputs:
5757
testResultsFormat: 'JUnit'
58-
testResultsFiles: '**/junit.xml'
58+
testResultsFiles: '**/junit.xml'
5959
condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x'))
6060

6161
- task: PublishPipelineArtifact@1
@@ -67,7 +67,7 @@ steps:
6767
- bash: |
6868
[ -z "$COVERAGE_VARIANCE" ] && { echo "Missing COVERAGE_VARIANCE variable"; exit 1; }
6969
echo "Code coverage variance value is: $COVERAGE_VARIANCE"
70-
displayName: 'Build quality pre-validation'
70+
displayName: 'Build quality pre-validation'
7171
failOnStderr: true
7272
env:
7373
COVERAGE_VARIANCE: $(COVERAGE_VARIANCE)

package.json

+17-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build": "shx rm -rf dist && webpack && pkg -t node12-linux-x64,node12-macos-x64,node12-win-x64 dist/spk.js && shx mv spk-{linux,macos,win.exe} dist",
1010
"build-cmd-docs": "ts-node tools/generateDoc.ts",
1111
"lint": "eslint 'src/**/*.ts{,x}'",
12-
"lint-fix": "tslint --fix 'src/**/*.ts{,x}'",
12+
"lint-fix": "eslint --fix 'src/**/*.ts{,x}'",
13+
"format": "prettier --write 'src/**/*.ts{,x}'",
1314
"test": "jest --rootDir src --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --coverageReporters=html",
1415
"test-watch": "jest --watchAll",
1516
"postinstall": "cd node_modules/azure-devops-node-api && git apply ../../patches/001-azure-devops-node.patch || true",
@@ -29,24 +30,25 @@
2930
"@types/node-emoji": "^1.8.1",
3031
"@types/shelljs": "^0.8.5",
3132
"@types/uuid": "^3.4.5",
32-
"@typescript-eslint/eslint-plugin": "^2.23.0",
33-
"@typescript-eslint/parser": "^2.23.0",
33+
"@typescript-eslint/eslint-plugin": "^2.24.0",
34+
"@typescript-eslint/parser": "^2.24.0",
3435
"eslint": "^6.8.0",
36+
"eslint-config-prettier": "^6.10.1",
3537
"husky": ">=1",
36-
"jest": "^24.9.0",
37-
"jest-junit": "^9.0.0",
38+
"jest": "^25.1.0",
39+
"jest-junit": "^10.0.0",
3840
"jest-when": "^2.7.0",
39-
"lint-staged": ">=8",
41+
"lint-staged": ">=10",
4042
"mock-fs": "^4.10.2",
4143
"nyc": "^14.1.1",
4244
"pkg": "^4.4.0",
43-
"prettier": "^1.19.1",
45+
"prettier": "^2.0.1",
4446
"shx": "^0.3.2",
45-
"ts-jest": "^24.2.0",
46-
"ts-loader": "^6.2.1",
47-
"ts-node": "^8.5.4",
47+
"ts-jest": "^25.2.1",
48+
"ts-loader": "^6.2.2",
49+
"ts-node": "^8.8.1",
4850
"tslint-config-prettier": "^1.18.0",
49-
"typescript": "^3.7.4",
51+
"typescript": "^3.8.3",
5052
"url-loader": "^3.0.0",
5153
"webpack": "^4.41.2",
5254
"webpack-cli": "^3.3.9"
@@ -60,10 +62,10 @@
6062
}
6163
},
6264
"lint-staged": {
63-
"*.{ts,tsx,js,jsx,css,json,md}": [
64-
"prettier --write",
65-
"git add"
66-
]
65+
"*.{js,jsx,ts,tsx}": [
66+
"eslint --cache --fix"
67+
],
68+
"*.{js,jsx,ts,tsx,json,css,md}": "prettier --write"
6769
},
6870
"dependencies": {
6971
"@azure/arm-containerregistry": "^7.0.0",

src/commands/command.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ export const Command = (
8484
}
8585

8686
// Catch-all for unknown commands
87-
cmd.on("command:*", calledCmd => {
87+
cmd.on("command:*", (calledCmd) => {
8888
logger.error(`Unknown command "${calledCmd}"`);
8989
cmd.outputHelp();
9090
});
91-
cmd.on("option:*", unknownOption => {
91+
cmd.on("option:*", (unknownOption) => {
9292
logger.error(`Unknown option "${unknownOption}"`);
9393
});
9494

9595
return linkSubCommands({
9696
command: cmd,
9797
description,
9898
name: name.toLowerCase(),
99-
subCommands
99+
subCommands,
100100
});
101101
};
102102

@@ -125,7 +125,7 @@ const decrementArgv = (argv: string[]): string[] => {
125125
export const executeCommand = (cmd: Command, argv: string[]): void => {
126126
const targetCommandName = argv.slice(2, 3)[0];
127127
const targetCommand = cmd.subCommands.find(
128-
sc => sc.name === targetCommandName
128+
(sc) => sc.name === targetCommandName
129129
);
130130

131131
// If the the next argument matches against a sub-command, recur into it.

src/commands/deployment/create.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const MOCKED_VALS: CommandOptions = {
2727
pr: undefined,
2828
repository: undefined,
2929
service: undefined,
30-
tableName: undefined
30+
tableName: undefined,
3131
};
3232

3333
const getMockedValues = (withKeyValue = false): CommandOptions => {
@@ -72,7 +72,7 @@ describe("test execute function", () => {
7272
commitId: uuid(),
7373
imageTag: uuid(),
7474
p1: uuid(),
75-
service: uuid()
75+
service: uuid(),
7676
})
7777
);
7878
const exitFn = jest.fn();
@@ -122,7 +122,7 @@ describe("test execute function", () => {
122122
imageTag: uuid(),
123123
p1: uuid(),
124124
p2: uuid(),
125-
service: uuid()
125+
service: uuid(),
126126
})
127127
);
128128
const exitFn = jest.fn();
@@ -165,7 +165,7 @@ describe("test execute function", () => {
165165
p1: uuid(),
166166
p2: uuid(),
167167
p3: uuid(),
168-
service: uuid()
168+
service: uuid(),
169169
})
170170
);
171171
const exitFn = jest.fn();
@@ -205,7 +205,7 @@ describe("test execute function", () => {
205205
p1: uuid(),
206206
p2: uuid(),
207207
p3: uuid(),
208-
service: uuid()
208+
service: uuid(),
209209
})
210210
);
211211
const exitFn = jest.fn();

src/commands/deployment/create.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
DeploymentTable,
55
updateACRToHLDPipeline,
66
updateHLDToManifestPipeline,
7-
updateManifestCommitId
7+
updateManifestCommitId,
88
} from "../../lib/azure/deploymenttable";
99
import { build as buildCmd, exit as exitCmd } from "../../lib/commandBuilder";
1010
import { hasValue } from "../../lib/validator";
@@ -121,7 +121,7 @@ export const execute = async (
121121
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
122122
partitionKey: opts.partitionKey!,
123123
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
124-
tableName: opts.tableName!
124+
tableName: opts.tableName!,
125125
};
126126

127127
if (hasValue(opts.p1)) {

src/commands/deployment/dashboard.test.ts

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/camelcase */
2+
13
jest.mock("open");
24
import open from "open";
35
jest.mock("../../config");
@@ -7,14 +9,14 @@ import { validatePrereqs } from "../../lib/validator";
79
import {
810
disableVerboseLogging,
911
enableVerboseLogging,
10-
logger
12+
logger,
1113
} from "../../logger";
1214
import {
1315
execute,
1416
extractManifestRepositoryInformation,
1517
getEnvVars,
1618
launchDashboard,
17-
validateValues
19+
validateValues,
1820
} from "./dashboard";
1921
import * as dashboard from "./dashboard";
2022

@@ -30,20 +32,20 @@ afterAll(() => {
3032

3133
const mockConfig = (): void => {
3234
(Config as jest.Mock).mockReturnValueOnce({
33-
"azure_devops": {
34-
"access_token": uuid(),
35+
azure_devops: {
36+
access_token: uuid(),
3537
org: uuid(),
36-
project: uuid()
38+
project: uuid(),
3739
},
3840
introspection: {
3941
azure: {
40-
"account_name": uuid(),
42+
account_name: uuid(),
4143
key: uuid(),
42-
"partition_key": uuid(),
43-
"source_repo_access_token": "test_token",
44-
"table_name": uuid()
45-
}
46-
}
44+
partition_key: uuid(),
45+
source_repo_access_token: "test_token",
46+
table_name: uuid(),
47+
},
48+
},
4749
});
4850
};
4951

@@ -53,7 +55,7 @@ describe("Test validateValues function", () => {
5355
try {
5456
validateValues(config, {
5557
port: "abc",
56-
removeAll: false
58+
removeAll: false,
5759
});
5860
expect(true).toBe(false);
5961
} catch (e) {
@@ -68,7 +70,7 @@ describe("Test validateValues function", () => {
6870
{},
6971
{
7072
port: "4000",
71-
removeAll: false
73+
removeAll: false,
7274
}
7375
);
7476
expect(true).toBe(false);
@@ -83,7 +85,7 @@ describe("Test validateValues function", () => {
8385
const config = Config();
8486
validateValues(config, {
8587
port: "4000",
86-
removeAll: false
88+
removeAll: false,
8789
});
8890
});
8991
});
@@ -100,7 +102,7 @@ describe("Test execute function", () => {
100102
await execute(
101103
{
102104
port: "4000",
103-
removeAll: false
105+
removeAll: false,
104106
},
105107
exitFn
106108
);
@@ -112,7 +114,7 @@ describe("Test execute function", () => {
112114
await execute(
113115
{
114116
port: "4000",
115-
removeAll: false
117+
removeAll: false,
116118
},
117119
exitFn
118120
);
@@ -133,7 +135,7 @@ describe("Validate dashboard container pull", () => {
133135
"images",
134136
"-q",
135137
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
136-
config.introspection!.dashboard!.image!
138+
config.introspection!.dashboard!.image!,
137139
]);
138140
expect(dockerId).toBeDefined();
139141
expect(dashboardContainerId).not.toBe("");
@@ -160,7 +162,7 @@ describe("Validate dashboard clean up", () => {
160162
"images",
161163
"-q",
162164
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
163-
config.introspection!.dashboard!.image!
165+
config.introspection!.dashboard!.image!,
164166
]);
165167

166168
expect(dockerId).toBeDefined();
@@ -208,10 +210,10 @@ describe("Fallback to azure devops access token", () => {
208210
describe("Extract manifest repository information", () => {
209211
test("Manifest repository information is successfully extracted", () => {
210212
(Config as jest.Mock).mockReturnValue({
211-
"azure_devops": {
212-
"manifest_repository":
213-
"https://dev.azure.com/bhnook/fabrikam/_git/materialized"
214-
}
213+
azure_devops: {
214+
manifest_repository:
215+
"https://dev.azure.com/bhnook/fabrikam/_git/materialized",
216+
},
215217
});
216218
const config = Config();
217219
let manifestInfo = extractManifestRepositoryInformation(config);

src/commands/deployment/dashboard.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const cleanDashboardContainers = async (
6969
"-q",
7070
"--filter",
7171
"ancestor=" + config.introspection!.dashboard!.image!,
72-
'--format="{{.ID}}"'
72+
'--format="{{.ID}}"',
7373
]);
7474
if (dockerOutput.length > 0) {
7575
dockerOutput = dockerOutput.replace(/\n/g, " ");
@@ -99,11 +99,11 @@ export const extractManifestRepositoryInformation = (
9999
if (gitComponents.resource === "github.com") {
100100
return {
101101
githubUsername: gitComponents.organization,
102-
manifestRepoName
102+
manifestRepoName,
103103
};
104104
} else {
105105
return {
106-
manifestRepoName
106+
manifestRepoName,
107107
};
108108
}
109109
}
@@ -218,7 +218,7 @@ export const launchDashboard = async (
218218
...(await getEnvVars(config)),
219219
"-p",
220220
port + ":5000",
221-
dockerRepository
221+
dockerRepository,
222222
]);
223223
return containerId;
224224
} catch (err) {

0 commit comments

Comments
 (0)