mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
perf: pro package download
This commit is contained in:
parent
2c709c97c6
commit
de9ac9957e
@ -140,7 +140,7 @@ class Package {
|
|||||||
.on('finish', resolve)
|
.on('finish', resolve)
|
||||||
.on('error', reject);
|
.on('error', reject);
|
||||||
});
|
});
|
||||||
console.log(chalk.greenBright(`Download success: ${this.packageName}@${version}`));
|
console.log(chalk.greenBright(`Downloaded: ${this.packageName}@${version}`));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(chalk.redBright(`Download failed: ${this.packageName}`));
|
console.log(chalk.redBright(`Download failed: ${this.packageName}`));
|
||||||
}
|
}
|
||||||
@ -194,16 +194,37 @@ class PackageManager {
|
|||||||
|
|
||||||
async getPackages() {
|
async getPackages() {
|
||||||
const pkgs = await this.getProPackages();
|
const pkgs = await this.getProPackages();
|
||||||
|
|
||||||
|
if (Array.isArray(pkgs)) {
|
||||||
|
return {
|
||||||
|
commercial_plugins: pkgs,
|
||||||
|
licensed_plugins: pkgs,
|
||||||
|
};
|
||||||
|
}
|
||||||
return pkgs;
|
return pkgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removePackage(packageName) {
|
||||||
|
const dir = path.resolve(process.env.PLUGIN_STORAGE_PATH, packageName);
|
||||||
|
const r = await fs.exists(dir);
|
||||||
|
if (r) {
|
||||||
|
console.log(chalk.yellowBright(`Removed: ${packageName}`));
|
||||||
|
await fs.rm(dir, { force: true, recursive: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async download(options = {}) {
|
async download(options = {}) {
|
||||||
const { version } = options;
|
const { version } = options;
|
||||||
if (!this.token) {
|
if (!this.token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pkgs = await this.getPackages();
|
const { commercial_plugins, licensed_plugins } = await this.getPackages();
|
||||||
for (const pkg of pkgs) {
|
for (const pkg of commercial_plugins) {
|
||||||
|
if (!licensed_plugins.includes(pkg)) {
|
||||||
|
await this.removePackage(pkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const pkg of licensed_plugins) {
|
||||||
await this.getPackage(pkg).download({ version });
|
await this.getPackage(pkg).download({ version });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,10 @@ exports.promptForTs = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.downloadPro = async () => {
|
exports.downloadPro = async () => {
|
||||||
|
const { NOCOBASE_PKG_USERNAME, NOCOBASE_PKG_PASSWORD } = process.env;
|
||||||
|
if (!(NOCOBASE_PKG_USERNAME && NOCOBASE_PKG_PASSWORD)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await exports.run('yarn', ['nocobase', 'pkg', 'download-pro']);
|
await exports.run('yarn', ['nocobase', 'pkg', 'download-pro']);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user