@kvihaugen/create-frontend-app 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@kvihaugen/create-frontend-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
+ "type": "module",
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },
package/dist/index.js DELETED
@@ -1,134 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const prompts_1 = __importDefault(require("prompts"));
8
- const ExtraPackage_1 = __importDefault(require("./types/ExtraPackage"));
9
- const chalk_1 = __importDefault(require("chalk"));
10
- const promiseType_1 = __importDefault(require("./utils/functions/promiseType"));
11
- const ora_1 = __importDefault(require("ora"));
12
- const node_fs_1 = __importDefault(require("node:fs"));
13
- const node_path_1 = __importDefault(require("node:path"));
14
- const postcss_config_1 = __importDefault(require("./text-templates/postcss-config"));
15
- const next_layout_1 = __importDefault(require("./text-templates/next-layout"));
16
- const next_page_1 = __importDefault(require("./text-templates/next-page"));
17
- const providers_component_1 = __importDefault(require("./text-templates/providers-component"));
18
- const global_css_notifs_1 = __importDefault(require("./text-templates/global-css-notifs"));
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");
24
- (async () => {
25
- console.log(chalk_1.default.cyan("🚀 Create a new frontend app!"));
26
- // Prompting
27
- const response = await (0, prompts_1.default)([
28
- {
29
- type: "text",
30
- name: "name",
31
- message: "Project name:",
32
- initial: "app"
33
- },
34
- {
35
- type: "multiselect",
36
- name: "extraPackages",
37
- message: "Extra packages:",
38
- choices: [
39
- {
40
- title: "Mantine UI - Notifications",
41
- value: ExtraPackage_1.default.MantineUiNotifications
42
- },
43
- {
44
- title: "NextAuth",
45
- value: ExtraPackage_1.default.NextAuth
46
- }
47
- ]
48
- }
49
- ]);
50
- const { name, extraPackages } = response;
51
- if (!name || !extraPackages)
52
- process.exit(1);
53
- if (!(0, promiseType_1.default)(name))
54
- return;
55
- if (!(0, promiseType_1.default)(extraPackages))
56
- return;
57
- // Creating Next.js project
58
- {
59
- const spinner = (0, ora_1.default)("Creating Next.js project...").start();
60
- try {
61
- (0, node_child_process_1.execSync)("npx create-next-app . --yes --empty");
62
- spinner.succeed(chalk_1.default.green("Created Next.js project!"));
63
- }
64
- catch {
65
- spinner.fail(chalk_1.default.red("Could not create Next.js project!"));
66
- process.exit(1);
67
- }
68
- }
69
- // Installing additional packages
70
- const packagesToInstall = [
71
- "@mantine/core",
72
- "@mantine/hooks",
73
- "react-i18next",
74
- "i18next",
75
- ...(extraPackages.includes(ExtraPackage_1.default.MantineUiNotifications)
76
- ? ["@mantine/notifications"]
77
- : []),
78
- ...(extraPackages.includes(ExtraPackage_1.default.NextAuth)
79
- ? ["next-auth"]
80
- : [])
81
- ];
82
- for (const pkg of packagesToInstall) {
83
- const spinner = (0, ora_1.default)(`Installing ${pkg}...`).start();
84
- try {
85
- (0, node_child_process_1.execSync)(`npm i ${pkg}`);
86
- spinner.succeed(chalk_1.default.green(`Installed ${pkg}!`));
87
- }
88
- catch {
89
- spinner.fail(chalk_1.default.red(`Could not install ${pkg}!`));
90
- process.exit(1);
91
- }
92
- }
93
- // Setting up PostCSS
94
- {
95
- const spinner = (0, ora_1.default)("Setting up PostCSS...").start();
96
- try {
97
- (0, node_child_process_1.execSync)("npm i --save-dev postcss postcss-preset-mantine postcss-simple-vars");
98
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "postcss.config.mjs"), postcss_config_1.default);
99
- spinner.succeed(chalk_1.default.green("Set up PostCSS!"));
100
- }
101
- catch {
102
- spinner.fail(chalk_1.default.red("Could not set up PostCSS!"));
103
- process.exit(1);
104
- }
105
- }
106
- // Setting up custom files
107
- {
108
- const spinner = (0, ora_1.default)("Setting up custom files...").start();
109
- try {
110
- node_fs_1.default.rmSync(node_path_1.default.join(process.cwd(), "src", "app"), { recursive: true, force: true });
111
- node_fs_1.default.rmSync(node_path_1.default.join(process.cwd(), "README.md"), { recursive: true, force: true });
112
- node_fs_1.default.mkdirSync(node_path_1.default.join(process.cwd(), "src", "app"), { recursive: true });
113
- node_fs_1.default.mkdirSync(node_path_1.default.join(process.cwd(), "src", "components", "common"), { recursive: true });
114
- node_fs_1.default.mkdirSync(node_path_1.default.join(process.cwd(), "src", "css"), { recursive: true });
115
- node_fs_1.default.mkdirSync(node_path_1.default.join(process.cwd(), "src", "utils", "i18n", "resources"), { recursive: true });
116
- node_fs_1.default.mkdirSync(node_path_1.default.join(process.cwd(), "src", "types", "common"), { recursive: true });
117
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "app", "layout.tsx"), next_layout_1.default);
118
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "app", "page.tsx"), next_page_1.default);
119
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "components", "common", "Providers.tsx"), providers_component_1.default);
120
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "css", "globals.css"), extraPackages.includes(ExtraPackage_1.default.MantineUiNotifications)
121
- ? global_css_notifs_1.default
122
- : global_css_1.default);
123
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "utils", "i18n", "resources", "en.json"), language_resource_1.default);
124
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "utils", "i18n", "index.ts"), i18n_config_1.default);
125
- node_fs_1.default.writeFileSync(node_path_1.default.join(process.cwd(), "src", "types", "common", "ParentProps.ts"), parent_props_type_1.default);
126
- spinner.succeed(chalk_1.default.green("Set up custom files!"));
127
- }
128
- catch (error) {
129
- spinner.fail(chalk_1.default.red("Could not set up custom files!"));
130
- console.log(error);
131
- process.exit(1);
132
- }
133
- }
134
- })();
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const globalCssNotifs = `
4
- @layer theme, base, components, mantine, utilities;
5
-
6
- @import "tailwindcss";
7
- @import "@mantine/core/styles.layer.css";
8
- @import "@mantine/notifications/styles.layer.css";
9
- `.trim();
10
- exports.default = globalCssNotifs;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const globalCss = `
4
- @layer theme, base, components, mantine, utilities;
5
-
6
- @import "tailwindcss";
7
- @import "@mantine/core/styles.layer.css";
8
- `.trim();
9
- exports.default = globalCss;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const i18nConfig = `
4
- import i18next from "i18next";
5
- import en from "./resources/en.json";
6
-
7
- import { initReactI18next } from "react-i18next";
8
-
9
- i18next
10
- .use(initReactI18next)
11
- .init({
12
- resources: { en },
13
- lng: "en",
14
- fallbackLng: "en",
15
- interpolation: {
16
- escapeValue: false
17
- }
18
- });
19
- `.trim();
20
- exports.default = i18nConfig;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const languageResource = `
4
- {
5
- "translation": {
6
- "common": {
7
- "HelloWorld": "Hello world!"
8
- }
9
- }
10
- }
11
- `.trim();
12
- exports.default = languageResource;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const nextLayout = `
4
- import { Metadata } from "next";
5
- import { ColorSchemeScript, mantineHtmlProps } from "@mantine/core";
6
-
7
- import ParentProps from "@/types/common/ParentProps";
8
- import Providers from "@/components/common/Providers";
9
-
10
- import "@/css/globals.css";
11
-
12
- // https://seostudio.tools/meta-tag-generator
13
- // https://www.searchenginejournal.com/important-tags-seo/156440/
14
-
15
- export const metadata = {
16
- title: "Frontend template",
17
- description: "My preferred template for frontend projects - tailored to my needs",
18
- applicationName: "Frontend template",
19
- authors: [{
20
- url: "https://lars.kvihaugen.no",
21
- name: "Lars Kvihaugen"
22
- }],
23
- generator: "Next.js",
24
- keywords: [
25
- "next.js",
26
- "next",
27
- "react",
28
- "frontend",
29
- "development",
30
- "dev"
31
- ],
32
- referrer: "origin",
33
- creator: "Lars Kvihaugen",
34
- publisher: "Lars Kvihaugen",
35
- robots: {
36
- index: true,
37
- follow: true
38
- },
39
- alternates: {
40
- canonical: "https://frontend-template.kvihaugen.no",
41
- languages: {
42
- en: "https://frontend-template.kvihaugen.no",
43
- no: "https://no.frontend-template.kvihaugen.no"
44
- }
45
- },
46
- icons: {
47
- icon: [{
48
- url: "/icons/icon-128x128.png",
49
- sizes: "128x128"
50
- }],
51
- apple: [{
52
- url: "/icons/icon-apple/128x128.png",
53
- sizes: "128x128"
54
- }]
55
- },
56
- manifest: "/.well-known/app.webmanifest",
57
- openGraph: {
58
- type: "website",
59
- title: "Frontend template",
60
- description: "My preferred template for frontend projects - tailored to my needs",
61
- emails: ["lars@kvihaugen.no"],
62
- phoneNumbers: ["+00 000 00 000"],
63
- siteName: "Frontend template",
64
- locale: "en",
65
- alternateLocale: ["no"],
66
- images: [{
67
- url: "/images/hero.png",
68
- alt: "The page hero",
69
- width: 1920,
70
- height: 1080
71
- }],
72
- url: "https://frontend-template.kvihaugen.no"
73
- },
74
- metadataBase: new URL("https://frontend-template.kvihaugen.no")
75
- } satisfies Metadata as Metadata;
76
-
77
- const RootLayout = ({ children }: ParentProps) => (
78
- <html {...mantineHtmlProps}>
79
- <head>
80
- <ColorSchemeScript />
81
- </head>
82
- <body className="antialiased">
83
- <Providers>
84
- {children}
85
- </Providers>
86
- </body>
87
- </html>
88
- );
89
-
90
- export default RootLayout;
91
- `.trim();
92
- exports.default = nextLayout;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const nextPage = `
4
- "use client";
5
-
6
- import { Button } from "@mantine/core";
7
- import { t } from "i18next";
8
-
9
- const Page = () => {
10
- return (
11
- <Button>
12
- {t("common.HelloWorld")}
13
- </Button>
14
- );
15
- };
16
-
17
- export default Page;
18
- `.trim();
19
- exports.default = nextPage;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const parentPropsType = `
4
- import { ReactNode } from "react";
5
-
6
- type ParentProps<T = ReactNode> = {
7
- children?: T;
8
- };
9
-
10
- export default ParentProps;
11
- `.trim();
12
- exports.default = parentPropsType;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const postcssConfig = `
4
- const config = {
5
- plugins: {
6
- "@tailwindcss/postcss": {},
7
- "postcss-preset-mantine": {},
8
- "postcss-simple-vars": {
9
- variables: {
10
- "mantine-breakpoint-xs": "36em",
11
- "mantine-breakpoint-sm": "48em",
12
- "mantine-breakpoint-md": "62em",
13
- "mantine-breakpoint-lg": "75em",
14
- "mantine-breakpoint-xl": "88em",
15
- },
16
- },
17
- },
18
- };
19
-
20
- export default config;
21
- `.trim();
22
- exports.default = postcssConfig;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const providersComponent = `
4
- "use client";
5
-
6
- import ParentProps from "@/types/common/ParentProps";
7
-
8
- import { createTheme, MantineProvider } from "@mantine/core";
9
-
10
- import "@/utils/i18n";
11
-
12
- const theme = createTheme({});
13
-
14
- const Providers = ({ children }: ParentProps) => (
15
- <MantineProvider theme={theme}>
16
- {children}
17
- </MantineProvider>
18
- );
19
-
20
- export default Providers;
21
- `.trim();
22
- exports.default = providersComponent;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var ExtraPackage;
4
- (function (ExtraPackage) {
5
- ExtraPackage[ExtraPackage["MantineUiNotifications"] = 0] = "MantineUiNotifications";
6
- ExtraPackage[ExtraPackage["NextAuth"] = 1] = "NextAuth";
7
- })(ExtraPackage || (ExtraPackage = {}));
8
- exports.default = ExtraPackage;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const promiseType = (v) => true;
4
- exports.default = promiseType;