genomic 4.0.2 → 5.0.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.
Files changed (92) hide show
  1. package/README.md +154 -1125
  2. package/cache/cache-manager.d.ts +60 -0
  3. package/cache/cache-manager.js +228 -0
  4. package/cache/types.d.ts +22 -0
  5. package/esm/cache/cache-manager.js +191 -0
  6. package/esm/git/git-cloner.js +92 -0
  7. package/esm/index.js +41 -4
  8. package/esm/licenses.js +120 -0
  9. package/esm/scaffolder/index.js +2 -0
  10. package/esm/scaffolder/template-scaffolder.js +310 -0
  11. package/esm/scaffolder/types.js +1 -0
  12. package/esm/template/extract.js +162 -0
  13. package/esm/template/prompt.js +103 -0
  14. package/esm/template/replace.js +110 -0
  15. package/esm/template/templatizer.js +73 -0
  16. package/esm/template/types.js +1 -0
  17. package/esm/types.js +1 -0
  18. package/esm/utils/npm-version-check.js +52 -0
  19. package/esm/utils/types.js +1 -0
  20. package/git/git-cloner.d.ts +32 -0
  21. package/git/git-cloner.js +129 -0
  22. package/git/types.d.ts +15 -0
  23. package/index.d.ts +29 -4
  24. package/index.js +43 -4
  25. package/licenses-templates/APACHE-2.0.txt +18 -0
  26. package/licenses-templates/BSD-3-CLAUSE.txt +28 -0
  27. package/licenses-templates/CLOSED.txt +20 -0
  28. package/licenses-templates/GPL-3.0.txt +18 -0
  29. package/licenses-templates/ISC.txt +16 -0
  30. package/licenses-templates/MIT.txt +22 -0
  31. package/licenses-templates/MPL-2.0.txt +8 -0
  32. package/licenses-templates/UNLICENSE.txt +22 -0
  33. package/licenses.d.ts +18 -0
  34. package/licenses.js +162 -0
  35. package/package.json +9 -14
  36. package/scaffolder/index.d.ts +2 -0
  37. package/{question → scaffolder}/index.js +1 -0
  38. package/scaffolder/template-scaffolder.d.ts +91 -0
  39. package/scaffolder/template-scaffolder.js +347 -0
  40. package/scaffolder/types.d.ts +191 -0
  41. package/scaffolder/types.js +2 -0
  42. package/template/extract.d.ts +7 -0
  43. package/template/extract.js +198 -0
  44. package/template/prompt.d.ts +19 -0
  45. package/template/prompt.js +107 -0
  46. package/template/replace.d.ts +9 -0
  47. package/template/replace.js +146 -0
  48. package/template/templatizer.d.ts +33 -0
  49. package/template/templatizer.js +110 -0
  50. package/template/types.d.ts +18 -0
  51. package/template/types.js +2 -0
  52. package/types.d.ts +99 -0
  53. package/types.js +2 -0
  54. package/utils/npm-version-check.d.ts +17 -0
  55. package/utils/npm-version-check.js +57 -0
  56. package/utils/types.d.ts +6 -0
  57. package/utils/types.js +2 -0
  58. package/commander.d.ts +0 -21
  59. package/commander.js +0 -57
  60. package/esm/commander.js +0 -50
  61. package/esm/keypress.js +0 -95
  62. package/esm/prompt.js +0 -1024
  63. package/esm/question/index.js +0 -1
  64. package/esm/resolvers/date.js +0 -11
  65. package/esm/resolvers/git.js +0 -26
  66. package/esm/resolvers/index.js +0 -103
  67. package/esm/resolvers/npm.js +0 -24
  68. package/esm/resolvers/workspace.js +0 -141
  69. package/esm/utils.js +0 -12
  70. package/keypress.d.ts +0 -45
  71. package/keypress.js +0 -99
  72. package/prompt.d.ts +0 -116
  73. package/prompt.js +0 -1032
  74. package/question/index.d.ts +0 -1
  75. package/question/types.d.ts +0 -65
  76. package/resolvers/date.d.ts +0 -5
  77. package/resolvers/date.js +0 -14
  78. package/resolvers/git.d.ts +0 -11
  79. package/resolvers/git.js +0 -30
  80. package/resolvers/index.d.ts +0 -63
  81. package/resolvers/index.js +0 -111
  82. package/resolvers/npm.d.ts +0 -10
  83. package/resolvers/npm.js +0 -28
  84. package/resolvers/types.d.ts +0 -12
  85. package/resolvers/workspace.d.ts +0 -6
  86. package/resolvers/workspace.js +0 -144
  87. package/utils.d.ts +0 -2
  88. package/utils.js +0 -16
  89. /package/{question → cache}/types.js +0 -0
  90. /package/esm/{question → cache}/types.js +0 -0
  91. /package/esm/{resolvers → git}/types.js +0 -0
  92. /package/{resolvers → git}/types.js +0 -0
