git-release-manager 0.0.0 → 0.0.3

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 (38) hide show
  1. package/dist/src/config/defaultConfig.json +232 -0
  2. package/dist/src/config/index.js +86 -0
  3. package/dist/src/config/index.js.map +1 -0
  4. package/dist/src/config/types.js +3 -0
  5. package/dist/src/config/types.js.map +1 -0
  6. package/dist/src/core/app.js +218 -0
  7. package/dist/src/core/app.js.map +1 -0
  8. package/dist/src/core/types.js +3 -0
  9. package/dist/src/core/types.js.map +1 -0
  10. package/dist/src/git/commits.js +237 -0
  11. package/dist/src/git/commits.js.map +1 -0
  12. package/dist/src/git/context.js +95 -0
  13. package/dist/src/git/context.js.map +1 -0
  14. package/dist/src/index.js +89 -0
  15. package/dist/src/index.js.map +1 -0
  16. package/dist/src/main.js +22 -0
  17. package/dist/src/main.js.map +1 -0
  18. package/dist/src/output/writer.js +46 -0
  19. package/dist/src/output/writer.js.map +1 -0
  20. package/dist/src/sections/index.js +207 -0
  21. package/dist/src/sections/index.js.map +1 -0
  22. package/dist/src/templates/changelog.detailed.ejs +111 -0
  23. package/dist/src/templates/changelog.ejs +68 -0
  24. package/dist/src/templates/index.js +101 -0
  25. package/dist/src/templates/index.js.map +1 -0
  26. package/dist/src/utils/cli.js +3 -0
  27. package/dist/src/utils/cli.js.map +1 -0
  28. package/dist/src/utils/cmd.js +57 -0
  29. package/dist/src/utils/cmd.js.map +1 -0
  30. package/dist/src/utils/git-utils.js +278 -0
  31. package/dist/src/utils/git-utils.js.map +1 -0
  32. package/dist/src/utils/helpers.js +50 -0
  33. package/dist/src/utils/helpers.js.map +1 -0
  34. package/dist/test/config/loadConfigFile.test.js +94 -0
  35. package/dist/test/config/loadConfigFile.test.js.map +1 -0
  36. package/dist/test/config/readConfig.test.js +125 -0
  37. package/dist/test/config/readConfig.test.js.map +1 -0
  38. package/package.json +7 -7
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ // Typescript version of your code
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createSections = createSections;
5
+ exports.summarizeCommits = summarizeCommits;
6
+ exports.summarizeNotes = summarizeNotes;
7
+ exports.summarizeContributors = summarizeContributors;
8
+ exports.groupBy = groupBy;
9
+ exports.groupByNotes = groupByNotes;
10
+ exports.getContributors = getContributors;
11
+ function createSections(commits, config) {
12
+ const sections = {};
13
+ sections.commits = groupBy(commits, "type", config);
14
+ sections.notes = groupByNotes(commits, config, false);
15
+ sections.contributors = getContributors(commits, config);
16
+ sections.summary = {
17
+ commits: summarizeCommits(sections.commits, config),
18
+ notes: summarizeNotes(sections.notes, config),
19
+ contributors: summarizeContributors(sections.contributors, config),
20
+ };
21
+ return sections;
22
+ }
23
+ function summarizeCommits(commits, config) {
24
+ if (!Array.isArray(commits)) {
25
+ throw new Error("Invalid input: commits must be an array");
26
+ }
27
+ const result = [];
28
+ const summary = commits.reduce((acc, commit) => {
29
+ const type = commit.type;
30
+ if (!acc[type]) {
31
+ const matchingType = config.commitTypes.find((ct) => ct.type === type);
32
+ const typeTitle = matchingType ? matchingType.title : "Other Changes";
33
+ const order = matchingType && matchingType.order !== undefined
34
+ ? matchingType.order
35
+ : Number.MAX_SAFE_INTEGER;
36
+ acc[type] = {
37
+ type: type,
38
+ title: typeTitle,
39
+ count: commit.items.length,
40
+ order: order,
41
+ };
42
+ }
43
+ return acc;
44
+ }, {});
45
+ result.push(...Object.values(summary));
46
+ result.sort((a, b) => a.order - b.order);
47
+ return result;
48
+ }
49
+ function summarizeNotes(notes, config) {
50
+ if (!Array.isArray(notes)) {
51
+ throw new Error("Invalid input: notes must be an array");
52
+ }
53
+ const result = [];
54
+ const summary = notes.reduce((acc, note) => {
55
+ const type = note.type;
56
+ if (!acc[type]) {
57
+ const matchingType = config.noteTypes.find((nt) => nt.type === type);
58
+ const typeTitle = matchingType ? matchingType.title : "Other Notes";
59
+ const order = matchingType && matchingType.order !== undefined
60
+ ? matchingType.order
61
+ : Number.MAX_SAFE_INTEGER;
62
+ acc[type] = {
63
+ type: type,
64
+ title: typeTitle,
65
+ count: note.items.length,
66
+ order: order,
67
+ };
68
+ }
69
+ return acc;
70
+ }, {});
71
+ result.push(...Object.values(summary));
72
+ result.sort((a, b) => a.order - b.order);
73
+ return result;
74
+ }
75
+ function summarizeContributors(contributors, config) {
76
+ if (!Array.isArray(contributors)) {
77
+ throw new Error("Invalid input: contributors must be an array");
78
+ }
79
+ const result = [];
80
+ const summary = contributors.reduce((acc, contributor) => {
81
+ var _a;
82
+ const type = contributor.email;
83
+ if (!acc[type]) {
84
+ acc[type] = {
85
+ email: contributor.email,
86
+ name: contributor.name,
87
+ profileUrl: contributor.profileUrl,
88
+ count: ((_a = contributor.groups) === null || _a === void 0 ? void 0 : _a.length) || 0,
89
+ };
90
+ }
91
+ return acc;
92
+ }, {});
93
+ result.push(...Object.values(summary));
94
+ return result;
95
+ }
96
+ function groupBy(commits, key, config) {
97
+ if (!Array.isArray(commits)) {
98
+ throw new Error("Invalid input: commits must be an array");
99
+ }
100
+ const result = [];
101
+ const grouped = commits.reduce((acc, commit) => {
102
+ const groupKey = key
103
+ .split(".")
104
+ .reduce((nested, part) => nested && nested[part], commit);
105
+ if (!acc[groupKey]) {
106
+ const matchingType = config.commitTypes.find((ct) => ct.terms.includes(groupKey));
107
+ const typeTitle = matchingType ? matchingType.title : "Other Changes";
108
+ const order = matchingType && matchingType.order !== undefined
109
+ ? matchingType.order
110
+ : Number.MAX_SAFE_INTEGER;
111
+ acc[groupKey] = {
112
+ type: matchingType ? matchingType.type : "other",
113
+ title: typeTitle,
114
+ order: order,
115
+ items: [],
116
+ };
117
+ }
118
+ acc[groupKey].items.push(commit);
119
+ return acc;
120
+ }, {});
121
+ result.push(...Object.values(grouped));
122
+ result.sort((a, b) => (a.order || 0) - (b.order || 0));
123
+ return result;
124
+ }
125
+ function groupByNotes(array, config, includeUnmatched = true) {
126
+ if (!Array.isArray(array)) {
127
+ throw new Error("Invalid input: array must be an array");
128
+ }
129
+ const result = [];
130
+ const grouped = array.reduce((acc, item) => {
131
+ if (!item.notes || item.notes.length === 0)
132
+ return acc;
133
+ item.notes.forEach((note) => {
134
+ const groupKey = note.type;
135
+ const matchingType = config.noteTypes.find((nt) => nt.type === groupKey);
136
+ if (!matchingType && !includeUnmatched)
137
+ return;
138
+ if (!acc[groupKey]) {
139
+ const typeTitle = matchingType ? matchingType.title : groupKey;
140
+ const order = matchingType && matchingType.order !== undefined
141
+ ? matchingType.order
142
+ : Number.MAX_SAFE_INTEGER;
143
+ acc[groupKey] = {
144
+ type: groupKey,
145
+ title: typeTitle,
146
+ order: order,
147
+ items: [],
148
+ };
149
+ }
150
+ acc[groupKey].items.push({
151
+ note,
152
+ commit: item,
153
+ });
154
+ });
155
+ return acc;
156
+ }, {});
157
+ result.push(...Object.values(grouped));
158
+ result.sort((a, b) => (a.order || 0) - (b.order || 0));
159
+ return result;
160
+ }
161
+ function getContributors(commits, config) {
162
+ const contributors = {};
163
+ commits.forEach((commit) => {
164
+ const allContributors = [commit.author, ...(commit.mentions || [])];
165
+ allContributors.forEach((contributor) => {
166
+ var _a;
167
+ const key = contributor.email;
168
+ if (!contributors[key]) {
169
+ contributors[key] = {
170
+ ...contributor,
171
+ groups: [],
172
+ files: [],
173
+ commits: [],
174
+ };
175
+ }
176
+ const normalizePath = (path) => path.replace(/\\/g, "/");
177
+ commit.files.forEach((file) => {
178
+ var _a;
179
+ const normalizedFile = normalizePath(file);
180
+ Object.entries(config.fileGroups).forEach(([group, paths]) => {
181
+ var _a;
182
+ if (paths.some((path) => normalizedFile.startsWith(normalizePath(path)))) {
183
+ let groupObj = (_a = contributors[key].groups) === null || _a === void 0 ? void 0 : _a.find((g) => g.title === group);
184
+ if (!groupObj) {
185
+ groupObj = { title: group, files: [], commits: [] };
186
+ contributors[key].groups.push(groupObj);
187
+ }
188
+ if (!groupObj.files.includes(normalizedFile)) {
189
+ groupObj.files.push(normalizedFile);
190
+ }
191
+ if (!groupObj.commits.includes(commit)) {
192
+ groupObj.commits.push(commit);
193
+ }
194
+ }
195
+ });
196
+ if (!((_a = contributors[key].files) === null || _a === void 0 ? void 0 : _a.includes(normalizedFile))) {
197
+ contributors[key].files.push(normalizedFile);
198
+ }
199
+ });
200
+ if (!((_a = contributors[key].commits) === null || _a === void 0 ? void 0 : _a.includes(commit))) {
201
+ contributors[key].commits.push(commit);
202
+ }
203
+ });
204
+ });
205
+ return Object.values(contributors);
206
+ }
207
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sections/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAiElC,wCAWC;AAED,4CAiCC;AAED,wCAiCC;AAED,sDA8BC;AAED,0BA8CC;AAED,oCAiDC;AAED,0CA0DC;AAhRD,SAAgB,cAAc,CAAC,OAAwB,EAAE,MAAc;IACrE,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACtD,QAAQ,CAAC,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzD,QAAQ,CAAC,OAAO,GAAG;QACjB,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,OAAQ,EAAE,MAAM,CAAC;QACpD,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,KAAM,EAAE,MAAM,CAAC;QAC9C,YAAY,EAAE,qBAAqB,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;KACnE,CAAC;IACF,OAAO,QAAoB,CAAC;AAC9B,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAyB,EAAE,MAAc;IACxE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,E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A,MAAA,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,0CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA,EAAE,CAAC;gBACjD,YAAY,CAAC,GAAG,CAAC,CAAC,OAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,111 @@
1
+ # <%= config.appName %> <%= changeInfo.header %> Release Notes - <%= latestTag?.date?.split("T")[0] %>
2
+
3
+ ## Summary:
4
+ <% sections.summary.commits.forEach(function(commit) { %>
5
+ - <%= commit.title %>: <%= commit.count %> <%= commit.count === 1 ? 'commit' : 'commits' %>
6
+ <% }) %>
7
+ <% sections.summary.notes.forEach(function(note) { %>
8
+ - <%= note.title %>: <%= note.count %> <%= note.count === 1 ? 'note' : 'notes' %>
9
+ <% }) %>
10
+ and <%= sections.summary.contributors.length %> <%= sections.summary.contributors.length === 1 ? '❤️ contributor' : '❤️ contributors' %>
11
+
12
+
13
+ <% if (sections.notes.length > 0) { %>
14
+ ## Notes
15
+ <% sections.notes.forEach((note) => { %>
16
+ ### <%= note.title %>
17
+ <% note.items.forEach(item => { %>
18
+ <%
19
+ const commitLinks = `[#${item.commit.raw.shortHash}](#commit-${item.commit.raw.shortHash})`;
20
+ %>
21
+ - <%= item.note.content %> (<%= commitLinks %>)
22
+ <% }) %>
23
+ <% }) %>
24
+ <% } %>
25
+
26
+
27
+ <% if (sections.commits.length > 0) { %>
28
+ ## Changes
29
+ <% sections.commits.forEach((section) => { %>
30
+ ### <%= section.title %>:
31
+ <%
32
+ // Scope'a göre commit'leri gruplama
33
+ const scopedCommits = {};
34
+ const unscopedCommits = [];
35
+
36
+ section.items.forEach(commit => {
37
+ if (commit.scope) {
38
+ if (!scopedCommits[commit.scope]) {
39
+ scopedCommits[commit.scope] = [];
40
+ }
41
+ scopedCommits[commit.scope].push(commit);
42
+ } else {
43
+ unscopedCommits.push(commit);
44
+ }
45
+ });
46
+ %>
47
+
48
+ <% // Scope'lu commit'leri gösterme
49
+ Object.keys(scopedCommits).sort().forEach(scope => { %>
50
+ #### <%= scope %>
51
+ <% scopedCommits[scope].forEach(commit => {
52
+ const author = `[@${commit.author.name}](${commit.author.profileUrl})`;
53
+ const mentions = commit.mentions
54
+ ? commit.mentions
55
+ .filter(mention => ['co-authored-by', 'helped-by'].includes(mention.type))
56
+ .map(mention => `[@${mention.name}](${mention.profileUrl})`)
57
+ .join(', ')
58
+ : '';
59
+ const authorText = mentions ? `${author} with ${mentions}` : author;
60
+
61
+ const commitLink = `[#${commit.raw.shortHash}](${repository.remote.repoUrl}/commit/${commit.raw.hash})`;
62
+
63
+ const issueLinks = commit.links && commit.links.length > 0
64
+ ? ` (${commit.links.length === 1 ? 'Issue' : 'Issues'}: ${commit.links.map(link => `[#${link.id}](${repository.remote.repoUrl}/issues/${link.id})`).join(', ')})`
65
+ : '';
66
+ %>
67
+ - <a id="commit-<%= commit.raw.shortHash %>"></a><%= commitLink %>: <%= commit.summary %> (by <%= authorText %>) <%= issueLinks %>
68
+ <% if (commit.description) { %>
69
+
70
+ <%= commit.description?.split('\n').map(line => `\t${line.trim()}`).join('\n') %>
71
+ <% } %>
72
+ <% }); %>
73
+ <% }); %>
74
+
75
+ <% // Scope'suz commit'leri gösterme
76
+ unscopedCommits.forEach(commit => {
77
+ const author = `[@${commit.author.name}](${commit.author.profileUrl})`;
78
+ const mentions = commit.mentions
79
+ ? commit.mentions
80
+ .filter(mention => ['co-authored-by', 'helped-by'].includes(mention.type))
81
+ .map(mention => `[@${mention.name}](${mention.profileUrl})`)
82
+ .join(', ')
83
+ : '';
84
+ const authorText = mentions ? `${author} with ${mentions}` : author;
85
+
86
+ const commitLink = `[#${commit.raw.shortHash}](${repository.remote.repoUrl}/commit/${commit.raw.hash})`;
87
+
88
+ const issueLinks = commit.links && commit.links.length > 0
89
+ ? ` (${commit.links.length === 1 ? 'Issue' : 'Issues'}: ${commit.links.map(link => `[#${link.id}](${repository.remote.repoUrl}/issues/${link.id})`).join(', ')})`
90
+ : '';
91
+ %>
92
+ - <a id="commit-<%= commit.raw.shortHash %>"></a><%= commitLink %>: <%= commit.summary %> (by <%= authorText %>) <%= issueLinks %>
93
+ <% if (commit.description) { %>
94
+
95
+ <%= commit.description %>
96
+ <% } %>
97
+ <% }); %>
98
+ <% }) %>
99
+ <% } %>
100
+
101
+ ## Useful Links
102
+ - 📜 [Full Changelog](<%= repository.remote.repoUrl %>/blob/main/CHANGELOG.md)
103
+
104
+
105
+
106
+ <% if (sections.contributors.length > 0) { %>
107
+ ## Contributors:
108
+ <% sections.contributors.forEach((contributor) => { %>
109
+ - [<%= contributor.name %>](<%= contributor.profileUrl %>) <% if (contributor.groups.length > 0) { %>(<%= contributor.groups.map(group => group.title).join(', ') %>)<% } %>
110
+ <% }) %>
111
+ <% } %>
@@ -0,0 +1,68 @@
1
+ # <%= config.appName %> <%= changeInfo.header %> Release Notes - <%= latestTag?.date?.split("T")[0] %>
2
+
3
+ ## Summary:
4
+ <% sections.summary.commits.forEach(function(commit) { %>
5
+ - <%= commit.title %>: <%= commit.count %> <%= commit.count === 1 ? 'commit' : 'commits' %>
6
+ <% }) %>
7
+ <% sections.summary.notes.forEach(function(note) { %>
8
+ - <%= note.title %>: <%= note.count %> <%= note.count === 1 ? 'note' : 'notes' %>
9
+ <% }) %>
10
+ and <%= sections.summary.contributors.length %> <%= sections.summary.contributors.length === 1 ? '❤️ contributor' : '❤️ contributors' %>
11
+
12
+
13
+ <% if (sections.notes.length > 0) { %>
14
+ ## Notes
15
+ <% sections.notes.forEach((note) => { %>
16
+ ### <%= note.title %>
17
+ <% note.items.forEach(item => { %>
18
+ <%
19
+ const commitLinks = `[#${item.commit.raw.shortHash}](#commit-${item.commit.raw.shortHash})`;
20
+ %>
21
+ - <%= item.note.content %> (<%= commitLinks %>)
22
+ <% }) %>
23
+ <% }) %>
24
+ <% } %>
25
+
26
+
27
+ <% if (sections.commits.length > 0) { %>
28
+ ## Changes
29
+ <% sections.commits.forEach((section) => { %>
30
+ ### <%= section.title %>:
31
+ <%
32
+ section.items.forEach(commit => {
33
+ const author = `[@${commit.author.name}](${commit.author.profileUrl})`;
34
+ const mentions = commit.mentions
35
+ ? commit.mentions
36
+ .filter(mention => ['co-authored-by', 'helped-by'].includes(mention.type))
37
+ .map(mention => `[@${mention.name}](${mention.profileUrl})`)
38
+ .join(', ')
39
+ : '';
40
+ const authorText = mentions ? `${author} with ${mentions}` : author;
41
+
42
+ const commitLink = `[#${commit.raw.shortHash}](${repository.remote.repoUrl}/commit/${commit.raw.hash})`;
43
+
44
+ const issueLinks = commit.links && commit.links.length > 0
45
+ ? ` (${commit.links.length === 1 ? 'Issue' : 'Issues'}: ${commit.links.map(link => `[#${link.id}](${repository.remote.repoUrl}/issues/${link.id})`).join(', ')})`
46
+ : '';
47
+
48
+ const scopeText = commit.scope ? `**${commit.scope}** ` : '';
49
+ %>
50
+ - <a id="commit-<%= commit.raw.shortHash %>"></a><%= scopeText %><%= commitLink %>: <%= commit.summary %> (by <%= authorText %>) <%= issueLinks %>
51
+ <% if (commit.description) { %>
52
+
53
+ <%= commit.description?.split('\n').map(line => `\t${line.trim()}`).join('\n') %>
54
+ <% } %>
55
+ <% }); %>
56
+ <% }) %>
57
+ <% } %>
58
+
59
+ ## Useful Links
60
+ - 📜 [Full Changelog](<%= repository.remote.repoUrl %>/blob/main/CHANGELOG.md)
61
+
62
+
63
+ <% if (sections.contributors.length > 0) { %>
64
+ ## Contributors:
65
+ <% sections.contributors.forEach((contributor) => { %>
66
+ - [<%= contributor.name %>](<%= contributor.profileUrl %>) <% if (contributor.groups.length > 0) { %>(<%= contributor.groups.map(group => group.title).join(', ') %>)<% } %>
67
+ <% }) %>
68
+ <% } %>
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveTemplatePath = resolveTemplatePath;
37
+ exports.renderTemplate = renderTemplate;
38
+ const ejs = __importStar(require("ejs"));
39
+ const fs = __importStar(require("fs"));
40
+ const path = __importStar(require("path"));
41
+ const DEFAULT_TEMPLATE_PATH = path.resolve(__dirname, 'changelog.ejs');
42
+ const LOCAL_TEMPLATE_PATH = path.resolve(process.cwd(), '.grm/templates/changelog.ejs');
43
+ // export async function resolveTemplatePath1(paramPath?: string): Promise<string> {
44
+ // if (paramPath) {
45
+ // const resolvedPath = path.resolve(paramPath);
46
+ // try {
47
+ // const isCustomTemplateExists = fs.existsSync(resolvedPath);
48
+ // if (isCustomTemplateExists) {
49
+ // return resolvedPath;
50
+ // }
51
+ // } catch (error: any) {
52
+ // if (error.code === 'ENOENT') {
53
+ // throw new Error(`Template file not found at: ${resolvedPath}`);
54
+ // }
55
+ // throw error;
56
+ // }
57
+ // }
58
+ // const isLocalTemplateExists = fs.existsSync(LOCAL_TEMPLATE_PATH);
59
+ // if (isLocalTemplateExists) {
60
+ // return LOCAL_TEMPLATE_PATH;
61
+ // } else {
62
+ // return DEFAULT_TEMPLATE_PATH;
63
+ // }
64
+ // }
65
+ async function resolveTemplatePath(paramPath, environment = null) {
66
+ const envSuffix = environment ? `.${environment}` : '';
67
+ if (paramPath) {
68
+ const resolvedPath = path.resolve(paramPath.replace(/\.ejs$/, `${envSuffix}.ejs`));
69
+ if (fs.existsSync(resolvedPath)) {
70
+ return resolvedPath;
71
+ }
72
+ // Fallback to default template if environment-specific template is not found
73
+ const defaultParamPath = path.resolve(paramPath);
74
+ if (fs.existsSync(defaultParamPath)) {
75
+ return defaultParamPath;
76
+ }
77
+ throw new Error(`Template file not found at: ${resolvedPath} or ${defaultParamPath}`);
78
+ }
79
+ const localTemplatePath = LOCAL_TEMPLATE_PATH.replace(/\.ejs$/, `${envSuffix}.ejs`);
80
+ if (fs.existsSync(localTemplatePath)) {
81
+ return localTemplatePath;
82
+ }
83
+ if (fs.existsSync(LOCAL_TEMPLATE_PATH)) {
84
+ return LOCAL_TEMPLATE_PATH;
85
+ }
86
+ const defaultTemplatePath = DEFAULT_TEMPLATE_PATH.replace(/\.ejs$/, `${envSuffix}.ejs`);
87
+ if (fs.existsSync(defaultTemplatePath)) {
88
+ return defaultTemplatePath;
89
+ }
90
+ if (fs.existsSync(DEFAULT_TEMPLATE_PATH)) {
91
+ return DEFAULT_TEMPLATE_PATH;
92
+ }
93
+ throw new Error('No valid template file found');
94
+ }
95
+ async function renderTemplate(templatePath, environment = null, data) {
96
+ const resolvedTemplatePath = await resolveTemplatePath(templatePath, environment);
97
+ const templateContent = fs.readFileSync(resolvedTemplatePath, 'utf-8');
98
+ const output = ejs.render(templateContent, { ...data });
99
+ return output;
100
+ }
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,kDAmCC;AAGD,wCAOC;AA3ED,yCAA2B;AAC3B,uCAAyB;AACzB,2CAA6B;AAE7B,MAAM,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AACvE,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,8BAA8B,CAAC,CAAC;AAExF,oFAAoF;AACpF,uBAAuB;AACvB,wDAAwD;AACxD,gBAAgB;AAChB,0EAA0E;AAC1E,4CAA4C;AAC5C,uCAAuC;AACvC,gBAAgB;AAChB,iCAAiC;AACjC,6CAA6C;AAC7C,kFAAkF;AAClF,gBAAgB;AAChB,2BAA2B;AAC3B,YAAY;AACZ,QAAQ;AAER,wEAAwE;AACxE,mCAAmC;AACnC,sCAAsC;AACtC,eAAe;AACf,wCAAwC;AACxC,QAAQ;AACR,IAAI;AACG,KAAK,UAAU,mBAAmB,CAAC,SAAkB,EAAE,cAA6B,IAAI;IAC3F,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEvD,IAAI,SAAS,EAAE,CAAC;QACZ,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,SAAS,MAAM,CAAC,CAAC,CAAC;QACnF,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,OAAO,YAAY,CAAC;QACxB,CAAC;QACD,6EAA6E;QAC7E,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAA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C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/utils/cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCommand = runCommand;
4
+ const child_process_1 = require("child_process");
5
+ function runCommand(cmd, onError) {
6
+ var _a;
7
+ try {
8
+ const [command, ...args] = cmd.split(' ');
9
+ const result = (0, child_process_1.spawnSync)(command, args, { encoding: 'utf8' });
10
+ if (result.status === 0) {
11
+ return ((_a = result.stdout) === null || _a === void 0 ? void 0 : _a.trim()) || '';
12
+ }
13
+ else {
14
+ if (onError && typeof onError === 'function') {
15
+ onError(cmd, result.stderr.trim(), result.status);
16
+ }
17
+ return null;
18
+ }
19
+ }
20
+ catch (error) {
21
+ if (onError && typeof onError === 'function') {
22
+ onError(cmd, error instanceof Error ? error.message : String(error), null);
23
+ }
24
+ return null;
25
+ }
26
+ }
27
+ // export async function runCommandAsync(cmd: string, onError?: ErrorCallback): Promise<string | null> {
28
+ // return new Promise((resolve) => {
29
+ // const [command, ...args] = cmd.split(' ');
30
+ // const process = spawn(command, args, { encoding: 'utf8' });
31
+ // let stdout = '';
32
+ // let stderr = '';
33
+ // process.stdout?.on('data', (data: Buffer) => {
34
+ // stdout += data.toString();
35
+ // });
36
+ // process.stderr?.on('data', (data: Buffer) => {
37
+ // stderr += data.toString();
38
+ // });
39
+ // process.on('close', (status: number | null) => {
40
+ // if (status === 0) {
41
+ // resolve(stdout.trim());
42
+ // } else {
43
+ // if (onError && typeof onError === 'function') {
44
+ // onError(cmd, stderr.trim(), status);
45
+ // }
46
+ // resolve(null);
47
+ // }
48
+ // });
49
+ // process.on('error', (error: Error) => {
50
+ // if (onError && typeof onError === 'function') {
51
+ // onError(cmd, error.message, null);
52
+ // }
53
+ // resolve(null);
54
+ // });
55
+ // });
56
+ // }
57
+ //# sourceMappingURL=cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cmd.js","sourceRoot":"","sources":["../../../src/utils/cmd.ts"],"names":[],"mappings":";;AAIA,gCAmBC;AAvBD,iDAAiD;AAIjD,SAAgB,UAAU,CAAC,GAAW,EAAE,OAAuB;;IAC3D,IAAI,CAAC;QACD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,CAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,IAAI,EAAE,KAAI,EAAE,CAAC;QACvC,CAAC;aAAM,CAAC;YACJ,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3C,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YACtD,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,wGAAwG;AACxG,wCAAwC;AACxC,qDAAqD;AACrD,sEAAsE;AAEtE,2BAA2B;AAC3B,2BAA2B;AAE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