Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/engine",
"version": "0.1.5",
"version": "0.1.6-beta.1",
"description": "a engine lib for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ class Engine {
const spec = cloneDeep(this.spec);
spec['command'] = 'info';
// 20240912 when -f, don't throw error
const { f } = parseArgv(this.options.args);
const { f, force } = parseArgv(this.options.args);
let res = {}
if (f) {
if (f || force) {
try {
res = await this.doSrc(item, {}, spec);
} catch(e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/load-application/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@serverless-devs/load-application",
"version": "0.0.15",
"version": "0.0.16-beta.1",
"description": "load application for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
24 changes: 23 additions & 1 deletion packages/load-application/src/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,35 @@ class LoadApplication {
* 7. 解析 s.yaml里的 name 字段
*/
this.parseAppName(templateData as string);
/**
* 8. 解析目录下所有后缀为.stpl的文件
*/
await this.parseStpl(this.filePath);
/**
* 8. 最后的动作, 比如:删除临时文件夹
* 9. 最后的动作, 比如:删除临时文件夹
*/
await this.final();
return this.filePath;
}

// art-template解析目录下所有后缀为.stpl的文件
private async parseStpl(dirPath: string) {
const allFiles = fs.readdirSync(dirPath);
for (const file of allFiles) {
if (fs.statSync(path.join(dirPath, file)).isDirectory()) {
await this.parseStpl(path.join(dirPath, file));
continue;
}
if (file.endsWith('.stpl')) {
const filePath = path.join(dirPath, file);
const newData = this.doArtTemplate(filePath);
fs.writeFileSync(filePath, newData, 'utf-8');
// 删除.stpl后缀
fs.renameSync(filePath, filePath.replace('.stpl', ''));
}
}
}

private async check() {
if (this.options.y) return true;
if (isCiCdEnvironment()) return true;
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.11",
"version": "0.0.12-beta.4",
"description": "request for serverless-devs",
"main": "lib/index.js",
"scripts": {
Expand Down
28 changes: 19 additions & 9 deletions packages/registry/src/actions/package.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import zip from '@serverless-devs/zip';
import { getRootHome, registry } from '@serverless-devs/utils';
import { getRootHome, registry, parseArgv } from '@serverless-devs/utils';
import fs from 'fs';
import { getYamlContentText, getContentText, request } from '../util';
import { PUBLISH_URL, PRIVATE_LIST_URL } from '../request-url';
Expand Down Expand Up @@ -121,7 +121,6 @@ async function getUploadUrl(codeUri: string): Promise<string> {
readme_en: readmeEn,
readme,
};

const { body, request_id } = await request.new_request_post(PUBLISH_URL, requestBodyIRequest);
logger.debug(`Publish responseId: ${request_id}`);
if (typeof body === 'string') {
Expand Down Expand Up @@ -279,14 +278,25 @@ export const publish = async (codeUri: string) => {
if (zipResult.compressedSize > 10 * 1024 * 1024 && zipResult.compressedSize <= 20 * 1024 * 1024) {
logger.warn(`Package size is ${zipResult.compressedSize / 1024 / 1024}MB, which is larger than 10MB.`);
} else if (zipResult.compressedSize > 20 * 1024 * 1024) {
logger.error(`Package size is ${zipResult.compressedSize / 1024 / 1024}MB, which is larger than 20MB.`);
throw new Error('Package size is larger than 20MB. Please optimize your package.');
const argv = process.argv.slice(2);
const { f, force } = parseArgv(argv);
if (f || force) {
logger.warn(`Package size is ${zipResult.compressedSize / 1024 / 1024}MB, which is larger than 20MB.`);
} else {
logger.error(`Package size is ${zipResult.compressedSize / 1024 / 1024}MB, which is larger than 20MB.`);
throw new Error('Package size is larger than 20MB. Please optimize your package.');
}
}

// 上传压缩文件
await request.request_put(uploadUrl, zipResult.outputFile);
logger.write(`${chalk.green(`Publish package ${packageInfo} success.`)}`);
try {
// 上传压缩文件
await request.request_put(uploadUrl, zipResult.outputFile);
logger.write(`${chalk.green(`Publish package ${packageInfo} success.`)}`);

// 删除压缩文件
fs.unlinkSync(zipResult.outputFile);
// 删除压缩文件
fs.unlinkSync(zipResult.outputFile);
} catch (error) {
logger.debug(`Upload package ${packageInfo} failed: ${error}`);
throw new Error('Upload request error, please check your internet connection or registry setting.');
}
};
7 changes: 5 additions & 2 deletions packages/registry/src/request-url.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { getGlobalConfig } from "@serverless-devs/utils";
import { getGlobalConfig } from '@serverless-devs/utils';

const baseUrl = getGlobalConfig('registry', 'https://api.devsapp.cn/v3');
const baseUrl =
getGlobalConfig('registry', 'https://api.devsapp.cn/v3') === 'https://api.devsapp.cn/v3'
? 'https://server-serverlgistry-v-awljqvnszb.cn-hangzhou.fcapp.run/v3'
: getGlobalConfig('registry', 'https://api.devsapp.cn/v3');
// *** 登陆 *** //
// 登陆
export const REGISTRY_INFORMATION_GITHUB = `${baseUrl}/user/check`;
Expand Down
Loading