@decaf-ts/utils 0.1.6

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 (112) hide show
  1. package/LICENSE.md +157 -0
  2. package/README.md +95 -0
  3. package/dist/esm/utils.js +1 -0
  4. package/dist/types/bin/tag-release.d.ts +1 -0
  5. package/dist/types/bin/update-scripts.d.ts +1 -0
  6. package/dist/types/cli/command.d.ts +110 -0
  7. package/dist/types/cli/commands/index.d.ts +2 -0
  8. package/dist/types/cli/commands/tag-release.d.ts +105 -0
  9. package/dist/types/cli/commands/update-scripts.d.ts +211 -0
  10. package/dist/types/cli/constants.d.ts +73 -0
  11. package/dist/types/cli/index.d.ts +4 -0
  12. package/dist/types/cli/types.d.ts +28 -0
  13. package/dist/types/index.d.ts +39 -0
  14. package/dist/types/input/index.d.ts +2 -0
  15. package/dist/types/input/input.d.ts +472 -0
  16. package/dist/types/input/types.d.ts +76 -0
  17. package/dist/types/output/common.d.ts +51 -0
  18. package/dist/types/output/index.d.ts +3 -0
  19. package/dist/types/output/logging.d.ts +177 -0
  20. package/dist/types/output/types.d.ts +203 -0
  21. package/dist/types/utils/accumulator.d.ts +105 -0
  22. package/dist/types/utils/constants.d.ts +136 -0
  23. package/dist/types/utils/environment.d.ts +57 -0
  24. package/dist/types/utils/fs.d.ts +133 -0
  25. package/dist/types/utils/http.d.ts +41 -0
  26. package/dist/types/utils/index.d.ts +7 -0
  27. package/dist/types/utils/md.d.ts +156 -0
  28. package/dist/types/utils/tests.d.ts +170 -0
  29. package/dist/types/utils/text.d.ts +106 -0
  30. package/dist/types/utils/timeout.d.ts +1 -0
  31. package/dist/types/utils/types.d.ts +81 -0
  32. package/dist/types/utils/utils.d.ts +91 -0
  33. package/dist/types/utils/web.d.ts +7 -0
  34. package/dist/types/writers/OutputWriter.d.ts +49 -0
  35. package/dist/types/writers/RegexpOutputWriter.d.ts +69 -0
  36. package/dist/types/writers/StandardOutputWriter.d.ts +91 -0
  37. package/dist/types/writers/index.d.ts +4 -0
  38. package/dist/types/writers/types.d.ts +29 -0
  39. package/dist/utils.js +1 -0
  40. package/lib/assets/slogans.json +802 -0
  41. package/lib/bin/tag-release.cjs +12 -0
  42. package/lib/bin/update-scripts.cjs +12 -0
  43. package/lib/cli/command.cjs +153 -0
  44. package/lib/cli/commands/index.cjs +20 -0
  45. package/lib/cli/commands/tag-release.cjs +168 -0
  46. package/lib/cli/commands/update-scripts.cjs +511 -0
  47. package/lib/cli/constants.cjs +80 -0
  48. package/lib/cli/index.cjs +22 -0
  49. package/lib/cli/types.cjs +4 -0
  50. package/lib/esm/assets/slogans.json +802 -0
  51. package/lib/esm/bin/tag-release.js +10 -0
  52. package/lib/esm/bin/update-scripts.js +10 -0
  53. package/lib/esm/cli/command.js +149 -0
  54. package/lib/esm/cli/commands/index.js +4 -0
  55. package/lib/esm/cli/commands/tag-release.js +164 -0
  56. package/lib/esm/cli/commands/update-scripts.js +504 -0
  57. package/lib/esm/cli/constants.js +77 -0
  58. package/lib/esm/cli/index.js +6 -0
  59. package/lib/esm/cli/types.js +3 -0
  60. package/lib/esm/index.js +41 -0
  61. package/lib/esm/input/index.js +4 -0
  62. package/lib/esm/input/input.js +570 -0
  63. package/lib/esm/input/types.js +3 -0
  64. package/lib/esm/output/common.js +93 -0
  65. package/lib/esm/output/index.js +5 -0
  66. package/lib/esm/output/logging.js +350 -0
  67. package/lib/esm/output/types.js +3 -0
  68. package/lib/esm/utils/accumulator.js +145 -0
  69. package/lib/esm/utils/constants.js +176 -0
  70. package/lib/esm/utils/environment.js +91 -0
  71. package/lib/esm/utils/fs.js +271 -0
  72. package/lib/esm/utils/http.js +70 -0
  73. package/lib/esm/utils/index.js +9 -0
  74. package/lib/esm/utils/md.js +3 -0
  75. package/lib/esm/utils/tests.js +223 -0
  76. package/lib/esm/utils/text.js +142 -0
  77. package/lib/esm/utils/timeout.js +5 -0
  78. package/lib/esm/utils/types.js +3 -0
  79. package/lib/esm/utils/utils.js +220 -0
  80. package/lib/esm/utils/web.js +12 -0
  81. package/lib/esm/writers/OutputWriter.js +3 -0
  82. package/lib/esm/writers/RegexpOutputWriter.js +98 -0
  83. package/lib/esm/writers/StandardOutputWriter.js +127 -0
  84. package/lib/esm/writers/index.js +6 -0
  85. package/lib/esm/writers/types.js +3 -0
  86. package/lib/index.cjs +58 -0
  87. package/lib/input/index.cjs +20 -0
  88. package/lib/input/input.cjs +577 -0
  89. package/lib/input/types.cjs +4 -0
  90. package/lib/output/common.cjs +100 -0
  91. package/lib/output/index.cjs +21 -0
  92. package/lib/output/logging.cjs +355 -0
  93. package/lib/output/types.cjs +4 -0
  94. package/lib/utils/accumulator.cjs +149 -0
  95. package/lib/utils/constants.cjs +179 -0
  96. package/lib/utils/environment.cjs +95 -0
  97. package/lib/utils/fs.cjs +288 -0
  98. package/lib/utils/http.cjs +77 -0
  99. package/lib/utils/index.cjs +25 -0
  100. package/lib/utils/md.cjs +4 -0
  101. package/lib/utils/tests.cjs +263 -0
  102. package/lib/utils/text.cjs +153 -0
  103. package/lib/utils/timeout.cjs +8 -0
  104. package/lib/utils/types.cjs +4 -0
  105. package/lib/utils/utils.cjs +226 -0
  106. package/lib/utils/web.cjs +15 -0
  107. package/lib/writers/OutputWriter.cjs +4 -0
  108. package/lib/writers/RegexpOutputWriter.cjs +102 -0
  109. package/lib/writers/StandardOutputWriter.cjs +131 -0
  110. package/lib/writers/index.cjs +22 -0
  111. package/lib/writers/types.cjs +4 -0
  112. package/package.json +121 -0
