diff --git a/local-cli/cli.json b/local-cli/cli.json index 000f327..90304f9 100644 --- a/local-cli/cli.json +++ b/local-cli/cli.json @@ -35,7 +35,25 @@ }, "uploadIpa": { + }, + "uploadApk": { + }, + "publish": { + "options": { + "platform": { + "hasValue": true + }, + "name": { + "hasValue": true + }, + "description": { + "hasValue": true + }, + "metaInfo": { + "hasValue": true + } + } }, "build": { diff --git a/local-cli/src/index.js b/local-cli/src/index.js index b57c157..8180c9c 100644 --- a/local-cli/src/index.js +++ b/local-cli/src/index.js @@ -18,6 +18,7 @@ const commands = { ...require('./bundle').commands, ...require('./app').commands, ...require('./package').commands, + ...require('./versions').commands, help: printUsage, }; diff --git a/local-cli/src/package.js b/local-cli/src/package.js index 1703a11..335ec77 100644 --- a/local-cli/src/package.js +++ b/local-cli/src/package.js @@ -27,5 +27,22 @@ export const commands = { name, hash, }); - } + console.log('Ok.'); + }, + uploadApk: async function({args}) { + const fn = args[0]; + if (!fn) { + throw new Error('Usage: pushy uploadApk '); + } + const name = await getApkVersion(fn); + const {appId} = await getSelectedApp('android'); + + const {hash} = await uploadFile(fn); + + await post(`/app/${appId}/package/create`, { + name, + hash, + }); + console.log('Ok.'); + }, }; diff --git a/local-cli/src/versions.js b/local-cli/src/versions.js new file mode 100644 index 0000000..2ba07e4 --- /dev/null +++ b/local-cli/src/versions.js @@ -0,0 +1,32 @@ +/** + * Created by tdzl2003 on 4/2/16. + */ + +const { + get, + post, + uploadFile, +} = require('./api'); + +import { checkPlatform, getSelectedApp } from './app'; + +export const commands = { + publish: async function({args, options}) { + const fn = args[0]; + const {platform, name, description, metaInfo } = options; + if (!fn || !platform) { + throw new Error('Usage: pushy publish --platform ios|android'); + } + const {appId} = await getSelectedApp(platform); + + const {hash} = await uploadFile(fn); + + const {id} = await post(`/app/${appId}/version/create`, { + name, + hash, + description, + metaInfo, + }); + console.log('Ok.'); + }, +};