@kvihaugen/create-frontend-app 1.0.1 → 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/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@kvihaugen/create-frontend-app",
3
- "version": "1.0.1",
4
- "main": "index.js",
3
+ "version": "1.0.3",
4
+ "main": "dist/index.js",
5
+ "type": "module",
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },
@@ -11,6 +12,7 @@
11
12
  "scripts": {
12
13
  "build": "tsc"
13
14
  },
15
+ "files": ["dist"],
14
16
  "author": "",
15
17
  "license": "MIT",
16
18
  "description": "",
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
@@ -1,37 +0,0 @@
1
- name: Publish to NPM
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
-
12
- permissions:
13
- contents: write
14
- packages: write
15
- id-token: write
16
-
17
- steps:
18
-
19
- - name: Checkout repository
20
- uses: actions/checkout@v4
21
-
22
- - name: Set up Node.js
23
- uses: actions/setup-node@v4
24
- with:
25
- node-version: 20
26
- registry-url: 'https://registry.npmjs.org/'
27
-
28
- - name: Install dependencies
29
- run: npm ci
30
-
31
- - name: Build project
32
- run: npm run build
33
-
34
- - name: Publish to NPM registry
35
- env:
36
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37
- run: npm publish
package/src/index.ts DELETED
@@ -1,222 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import prompts from "prompts";
4
- import ExtraPackage from "./types/ExtraPackage";
5
- import chalk from "chalk";
6
- import promiseType from "./utils/functions/promiseType";
7
- import ora from "ora";
8
- import fs from "node:fs";
9
- import path from "node:path";
10
- import postcssConfig from "./text-templates/postcss-config";
11
- import nextLayout from "./text-templates/next-layout";
12
- import nextPage from "./text-templates/next-page";
13
- import providersComponent from "./text-templates/providers-component";
14
- import globalCssNotifs from "./text-templates/global-css-notifs";
15
- import globalCss from "./text-templates/global-css";
16
- import languageResource from "./text-templates/language-resource";
17
- import i18nConfig from "./text-templates/i18n-config";
18
- import parentPropsType from "./text-templates/parent-props-type";
19
-
20
- import { execSync } from "node:child_process";
21
-
22
- (async () => {
23
- console.log(chalk.cyan("🚀 Create a new frontend app!"));
24
-
25
-
26
-
27
- // Prompting
28
-
29
- const response = await prompts([
30
- {
31
- type: "text",
32
- name: "name",
33
- message: "Project name:",
34
- initial: "app"
35
- },
36
- {
37
- type: "multiselect",
38
- name: "extraPackages",
39
- message: "Extra packages:",
40
- choices: [
41
- {
42
- title: "Mantine UI - Notifications",
43
- value: ExtraPackage.MantineUiNotifications
44
- },
45
- {
46
- title: "NextAuth",
47
- value: ExtraPackage.NextAuth
48
- }
49
- ]
50
- }
51
- ]);
52
-
53
- const { name, extraPackages } = response;
54
-
55
- if (!name || !extraPackages) process.exit(1);
56
-
57
- if (!promiseType<string>(name)) return;
58
- if (!promiseType<number[]>(extraPackages)) return;
59
-
60
-
61
-
62
- // Creating Next.js project
63
- {
64
- const spinner = ora("Creating Next.js project...").start();
65
-
66
- try {
67
- execSync("npx create-next-app . --yes --empty");
68
-
69
- spinner.succeed(chalk.green("Created Next.js project!"));
70
- }
71
- catch {
72
- spinner.fail(chalk.red("Could not create Next.js project!"));
73
-
74
- process.exit(1);
75
- }
76
- }
77
-
78
-
79
-
80
- // Installing additional packages
81
-
82
- const packagesToInstall = [
83
- "@mantine/core",
84
- "@mantine/hooks",
85
- "react-i18next",
86
- "i18next",
87
- ...(
88
- extraPackages.includes(ExtraPackage.MantineUiNotifications)
89
- ? ["@mantine/notifications"]
90
- : []
91
- ),
92
- ...(
93
- extraPackages.includes(ExtraPackage.NextAuth)
94
- ? ["next-auth"]
95
- : []
96
- )
97
- ];
98
-
99
- for (const pkg of packagesToInstall) {
100
- const spinner = ora(`Installing ${pkg}...`).start();
101
-
102
- try {
103
- execSync(`npm i ${pkg}`);
104
-
105
- spinner.succeed(chalk.green(`Installed ${pkg}!`));
106
- }
107
- catch {
108
- spinner.fail(chalk.red(`Could not install ${pkg}!`));
109
-
110
- process.exit(1);
111
- }
112
- }
113
-
114
-
115
-
116
- // Setting up PostCSS
117
- {
118
- const spinner = ora("Setting up PostCSS...").start();
119
-
120
- try {
121
- execSync("npm i --save-dev postcss postcss-preset-mantine postcss-simple-vars");
122
-
123
- fs.writeFileSync(
124
- path.join(process.cwd(), "postcss.config.mjs"),
125
- postcssConfig
126
- );
127
-
128
- spinner.succeed(chalk.green("Set up PostCSS!"));
129
- }
130
- catch {
131
- spinner.fail(chalk.red("Could not set up PostCSS!"));
132
-
133
- process.exit(1);
134
- }
135
- }
136
-
137
-
138
-
139
- // Setting up custom files
140
- {
141
- const spinner = ora("Setting up custom files...").start();
142
-
143
- try {
144
- fs.rmSync(path.join(process.cwd(), "src", "app"), { recursive: true, force: true });
145
- fs.rmSync(path.join(process.cwd(), "README.md"), { recursive: true, force: true });
146
-
147
-
148
- fs.mkdirSync(
149
- path.join(process.cwd(), "src", "app"),
150
- { recursive: true }
151
- );
152
-
153
- fs.mkdirSync(
154
- path.join(process.cwd(), "src", "components", "common"),
155
- { recursive: true }
156
- );
157
-
158
- fs.mkdirSync(
159
- path.join(process.cwd(), "src", "css"),
160
- { recursive: true }
161
- );
162
-
163
- fs.mkdirSync(
164
- path.join(process.cwd(), "src", "utils", "i18n", "resources"),
165
- { recursive: true }
166
- );
167
-
168
- fs.mkdirSync(
169
- path.join(process.cwd(), "src", "types", "common"),
170
- { recursive: true }
171
- );
172
-
173
-
174
- fs.writeFileSync(
175
- path.join(process.cwd(), "src", "app", "layout.tsx"),
176
- nextLayout
177
- );
178
-
179
- fs.writeFileSync(
180
- path.join(process.cwd(), "src", "app", "page.tsx"),
181
- nextPage
182
- );
183
-
184
- fs.writeFileSync(
185
- path.join(process.cwd(), "src", "components", "common", "Providers.tsx"),
186
- providersComponent
187
- );
188
-
189
- fs.writeFileSync(
190
- path.join(process.cwd(), "src", "css", "globals.css"),
191
- extraPackages.includes(ExtraPackage.MantineUiNotifications)
192
- ? globalCssNotifs
193
- : globalCss
194
- );
195
-
196
- fs.writeFileSync(
197
- path.join(process.cwd(), "src", "utils", "i18n", "resources", "en.json"),
198
- languageResource
199
- );
200
-
201
- fs.writeFileSync(
202
- path.join(process.cwd(), "src", "utils", "i18n", "index.ts"),
203
- i18nConfig
204
- );
205
-
206
- fs.writeFileSync(
207
- path.join(process.cwd(), "src", "types", "common", "ParentProps.ts"),
208
- parentPropsType
209
- );
210
-
211
-
212
- spinner.succeed(chalk.green("Set up custom files!"));
213
- }
214
- catch (error) {
215
- spinner.fail(chalk.red("Could not set up custom files!"));
216
-
217
- console.log(error);
218
-
219
- process.exit(1);
220
- }
221
- }
222
- })();
@@ -1,9 +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
-
9
- export default globalCssNotifs;
@@ -1,8 +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
-
8
- export default globalCss;
@@ -1,19 +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
-
19
- export default i18nConfig;
@@ -1,11 +0,0 @@
1
- const languageResource = `
2
- {
3
- "translation": {
4
- "common": {
5
- "HelloWorld": "Hello world!"
6
- }
7
- }
8
- }
9
- `.trim();
10
-
11
- export default languageResource;
@@ -1,91 +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
-
91
- export default nextLayout;
@@ -1,18 +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
-
18
- export default nextPage;
@@ -1,11 +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
-
11
- export default parentPropsType;
@@ -1,21 +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
-
21
- export default postcssConfig;
@@ -1,21 +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
-
21
- export default providersComponent;
@@ -1,6 +0,0 @@
1
- enum ExtraPackage {
2
- MantineUiNotifications,
3
- NextAuth
4
- }
5
-
6
- export default ExtraPackage;
@@ -1,3 +0,0 @@
1
- const promiseType = <T>(v: any): v is T => true;
2
-
3
- export default promiseType;
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2020",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "outDir": "dist",
7
- "esModuleInterop": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "strict": true,
10
- "skipLibCheck": true
11
- },
12
- "include": ["src"]
13
- }