create-xplora-app 0.0.1

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/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # Create Xplora App šŸš€
2
+
3
+ CLI tool untuk membuat aplikasi XploraJS statis baru dengan cepat.
4
+
5
+ ## šŸš€ Penggunaan
6
+
7
+ ```bash
8
+ # Menggunakan bun
9
+ bun create xplora-app my-app
10
+
11
+ # Menggunakan npm
12
+ npx create-xplora-app my-app
13
+
14
+ # Menggunakan yarn
15
+ yarn create xplora-app my-app
16
+ ```
17
+
18
+ ## šŸ“¦ Fitur Template
19
+
20
+ Template aplikasi yang dibuat mencakup:
21
+
22
+ - TypeScript configuration
23
+ - React setup
24
+ - Static site generation
25
+ - File system routing
26
+ - Development server
27
+ - Build configuration
28
+ - Hot Module Replacement (HMR)
29
+ - Incremental Static Regeneration (ISR)
30
+
31
+ ## šŸ› ļø Struktur Project
32
+
33
+ ```
34
+ my-app/
35
+ ā”œā”€ā”€ src/
36
+ │ ā”œā”€ā”€ app/
37
+ │ │ └── page.tsx
38
+ │ ā”œā”€ā”€ components/
39
+ │ └── static/
40
+ │ └── getStaticProps.ts
41
+ ā”œā”€ā”€ public/
42
+ ā”œā”€ā”€ xplora.config.ts
43
+ ā”œā”€ā”€ tsconfig.json
44
+ └── package.json
45
+ ```
46
+
47
+ ## šŸ“š Scripts
48
+
49
+ Setelah project dibuat, Anda dapat menggunakan script berikut:
50
+
51
+ ```bash
52
+ # Development
53
+ bun run dev
54
+
55
+ # Build static site
56
+ bun run build
57
+
58
+ # Preview static site
59
+ bun run preview
60
+ ```
61
+
62
+ ## šŸ”§ Konfigurasi
63
+
64
+ Template menyediakan konfigurasi default yang dapat disesuaikan di
65
+ `xplora.config.ts`:
66
+
67
+ ```typescript
68
+ import { defineConfig } from "xplora";
69
+
70
+ export default defineConfig({
71
+ static: {
72
+ outputDir: "./dist",
73
+ revalidate: 3600,
74
+ fallback: false,
75
+ },
76
+ build: {
77
+ minify: true,
78
+ sourcemap: true,
79
+ },
80
+ });
81
+ ```
82
+
83
+ ## šŸ¤ Kontribusi
84
+
85
+ Kami menyambut kontribusi! Silakan baca [CONTRIBUTING.md](../../CONTRIBUTING.md)
86
+ untuk panduan kontribusi.
87
+
88
+ ## šŸ“ Lisensi
89
+
90
+ MIT License - lihat [LICENSE](../../LICENSE) untuk detail lebih lanjut.
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from "node:child_process";
3
+ import { mkdir, writeFile } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+ import { copy } from "fs-extra";
6
+
7
+ const templateDir = join(import.meta.dirname, "..", "template");
8
+
9
+ async function createApp(name) {
10
+ const targetDir = join(process.cwd(), name);
11
+
12
+ await mkdir(targetDir, { recursive: true });
13
+ await copy(templateDir, targetDir);
14
+ execSync("git init", { cwd: targetDir });
15
+
16
+ console.log(`
17
+ ✨ Successfully created ${name}
18
+
19
+ Next steps:
20
+ cd ${name}
21
+ bun install
22
+ bun run dev
23
+
24
+ Happy coding! šŸš€
25
+ `);
26
+ }
27
+
28
+ const name = process.argv[2];
29
+ if (!name) {
30
+ console.error("Please provide a project name");
31
+ process.exit(1);
32
+ }
33
+
34
+ createApp(name).catch(console.error);
package/bin/index.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import fs from "fs-extra";
5
+ import prompts from "prompts";
6
+
7
+ async function main() {
8
+ const { name, ts } = await prompts([
9
+ { type: "text", name: "name", message: "Project name:" },
10
+ ]);
11
+
12
+ if (!name) process.exit(1);
13
+
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = path.dirname(__filename);
16
+
17
+ const target = path.resolve(process.cwd(), name);
18
+ if (await fs.pathExists(target)) {
19
+ console.error("āŒ Folder already exists");
20
+ process.exit(1);
21
+ }
22
+
23
+ const tplDir = path.resolve(__dirname, "../template");
24
+ if (!(await fs.pathExists(tplDir))) {
25
+ console.error("āŒ Template not found");
26
+ process.exit(1);
27
+ }
28
+
29
+ await fs.copy(tplDir, target);
30
+
31
+ const pkgPath = path.join(target, "package.json");
32
+ const pkg = await fs.readJson(pkgPath);
33
+ pkg.name = name;
34
+ if (!ts) {
35
+ pkg.devDependencies = { ...pkg.devDependencies };
36
+ if (pkg.devDependencies?.typescript) {
37
+ const { typescript, ...rest } = pkg.devDependencies;
38
+ pkg.devDependencies = rest;
39
+ }
40
+ pkg.tsconfig = undefined;
41
+ }
42
+ await fs.writeJson(pkgPath, pkg, { spaces: 2 });
43
+
44
+ console.log(`\nāœ… Project "${name}" successfully created`);
45
+ console.log("\nTo start the project, run the following commands:");
46
+ console.log(` cd ${name}\n bun install\n bun run dev`);
47
+ }
48
+
49
+ main().catch((err) => {
50
+ console.error(err);
51
+ process.exit(1);
52
+ });
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "create-xplora-app",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "create-xplora-app": "bin/create-xplora-app.js"
7
+ },
8
+ "files": [
9
+ "dist",
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "build": "swc src -d dist",
15
+ "prepublishOnly": "bun run build"
16
+ },
17
+ "dependencies": {
18
+ "fs-extra": "^11.1.1",
19
+ "prompts": "^2.4.2"
20
+ },
21
+ "devDependencies": {
22
+ "@swc/cli": "^0.1.65",
23
+ "@swc/core": "^1.11.24"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
28
+ }