Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Commit

Permalink
- Upgrade to Webpack 5 and react 17
Browse files Browse the repository at this point in the history
- Fixed some minor bugs while upgrading
-
  • Loading branch information
use-the-fork committed Jun 5, 2022
1 parent 990016c commit b2b5434
Show file tree
Hide file tree
Showing 21 changed files with 53,672 additions and 46,335 deletions.
10 changes: 5 additions & 5 deletions cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import commander, { Command } from 'commander';
import { program, Command } from 'commander';
import chalk from 'chalk';
import headline from './headline';
import { createDireflowSetup } from './create';
Expand All @@ -16,7 +16,7 @@ type TOptions =
type TParsed = Command & { [key in TOptions]?: true } & { desc: string };

export default function cli() {
commander
program
.command('create [project-name]')
.alias('c')
.description('Create a new Direflow Setup')
Expand All @@ -28,7 +28,7 @@ export default function cli() {
.option('--npm', 'Make the project an NPM module')
.action(handleAction);

commander
program
.description(chalk.magenta(headline))
.version(showVersion())
.helpOption('-h, --help', 'Show how to use direflow-cli')
Expand All @@ -37,14 +37,14 @@ export default function cli() {
const [, , simpleArg] = process.argv;

if (!simpleArg) {
return commander.help();
return program.help();
}

if (['-v', '--version'].includes(simpleArg)) {
console.log(checkForUpdates());
}

commander.parse(process.argv);
program.parse(process.argv);
}

async function handleAction(name: string | undefined, parsed: TParsed) {
Expand Down
7 changes: 3 additions & 4 deletions cli/helpers/copyTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { resolve } from 'path';
import fs from 'fs';
import ncp from 'ncp';
import mkdirp from 'mkdirp';
import { ITemplateOption } from '../types/TemplateOption';

const copyTemplate = async (options: ITemplateOption): Promise<string> => {
Expand All @@ -10,7 +9,7 @@ const copyTemplate = async (options: ITemplateOption): Promise<string> => {

const projectDirectory: string = await new Promise((projectResolve, reject) => {
const projectDir = `${currentDirectory}/${options.projectName}`;
mkdirp(projectDir, (err) => {
fs.mkdir(projectDir, (err: any) => {
if (err) {
console.log(err);
reject(new Error(`Could not create directory: ${projectDir}`));
Expand All @@ -27,7 +26,7 @@ const copyTemplate = async (options: ITemplateOption): Promise<string> => {
reject(new Error('Could not copy template files'));
}

ncpResolve();
ncpResolve(true);
});
});

Expand All @@ -41,7 +40,7 @@ const copyTemplate = async (options: ITemplateOption): Promise<string> => {
reject(new Error('Could not rename component folder'));
}

renameResolve();
renameResolve(true);
},
);
});
Expand Down
16 changes: 9 additions & 7 deletions cli/helpers/writeNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function changeNameInfile(filePath: string, data: IHandelbarData): Promise
const changedFile = await new Promise((resolve, reject) => {
fs.readFile(filePath, 'utf-8', (err, content) => {
if (err) {
reject();
reject(false);
}

const template = handelbars.compile(content);
Expand All @@ -88,13 +88,15 @@ async function changeNameInfile(filePath: string, data: IHandelbarData): Promise
});

await new Promise((resolve, reject) => {
fs.writeFile(filePath, changedFile, 'utf-8', (err) => {
if (err) {
reject();
}
if ( typeof changedFile == 'string' ) {
fs.writeFile(filePath, changedFile, 'utf-8', (err) => {
if (err) {
reject();
}

resolve();
});
resolve(true);
});
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"baseUrl": "http://localhost:5000",
"video": false
}
}
Loading

0 comments on commit b2b5434

Please sign in to comment.