Skip to content

Commit b51c978

Browse files
author
Mads Thines
committed
Added Widgets variant to setup
1 parent 2123c46 commit b51c978

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

config/setup/actions.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { Spinner } = require("cli-spinner");
55

66
const { packages, features } = require("./packages");
77
const { schema } = require("./schema");
8-
const { print, bold, dim, highlight, underline, actions, runActions, isYes } = require("./utilities");
8+
const { print, bold, dim, highlight, underline, actions, runActions, isYes, printFeatureConf } = require("./utilities");
99

1010
const spinner = new Spinner("%s Installing the new modules...").setSpinnerString(18);
1111

@@ -17,12 +17,12 @@ const spinner = new Spinner("%s Installing the new modules...").setSpinnerString
1717
const startPrompt = project =>
1818
new Promise((res, rej) => {
1919
print(
20-
`${dim(`${bold("Thanks for using React Boilerplate.")}
20+
`${bold("Thanks for using React Boilerplate. ❤️")}
2121
If you run into trouble, don't hesitate to write an issue or contact one of the maintainers.
2222
23-
Make sure that you don't have any uncommited changes before running the yarn setup.
23+
Make sure you don't have any uncommited changes before running, as it will stage any changes.
2424
25-
${bold("Github Link")}
25+
${dim(`${bold("Github Link")}
2626
${underline("https://github.com/adaptdk/react_boilerplate/issues")}
2727
2828
${bold("Maintainers")}
@@ -75,7 +75,7 @@ const getProjectName = project =>
7575
const getPackages = project =>
7676
new Promise((res, rej) => {
7777
print("------", "dim", [2, 0]);
78-
print(`🌲 Now, this is the available packages:`, null, [2, 0]);
78+
print(`Available packages:`, "bold", [2, 0]);
7979
print(
8080
`Read more about the different packages at ${underline(
8181
"https://github.com/adaptdk/react_boilerplate#-packages"
@@ -86,7 +86,14 @@ const getPackages = project =>
8686

8787
// Output Each Package
8888
packages.forEach(variant => {
89-
print(`${variant.id} ${variant.title}`);
89+
switch (variant.type) {
90+
case "break":
91+
print(variant.title, "bold", [1, 0]);
92+
break;
93+
default:
94+
print(` ${variant.id} ${variant.title}`);
95+
break;
96+
}
9097
});
9198

9299
print(`${bold("📦 Which package do you want to install?")}`, null, [2, 0]);
@@ -137,8 +144,9 @@ const getFeatures = project =>
137144
prompt.get(schema.features, (err, result) => {
138145
if (result) {
139146
if (isYes(result.features)) {
147+
// If they want to customize and change the options
148+
project.customizeFeature = true;
140149
const { features: selectedFeatures } = project;
141-
142150
selectedFeatures.forEach(async (selectedFeature, featuresIndex) => {
143151
let activeFeatureIndex;
144152
const activeFeature = features.find((feature, featureIndex) => {
@@ -267,15 +275,19 @@ Thank you for using the boilerplate for your React project. 💪`);
267275
print(
268276
`
269277
${bold("Project overview:")}
270-
${bold("✏️ Title:")} ${project.title}
271278
${bold("✏️ Machine name:")} ${project.machine}
279+
${bold("✏️ Title:")} ${project.title}
272280
${bold("📦 Package:")} ${project.package.branch}`,
273281
null,
274282
[1, 0]
275283
);
276284
if (setupConf.hasRepo) {
277285
print(` ${bold("🌲 Repo Url:")} ${project.ownRepo}`);
278286
}
287+
if (setupConf.hasFeatures && project.customizeFeature) {
288+
print(" 💎 Features:", "bold", [0, 1]);
289+
printFeatureConf(project.features);
290+
}
279291

280292
print(
281293
`${bold("Here's some quick commands to get you started.")}

config/setup/packages.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,42 @@
33
// Utilities
44
const { dim } = require("./utilities");
55

6-
const urlRegExp = /htt(ps|p).*(:|.)/;
7-
86
// Read more about the different packages here: https://github.com/adaptdk/react_boilerplate
97
const packages = [
8+
{
9+
type: "break",
10+
title: "Typescript",
11+
},
1012
{
1113
id: "1",
12-
title: "Base (TypeScript)",
14+
title: "Base",
1315
branch: "typescript/base",
1416
features: [{ name: "proxy" }],
1517
},
1618
{
1719
id: "2",
18-
title: "Complex (TypeScript)",
20+
title: "Complex",
1921
branch: "typescript/complex",
2022
features: [{ name: "proxy" }],
2123
},
2224
{
2325
id: "3",
26+
title: "Widgets",
27+
branch: "typescript/widgets",
28+
features: [{ name: "proxy" }],
29+
},
30+
{
31+
type: "break",
32+
title: "Regular",
33+
},
34+
{
35+
id: "4",
2436
title: "Base",
2537
branch: "regular/base",
2638
features: [{ name: "proxy" }],
2739
},
2840
{
29-
id: "4",
41+
id: "5",
3042
title: "Complex",
3143
branch: "regular/complex",
3244
features: [{ name: "proxy" }],
@@ -49,7 +61,7 @@ const features = [
4961
"You can always enable later in config/config-overrides.js"
5062
)}`,
5163
description: "Local Env. URL",
52-
pattern: urlRegExp,
64+
pattern: /(no|^htt(ps|p).*(:|.))/,
5365
default: "no",
5466
required: true,
5567
},

config/setup/setup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ const prompt = require("prompt");
55
const { startPrompt, finishSetup, getPackages, getFeatures, getProjectName, setupGit, exited } = require("./actions");
66

77
const project = {
8-
debug: false,
8+
debug: true,
99
branch: null,
10+
customizeFeature: false,
1011
deleteRepo: false,
1112
features: [],
1213
finished: false,

config/setup/utilities/logger.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,19 @@ const print = (string, variant, space = [0, 0]) => {
4141
spacer(space[1]);
4242
};
4343

44+
const printFeatureConf = features => {
45+
features.forEach(feature => {
46+
print(` {`);
47+
Object.entries(feature).forEach(([key, value]) => {
48+
print(` ${color.bold(`${key}:`)} ${value}`);
49+
});
50+
print(` }`, null, [0, 1]);
51+
});
52+
};
53+
4454
module.exports = {
4555
...color,
4656
spacer,
4757
print,
58+
printFeatureConf,
4859
};

0 commit comments

Comments
 (0)