update
This commit is contained in:
@@ -9,13 +9,10 @@ import path from 'path';
|
||||
import { appsPath } from '../lib/index.ts';
|
||||
import { installAppFromKey } from './manager.ts';
|
||||
export type InstallAppOpts = {
|
||||
path?: string;
|
||||
key?: string;
|
||||
needInstallDeps?: boolean;
|
||||
// minio中
|
||||
appKey?: string;
|
||||
version?: string;
|
||||
username?: string;
|
||||
};
|
||||
/**
|
||||
* 检测路径是否存在
|
||||
@@ -23,16 +20,16 @@ export type InstallAppOpts = {
|
||||
* @returns
|
||||
*/
|
||||
export const appPathCheck = async (opts: InstallAppOpts) => {
|
||||
const { key } = opts;
|
||||
const directory = path.join(appsPath, key);
|
||||
const { appKey } = opts;
|
||||
const directory = path.join(appsPath, appKey);
|
||||
if (fileIsExist(directory)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export const installApp = async (opts: InstallAppOpts) => {
|
||||
const { key, needInstallDeps, appKey, version, username } = opts;
|
||||
const prefix = `${username}/${appKey}/${version}`;
|
||||
const { needInstallDeps, appKey, version } = opts;
|
||||
const prefix = `${appKey}/${version}`;
|
||||
const pkgPrefix = prefix + '/package.json';
|
||||
const stat = await getFileStat(pkgPrefix);
|
||||
if (!stat) {
|
||||
@@ -44,7 +41,7 @@ export const installApp = async (opts: InstallAppOpts) => {
|
||||
});
|
||||
for (const file of fileList) {
|
||||
const { name } = file as MinioFile;
|
||||
const outputPath = path.join(appsPath, key, name.replace(prefix, ''));
|
||||
const outputPath = path.join(appsPath, appKey, name.replace(prefix, ''));
|
||||
const dir = path.dirname(outputPath);
|
||||
if (!fileIsExist(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
@@ -58,7 +55,7 @@ export const installApp = async (opts: InstallAppOpts) => {
|
||||
writeStream.on('error', reject);
|
||||
});
|
||||
}
|
||||
const directory = path.join(appsPath, key);
|
||||
const directory = path.join(appsPath, appKey);
|
||||
if (!fileIsExist(directory)) {
|
||||
fs.mkdirSync(directory, { recursive: true });
|
||||
}
|
||||
@@ -69,7 +66,7 @@ export const installApp = async (opts: InstallAppOpts) => {
|
||||
console.log('installDeps error, [need manual install deps]', e);
|
||||
}
|
||||
}
|
||||
return installAppFromKey(key);
|
||||
return installAppFromKey(appKey);
|
||||
};
|
||||
|
||||
export const checkPnpm = () => {
|
||||
|
||||
Reference in New Issue
Block a user