@kvihaugen/create-frontend-app 1.0.4 → 1.1.0

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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,35 @@
1
+ name: Build and publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ permissions:
9
+ id-token: write
10
+ contents: read
11
+
12
+ jobs:
13
+ build-and-publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Install Node.js
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: '20'
23
+ registry-url: 'https://registry.npmjs.org'
24
+
25
+ - name: Update NPM
26
+ run: npm install -g npm@latest
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Build project
32
+ run: npm run build --if-present
33
+
34
+ - name: Publish artifact
35
+ run: npm publish
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import os from "node:os";
3
+ import fs from "node:fs";
4
+ import degit from "degit";
5
+ import path from "node:path";
6
+ import { execSync } from "node:child_process";
7
+ const cwd = process.cwd();
8
+ (async () => {
9
+ console.log("🚀 Creating frontend app...\n");
10
+ console.log("\t- 🔃 Generating Next.js app...");
11
+ const emitter = degit("LarsSK06/frontend-template");
12
+ const tempFolderPath = path.join(os.tmpdir(), `${Date.now()}-create-frontend-app`);
13
+ await emitter.clone(tempFolderPath);
14
+ execSync("npx create-next-app . --yes --empty --skip-install");
15
+ console.log("\t ✅ Generated Next.js app!\n");
16
+ console.log("\t- 🔃 Cloning files from template...");
17
+ for (const objName of [
18
+ "src",
19
+ "public",
20
+ "postcss.config.mjs",
21
+ "next.config.ts"
22
+ ]) {
23
+ const absoluteCwdPath = path.join(cwd, objName);
24
+ const absoluteTempFolderPath = path.join(tempFolderPath, objName);
25
+ if (fs.existsSync(absoluteCwdPath)) {
26
+ const stat = fs.statSync(absoluteCwdPath);
27
+ if (stat.isFile())
28
+ fs.unlinkSync(absoluteCwdPath);
29
+ else
30
+ fs.rmSync(absoluteCwdPath, { recursive: true, force: true });
31
+ }
32
+ fs.cpSync(absoluteTempFolderPath, absoluteCwdPath, { recursive: true });
33
+ }
34
+ console.log("\t ✅ Cloned files from template!\n");
35
+ console.log("\t- 🔃 Formatting files...");
36
+ for (const fileName of [
37
+ "package.json",
38
+ "package-lock.json",
39
+ "tsconfig.json"
40
+ ]) {
41
+ const absolutePath = path.join(cwd, fileName);
42
+ if (!fs.existsSync(absolutePath))
43
+ continue;
44
+ const fileContent = fs.readFileSync(absolutePath).toString();
45
+ fs.writeFileSync(absolutePath, JSON.stringify(JSON.parse(fileContent), null, 4));
46
+ }
47
+ console.log("\t ✅ Formatted files!\n");
48
+ console.log("\t- 🔃 Deleting unnecessary files...");
49
+ for (const objName of [
50
+ "README.md"
51
+ ]) {
52
+ const absolutePath = path.join(cwd, objName);
53
+ if (!fs.existsSync(absolutePath))
54
+ continue;
55
+ const stat = fs.statSync(absolutePath);
56
+ if (stat.isFile())
57
+ fs.unlinkSync(absolutePath);
58
+ else
59
+ fs.rmSync(absolutePath, { recursive: true, force: true });
60
+ }
61
+ console.log("\t ✅ Deleted unnecessary files!");
62
+ })();
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OA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AAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAEpD,CAAC,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,32 +1,27 @@
1
1
  {
2
2
  "name": "@kvihaugen/create-frontend-app",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
6
  "bin": {
10
- "create-frontend-app": "dist/index.js"
7
+ "create-frontend-app": "./dist/index.js"
11
8
  },
12
9
  "scripts": {
13
- "build": "tsc"
10
+ "build": "tsc",
11
+ "prepublishOnly": "npm run build"
14
12
  },
15
- "files": ["dist"],
16
13
  "author": "",
17
14
  "license": "MIT",
18
15
  "description": "",
19
- "dependencies": {
20
- "chalk": "^5.6.2",
21
- "ora": "^9.0.0",
22
- "prompts": "^2.4.2"
23
- },
24
16
  "devDependencies": {
25
- "@types/chalk": "^0.4.31",
17
+ "@types/degit": "^2.8.6",
26
18
  "@types/node": "^24.10.0",
27
- "@types/ora": "^3.1.0",
28
19
  "@types/prompts": "^2.4.9",
29
20
  "ts-node": "^10.9.2",
30
21
  "typescript": "^5.9.3"
22
+ },
23
+ "dependencies": {
24
+ "degit": "^2.8.4",
25
+ "prompts": "^2.4.2"
31
26
  }
32
27
  }
