Skip to content

Commit

Permalink
启动服务时候, 执行初始化软件包的安装
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Dec 12, 2024
1 parent 8ba2a45 commit 21f50d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function installModule(module, version, url, registry_url) {
// if( check !== false){
// return check;
// }
// console.log(`installModule`, module,version,url)
console.log(`install page`, module, version, url)
module = module || "";
activePromise = activePromise.then(async function() {
//TODO: ensure module is 'safe'
Expand Down Expand Up @@ -193,7 +193,7 @@ async function installModule(module, version, url, registry_url) {

var installDir = settings.userDir || ".";
var args = ['install','--no-audit','--no-update-notifier','--no-fund','--save','--save-prefix=~','--production',installName];
var yarnArgs = ['add', '-E', installName, '--json']; //yarnCommand , '--json' --registry
var yarnArgs = ['add', '-E', ...installName.split(' '), '--json']; //yarnCommand , '--json' --registry
if (false && registry_url) {
yarnArgs.push('--registry')
yarnArgs.push(registry_url)
Expand Down
3 changes: 2 additions & 1 deletion services/service-package-registry/project.package.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ module.exports = {
async handler(){
const settings = this.settings;
const packages = settings.STEEDOS_INITIAL_PACKAGES;
console.log('install initial packages: ', STEEDOS_INITIAL_PACKAGES);
if(_.isString(packages) && packages){
for (const packageName of packages.split(',')) {
try {
Expand Down Expand Up @@ -430,7 +431,7 @@ module.exports = {
await this.installPackageFromUrl(installProps.url, installProps.version, installProps.url, null, true, null, this.broker);
}else{
//module, version, label, description, enable, broker
await this.installPackage(installProps.name, installProps.version, null, null, true, this.broker);
await this.installPackage(process.env.NPM_REGISTRY_URL ? `${installProps.name} --registry ${process.env.NPM_REGISTRY_URL}` : installProps.name, installProps.version, null, null, true, this.broker);
}
} catch (error) {
this.broker.logger.error(`initialPackages: ${packageName}. ${error.message}`);
Expand Down
8 changes: 4 additions & 4 deletions services/service-steedos-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ module.exports = {
steedosConfig.setTenant({ enable_create_tenant: true, enable_register: true });
}
// 工作区未初始化时,才初始化软件包
const allowInit = await this.allowInit(records);
if (!allowInit) {
return
}
// const allowInit = await this.allowInit(records);
// if (!allowInit) {
// return
// }
try {
await ctx.broker.call('@steedos/service-project.initialPackages', {}, {});
} catch (error) {
Expand Down

0 comments on commit 21f50d0

Please sign in to comment.