bunkit-cli 1.0.0 → 1.0.2
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 +26 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18565,7 +18565,9 @@ async function isGitAvailable() {
|
|
|
18565
18565
|
async function initGit(cwd2) {
|
|
18566
18566
|
await execa("git", ["init"], { cwd: cwd2 });
|
|
18567
18567
|
await execa("git", ["add", "-A"], { cwd: cwd2 });
|
|
18568
|
-
|
|
18568
|
+
try {
|
|
18569
|
+
await execa("git", ["commit", "-m", "Initial commit from bunkit", "--no-verify"], { cwd: cwd2 });
|
|
18570
|
+
} catch {}
|
|
18569
18571
|
}
|
|
18570
18572
|
async function isGitRepository(cwd2) {
|
|
18571
18573
|
try {
|
|
@@ -22707,12 +22709,19 @@ var init_types2 = __esm(() => {
|
|
|
22707
22709
|
// ../core/src/project.ts
|
|
22708
22710
|
async function createProject(config) {
|
|
22709
22711
|
const projectPath = join(process.cwd(), config.path);
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22712
|
+
const currentDirName = basename(resolve(process.cwd()));
|
|
22713
|
+
if (currentDirName === config.name && config.path === config.name) {
|
|
22714
|
+
const isEmpty = await isDirectoryEmpty(process.cwd());
|
|
22715
|
+
if (isEmpty) {
|
|
22716
|
+
throw new Error(`You are already in a directory named "${config.name}". ` + `Since this directory is empty, you can initialize the project here directly. ` + `Please run "bunkit init" instead, or navigate to the parent directory first.`);
|
|
22717
|
+
} else {
|
|
22718
|
+
throw new Error(`You are already in a directory named "${config.name}" which is not empty. ` + `Creating the project here would result in "${config.name}/${config.name}". ` + `Please navigate to the parent directory first, or use a different project name.`);
|
|
22714
22719
|
}
|
|
22715
22720
|
}
|
|
22721
|
+
const targetExists = await import_fs_extra2.default.pathExists(projectPath);
|
|
22722
|
+
if (targetExists && !await isDirectoryEmpty(projectPath)) {
|
|
22723
|
+
throw new Error(`Directory "${config.path}" already exists and is not empty`);
|
|
22724
|
+
}
|
|
22716
22725
|
await ensureDirectory(projectPath);
|
|
22717
22726
|
await createPackageJson(projectPath, config);
|
|
22718
22727
|
await createBaseFiles(projectPath, config);
|
|
@@ -23035,17 +23044,24 @@ var init_monorepo = __esm(() => {
|
|
|
23035
23044
|
});
|
|
23036
23045
|
|
|
23037
23046
|
// ../core/src/presets.ts
|
|
23047
|
+
function getPresetsDir() {
|
|
23048
|
+
return join(process.env.HOME || process.env.USERPROFILE || ".", ".bunkit");
|
|
23049
|
+
}
|
|
23050
|
+
function getPresetsFile() {
|
|
23051
|
+
return join(getPresetsDir(), "presets.json");
|
|
23052
|
+
}
|
|
23038
23053
|
async function loadCustomPresets() {
|
|
23039
23054
|
try {
|
|
23040
|
-
|
|
23041
|
-
|
|
23055
|
+
const presetsDir = getPresetsDir();
|
|
23056
|
+
await ensureDirectory(presetsDir);
|
|
23057
|
+
const content = await readFile(getPresetsFile());
|
|
23042
23058
|
return JSON.parse(content);
|
|
23043
23059
|
} catch (error) {
|
|
23044
23060
|
return {};
|
|
23045
23061
|
}
|
|
23046
23062
|
}
|
|
23047
23063
|
async function saveCustomPreset(preset) {
|
|
23048
|
-
await ensureDirectory(
|
|
23064
|
+
await ensureDirectory(getPresetsDir());
|
|
23049
23065
|
const presets = await loadCustomPresets();
|
|
23050
23066
|
const existing = presets[preset.name];
|
|
23051
23067
|
presets[preset.name] = {
|
|
@@ -23053,7 +23069,7 @@ async function saveCustomPreset(preset) {
|
|
|
23053
23069
|
createdAt: existing?.createdAt || new Date().toISOString(),
|
|
23054
23070
|
updatedAt: new Date().toISOString()
|
|
23055
23071
|
};
|
|
23056
|
-
await writeFile(
|
|
23072
|
+
await writeFile(getPresetsFile(), JSON.stringify(presets, null, 2));
|
|
23057
23073
|
}
|
|
23058
23074
|
async function deleteCustomPreset(name) {
|
|
23059
23075
|
const presets = await loadCustomPresets();
|
|
@@ -23061,7 +23077,7 @@ async function deleteCustomPreset(name) {
|
|
|
23061
23077
|
return false;
|
|
23062
23078
|
}
|
|
23063
23079
|
delete presets[name];
|
|
23064
|
-
await writeFile(
|
|
23080
|
+
await writeFile(getPresetsFile(), JSON.stringify(presets, null, 2));
|
|
23065
23081
|
return true;
|
|
23066
23082
|
}
|
|
23067
23083
|
async function getCustomPreset(name) {
|
|
@@ -23072,12 +23088,9 @@ async function listCustomPresets() {
|
|
|
23072
23088
|
const presets = await loadCustomPresets();
|
|
23073
23089
|
return Object.values(presets);
|
|
23074
23090
|
}
|
|
23075
|
-
var PRESETS_DIR, PRESETS_FILE;
|
|
23076
23091
|
var init_presets = __esm(() => {
|
|
23077
23092
|
init_dist();
|
|
23078
23093
|
init_fs();
|
|
23079
|
-
PRESETS_DIR = join(process.env.HOME || process.env.USERPROFILE || ".", ".bunkit");
|
|
23080
|
-
PRESETS_FILE = join(PRESETS_DIR, "presets.json");
|
|
23081
23094
|
});
|
|
23082
23095
|
|
|
23083
23096
|
// ../core/src/index.ts
|