Skip to content

Commit

Permalink
fix: .uniSdk 路径效验,/simpleDemo/libs 文件夹效验,uniapp-v8-release.aar SDK …
Browse files Browse the repository at this point in the history
…必要sdk

.uniSdk 路径效验,/simpleDemo/libs 文件夹效验,`uniapp-v8-release.aar` SDK 必要sdk
  • Loading branch information
hewx815 committed Oct 28, 2023
1 parent da4b4d5 commit 1e464ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
9 changes: 0 additions & 9 deletions for-vue2/src/packages/plugins/APPDevTool/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,5 @@

## BUG 自动下载 java

## BUG .uniSdk 路径效验

## BUG /simpleDemo/libs 文件夹效验

## BUG 获取 java 版本 ,适配 `java version "xxx.xxx.xxx"`

## BUG 安装后 `gradle-wrapper.jar` 文件失效

## BUG 安装后 `gradle-wrapper.jar` 文件失效

## BUG `uniapp-v8-release.aar` SDK 必要sdk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default async function checkoutDep() {

const data1 = String(data).split('\r\n')[0];

if (data1.indexOf('openjdk version') !== 0) {
if (data1.indexOf('openjdk version') !== 0 && data1.indexOf('java version') !== 0) {
reject(new Error());
} else {
const version = data1.split(' ')[2].replace(/"/g, '').split('.');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseStringPromise, Builder } from 'xml2js';
import {
readFile, writeFile, readdir, copyFile,
readFile, writeFile, readdir, copyFile, mkdir,
} from 'fs/promises';
import { resolve } from 'path';
import {
Expand Down Expand Up @@ -59,7 +59,7 @@ export default async function constructorProject(
};

const UNI_SDK_NAME_LIST = [
// 'uniapp-v8-release.aar',
'uniapp-v8-release.aar',
'oaid_sdk_1.0.25.aar',
'lib.5plus.base-release.aar',
'breakpad-build-release.aar',
Expand All @@ -68,11 +68,22 @@ export default async function constructorProject(

// 配置uniSdk
async function changeUniSdk(
uniSdkDir: string,
uniSdkDir?: string,
) {
if (!uniSdkDir) {
if (!checkPathExists(resolve(projectPath, '../.uniSdk'))) {
err(`缺少uniSdk
uniSdk 下载: https://nativesupport.dcloud.net.cn/AppDocs/download/android.html#
uniSdk 配置教程: https://h-uni.hewxing.cn/for-vue2/plugins/APPDevTool#uniSdk`, '', 'android');
}
} else if (!checkPathExists(uniSdkDir)) {
err(`文件夹:${uniSdkDir} 不存在`, '', 'android');
}

const path = resolve(projectPath, './simpleDemo/libs');

const sdks = await readdir(uniSdkDir);
const sdks = await readdir(uniSdkDir as string);

const deficiencySdks = UNI_SDK_NAME_LIST.filter((item) => !sdks.some((sdkName) => sdkName === item));

Expand All @@ -81,10 +92,14 @@ export default async function constructorProject(
err(`缺少以下 SDK 文件:${`\n${N}${deficiencySdks.join(N)}`}`, '', 'android');
}

if (!checkPathExists(path)) {
await mkdir(path);
}

await emptyFolder(path);

await Promise.all(
UNI_SDK_NAME_LIST.map((sdkName) => copyFile(resolve(uniSdkDir, sdkName), resolve(path, sdkName))),
UNI_SDK_NAME_LIST.map((sdkName) => copyFile(resolve(uniSdkDir as string, sdkName), resolve(path, sdkName))),
);
}

Expand Down Expand Up @@ -251,7 +266,7 @@ export default async function constructorProject(
),
changeResource(constructorProjectOptions?.appID || DEFAULT_APP_ID),
changeDcloudControlXml(constructorProjectOptions?.appID || DEFAULT_APP_ID),
changeUniSdk(constructorProjectOptions?.uniSdkPath || resolve(projectPath, '../.uniSdk')),
changeUniSdk(constructorProjectOptions?.uniSdkPath),
]);
}

Expand Down

0 comments on commit 1e464ad

Please sign in to comment.