Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves cli to TypeScript and uses Inquirer.js #86

Merged
merged 2 commits into from
Jan 27, 2020
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
3,725 changes: 3,339 additions & 386 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@
"dependencies": {
"@types/color": "^3.0.0",
"@types/extract-zip": "^1.6.2",
"@types/inquirer": "^6.5.0",
"@types/jasmine": "^3.5.0",
"@types/lodash.template": "^4.4.6",
"@types/minimist": "^1.2.0",
"@types/node": "^12.12.14",
"@types/node-fetch": "^2.5.4",
"@types/tar": "^4.0.3",
"@types/valid-url": "^1.0.2",
"color": "^3.1.2",
"colors": "^1.4.0",
"extract-zip": "^1.6.7",
"inquirer": "^7.0.4",
"jimp": "^0.9.3",
"lodash.template": "^4.5.0",
"minimist": "^1.2.0",
"node-fetch": "^2.6.0",
"prompt": "^1.0.0",
"npm": "^6.13.6",
"tar": "^5.0.5",
"typescript": "^3.7.2",
"valid-url": "^1.0.9"
Expand Down
72 changes: 29 additions & 43 deletions src/cli/cmds/build.js → src/cli/cmds/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@
* limitations under the License.
*/

'use strict';
import {AndroidSdkTools} from '../../lib/androidSdk/AndroidSdkTools';
import {JdkHelper} from '../../lib/jdk/JdkHelper';
import {GradleWrapper} from '../../lib/GradleWrapper';
import {TwaManifest} from '../../lib/TwaManifest';
import {Config} from '../../lib/Config';
import Log from '../../lib/Log';
import * as inquirer from 'inquirer';
import {validatePassword} from '../inputHelpers';

const {AndroidSdkTools} = require('../../lib/androidSdk/AndroidSdkTools');
const {JdkHelper} = require('../../lib/jdk/JdkHelper');
const {GradleWrapper} = require('../../lib/GradleWrapper');
const {TwaManifest} = require('../../lib/TwaManifest');

const {promisify} = require('util');
const prompt = require('prompt');
const colors = require('colors/safe');
prompt.get = promisify(prompt.get);

async function build(_, config) {
export async function build(config: Config, log = new Log('build')): Promise<void> {
const jdkHelper = new JdkHelper(process, config);
const androidSdkTools = new AndroidSdkTools(process, config, jdkHelper);

Expand All @@ -36,58 +33,47 @@ async function build(_, config) {
}

const twaManifest = await TwaManifest.fromFile('./twa-manifest.json');
prompt.message = colors.green('[llama-pack-build]');
prompt.delimiter = ' ';
prompt.start();

const schema = {
properties: {
password: {
name: 'password',
required: true,
description: 'KeyStore password:',
hidden: true,
replace: '*',
},
keypassword: {
name: 'keypassword',
required: true,
description: 'Key password:',
hidden: true,
replace: '*',
},
},
};

// Ask user for the keystore password
const result = await prompt.get(schema);
const result = await inquirer.prompt([
{
name: 'password',
type: 'password',
message: 'KeyStore password:',
validate: validatePassword,
mask: '*',
}, {
name: 'keypassword',
type: 'password',
message: 'Key password:',
validate: validatePassword,
mask: '*',
},
]);

// Builds the Android Studio Project
console.log('Building the Android App...');
log.info('Building the Android App...');
const gradleWraper = new GradleWrapper(process, androidSdkTools);
await gradleWraper.assembleRelease();

// Zip Align
console.log('Zip Aligning...');
log.info('Zip Aligning...');
await androidSdkTools.zipalign(
'./app/build/outputs/apk/release/app-release-unsigned.apk', // input file
'./app-release-unsigned-aligned.apk', // output file
);

// And sign APK
console.log('Signing...');
log.info('Signing...');
const outputFile = './app-release-signed.apk';
await androidSdkTools.apksigner(
twaManifest.signingKey.path,
result.password, // keystore password
twaManifest.signingKey.alias, // alias
result.keypassword, // key password
'./app-release-unsigned-aligned.apk', // input file path
'./app-release-signed.apk', // output file path
outputFile,
outputFile, // output file path
);

console.log(`Signed Android App generated at "${outputFile}"`);
log.info(`Signed Android App generated at "${outputFile}"`);
}

module.exports = build;
7 changes: 2 additions & 5 deletions src/cli/cmds/help.js → src/cli/cmds/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* limitations under the License.
*/

'use strict';

async function help() {
export async function help(): Promise<void> {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help is a no-op?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now... Need to add actual help messages (I'll do in another PR. Focusing this one on translating JS => TS)

}

module.exports = help;
239 changes: 0 additions & 239 deletions src/cli/cmds/init.js

This file was deleted.

Loading