@canyonjs/cli 1.0.26 → 1.0.27
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/index.js +21 -14
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { program } from "commander";
|
|
3
|
-
import { error, log } from "node:console";
|
|
4
3
|
import node_fs from "node:fs";
|
|
5
4
|
import node_path from "node:path";
|
|
6
5
|
import axios from "axios";
|
|
7
6
|
var package_namespaceObject = {
|
|
8
|
-
rE: "1.0.
|
|
7
|
+
rE: "1.0.27"
|
|
9
8
|
};
|
|
10
9
|
function mergeNumberMaps(a = {}, b = {}) {
|
|
11
10
|
const result = {
|
|
@@ -61,9 +60,9 @@ function mergeCoverageMaps(target = {}, source = {}) {
|
|
|
61
60
|
return out;
|
|
62
61
|
}
|
|
63
62
|
async function mapCommand(params, options) {
|
|
64
|
-
log('Current working directory:', process.cwd());
|
|
63
|
+
console.log('Current working directory:', process.cwd());
|
|
65
64
|
const { dsn, repo_id: repoID, sha, provider, build_target, debug, instrument_cwd, filter, scene } = params;
|
|
66
|
-
if (!node_fs.existsSync(node_path.resolve(process.cwd(), '.canyon_output'))) return void log('
|
|
65
|
+
if (!node_fs.existsSync(node_path.resolve(process.cwd(), '.canyon_output'))) return void console.log('No .canyon_output directory found, skipping upload.');
|
|
67
66
|
const files = node_fs.readdirSync(node_path.resolve(process.cwd(), '.canyon_output'));
|
|
68
67
|
let data = {};
|
|
69
68
|
for(let i = 0; i < files.length; i++){
|
|
@@ -83,12 +82,17 @@ async function mapCommand(params, options) {
|
|
|
83
82
|
const env_buildID = process.env.CI_JOB_ID;
|
|
84
83
|
const env_buildProvider = 'gitlab_runner';
|
|
85
84
|
let sceneMap;
|
|
86
|
-
if (scene)
|
|
87
|
-
sceneMap =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
if (scene && Array.isArray(scene)) {
|
|
86
|
+
sceneMap = {};
|
|
87
|
+
for (const pair of scene){
|
|
88
|
+
if ('string' != typeof pair) return void console.error(`Invalid scene parameter: ${pair}. Expected format: key=value`);
|
|
89
|
+
const equalIndex = pair.indexOf('=');
|
|
90
|
+
if (-1 === equalIndex || 0 === equalIndex) return void console.error(`Invalid scene parameter format: ${pair}. Expected format: key=value`);
|
|
91
|
+
const key = pair.substring(0, equalIndex);
|
|
92
|
+
const value = pair.substring(equalIndex + 1);
|
|
93
|
+
if (!key || !value) return void console.error(`Invalid scene parameter format: ${pair}. Key and value cannot be empty`);
|
|
94
|
+
sceneMap[key] = value;
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
const p = {
|
|
94
98
|
dsn,
|
|
@@ -109,15 +113,15 @@ async function mapCommand(params, options) {
|
|
|
109
113
|
scene: sceneMap
|
|
110
114
|
}
|
|
111
115
|
};
|
|
112
|
-
if ('true' === debug) log(p);
|
|
116
|
+
if ('true' === debug) console.log(p);
|
|
113
117
|
await axios.post(dsn, {
|
|
114
118
|
...p,
|
|
115
119
|
coverage: data
|
|
116
120
|
}).then((r)=>{
|
|
117
|
-
log(JSON.stringify(r.data, null, 2));
|
|
121
|
+
console.log(JSON.stringify(r.data, null, 2));
|
|
118
122
|
return r;
|
|
119
123
|
}).catch((err)=>{
|
|
120
|
-
if (err?.response?.data) log(err?.response?.data);
|
|
124
|
+
if (err?.response?.data) console.log(err?.response?.data);
|
|
121
125
|
else String(err);
|
|
122
126
|
return err;
|
|
123
127
|
});
|
|
@@ -130,7 +134,10 @@ program.name('canyon').version(package_namespaceObject.rE, '-v, --version', 'see
|
|
|
130
134
|
subcommandTerm: (cmd)=>accent(cmd.name(), cmd.usage()),
|
|
131
135
|
argumentTerm: (arg)=>accent(arg.name())
|
|
132
136
|
}).showHelpAfterError(true);
|
|
133
|
-
program.command('upload').option('--debug <dsn>', 'debug').option('--dsn <dsn>', 'dsn of the canyon server').option('--repo_id <repo_id>', 'repo id of the canyon server').option('--filter <filter>', '仅合并路径包含该子串的文件覆盖率').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').option('--scene <
|
|
137
|
+
program.command('upload').option('--debug <dsn>', 'debug').option('--dsn <dsn>', 'dsn of the canyon server').option('--repo_id <repo_id>', 'repo id of the canyon server').option('--filter <filter>', '仅合并路径包含该子串的文件覆盖率').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').option('--scene <key=value>', 'scene key-value pair, can be used multiple times, e.g. --scene env=prod --scene type=e2e', (value, previous = [])=>{
|
|
138
|
+
previous.push(value);
|
|
139
|
+
return previous;
|
|
140
|
+
}, []).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));
|
|
134
141
|
const cli = async (args)=>{
|
|
135
142
|
try {
|
|
136
143
|
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.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@rslib/core": "^0.15.1",
|
|
21
21
|
"@rstest/core": "^0.5.1",
|
|
22
22
|
"@types/node": "^24.10.1",
|
|
23
|
-
"@typescript/native-preview": "
|
|
23
|
+
"@typescript/native-preview": "7.0.0-dev.20260119.1"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"axios": "^1.12.2",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "rslib build",
|
|
32
|
-
"
|
|
32
|
+
"do-test": "npm run build && node ./bin/canyon.js upload --debug true --scene k1=v2 --scene k2=v3",
|
|
33
33
|
"dev-cli": "rslib build --watch"
|
|
34
34
|
}
|
|
35
35
|
}
|