From a06c5abbb9f934026b6700698511e520a283be4d Mon Sep 17 00:00:00 2001
From: alexlee-dev
Date: Tue, 26 May 2020 12:10:54 -0700
Subject: [PATCH 1/6] =?UTF-8?q?=20=F0=9F=93=A6Bump=20Version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 2 +-
src/index.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/package.json b/package.json
index 37a8f63..9665cd2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "create-cli-application",
- "version": "0.2.0",
+ "version": "0.3.0",
"description": "A bootstrapper for creating a cli application with Node.",
"bin": {
"create-cli-application": "./index.js"
diff --git a/src/index.ts b/src/index.ts
index 8fed4d0..313a55c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -5,7 +5,7 @@ import * as Sentry from "@sentry/node";
Sentry.init({
dsn:
"https://55c913cc3d394f71ba669fda095698fd@o202486.ingest.sentry.io/5254191",
- release: "0.2.0",
+ release: "0.3.0",
});
import {
@@ -24,7 +24,7 @@ const main = async (): Promise => {
let language: "js" | "ts";
language = "js";
const program = new commander.Command("create-cli-application")
- .version("0.2.0")
+ .version("0.3.0")
.arguments("")
.usage(`${chalk.yellowBright("")} [options]`)
.action((name) => {
From bbb919b3530692e5f6e50feab0a763133891c7a7 Mon Sep 17 00:00:00 2001
From: alexlee-dev
Date: Tue, 26 May 2020 12:11:32 -0700
Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9D=20Add=20v0.3.0=20to=20CHANGELO?=
=?UTF-8?q?G?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbdad79..7bcc7fb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.3.0] - _Unreleased_
+
+### Added
+
+### Changed
+
+### Removed
+
+### Fixed
+
## [0.2.0] - 2020-05-26
### 🔧 Vanilla JS Support
From 53b6249b51075a47d2896e166603a1dfe41eb7a2 Mon Sep 17 00:00:00 2001
From: alexlee-dev
Date: Tue, 26 May 2020 12:59:24 -0700
Subject: [PATCH 3/6] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Change=20APP=20Name=20?=
=?UTF-8?q?to=20'=5F=5F=5FAPP=20NAME=5F=5F=5F'=20in=20Templates?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/init.ts | 3 +++
src/template/README.md | 2 +-
src/template/js/src/index.js | 4 ++--
src/template/js/src/menu.js | 8 ++++----
src/template/js/src/setup.js | 2 +-
src/template/ts/src/index.ts | 4 ++--
src/template/ts/src/menu.ts | 8 ++++----
src/template/ts/src/setup.ts | 2 +-
8 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/init.ts b/src/init.ts
index e90ff29..821a95a 100644
--- a/src/init.ts
+++ b/src/init.ts
@@ -144,6 +144,9 @@ export const copyTemplateFiles = async (
path.join(root, "/.babelrc")
);
}
+
+ // * Apply the applicationName to template files
+
spinner.succeed("Template files copied successfully");
} catch (error) {
spinner.fail();
diff --git a/src/template/README.md b/src/template/README.md
index bc4bcc6..1b1dff0 100644
--- a/src/template/README.md
+++ b/src/template/README.md
@@ -3,7 +3,7 @@
-APP NAME
+___APP NAME___
---
diff --git a/src/template/js/src/index.js b/src/template/js/src/index.js
index f2e8bd3..4e9916b 100644
--- a/src/template/js/src/index.js
+++ b/src/template/js/src/index.js
@@ -9,7 +9,7 @@ import setup from "./setup";
const main = async () => {
const menuActionEmitter = new EventEmitter.EventEmitter();
menuActionEmitter.on("actionCompleted", async (state) => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
await displayMainMenu(state);
await interpretMenuAction(state);
});
@@ -30,7 +30,7 @@ const main = async () => {
clear();
}
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
await displayMainMenu(state);
await interpretMenuAction(state);
diff --git a/src/template/js/src/menu.js b/src/template/js/src/menu.js
index 2953718..12ec199 100644
--- a/src/template/js/src/menu.js
+++ b/src/template/js/src/menu.js
@@ -71,7 +71,7 @@ export const interpretMenuAction = async (state) => {
}
const actions = {
about: async (state) => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log(
boxen(chalk.yellow(`Author: `) + "YOUR NAME", blankBoxenStyle)
);
@@ -81,7 +81,7 @@ export const interpretMenuAction = async (state) => {
state.menuActionEmitter.emit("actionCompleted", state);
},
option1: async (state) => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log("Option 1 Logic would take place here :)");
console.log("");
@@ -90,7 +90,7 @@ export const interpretMenuAction = async (state) => {
state.menuActionEmitter.emit("actionCompleted", state);
},
option2: async (state) => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log("Option 2 Logic would take place here :)");
console.log("");
@@ -99,7 +99,7 @@ export const interpretMenuAction = async (state) => {
state.menuActionEmitter.emit("actionCompleted", state);
},
option3: async (state) => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log("Option 3 Logic would take place here :)");
console.log("");
diff --git a/src/template/js/src/setup.js b/src/template/js/src/setup.js
index fc04df1..bbf6de4 100644
--- a/src/template/js/src/setup.js
+++ b/src/template/js/src/setup.js
@@ -8,7 +8,7 @@ const setup = async (state) => {
console.log(
`Welcome to ${chalk.yellowBright(
- "APP NAME"
+ "___APP NAME___"
)}! Let's walk you through the initial set up.\n`
);
diff --git a/src/template/ts/src/index.ts b/src/template/ts/src/index.ts
index 6a2454a..e8739c9 100644
--- a/src/template/ts/src/index.ts
+++ b/src/template/ts/src/index.ts
@@ -10,7 +10,7 @@ import { AppState } from "./types";
const main = async (): Promise => {
const menuActionEmitter = new EventEmitter.EventEmitter();
menuActionEmitter.on("actionCompleted", async (state: AppState) => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
await displayMainMenu(state);
await interpretMenuAction(state);
});
@@ -31,7 +31,7 @@ const main = async (): Promise => {
clear();
}
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
await displayMainMenu(state);
await interpretMenuAction(state);
diff --git a/src/template/ts/src/menu.ts b/src/template/ts/src/menu.ts
index 38eae99..1d88a50 100644
--- a/src/template/ts/src/menu.ts
+++ b/src/template/ts/src/menu.ts
@@ -73,7 +73,7 @@ export const interpretMenuAction = async (state: AppState): Promise => {
}
const actions = {
about: async (state: AppState): Promise => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log(
boxen(chalk.yellow(`Author: `) + "YOUR NAME", blankBoxenStyle)
);
@@ -83,7 +83,7 @@ export const interpretMenuAction = async (state: AppState): Promise => {
state.menuActionEmitter.emit("actionCompleted", state);
},
option1: async (state: AppState): Promise => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log("Option 1 Logic would take place here :)");
console.log("");
@@ -92,7 +92,7 @@ export const interpretMenuAction = async (state: AppState): Promise => {
state.menuActionEmitter.emit("actionCompleted", state);
},
option2: async (state: AppState): Promise => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log("Option 2 Logic would take place here :)");
console.log("");
@@ -101,7 +101,7 @@ export const interpretMenuAction = async (state: AppState): Promise => {
state.menuActionEmitter.emit("actionCompleted", state);
},
option3: async (state: AppState): Promise => {
- await titleScreen("APP NAME");
+ await titleScreen("___APP NAME___");
console.log("Option 3 Logic would take place here :)");
console.log("");
diff --git a/src/template/ts/src/setup.ts b/src/template/ts/src/setup.ts
index cd1c076..5c9bc99 100644
--- a/src/template/ts/src/setup.ts
+++ b/src/template/ts/src/setup.ts
@@ -9,7 +9,7 @@ const setup = async (state: AppState): Promise => {
console.log(
`Welcome to ${chalk.yellowBright(
- "APP NAME"
+ "___APP NAME___"
)}! Let's walk you through the initial set up.\n`
);
From 8bf150cb5e29b30890221aad0c47fe940b730ddb Mon Sep 17 00:00:00 2001
From: alexlee-dev
Date: Tue, 26 May 2020 13:18:56 -0700
Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8=20Replace=20generic=20'APP=20Name?=
=?UTF-8?q?'=20in=20template=20files=20with=20applicationName=20value?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 2 +
src/init.ts | 100 ++++++++++++++++++++++++++++++++++-
src/template/js/src/index.js | 2 +-
src/template/ts/src/index.ts | 2 +-
4 files changed, 103 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7bcc7fb..e8fd9a2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- Replace generic "APP NAME" in template files with applicationName value
+
### Changed
### Removed
diff --git a/src/init.ts b/src/init.ts
index 821a95a..5774507 100644
--- a/src/init.ts
+++ b/src/init.ts
@@ -146,7 +146,105 @@ export const copyTemplateFiles = async (
}
// * Apply the applicationName to template files
-
+ const readmeFile = await fs.readFile(path.join(root, "README.md"), "utf-8");
+ const newReadmeContent = readmeFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(path.join(root, "README.md"), newReadmeContent, "utf8");
+
+ if (language === "js") {
+ // * src/index.js
+ const indexFile = await fs.readFile(
+ path.join(root, "/src/index.js"),
+ "utf-8"
+ );
+ const newIndexFileContent = indexFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(
+ path.join(root, "/src/index.js"),
+ newIndexFileContent,
+ "utf8"
+ );
+
+ // * src/menu.js
+ const menuFile = await fs.readFile(
+ path.join(root, "/src/menu.js"),
+ "utf-8"
+ );
+ const newMenuFileContent = menuFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(
+ path.join(root, "/src/menu.js"),
+ newMenuFileContent,
+ "utf8"
+ );
+
+ // * src/setup.js
+ const setupFile = await fs.readFile(
+ path.join(root, "/src/setup.js"),
+ "utf-8"
+ );
+ const newSetupFileContent = setupFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(
+ path.join(root, "/src/setup.js"),
+ newSetupFileContent,
+ "utf8"
+ );
+ } else if (language === "ts") {
+ // * src/index.ts
+ const indexFile = await fs.readFile(
+ path.join(root, "/src/index.ts"),
+ "utf-8"
+ );
+ const newIndexFileContent = indexFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(
+ path.join(root, "/src/index.ts"),
+ newIndexFileContent,
+ "utf8"
+ );
+
+ // * src/menu.ts
+ const menuFile = await fs.readFile(
+ path.join(root, "/src/menu.ts"),
+ "utf-8"
+ );
+ const newMenuFileContent = menuFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(
+ path.join(root, "/src/menu.ts"),
+ newMenuFileContent,
+ "utf8"
+ );
+
+ // * src/setup.ts
+ const setupFile = await fs.readFile(
+ path.join(root, "/src/setup.ts"),
+ "utf-8"
+ );
+ const newSetupFileContent = setupFile.replace(
+ /___APP NAME___/gm,
+ applicationName
+ );
+ await fs.writeFile(
+ path.join(root, "/src/setup.ts"),
+ newSetupFileContent,
+ "utf8"
+ );
+ }
+
spinner.succeed("Template files copied successfully");
} catch (error) {
spinner.fail();
diff --git a/src/template/js/src/index.js b/src/template/js/src/index.js
index 4e9916b..6532d41 100644
--- a/src/template/js/src/index.js
+++ b/src/template/js/src/index.js
@@ -14,7 +14,7 @@ const main = async () => {
await interpretMenuAction(state);
});
- const config = new Configstore("app-name");
+ const config = new Configstore("___APP NAME___");
const state = {
config,
diff --git a/src/template/ts/src/index.ts b/src/template/ts/src/index.ts
index e8739c9..48da734 100644
--- a/src/template/ts/src/index.ts
+++ b/src/template/ts/src/index.ts
@@ -15,7 +15,7 @@ const main = async (): Promise => {
await interpretMenuAction(state);
});
- const config = new Configstore("app-name");
+ const config = new Configstore("___APP NAME___");
const state: AppState = {
config,
From 8b537f478783322d50752dfa489c81fa3aad2680 Mon Sep 17 00:00:00 2001
From: alexlee-dev
Date: Tue, 26 May 2020 13:22:47 -0700
Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=93=9D=20Update=20CHANGELOG?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8fd9a2..b135afc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [0.3.0] - _Unreleased_
+## [0.3.0] - 2020-05-26
### Added
From 7a4fab86982cce064c41c4fd190f86b0da5a9df7 Mon Sep 17 00:00:00 2001
From: alexlee-dev
Date: Tue, 26 May 2020 13:23:31 -0700
Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=93=9D=20Update=20CHANGELOG?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b135afc..228b95c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.3.0] - 2020-05-26
+### ✏️ Application Name in Template Files
+
### Added
- Replace generic "APP NAME" in template files with applicationName value