Skip to content

Commit 51c3349

Browse files
committed
perf: updates and improvement
- Updated: App dependencies, - Added: ESM support required by [ora v6](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), - Fixed: License author - year wrong content
1 parent 72df041 commit 51c3349

File tree

12 files changed

+1190
-1007
lines changed

12 files changed

+1190
-1007
lines changed

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
src
2+
assets
3+
.eslintignore
4+
.editorconfig
5+
.eslintrc.js
6+
.prettierrc
7+
tsconfig.json

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ cd my-app
4040
yarn start | npm run start
4141
```
4242

43+
### Known issue
44+
45+
Inquirer select does't work on Windows 10 git bash Terminal [mintty](https://github.com/mintty/mintty), It works fine on integrated VS Code Terminal though.
46+
4347
## Available Templates
4448

4549
- Default [JS template](https://github.com/awran5/esbuild-react-app-js-template)

bin/functions.js

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,39 @@
1-
"use strict";
2-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4-
return new (P || (P = Promise))(function (resolve, reject) {
5-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8-
step((generator = generator.apply(thisArg, _arguments || [])).next());
9-
});
10-
};
11-
var __importDefault = (this && this.__importDefault) || function (mod) {
12-
return (mod && mod.__esModule) ? mod : { "default": mod };
13-
};
14-
Object.defineProperty(exports, "__esModule", { value: true });
15-
exports.removeDir = exports.templateInquirer = exports.confirmInquirer = void 0;
16-
const fs_1 = require("fs");
17-
const inquirer_1 = __importDefault(require("inquirer"));
18-
const chalk_1 = __importDefault(require("chalk"));
19-
function confirmInquirer(projectName) {
20-
return __awaiter(this, void 0, void 0, function* () {
21-
return new Promise((resolve, reject) => {
22-
inquirer_1.default
23-
.prompt({
24-
type: 'confirm',
25-
name: 'exists',
26-
message: `Project ${chalk_1.default.cyan(projectName)} is already exists. Do you want to remove it? (hit enter for NO)?`,
27-
default: false
28-
})
29-
.then((answer) => answer.exists && resolve(true))
30-
.catch((err) => reject(new Error(err)));
31-
});
1+
import { rmdir } from 'fs';
2+
import inquirer from 'inquirer';
3+
import chalk from 'chalk';
4+
export async function confirmInquirer(projectName) {
5+
return new Promise((resolve, reject) => {
6+
inquirer
7+
.prompt({
8+
type: 'confirm',
9+
name: 'exists',
10+
message: `Project ${chalk.cyan(projectName)} is already exists. Do you want to remove it? (hit enter for NO)?`,
11+
default: false
12+
})
13+
.then((answer) => answer.exists && resolve(true))
14+
.catch((err) => reject(new Error(err)));
3215
});
3316
}
34-
exports.confirmInquirer = confirmInquirer;
35-
function templateInquirer() {
36-
return __awaiter(this, void 0, void 0, function* () {
37-
return new Promise((resolve, reject) => {
38-
inquirer_1.default
39-
.prompt({
40-
type: 'list',
41-
name: 'selected',
42-
message: `To get started please choose a template`,
43-
choices: ['Javascript', 'Typescript']
44-
})
45-
.then((answer) => resolve(answer.selected))
46-
.catch((err) => reject(new Error(err)));
47-
});
17+
export async function templateInquirer() {
18+
return new Promise((resolve, reject) => {
19+
inquirer
20+
.prompt({
21+
type: 'list',
22+
name: 'selected',
23+
message: `To get started please choose a template`,
24+
choices: ['Javascript', 'Typescript']
25+
})
26+
.then((answer) => resolve(answer.selected))
27+
.catch((err) => reject(new Error(err)));
4828
});
4929
}
50-
exports.templateInquirer = templateInquirer;
51-
function removeDir(dirName) {
52-
return __awaiter(this, void 0, void 0, function* () {
53-
return new Promise((resolve, reject) => {
54-
fs_1.rmdir(dirName, { recursive: true }, (err) => {
55-
if (err) {
56-
reject(new Error(`Failed to remove ${chalk_1.default.cyan(dirName)}. ${err}`));
57-
}
58-
resolve();
59-
});
30+
export async function removeDir(dirName) {
31+
return new Promise((resolve, reject) => {
32+
rmdir(dirName, { recursive: true }, (err) => {
33+
if (err) {
34+
reject(new Error(`Failed to remove ${chalk.cyan(dirName)}. ${err}`));
35+
}
36+
resolve();
6037
});
6138
});
6239
}
63-
exports.removeDir = removeDir;

bin/index.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
#!/usr/bin/env node
2-
"use strict";
3-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5-
return new (P || (P = Promise))(function (resolve, reject) {
6-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9-
step((generator = generator.apply(thisArg, _arguments || [])).next());
10-
});
11-
};
12-
var __importDefault = (this && this.__importDefault) || function (mod) {
13-
return (mod && mod.__esModule) ? mod : { "default": mod };
14-
};
15-
Object.defineProperty(exports, "__esModule", { value: true });
16-
const projectName_1 = require("./projectName");
17-
const tasks_1 = __importDefault(require("./tasks"));
18-
(() => __awaiter(void 0, void 0, void 0, function* () {
19-
const projectName = yield projectName_1.getProjectName();
2+
import { getProjectName } from './projectName.js';
3+
import createProject from './tasks.js';
4+
(async () => {
5+
const projectName = await getProjectName();
206
try {
21-
yield tasks_1.default(projectName);
7+
await createProject(projectName);
228
}
239
catch (error) {
2410
console.log(error);
2511
process.exit(1);
2612
}
27-
}))();
13+
})();

bin/projectName.js

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
"use strict";
2-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4-
return new (P || (P = Promise))(function (resolve, reject) {
5-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8-
step((generator = generator.apply(thisArg, _arguments || [])).next());
9-
});
10-
};
11-
var __importDefault = (this && this.__importDefault) || function (mod) {
12-
return (mod && mod.__esModule) ? mod : { "default": mod };
13-
};
14-
Object.defineProperty(exports, "__esModule", { value: true });
15-
exports.getProjectName = void 0;
16-
const chalk_1 = __importDefault(require("chalk"));
17-
function getProjectName() {
18-
return __awaiter(this, void 0, void 0, function* () {
19-
const args = process.argv.slice(2, process.argv.length);
20-
const name = args[0];
21-
const acceptedName = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name);
22-
if (!name) {
23-
console.log(`\n${chalk_1.default.bgRed(` Error! `)} Please specify a project name e.g. ${chalk_1.default.cyan(`npx react-esbuild-app`)} ${chalk_1.default.green('my-app')}\n`);
24-
process.exit();
25-
}
26-
if (!acceptedName) {
27-
console.log(`\n${chalk_1.default.bgRed(` npm naming restrictions! `)} Please specify a project name with lowercase characters separated by hyphen (-) e.g. ${chalk_1.default.green('my-app')}\n`);
28-
process.exit();
29-
}
30-
return name;
31-
});
1+
import chalk from 'chalk';
2+
export async function getProjectName() {
3+
const args = process.argv.slice(2, process.argv.length);
4+
const name = args[0];
5+
const acceptedName = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name);
6+
if (!name) {
7+
console.log(`\n${chalk.bgRed(` Error! `)} Please specify a project name e.g. ${chalk.cyan(`npx react-esbuild-app`)} ${chalk.green('my-app')}\n`);
8+
process.exit();
9+
}
10+
if (!acceptedName) {
11+
console.log(`\n${chalk.bgRed(` npm naming restrictions! `)} Please specify a project name with lowercase characters separated by hyphen (-) e.g. ${chalk.green('my-app')}\n`);
12+
process.exit();
13+
}
14+
return name;
3215
}
33-
exports.getProjectName = getProjectName;

0 commit comments

Comments
 (0)