Commit c1dccfb9 authored by nano's avatar nano

actions

parent b5cebf79
This diff is collapsed.
aria2c --conf-path=/usr/src/app/aria2.conf -D;
./ossutil config --endpoint oss-cn-hangzhou.aliyuncs.com --access-key-id $OSS_ACCESS_ID
--access-key-secret $OSS_ACCESS_KEY;
ossutil config --endpoint oss-cn-hangzhou.aliyuncs.com --access-key-id $OSS_ACCESS_ID --access-key-secret $OSS_ACCESS_KEY;
npm start
......@@ -26,6 +26,8 @@ interface File {
export interface App {
id: string;
status: string;
author: string;
name?: I18n<string>;
description?: I18n<string>;
developers?: I18n<[{ name: string, url: string }]>;
......@@ -48,7 +50,7 @@ export interface App {
cover?: string;
background?: string;
// packages?: Package[];
created_at: Date;
created_at?: Date;
}
@Collection('apps')
......@@ -56,6 +58,10 @@ export interface App {
export class AppSchema extends Instance<App, AppSchema> implements App {
@Property(String, true)
id: string;
@Property(String, true)
status: string;
@Property(String, true)
author: string;
@Property(Object, false)
name?: I18n<string>;
@Property(Object, false)
......
import Router = require('koa-router');
import {mongodb} from '../models/Iridium';
import {App, AppSchema} from '../models/App';
import {App} from '../models/App';
import {Context} from 'koa';
import * as joi from 'joi';
import {promisify as py} from 'bluebird';
const router = new Router();
router.get('/v2/apps', async (ctx: Context, next) => {
......@@ -24,7 +26,12 @@ router.get('/v1/apps', async (ctx: Context, next) => {
});
router.post('/v1/app/:id', async (ctx: Context, next) => {
let payload = ctx.request.body;
let payload: App = {
id: ctx.request.body.id,
name: ctx.request.body.name,
author: ctx.request.body.author,
status: 'editing',
};
if (!payload.id) {
ctx.throw(400, 'params error');
}
......@@ -37,7 +44,7 @@ router.post('/v1/app/:id', async (ctx: Context, next) => {
}
try {
ctx.body = await mongodb.Apps.insert(payload);
ctx.body = await mongodb.Apps.create(payload);
} catch (e) {
ctx.throw(400, e);
}
......@@ -49,9 +56,22 @@ router.patch('/v1/app/:id', async (ctx: Context, next) => {
if (!app) {
return ctx.throw(400, `App ${ctx.params.id} Not Found `);
}
if (!ctx.request.body.id || ctx.request.body.id !== app.id) {
if (!_app.id || _app.id !== app.id) {
ctx.throw(400, `Can not change AppID`);
}
if (_app.status == 'ready') {
try {
await py(joi.validate)(_app, joi.object().keys({
action: joi.object().keys({
win32: joi.object().required(),
darwin: joi.object().required()
}).required(),
}).required());
} catch (e) {
e.message = '资料尚未填写完毕或格式有误';
return ctx.throw(e);
}
}
app.handleUpdate(_app);
......
......@@ -21,7 +21,7 @@ export function renderChecksum(files: { path: string, hash?: string }[]) {
export function UploadOSS(dist: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
let child = child_process.spawn('ossutil', ['cp', dist, 'oss://mycard/test-release'], {stdio: 'inherit'});
let child = child_process.spawn('ossutil', ['cp', '--recursive', dist, 'oss://mycard/test-release'], {stdio: 'inherit'});
child.on('exit', (code) => {
if (code == 0) {
resolve();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment