Skip to content

Commit

Permalink
refactor: 更新插件配置文件中的环境变量名
Browse files Browse the repository at this point in the history
更新插件配置文件中的环境变量名,将原先的 MALAGU_DOMAIN、MALAGU_REGION、MALAGU_ACCESS_KEY_ID 等变量名改为 CELL_DOMAIN、CELL_REGION、CELL_ACCESS_KEY_ID 等变量名,以与其他组件保持一致。
  • Loading branch information
muxiangqiu committed Oct 13, 2024
1 parent 652f96a commit 9375349
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 45 deletions.
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@

## 2.51.3

- feat(scf-plugin) 支持 MALAGU_APP_ID 环境变量
- feat(scf-plugin) 支持 CELL_APP_ID 环境变量

## 2.51.2

Expand Down Expand Up @@ -596,7 +596,7 @@ cell:

## 2.24.0

- feat(config) 新增 @celljs/config 组件,用于提供运行时的配置属性方式。包含以下运行时配置属性策略:通过环境变量 MALAGU_PROPS_FILE 配置属性文件位置和尝试从 process.cwd() 和 __dirname 目录下加载 cell.yml 和 cell.yaml 配置文件
- feat(config) 新增 @celljs/config 组件,用于提供运行时的配置属性方式。包含以下运行时配置属性策略:通过环境变量 CELL_PROPS_FILE 配置属性文件位置和尝试从 process.cwd() 和 __dirname 目录下加载 cell.yml 和 cell.yaml 配置文件

## 2.23.3

Expand Down Expand Up @@ -763,7 +763,7 @@ cell:
## 2.16.0

- feat(cli) 支持根命令参数 `--props-dir` 和 `--props-file`,用于指定额外的自定义属性文件位置,优先级比项目级别的属性文件高,方便开发者透传属性配置
- fix(cli) 把全局属性配置文件改为全局配置目录,基于环境变量 `GLOBAL_MALAGU_PROPS_DIR_PATH` 自定义,默认是 `~/.cell`
- fix(cli) 把全局属性配置文件改为全局配置目录,基于环境变量 `GLOBAL_CELL_PROPS_DIR_PATH` 自定义,默认是 `~/.cell`

## 2.15.2

Expand Down Expand Up @@ -808,7 +808,7 @@ cell:

## 2.13.0

- feat(cli + cli-common) 支持全局配置文件,默认全局配置文件路径为: `~/.cell/cell.yml`,可以通过环境变量自定义:`GLOBAL_MALAGU_CONFIG_PATH`
- feat(cli + cli-common) 支持全局配置文件,默认全局配置文件路径为: `~/.cell/cell.yml`,可以通过环境变量自定义:`GLOBAL_CELL_CONFIG_PATH`
- feat(cli + cli-common) 支持配置属性 `projectPath`,可以在配置文件中指定项目的真正工作目录,该配置项只在命令行的工作目录的配置文件有效

## 2.12.0
Expand Down Expand Up @@ -1021,7 +1021,7 @@ cell:

- feat(framework) 优化 `cell` 框架的默认构建目录
- fix(cli) 优化 `cell init` 命令初始化模板后没有正确安装依赖包
- fix(cli-common) 提供环境变量 `MALAGU_PROJECT_DIST_PATH` 配置项目构建目录
- fix(cli-common) 提供环境变量 `CELL_PROJECT_DIST_PATH` 配置项目构建目录

## 2.5.2

Expand All @@ -1044,8 +1044,8 @@ cell:

## 2.4.4

- feat(cli-common) 提供 `MALAGU_CONFIG_FILE_ALIAS` 环境变量方式配置,优先级比配置文件高
- feat(cli) 提供 `MALAGU_BANNER` 环境变量方式配置,优先级比配置文件高
- feat(cli-common) 提供 `CELL_CONFIG_FILE_ALIAS` 环境变量方式配置,优先级比配置文件高
- feat(cli) 提供 `CELL_BANNER` 环境变量方式配置,优先级比配置文件高
- fix(cloud-plugin) 修复 `profile.credentials.token` 赋值
- fix(*-plugin) 优化日志输出和自定义域名配置

Expand Down Expand Up @@ -1454,7 +1454,7 @@ cell:

## v1.18.6

- feat(fc-adapter) support `MALAGU_DOMAIN` environment variables
- feat(fc-adapter) support `CELL_DOMAIN` environment variables

## v1.18.5