@@ -0,0 +1,211 @@
1
+ import { Command } from "../command";
2
+ import { CommandOptions } from "../types";
3
+ import { LoggingConfig } from "../../output";
4
+ import { DefaultCommandValues } from "../index";
5
+ declare const options: {
6
+ templates: string[];
7
+ workflows: string[];
8
+ ide: string[];
9
+ docs: string[];
10
+ styles: string[];
11
+ scripts: string[];
12
+ tests: string[];
13
+ typescript: string[];
14
+ docker: string[];
15
+ automation: string[];
16
+ };
17
+ declare const argzz: {
18
+ boot: {
19
+ type: string;
20
+ };
21
+ org: {
22
+ type: string;
23
+ short: string;
24
+ };
25
+ name: {
26
+ type: string;
27
+ short: string;
28
+ default: undefined;
29
+ };
30
+ author: {
31
+ type: string;
32
+ short: string;
33
+ default: undefined;
34
+ };
35
+ all: {
36
+ type: string;
37
+ };
38
+ license: {
39
+ type: string;
40
+ message: string;
41
+ };
42
+ scripts: {
43
+ type: string;
44
+ };
45
+ styles: {
46
+ type: string;
47
+ };
48
+ docs: {
49
+ type: string;
50
+ };
51
+ ide: {
52
+ type: string;
53
+ };
54
+ workflows: {
55
+ type: string;
56
+ };
57
+ templates: {
58
+ type: string;
59
+ };
60
+ typescript: {
61
+ type: string;
62
+ };
63
+ docker: {
64
+ type: string;
65
+ };
66
+ pkg: {
67
+ type: string;
68
+ };
69
+ dependencies: {
70
+ type: string;
71
+ };
72
+ tests: {
73
+ type: string;
74
+ };
75
+ automation: {
76
+ type: string;
77
+ };
78
+ };
79
+ /**
80
+ * @class TemplateSync
81
+ * @extends {Command}
82
+ * @category scripts
83
+ * @description A command-line tool for synchronizing project templates and configurations.
84
+ * @summary This class provides functionality to download and update various project files and configurations from a remote repository.
85
+ * It supports updating licenses, IDE configurations, scripts, styles, documentation, workflows, and templates.
86
+ *
87
+ * @param {CommandOptions} args - The command options for TemplateSync
88
+ */
89
+ export declare class TemplateSync extends Command<CommandOptions<typeof argzz>, void> {
90
+ private replacements;
91
+ constructor();
92
+ private loadValuesFromPackage;
93
+ /**
94
+ * @description Downloads files for a specific option category.
95
+ * @summary This method downloads all files associated with a given option key from the remote repository.
96
+ * @param {string} key - The key representing the option category to download
97
+ * @returns {Promise<void>}
98
+ * @throws {Error} If the specified option key is not found
99
+ */
100
+ downloadOption(key: keyof typeof options): Promise<void>;
101
+ /**
102
+ * @description Downloads and sets up the specified license.
103
+ * @summary This method downloads the chosen license file, saves it to the project, and updates the package.json license field.
104
+ * @param {"MIT" | "GPL" | "Apache" | "LGPL" | "AGPL"} license - The license to download and set up
105
+ * @returns {Promise<void>}
106
+ */
107
+ getLicense(license: "MIT" | "GPL" | "Apache" | "LGPL" | "AGPL"): Promise<void>;
108
+ /**
109
+ * @description Downloads IDE configuration files.
110
+ * @returns {Promise<void>}
111
+ */
112
+ getIde(): Promise<void>;
113
+ /**
114
+ * @description Update npm scripts
115
+ * @returns {Promise<void>}
116
+ */
117
+ getScripts(): Promise<void>;
118
+ /**
119
+ * @description Downloads style configuration files.
120
+ * @returns {Promise<void>}
121
+ */
122
+ getStyles: () => Promise<void>;
123
+ /**
124
+ * @description Downloads template files.
125
+ * @returns {Promise<void>}
126
+ */
127
+ getTemplates: () => Promise<void>;
128
+ /**
129
+ * @description Downloads workflow configuration files.
130
+ * @returns {Promise<void>}
131
+ */
132
+ getWorkflows: () => Promise<void>;
133
+ /**
134
+ * @description Downloads documentation files.
135
+ * @returns {Promise<void>}
136
+ */
137
+ getDocs: () => Promise<void>;
138
+ /**
139
+ * @description Downloads typescript config files.
140
+ * @returns {Promise<void>}
141
+ */
142
+ getTypescript: () => Promise<void>;
143
+ /**
144
+ * @description Downloads automation documentation files.
145
+ * @returns {Promise<void>}
146
+ */
147
+ getAutomation: () => Promise<void>;
148
+ /**
149
+ * @description Downloads automation documentation files.
150
+ * @returns {Promise<void>}
151
+ */
152
+ getTests: () => Promise<void>;
153
+ /**
154
+ * @description Downloads docker image files.
155
+ * @returns {Promise<void>}
156
+ */
157
+ getDocker: () => Promise<void>;
158
+ initPackage(pkgName: string, author: string, license: string): Promise<void>;
159
+ updatePackageScrips(): Promise<void>;
160
+ createTokenFiles(): Promise<void>;
161
+ getOrg(): Promise<string>;
162
+ auditFix(): Promise<string>;
163
+ patchFiles(): void;
164
+ updateDependencies(): Promise<void>;
165
+ /**
166
+ * @description Runs the template synchronization process.
167
+ * @summary This method orchestrates the downloading of various project components based on the provided arguments.
168
+ * @param {ParseArgsResult} args - The parsed command-line arguments
169
+ * @returns {Promise<void>}
170
+ *
171
+ * @mermaid
172
+ * sequenceDiagram
173
+ * participant T as TemplateSync
174
+ * participant L as getLicense
175
+ * participant I as getIde
176
+ * participant S as getScripts
177
+ * participant St as getStyles
178
+ * participant D as getDocs
179
+ * participant W as getWorkflows
180
+ * participant Te as getTemplates
181
+ * T->>T: Parse arguments
182
+ * alt all flag is true
183
+ * T->>T: Set all component flags to true
184
+ * end
185
+ * alt license is specified
186
+ * T->>L: getLicense(license)
187
+ * end
188
+ * alt ide flag is true
189
+ * T->>I: getIde()
190
+ * end
191
+ * alt scripts flag is true
192
+ * T->>S: getScripts()
193
+ * end
194
+ * alt styles flag is true
195
+ * T->>St: getStyles()
196
+ * end
197
+ * alt docs flag is true
198
+ * T->>D: getDocs()
199
+ * end
200
+ * alt workflows flag is true
201
+ * T->>W: getWorkflows()
202
+ * end
203
+ * alt templates flag is true
204
+ * T->>Te: getTemplates()
205
+ * end
206
+ */
207
+ run(args: LoggingConfig & typeof DefaultCommandValues & {
208
+ [k in keyof typeof argzz]: unknown;
209
+ }): Promise<void>;
210
+ }
211
+ export {};
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @description Default command options for CLI commands.
3
+ * @summary Defines the structure and default values for common command-line options used across various CLI commands.
4
+ * @const DefaultCommandOptions
5
+ * @typedef {Object} DefaultCommandOptions
6
+ * @property {Object} verbose - Verbosity level option.
7
+ * @property {string} verbose.type - The type of the verbose option (number).
8
+ * @property {string} verbose.short - The short flag for the verbose option (V).
9
+ * @property {number} verbose.default - The default value for verbosity (0).
10
+ * @property {Object} version - Version display option.
11
+ * @property {string} version.type - The type of the version option (boolean).
12
+ * @property {string} version.short - The short flag for the version option (v).
13
+ * @property {undefined} version.default - The default value for version display (undefined).
14
+ * @property {Object} help - Help display option.
15
+ * @property {string} help.type - The type of the help option (boolean).
16
+ * @property {string} help.short - The short flag for the help option (h).
17
+ * @property {boolean} help.default - The default value for help display (false).
18
+ * @property {Object} logLevel - Log level option.
19
+ * @property {string} logLevel.type - The type of the logLevel option (string).
20
+ * @property {string} logLevel.default - The default value for log level ("info").
21
+ * @property {Object} logStyle - Log styling option.
22
+ * @property {string} logStyle.type - The type of the logStyle option (boolean).
23
+ * @property {boolean} logStyle.default - The default value for log styling (true).
24
+ * @property {Object} timestamp - Timestamp display option.
25
+ * @property {string} timestamp.type - The type of the timestamp option (boolean).
26
+ * @property {boolean} timestamp.default - The default value for timestamp display (true).
27
+ * @property {Object} banner - Banner display option.
28
+ * @property {string} banner.type - The type of the banner option (boolean).
29
+ * @property {boolean} banner.default - The default value for banner display (false).
30
+ */
31
+ export declare const DefaultCommandOptions: {
32
+ verbose: {
33
+ type: string;
34
+ short: string;
35
+ default: undefined;
36
+ };
37
+ version: {
38
+ type: string;
39
+ short: string;
40
+ default: undefined;
41
+ };
42
+ help: {
43
+ type: string;
44
+ short: string;
45
+ default: boolean;
46
+ };
47
+ logLevel: {
48
+ type: string;
49
+ default: string;
50
+ };
51
+ logStyle: {
52
+ type: string;
53
+ default: boolean;
54
+ };
55
+ timestamp: {
56
+ type: string;
57
+ default: boolean;
58
+ };
59
+ banner: {
60
+ type: string;
61
+ default: boolean;
62
+ };
63
+ };
64
+ /**
65
+ * @description Default command values derived from DefaultCommandOptions.
66
+ * @summary Creates an object with the default values of all options defined in DefaultCommandOptions.
67
+ * @const DefaultCommandValues
68
+ * @typedef {Object} DefaultCommandValues
69
+ * @property {unknown} [key: string] - The default value for each option in DefaultCommandOptions.
70
+ */
71
+ export declare const DefaultCommandValues: {
72
+ [k in keyof typeof DefaultCommandOptions]: unknown;
73
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./commands";
2
+ export * from "./command";
3
+ export * from "./constants";
4
+ export * from "./types";
@@ -0,0 +1,28 @@
1
+ import { LoggingConfig } from "../output/types";
2
+ import { ParseArgsOptionConfig } from "../input/types";
3
+ /**
4
+ * @description Interface for input options.
5
+ * @summary Defines the structure of input options for CLI commands.
6
+ * @interface InputOptions
7
+ * @property {number} [verbose] - The verbosity level.
8
+ * @property {boolean} [version] - Flag to show version information.
9
+ * @property {boolean} [banner] - Flag to show banner.
10
+ * @property {boolean} [help] - Flag to show help information.
11
+ */
12
+ export type InputOptions = {
13
+ verbose?: number;
14
+ version?: boolean;
15
+ banner?: boolean;
16
+ help?: boolean;
17
+ };
18
+ /**
19
+ * @description Type definition for command options.
20
+ * @summary Combines input options, input option configurations, and logging configurations into a single type.
21
+ * @template I - The type of additional input options specific to the command.
22
+ * @typedef {Object} CommandOptions
23
+ */
24
+ export type CommandOptions<I> = I & Partial<{
25
+ [k in keyof InputOptions]: ParseArgsOptionConfig;
26
+ }> & Partial<{
27
+ [k in keyof LoggingConfig]: ParseArgsOptionConfig;
28
+ }>;
@@ -0,0 +1,39 @@
1
+ export * from "./cli";
2
+ export * from "./input";
3
+ export * from "./output";
4
+ export * from "./utils";
5
+ export * from "./writers";
6
+ /**
7
+ * @module @decaf-ts/utils
8
+ * @description
9
+ * This module serves a light version of Decaf CLI tool, providing a comprehensive set of utilities
10
+ * and functionalities for command-line interface operations. It encompasses several key components:
11
+ *
12
+ * 1. Input Handling: Manages user input and command-line arguments processing.
13
+ * 2. Utility Functions: Offers a collection of helper functions and constants for various operations.
14
+ * 3. Type Definitions: Defines custom types and interfaces used throughout the module.
15
+ * 4. Output Management: Provides different output writing strategies for flexible console output handling.
16
+ *
17
+ * The module is designed to facilitate the creation of robust CLI applications by offering:
18
+ * - Standardized input parsing and validation
19
+ * - Consistent output formatting and handling
20
+ * - Reusable utility functions for common CLI tasks
21
+ * - Extensible architecture for adding new commands and features
22
+ *
23
+ * It supports various output modes, including standard console output and regular expression-based output,
24
+ * allowing for versatile data presentation and processing. The modular structure enables easy maintenance
25
+ * and extension of the CLI functionality.
26
+ *
27
+ * This module is particularly useful for developers building complex command-line tools that require
28
+ * structured input handling, flexible output formatting, and a rich set of utility functions.
29
+ */
30
+ /**
31
+ * @description Represents the current version of the module.
32
+ * @summary This constant stores the version number of the @asdasdasd/utils module.
33
+ * The actual version number is replaced during the build process,
34
+ * with the placeholder "0.1.6" being substituted with the current version.
35
+ *
36
+ * @const VERSION
37
+ * @memberOf module:@decaf-ts/utils
38
+ */
39
+ export declare const VERSION = "0.1.6";
@@ -0,0 +1,2 @@
1
+ export * from './input';
2
+ export * from './types';