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