Skip to content

Commit

Permalink
Added --force-install option.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-KaiNet committed Nov 20, 2024
1 parent 71df9a9 commit 9164763
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [4.0.2] - 20 Nov 2024

### Added

- `--force-install` parameter to run dependencies installation automatically [#157](https://github.com/s-KaiNet/spfx-fast-serve/issues/157)

## [4.0.1] - 02 Apr 2024

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ SharePoint 2016 is **NOT** supported.

Follow [this guide](./docs/MS%20Teams%20Toolkit.md) to configure MS Teams Toolkit with `fast-serve`. Also checkout the [sample repository](https://github.com/s-KaiNet/fast-serve-teams-tk) where everything is configured.

## `spfx-fast-serve` command options

- `--force-install` - installs dependencies without asking for a confirmation

## How it works

The tool adds necessary files to run your own webpack based build with webpack dev server. Technically it's a custom webpack build, which produces the same output files as SharePoint Framework build pipeline, but does it a lot faster, because of a number of improvements:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spfx-fast-serve",
"version": "4.0.1",
"version": "4.0.2",
"author": "Sergei Sergeev (https://github.com/s-KaiNet)",
"description": "Improve your SharePoint Framework development by speeding up 'serve' command",
"main": "lib/index.js",
Expand Down
46 changes: 33 additions & 13 deletions src/commands/Install.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
import { BaseCommand } from './BaseCommand';
import { prompt } from 'enquirer';
import { detect } from 'detect-package-manager';
import { detect, PM } from 'detect-package-manager';
import { logger } from '../common/Logger';
import chalk from 'chalk';
import { spawnProcess } from '../common/utils';

export class Install extends BaseCommand {

private force: boolean;

constructor() {
super();

const args = process.argv.slice(2);
this.force = args.indexOf('--force-install') !== -1;
}

public async execute(): Promise<void> {
const pm = await detect();

const message = `Now install dependencies ('${pm} install') and execute '${pm} run serve' afterwards.`;
logger.info(chalk.bgMagenta.white(message));
logger.newLine();
const completed = 'spfx-fast-serve configuration is completed!';
let answer: { install: boolean };

if (this.force) {
await this.installDependencies(pm, completed);
return;
}

logger.info(chalk.bgMagenta.white(message));
logger.newLine();

try {
answer = await prompt<{ install: boolean }>({
name: 'install',
Expand All @@ -30,20 +46,24 @@ export class Install extends BaseCommand {
}

if (answer.install) {
logger.newLine();

logger.info(chalk.bgMagenta.white(`Executing '${pm} install'...`));
logger.newLine();

await spawnProcess(pm, ['install']);

logger.newLine();
logger.success(chalk.green(completed));
logger.newLine();
await this.installDependencies(pm, completed);
} else {
logger.newLine();
logger.success(chalk.green(completed));
logger.newLine();
}
}

private async installDependencies(pm: PM, message: string): Promise<void> {
logger.newLine();

logger.info(chalk.bgMagenta.white(`Executing '${pm} install'...`));
logger.newLine();

await spawnProcess(pm, ['install']);

logger.newLine();
logger.success(chalk.green(message));
logger.newLine();
}
}

0 comments on commit 9164763

Please sign in to comment.