Expand Down
6 changes: 3 additions & 3 deletions cloud-packages/faas-adapter/src/node/credentials-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class FaaSCredentialsProvider extends DefaultCredentialsProvider {
return credentials;
}
return {
accessKeyId: process.env.MALAGU_ACCESS_KEY_ID!,
accessKeySecret: process.env.MALAGU_ACCESS_KEY_SECRET!,
token: process.env.MALAGU_TOKEN
accessKeyId: process.env.CELL_ACCESS_KEY_ID!,
accessKeySecret: process.env.CELL_ACCESS_KEY_SECRET!,
token: process.env.CELL_TOKEN
};
}

Expand Down
2 changes: 1 addition & 1 deletion cloud-packages/faas-adapter/src/node/regin-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export class FaaSRegionProvider extends DefaultRegionProvider {
if (region) {
return region;
}
return process.env.MALAGU_REGION;
return process.env.CELL_REGION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ComponentPackageLoader {

protected parseConfigPaths(nodePackage: NodePackage, mode?: string): string[] {
const configFileAliases = ComponentUtil.getComponentAlias(nodePackage.keywords);
const configFileAlias = process.env.MALAGU_CONFIG_FILE_ALIAS || this.pkg.settings?.configFileAlias;
const configFileAlias = process.env.CELL_CONFIG_FILE_ALIAS || this.pkg.settings?.configFileAlias;
if (configFileAlias) {
configFileAliases.push(configFileAlias);
}
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/cli-common/src/package/package-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Command } from 'commander';
import { Settings } from '../settings/settings-protocol';
import { Framework } from '@celljs/frameworks/lib/detector/detector-protocol';

export const MALAGU_COMPONENT_SUFFIX = '-component';
export const CELL_COMPONENT_SUFFIX = '-component';

export type ApplicationLog = (message?: any, ...optionalParams: any[]) => void;

Expand Down Expand Up @@ -124,6 +124,6 @@ export namespace RawComponentPackage {
if (!pck.keywords.includes('cell')) {
return false;
}
return pck.keywords.some(k => k.endsWith(MALAGU_COMPONENT_SUFFIX));
return pck.keywords.some(k => k.endsWith(CELL_COMPONENT_SUFFIX));
}
}
2 changes: 1 addition & 1 deletion dev-packages/cli-common/src/settings/settings-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DEFAULT_SETTINGS, Settings } from './settings-protocol';

