xhs-mp-compiler-cli 1.4.0-beta.1 → 1.4.0-beta.4
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/utils/apm/index.js
CHANGED
|
@@ -5,16 +5,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createReporter = void 0;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
10
14
|
const xhs_mp_utils_1 = require("xhs-mp-utils");
|
|
15
|
+
const fs_extra_1 = require("fs-extra");
|
|
11
16
|
const pkg = require('../../../package.json');
|
|
12
17
|
function debug(...data) {
|
|
13
|
-
return;
|
|
14
18
|
// return process.send?.(JSON.stringify({ method: 'debugger', data }))
|
|
15
19
|
}
|
|
16
20
|
const cacheMap = {};
|
|
17
|
-
function
|
|
21
|
+
function onceByParams(target, key, descriptor) {
|
|
18
22
|
const originalMethod = descriptor.value;
|
|
19
23
|
descriptor.value = function (...args) {
|
|
20
24
|
try {
|
|
@@ -87,22 +91,22 @@ class Reporter {
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
__decorate([
|
|
90
|
-
|
|
94
|
+
onceByParams
|
|
91
95
|
], Reporter.prototype, "reportThirdFramework", null);
|
|
92
96
|
__decorate([
|
|
93
|
-
|
|
97
|
+
onceByParams
|
|
94
98
|
], Reporter.prototype, "reportMlFeature", null);
|
|
95
99
|
__decorate([
|
|
96
|
-
|
|
100
|
+
onceByParams
|
|
97
101
|
], Reporter.prototype, "reportMlWebComponent", null);
|
|
98
102
|
__decorate([
|
|
99
|
-
|
|
103
|
+
onceByParams
|
|
100
104
|
], Reporter.prototype, "reportJSONComponent", null);
|
|
101
105
|
__decorate([
|
|
102
|
-
|
|
106
|
+
onceByParams
|
|
103
107
|
], Reporter.prototype, "reportStyleIsolation", null);
|
|
104
108
|
__decorate([
|
|
105
|
-
|
|
109
|
+
onceByParams
|
|
106
110
|
], Reporter.prototype, "reportJSONApp", null);
|
|
107
111
|
function isObject(t) {
|
|
108
112
|
return t != null && typeof t === 'object';
|
|
@@ -120,18 +124,20 @@ function createReporter(project, option) {
|
|
|
120
124
|
var _a, _b, _c;
|
|
121
125
|
try {
|
|
122
126
|
const app_id = option === null || option === void 0 ? void 0 : option.upload_app_id;
|
|
123
|
-
|
|
127
|
+
// 上传时有version
|
|
128
|
+
const version = (_a = option === null || option === void 0 ? void 0 : option.pkgInfo) === null || _a === void 0 ? void 0 : _a.version;
|
|
129
|
+
if (!app_id || !version) {
|
|
124
130
|
return;
|
|
125
131
|
}
|
|
126
132
|
const apm = new xhs_mp_utils_1.APM(`mp-compiler-${pkg.version}`);
|
|
127
|
-
(
|
|
133
|
+
(_b = apm === null || apm === void 0 ? void 0 : apm.setContext) === null || _b === void 0 ? void 0 : _b.call(apm, app_id, {
|
|
128
134
|
app_id,
|
|
129
135
|
app_name: app_id,
|
|
130
136
|
third_name: app_id,
|
|
131
137
|
page_key: '0',
|
|
132
138
|
app_env: 0,
|
|
133
139
|
app_type: 0,
|
|
134
|
-
bundle_version:
|
|
140
|
+
bundle_version: version,
|
|
135
141
|
base_version: ((_c = project.projectJsonContent) === null || _c === void 0 ? void 0 : _c.libVersion) || ''
|
|
136
142
|
});
|
|
137
143
|
const reporter = new Reporter(apm);
|
|
@@ -170,8 +176,19 @@ function createReporter(project, option) {
|
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
}
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
reportJSON();
|
|
180
|
+
// 统计taro版本
|
|
181
|
+
const vendor = path_1.default.join(project.miniprogramDir, 'vendors.js.LICENSE.txt');
|
|
182
|
+
const taro = path_1.default.join(project.miniprogramDir, 'taro.js');
|
|
183
|
+
if ((0, fs_extra_1.pathExistsSync)(taro) && (0, fs_extra_1.pathExistsSync)(vendor)) {
|
|
184
|
+
const txt = (0, fs_extra_1.readFileSync)(vendor, { encoding: 'utf-8' });
|
|
185
|
+
if (txt.includes('React') || txt.includes('react')) {
|
|
186
|
+
reporter.reportThirdFramework(xhs_mp_utils_1.FeatureReporter.ThirdFramework.taroReact);
|
|
187
|
+
}
|
|
188
|
+
else if (txt.includes('@vue') || txt.includes('Vue')) {
|
|
189
|
+
reporter.reportThirdFramework(xhs_mp_utils_1.FeatureReporter.ThirdFramework.taroVue);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
175
192
|
return reporter;
|
|
176
193
|
}
|
|
177
194
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xhs-mp-compiler-cli",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.4",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -94,12 +94,12 @@
|
|
|
94
94
|
"webpack-bundle-analyzer": "^4.4.0",
|
|
95
95
|
"webpack-chain": "^6.5.1",
|
|
96
96
|
"webpack-sources": "^3.2.2",
|
|
97
|
-
"xhs-mp-compiler-ml-loader": "1.4.0-beta.
|
|
98
|
-
"xhs-mp-compiler-utils": "1.3.0-beta.
|
|
99
|
-
"xhs-mp-pack": "^1.3.0-beta.
|
|
100
|
-
"xhs-mp-project": "^1.3.0-beta.
|
|
101
|
-
"xhs-mp-utils": "^1.4.0-beta.
|
|
102
|
-
"xhs-mp-shared-fs": "^1.1.0-beta.
|
|
97
|
+
"xhs-mp-compiler-ml-loader": "1.4.0-beta.4",
|
|
98
|
+
"xhs-mp-compiler-utils": "1.3.0-beta.4",
|
|
99
|
+
"xhs-mp-pack": "^1.3.0-beta.4",
|
|
100
|
+
"xhs-mp-project": "^1.3.0-beta.4",
|
|
101
|
+
"xhs-mp-utils": "^1.4.0-beta.4",
|
|
102
|
+
"xhs-mp-shared-fs": "^1.1.0-beta.4",
|
|
103
103
|
"yauzl": "^2.10.0"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
property targetTab: null
|
|
2
|
-
property targetTabIndex: -1
|
|
3
|
-
property targetWindow: null
|
|
4
|
-
|
|
5
|
-
on run argv
|
|
6
|
-
set theURL to item 1 of argv
|
|
7
|
-
|
|
8
|
-
with timeout of 2 seconds
|
|
9
|
-
tell application "Chrome"
|
|
10
|
-
|
|
11
|
-
if (count every window) = 0 then
|
|
12
|
-
make new window
|
|
13
|
-
end if
|
|
14
|
-
|
|
15
|
-
-- 1: Looking for tab running debugger
|
|
16
|
-
-- then, Reload debugging tab if found
|
|
17
|
-
-- then return
|
|
18
|
-
set found to my lookupTabWithUrl(theURL)
|
|
19
|
-
if found then
|
|
20
|
-
set targetWindow's active tab index to targetTabIndex
|
|
21
|
-
tell targetTab to reload
|
|
22
|
-
tell targetWindow to activate
|
|
23
|
-
set index of targetWindow to 1
|
|
24
|
-
return
|
|
25
|
-
end if
|
|
26
|
-
|
|
27
|
-
-- 2: Looking for Empty tab
|
|
28
|
-
-- In case debugging tab was not found
|
|
29
|
-
-- We try to find an empty tab instead
|
|
30
|
-
set found to my lookupTabWithUrl("chrome://newtab/")
|
|
31
|
-
if found then
|
|
32
|
-
set targetWindow's active tab index to targetTabIndex
|
|
33
|
-
set URL of targetTab to theURL
|
|
34
|
-
tell targetWindow to activate
|
|
35
|
-
return
|
|
36
|
-
end if
|
|
37
|
-
|
|
38
|
-
-- 3: Create new tab
|
|
39
|
-
-- both debugging and empty tab were not found
|
|
40
|
-
-- make a new tab with url
|
|
41
|
-
tell window 1
|
|
42
|
-
activate
|
|
43
|
-
make new tab with properties {URL:theURL}
|
|
44
|
-
end tell
|
|
45
|
-
end tell
|
|
46
|
-
end timeout
|
|
47
|
-
end run
|
|
48
|
-
|
|
49
|
-
-- Function:
|
|
50
|
-
-- Lookup tab with given url
|
|
51
|
-
-- if found, store tab, index, and window in properties
|
|
52
|
-
-- (properties were declared on top of file)
|
|
53
|
-
on lookupTabWithUrl(lookupUrl)
|
|
54
|
-
tell application "Chrome"
|
|
55
|
-
-- Find a tab with the given url
|
|
56
|
-
set found to false
|
|
57
|
-
set theTabIndex to -1
|
|
58
|
-
repeat with theWindow in every window
|
|
59
|
-
set theTabIndex to 0
|
|
60
|
-
repeat with theTab in every tab of theWindow
|
|
61
|
-
set theTabIndex to theTabIndex + 1
|
|
62
|
-
if (theTab's URL as string) contains lookupUrl then
|
|
63
|
-
-- assign tab, tab index, and window to properties
|
|
64
|
-
set targetTab to theTab
|
|
65
|
-
set targetTabIndex to theTabIndex
|
|
66
|
-
set targetWindow to theWindow
|
|
67
|
-
set found to true
|
|
68
|
-
exit repeat
|
|
69
|
-
end if
|
|
70
|
-
end repeat
|
|
71
|
-
|
|
72
|
-
if found then
|
|
73
|
-
exit repeat
|
|
74
|
-
end if
|
|
75
|
-
end repeat
|
|
76
|
-
end tell
|
|
77
|
-
return found
|
|
78
|
-
end lookupTabWithUrl
|