@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 CHANGED
@@ -1,30 +1,25 @@
1
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");
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(chalk_1.default.cyan("🚀 Create a new frontend app!"));
20
+ console.log(chalk.cyan("🚀 Create a new frontend app!"));
26
21
  // Prompting
27
- const response = await (0, prompts_1.default)([
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: ExtraPackage_1.default.MantineUiNotifications
36
+ value: ExtraPackage.MantineUiNotifications
42
37
  },
43
38
  {
44
39
  title: "NextAuth",
45
- value: ExtraPackage_1.default.NextAuth
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 (!(0, promiseType_1.default)(name))
48
+ if (!promiseType(name))
54
49
  return;
55
- if (!(0, promiseType_1.default)(extraPackages))
50
+ if (!promiseType(extraPackages))
56
51
  return;
57
52
  // Creating Next.js project
58
53
  {
59
- const spinner = (0, ora_1.default)("Creating Next.js project...").start();
54
+ const spinner = ora("Creating Next.js project...").start();
60
55
  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!"));
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(chalk_1.default.red("Could not create Next.js project!"));
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(ExtraPackage_1.default.MantineUiNotifications)
70
+ ...(extraPackages.includes(ExtraPackage.MantineUiNotifications)
76
71
  ? ["@mantine/notifications"]
77
72
  : []),
78
- ...(extraPackages.includes(ExtraPackage_1.default.NextAuth)
73
+ ...(extraPackages.includes(ExtraPackage.NextAuth)
79
74
  ? ["next-auth"]
80
75
  : [])
81
76
  ];
82
77
  for (const pkg of packagesToInstall) {
83
- const spinner = (0, ora_1.default)(`Installing ${pkg}...`).start();
78
+ const spinner = ora(`Installing ${pkg}...`).start();
84
79
  try {
85
- (0, node_child_process_1.execSync)(`npm i ${pkg}`);
86
- spinner.succeed(chalk_1.default.green(`Installed ${pkg}!`));
80
+ execSync(`npm i ${pkg}`);
81
+ spinner.succeed(chalk.green(`Installed ${pkg}!`));
87
82
  }
88
83
  catch {
89
- spinner.fail(chalk_1.default.red(`Could not install ${pkg}!`));
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 = (0, ora_1.default)("Setting up PostCSS...").start();
90
+ const spinner = ora("Setting up PostCSS...").start();
96
91
  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!"));
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(chalk_1.default.red("Could not set up PostCSS!"));
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 = (0, ora_1.default)("Setting up custom files...").start();
103
+ const spinner = ora("Setting up custom files...").start();
109
104
  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!"));
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(chalk_1.default.red("Could not set up custom files!"));
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
- exports.default = globalCssNotifs;
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
- exports.default = globalCss;
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
- exports.default = i18nConfig;
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
- exports.default = languageResource;
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
- exports.default = nextLayout;
90
+ export default nextLayout;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const nextPage = `
4
2
  "use client";
5
3
 
@@ -16,4 +14,4 @@ const Page = () => {
16
14
 
17
15
  export default Page;
18
16
  `.trim();
19
- exports.default = nextPage;
17
+ export default nextPage;
@@ -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
- exports.default = parentPropsType;
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
- exports.default = postcssConfig;
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
- exports.default = providersComponent;
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
- exports.default = ExtraPackage;
6
+ export default ExtraPackage;
@@ -1,4 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const promiseType = (v) => true;
4
- exports.default = promiseType;
2
+ export default promiseType;
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.3",
4
4
  "main": "dist/index.js",
5
+ "type": "module",
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },