create-awesome-node-app 0.4.17 → 0.4.19
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 +0 -6
- package/dist/index.cjs +52 -21
- package/dist/index.d.ts +2 -1
- package/dist/index.js +52 -21
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
<h1>🌟 Create Awesome Node App 🚀</h1>
|
|
5
5
|
|
|
6
|
-
[Changelog](./CHANGELOG.md) |
|
|
7
|
-
[Contributing](./CONTRIBUTING.md)
|
|
8
|
-
|
|
9
|
-
</div>
|
|
10
|
-
<div align="center">
|
|
11
|
-
|
|
12
6
|
[![Continious Integration][cibadge]][ciurl]
|
|
13
7
|
[![npm][npmversion]][npmurl]
|
|
14
8
|
[![npm][npmdownloads]][npmurl]
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
"use strict";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -3427,20 +3426,33 @@ var import_semver = __toESM(require("semver"), 1);
|
|
|
3427
3426
|
var import_core = require("@create-node-app/core");
|
|
3428
3427
|
|
|
3429
3428
|
// src/options.ts
|
|
3429
|
+
var import_ci_info = require("ci-info");
|
|
3430
3430
|
var import_prompts = __toESM(require("prompts"), 1);
|
|
3431
3431
|
var import_yargs = __toESM(require("yargs"), 1);
|
|
3432
3432
|
|
|
3433
3433
|
// src/templates.ts
|
|
3434
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
3434
3435
|
var TEMPLATE_DATA_FILE_URL = "https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json";
|
|
3435
|
-
var
|
|
3436
|
+
var CACHE_TTL_MS = 36e5;
|
|
3437
|
+
var templateDataCache = {
|
|
3438
|
+
data: null,
|
|
3439
|
+
timestamp: 0
|
|
3440
|
+
};
|
|
3441
|
+
var fetchTemplateData = async () => {
|
|
3442
|
+
try {
|
|
3443
|
+
const response = await import_axios.default.get(TEMPLATE_DATA_FILE_URL);
|
|
3444
|
+
return response.data;
|
|
3445
|
+
} catch (error) {
|
|
3446
|
+
throw new Error("Failed to fetch template data");
|
|
3447
|
+
}
|
|
3448
|
+
};
|
|
3436
3449
|
var getTemplateData = async () => {
|
|
3437
|
-
|
|
3438
|
-
|
|
3450
|
+
const currentTime = Date.now();
|
|
3451
|
+
if (templateDataCache.data === null || currentTime - templateDataCache.timestamp > CACHE_TTL_MS) {
|
|
3452
|
+
templateDataCache.data = await fetchTemplateData();
|
|
3453
|
+
templateDataCache.timestamp = currentTime;
|
|
3439
3454
|
}
|
|
3440
|
-
|
|
3441
|
-
const templateData = await templateDataFile.json();
|
|
3442
|
-
templateDataMap.set(TEMPLATE_DATA_FILE_URL, templateData);
|
|
3443
|
-
return templateData;
|
|
3455
|
+
return templateDataCache.data;
|
|
3444
3456
|
};
|
|
3445
3457
|
var getTemplateCategories = async () => {
|
|
3446
3458
|
const templateData = await getTemplateData();
|
|
@@ -3479,7 +3491,14 @@ var getExtensionsGroupedByCategory = async (type) => {
|
|
|
3479
3491
|
|
|
3480
3492
|
// src/options.ts
|
|
3481
3493
|
import_prompts.default.override(import_yargs.default.argv);
|
|
3494
|
+
var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm"];
|
|
3482
3495
|
var getCnaOptions = async (options) => {
|
|
3496
|
+
if (import_ci_info.isCI) {
|
|
3497
|
+
if (options.verbose) {
|
|
3498
|
+
console.log(JSON.stringify(options, null, 2));
|
|
3499
|
+
}
|
|
3500
|
+
return options;
|
|
3501
|
+
}
|
|
3483
3502
|
const categories = await getTemplateCategories();
|
|
3484
3503
|
const categoriesOptions = [
|
|
3485
3504
|
...categories.map((category) => ({
|
|
@@ -3503,12 +3522,11 @@ var getCnaOptions = async (options) => {
|
|
|
3503
3522
|
type: "select",
|
|
3504
3523
|
name: "packageManager",
|
|
3505
3524
|
message: "What package manager do you want to use?",
|
|
3506
|
-
choices:
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
initial: 0
|
|
3525
|
+
choices: PACKAGE_MANAGERS.map((packageManager) => ({
|
|
3526
|
+
title: packageManager,
|
|
3527
|
+
value: packageManager
|
|
3528
|
+
})),
|
|
3529
|
+
initial: options.packageManager ? PACKAGE_MANAGERS.indexOf(options.packageManager) : 0
|
|
3512
3530
|
},
|
|
3513
3531
|
{
|
|
3514
3532
|
type: "select",
|
|
@@ -3533,7 +3551,7 @@ var getCnaOptions = async (options) => {
|
|
|
3533
3551
|
type: "text",
|
|
3534
3552
|
name: "template",
|
|
3535
3553
|
message: "Enter the URL of your template. e.g: https://github.com/username/repository/tree/main/subdir",
|
|
3536
|
-
initial:
|
|
3554
|
+
initial: options.template,
|
|
3537
3555
|
validate: (value) => {
|
|
3538
3556
|
if (!value) {
|
|
3539
3557
|
return "Template URL is required";
|
|
@@ -3640,7 +3658,7 @@ var getCnaOptions = async (options) => {
|
|
|
3640
3658
|
// package.json
|
|
3641
3659
|
var package_default = {
|
|
3642
3660
|
name: "create-awesome-node-app",
|
|
3643
|
-
version: "0.4.
|
|
3661
|
+
version: "0.4.19",
|
|
3644
3662
|
type: "module",
|
|
3645
3663
|
description: "Command line tool to create Node apps with a lot of different templates and extensions.",
|
|
3646
3664
|
license: "MIT",
|
|
@@ -3686,8 +3704,10 @@ var package_default = {
|
|
|
3686
3704
|
},
|
|
3687
3705
|
dependencies: {
|
|
3688
3706
|
"@create-node-app/core": "*",
|
|
3707
|
+
axios: "^1.5.0",
|
|
3708
|
+
"ci-info": "^3.8.0",
|
|
3689
3709
|
prompts: "^2.4.1",
|
|
3690
|
-
semver: "^7.
|
|
3710
|
+
semver: "^5.7.2",
|
|
3691
3711
|
yargs: "^17.0.1"
|
|
3692
3712
|
},
|
|
3693
3713
|
devDependencies: {
|
|
@@ -3706,9 +3726,15 @@ var main = async () => {
|
|
|
3706
3726
|
import_commander.default.version(package_default.version).arguments("[project-directory]").usage(`${import_chalk.default.green("[project-directory]")} [options]`).action((name) => {
|
|
3707
3727
|
projectName = name || projectName;
|
|
3708
3728
|
}).option("--verbose", "print additional logs").option("--info", "print environment debug info").option(
|
|
3709
|
-
"--
|
|
3710
|
-
"
|
|
3711
|
-
).
|
|
3729
|
+
"--no-install",
|
|
3730
|
+
"Generate package.json without installing dependencies"
|
|
3731
|
+
).option(
|
|
3732
|
+
"--template <template>",
|
|
3733
|
+
"specify a template for the created project"
|
|
3734
|
+
).option(
|
|
3735
|
+
"--extend [extensions...]",
|
|
3736
|
+
"specify extensions to apply for the boilerplate generation"
|
|
3737
|
+
).option("--use-yarn", "use yarn instead of npm or pnpm").option("--use-pnpm", "use pnpm instead of yarn or npm").parse(process.argv);
|
|
3712
3738
|
(0, import_core.checkNodeVersion)(package_default.engines.node, package_default.name);
|
|
3713
3739
|
const latest = await (0, import_core.checkForLatestVersion)("create-awesome-node-app");
|
|
3714
3740
|
if (latest && import_semver.default.lt(package_default.version, latest)) {
|
|
@@ -3722,9 +3748,14 @@ We recommend always using the latest version of create-awesome-node-app if possi
|
|
|
3722
3748
|
);
|
|
3723
3749
|
return;
|
|
3724
3750
|
}
|
|
3751
|
+
const { useYarn, usePnpm, ...opts } = import_commander.default.opts();
|
|
3752
|
+
const packageManager = useYarn ? "yarn" : usePnpm ? "pnpm" : "npm";
|
|
3753
|
+
const templatesOrExtensions = [opts.template].concat(opts.extend || []).filter(Boolean).map((templateOrExtension) => ({
|
|
3754
|
+
url: templateOrExtension
|
|
3755
|
+
}));
|
|
3725
3756
|
return (0, import_core.createNodeApp)(
|
|
3726
3757
|
projectName,
|
|
3727
|
-
{ ...
|
|
3758
|
+
{ ...opts, packageManager, templatesOrExtensions, projectName },
|
|
3728
3759
|
getCnaOptions
|
|
3729
3760
|
);
|
|
3730
3761
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3437,20 +3436,33 @@ import {
|
|
|
3437
3436
|
} from "@create-node-app/core";
|
|
3438
3437
|
|
|
3439
3438
|
// src/options.ts
|
|
3439
|
+
import { isCI } from "ci-info";
|
|
3440
3440
|
import prompts from "prompts";
|
|
3441
3441
|
import yargs from "yargs";
|
|
3442
3442
|
|
|
3443
3443
|
// src/templates.ts
|
|
3444
|
+
import axios from "axios";
|
|
3444
3445
|
var TEMPLATE_DATA_FILE_URL = "https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json";
|
|
3445
|
-
var
|
|
3446
|
+
var CACHE_TTL_MS = 36e5;
|
|
3447
|
+
var templateDataCache = {
|
|
3448
|
+
data: null,
|
|
3449
|
+
timestamp: 0
|
|
3450
|
+
};
|
|
3451
|
+
var fetchTemplateData = async () => {
|
|
3452
|
+
try {
|
|
3453
|
+
const response = await axios.get(TEMPLATE_DATA_FILE_URL);
|
|
3454
|
+
return response.data;
|
|
3455
|
+
} catch (error) {
|
|
3456
|
+
throw new Error("Failed to fetch template data");
|
|
3457
|
+
}
|
|
3458
|
+
};
|
|
3446
3459
|
var getTemplateData = async () => {
|
|
3447
|
-
|
|
3448
|
-
|
|
3460
|
+
const currentTime = Date.now();
|
|
3461
|
+
if (templateDataCache.data === null || currentTime - templateDataCache.timestamp > CACHE_TTL_MS) {
|
|
3462
|
+
templateDataCache.data = await fetchTemplateData();
|
|
3463
|
+
templateDataCache.timestamp = currentTime;
|
|
3449
3464
|
}
|
|
3450
|
-
|
|
3451
|
-
const templateData = await templateDataFile.json();
|
|
3452
|
-
templateDataMap.set(TEMPLATE_DATA_FILE_URL, templateData);
|
|
3453
|
-
return templateData;
|
|
3465
|
+
return templateDataCache.data;
|
|
3454
3466
|
};
|
|
3455
3467
|
var getTemplateCategories = async () => {
|
|
3456
3468
|
const templateData = await getTemplateData();
|
|
@@ -3489,7 +3501,14 @@ var getExtensionsGroupedByCategory = async (type) => {
|
|
|
3489
3501
|
|
|
3490
3502
|
// src/options.ts
|
|
3491
3503
|
prompts.override(yargs.argv);
|
|
3504
|
+
var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm"];
|
|
3492
3505
|
var getCnaOptions = async (options) => {
|
|
3506
|
+
if (isCI) {
|
|
3507
|
+
if (options.verbose) {
|
|
3508
|
+
console.log(JSON.stringify(options, null, 2));
|
|
3509
|
+
}
|
|
3510
|
+
return options;
|
|
3511
|
+
}
|
|
3493
3512
|
const categories = await getTemplateCategories();
|
|
3494
3513
|
const categoriesOptions = [
|
|
3495
3514
|
...categories.map((category) => ({
|
|
@@ -3513,12 +3532,11 @@ var getCnaOptions = async (options) => {
|
|
|
3513
3532
|
type: "select",
|
|
3514
3533
|
name: "packageManager",
|
|
3515
3534
|
message: "What package manager do you want to use?",
|
|
3516
|
-
choices:
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
initial: 0
|
|
3535
|
+
choices: PACKAGE_MANAGERS.map((packageManager) => ({
|
|
3536
|
+
title: packageManager,
|
|
3537
|
+
value: packageManager
|
|
3538
|
+
})),
|
|
3539
|
+
initial: options.packageManager ? PACKAGE_MANAGERS.indexOf(options.packageManager) : 0
|
|
3522
3540
|
},
|
|
3523
3541
|
{
|
|
3524
3542
|
type: "select",
|
|
@@ -3543,7 +3561,7 @@ var getCnaOptions = async (options) => {
|
|
|
3543
3561
|
type: "text",
|
|
3544
3562
|
name: "template",
|
|
3545
3563
|
message: "Enter the URL of your template. e.g: https://github.com/username/repository/tree/main/subdir",
|
|
3546
|
-
initial:
|
|
3564
|
+
initial: options.template,
|
|
3547
3565
|
validate: (value) => {
|
|
3548
3566
|
if (!value) {
|
|
3549
3567
|
return "Template URL is required";
|
|
@@ -3650,7 +3668,7 @@ var getCnaOptions = async (options) => {
|
|
|
3650
3668
|
// package.json
|
|
3651
3669
|
var package_default = {
|
|
3652
3670
|
name: "create-awesome-node-app",
|
|
3653
|
-
version: "0.4.
|
|
3671
|
+
version: "0.4.19",
|
|
3654
3672
|
type: "module",
|
|
3655
3673
|
description: "Command line tool to create Node apps with a lot of different templates and extensions.",
|
|
3656
3674
|
license: "MIT",
|
|
@@ -3696,8 +3714,10 @@ var package_default = {
|
|
|
3696
3714
|
},
|
|
3697
3715
|
dependencies: {
|
|
3698
3716
|
"@create-node-app/core": "*",
|
|
3717
|
+
axios: "^1.5.0",
|
|
3718
|
+
"ci-info": "^3.8.0",
|
|
3699
3719
|
prompts: "^2.4.1",
|
|
3700
|
-
semver: "^7.
|
|
3720
|
+
semver: "^5.7.2",
|
|
3701
3721
|
yargs: "^17.0.1"
|
|
3702
3722
|
},
|
|
3703
3723
|
devDependencies: {
|
|
@@ -3716,9 +3736,15 @@ var main = async () => {
|
|
|
3716
3736
|
import_commander.default.version(package_default.version).arguments("[project-directory]").usage(`${import_chalk.default.green("[project-directory]")} [options]`).action((name) => {
|
|
3717
3737
|
projectName = name || projectName;
|
|
3718
3738
|
}).option("--verbose", "print additional logs").option("--info", "print environment debug info").option(
|
|
3719
|
-
"--
|
|
3720
|
-
"
|
|
3721
|
-
).
|
|
3739
|
+
"--no-install",
|
|
3740
|
+
"Generate package.json without installing dependencies"
|
|
3741
|
+
).option(
|
|
3742
|
+
"--template <template>",
|
|
3743
|
+
"specify a template for the created project"
|
|
3744
|
+
).option(
|
|
3745
|
+
"--extend [extensions...]",
|
|
3746
|
+
"specify extensions to apply for the boilerplate generation"
|
|
3747
|
+
).option("--use-yarn", "use yarn instead of npm or pnpm").option("--use-pnpm", "use pnpm instead of yarn or npm").parse(process.argv);
|
|
3722
3748
|
checkNodeVersion(package_default.engines.node, package_default.name);
|
|
3723
3749
|
const latest = await checkForLatestVersion("create-awesome-node-app");
|
|
3724
3750
|
if (latest && semver.lt(package_default.version, latest)) {
|
|
@@ -3732,9 +3758,14 @@ We recommend always using the latest version of create-awesome-node-app if possi
|
|
|
3732
3758
|
);
|
|
3733
3759
|
return;
|
|
3734
3760
|
}
|
|
3761
|
+
const { useYarn, usePnpm, ...opts } = import_commander.default.opts();
|
|
3762
|
+
const packageManager = useYarn ? "yarn" : usePnpm ? "pnpm" : "npm";
|
|
3763
|
+
const templatesOrExtensions = [opts.template].concat(opts.extend || []).filter(Boolean).map((templateOrExtension) => ({
|
|
3764
|
+
url: templateOrExtension
|
|
3765
|
+
}));
|
|
3735
3766
|
return createNodeApp(
|
|
3736
3767
|
projectName,
|
|
3737
|
-
{ ...
|
|
3768
|
+
{ ...opts, packageManager, templatesOrExtensions, projectName },
|
|
3738
3769
|
getCnaOptions
|
|
3739
3770
|
);
|
|
3740
3771
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-awesome-node-app",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Command line tool to create Node apps with a lot of different templates and extensions.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,8 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@create-node-app/core": "*",
|
|
49
|
+
"axios": "^1.5.0",
|
|
50
|
+
"ci-info": "^3.8.0",
|
|
49
51
|
"prompts": "^2.4.1",
|
|
50
|
-
"semver": "^7.
|
|
52
|
+
"semver": "^5.7.2",
|
|
51
53
|
"yargs": "^17.0.1"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|