@kvihaugen/create-frontend-app 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +57 -62
- package/dist/text-templates/global-css-notifs.js +1 -3
- package/dist/text-templates/global-css.js +1 -3
- package/dist/text-templates/i18n-config.js +1 -3
- package/dist/text-templates/language-resource.js +1 -3
- package/dist/text-templates/next-layout.js +1 -3
- package/dist/text-templates/next-page.js +1 -3
- package/dist/text-templates/parent-props-type.js +1 -3
- package/dist/text-templates/postcss-config.js +1 -3
- package/dist/text-templates/providers-component.js +1 -3
- package/dist/types/ExtraPackage.js +1 -3
- package/dist/utils/functions/promiseType.js +1 -3
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const global_css_1 = __importDefault(require("./text-templates/global-css"));
|
|
20
|
-
const language_resource_1 = __importDefault(require("./text-templates/language-resource"));
|
|
21
|
-
const i18n_config_1 = __importDefault(require("./text-templates/i18n-config"));
|
|
22
|
-
const parent_props_type_1 = __importDefault(require("./text-templates/parent-props-type"));
|
|
23
|
-
const node_child_process_1 = require("node:child_process");
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
import ExtraPackage from "./types/ExtraPackage";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import promiseType from "./utils/functions/promiseType";
|
|
6
|
+
import ora from "ora";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import postcssConfig from "./text-templates/postcss-config";
|
|
10
|
+
import nextLayout from "./text-templates/next-layout";
|
|
11
|
+
import nextPage from "./text-templates/next-page";
|
|
12
|
+
import providersComponent from "./text-templates/providers-component";
|
|
13
|
+
import globalCssNotifs from "./text-templates/global-css-notifs";
|
|
14
|
+
import globalCss from "./text-templates/global-css";
|
|
15
|
+
import languageResource from "./text-templates/language-resource";
|
|
16
|
+
import i18nConfig from "./text-templates/i18n-config";
|
|
17
|
+
import parentPropsType from "./text-templates/parent-props-type";
|
|
18
|
+
import { execSync } from "node:child_process";
|
|
24
19
|
(async () => {
|
|
25
|
-
console.log(
|
|
20
|
+
console.log(chalk.cyan("🚀 Create a new frontend app!"));
|
|
26
21
|
// Prompting
|
|
27
|
-
const response = await (
|
|
22
|
+
const response = await prompts([
|
|
28
23
|
{
|
|
29
24
|
type: "text",
|
|
30
25
|
name: "name",
|
|
@@ -38,11 +33,11 @@ const node_child_process_1 = require("node:child_process");
|
|
|
38
33
|
choices: [
|
|
39
34
|
{
|
|
40
35
|
title: "Mantine UI - Notifications",
|
|
41
|
-
value:
|
|
36
|
+
value: ExtraPackage.MantineUiNotifications
|
|
42
37
|
},
|
|
43
38
|
{
|
|
44
39
|
title: "NextAuth",
|
|
45
|
-
value:
|
|
40
|
+
value: ExtraPackage.NextAuth
|
|
46
41
|
}
|
|
47
42
|
]
|
|
48
43
|
}
|
|
@@ -50,19 +45,19 @@ const node_child_process_1 = require("node:child_process");
|
|
|
50
45
|
const { name, extraPackages } = response;
|
|
51
46
|
if (!name || !extraPackages)
|
|
52
47
|
process.exit(1);
|
|
53
|
-
if (!(
|
|
48
|
+
if (!promiseType(name))
|
|
54
49
|
return;
|
|
55
|
-
if (!(
|
|
50
|
+
if (!promiseType(extraPackages))
|
|
56
51
|
return;
|
|
57
52
|
// Creating Next.js project
|
|
58
53
|
{
|
|
59
|
-
const spinner = (
|
|
54
|
+
const spinner = ora("Creating Next.js project...").start();
|
|
60
55
|
try {
|
|
61
|
-
|
|
62
|
-
spinner.succeed(
|
|
56
|
+
execSync("npx create-next-app . --yes --empty");
|
|
57
|
+
spinner.succeed(chalk.green("Created Next.js project!"));
|
|
63
58
|
}
|
|
64
59
|
catch {
|
|
65
|
-
spinner.fail(
|
|
60
|
+
spinner.fail(chalk.red("Could not create Next.js project!"));
|
|
66
61
|
process.exit(1);
|
|
67
62
|
}
|
|
68
63
|
}
|
|
@@ -72,61 +67,61 @@ const node_child_process_1 = require("node:child_process");
|
|
|
72
67
|
"@mantine/hooks",
|
|
73
68
|
"react-i18next",
|
|
74
69
|
"i18next",
|
|
75
|
-
...(extraPackages.includes(
|
|
70
|
+
...(extraPackages.includes(ExtraPackage.MantineUiNotifications)
|
|
76
71
|
? ["@mantine/notifications"]
|
|
77
72
|
: []),
|
|
78
|
-
...(extraPackages.includes(
|
|
73
|
+
...(extraPackages.includes(ExtraPackage.NextAuth)
|
|
79
74
|
? ["next-auth"]
|
|
80
75
|
: [])
|
|
81
76
|
];
|
|
82
77
|
for (const pkg of packagesToInstall) {
|
|
83
|
-
const spinner = (
|
|
78
|
+
const spinner = ora(`Installing ${pkg}...`).start();
|
|
84
79
|
try {
|
|
85
|
-
|
|
86
|
-
spinner.succeed(
|
|
80
|
+
execSync(`npm i ${pkg}`);
|
|
81
|
+
spinner.succeed(chalk.green(`Installed ${pkg}!`));
|
|
87
82
|
}
|
|
88
83
|
catch {
|
|
89
|
-
spinner.fail(
|
|
84
|
+
spinner.fail(chalk.red(`Could not install ${pkg}!`));
|
|
90
85
|
process.exit(1);
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
// Setting up PostCSS
|
|
94
89
|
{
|
|
95
|
-
const spinner = (
|
|
90
|
+
const spinner = ora("Setting up PostCSS...").start();
|
|
96
91
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
spinner.succeed(
|
|
92
|
+
execSync("npm i --save-dev postcss postcss-preset-mantine postcss-simple-vars");
|
|
93
|
+
fs.writeFileSync(path.join(process.cwd(), "postcss.config.mjs"), postcssConfig);
|
|
94
|
+
spinner.succeed(chalk.green("Set up PostCSS!"));
|
|
100
95
|
}
|
|
101
96
|
catch {
|
|
102
|
-
spinner.fail(
|
|
97
|
+
spinner.fail(chalk.red("Could not set up PostCSS!"));
|
|
103
98
|
process.exit(1);
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
// Setting up custom files
|
|
107
102
|
{
|
|
108
|
-
const spinner = (
|
|
103
|
+
const spinner = ora("Setting up custom files...").start();
|
|
109
104
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
?
|
|
122
|
-
:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
spinner.succeed(
|
|
105
|
+
fs.rmSync(path.join(process.cwd(), "src", "app"), { recursive: true, force: true });
|
|
106
|
+
fs.rmSync(path.join(process.cwd(), "README.md"), { recursive: true, force: true });
|
|
107
|
+
fs.mkdirSync(path.join(process.cwd(), "src", "app"), { recursive: true });
|
|
108
|
+
fs.mkdirSync(path.join(process.cwd(), "src", "components", "common"), { recursive: true });
|
|
109
|
+
fs.mkdirSync(path.join(process.cwd(), "src", "css"), { recursive: true });
|
|
110
|
+
fs.mkdirSync(path.join(process.cwd(), "src", "utils", "i18n", "resources"), { recursive: true });
|
|
111
|
+
fs.mkdirSync(path.join(process.cwd(), "src", "types", "common"), { recursive: true });
|
|
112
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "app", "layout.tsx"), nextLayout);
|
|
113
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "app", "page.tsx"), nextPage);
|
|
114
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "components", "common", "Providers.tsx"), providersComponent);
|
|
115
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "css", "globals.css"), extraPackages.includes(ExtraPackage.MantineUiNotifications)
|
|
116
|
+
? globalCssNotifs
|
|
117
|
+
: globalCss);
|
|
118
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "utils", "i18n", "resources", "en.json"), languageResource);
|
|
119
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "utils", "i18n", "index.ts"), i18nConfig);
|
|
120
|
+
fs.writeFileSync(path.join(process.cwd(), "src", "types", "common", "ParentProps.ts"), parentPropsType);
|
|
121
|
+
spinner.succeed(chalk.green("Set up custom files!"));
|
|
127
122
|
}
|
|
128
123
|
catch (error) {
|
|
129
|
-
spinner.fail(
|
|
124
|
+
spinner.fail(chalk.red("Could not set up custom files!"));
|
|
130
125
|
console.log(error);
|
|
131
126
|
process.exit(1);
|
|
132
127
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const globalCssNotifs = `
|
|
4
2
|
@layer theme, base, components, mantine, utilities;
|
|
5
3
|
|
|
@@ -7,4 +5,4 @@ const globalCssNotifs = `
|
|
|
7
5
|
@import "@mantine/core/styles.layer.css";
|
|
8
6
|
@import "@mantine/notifications/styles.layer.css";
|
|
9
7
|
`.trim();
|
|
10
|
-
|
|
8
|
+
export default globalCssNotifs;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const globalCss = `
|
|
4
2
|
@layer theme, base, components, mantine, utilities;
|
|
5
3
|
|
|
6
4
|
@import "tailwindcss";
|
|
7
5
|
@import "@mantine/core/styles.layer.css";
|
|
8
6
|
`.trim();
|
|
9
|
-
|
|
7
|
+
export default globalCss;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const i18nConfig = `
|
|
4
2
|
import i18next from "i18next";
|
|
5
3
|
import en from "./resources/en.json";
|
|
@@ -17,4 +15,4 @@ i18next
|
|
|
17
15
|
}
|
|
18
16
|
});
|
|
19
17
|
`.trim();
|
|
20
|
-
|
|
18
|
+
export default i18nConfig;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const languageResource = `
|
|
4
2
|
{
|
|
5
3
|
"translation": {
|
|
@@ -9,4 +7,4 @@ const languageResource = `
|
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
9
|
`.trim();
|
|
12
|
-
|
|
10
|
+
export default languageResource;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const nextLayout = `
|
|
4
2
|
import { Metadata } from "next";
|
|
5
3
|
import { ColorSchemeScript, mantineHtmlProps } from "@mantine/core";
|
|
@@ -89,4 +87,4 @@ const RootLayout = ({ children }: ParentProps) => (
|
|
|
89
87
|
|
|
90
88
|
export default RootLayout;
|
|
91
89
|
`.trim();
|
|
92
|
-
|
|
90
|
+
export default nextLayout;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const parentPropsType = `
|
|
4
2
|
import { ReactNode } from "react";
|
|
5
3
|
|
|
@@ -9,4 +7,4 @@ type ParentProps<T = ReactNode> = {
|
|
|
9
7
|
|
|
10
8
|
export default ParentProps;
|
|
11
9
|
`.trim();
|
|
12
|
-
|
|
10
|
+
export default parentPropsType;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const postcssConfig = `
|
|
4
2
|
const config = {
|
|
5
3
|
plugins: {
|
|
@@ -19,4 +17,4 @@ const config = {
|
|
|
19
17
|
|
|
20
18
|
export default config;
|
|
21
19
|
`.trim();
|
|
22
|
-
|
|
20
|
+
export default postcssConfig;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const providersComponent = `
|
|
4
2
|
"use client";
|
|
5
3
|
|
|
@@ -19,4 +17,4 @@ const Providers = ({ children }: ParentProps) => (
|
|
|
19
17
|
|
|
20
18
|
export default Providers;
|
|
21
19
|
`.trim();
|
|
22
|
-
|
|
20
|
+
export default providersComponent;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
var ExtraPackage;
|
|
4
2
|
(function (ExtraPackage) {
|
|
5
3
|
ExtraPackage[ExtraPackage["MantineUiNotifications"] = 0] = "MantineUiNotifications";
|
|
6
4
|
ExtraPackage[ExtraPackage["NextAuth"] = 1] = "NextAuth";
|
|
7
5
|
})(ExtraPackage || (ExtraPackage = {}));
|
|
8
|
-
|
|
6
|
+
export default ExtraPackage;
|