@docubook/create 1.8.6 → 1.8.8

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.
Files changed (2) hide show
  1. package/create.js +23 -6
  2. package/package.json +1 -1
package/create.js CHANGED
@@ -102,9 +102,18 @@ function manualSteps(projectDirectory, packageManager) {
102
102
  );
103
103
  }
104
104
 
105
+ // Deteksi default package manager dari eksekusi CLI
106
+ function detectDefaultPackageManager() {
107
+ const userAgent = process.env.npm_config_user_agent || "";
108
+ if (userAgent.includes("pnpm")) return "pnpm";
109
+ if (userAgent.includes("yarn")) return "yarn";
110
+ if (userAgent.includes("bun")) return "bun";
111
+ return "npm";
112
+ }
113
+
105
114
  // ========== Entry CLI ========== //
106
115
  program
107
- .version("1.8.6")
116
+ .version("1.8.8")
108
117
  .description("CLI to create a new Docubook project")
109
118
  .argument("[project-directory]", "Directory to create the new Docubook project")
110
119
  .action(async (projectDirectory) => {
@@ -125,14 +134,15 @@ program
125
134
  }
126
135
 
127
136
  // Pilihan package manager
137
+ const defaultPM = detectDefaultPackageManager();
128
138
  const { packageManager } = await inquirer.prompt([
129
- {
139
+ {
130
140
  type: "list",
131
141
  name: "packageManager",
132
142
  message: "Choose a package manager:",
133
143
  choices: ["npm", "pnpm", "yarn", "bun"],
134
- default: "npm",
135
- },
144
+ default: defaultPM,
145
+ },
136
146
  ]);
137
147
 
138
148
  const version = getPackageManagerVersion(packageManager);
@@ -199,13 +209,20 @@ program
199
209
  console.log(chalk.white("When you install the package manager, the installation speed depends on the hardware you have."));
200
210
  const installSpinner = ora(`Using ${packageManager}...`).start();
201
211
 
212
+ // Tambahkan konfigurasi khusus untuk yarn
213
+ if (packageManager === "yarn") {
214
+ const yarnrcPath = path.join(projectPath, ".yarnrc.yml");
215
+ fs.writeFileSync(yarnrcPath, "nodeLinker: node-modules\n");
216
+ }
217
+
202
218
  try {
203
219
  execSync(`${packageManager} install`, { cwd: projectPath, stdio: "ignore" });
204
220
  installSpinner.succeed("Dependencies installed.");
205
- } catch {
221
+ } catch {
206
222
  installSpinner.fail("Failed to install dependencies.");
223
+ manualSteps(projectDirectory, packageManager); // Jika gagal install otomatis
207
224
  process.exit(1);
208
- }
225
+ }
209
226
 
210
227
  await simulateInstallation();
211
228
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docubook/create",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {