Skip to content

Commit

Permalink
Merge branch 'release/0.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Definitely-Not-Vlad committed Jun 29, 2020
2 parents 1e7664b + 9d59aa7 commit b0457b9
Show file tree
Hide file tree
Showing 60 changed files with 181 additions and 182 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Shoutem CLI

Shoutem CLI is a command line tool which helps you build Shoutem extensions.

You can read more about CLI in our [documentation](http://shoutem.github.io/docs/extensions/reference/cli)

## Local Development

For local development there are three ways of approaching this:

#### 1. Compiling and running from the repository

1. Run `npm i` inside repository
2. Run `node path/to/build/shoutem.js <command>`, where `<command>` is the command you're testing

After making changes to the code, you can run `rm -rf build && npm run build` to recompile and then continue using step 2 described above.

#### 2. Editing global node_modules

While messy and harder to keep track of changes (since you can't see the diff directly), this has proven effective. You can make changes in your global `node_modules` directory on your machine in the `src` directory, then re-build the CLI using `npm run build` within the `cli` directory (where the package.json is).

#### 3. Installing via git commit hash

Prerequisites:
- babel-cli v6.8.0 installed globally on your machine
- commit should have `package.json` edited in such a way that the `prepare` script is replaced with a `preinstall` script

You can see the changes you've made with your code and how they affect the CLI by using `npm i -g shoutem/cli#<commit_hash>`, e.g.:
`npm i -g shoutem/cli#6874qbr`

This can also be used for testing before release, unlike the other two methods.

**NOTE:** Once a release is ready, make sure to turn the preinstall script back into a prepare script as users may not have babel-cli installed.
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"name": "@shoutem/cli",
"version": "0.13.0",
"version": "0.13.1",
"description": "Command-line tools for Shoutem applications",
"repository": {
"type": "git",
"url": "https://github.com/shoutem/cli"
},
"bin": {
"shoutem": "./src/shoutem.js"
"shoutem": "./build/shoutem.js"
},
"scripts": {
"beta": "npm publish --access public --tag beta",
"build": "babel ./src --ignore ./src/templates --out-dir build --source-maps inline --copy-files",
"extlint": "eslint",
"hotfix": "npm publish --access public --tag hotfix",
"lint": "eslint ./",
"prepublish": "dos2unix src/shoutem.js",
"shoutem": "node src/shoutem.js",
"lint": "eslint ./ --ignore-pattern build --ignore-pattern templates",
"prepare": "npm run build",
"shoutem": "node build/shoutem.js",
"test": "mocha -R spec --require fetch-everywhere --compilers js:babel-core/register \"src/**/*spec.js\""
},
"author": "",
Expand Down
4 changes: 2 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ analytics.setArgv(process.argv);
const cli = yargs.usage('Usage: shoutem [command] [-h]')
.option('version', {
alias: 'v',
description: 'Show version number'
description: 'Shows version number.'
})
.commandDir('cli')
.strict()
.help()
.epilog(`If you don't have a developer account, you can register at ${apiUrls.appBuilder.bold}.\n\n` +
`More detailed reference on how to use CLI can be found on the Developer Portal: ${cliReferenceUrl.bold}`)
`A more detailed reference on how to use CLI can be found on the Developer Portal: ${cliReferenceUrl.bold}.`)
.alias('help', 'h');

const argv = cli.argv;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import services from '../../config/services';
import {getPlatformConfig} from "../services/platform";
import {executeAndHandleError} from "../services/error-handler";

export const description = 'Opens the app in the shoutem builder dashboard using default browser';
export const description = 'Opens the app in the Shoutem Builder using the system default browser.';
export const command = 'builder [appId]';
export const builder = yargs => {
return yargs
Expand Down
10 changes: 5 additions & 5 deletions src/cli/clone.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { executeAndHandleError } from '../services/error-handler';
import { clone } from '../commands/clone';

export const description = 'Downloads a shoutem application with all it\'s extensions';
export const description = 'Downloads a Shoutem app with all it\'s extensions.';
export const command = 'clone [appId]';
export const builder = yargs => {
return yargs
.options({
platform: {

alias: 'p',
description: 'use external mobile app (ignores platform settings)',
description: 'Uses external mobile app (ignores platform settings).',
requiresArg: true
},
noconfigure: {
description: 'skip platform configuration step',
description: 'Skips platform configuration step.',
type: 'boolean'
},
dir: {
description: 'directory name for the cloned app',
description: 'Specifies directory name for the cloned app.',
requiresArg: true
},
force: {
alias: 'f',
description: 'destroys destination directory if it already exists',
description: 'Destroys destination directory if it already exists.',
type: 'boolean'
}
})
Expand Down
6 changes: 3 additions & 3 deletions src/cli/configure.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { executeAndHandleError } from '../services/error-handler';
import {configurePlatform, getPlatformConfig, getPlatformRootDir, setPlatformConfig} from '../services/platform';

export const description = 'Runs platform\'s configure script to sync with native changes to local extensions';
export const description = 'Runs the platform\'s configure script to install dependencies, link extensions and their dependencies and run extension build scripts.';
export const command = 'configure';
export const builder = yargs => {
return yargs
.options({
release: {
alias: 'r',
description: '(re)configure the app with last published configuration from the shoutem server',
description: '(Re)configures the app with the latest (re)published configuration from the Shoutem builder.',
type: 'boolean',
default: false
},
production: {
alias: 'p',
description: 'configure the app for production mode build',
description: 'Configures the app for production build, used when publishing to the App Store or the Google Play store',
type: 'boolean',
default: false
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/extension.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const description = 'Manage extensions within the current app';
export const description = 'Manages extensions within the current app.';
export const command = 'extension <command>';
export const builder = page => {
return page
Expand Down
11 changes: 5 additions & 6 deletions src/cli/extension/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const builder = yargs => {
return yargs
.options({
local: {
description: 'Extension is only added locally and is not published or installed on the shoutem server',
description: 'Extension is only added locally and is not published or installed on the Shoutem Builder',
type: 'boolean',
default: false
}
Expand All @@ -39,8 +39,8 @@ const postRunMessage =
${'shoutem theme add <themeName>'.cyan}
add a new theme
${'shoutem page add'.cyan}
add a new settings page
${'shoutem page add'.cyan}
add a new settings page
`;

export const handler = args => executeAndHandleError(() => addExtension(args));
Expand All @@ -66,8 +66,7 @@ export async function addExtension({ name, local, externalDestination }) {

const cdCommand = 'cd ' + path.relative(process.cwd(), extensionPath);
console.log('\nCongratulations, your new extension is ready!'.green.bold);
console.log(`You might try doing ${cdCommand.cyan} where you can:`);
console.log(`You can now do '${cdCommand.cyan}' where you can:`);
console.log(postRunMessage);
console.log('Success!'.green.bold);
console.log('Happy coding!');
console.log('Happy coding!\n');
}
2 changes: 1 addition & 1 deletion src/cli/extension/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {updateExtension, getInstallation, installExtension} from "../../clients/
import confirmer from "../../services/confirmer";
import {getExtension} from "../../clients/extension-manager";

export const description = 'Publish an extension from the app in the working directory';
export const description = 'Publishes an extension from the app in the specified or current working directory.';
export const command = 'publish <name>';
export const builder = yargs => {
return yargs
Expand Down
2 changes: 1 addition & 1 deletion src/cli/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {executeAndHandleError} from '../services/error-handler';
import {addExtension} from "./extension/add";

export const command = 'init <name>';
export const description = 'Create a scaffold of all files and folders required to build an extension.';
export const description = 'Creates a basic extension structure, with all the required files and folders.';
export const builder = yargs => {
return yargs.usage(`shoutem ${command}\n\n${description}`).strict();
};
Expand Down
6 changes: 3 additions & 3 deletions src/cli/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ import msg from '../user_messages';
import { ensureUserIsLoggedIn } from '../commands/login';
import { handleError } from '../services/error-handler';

export const description = 'Install the current extension to an application.';
export const description = 'Install the current extension to an app on the Shoutem Builder.';

export const command = 'install';
export const builder = yargs => {
return yargs
.options({
app: {
alias: 'a',
description: 'app id to install current extension to',
description: 'Specifies app id to install current extension to.',
requiresArg: true
},
new: {
alias: 'n',
description: 'install to a new app with given name',
description: 'Creates new app with the given name and installs the extension to it.',
type: 'string'
}})
.usage(`usage: shoutem ${command} [options]\n\n${description}`);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/last-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export async function handler() {
}));
console.log(`\nIf you think this error is caused by bug in the shoutem command, you can report the issue here: ${"https://github.com/shoutem/cli/issues".bold}`.yellow);
} else {
console.log('No error'.green);
console.log('No error.'.green);
}
}
2 changes: 1 addition & 1 deletion src/cli/login.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loginUser } from '../commands/login';
import { executeAndHandleError } from '../services/error-handler';

export const description = 'Log in and register as a Shoutem developer.\nProvide credentials in username:password format.';
export const description = 'Handles Shoutem developer\'s authentication. Users already registered as Shoutem developers are simply logged in and non-developer users are first registered as developers and then logged in. Credentials can be provided in the username:password format as a command argument to skip the interactive menu.';
export const command = 'login [credentials]';

export function handler(args) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/logout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logout from '../commands/logout';
import { executeAndHandleError } from '../services/error-handler';

export const description = 'Erase all locally stored credentials.';
export const description = 'Erases all locally stored credentials.';
export const command = 'logout';
export async function handler() {
await executeAndHandleError(logout);
Expand Down
4 changes: 2 additions & 2 deletions src/cli/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import shoutemPack from '../services/packer';
import { ensureInExtensionDir } from '../services/extension';
import { handleError } from '../services/error-handler';

export const description = 'Pack shoutem extensions for upload';
export const description = 'Packs a Shoutem extension for upload.';
export const command = 'pack';
export const builder = yargs => {
return yargs
.options({
nobuild: {
type: 'boolean',
description: 'Pack the extension without building it.'
description: 'Packs the extension without building it.'
}
})
.usage(`shoutem ${command} [options]\n\n${description}`);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const description = 'Manage settings pages';
export const description = 'Manages settings pages.';
export const command = 'page <command>';
export const builder = page => {
return page
Expand Down
2 changes: 1 addition & 1 deletion src/cli/page/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {askPageCreationQuestions} from "../../services/page";
import {instantiateExtensionTemplate} from "../../services/extension-template";
import {offerChanges} from "../../services/diff";

export const description = 'Add a settings page to current extension';
export const description = 'Adds a settings page to the current extension.';
export const command = 'add [name]';

export const handler = args => executeAndHandleError(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/platform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const description = 'Manage platforms';
export const description = 'Manages platforms.';
export const command = 'platform <command>';
export const builder = page => page
.commandDir('platform')
Expand Down
10 changes: 5 additions & 5 deletions src/cli/platform/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { uploadPlatformArchive } from '../../commands/platform';
import { createPlatformArchiveProvider } from '../../services/platform-archive';
import { platformMessages } from '../const';

export const description = 'Create a new platform';
export const description = 'Creates a new platform.';
export const command = 'create';
export const builder = yargs => yargs
.options({
Expand All @@ -25,12 +25,12 @@ export const builder = yargs => yargs

const postRunInstall = platformId => `
${`shoutem platform install --app [app ID] --platform ${platformId}`.cyan}
To install this platform on an app
To install this platform to an app.
`;

const postRunPublish = platformId => `
${`shoutem platform publish --platform ${platformId}`.cyan}
To publish this platform for everyone to use
To publish this platform to make it visible on the Builder.
`;

export const handler = args => executeAndHandleError(() => createPlatform(args));
Expand All @@ -56,12 +56,12 @@ export async function createPlatform({ url }) {

const { appId } = await getPlatformConfig();
if (!_.isNil(appId)) {
if (await confirmer(`Do you want to install the new platform to this app (${appId})?`)) {
if (await confirmer(`Do you want to install the new platform to app ${appId}?`)) {
await spinify(installPlatform({ app: appId, platform: platformResponse.id }));
installed = true;
}

console.log(`\nYou can manage your platforms for this app any time at https://builder.shoutem.com/app/${appId}/settings/platform`);
console.log(`\nYou can manage your platforms for this app any time at https://builder.shoutem.com/app/${appId}/settings/platform.`);
}

if (!published || !installed) {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/platform/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export const command = 'install';
export const builder = yargs => yargs
.options({
app: {
description: 'Id of the application to install the new platform to',
description: 'Installs new platform into app with given app id.',
type: 'number',
requiresArg: true,
alias: 'a',
},
platform: {
description: 'Id of platform to install',
description: 'Installs platform with given id.',
type: 'string',
requiresArg: true,
alias: 'p',
Expand Down
4 changes: 2 additions & 2 deletions src/cli/platform/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { ensureUserIsLoggedIn } from '../../commands/login';
import { getAvailablePlatforms } from '../../commands/platform';
import { executeAndHandleError } from '../../services/error-handler';

export const description = 'Lists available platforms';
export const description = 'Lists available platforms.';
export const command = 'list';
export const builder = yargs => yargs
.options({
all: {
description: 'Lists all available platforms',
description: 'Lists all available platforms.',
type: 'boolean',
alias: 'a',
},
Expand Down
4 changes: 2 additions & 2 deletions src/cli/platform/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { getAvailablePlatforms } from '../../commands/platform';
import { publishPlatform } from '../../clients/extension-manager';
import { executeAndHandleError } from '../../services/error-handler';

export const description = 'Publish a platform';
export const description = 'Publishes a platform.';
export const command = 'publish';
export const builder = yargs => yargs
.options({
platform: {
description: 'Id of platform to install',
description: 'Publishes platform with given id.',
type: 'string',
requiresArg: true,
alias: 'p',
Expand Down
Loading

0 comments on commit b0457b9

Please sign in to comment.