Skip to content

Commit

Permalink
Update docs. Remove github commands
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Sep 27, 2023
1 parent decf566 commit dae715f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 284 deletions.
33 changes: 16 additions & 17 deletions docs/introduction/cli.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# CLI Commands
There are many command line arguments available for the `commoners` tool.
The CLI commands for `commoners` share the same options structure:

- `--web` - Default option

- `--desktop` - For your current desktop platform
- `--mac` - For Mac
- `--windows` - For Windows
- `--linux` - For Linux

- `--mobile` - For the mobile platform corresponding to your build enviroment
- `--ios` - For iOS
- `--android` - For Android

## commoners
Start your project in development mode
- `--desktop` - As an Electron app on your current desktop platform

## commoners build
Build the project assets
- `--desktop` - For your current desktop platform
- `--pwa` - As a Progressive Web App
- `--ios` - For iOS
- `--android` - For Android

## commoners launch
Launch your built application
- `--desktop` - Start your desktop build
- `--ios` - Open the project with XCode
- `--android` - Open the project with Android Studio

## commoners commit
Commit your latest build to Github (coming soon)
### Additional Options
- `--pwa` - As a Progressive Web App

## commoners publish
Publish your latest commit to Github Pages (coming soon)
- `--message` - Add a commit message and trigger a new commit
## commoners launch
Launch your built application
23 changes: 10 additions & 13 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import chalk from "chalk";

// import { initGitRepo } from "./src/github/index.js";
import { onExit as processOnExit } from "../core/utils/processes.js";
import { cliArgs, command, COMMAND, PLATFORM, target, TARGET } from "../core/globals.js";
import { build, commit, createServer, launch, loadConfigFromFile, publish, configureForDesktop, resolveConfig, createServices } from "../core/index.js";
import { command, COMMAND, PLATFORM, target, TARGET } from "../core/globals.js";
import { build, createServer, launch, loadConfigFromFile, configureForDesktop, resolveConfig, createServices } from "../core/index.js";
import { clearOutputDirectory, populateOutputDirectory } from "../core/common.js";

// Error Handling for CLI
Expand All @@ -20,13 +19,11 @@ process.on('beforeExit', onExit);

const baseOptions = { target: TARGET, platform: PLATFORM }

if (command.launch) launch(baseOptions)
else if (command.commit) commit({ message: cliArgs.message })
else if (command.publish) publish({ message: cliArgs.message })
else {
const config = await loadConfigFromFile() // Load configuration file only once...
if (command.build) build(baseOptions, config)
else if (command.dev || command.start || !command) {
if (command.launch) launch(baseOptions) // Launch the specified build
else if (command.build) build(baseOptions) // Build the application using the specified settings
else if (command.dev || command.start || !command) {

const config = await loadConfigFromFile() // Load configuration file only once

const resolvedConfig = await resolveConfig(config);

Expand All @@ -42,6 +39,6 @@ else {

if (!target.mobile) await createServer(config, !target.desktop) // Create frontend server

}
else throw new Error(`'${COMMAND}' is an invalid command.`)
}
}

else throw new Error(`'${COMMAND}' is an invalid command.`)
2 changes: 1 addition & 1 deletion packages/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function build ({ target, platform }: BuildOptions, config?
let build = (service && typeof service === 'object') ? service.build : null
if (build && typeof build === 'object') build = build[platform] // Run based on the platform if an object
if (build) {
console.log(chalk.yellow(`Running build command for commoners-${name}-service`))
console.log(`Running build command for the ${chalk.bold(name)} service`)
await spawnProcess(build)
}
}
Expand Down
11 changes: 0 additions & 11 deletions packages/core/commit.ts

This file was deleted.

49 changes: 0 additions & 49 deletions packages/core/github/github.js

This file was deleted.

82 changes: 0 additions & 82 deletions packages/core/github/index.js

This file was deleted.

94 changes: 0 additions & 94 deletions packages/core/github/repo.js

This file was deleted.

12 changes: 11 additions & 1 deletion packages/core/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as yaml from 'js-yaml'

// Types
import { valid, validMobilePlatforms, WritableElectronBuilderConfig } from "./types.js";
import chalk from "chalk";

export const outDir = 'dist'
export const scopedOutDir = path.join('dist', '.commoners')
Expand All @@ -25,7 +26,16 @@ export const COMMAND = process.env.COMMAND = passedCommand
const getOS = () => process.platform === 'win32' ? 'windows' : (process.platform === 'darwin' ? 'mac' : 'linux')
export const PLATFORM = process.env.PLATFORM = (validMobilePlatforms.find(str => cliArgs[str]) || getOS()) as typeof valid.platform[number] // Declared Mobile OR Implicit Desktop Patform

const isDesktopCommandConsistent = (platform) => PLATFORM === platform && cliArgs[platform]
const isDesktopCommandConsistent = (platform) => {
if (cliArgs[platform]) {
if (PLATFORM === platform) return true
else {
console.log(`Cannot run a command for the ${chalk.bold(platform)} platform on ${chalk.bold(PLATFORM)}`)
process.exit(1)
}
}
}


const isDesktop = cliArgs.desktop || isDesktopCommandConsistent('mac') || isDesktopCommandConsistent('windows') || isDesktopCommandConsistent('linux')
const isMobile = cliArgs.mobile || !!validMobilePlatforms.find(platform => cliArgs[platform])
Expand Down
3 changes: 0 additions & 3 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { APPID, NAME, assetOutDir, cliArgs, commonersPkg, configPath, defaultMai
import { ResolvedConfig, UserConfig } from './types.js'

import { resolveAll, createAll } from '../../template/src/main/services/index.js'
import { clearOutputDirectory, populateOutputDirectory } from './common.js'

export { default as launch } from './launch.js'
export { default as commit } from './commit.js'
export { default as publish } from './publish.js'
export { default as build } from './build.js'

import { ManifestOptions } from 'vite-plugin-pwa'
Expand Down
13 changes: 0 additions & 13 deletions packages/core/publish.ts

This file was deleted.

0 comments on commit dae715f

Please sign in to comment.