@darkoto/gulp-template-cli 1.0.1 → 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/helpers.js CHANGED
@@ -126,3 +126,24 @@ export const safeReplace = (
126
126
  content: nextContent,
127
127
  };
128
128
  };
129
+
130
+ // getPackageManager: Detect package manager from lock files or package.json
131
+ export function getPackageManager(cwd = process.cwd()) {
132
+ const packageJsonPath = path.join(cwd, 'package.json');
133
+
134
+ if (fs.existsSync(packageJsonPath)) {
135
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
136
+
137
+ if (pkg.packageManager) {
138
+ return pkg.packageManager.split('@')[0];
139
+ }
140
+ }
141
+
142
+ if (fs.existsSync(path.join(cwd, 'bun.lockb'))) return 'bun';
143
+ if (fs.existsSync(path.join(cwd, 'bun.lock'))) return 'bun';
144
+ if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))) return 'pnpm';
145
+ if (fs.existsSync(path.join(cwd, 'yarn.lock'))) return 'yarn';
146
+ if (fs.existsSync(path.join(cwd, 'package-lock.json'))) return 'npm';
147
+
148
+ return 'npm';
149
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkoto/gulp-template-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Feature pnpm installer CLI for gulp-template — adds tailwind, etc. on demand into the target project.",
6
6
  "bin": {
@@ -13,6 +13,7 @@ import {
13
13
  getSourcePath,
14
14
  copyTemplate,
15
15
  safeReplace,
16
+ getPackageManager
16
17
  } from '../../helpers.js';
17
18
 
18
19
  // ─────────────────────────────────────────────────────────────
@@ -20,10 +21,19 @@ import {
20
21
  // ─────────────────────────────────────────────────────────────
21
22
 
22
23
  function installPackage() {
24
+ const pm = getPackageManager();
25
+
23
26
  log(`Installing ${config.packageName}@${config.version}...`, 'info');
24
27
 
28
+ const commands = {
29
+ npm: `npm i -D ${config.packageName}@${config.version}`,
30
+ pnpm: `pnpm add -D ${config.packageName}@${config.version}`,
31
+ yarn: `yarn add -D ${config.packageName}@${config.version}`,
32
+ bun: `bun add -d ${config.packageName}@${config.version}`,
33
+ };
34
+
25
35
  try {
26
- execSync(`pnpm i -D ${config.packageName}@${config.version}`, {
36
+ execSync(commands[pm], {
27
37
  stdio: 'pipe',
28
38
  });
29
39
  log(`Installed ${config.packageName}@${config.version}.`, 'success');
@@ -36,9 +46,9 @@ function installPackage() {
36
46
  }
37
47
  }
38
48
 
39
- function createConfig(provider = 'pnpm') {
49
+ function createConfig(provider = 'npm') {
40
50
  let destPath;
41
- if (provider === 'pnpm') {
51
+ if (provider === 'npm') {
42
52
  destPath = resolvePath(
43
53
  config.paths.configModule.dest,
44
54
  config.files.tailwindConfig,
@@ -262,10 +272,10 @@ function updateGulpfile() {
262
272
  log('Updated gulpfile.js.', 'success');
263
273
  }
264
274
 
265
- function isInstalled(provider = 'pnpm') {
275
+ function isInstalled(provider = 'npm') {
266
276
  let configPath;
267
277
 
268
- if (provider === 'pnpm')
278
+ if (provider === 'npm')
269
279
  configPath = resolvePath(
270
280
  config.paths.configModule.dest,
271
281
  config.paths.configModule.filename,
@@ -302,8 +312,8 @@ export async function setup() {
302
312
  const provider = await select({
303
313
  message: 'Select Tailwind installation',
304
314
  choices: [
305
- { name: 'pnpm(npm)', value: 'pnpm' },
306
- { name: 'cdn', value: 'cdn' },
315
+ { name: 'Package Manager(npm, pnpm, yarn, bun)', value: 'npm' },
316
+ { name: 'CDN', value: 'cdn' },
307
317
  ],
308
318
  });
309
319
 
@@ -316,7 +326,7 @@ export async function setup() {
316
326
  }
317
327
 
318
328
  switch (provider) {
319
- case 'pnpm': {
329
+ case 'npm': {
320
330
  console.log(`\n 🎨 Tailwind CSS v${config.version} Setup (CLI)\n`);
321
331
 
322
332
  console.log(' This will:');
@@ -348,7 +358,7 @@ export async function setup() {
348
358
  console.log(`\n ✅ Done! Docs: ${config.urls.docs}\n`);
349
359
 
350
360
  if (config.options.copyDemoPage) {
351
- console.log(' 💡 Run "pnpm dev" to view the demo page.\n');
361
+ console.log(' 💡 Run "npm run dev" to view the demo page.\n');
352
362
  }
353
363
 
354
364
  break;
@@ -383,7 +393,7 @@ export async function setup() {
383
393
  console.log(`\n ✅ Done! Docs: ${config.urls.docs}\n`);
384
394
 
385
395
  if (config.options.copyDemoPage) {
386
- console.log(' 💡 Run "pnpm dev" to view the demo page.\n');
396
+ console.log(' 💡 Run "npm run dev" to view the demo page.\n');
387
397
  }
388
398
  break;
389
399
  }