@darkoto/gulp-template-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/README.md +1 -1
- package/helpers.js +21 -0
- package/package.json +9 -3
- package/setup/tailwind/setup.js +22 -12
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @darkoto/gulp-template-cli
|
|
2
2
|
|
|
3
|
-
A CLI feature installer for [gulp-template](
|
|
3
|
+
A CLI feature installer for [gulp-template](https://github.com/darkoton/gulp-template). Instead of keeping a
|
|
4
4
|
`.template/` folder with setup scripts inside every cloned project,
|
|
5
5
|
the scripts live in a standalone package and copy the files you need
|
|
6
6
|
(configs, gulp tasks, styles, demo pages) directly into your project
|
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.
|
|
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,7 +13,13 @@
|
|
|
13
13
|
"helpers.js",
|
|
14
14
|
"setup-env.js"
|
|
15
15
|
],
|
|
16
|
-
"keywords": [
|
|
16
|
+
"keywords": [
|
|
17
|
+
"gulp",
|
|
18
|
+
"cli",
|
|
19
|
+
"tailwind",
|
|
20
|
+
"scaffolding",
|
|
21
|
+
"template"
|
|
22
|
+
],
|
|
17
23
|
"license": "MIT",
|
|
18
24
|
"author": "Darkoto darkoto12@gmail.com",
|
|
19
25
|
"repository": {
|
|
@@ -27,4 +33,4 @@
|
|
|
27
33
|
"@inquirer/prompts": "^7.0.0",
|
|
28
34
|
"dotenv": "^16.4.5"
|
|
29
35
|
}
|
|
30
|
-
}
|
|
36
|
+
}
|
package/setup/tailwind/setup.js
CHANGED
|
@@ -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(
|
|
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 = '
|
|
49
|
+
function createConfig(provider = 'npm') {
|
|
40
50
|
let destPath;
|
|
41
|
-
if (provider === '
|
|
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 = '
|
|
275
|
+
function isInstalled(provider = 'npm') {
|
|
266
276
|
let configPath;
|
|
267
277
|
|
|
268
|
-
if (provider === '
|
|
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: '
|
|
306
|
-
{ name: '
|
|
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 '
|
|
329
|
+
case 'npm': {
|
|
320
330
|
console.log(`\n 🎨 Tailwind CSS v${config.version} Setup (CLI)\n`);
|
|
321
331
|
|
|
322
332
|
console.log(' This will:');
|
|
@@ -328,7 +338,7 @@ export async function setup() {
|
|
|
328
338
|
console.log(' • Copy demo page');
|
|
329
339
|
console.log(' • Auto-generate rebuild kit in dist/\n');
|
|
330
340
|
|
|
331
|
-
const confirmed = await confirm({ message: 'Do you want to continue?' });
|
|
341
|
+
const confirmed = await confirm({ message: 'Do you want to continue?' });
|
|
332
342
|
|
|
333
343
|
if (!confirmed) {
|
|
334
344
|
console.log('\n ❌ Setup cancelled.\n');
|
|
@@ -348,7 +358,7 @@ const confirmed = await confirm({ message: 'Do you want to continue?' });
|
|
|
348
358
|
console.log(`\n ✅ Done! Docs: ${config.urls.docs}\n`);
|
|
349
359
|
|
|
350
360
|
if (config.options.copyDemoPage) {
|
|
351
|
-
console.log(' 💡 Run "
|
|
361
|
+
console.log(' 💡 Run "npm run dev" to view the demo page.\n');
|
|
352
362
|
}
|
|
353
363
|
|
|
354
364
|
break;
|
|
@@ -364,7 +374,7 @@ const confirmed = await confirm({ message: 'Do you want to continue?' });
|
|
|
364
374
|
console.log(' • Add Config link to head.html');
|
|
365
375
|
console.log(' • Copy demo page \n');
|
|
366
376
|
|
|
367
|
-
const confirmed = await confirm('Do you want to continue?');
|
|
377
|
+
const confirmed = await confirm({ message: 'Do you want to continue?' });
|
|
368
378
|
|
|
369
379
|
if (!confirmed) {
|
|
370
380
|
console.log('\n ❌ Setup cancelled.\n');
|
|
@@ -383,7 +393,7 @@ const confirmed = await confirm({ message: 'Do you want to continue?' });
|
|
|
383
393
|
console.log(`\n ✅ Done! Docs: ${config.urls.docs}\n`);
|
|
384
394
|
|
|
385
395
|
if (config.options.copyDemoPage) {
|
|
386
|
-
console.log(' 💡 Run "
|
|
396
|
+
console.log(' 💡 Run "npm run dev" to view the demo page.\n');
|
|
387
397
|
}
|
|
388
398
|
break;
|
|
389
399
|
}
|