package/types.d.ts ADDED
@@ -0,0 +1,99 @@
1
+ import { Question } from 'inquirerer';
2
+ /**
3
+ * Questions configuration that can be loaded from .boilerplate.json or .boilerplate.js
4
+ * @typedef {Object} Questions
5
+ * @property {Question[]} questions - Array of genomic questions
6
+ */
7
+ export interface Questions {
8
+ questions: Question[];
9
+ }
10
+ /**
11
+ * Variable extracted from filename patterns like ____variable____
12
+ */
13
+ export interface FileReplacer {
14
+ variable: string;
15
+ pattern: RegExp;
16
+ }
17
+ /**
18
+ * Variable extracted from file content patterns like ____variable____
19
+ */
20
+ export interface ContentReplacer {
21
+ variable: string;
22
+ pattern: RegExp;
23
+ }
24
+ /**
25
+ * Options for creating a new project from a template
26
+ */
27
+ export interface CreateGenOptions {
28
+ /**
29
+ * URL or path to the template repository
30
+ */
31
+ templateUrl: string;
32
+ /**
33
+ * Optional branch or tag to checkout after cloning
34
+ */
35
+ fromBranch?: string;
36
+ /**
37
+ * Path inside the repository to use as the template root
38
+ */
39
+ fromPath?: string;
40
+ /**
41
+ * Destination directory for the generated project
42
+ */
43
+ outputDir: string;
44
+ /**
45
+ * Command-line arguments to pre-populate answers
46
+ */
47
+ argv?: Record<string, any>;
48
+ /**
49
+ * Whether to use TTY for interactive prompts
50
+ */
51
+ noTty?: boolean;
52
+ /**
53
+ * Optional caching configuration. Pass `false` to disable caching entirely.
54
+ */
55
+ cache?: CacheOptions | false;
56
+ }
57
+ /**
58
+ * Options that control template caching behavior
59
+ */
60
+ export interface CacheOptions {
61
+ /**
62
+ * Enable or disable caching. Defaults to true.
63
+ */
64
+ enabled?: boolean;
65
+ /**
66
+ * Tool name used for appstash (affects ~/.<tool> dirs). Defaults to `pgpm`.
67
+ */
68
+ toolName?: string;
69
+ /**
70
+ * Optional base directory for appstash. Useful for tests to avoid touching the real home dir.
71
+ */
72
+ baseDir?: string;
73
+ /**
74
+ * Time-to-live in milliseconds. If set, cached templates older than this will be invalidated.
75
+ * Defaults to undefined (no expiration).
76
+ */
77
+ ttl?: number;
78
+ /**
79
+ * Alias for ttl. Maximum age in milliseconds for cached templates.
80
+ * Defaults to undefined (no expiration).
81
+ */
82
+ maxAge?: number;
83
+ }
84
+ /**
85
+ * Result of extracting variables from a template
86
+ */
87
+ export interface ExtractedVariables {
88
+ fileReplacers: FileReplacer[];
89
+ contentReplacers: ContentReplacer[];
90
+ projectQuestions: Questions | null;
91
+ }
92
+ /**
93
+ * Context for processing a template
94
+ */
95
+ export interface TemplateContext {
96
+ tempDir: string;
97
+ extractedVariables: ExtractedVariables;
98
+ answers: Record<string, any>;
99
+ }
package/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ import { VersionCheckResult } from './types';
2
+ /**
3
+ * Check if current package version is outdated compared to npm registry
4
+ * @param packageName - Package name to check
5
+ * @param currentVersion - Current version string
6
+ * @returns Version comparison result
7
+ */
8
+ export declare function checkNpmVersion(packageName: string, currentVersion: string): Promise<VersionCheckResult>;
9
+ /**
10
+ * Compare two semver version strings
11
+ * Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
12
+ */
13
+ export declare function compareVersions(v1: string, v2: string): number;
14
+ /**
15
+ * Print version warning to console if outdated
16
+ */
17
+ export declare function warnIfOutdated(packageName: string, result: VersionCheckResult): void;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkNpmVersion = checkNpmVersion;
4
+ exports.compareVersions = compareVersions;
5
+ exports.warnIfOutdated = warnIfOutdated;
6
+ const child_process_1 = require("child_process");
7
+ /**
8
+ * Check if current package version is outdated compared to npm registry
9
+ * @param packageName - Package name to check
10
+ * @param currentVersion - Current version string
11
+ * @returns Version comparison result
12
+ */
13
+ async function checkNpmVersion(packageName, currentVersion) {
14
+ try {
15
+ const latestVersion = (0, child_process_1.execSync)(`npm view ${packageName} version`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
16
+ const isOutdated = compareVersions(currentVersion, latestVersion) < 0;
17
+ return {
18
+ currentVersion,
19
+ latestVersion,
20
+ isOutdated,
21
+ };
22
+ }
23
+ catch (error) {
24
+ return {
25
+ currentVersion,
26
+ latestVersion: null,
27
+ isOutdated: false,
28
+ error: error instanceof Error ? error.message : String(error),
29
+ };
30
+ }
31
+ }
32
+ /**
33
+ * Compare two semver version strings
34
+ * Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
35
+ */
36
+ function compareVersions(v1, v2) {
37
+ const parts1 = v1.split('.').map(Number);
38
+ const parts2 = v2.split('.').map(Number);
39
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
40
+ const p1 = parts1[i] || 0;
41
+ const p2 = parts2[i] || 0;
42
+ if (p1 < p2)
43
+ return -1;
44
+ if (p1 > p2)
45
+ return 1;
46
+ }
47
+ return 0;
48
+ }
49
+ /**
50
+ * Print version warning to console if outdated
51
+ */
52
+ function warnIfOutdated(packageName, result) {
53
+ if (result.isOutdated && result.latestVersion) {
54
+ console.warn(`\n⚠️ New version available: ${result.currentVersion} → ${result.latestVersion}`);
55
+ console.warn(` Run: npm install -g ${packageName}@latest\n`);
56
+ }
57
+ }
@@ -0,0 +1,6 @@
1
+ export interface VersionCheckResult {
2
+ currentVersion: string;
3
+ latestVersion: string | null;
4
+ isOutdated: boolean;
5
+ error?: string;
6
+ }
package/utils/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/commander.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import { Opts, ParsedArgs } from 'minimist';
2
- import { Readable, Writable } from 'stream';
3
- import { Prompter } from './prompt';
4
- export type CommandHandler = (argv: ParsedArgs, prompter: Prompter, options: CLIOptions) => void;
5
- export interface CLIOptions {
6
- noTty: boolean;
7
- input: Readable;
8
- output: Writable;
9
- minimistOpts: Opts;
10
- version: string;
11
- }
12
- export declare const defaultCLIOptions: CLIOptions;
13
- export declare class CLI {
14
- private argv;
15
- private prompter;
16
- private commandHandler;
17
- private options;
18
- constructor(commandHandler: CommandHandler, options: Partial<CLIOptions>, argv?: any);
19
- run(): Promise<void>;
20
- }
21
- export default CLI;
package/commander.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CLI = exports.defaultCLIOptions = void 0;
7
- const deepmerge_1 = __importDefault(require("deepmerge"));
8
- const minimist_1 = __importDefault(require("minimist"));
9
- const prompt_1 = require("./prompt");
10
- const utils_1 = require("./utils");
11
- exports.defaultCLIOptions = {
12
- version: `genomic@${(0, utils_1.getVersion)()}`,
13
- noTty: false,
14
- input: process.stdin,
15
- output: process.stdout,
16
- minimistOpts: {
17
- alias: {
18
- v: 'version'
19
- }
20
- }
21
- };
22
- class CLI {
23
- argv;
24
- prompter;
25
- commandHandler;
26
- options;
27
- constructor(commandHandler, options, argv) {
28
- const { input, output, ...optionsWithoutIO } = options;
29
- const { input: defaultInput, output: defaultOutput, ...defaultOptionsWithoutIO } = exports.defaultCLIOptions;
30
- const mergedOptions = (0, deepmerge_1.default)(defaultOptionsWithoutIO, optionsWithoutIO);
31
- mergedOptions.input = input || defaultInput;
32
- mergedOptions.output = output || defaultOutput;
33
- this.options = mergedOptions;
34
- this.argv = argv ? argv : (0, minimist_1.default)(process.argv.slice(2), this.options.minimistOpts);
35
- this.prompter = new prompt_1.Prompter({
36
- noTty: this.options.noTty,
37
- input: this.options.input,
38
- output: this.options.output
39
- });
40
- this.commandHandler = commandHandler;
41
- }
42
- async run() {
43
- if (!('tty' in this.argv)) {
44
- this.argv.tty = true;
45
- }
46
- if (this.argv.version) {
47
- console.log(this.options.version);
48
- process.exit(0);
49
- }
50
- const args = await this.commandHandler(this.argv, this.prompter, this.options);
51
- // this.prompter.exit();
52
- this.prompter.close();
53
- return args;
54
- }
55
- }
56
- exports.CLI = CLI;
57
- exports.default = CLI;
package/esm/commander.js DELETED
@@ -1,50 +0,0 @@
1
- import deepmerge from 'deepmerge';
2
- import minimist from 'minimist';
3
- import { Prompter } from './prompt';
4
- import { getVersion } from './utils';
5
- export const defaultCLIOptions = {
6
- version: `genomic@${getVersion()}`,
7
- noTty: false,
8
- input: process.stdin,
9
- output: process.stdout,
10
- minimistOpts: {
11
- alias: {
12
- v: 'version'
13
- }
14
- }
15
- };
16
- export class CLI {
17
- argv;
18
- prompter;
19
- commandHandler;
20
- options;
21
- constructor(commandHandler, options, argv) {
22
- const { input, output, ...optionsWithoutIO } = options;
23
- const { input: defaultInput, output: defaultOutput, ...defaultOptionsWithoutIO } = defaultCLIOptions;
24
- const mergedOptions = deepmerge(defaultOptionsWithoutIO, optionsWithoutIO);
25
- mergedOptions.input = input || defaultInput;
26
- mergedOptions.output = output || defaultOutput;
27
- this.options = mergedOptions;
28
- this.argv = argv ? argv : minimist(process.argv.slice(2), this.options.minimistOpts);
29
- this.prompter = new Prompter({
30
- noTty: this.options.noTty,
31
- input: this.options.input,
32
- output: this.options.output
33
- });
34
- this.commandHandler = commandHandler;
35
- }
36
- async run() {
37
- if (!('tty' in this.argv)) {
38
- this.argv.tty = true;
39
- }
40
- if (this.argv.version) {
41
- console.log(this.options.version);
42
- process.exit(0);
43
- }
44
- const args = await this.commandHandler(this.argv, this.prompter, this.options);
45
- // this.prompter.exit();
46
- this.prompter.close();
47
- return args;
48
- }
49
- }
50
- export default CLI;
package/esm/keypress.js DELETED
@@ -1,95 +0,0 @@
1
- const defaultProcessWrapper = {
2
- exit: (code) => process.exit(code)
3
- };
4
- export const KEY_CODES = {
5
- UP_ARROW: '\u001b[A',
6
- DOWN_ARROW: '\u001b[B',
7
- RIGHT_ARROW: '\u001b[C',
8
- LEFT_ARROW: '\u001b[D',
9
- ENTER: '\r',
10
- SPACE: ' ',
11
- CTRL_C: '\u0003',
12
- BACKSPACE: '\x7f', // Commonly used BACKSPACE key in Unix-like systems
13
- BACKSPACE_LEGACY: '\x08' // For compatibility with some systems
14
- };
15
- /**
16
- * Handles keyboard input for interactive prompts.
17
- *
18
- * **Important**: Only one TerminalKeypress instance should be actively listening
19
- * on a given input stream at a time. If you need multiple Prompter instances,
20
- * call `close()` on the first instance before using the second, or reuse a single
21
- * instance for all prompts.
22
- *
23
- * Multiple instances sharing the same input stream (e.g., process.stdin) will
24
- * each receive all keypresses, which can cause duplicate or unexpected behavior.
25
- */
26
- export class TerminalKeypress {
27
- listeners = {};
28
- active = true;
29
- noTty;
30
- input;
31
- proc;
32
- dataHandler = null;
33
- constructor(noTty = false, input = process.stdin, proc = defaultProcessWrapper) {
34
- this.noTty = noTty;
35
- this.input = input;
36
- this.proc = proc;
37
- if (this.isTTY()) {
38
- this.input.resume();
39
- this.input.setEncoding('utf8');
40
- }
41
- this.setupListeners();
42
- }
43
- isTTY() {
44
- return !this.noTty;
45
- }
46
- setupListeners() {
47
- this.dataHandler = (key) => {
48
- if (!this.active)
49
- return;
50
- const handlers = this.listeners[key];
51
- handlers?.forEach(handler => handler());
52
- if (key === KEY_CODES.CTRL_C) {
53
- this.proc.exit(0);
54
- }
55
- };
56
- this.input.on('data', this.dataHandler);
57
- }
58
- on(key, callback) {
59
- if (!this.listeners[key]) {
60
- this.listeners[key] = [];
61
- }
62
- this.listeners[key].push(callback);
63
- }
64
- off(key, callback) {
65
- if (this.listeners[key]) {
66
- const index = this.listeners[key].indexOf(callback);
67
- if (index !== -1) {
68
- this.listeners[key].splice(index, 1);
69
- }
70
- }
71
- }
72
- clearHandlers() {
73
- this.listeners = {};
74
- }
75
- pause() {
76
- this.active = false;
77
- this.clearHandlers();
78
- }
79
- resume() {
80
- this.active = true;
81
- if (this.isTTY() && typeof this.input.setRawMode === 'function') {
82
- this.input.setRawMode(true);
83
- }
84
- }
85
- destroy() {
86
- if (typeof this.input.setRawMode === 'function') {
87
- this.input.setRawMode(false);
88
- }
89
- this.input.pause();
90
- if (this.dataHandler) {
91
- this.input.removeListener('data', this.dataHandler);
92
- this.dataHandler = null;
93
- }
94
- }
95
- }