Skip to content

Commit

Permalink
feat: rename init command to bootstrap
Browse files Browse the repository at this point in the history
To have consistency.
  • Loading branch information
swashata committed Oct 12, 2018
1 parent 7b42327 commit b7a6342
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import path from 'path';
import PrettyError from 'pretty-error';

import { ProgramOptions } from '.';
import { Init } from '../scripts/Init';
import { Bootstrap } from '../scripts/Bootstrap';
import { bulletSymbol, endBootstrapInfo, isYarn, resolveCWD } from './utils';

export async function init(
export async function bootstrap(
options: ProgramOptions | undefined,
version: string
): Promise<void> {
Expand All @@ -22,7 +22,7 @@ export async function init(
)}`
);
try {
const initiator = new Init(cwd, version);
const initiator = new Bootstrap(cwd, version);

try {
const done = await initiator.bootstrap();
Expand Down Expand Up @@ -79,7 +79,6 @@ export async function init(
);
}
} catch (e) {
console.log(pe.render(e));
console.log(
`${logSymbols.error} configuration files are already present.`
);
Expand Down
6 changes: 3 additions & 3 deletions packages/scripts/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import program from 'commander';
import path from 'path';
import clearConsole from 'react-dev-utils/clearConsole';
import updateNotifier from 'update-notifier';
import { bootstrap } from './bootstrap';
import { build } from './build';
import { init } from './init';
import { serve } from './serve';
import { bulletSymbol, contextHelp, printIntro } from './utils';

Expand Down Expand Up @@ -45,7 +45,7 @@ program.on('--help', () => {
console.log(chalk.cyan.bold('Bootstrap/Onboarding:'));
console.log(`If you are just starting out with wpackio-scripts, then run
${bulletSymbol} ${chalk.yellow('npx @wpack/scripts wpackio-scripts init')}
${bulletSymbol} ${chalk.yellow('npx @wpackio/scripts bootstrap')}
If you already have the project config file and would like to configure
local server for this machine, then run
Expand Down Expand Up @@ -104,7 +104,7 @@ program
.option('-c, --context', contextHelp)
.action((options: ProgramOptions | undefined) => {
isValidCommand = true;
init(options, pkg.version);
bootstrap(options, pkg.version);
});

// Output our fancy stuff first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InitResolve {
}
}

export class Init {
export class Bootstrap {
private cwd: string;
private projectConfigPath: string;
private serverConfigPath: string;
Expand Down Expand Up @@ -89,7 +89,9 @@ export class Init {
// If project config is present, then just configure the server
if (this.isConfigPresent('server')) {
// Server is also present, so just bail
return Promise.reject();
return Promise.reject(
new Error('project is already bootstrapped.')
);
} else {
// Configure the server
const serverContext = await this.initServerConfig();
Expand Down Expand Up @@ -259,7 +261,7 @@ export class Init {
const scripts: { [x: string]: string } = {
build: 'wpackio-scripts build',
start: 'wpackio-scripts start',
bootstrap: 'wpackio-scripts init',
bootstrap: 'wpackio-scripts bootstrap',
};
if (!packageFileData.scripts) {
packageFileData.scripts = {};
Expand Down

0 comments on commit b7a6342

Please sign in to comment.