@canyonjs/cli 1.0.1 → 1.0.3
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 +0 -9
- package/dist/index.js +18 -13
- package/package.json +2 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,20 +3,26 @@ import { program } from "commander";
|
|
|
3
3
|
import node_fs from "node:fs";
|
|
4
4
|
import node_path from "node:path";
|
|
5
5
|
import axios from "axios";
|
|
6
|
-
import { log } from "node:console";
|
|
7
6
|
var package_namespaceObject = {
|
|
8
|
-
rE: "1.0.
|
|
7
|
+
rE: "1.0.3"
|
|
9
8
|
};
|
|
10
9
|
async function mapCommand(params, options) {
|
|
11
|
-
const { dsn, repo_id: repoID, commit_sha: sha, provider } = params;
|
|
12
|
-
if (!node_fs.existsSync(node_path.resolve(process.cwd(),
|
|
13
|
-
const files = node_fs.readdirSync(node_path.resolve(process.cwd(),
|
|
10
|
+
const { dsn, repo_id: repoID, commit_sha: sha, provider, build_target } = params;
|
|
11
|
+
if (!node_fs.existsSync(node_path.resolve(process.cwd(), '.canyon_output'))) return void console.log('不存在');
|
|
12
|
+
const files = node_fs.readdirSync(node_path.resolve(process.cwd(), '.canyon_output'));
|
|
14
13
|
let data = {};
|
|
15
14
|
for(let i = 0; i < files.length; i++){
|
|
16
|
-
const fileCoverageString = node_fs.readFileSync(node_path.resolve(process.cwd(),
|
|
15
|
+
const fileCoverageString = node_fs.readFileSync(node_path.resolve(process.cwd(), '.canyon_output', files[i]), 'utf-8');
|
|
16
|
+
const fileCoverage = JSON.parse(fileCoverageString);
|
|
17
|
+
if (files[i].includes('-init-')) try {
|
|
18
|
+
const pathString = node_fs.readFileSync(node_path.resolve(Object.keys(fileCoverage)[0] + '.map'), 'utf-8');
|
|
19
|
+
Object.entries(fileCoverage).forEach((item)=>{
|
|
20
|
+
item[1].inputSourceMap = pathString;
|
|
21
|
+
});
|
|
22
|
+
} catch (e) {}
|
|
17
23
|
data = {
|
|
18
24
|
...data,
|
|
19
|
-
...
|
|
25
|
+
...fileCoverage
|
|
20
26
|
};
|
|
21
27
|
}
|
|
22
28
|
const p = {
|
|
@@ -27,24 +33,23 @@ async function mapCommand(params, options) {
|
|
|
27
33
|
instrumentCwd: process.cwd(),
|
|
28
34
|
reportID: 'initial_coverage_data',
|
|
29
35
|
reportProvider: 'ci',
|
|
30
|
-
buildTarget: '',
|
|
36
|
+
buildTarget: build_target || '',
|
|
31
37
|
coverage: Object.keys(data)
|
|
32
38
|
};
|
|
33
|
-
log(p);
|
|
34
39
|
await axios.post(dsn, {
|
|
35
40
|
...p,
|
|
36
41
|
coverage: data
|
|
37
42
|
});
|
|
38
43
|
}
|
|
39
44
|
const accent = chalk.greenBright;
|
|
40
|
-
const CLI_BEFORE_ALL_TXT = `canyon: The ${accent(
|
|
41
|
-
const CLI_AFTER_ALL_TXT = `\nFor more help, head on to ${accent(
|
|
42
|
-
program.name(
|
|
45
|
+
const CLI_BEFORE_ALL_TXT = `canyon: The ${accent('Canyon')} CLI - Version ${package_namespaceObject.rE} (${accent('https://github.com/canyon-project/canyon')}) ${chalk.black.bold.bgYellowBright(' ALPHA ')} \n`;
|
|
46
|
+
const CLI_AFTER_ALL_TXT = `\nFor more help, head on to ${accent('https://github.com/canyon-project/canyon')}`;
|
|
47
|
+
program.name('canyon').version(package_namespaceObject.rE, '-v, --version', 'see the current version of canyon-uploader').usage('[options or commands] arguments').addHelpText('beforeAll', CLI_BEFORE_ALL_TXT).addHelpText('after', CLI_AFTER_ALL_TXT).configureHelp({
|
|
43
48
|
optionTerm: (option)=>accent(option.flags),
|
|
44
49
|
subcommandTerm: (cmd)=>accent(cmd.name(), cmd.usage()),
|
|
45
50
|
argumentTerm: (arg)=>accent(arg.name())
|
|
46
51
|
}).showHelpAfterError(true);
|
|
47
|
-
program.command(
|
|
52
|
+
program.command('upload').option('--dsn <dsn>', 'dsn of the canyon server').option('--repo_id <repo_id>', 'repo id of the canyon server').option('--instrument_cwd <instrument_cwd>', 'instrument cwd of the canyon server').option('--sha <sha>', 'sha of the canyon server').option('--branch <branch>', 'branch of the canyon server').option('--provider <provider>', 'provider of the canyon server').option('--build_target <build_target>', 'build target of the canyon server').option('--coverage <coverage>', 'coverage of the canyon server').allowExcessArguments(false).allowUnknownOption(false).description('modify react native project code to adapt to canyon').addHelpText('after', `\nFor help, head on to ${accent('https://github.com/canyon-project/canyon')}`).action(async (params, options)=>await mapCommand(params, options));
|
|
48
53
|
const cli = async (args)=>{
|
|
49
54
|
try {
|
|
50
55
|
await program.parseAsync(args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canyonjs/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "rslib build",
|
|
33
|
+
"my-test": "npm run build && node ./bin/canyon upload",
|
|
33
34
|
"check": "biome check --write",
|
|
34
35
|
"dev": "rslib build --watch",
|
|
35
36
|
"format": "biome format --write",
|