mirror of
https://github.com/ziex-dev/ziex.git
synced 2026-07-20 02:29:36 -06:00
feat: bun create ziex
This commit is contained in:
parent
3f6ff52c05
commit
4d8372740c
5
pkg/create-ziex/.gitignore
vendored
Normal file
5
pkg/create-ziex/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Zig
|
||||
.zig-cache
|
||||
|
||||
# Nodejs
|
||||
node_modules
|
||||
3
pkg/create-ziex/README.md
Normal file
3
pkg/create-ziex/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Create Ziex
|
||||
|
||||
This package provides `bun create ziex` command to create a new Ziex application.
|
||||
77
pkg/create-ziex/bin/index.js
Normal file
77
pkg/create-ziex/bin/index.js
Normal file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { intro, outro, text, select, spinner, isCancel, cancel } from '@clack/prompts';
|
||||
import color from 'picocolors';
|
||||
import { downloadTemplate } from 'giget';
|
||||
import { replaceInFile } from 'replace-in-file';
|
||||
|
||||
import path from 'node:path';
|
||||
|
||||
async function main() {
|
||||
console.log();
|
||||
intro(color.bgCyan(color.black(' create-ziex ')));
|
||||
|
||||
// 1. Gather User Input
|
||||
const project = await text({
|
||||
message: 'Where should we create your project?',
|
||||
placeholder: './my-ziex-app',
|
||||
validate: (value) => {
|
||||
if (!value) return 'Please enter a path.';
|
||||
},
|
||||
});
|
||||
|
||||
if (isCancel(project)) {
|
||||
cancel('Operation cancelled.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const template = await select({
|
||||
message: 'Pick a template',
|
||||
options: [
|
||||
{ value: 'vercel', label: 'Vercel', hint: 'Ziex on Vercel' },
|
||||
{ value: 'cloudflare', label: 'Cloudflare', hint: 'Ziex on Cloudflare' },
|
||||
],
|
||||
});
|
||||
|
||||
const s = spinner();
|
||||
const targetDir = path.resolve(process.cwd(), project);
|
||||
|
||||
// 2. Download from GitHub
|
||||
s.start('Downloading template...');
|
||||
try {
|
||||
// Uses giget to fetch from: github:ziex-dev/templates/templates/<name>
|
||||
await downloadTemplate(`github:ziex-dev/template-${template}`, {
|
||||
dir: targetDir,
|
||||
force: true,
|
||||
});
|
||||
s.stop('Template downloaded successfully!');
|
||||
} catch (err) {
|
||||
s.stop('Failed to download template', 1);
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 3. Perform String Replacements
|
||||
s.start('Customizing project files...');
|
||||
try {
|
||||
const projectName = sanitizeProjectName(path.basename(targetDir));
|
||||
await replaceInFile({
|
||||
files: `${targetDir}/**/*`,
|
||||
from: /zx_app/g,
|
||||
to: projectName,
|
||||
});
|
||||
s.stop('Project customized!');
|
||||
} catch (err) {
|
||||
s.stop('Replacement failed', 1);
|
||||
}
|
||||
|
||||
outro(`Successfully created ${color.cyan(project)}!`);
|
||||
console.log(`\n cd ${project}\n zig build dev\n`);
|
||||
}
|
||||
|
||||
// Make sure project name is suported Zig identifier
|
||||
function sanitizeProjectName(name) {
|
||||
return name.replace(/[^a-zA-Z0-9_]/g, '_');
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
5
pkg/create-ziex/build.zig
Normal file
5
pkg/create-ziex/build.zig
Normal file
@ -0,0 +1,5 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
_ = b; // stub
|
||||
}
|
||||
7
pkg/create-ziex/build.zig.zon
Normal file
7
pkg/create-ziex/build.zig.zon
Normal file
@ -0,0 +1,7 @@
|
||||
.{
|
||||
.name = .create_ziex,
|
||||
.version = "0.0.1",
|
||||
.minimum_zig_version = "0.15.2",
|
||||
.paths = .{""},
|
||||
.fingerprint = 0xa53594cec9c2ad31,
|
||||
}
|
||||
70
pkg/create-ziex/bun.lock
Normal file
70
pkg/create-ziex/bun.lock
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "create-ziex",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.1.0",
|
||||
"giget": "^3.1.2",
|
||||
"picocolors": "^1.1.1",
|
||||
"replace-in-file": "^8.4.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@clack/core": ["@clack/core@1.1.0", "", { "dependencies": { "sisteransi": "^1.0.5" } }, "sha512-SVcm4Dqm2ukn64/8Gub2wnlA5nS2iWJyCkdNHcvNHPIeBTGojpdJ+9cZKwLfmqy7irD4N5qLteSilJlE0WLAtA=="],
|
||||
|
||||
"@clack/prompts": ["@clack/prompts@1.1.0", "", { "dependencies": { "@clack/core": "1.1.0", "sisteransi": "^1.0.5" } }, "sha512-pkqbPGtohJAvm4Dphs2M8xE29ggupihHdy1x84HNojZuMtFsHiUlRvqD24tM2+XmI+61LlfNceM3Wr7U5QES5g=="],
|
||||
|
||||
"ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
|
||||
|
||||
"ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="],
|
||||
|
||||
"balanced-match": ["balanced-match@4.0.4", "", {}, "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="],
|
||||
|
||||
"brace-expansion": ["brace-expansion@5.0.4", "", { "dependencies": { "balanced-match": "^4.0.2" } }, "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg=="],
|
||||
|
||||
"chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
|
||||
|
||||
"cliui": ["cliui@9.0.1", "", { "dependencies": { "string-width": "^7.2.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w=="],
|
||||
|
||||
"emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="],
|
||||
|
||||
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
||||
|
||||
"get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
|
||||
|
||||
"get-east-asian-width": ["get-east-asian-width@1.5.0", "", {}, "sha512-CQ+bEO+Tva/qlmw24dCejulK5pMzVnUOFOijVogd3KQs07HnRIgp8TGipvCCRT06xeYEbpbgwaCxglFyiuIcmA=="],
|
||||
|
||||
"giget": ["giget@3.1.2", "", { "bin": { "giget": "dist/cli.mjs" } }, "sha512-T2qUpKBHeUTwHcIhydgnJzhL0Hj785ms+JkxaaWQH9SDM/llXeewnOkfJcFShAHjWI+26hOChwUfCoupaXLm8g=="],
|
||||
|
||||
"glob": ["glob@13.0.6", "", { "dependencies": { "minimatch": "^10.2.2", "minipass": "^7.1.3", "path-scurry": "^2.0.2" } }, "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw=="],
|
||||
|
||||
"lru-cache": ["lru-cache@11.2.7", "", {}, "sha512-aY/R+aEsRelme17KGQa/1ZSIpLpNYYrhcrepKTZgE+W3WM16YMCaPwOHLHsmopZHELU0Ojin1lPVxKR0MihncA=="],
|
||||
|
||||
"minimatch": ["minimatch@10.2.4", "", { "dependencies": { "brace-expansion": "^5.0.2" } }, "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg=="],
|
||||
|
||||
"minipass": ["minipass@7.1.3", "", {}, "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A=="],
|
||||
|
||||
"path-scurry": ["path-scurry@2.0.2", "", { "dependencies": { "lru-cache": "^11.0.0", "minipass": "^7.1.2" } }, "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg=="],
|
||||
|
||||
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||
|
||||
"replace-in-file": ["replace-in-file@8.4.0", "", { "dependencies": { "chalk": "^5.6.2", "glob": "^13.0.0", "yargs": "^18.0.0" }, "bin": { "replace-in-file": "bin/cli.js" } }, "sha512-D28k8jy2LtUGbCzCnR3znajaTWIjJ/Uee3UdodzcHRxE7zn6NmYW/dcSqyivnsYU3W+MxdX6SbF28NvJ0GRoLA=="],
|
||||
|
||||
"sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="],
|
||||
|
||||
"string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
|
||||
|
||||
"strip-ansi": ["strip-ansi@7.2.0", "", { "dependencies": { "ansi-regex": "^6.2.2" } }, "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w=="],
|
||||
|
||||
"wrap-ansi": ["wrap-ansi@9.0.2", "", { "dependencies": { "ansi-styles": "^6.2.1", "string-width": "^7.0.0", "strip-ansi": "^7.1.0" } }, "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww=="],
|
||||
|
||||
"y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="],
|
||||
|
||||
"yargs": ["yargs@18.0.0", "", { "dependencies": { "cliui": "^9.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "string-width": "^7.2.0", "y18n": "^5.0.5", "yargs-parser": "^22.0.0" } }, "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg=="],
|
||||
|
||||
"yargs-parser": ["yargs-parser@22.0.0", "", {}, "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="],
|
||||
}
|
||||
}
|
||||
15
pkg/create-ziex/package.json
Normal file
15
pkg/create-ziex/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "create-ziex",
|
||||
"version": "0.1.0-dev.2",
|
||||
"bin": "bin/index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node bin/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.1.0",
|
||||
"giget": "^3.1.2",
|
||||
"picocolors": "^1.1.1",
|
||||
"replace-in-file": "^8.4.0"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user