@ucdjs/release-scripts 0.1.0-beta.3 → 0.1.0-beta.5

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.
@@ -0,0 +1,477 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+
4
+ //#region node_modules/.pnpm/eta@4.0.1/node_modules/eta/dist/index.js
5
+ var EtaError = class extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "Eta Error";
9
+ }
10
+ };
11
+ var EtaParseError = class extends EtaError {
12
+ constructor(message) {
13
+ super(message);
14
+ this.name = "EtaParser Error";
15
+ }
16
+ };
17
+ var EtaRuntimeError = class extends EtaError {
18
+ constructor(message) {
19
+ super(message);
20
+ this.name = "EtaRuntime Error";
21
+ }
22
+ };
23
+ var EtaFileResolutionError = class extends EtaError {
24
+ constructor(message) {
25
+ super(message);
26
+ this.name = "EtaFileResolution Error";
27
+ }
28
+ };
29
+ var EtaNameResolutionError = class extends EtaError {
30
+ constructor(message) {
31
+ super(message);
32
+ this.name = "EtaNameResolution Error";
33
+ }
34
+ };
35
+ /**
36
+ * Throws an EtaError with a nicely formatted error and message showing where in the template the error occurred.
37
+ */
38
+ function ParseErr(message, str, indx) {
39
+ const whitespace = str.slice(0, indx).split(/\n/);
40
+ const lineNo = whitespace.length;
41
+ const colNo = whitespace[lineNo - 1].length + 1;
42
+ message += " at line " + lineNo + " col " + colNo + ":\n\n " + str.split(/\n/)[lineNo - 1] + "\n " + Array(colNo).join(" ") + "^";
43
+ throw new EtaParseError(message);
44
+ }
45
+ function RuntimeErr(originalError, str, lineNo, path$1) {
46
+ const lines = str.split("\n");
47
+ const start = Math.max(lineNo - 3, 0);
48
+ const end = Math.min(lines.length, lineNo + 3);
49
+ const filename = path$1;
50
+ const context = lines.slice(start, end).map((line, i) => {
51
+ const curr = i + start + 1;
52
+ return (curr === lineNo ? " >> " : " ") + curr + "| " + line;
53
+ }).join("\n");
54
+ const err = new EtaRuntimeError((filename ? filename + ":" + lineNo + "\n" : "line " + lineNo + "\n") + context + "\n\n" + originalError.message);
55
+ err.name = originalError.name;
56
+ throw err;
57
+ }
58
+ function readFile(path$1) {
59
+ let res = "";
60
+ try {
61
+ res = fs.readFileSync(path$1, "utf8");
62
+ } catch (err) {
63
+ if (err?.code === "ENOENT") throw new EtaFileResolutionError(`Could not find template: ${path$1}`);
64
+ else throw err;
65
+ }
66
+ return res;
67
+ }
68
+ function resolvePath(templatePath, options) {
69
+ let resolvedFilePath = "";
70
+ const views = this.config.views;
71
+ if (!views) throw new EtaFileResolutionError("Views directory is not defined");
72
+ const baseFilePath = options?.filepath;
73
+ const defaultExtension = this.config.defaultExtension === void 0 ? ".eta" : this.config.defaultExtension;
74
+ const cacheIndex = JSON.stringify({
75
+ filename: baseFilePath,
76
+ path: templatePath,
77
+ views: this.config.views
78
+ });
79
+ templatePath += path.extname(templatePath) ? "" : defaultExtension;
80
+ if (baseFilePath) {
81
+ if (this.config.cacheFilepaths && this.filepathCache[cacheIndex]) return this.filepathCache[cacheIndex];
82
+ if (absolutePathRegExp.exec(templatePath)?.length) {
83
+ const formattedPath = templatePath.replace(/^\/*|^\\*/, "");
84
+ resolvedFilePath = path.join(views, formattedPath);
85
+ } else resolvedFilePath = path.join(path.dirname(baseFilePath), templatePath);
86
+ } else resolvedFilePath = path.join(views, templatePath);
87
+ if (dirIsChild(views, resolvedFilePath)) {
88
+ if (baseFilePath && this.config.cacheFilepaths) this.filepathCache[cacheIndex] = resolvedFilePath;
89
+ return resolvedFilePath;
90
+ } else throw new EtaFileResolutionError(`Template '${templatePath}' is not in the views directory`);
91
+ }
92
+ function dirIsChild(parent, dir) {
93
+ const relative = path.relative(parent, dir);
94
+ return relative && !relative.startsWith("..") && !path.isAbsolute(relative);
95
+ }
96
+ const absolutePathRegExp = /^\\|^\//;
97
+ /* istanbul ignore next */
98
+ const AsyncFunction = (async () => {}).constructor;
99
+ /**
100
+ * Takes a template string and returns a template function that can be called with (data, config)
101
+ *
102
+ * @param str - The template string
103
+ * @param config - A custom configuration object (optional)
104
+ */
105
+ function compile(str, options) {
106
+ const config = this.config;
107
+ const ctor = options?.async ? AsyncFunction : Function;
108
+ try {
109
+ return new ctor(config.varName, "options", this.compileToString.call(this, str, options));
110
+ } catch (e) {
111
+ if (e instanceof SyntaxError) throw new EtaParseError("Bad template syntax\n\n" + e.message + "\n" + Array(e.message.length + 1).join("=") + "\n" + this.compileToString.call(this, str, options) + "\n");
112
+ else throw e;
113
+ }
114
+ }
115
+ /**
116
+ * Compiles a template string to a function string. Most often users just use `compile()`, which calls `compileToString` and creates a new function using the result
117
+ */
118
+ function compileToString(str, options) {
119
+ const config = this.config;
120
+ const isAsync = options?.async;
121
+ const compileBody$1 = this.compileBody;
122
+ const buffer = this.parse.call(this, str);
123
+ let res = `${config.functionHeader}
124
+ let include = (template, data) => this.render(template, data, options);
125
+ let includeAsync = (template, data) => this.renderAsync(template, data, options);
126
+
127
+ let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction${config.debug ? ", line: 1, templateStr: \"" + str.replace(/\\|"/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n") + "\"" : ""}};
128
+
129
+ function layout(path, data) {
130
+ __eta.layout = path;
131
+ __eta.layoutData = data;
132
+ }${config.debug ? "try {" : ""}${config.useWith ? "with(" + config.varName + "||{}){" : ""}
133
+
134
+ ${compileBody$1.call(this, buffer)}
135
+ if (__eta.layout) {
136
+ __eta.res = ${isAsync ? "await includeAsync" : "include"} (__eta.layout, {...${config.varName}, body: __eta.res, ...__eta.layoutData});
137
+ }
138
+ ${config.useWith ? "}" : ""}${config.debug ? "} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }" : ""}
139
+ return __eta.res;
140
+ `;
141
+ if (config.plugins) for (let i = 0; i < config.plugins.length; i++) {
142
+ const plugin = config.plugins[i];
143
+ if (plugin.processFnString) res = plugin.processFnString(res, config);
144
+ }
145
+ return res;
146
+ }
147
+ /**
148
+ * Loops through the AST generated by `parse` and transform each item into JS calls
149
+ *
150
+ * **Example**
151
+ *
152
+ * ```js
153
+ * let templateAST = ['Hi ', { val: 'it.name', t: 'i' }]
154
+ * compileBody.call(Eta, templateAST)
155
+ * // => "__eta.res+='Hi '\n__eta.res+=__eta.e(it.name)\n"
156
+ * ```
157
+ */
158
+ function compileBody(buff) {
159
+ const config = this.config;
160
+ let i = 0;
161
+ const buffLength = buff.length;
162
+ let returnStr = "";
163
+ for (; i < buffLength; i++) {
164
+ const currentBlock = buff[i];
165
+ if (typeof currentBlock === "string") returnStr += "__eta.res+='" + currentBlock + "'\n";
166
+ else {
167
+ const type = currentBlock.t;
168
+ let content = currentBlock.val || "";
169
+ if (config.debug) returnStr += "__eta.line=" + currentBlock.lineNo + "\n";
170
+ if (type === "r") {
171
+ if (config.autoFilter) content = "__eta.f(" + content + ")";
172
+ returnStr += "__eta.res+=" + content + "\n";
173
+ } else if (type === "i") {
174
+ if (config.autoFilter) content = "__eta.f(" + content + ")";
175
+ if (config.autoEscape) content = "__eta.e(" + content + ")";
176
+ returnStr += "__eta.res+=" + content + "\n";
177
+ } else if (type === "e") returnStr += content + "\n";
178
+ }
179
+ }
180
+ return returnStr;
181
+ }
182
+ /**
183
+ * Takes a string within a template and trims it, based on the preceding tag's whitespace control and `config.autoTrim`
184
+ */
185
+ function trimWS(str, config, wsLeft, wsRight) {
186
+ let leftTrim;
187
+ let rightTrim;
188
+ if (Array.isArray(config.autoTrim)) {
189
+ leftTrim = config.autoTrim[1];
190
+ rightTrim = config.autoTrim[0];
191
+ } else leftTrim = rightTrim = config.autoTrim;
192
+ if (wsLeft || wsLeft === false) leftTrim = wsLeft;
193
+ if (wsRight || wsRight === false) rightTrim = wsRight;
194
+ if (!rightTrim && !leftTrim) return str;
195
+ if (leftTrim === "slurp" && rightTrim === "slurp") return str.trim();
196
+ if (leftTrim === "_" || leftTrim === "slurp") str = str.trimStart();
197
+ else if (leftTrim === "-" || leftTrim === "nl") str = str.replace(/^(?:\r\n|\n|\r)/, "");
198
+ if (rightTrim === "_" || rightTrim === "slurp") str = str.trimEnd();
199
+ else if (rightTrim === "-" || rightTrim === "nl") str = str.replace(/(?:\r\n|\n|\r)$/, "");
200
+ return str;
201
+ }
202
+ /**
203
+ * A map of special HTML characters to their XML-escaped equivalents
204
+ */
205
+ const escMap = {
206
+ "&": "&amp;",
207
+ "<": "&lt;",
208
+ ">": "&gt;",
209
+ "\"": "&quot;",
210
+ "'": "&#39;"
211
+ };
212
+ function replaceChar(s) {
213
+ return escMap[s];
214
+ }
215
+ /**
216
+ * XML-escapes an input value after converting it to a string
217
+ *
218
+ * @param str - Input value (usually a string)
219
+ * @returns XML-escaped string
220
+ */
221
+ function XMLEscape(str) {
222
+ const newStr = String(str);
223
+ if (/[&<>"']/.test(newStr)) return newStr.replace(/[&<>"']/g, replaceChar);
224
+ else return newStr;
225
+ }
226
+ /** Eta's base (global) configuration */
227
+ const defaultConfig = {
228
+ autoEscape: true,
229
+ autoFilter: false,
230
+ autoTrim: [false, "nl"],
231
+ cache: false,
232
+ cacheFilepaths: true,
233
+ debug: false,
234
+ escapeFunction: XMLEscape,
235
+ filterFunction: (val) => String(val),
236
+ functionHeader: "",
237
+ parse: {
238
+ exec: "",
239
+ interpolate: "=",
240
+ raw: "~"
241
+ },
242
+ plugins: [],
243
+ rmWhitespace: false,
244
+ tags: ["<%", "%>"],
245
+ useWith: false,
246
+ varName: "it",
247
+ defaultExtension: ".eta"
248
+ };
249
+ const templateLitReg = /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g;
250
+ const singleQuoteReg = /'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g;
251
+ const doubleQuoteReg = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;
252
+ /** Escape special regular expression characters inside a string */
253
+ function escapeRegExp(string) {
254
+ return string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
255
+ }
256
+ function getLineNo(str, index) {
257
+ return str.slice(0, index).split("\n").length;
258
+ }
259
+ function parse(str) {
260
+ const config = this.config;
261
+ let buffer = [];
262
+ let trimLeftOfNextStr = false;
263
+ let lastIndex = 0;
264
+ const parseOptions = config.parse;
265
+ if (config.plugins) for (let i = 0; i < config.plugins.length; i++) {
266
+ const plugin = config.plugins[i];
267
+ if (plugin.processTemplate) str = plugin.processTemplate(str, config);
268
+ }
269
+ if (config.rmWhitespace) str = str.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
270
+ templateLitReg.lastIndex = 0;
271
+ singleQuoteReg.lastIndex = 0;
272
+ doubleQuoteReg.lastIndex = 0;
273
+ function pushString(strng, shouldTrimRightOfString) {
274
+ if (strng) {
275
+ strng = trimWS(strng, config, trimLeftOfNextStr, shouldTrimRightOfString);
276
+ if (strng) {
277
+ strng = strng.replace(/\\|'/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n");
278
+ buffer.push(strng);
279
+ }
280
+ }
281
+ }
282
+ const prefixes = [
283
+ parseOptions.exec,
284
+ parseOptions.interpolate,
285
+ parseOptions.raw
286
+ ].reduce((accumulator, prefix) => {
287
+ if (accumulator && prefix) return accumulator + "|" + escapeRegExp(prefix);
288
+ else if (prefix) return escapeRegExp(prefix);
289
+ else return accumulator;
290
+ }, "");
291
+ const parseOpenReg = new RegExp(escapeRegExp(config.tags[0]) + "(-|_)?\\s*(" + prefixes + ")?\\s*", "g");
292
+ const parseCloseReg = new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?" + escapeRegExp(config.tags[1]) + ")", "g");
293
+ let m;
294
+ while (m = parseOpenReg.exec(str)) {
295
+ const precedingString = str.slice(lastIndex, m.index);
296
+ lastIndex = m[0].length + m.index;
297
+ const wsLeft = m[1];
298
+ const prefix = m[2] || "";
299
+ pushString(precedingString, wsLeft);
300
+ parseCloseReg.lastIndex = lastIndex;
301
+ let closeTag;
302
+ let currentObj = false;
303
+ while (closeTag = parseCloseReg.exec(str)) if (closeTag[1]) {
304
+ const content = str.slice(lastIndex, closeTag.index);
305
+ parseOpenReg.lastIndex = lastIndex = parseCloseReg.lastIndex;
306
+ trimLeftOfNextStr = closeTag[2];
307
+ currentObj = {
308
+ t: prefix === parseOptions.exec ? "e" : prefix === parseOptions.raw ? "r" : prefix === parseOptions.interpolate ? "i" : "",
309
+ val: content
310
+ };
311
+ break;
312
+ } else {
313
+ const char = closeTag[0];
314
+ if (char === "/*") {
315
+ const commentCloseInd = str.indexOf("*/", parseCloseReg.lastIndex);
316
+ if (commentCloseInd === -1) ParseErr("unclosed comment", str, closeTag.index);
317
+ parseCloseReg.lastIndex = commentCloseInd;
318
+ } else if (char === "'") {
319
+ singleQuoteReg.lastIndex = closeTag.index;
320
+ if (singleQuoteReg.exec(str)) parseCloseReg.lastIndex = singleQuoteReg.lastIndex;
321
+ else ParseErr("unclosed string", str, closeTag.index);
322
+ } else if (char === "\"") {
323
+ doubleQuoteReg.lastIndex = closeTag.index;
324
+ if (doubleQuoteReg.exec(str)) parseCloseReg.lastIndex = doubleQuoteReg.lastIndex;
325
+ else ParseErr("unclosed string", str, closeTag.index);
326
+ } else if (char === "`") {
327
+ templateLitReg.lastIndex = closeTag.index;
328
+ if (templateLitReg.exec(str)) parseCloseReg.lastIndex = templateLitReg.lastIndex;
329
+ else ParseErr("unclosed string", str, closeTag.index);
330
+ }
331
+ }
332
+ if (currentObj) {
333
+ if (config.debug) currentObj.lineNo = getLineNo(str, m.index);
334
+ buffer.push(currentObj);
335
+ } else ParseErr("unclosed tag", str, m.index);
336
+ }
337
+ pushString(str.slice(lastIndex, str.length), false);
338
+ if (config.plugins) for (let i = 0; i < config.plugins.length; i++) {
339
+ const plugin = config.plugins[i];
340
+ if (plugin.processAST) buffer = plugin.processAST(buffer, config);
341
+ }
342
+ return buffer;
343
+ }
344
+ function handleCache(template, options) {
345
+ const templateStore = options?.async ? this.templatesAsync : this.templatesSync;
346
+ if (this.resolvePath && this.readFile && !template.startsWith("@")) {
347
+ const templatePath = options.filepath;
348
+ const cachedTemplate = templateStore.get(templatePath);
349
+ if (this.config.cache && cachedTemplate) return cachedTemplate;
350
+ else {
351
+ const templateString = this.readFile(templatePath);
352
+ const templateFn = this.compile(templateString, options);
353
+ if (this.config.cache) templateStore.define(templatePath, templateFn);
354
+ return templateFn;
355
+ }
356
+ } else {
357
+ const cachedTemplate = templateStore.get(template);
358
+ if (cachedTemplate) return cachedTemplate;
359
+ else throw new EtaNameResolutionError(`Failed to get template '${template}'`);
360
+ }
361
+ }
362
+ function render(template, data, meta) {
363
+ let templateFn;
364
+ const options = {
365
+ ...meta,
366
+ async: false
367
+ };
368
+ if (typeof template === "string") {
369
+ if (this.resolvePath && this.readFile && !template.startsWith("@")) options.filepath = this.resolvePath(template, options);
370
+ templateFn = handleCache.call(this, template, options);
371
+ } else templateFn = template;
372
+ return templateFn.call(this, data, options);
373
+ }
374
+ function renderAsync(template, data, meta) {
375
+ let templateFn;
376
+ const options = {
377
+ ...meta,
378
+ async: true
379
+ };
380
+ if (typeof template === "string") {
381
+ if (this.resolvePath && this.readFile && !template.startsWith("@")) options.filepath = this.resolvePath(template, options);
382
+ templateFn = handleCache.call(this, template, options);
383
+ } else templateFn = template;
384
+ const res = templateFn.call(this, data, options);
385
+ return Promise.resolve(res);
386
+ }
387
+ function renderString(template, data) {
388
+ const templateFn = this.compile(template, { async: false });
389
+ return render.call(this, templateFn, data);
390
+ }
391
+ function renderStringAsync(template, data) {
392
+ const templateFn = this.compile(template, { async: true });
393
+ return renderAsync.call(this, templateFn, data);
394
+ }
395
+ /**
396
+ * Handles storage and accessing of values
397
+ *
398
+ * In this case, we use it to store compiled template functions
399
+ * Indexed by their `name` or `filename`
400
+ */
401
+ var Cacher = class {
402
+ constructor(cache) {
403
+ this.cache = cache;
404
+ }
405
+ define(key, val) {
406
+ this.cache[key] = val;
407
+ }
408
+ get(key) {
409
+ return this.cache[key];
410
+ }
411
+ remove(key) {
412
+ delete this.cache[key];
413
+ }
414
+ reset() {
415
+ this.cache = {};
416
+ }
417
+ load(cacheObj) {
418
+ this.cache = {
419
+ ...this.cache,
420
+ ...cacheObj
421
+ };
422
+ }
423
+ };
424
+ var Eta$1 = class {
425
+ constructor(customConfig) {
426
+ if (customConfig) this.config = {
427
+ ...defaultConfig,
428
+ ...customConfig
429
+ };
430
+ else this.config = { ...defaultConfig };
431
+ }
432
+ config;
433
+ RuntimeErr = RuntimeErr;
434
+ compile = compile;
435
+ compileToString = compileToString;
436
+ compileBody = compileBody;
437
+ parse = parse;
438
+ render = render;
439
+ renderAsync = renderAsync;
440
+ renderString = renderString;
441
+ renderStringAsync = renderStringAsync;
442
+ filepathCache = {};
443
+ templatesSync = new Cacher({});
444
+ templatesAsync = new Cacher({});
445
+ resolvePath = null;
446
+ readFile = null;
447
+ configure(customConfig) {
448
+ this.config = {
449
+ ...this.config,
450
+ ...customConfig
451
+ };
452
+ }
453
+ withConfig(customConfig) {
454
+ return {
455
+ ...this,
456
+ config: {
457
+ ...this.config,
458
+ ...customConfig
459
+ }
460
+ };
461
+ }
462
+ loadTemplate(name, template, options) {
463
+ if (typeof template === "string") (options?.async ? this.templatesAsync : this.templatesSync).define(name, this.compile(template, options));
464
+ else {
465
+ let templates = this.templatesSync;
466
+ if (template.constructor.name === "AsyncFunction" || options?.async) templates = this.templatesAsync;
467
+ templates.define(name, template);
468
+ }
469
+ }
470
+ };
471
+ var Eta = class extends Eta$1 {
472
+ readFile = readFile;
473
+ resolvePath = resolvePath;
474
+ };
475
+
476
+ //#endregion
477
+ export { Eta as t };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,13 @@
1
+ //#region src/workspace.d.ts
2
+ interface WorkspacePackage {
3
+ name: string;
4
+ version: string;
5
+ path: string;
6
+ packageJson: PackageJson;
7
+ workspaceDependencies: string[];
8
+ workspaceDevDependencies: string[];
9
+ }
10
+ //#endregion
1
11
  //#region src/types.d.ts
2
12
  type BumpKind = "none" | "patch" | "minor" | "major";
3
13
  interface PackageJson {
@@ -6,16 +16,9 @@ interface PackageJson {
6
16
  dependencies?: Record<string, string>;
7
17
  devDependencies?: Record<string, string>;
8
18
  peerDependencies?: Record<string, string>;
19
+ private?: boolean;
9
20
  [key: string]: unknown;
10
21
  }
11
- interface WorkspacePackage {
12
- name: string;
13
- version: string;
14
- path: string;
15
- packageJson: PackageJson;
16
- workspaceDependencies: string[];
17
- workspaceDevDependencies: string[];
18
- }
19
22
  interface FindWorkspacePackagesOptions {
20
23
  /**
21
24
  * Package names to exclude
@@ -100,8 +103,19 @@ interface ReleaseOptions {
100
103
  */
101
104
  githubToken: string;
102
105
  pullRequest?: {
103
- title: string;
104
- body: string;
106
+ /**
107
+ * Title for the release pull request
108
+ */
109
+ title?: string;
110
+ /**
111
+ * Body for the release pull request
112
+ *
113
+ * If not provided, a default body will be generated.
114
+ *
115
+ * NOTE:
116
+ * You can use custom template expressions, see [h3js/rendu](https://github.com/h3js/rendu)
117
+ */
118
+ body?: string;
105
119
  };
106
120
  }
107
121
  interface ReleaseResult {