@zeppos/zeus-cli 1.7.4 → 1.7.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeppos/zeus-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.6",
|
|
4
4
|
"description": "zeus mini-program tools",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"author": "zepp",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"qrcode-terminal": "^0.12.0",
|
|
22
22
|
"vorpal": "^1.12.0",
|
|
23
23
|
"yargs": "^17.7.2",
|
|
24
|
-
"@zeppos/zpm": "^3.2.
|
|
24
|
+
"@zeppos/zpm": "^3.2.5",
|
|
25
25
|
"axios": "1.8.2",
|
|
26
26
|
"chalk": "^4.1.2",
|
|
27
27
|
"chokidar": "^3.6.0",
|
|
@@ -77,6 +77,7 @@ exports.runX = exports.previewBuild = exports.build = exports.buildSupportV3Conf
|
|
|
77
77
|
var zpm_1 = require("@zeppos/zpm");
|
|
78
78
|
var rd = __importStar(require("rd"));
|
|
79
79
|
var fs_1 = __importDefault(require("fs"));
|
|
80
|
+
var os_1 = __importDefault(require("os"));
|
|
80
81
|
var path = __importStar(require("path"));
|
|
81
82
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
82
83
|
var form_data_1 = __importDefault(require("form-data"));
|
|
@@ -118,6 +119,54 @@ var gitignoreDefaultItem = [
|
|
|
118
119
|
'*.njsproj',
|
|
119
120
|
'*.sln',
|
|
120
121
|
];
|
|
122
|
+
function getSimulatorPath() {
|
|
123
|
+
var platform = os_1["default"].platform();
|
|
124
|
+
var newPath;
|
|
125
|
+
if (platform === 'win32')
|
|
126
|
+
newPath = process.env.APPDATA || '';
|
|
127
|
+
else
|
|
128
|
+
newPath = path.join(os_1["default"].homedir(), '.config');
|
|
129
|
+
return path.join(newPath, 'simulator');
|
|
130
|
+
}
|
|
131
|
+
function getSimulatorAppsPath(projectName, appId) {
|
|
132
|
+
var simulatorPath = getSimulatorPath();
|
|
133
|
+
var appsPath = path.join(simulatorPath, 'apps');
|
|
134
|
+
if (projectName && appId)
|
|
135
|
+
return path.join(appsPath, projectName + appId);
|
|
136
|
+
return appsPath;
|
|
137
|
+
}
|
|
138
|
+
function updateLastAppInfo(projectName, appId, userProjectPath) {
|
|
139
|
+
var simulatorDir = getSimulatorPath();
|
|
140
|
+
var lastAppInfoPath = path.join(simulatorDir, 'last_app_info.json');
|
|
141
|
+
var simAppPath = getSimulatorAppsPath(projectName, appId);
|
|
142
|
+
var newAppInfo = {
|
|
143
|
+
sim_app_path: simAppPath,
|
|
144
|
+
user_app_path: userProjectPath,
|
|
145
|
+
project_name: projectName,
|
|
146
|
+
app_id: appId,
|
|
147
|
+
last_updated: new Date().toISOString()
|
|
148
|
+
};
|
|
149
|
+
var needsUpdate = true;
|
|
150
|
+
if (fs_1["default"].existsSync(lastAppInfoPath)) {
|
|
151
|
+
try {
|
|
152
|
+
var existingContent = fs_1["default"].readFileSync(lastAppInfoPath, 'utf8');
|
|
153
|
+
var existingInfo = JSON.parse(existingContent);
|
|
154
|
+
if (existingInfo.sim_app_path === newAppInfo.sim_app_path &&
|
|
155
|
+
existingInfo.user_app_path === newAppInfo.user_app_path) {
|
|
156
|
+
needsUpdate = false;
|
|
157
|
+
return existingInfo;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.log('Error reading existing app info, will overwrite:', error.message);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (needsUpdate) {
|
|
165
|
+
fs_1["default"].mkdirSync(simulatorDir, { recursive: true });
|
|
166
|
+
fs_1["default"].writeFileSync(lastAppInfoPath, JSON.stringify(newAppInfo, null, 2));
|
|
167
|
+
}
|
|
168
|
+
return newAppInfo;
|
|
169
|
+
}
|
|
121
170
|
var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
|
|
122
171
|
if (mode === void 0) { mode = BuildMode.PROD; }
|
|
123
172
|
if (buildConfigOption === void 0) { buildConfigOption = {}; }
|
|
@@ -172,7 +221,7 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
|
|
|
172
221
|
}
|
|
173
222
|
if (buildConfigOption.renameWithAppId) {
|
|
174
223
|
distDir_1 = path.join(workspace, 'dist');
|
|
175
|
-
name_1 = zabName_1.replace(
|
|
224
|
+
name_1 = zabName_1.replace(/\s/g, '_').split('.zab');
|
|
176
225
|
newName_1 = "".concat(buildConfigOption.renameWithAppId, "-").concat(name_1[0], ".zab");
|
|
177
226
|
rd.eachFileSync(distDir_1, function (file) {
|
|
178
227
|
var oldName = path.join(distDir_1, zabName_1);
|
|
@@ -213,7 +262,7 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
|
|
|
213
262
|
jsc: TransformType.Default
|
|
214
263
|
};
|
|
215
264
|
if (mode === BuildMode.PROD || mode === BuildMode.PREVIEW) {
|
|
216
|
-
_a = buildConfigOption || {}, js2c = _a.js2c, _b = _a.js2bin, js2bin = _b === void 0 ? true : _b, _c = _a.png2vg, png2vg = _c === void 0 ? true : _c, _d = _a.prune, prune = _d === void 0 ? true : _d, _e = _a.compress, compress = _e === void 0 ? true : _e, _f = _a.ip, ip = _f === void 0 ?
|
|
265
|
+
_a = buildConfigOption || {}, js2c = _a.js2c, _b = _a.js2bin, js2bin = _b === void 0 ? true : _b, _c = _a.png2vg, png2vg = _c === void 0 ? true : _c, _d = _a.prune, prune = _d === void 0 ? true : _d, _e = _a.compress, compress = _e === void 0 ? true : _e, _f = _a.ip, ip = _f === void 0 ? mode === BuildMode.PROD : _f;
|
|
217
266
|
js2c = (0, tools_1.booleanString)(js2c);
|
|
218
267
|
js2bin = (0, tools_1.booleanString)(js2bin);
|
|
219
268
|
js2c && Object.assign(buildOptions, { jsc: TransformType.C });
|
|
@@ -230,14 +279,13 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
|
|
|
230
279
|
_g.trys.push([1, 6, , 7]);
|
|
231
280
|
index_1.logger.info("Start building package, targets: ".concat(packages.join(', '), "."));
|
|
232
281
|
curOpt = (0, lodash_1.get)(buildConfigOption, '_', [])[0];
|
|
233
|
-
if (!(mode !== BuildMode.DEV ||
|
|
234
|
-
(mode === BuildMode.DEV && curOpt === 'install'))) return [3, 3];
|
|
282
|
+
if (!(mode !== BuildMode.DEV || (mode === BuildMode.DEV && curOpt === 'install'))) return [3, 3];
|
|
235
283
|
return [4, (0, zpm_1.start)(buildOptions)];
|
|
236
284
|
case 2:
|
|
237
285
|
productName_1 = _g.sent();
|
|
238
286
|
if (productName_1) {
|
|
239
287
|
DistDir_1 = path.join(workspace, 'dist');
|
|
240
|
-
name_2 = productName_1.replace(
|
|
288
|
+
name_2 = productName_1.replace(/\s/g, '_').split('.zab');
|
|
241
289
|
newName_2 = "".concat(appId, "-").concat(name_2[0], ".zab");
|
|
242
290
|
rd.eachFileSync(DistDir_1, function (file) {
|
|
243
291
|
var oldName = path.join(DistDir_1, productName_1);
|
|
@@ -380,6 +428,7 @@ var runX = function (root, args, url, logAfterFunc) { return __awaiter(void 0, v
|
|
|
380
428
|
_a = (0, index_1.getDeviceInfoFromAppJson)(root), targetDeviceInternalName = _a.targetDeviceInternalName, appId = _a.appId, devices = _a.deviceSourceArr;
|
|
381
429
|
projectName = path.parse(process.cwd()).base;
|
|
382
430
|
simulator.upload(zpkBuffer, projectName, targetDeviceInternalName, appId, devices);
|
|
431
|
+
updateLastAppInfo(projectName, appId, root);
|
|
383
432
|
}
|
|
384
433
|
else {
|
|
385
434
|
logger.error('build error');
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dev": "nodemon -e ts,tsx --exec \"rimraf dist && tsc && ts-node build.ts\" --ignore types/ --ignore dist/"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@zeppos/zpm": "^3.2.
|
|
16
|
+
"@zeppos/zpm": "^3.2.5",
|
|
17
17
|
"axios": "1.8.2",
|
|
18
18
|
"chalk": "^4.1.2",
|
|
19
19
|
"chokidar": "^3.6.0",
|