Skip to content

Commit 0bed70a

Browse files
authored
Merge branch 'master' into improve-package-name-resolver-test
2 parents 3369f48 + 0f3d941 commit 0bed70a

18 files changed

Lines changed: 825 additions & 810 deletions

.ci/smoke-tests-common-validation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ steps:
99
TargetFolder: "$(System.DefaultWorkingDirectory)/test/smoke/resources/extension"
1010
- script: npm run prepare-smoke-tests
1111
displayName: "Prepare smoke tests"
12+
env:
13+
NODE_OPTIONS: "--openssl-legacy-provider"
1214
- script: npm run prepare-smoke-tests-project
1315
displayName: "Prepare smoke tests sample project"
1416
- script: npm run smoke-tests --verbose

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@
2121
},
2222
// "gulp.autoDetect": "on",
2323
"typescript.tsdk": "./node_modules/typescript/lib"
24+
,
25+
"react-native-tools.logHighlight.enabled": true,
26+
"files.associations": {
27+
"*.rn-output": "rn-output-log"
28+
}
2429
}

package-lock.json

Lines changed: 592 additions & 426 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
],
4040
"main": "./dist/rn-extension",
4141
"contributes": {
42+
"languages": [
43+
{
44+
"id": "rn-output-log",
45+
"aliases": ["RN Output Log"],
46+
"extensions": [".rn-output"]
47+
}
48+
],
4249
"walkthroughs": [
4350
{
4451
"id": "RNTGetStarted",
@@ -1163,6 +1170,13 @@
11631170
}
11641171
}
11651172
],
1173+
"grammars": [
1174+
{
1175+
"language": "rn-output-log",
1176+
"scopeName": "react-native-tools-output-simple",
1177+
"path": "./syntaxes/rn-output-simple.tmGrammar.json"
1178+
}
1179+
],
11661180
"configuration": {
11671181
"type": "object",
11681182
"title": "%reactNative.configuration.title%",
@@ -1366,6 +1380,12 @@
13661380
],
13671381
"scope": "resource",
13681382
"default": "npm"
1383+
},
1384+
"react-native-tools.logHighlight.enabled": {
1385+
"description": "Enable lightweight syntax highlighting for extension output logs. When enabled, applies color highlighting to common log keywords (ERROR, WARN, INFO, DEBUG, SUCCESS, etc.). This feature is disabled by default to avoid performance issues.",
1386+
"type": "boolean",
1387+
"scope": "resource",
1388+
"default": false
13691389
}
13701390
}
13711391
}
@@ -1514,7 +1534,7 @@
15141534
"typescript": "^5.0.4",
15151535
"vscode-debugprotocol": "1.51.0",
15161536
"vscode-nls-dev": "^4.0.4",
1517-
"webpack": "5.94.0",
1537+
"webpack": "5.105.0",
15181538
"webpack-bundle-analyzer": "4.4.0"
15191539
},
15201540
"extensionDependencies": [

src/extension/android/packageNameResolver.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ export class PackageNameResolver {
2020
PackageNameResolver.GradleBuildName,
2121
];
2222
private applicationName: string;
23+
private fileSystem: FileSystem;
2324

24-
constructor(applicationName: string) {
25+
constructor(applicationName: string, fileSystem?: FileSystem) {
2526
this.applicationName = applicationName;
27+
this.fileSystem = fileSystem || new FileSystem();
2628
}
2729

2830
/**
@@ -47,36 +49,27 @@ export class PackageNameResolver {
4749
}
4850

4951
private async readApplicationId(gradlePath: string): Promise<string | null> {
50-
if (gradlePath) {
51-
const fs = new FileSystem();
52-
if (await fs.exists(gradlePath)) {
53-
const content = await fs.readFile(gradlePath);
54-
const match = content.toString().match(PackageNameResolver.ApplicationIdRegexp);
55-
return match ? match[2] : null;
56-
}
52+
if (!(await this.fileSystem.exists(gradlePath))) {
53+
return null;
5754
}
58-
return null;
55+
56+
const content = await this.fileSystem.readFile(gradlePath);
57+
const match = content.toString().match(PackageNameResolver.ApplicationIdRegexp);
58+
return match ? match[2] : null;
5959
}
6060

6161
/**
6262
* Given a manifest file path, it parses the file and returns the package name.
6363
* If the package name cannot be parsed, the default packge name is returned.
6464
*/
6565
private async readPackageName(manifestPath: string): Promise<string> {
66-
if (manifestPath) {
67-
const fs = new FileSystem();
68-
const exists = await fs.exists(manifestPath);
69-
if (exists) {
70-
const manifestContent = await fs.readFile(manifestPath);
71-
let packageName = this.parsePackageName(manifestContent.toString());
72-
if (!packageName) {
73-
packageName = this.getDefaultPackageName(this.applicationName);
74-
}
75-
return packageName;
76-
}
66+
if (!(await this.fileSystem.exists(manifestPath))) {
7767
return this.getDefaultPackageName(this.applicationName);
7868
}
79-
return this.getDefaultPackageName(this.applicationName);
69+
70+
const manifestContent = await this.fileSystem.readFile(manifestPath);
71+
const packageName = this.parsePackageName(manifestContent.toString());
72+
return packageName || this.getDefaultPackageName(this.applicationName);
8073
}
8174

8275
/**
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"scopeName": "react-native-tools-output-simple",
3+
"patterns": [
4+
{
5+
"include": "#keywords-error"
6+
},
7+
{
8+
"include": "#keywords-warn"
9+
},
10+
{
11+
"include": "#keywords-info"
12+
},
13+
{
14+
"include": "#keywords-debug"
15+
},
16+
{
17+
"include": "#keywords-success"
18+
},
19+
{
20+
"include": "#constants"
21+
},
22+
{
23+
"include": "#string-quoted"
24+
},
25+
{
26+
"include": "#url-simple"
27+
},
28+
{
29+
"include": "#numeric-decimal"
30+
}
31+
],
32+
"repository": {
33+
"keywords-error": {
34+
"match": "\\b(ERROR|error|FAILED|failed|FAILURE|failure|Exception|exception|FATAL|fatal|Fatal)\\b",
35+
"name": "markup.bold invalid.illegal rnt.output.error"
36+
},
37+
"keywords-warn": {
38+
"match": "\\b(WARN|warn|WARNING|warning)\\b",
39+
"name": "markup.bold markup.deleted rnt.output.warn"
40+
},
41+
"keywords-info": {
42+
"match": "\\b(INFO|info|INFORMATION|information)\\b",
43+
"name": "markup.bold markup.inserted rnt.output.info"
44+
},
45+
"keywords-debug": {
46+
"match": "\\b(DEBUG|debug)\\b",
47+
"name": "markup.bold markup.changed rnt.output.debug"
48+
},
49+
"keywords-success": {
50+
"match": "\\b(SUCCESS|success|BUILD SUCCESSFUL|BUILD PASSED|PASSED|passed)\\b",
51+
"name": "markup.bold markup.inserted rnt.output.success"
52+
},
53+
"constants": {
54+
"match": "\\b(true|false|null|undefined|NaN)\\b",
55+
"name": "constant.language rnt.output.constant"
56+
},
57+
"string-quoted": {
58+
"match": "['\"]([^'\"]{0,50})['\"]",
59+
"name": "string.quoted rnt.output.string"
60+
},
61+
"url-simple": {
62+
"match": "https?://[^\\s]+",
63+
"name": "markup.underline.link rnt.output.url"
64+
},
65+
"numeric-decimal": {
66+
"match": "\\b\\d+(?:\\.\\d+)?\\b",
67+
"name": "constant.numeric rnt.output.numeric"
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)