create-awesome-node-app 0.6.7 → 0.7.0

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.
@@ -1,123 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- // src/templates.ts
34
- import axios from "axios";
35
- var TEMPLATE_DATA_FILE_URL = "https://raw.githubusercontent.com/Create-Node-App/cna-templates/main/templates.json";
36
- var CACHE_TTL_MS = 36e5;
37
- var templateDataCache = {
38
- data: null,
39
- timestamp: 0
40
- };
41
- var fetchTemplateData = async () => {
42
- try {
43
- const response = await axios.get(TEMPLATE_DATA_FILE_URL);
44
- return response.data;
45
- } catch (error) {
46
- throw new Error("Failed to fetch template data");
47
- }
48
- };
49
- var getTemplateData = async () => {
50
- const currentTime = Date.now();
51
- if (templateDataCache.data === null || currentTime - templateDataCache.timestamp > CACHE_TTL_MS) {
52
- templateDataCache.data = await fetchTemplateData();
53
- templateDataCache.timestamp = currentTime;
54
- }
55
- return templateDataCache.data;
56
- };
57
- var getTemplateCategories = async (cliArgs) => {
58
- if (cliArgs?.category) {
59
- return [cliArgs.category];
60
- }
61
- const templateData = await getTemplateData();
62
- if (templateData.categories && templateData.categories.length > 0) {
63
- return templateData.categories.map((category) => category.slug);
64
- }
65
- const categories = /* @__PURE__ */ new Set();
66
- templateData.templates.forEach((template) => {
67
- categories.add(template.category);
68
- });
69
- return Array.from(categories);
70
- };
71
- var getCategoryData = async (categorySlug) => {
72
- const templateData = await getTemplateData();
73
- if (templateData.categories && templateData.categories.length > 0) {
74
- return templateData.categories.find(
75
- (category) => category.slug === categorySlug
76
- );
77
- }
78
- return void 0;
79
- };
80
- var getTemplatesForCategory = async (category, cliArgs) => {
81
- const selectedCategory = cliArgs?.category || category;
82
- if (!selectedCategory) {
83
- throw new Error("Category is required in non-interactive mode.");
84
- }
85
- const templateData = await getTemplateData();
86
- const templates = templateData.templates.filter(
87
- (template) => template.category === selectedCategory
88
- );
89
- return templates;
90
- };
91
- var getExtensionsGroupedByCategory = async (type, cliArgs) => {
92
- const selectedType = cliArgs?.type ? cliArgs.type.split(",") : type;
93
- const safeType = Array.isArray(selectedType) ? selectedType : [selectedType];
94
- const templateData = await getTemplateData();
95
- const extensions = templateData.extensions.filter((extension) => {
96
- const safeExtensionType = Array.isArray(extension.type) ? extension.type : [extension.type];
97
- return safeExtensionType.some(
98
- (extensionType) => safeType.includes(extensionType)
99
- );
100
- });
101
- const extensionsGroupedByCategory = extensions.reduce(
102
- (acc, extension) => {
103
- const category = extension.category;
104
- if (!acc[category]) {
105
- acc[category] = [];
106
- }
107
- acc[category].push(extension);
108
- return acc;
109
- },
110
- {}
111
- );
112
- return extensionsGroupedByCategory;
113
- };
114
-
115
- export {
116
- __require,
117
- __commonJS,
118
- __toESM,
119
- getTemplateCategories,
120
- getCategoryData,
121
- getTemplatesForCategory,
122
- getExtensionsGroupedByCategory
123
- };