Skip to content

Commit

Permalink
fix: [Task]: 软件包列表添加按钮: 验证信息, 用于管理.steedos 下的.npmrc内容 #5617
Browse files Browse the repository at this point in the history
fix: [Task]: 手动安装软件包表单调整 #5618
|[Task]: 安装软件包不自动启用 #5619
  • Loading branch information
baozhoutao committed Nov 3, 2023
1 parent be21084 commit 96fc08e
Show file tree
Hide file tree
Showing 20 changed files with 386 additions and 270 deletions.
11 changes: 9 additions & 2 deletions packages/standard-objects/base.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ Steedos.StandardObjects = {
},
standard_new:{
visible: function (object_name) {
var permissions;
permissions = Creator.getPermissions(object_name);
var permissions = Creator.getPermissions(object_name);
if (permissions) {
return permissions["allowCreate"];
}
}
},
standard_edit:{
visible: function (object_name, record_id, record_permissions) {
var permissions = Creator.getPermissions(object_name);
if (permissions && permissions["allowEdit"] != true) {
return false;
}
var perms, record;
perms = {};
if (record_permissions) {
Expand All @@ -36,6 +39,10 @@ Steedos.StandardObjects = {
},
standard_delete:{
visible: function (object_name, record_id, record_permissions) {
var permissions = Creator.getPermissions(object_name);
if (permissions && permissions["allowDelete"] != true) {
return false;
}
var perms, record;
perms = {};
if (record_permissions) {
Expand Down
20 changes: 19 additions & 1 deletion services/service-package-registry/main/default/manager/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ const packagesFilePath = path.join(userDir, 'steedos-packages.yml');
const metadataApi = require('@steedos/metadata-api');
const util = require('./util');
const metaDataCore = require('@steedos/metadata-core');
const npmRCFilePath = path.join(userDir, '.npmrc')

// 读取.steedos下的.npmrc文件内容
const getNpmrc = ()=>{
let npmrc = "";
if(fs.existsSync(npmRCFilePath)){
npmrc = fs.readFileSync(npmRCFilePath, 'utf8')
}
return npmrc;
}

// 写入.steedos下的.npmrc文件内容
const setNpmrc = (data)=>{
fs.writeFileSync(npmRCFilePath, data);
}

const getPackageYmlData = (packagePath)=>{
let packageYmlData = {};
Expand Down Expand Up @@ -405,5 +420,8 @@ module.exports = {
getPackageInfo,
getPackageMetadata,
installPackage,
getPackageYmlData
getPackageYmlData,
getNpmrc,
setNpmrc,
getPackageConfig
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ const scanPackageMetadatas = async (packagePath) => {
return packageMetadatas;
}

const checkDependencies = async (packagePath)=>{
const packageServiceConfig = require(path.join(packagePath, 'package.service.js'));
const dependencies = (packageServiceConfig && packageServiceConfig.dependencies) || [];
const checkDependencies = async (packagePath, dependencies)=>{
if(!dependencies){
const packageServiceConfig = require(path.join(packagePath, 'package.service.js'));
dependencies = (packageServiceConfig && packageServiceConfig.dependencies) || [];
}
for(const item of dependencies){
const hasService = await objectql.getSteedosSchema().broker.registry.hasService(item);
if(!hasService){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ let installDenyList = [];
let installAllAllowed = true;
let installVersionRestricted = false;
var activePromise = Promise.resolve();
const _ = require('lodash');
const npa = require("npm-package-arg");

log.init({});

Expand Down Expand Up @@ -268,6 +270,27 @@ async function installModule(module, version, url, registry_url) {
return activePromise;
}

async function yarnAddPackage(yarnPackage){
var installDir = settings.userDir || ".";
var yarnArgs = ['add', '-E', ...yarnPackage.split(' '), '--json'];
const data = await exec.run(yarnCommand, yarnArgs, {cwd: installDir}, true);
const formatData = JSON.parse(_.last(_.compact(data.stdout.split('\n'))))
// 解析 yarn add 返回的结果
const steedosPackages = [];
_.each(formatData.data.trees, (module)=>{
const parsed = npa(module.name);
const packagePath = path.dirname(require.resolve(`${parsed.name}/package.json`, {
paths: [path.join(installDir, 'node_modules')]
}))
steedosPackages.push({
name: parsed.name,
version: parsed.rawSpec,
path: packagePath
})
})
return steedosPackages;
}


async function uninstallModule(module){
if (Buffer.isBuffer(module)) {
Expand Down Expand Up @@ -326,5 +349,6 @@ const isPackageUrl = (url)=>{
module.exports = {
installModule,
uninstallModule,
isPackageUrl
isPackageUrl,
yarnAddPackage
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: dependencies
type: select
multiple: true
label: 依赖项
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,42 @@
"mode": "read",
"className": "mb-4",
"excludedFields": [
"metadata"
"metadata",
"dependencies"
]
}
],
"className": "p-0",
"id": "u:5d4e7e3f6ecc"
},
{
"title": "依赖服务",
"body": [
{
"type": "steedos-object-form",
"label": "对象表单",
"objectApiName": "${objectName}",
"recordId": "${recordId}",
"appId": "${appId}",
"id": "u:fec578db3278",
"mode": "read",
"className": "mb-4",
"fields": [
"dependencies"
],
"fieldsExtend": {
"dependencies": {
"label": false,
"amis": {
"type": "tpl",
"tpl": "${dependencies | join: }"
}
}
}
}
],
"className": "p-0",
"id": "u:5d4e7e3f6ecc"
}
],
"id": "u:148cf8e840eb"
Expand Down
166 changes: 0 additions & 166 deletions services/service-package-registry/main/default/routes/nodes.router.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit 96fc08e

Please sign in to comment.