package/src/index.ts ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+
3
+ import os from "node:os";
4
+ import fs from "node:fs";
5
+ import degit from "degit";
6
+ import path from "node:path";
7
+
8
+ import { execSync } from "node:child_process";
9
+
10
+ const cwd = process.cwd();
11
+
12
+ (async () => {
13
+
14
+ console.log("🚀 Creating frontend app...\n");
15
+
16
+
17
+ console.log("\t- 🔃 Generating Next.js app...");
18
+
19
+ const emitter = degit("LarsSK06/frontend-template");
20
+
21
+ const tempFolderPath = path.join(os.tmpdir(), `${Date.now()}-create-frontend-app`);
22
+
23
+ await emitter.clone(tempFolderPath);
24
+
25
+ execSync("npx create-next-app . --yes --empty --skip-install");
26
+
27
+ console.log("\t ✅ Generated Next.js app!\n");
28
+
29
+
30
+ console.log("\t- 🔃 Cloning files from template...");
31
+
32
+ for (const objName of [
33
+ "src",
34
+ "public",
35
+ "postcss.config.mjs",
36
+ "next.config.ts"
37
+ ]) {
38
+ const absoluteCwdPath = path.join(cwd, objName);
39
+ const absoluteTempFolderPath = path.join(tempFolderPath, objName);
40
+
41
+ if (fs.existsSync(absoluteCwdPath)) {
42
+ const stat = fs.statSync(absoluteCwdPath);
43
+
44
+ if (stat.isFile()) fs.unlinkSync(absoluteCwdPath);
45
+ else fs.rmSync(absoluteCwdPath, { recursive: true, force: true });
46
+ }
47
+
48
+ fs.cpSync(
49
+ absoluteTempFolderPath,
50
+ absoluteCwdPath,
51
+ { recursive: true }
52
+ );
53
+ }
54
+
55
+ console.log("\t ✅ Cloned files from template!\n");
56
+
57
+
58
+ console.log("\t- 🔃 Formatting files...");
59
+
60
+ for (const fileName of [
61
+ "package.json",
62
+ "package-lock.json",
63
+ "tsconfig.json"
64
+ ]) {
65
+ const absolutePath = path.join(cwd, fileName);
66
+
67
+ if (!fs.existsSync(absolutePath))
68
+ continue;
69
+
70
+ const fileContent = fs.readFileSync(absolutePath).toString();
71
+
72
+ fs.writeFileSync(
73
+ absolutePath,
74
+ JSON.stringify(JSON.parse(fileContent), null, 4)
75
+ );
76
+ }
77
+
78
+ console.log("\t ✅ Formatted files!\n");
79
+
80
+
81
+ console.log("\t- 🔃 Deleting unnecessary files...");
82
+
83
+ for (const objName of [
84
+ "README.md"
85
+ ]) {
86
+ const absolutePath = path.join(cwd, objName);
87
+
88
+ if (!fs.existsSync(absolutePath))
89
+ continue;
90
+
91
+ const stat = fs.statSync(absolutePath);
92
+
93
+ if (stat.isFile()) fs.unlinkSync(absolutePath);
94
+ else fs.rmSync(absolutePath, { recursive: true, force: true });
95
+ }
96
+
97
+ console.log("\t ✅ Deleted unnecessary files!");
98
+
99
+ })();
package/tsconfig.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "./src",
4
+ "outDir": "./dist",
5
+ "module": "nodenext",
6
+ "target": "esnext",
7
+ "types": ["node"],
8
+ "sourceMap": true,
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "noUncheckedIndexedAccess": true,
12
+ "exactOptionalPropertyTypes": true,
13
+ // "noImplicitReturns": true,
14
+ // "noImplicitOverride": true,
15
+ // "noUnusedLocals": true,
16
+ // "noUnusedParameters": true,
17
+ // "noFallthroughCasesInSwitch": true,
18
+ // "noPropertyAccessFromIndexSignature": true,
19
+ "strict": true,
20
+ "jsx": "react-jsx",
21
+ "verbatimModuleSyntax": true,
22
+ "isolatedModules": true,
23
+ "noUncheckedSideEffectImports": true,
24
+ "moduleDetection": "force",
25
+ "skipLibCheck": true
26
+ },
27
+ "include": ["src/**/*"],
28
+ "exclude": ["node_modules", "dist"]
29
+ }