Skip to content

Commit

Permalink
refactor: Move commands to separate folders
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkr00t committed Apr 24, 2017
1 parent 01cf7f4 commit 400440c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
const meow = require("meow");
const chalk = require("chalk");
const insight = require("./lib/analytics");
const aikDevServer = require("./lib/dev-server-command").default;
const aikBuild = require("./lib/build-command").default;
const aikDevServer = require("./lib/commands/dev-server").default;
const aikBuild = require("./lib/commands/build").default;
const cli = meow(
{
help: [
Expand Down
2 changes: 1 addition & 1 deletion src/build-command.js → src/commands/build/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */
import runWebpackBuilder from "./webpack-build";
import createParams from "./utils/params";
import createParams from "./../../utils/params";

/**
* Aik build command
Expand Down
25 changes: 16 additions & 9 deletions src/webpack-build.js → src/commands/build/webpack-build.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* @flow */

import fs from 'fs-extra';
import path from 'path';
import webpack from 'webpack';
import gzipSize from 'gzip-size';
import webpackConfigBuilder from './webpack/config-builder';
import fs from "fs-extra";
import path from "path";
import webpack from "webpack";
import gzipSize from "gzip-size";
import webpackConfigBuilder from "./../../webpack/config-builder";
import {
builderBanner,
builderRemovingDistMsg,
builderRunningBuildMsg,
builderErrorMsg,
builderSuccessMsg,
fileDoesNotExistMsg
} from './utils/messages';
} from "./../../utils/messages";

/**
* Removes distribute folder to prevent duplicates.
Expand All @@ -24,7 +24,11 @@ export function removeDist(distPath: string): Promise<*> {
/**
* Builds project using webpack.
*/
export default async function runWebpackBuilder(filename: string, flags: CLIFlags, params: AikParams): Promise<*> {
export default async function runWebpackBuilder(
filename: string,
flags: CLIFlags,
params: AikParams
): Promise<*> {
try {
fs.statSync(filename);
} catch (error) {
Expand All @@ -51,8 +55,11 @@ export default async function runWebpackBuilder(filename: string, flags: CLIFlag

const json = stats.toJson({}, true);
const buildDuration: number = stats.endTime - stats.startTime;
const assets:BuildStatAsset[] = json.assets.map(item => {
const content: string = fs.readFileSync(path.join(params.dist.path, item.name), 'utf-8');
const assets: BuildStatAsset[] = json.assets.map(item => {
const content: string = fs.readFileSync(
path.join(params.dist.path, item.name),
"utf-8"
);
return {
name: item.name,
size: item.size / 1024,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { outputFile } from "fs-extra";
import resolveModule from "resolve";
import createWebpackDevServer from "./webpack-dev-server";
import createNgrokTunnel from "./ngrok";
import createParams from "./utils/params";
import createParams from "./../../utils/params";
import {
devServerFileDoesNotExistMsg,
devServerInvalidBuildMsg,
fileDoesNotExistMsg,
devServerReactRequired,
devServerInstallingModuleMsg,
devServerSkipInstallingModuleMsg
} from "./utils/messages";
} from "./../../utils/messages";

export function requestCreatingAnEntryPoint(
filename: string
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import historyApiFallback from "connect-history-api-fallback";
import resolveModule from "resolve";
import webpack from "webpack";
import WebpackDevServer from "webpack-dev-server";
import webpackConfigBuilder from "./webpack/config-builder";
import detectPort from "./utils/detect-port";
import testUtils from "./utils/test-utils";
import { isLikelyASyntaxError, formatMessage } from "./utils/error-helpers";
import webpackConfigBuilder from "./../../webpack/config-builder";
import detectPort from "./../../utils/detect-port";
import testUtils from "./../../utils/test-utils";
import {
isLikelyASyntaxError,
formatMessage
} from "./../../utils/error-helpers";
import {
clearConsole,
eslintExtraWarningMsg,
Expand All @@ -17,7 +20,7 @@ import {
devServerCompiledWithWarningsMsg,
devServerRestartMsg,
devServerModuleDoesntExists
} from "./utils/messages";
} from "./../../utils/messages";

/**
* On done handler for webpack compiler.
Expand Down

0 comments on commit 400440c

Please sign in to comment.