Skip to content

Commit

Permalink
Merge pull request #43 from Serverless-Devs/zxy/dev-20240514
Browse files Browse the repository at this point in the history
feat: add --private for s registry list && fix: path error when props.code is not a str
  • Loading branch information
zxypro1 authored Jun 14, 2024
2 parents 3d6ec19 + f2f1c9f commit c0da294
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/credential/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/credential",
"version": "0.0.6",
"version": "0.0.7",
"description": "credential for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion packages/credential/src/actions/set/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ export interface ITencent extends IBaseOptions {
SecretKey: string;
}

export interface IVolcengine extends IBaseOptions {
AccessKey: string;
SecretKey: string;
}

export interface ICustom extends IBaseOptions {
keyList: string;
infoList: string;
}

export type ISetOptions = IBaseOptions | ICustom | IAlibaba | IAws | IBaidu | IHuawei | IAzure | IGoogle | ITencent | IGoogle;
export type ISetOptions = IBaseOptions | IVolcengine | ICustom | IAlibaba | IAws | IBaidu | IHuawei | IAzure | IGoogle | ITencent | IGoogle;

export type IResult = {
access: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/credential/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum PROVIDER {
alibaba = 'Alibaba Cloud',
baidu = 'Baidu Cloud',
huawei = 'Huawei Cloud',
volcengine = 'Volcengine',
aws = 'AWS',
azure = 'Azure',
google = 'Google Cloud',
Expand All @@ -19,6 +20,7 @@ export enum PROVIDER {
// 选择厂商
export const PROVIDER_LIST = [
{ name: 'Alibaba Cloud (alibaba)', value: PROVIDER.alibaba },
{ name: 'Volcengine (volcengine)', value: PROVIDER.volcengine },
{ name: 'AWS (aws)', value: PROVIDER.aws },
{ name: 'Azure (azure)', value: PROVIDER.azure },
{ name: 'Baidu Cloud (baidu)', value: PROVIDER.baidu },
Expand All @@ -37,6 +39,7 @@ export const PROVIDER_DOCS = {
[PROVIDER.baidu]: 'http://config.devsapp.net/account/baidu',
[PROVIDER.google]: 'http://config.devsapp.net/account/gcp',
[PROVIDER.tencent]: 'http://config.devsapp.net/account/tencent',
[PROVIDER.volcengine]: 'https://www.volcengine.com/docs/6291/65568',
};

// 厂商密钥Key列表
Expand All @@ -48,6 +51,7 @@ export const PROVIDER_CREDENTIAL_KEYS = {
[PROVIDER.baidu]: ['AccessKeyID', 'SecretAccessKey'],
[PROVIDER.google]: ['PrivateKeyData'],
[PROVIDER.tencent]: ['AccountID', 'SecretID', 'SecretKey'],
[PROVIDER.volcengine]: ['AccessKey', 'SecretKey'],
};

export const CRYPTO_STRING = 'SecretKey123';
Expand Down
2 changes: 1 addition & 1 deletion packages/parse-spec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/parse-spec",
"version": "0.0.26",
"version": "0.0.27",
"description": "a parse yaml spec lib for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions packages/parse-spec/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getDefaultYamlPath, isExtendMode } from './utils';
const compile = require('@serverless-devs/art-template/lib/devs-compile');
import Order from './order';
import ParseContent from './parse-content';
import { each, filter, find, get, has, includes, isArray, isEmpty, keys, map, set, split } from 'lodash';
import { each, filter, find, get, has, includes, isArray, isEmpty, isString, keys, map, set, split } from 'lodash';
import { ISpec, IYaml, IActionType, IActionLevel, IStep, IRecord } from './types';
import { ENVIRONMENT_FILE_NAME, ENVIRONMENT_FILE_PATH, ENVIRONMENT_KEY, REGX } from './contants';
import assert from 'assert';
Expand Down Expand Up @@ -56,7 +56,8 @@ class ParseSpec {

// 兼容2.0: 加入项目的.env环境变量
for (const i of this.yaml.projectNames) {
if (get(projects, `${i}.props.code`)) {
const code = get(projects, `${i}.props.code`);
if (code && isString(code)) {
const codePath = utils.getAbsolutePath(get(projects, `${i}.props.code`, ''));
expand(dotenv.config({ path: path.join(codePath, '.env') }));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/registry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/registry",
"version": "0.0.9",
"version": "0.0.10",
"description": "request for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
9 changes: 6 additions & 3 deletions packages/registry/src/actions/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import zip from '@serverless-devs/zip';
import { getRootHome, registry } from '@serverless-devs/utils';
import fs from 'fs';
import { getYamlContentText, getContentText, request } from '../util';
import { PUBLISH_URL } from '../request-url';
import { PUBLISH_URL, PRIVATE_LIST_URL } from '../request-url';
import logger from '../util/logger';
import path from 'path';
import yaml from 'js-yaml';
Expand Down Expand Up @@ -165,13 +165,16 @@ export interface IList {
tag?: string;
search?: string;
page?: string;
private?: boolean;
}

export const list = async (options?: IList) => {
const headers = registry.getSignHeaders();
const qs = querystring.stringify((options || {}) as any);
const uri = `${PUBLISH_URL}?${qs}`;
const { private: _private, ...rest } = options || {};
const qs = querystring.stringify((rest || {}) as any);
const uri = _private ? `${PRIVATE_LIST_URL}?${qs}` : `${PUBLISH_URL}?${qs}`;

logger.debug(`Get registry list uri: ${uri}`);
const { body, request_id } = await request.new_request_get(uri, headers);
logger.debug(`Get registry list responseId: ${request_id}`);

Expand Down
3 changes: 3 additions & 0 deletions packages/registry/src/request-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export const RESET_URL = `${baseUrl}/user/token`;
// *** 发布 *** //
export const PUBLISH_URL = `${baseUrl}/packages/releases`;

// *** 用户Packages查找 *** //
export const PRIVATE_LIST_URL = `${baseUrl}/package/user`;

// *** 指定仓库详情 *** //
export const getDetailUrl = (name: string) => `${baseUrl}/packages/${name}/release`;

Expand Down

0 comments on commit c0da294

Please sign in to comment.