export namespace SettingsUtil {
export function getSettingsPath() {
return process.env.MALAGU_SETTINGS_PATH ? process.env.MALAGU_SETTINGS_PATH : path.join(PathUtil.getCellHomePath(), 'settings.yml');
return process.env.CELL_SETTINGS_PATH ? process.env.CELL_SETTINGS_PATH : path.join(PathUtil.getCellHomePath(), 'settings.yml');
}

function doGetSettings(): Settings {
Expand Down
6 changes: 3 additions & 3 deletions dev-packages/cli-common/src/utils/component-util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync, existsSync } from 'fs-extra';
import * as lockfile from '@yarnpkg/lockfile';
import * as path from 'path';
import { MALAGU_COMPONENT_SUFFIX } from '../package/package-protocol';
import { CELL_COMPONENT_SUFFIX } from '../package/package-protocol';
const chalk = require('chalk');

export namespace ComponentUtil {
Expand Down Expand Up @@ -56,8 +56,8 @@ export namespace ComponentUtil {

export function getComponentAlias(keywords: string[] = []): string[] {
const keywordsAlias = keywords
.filter(k => k.endsWith(MALAGU_COMPONENT_SUFFIX))
.map(k => k.substring(0, k.length - MALAGU_COMPONENT_SUFFIX.length));
.filter(k => k.endsWith(CELL_COMPONENT_SUFFIX))
.map(k => k.substring(0, k.length - CELL_COMPONENT_SUFFIX.length));
return keywordsAlias.includes('cell') ? keywordsAlias : [ ...keywordsAlias, 'cell' ];
}
}
Expand Down
20 changes: 10 additions & 10 deletions dev-packages/cli-common/src/utils/path-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export namespace PathUtil {
}

export function getProjectDistPath() {
if (process.env.MALAGU_PROJECT_DIST_PATH) {
return path.resolve(process.cwd(), process.env.MALAGU_PROJECT_DIST_PATH);
if (process.env.CELL_PROJECT_DIST_PATH) {
return path.resolve(process.cwd(), process.env.CELL_PROJECT_DIST_PATH);
}
return path.resolve(getProjectHomePath(), 'dist');
}
Expand Down Expand Up @@ -41,8 +41,8 @@ export namespace PathUtil {
}

export function getProjectHomePath() {
if (process.env.MALAGU_PROJECT_HOME_PATH) {
return path.resolve(process.cwd(), process.env.MALAGU_PROJECT_HOME_PATH);
if (process.env.CELL_PROJECT_HOME_PATH) {
return path.resolve(process.cwd(), process.env.CELL_PROJECT_HOME_PATH);
}
let keywords = [];
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
Expand All @@ -56,31 +56,31 @@ export namespace PathUtil {
}

export function getProjectConfigPath() {
return process.env.MALAGU_PROJECT_CONFIG_PATH ? path.resolve(process.cwd(), process.env.MALAGU_PROJECT_CONFIG_PATH) : path.resolve(getProjectHomePath(), 'project.json');
return process.env.CELL_PROJECT_CONFIG_PATH ? path.resolve(process.cwd(), process.env.CELL_PROJECT_CONFIG_PATH) : path.resolve(getProjectHomePath(), 'project.json');
}

export function setProjectHomePath(projectHomePath: string) {
process.env.MALAGU_PROJECT_HOME_PATH = projectHomePath;
process.env.CELL_PROJECT_HOME_PATH = projectHomePath;
}

export function getCellHomePath() {
return process.env.MALAGU_HOME_PATH ? process.env.MALAGU_HOME_PATH : path.join(homedir(), '.cell');
return process.env.CELL_HOME_PATH ? process.env.CELL_HOME_PATH : path.join(homedir(), '.cell');
}

export function getGlobalCellPropsDirPath() {
return process.env.GLOBAL_MALAGU_PROPS_DIR_PATH ? process.env.GLOBAL_MALAGU_PROPS_DIR_PATH : getCellHomePath();
return process.env.GLOBAL_CELL_PROPS_DIR_PATH ? process.env.GLOBAL_CELL_PROPS_DIR_PATH : getCellHomePath();
}

export function getRuntimePath(runtime?: string) {
if (runtime) {
const basePath = process.env.MALAGU_RUNTIME_PATH ? process.env.MALAGU_RUNTIME_PATH : path.resolve(getCellHomePath(), 'runtimes');
const basePath = process.env.CELL_RUNTIME_PATH ? process.env.CELL_RUNTIME_PATH : path.resolve(getCellHomePath(), 'runtimes');
return path.resolve(basePath, RuntimeUtil.getVersion(), runtime);
}
return process.cwd();
}

export function getRuntimeRootPath(version?: string) {
const basePath = process.env.MALAGU_RUNTIME_PATH ? process.env.MALAGU_RUNTIME_PATH : path.resolve(getCellHomePath(), 'runtimes');
const basePath = process.env.CELL_RUNTIME_PATH ? process.env.CELL_RUNTIME_PATH : path.resolve(getCellHomePath(), 'runtimes');
return version ? path.resolve(basePath, RuntimeUtil.getVersion()) : basePath;
}

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/src/cell-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function execute() {
join(projectPath, '..', '..', '..', 'node_modules')
]));

process.env.MALAGU_RFS = JSON.stringify({ runtime, settings, framework });
process.env.CELL_RFS = JSON.stringify({ runtime, settings, framework });
const runtimePath = PathUtil.getRuntimePath(runtime);
if (runtimePath !== projectPath) {
nodePaths.push(join(runtimePath, 'node_modules'));
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ updateNotifier({ pkg }).notify();
const spinner = ora({ text: chalk.italic.gray('loading command line context...\n'), discardStdin: false });

(async () => {
const { runtime, framework, settings } = JSON.parse(process.env.MALAGU_RFS!);
const { runtime, framework, settings } = JSON.parse(process.env.CELL_RFS!);
BannerUtil.print(version, settings, runtime, framework);

spinner.start();
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/src/utils/banner-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export namespace BannerUtil {
runtimeStrLine = '\n│';
runtimeStrLine += chalk.yellow.bold(runtimeStr.padStart(20 + Math.floor(runtimeStr.length / 2)).padEnd(40)) + '│';
}
const banner = process.env.MALAGU_BANNER || settings.banner;
const banner = process.env.CELL_BANNER || settings.banner;
if (banner) {
console.log(banner.replace('{ version }', version).replace('{ runtime }', runtimeStr));
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/config/src/node/runtime-context-initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { resolve } from 'path';
export class RuntimeContextInitializer implements ContextInitializer {

protected doInitializeForEnv(ctx: ExpressionContext) {
if (process.env.MALAGU_PROPS_FILE) {
const propsFile = resolve(process.cwd(), process.env.MALAGU_PROPS_FILE);
if (process.env.CELL_PROPS_FILE) {
const propsFile = resolve(process.cwd(), process.env.CELL_PROPS_FILE);
if (existsSync(propsFile)) {
const props = load(readFileSync(propsFile, 'utf-8'));
ConfigUtil.merge(ctx, props);
Expand Down
2 changes: 1 addition & 1 deletion packages/security/src/node/cache/cache-protocol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpMethod } from '@celljs/http';

export const RequestCache = Symbol('RequestCache');
export const SAVED_REQUEST = 'MALAGU_SECURITY_SAVED_REQUEST';
export const SAVED_REQUEST = 'CELL_SECURITY_SAVED_REQUEST';

export interface SavedRequest {
redirectUrl: string;
Expand Down
8 changes: 4 additions & 4 deletions plugins/cloud-plugin/src/hooks/profile-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export class DefaultProfileProvider implements ProfileProvider {

protected async getProfileFromEnv(): Promise<Profile> {
return <Profile>{
region: process.env.MALAGU_REGION,
region: process.env.CELL_REGION,
credentials: {
accessKeyId: process.env.MALAGU_ACCESS_KEY_ID,
accessKeySecret: process.env.MALAGU_ACCESS_KEY_SECRET
accessKeyId: process.env.CELL_ACCESS_KEY_ID,
accessKeySecret: process.env.CELL_ACCESS_KEY_SECRET
},
account: {
id: process.env.MALAGU_ACCOUNT_ID
id: process.env.CELL_ACCOUNT_ID
}

};
Expand Down
2 changes: 1 addition & 1 deletion plugins/fc-plugin/cell-http-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cell:
authType: anonymous
methods: [GET, POST, PUT, DELETE, HEAD, PATCH]
customDomain:
name: ${env.MALAGU_DOMAIN || 'auto'}
name: ${env.CELL_DOMAIN || 'auto'}
protocol: HTTP
certConfig:
# certName: xxx
Expand Down
2 changes: 1 addition & 1 deletion plugins/fc-plugin/cell-sample-http-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cell:
authType: anonymous
methods: [GET, POST, PUT, DELETE, HEAD, PATCH]
customDomain:
name: ${env.MALAGU_DOMAIN || 'auto'}
name: ${env.CELL_DOMAIN || 'auto'}
protocol: HTTP
certConfig:
# certName: xxx
Expand Down
2 changes: 1 addition & 1 deletion plugins/fc3-plugin/cell-http-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cell:
authType: anonymous
methods: [GET, POST, PUT, DELETE, HEAD, PATCH]
customDomain:
name: ${env.MALAGU_DOMAIN || 'auto'}
name: ${env.CELL_DOMAIN || 'auto'}
protocol: HTTP
certConfig:
# certName: xxx
Expand Down
2 changes: 1 addition & 1 deletion plugins/fc3-plugin/cell-sample-http-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cell:
authType: anonymous
methods: [GET, POST, PUT, DELETE, HEAD, PATCH]
customDomain:
name: ${env.MALAGU_DOMAIN || 'auto'}
name: ${env.CELL_DOMAIN || 'auto'}
protocol: HTTP
certConfig:
# certName: xxx
Expand Down
2 changes: 1 addition & 1 deletion plugins/python-plugin/src/packager/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function findTestFile(servicePath: string, options: PythonPluginOptions)
}

async function tryBindPath(bindPath: string, testFile: string, pluginOptions: PythonPluginOptions) {
const debug = process.env.MALAGU_DEBUG;
const debug = process.env.CELL_DEBUG;
const options = [
'run',
'--rm',
Expand Down
2 changes: 1 addition & 1 deletion plugins/scf-plugin/src/hooks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async (context: DeployContext) => {
const cloudConfig = CloudUtils.getConfiguration(cfg);

const profileProvider = new DefaultProfileProvider();
const { region, credentials, account, appId = process.env.MALAGU_APP_ID } = await profileProvider.provide(cloudConfig) as (Profile & { appId?: string });
const { region, credentials, account, appId = process.env.CELL_APP_ID } = await profileProvider.provide(cloudConfig) as (Profile & { appId?: string });

const clients = await createClients(cloudConfig, region, credentials);
cosClient = clients.cosClient;
Expand Down

0 comments on commit 9375349

Please sign in to comment.