Skip to content

Commit 3e88ffc

Browse files
feat(utils): add upload logic (#66)
This PR includes: - [x] add `organisation` and `project` to `UploadConfig` - [x] add upload logic and tests closes #21 closes #57 closes #85 --------- Co-authored-by: Matěj Chalk <[email protected]> Co-authored-by: Matěj Chalk <[email protected]>
1 parent 6440590 commit 3e88ffc

File tree

111 files changed

+1203
-658
lines changed

Some content is hidden

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

111 files changed

+1203
-658
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

3+
.env
4+
35
# compiled output
46
dist
57
tmp
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// TODO: import plugins using NPM package names using local registry: https://github.com/flowup/quality-metrics-cli/issues/33
2-
import eslintPlugin from '../../../dist/packages/plugin-eslint';
2+
// import eslintPlugin from '../../../dist/packages/plugin-eslint';
33
import lighthousePlugin from '../../../dist/packages/plugin-lighthouse';
44

55
export default {
66
persist: { outputPath: 'tmp/cli-config-out.json' },
77
categories: [],
88
plugins: [
9-
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
9+
// TODO: uncomment once runner is implemented
10+
// await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
1011
lighthousePlugin({ config: '.lighthouserc.json' }),
1112
],
1213
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// TODO: import plugins using NPM package names using local registry: https://github.com/flowup/quality-metrics-cli/issues/33
2+
// import eslintPlugin from '../../../dist/packages/plugin-eslint';
3+
import lighthousePlugin from '../../../dist/packages/plugin-lighthouse';
4+
5+
export default {
6+
persist: { outputPath: 'tmp/cli-config-out.json' },
7+
categories: [],
8+
plugins: [
9+
// TODO: uncomment once runner is implemented
10+
// await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
11+
lighthousePlugin({ config: '.lighthouserc.json' }),
12+
],
13+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// TODO: import plugins using NPM package names using local registry: https://github.com/flowup/quality-metrics-cli/issues/33
2+
// import eslintPlugin from '../../../dist/packages/plugin-eslint';
3+
import lighthousePlugin from '../../../dist/packages/plugin-lighthouse';
4+
5+
export default {
6+
persist: { outputPath: 'tmp/cli-config-out.json' },
7+
categories: [],
8+
plugins: [
9+
// TODO: uncomment once runner is implemented
10+
// await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
11+
lighthousePlugin({ config: '.lighthouserc.json' }),
12+
],
13+
};

examples/cli-e2e/mocks/config.mock.mjs

-12
This file was deleted.

examples/cli-e2e/mocks/config.mock.ts

-12
This file was deleted.

examples/cli-e2e/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
}
1414
}
1515
},
16+
"implicitDependencies": ["cli", "plugin-eslint", "plugin-lighthouse"],
1617
"tags": ["scope:core", "scope:plugin", "type:e2e"]
1718
}

examples/cli-e2e/tests/cli.spec.ts

+19-29
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
1-
import { cli } from '@quality-metrics/cli';
2-
import eslintPlugin from '@quality-metrics/eslint-plugin';
3-
import lighthousePlugin from '@quality-metrics/lighthouse-plugin';
1+
import {
2+
CliArgsObject,
3+
executeProcess,
4+
objectToCliArgs,
5+
} from '@code-pushup/utils';
46
import { join } from 'path';
5-
import { describe, expect, it } from 'vitest';
67

78
const configFile = (ext: 'ts' | 'js' | 'mjs') =>
8-
join(process.cwd(), `examples/cli-e2e/mocks/config.mock.${ext}`);
9+
join(process.cwd(), `examples/cli-e2e/mocks/code-pushup.config.${ext}`);
10+
11+
const execCli = (argObj: Partial<CliArgsObject>) =>
12+
executeProcess({
13+
command: 'node',
14+
args: objectToCliArgs({
15+
_: './dist/packages/cli/index.js',
16+
verbose: true,
17+
...argObj,
18+
}),
19+
});
920

1021
describe('cli', () => {
1122
it('should load .js config file', async () => {
12-
const argv = await cli(['--configPath', configFile('js'), '--verbose'])
13-
.argv;
14-
expect(argv.plugins[0]).toEqual(
15-
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
16-
);
17-
expect(argv.plugins[1]).toEqual(
18-
lighthousePlugin({ config: '.lighthouserc.json' }),
19-
);
23+
await execCli({ configPath: configFile('js') });
2024
});
2125

2226
it('should load .mjs config file', async () => {
23-
const argv = await cli(['--configPath', configFile('mjs'), '--verbose'])
24-
.argv;
25-
expect(argv.plugins[0]).toEqual(
26-
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
27-
);
28-
expect(argv.plugins[1]).toEqual(
29-
lighthousePlugin({ config: '.lighthouserc.json' }),
30-
);
27+
await execCli({ configPath: configFile('mjs') });
3128
});
3229

3330
it('should load .ts config file', async () => {
34-
const argv = await cli(['--configPath', configFile('ts'), '--verbose'])
35-
.argv;
36-
expect(argv.plugins[0]).toEqual(
37-
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
38-
);
39-
expect(argv.plugins[1]).toEqual(
40-
lighthousePlugin({ config: '.lighthouserc.json' }),
41-
);
31+
await execCli({ configPath: configFile('ts') });
4232
});
4333
});

examples/cli-e2e/tsconfig.spec.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
},
77
"include": [
88
"vite.config.ts",
9-
"src/**/*.test.ts",
10-
"src/**/*.spec.ts",
11-
"src/**/*.test.tsx",
12-
"src/**/*.spec.tsx",
13-
"src/**/*.test.js",
14-
"src/**/*.spec.js",
15-
"src/**/*.test.jsx",
16-
"src/**/*.spec.jsx",
17-
"src/**/*.d.ts"
9+
"tests/**/*.test.ts",
10+
"tests/**/*.spec.ts",
11+
"tests/**/*.test.tsx",
12+
"tests/**/*.spec.tsx",
13+
"tests/**/*.test.js",
14+
"tests/**/*.spec.js",
15+
"tests/**/*.test.jsx",
16+
"tests/**/*.spec.jsx",
17+
"tests/**/*.d.ts"
1818
]
1919
}

0 commit comments

Comments
 (0)