@biorate/hygen 0.3.0 → 0.5.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 (90) hide show
  1. package/README.md +14 -14
  2. package/dist/cjs/src/config-resolver.js +4 -11
  3. package/dist/cjs/src/constants/config.js +5 -0
  4. package/dist/cjs/src/constants/engine.js +4 -0
  5. package/dist/cjs/src/constants/hooks.js +18 -0
  6. package/dist/cjs/src/constants/index.js +19 -0
  7. package/dist/cjs/src/engine.js +14 -14
  8. package/dist/cjs/src/errors.js +19 -1
  9. package/dist/cjs/src/help.js +3 -3
  10. package/dist/cjs/src/params-schema/index.js +11 -0
  11. package/dist/cjs/src/params-schema/prompts.js +34 -0
  12. package/dist/cjs/src/params-schema/registry.js +92 -0
  13. package/dist/cjs/src/params.js +21 -5
  14. package/dist/cjs/src/picker.js +55 -0
  15. package/dist/cjs/src/prompt.js +39 -69
  16. package/dist/cjs/src/ts-node-register.js +36 -0
  17. package/dist/cjs/src/types/config.js +2 -0
  18. package/dist/cjs/src/types/helpers-ns.js +2 -0
  19. package/dist/cjs/src/types/hooks.js +2 -0
  20. package/dist/cjs/src/types/index.js +28 -0
  21. package/dist/cjs/src/types/inflection.js +2 -0
  22. package/dist/cjs/src/types/logger.js +2 -0
  23. package/dist/cjs/src/types/ops.js +2 -0
  24. package/dist/cjs/src/types/params-schema.js +2 -0
  25. package/dist/cjs/src/types/params.js +2 -0
  26. package/dist/cjs/src/types/prompter-ns.js +2 -0
  27. package/dist/cjs/src/types/prompter.js +2 -0
  28. package/dist/cjs/src/types/results.js +2 -0
  29. package/dist/esm/src/config-resolver.js +3 -9
  30. package/dist/esm/src/constants/config.js +2 -0
  31. package/dist/esm/src/constants/engine.js +1 -0
  32. package/dist/esm/src/constants/hooks.js +15 -0
  33. package/dist/esm/src/constants/index.js +3 -0
  34. package/dist/esm/src/engine.js +10 -10
  35. package/dist/esm/src/errors.js +15 -0
  36. package/dist/esm/src/help.js +1 -1
  37. package/dist/esm/src/params-schema/index.js +2 -0
  38. package/dist/esm/src/params-schema/prompts.js +30 -0
  39. package/dist/esm/src/params-schema/registry.js +84 -0
  40. package/dist/esm/src/params.js +19 -2
  41. package/dist/esm/src/picker.js +48 -0
  42. package/dist/esm/src/prompt.js +34 -64
  43. package/dist/esm/src/ts-node-register.js +11 -0
  44. package/dist/esm/src/types/config.js +1 -0
  45. package/dist/esm/src/types/helpers-ns.js +1 -0
  46. package/dist/esm/src/types/hooks.js +1 -0
  47. package/dist/esm/src/types/index.js +12 -0
  48. package/dist/esm/src/types/inflection.js +1 -0
  49. package/dist/esm/src/types/logger.js +1 -0
  50. package/dist/esm/src/types/ops.js +1 -0
  51. package/dist/esm/src/types/params-schema.js +1 -0
  52. package/dist/esm/src/types/params.js +1 -0
  53. package/dist/esm/src/types/prompter-ns.js +1 -0
  54. package/dist/esm/src/types/prompter.js +1 -0
  55. package/dist/esm/src/types/results.js +1 -0
  56. package/dist/types/src/config-resolver.d.ts +0 -1
  57. package/dist/types/src/constants/config.d.ts +2 -0
  58. package/dist/types/src/constants/engine.d.ts +1 -0
  59. package/dist/types/src/constants/hooks.d.ts +4 -0
  60. package/dist/types/src/constants/index.d.ts +3 -0
  61. package/dist/types/src/context.d.ts +1 -1
  62. package/dist/types/src/errors.d.ts +9 -0
  63. package/dist/types/src/helpers.d.ts +1 -13
  64. package/dist/types/src/index.d.ts +1 -0
  65. package/dist/types/src/ops/anchors.d.ts +0 -3
  66. package/dist/types/src/ops/index.d.ts +1 -2
  67. package/dist/types/src/params-schema/index.d.ts +2 -0
  68. package/dist/types/src/params-schema/prompts.d.ts +2 -0
  69. package/dist/types/src/params-schema/registry.d.ts +6 -0
  70. package/dist/types/src/params.d.ts +1 -2
  71. package/dist/types/src/picker.d.ts +2 -0
  72. package/dist/types/src/prompt.d.ts +4 -18
  73. package/dist/types/src/ts-node-register.d.ts +2 -0
  74. package/dist/types/src/types/attributes.d.ts +18 -0
  75. package/dist/types/src/types/config.d.ts +26 -0
  76. package/dist/types/src/types/helpers-ns.d.ts +4 -0
  77. package/dist/types/src/types/hooks.d.ts +39 -0
  78. package/dist/types/src/types/index.d.ts +12 -0
  79. package/dist/types/src/types/inflection.d.ts +12 -0
  80. package/dist/types/src/types/logger.d.ts +8 -0
  81. package/dist/types/src/types/ops.d.ts +7 -0
  82. package/dist/types/src/types/params-schema.d.ts +9 -0
  83. package/dist/types/src/types/params.d.ts +14 -0
  84. package/dist/types/src/types/prompter-ns.d.ts +4 -0
  85. package/dist/types/src/types/prompter.d.ts +3 -0
  86. package/dist/types/src/types/results.d.ts +27 -0
  87. package/package.json +2 -2
  88. package/dist/types/src/types.d.ts +0 -121
  89. /package/dist/cjs/src/{types.js → types/attributes.js} +0 -0
  90. /package/dist/esm/src/{types.js → types/attributes.js} +0 -0
@@ -1,27 +1,32 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
3
  import helpers from './helpers.js';
4
- import { pickableGenerators, generatorActions } from './help.js';
5
4
  import { HookModuleError, HookTsNodeError } from './errors.js';
6
- export const ACTION_HOOK_FILES = ['hooks.ts', 'hooks.js', 'hooks.mjs', 'hooks.cjs'];
7
- export const LEGACY_HOOK_FILES = [
8
- 'index.js',
9
- 'index.ts',
10
- 'prompt.cjs',
11
- 'prompt.js',
12
- 'prompt.ts',
13
- ];
14
- export const HOOK_FILES = [...ACTION_HOOK_FILES, ...LEGACY_HOOK_FILES];
15
- const LIFECYCLE_METHODS = ['beforeAll', 'beforeEach', 'afterEach', 'afterAll'];
16
- const loadHookModule = async (file) => {
17
- if (/\.ts$/.test(file)) {
18
- try {
19
- await import('ts-node/register/transpile-only');
5
+ import registerTsNode from './ts-node-register.js';
6
+ import { promptFromParams } from './params-schema/index.js';
7
+ import { ParamUnknownTypeError } from './errors.js';
8
+ export const validateParamsSchema = (schema) => {
9
+ if (!schema)
10
+ return undefined;
11
+ if (!Array.isArray(schema)) {
12
+ throw new Error('the params export must be an array of parameter descriptors');
13
+ }
14
+ for (const descriptor of schema) {
15
+ if (typeof descriptor?.name !== 'string' || descriptor.name === '') {
16
+ throw new Error('every parameter descriptor must declare a non-empty string name');
20
17
  }
21
- catch (cause) {
22
- throw new HookTsNodeError(file, cause);
18
+ const { type } = descriptor;
19
+ if (typeof type === 'function')
20
+ continue;
21
+ if (type !== 'string' && type !== 'number' && type !== 'boolean') {
22
+ throw new ParamUnknownTypeError(descriptor.name, String(type));
23
23
  }
24
24
  }
25
+ return schema;
26
+ };
27
+ import { ACTION_HOOK_FILES, HOOK_FILES, LIFECYCLE_METHODS } from './constants/index.js';
28
+ const loadHookModule = async (file) => {
29
+ await registerTsNode(file, HookTsNodeError);
25
30
  return (await import(file));
26
31
  };
27
32
  const legacyAdapter = (raw) => ({
@@ -57,6 +62,7 @@ const loadResolvedHooks = async (actionfolder) => {
57
62
  instance: new exported(),
58
63
  kind: 'class',
59
64
  file,
65
+ params: validateParamsSchema(module.params),
60
66
  };
61
67
  }
62
68
  catch (cause) {
@@ -97,59 +103,23 @@ const prompt = async (createPrompter, actionfolder, args, options = {}) => {
97
103
  if (resolved.kind === 'legacy' && legacy?.params) {
98
104
  return legacy.params({ args, h: helpers });
99
105
  }
106
+ if (resolved.kind === 'class' && resolved.params?.length) {
107
+ return promptFromParams(resolved.params, createPrompter, args);
108
+ }
100
109
  if (!resolved.instance.prompt)
101
110
  return {};
102
111
  const prompter = createPrompter();
112
+ const lazyHelpers = options.h;
103
113
  return resolved.instance.prompt({
104
114
  prompter,
105
115
  args,
106
- h: resolved.kind === 'class' ? options.h ?? helpers : helpers,
107
- });
108
- };
109
- const answerValue = (answer, name) => {
110
- const value = answer[name];
111
- return typeof value === 'string' && value.length > 0 ? value : undefined;
112
- };
113
- export const pickGeneratorAction = async (config) => {
114
- const { templates, logger } = config;
115
- if (!templates || !fs.existsSync(templates)) {
116
- logger.log(`No generators found.
117
-
118
- The interactive picker needs a _templates folder here, or anywhere up the folder tree.
119
- Create one with: $ hygen init self
120
- `);
121
- return null;
122
- }
123
- const generators = pickableGenerators(templates);
124
- if (generators.length === 0) {
125
- logger.log(`No generators found.
126
-
127
- Every top-level folder in _templates should hold at least one action subfolder.
128
- Create one with: $ hygen with-prompt new my-generator
129
- `);
130
- return null;
131
- }
132
- const prompter = config.createPrompter();
133
- const generatorAnswer = await prompter.prompt({
134
- type: 'select',
135
- name: 'generator',
136
- message: 'Select a generator:',
137
- choices: generators,
138
- });
139
- const generator = answerValue(generatorAnswer, 'generator');
140
- if (!generator)
141
- return null;
142
- const actions = generatorActions(templates, generator);
143
- const actionPrompter = config.createPrompter();
144
- const actionAnswer = await actionPrompter.prompt({
145
- type: 'select',
146
- name: 'action',
147
- message: `Select an action for ${generator}:`,
148
- choices: actions,
116
+ get h() {
117
+ if (resolved.kind !== 'class')
118
+ return helpers;
119
+ if (typeof lazyHelpers === 'function')
120
+ return lazyHelpers();
121
+ return lazyHelpers ?? helpers;
122
+ },
149
123
  });
150
- const action = answerValue(actionAnswer, 'action');
151
- if (!action)
152
- return null;
153
- return { generator, action };
154
124
  };
155
125
  export default prompt;
@@ -0,0 +1,11 @@
1
+ const registerTsNode = async (file, error) => {
2
+ if (!/\.ts$/.test(file))
3
+ return;
4
+ try {
5
+ await import('ts-node/register/transpile-only');
6
+ }
7
+ catch (cause) {
8
+ throw new error(file, cause);
9
+ }
10
+ };
11
+ export default registerTsNode;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ export * from './logger.js';
2
+ export * from './prompter.js';
3
+ export * from './prompter-ns.js';
4
+ export * from './attributes.js';
5
+ export * from './helpers-ns.js';
6
+ export * from './hooks.js';
7
+ export * from './config.js';
8
+ export * from './results.js';
9
+ export * from './params.js';
10
+ export * from './params-schema.js';
11
+ export * from './ops.js';
12
+ export * from './inflection.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,3 @@
1
1
  import type { RunnerConfig } from './types';
2
- export declare const CONFIG_FILES: string[];
3
2
  declare const _default: (config: RunnerConfig) => Promise<RunnerConfig>;
4
3
  export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const CONFIG_FILES: string[];
2
+ export declare const DEFAULT_ACTION = "_default";
@@ -0,0 +1 @@
1
+ export declare const RUN_SCOPE = "*";
@@ -0,0 +1,4 @@
1
+ export declare const ACTION_HOOK_FILES: string[];
2
+ export declare const LEGACY_HOOK_FILES: string[];
3
+ export declare const HOOK_FILES: string[];
4
+ export declare const LIFECYCLE_METHODS: readonly ["beforeAll", "beforeEach", "afterEach", "afterAll"];
@@ -0,0 +1,3 @@
1
+ export * from './hooks';
2
+ export * from './config';
3
+ export * from './engine';
@@ -4,7 +4,7 @@ declare const context: (locals: Record<string, any>, config?: Partial<RunnerConf
4
4
  } & Record<string, any> & {
5
5
  h: {
6
6
  capitalize(str: string): string;
7
- inflection: import("./helpers").Inflection;
7
+ inflection: import("./types").Inflection;
8
8
  changeCase: typeof import("change-case");
9
9
  path: import("path").PlatformPath;
10
10
  };
@@ -54,3 +54,12 @@ export declare class CliArgumentError extends BaseError {
54
54
  export declare class NameFlagRemovedError extends BaseError {
55
55
  constructor(name: unknown);
56
56
  }
57
+ export declare class ParamCoercionError extends BaseError {
58
+ constructor(name: string, type: string, raw: unknown);
59
+ }
60
+ export declare class ParamRequiredError extends BaseError {
61
+ constructor(name: string);
62
+ }
63
+ export declare class ParamUnknownTypeError extends BaseError {
64
+ constructor(name: string, type: string);
65
+ }
@@ -1,18 +1,6 @@
1
1
  import path from 'path';
2
2
  import changeCase from 'change-case';
3
- interface Inflection {
4
- pluralize(str: string, plural?: string): string;
5
- singularize(str: string, singular?: string): string;
6
- inflect(str: string, count: number, singular?: string, plural?: string): string;
7
- camelize(str: string, low_first_letter?: boolean): string;
8
- underscore(str: string, all_upper_case?: boolean): string;
9
- humanize(str: string, low_first_letter?: boolean): string;
10
- capitalize(str: string): string;
11
- dasherize(str: string): string;
12
- titleize(str: string): string;
13
- undasherize(str: string): string;
14
- }
15
- export { Inflection };
3
+ import type { Inflection } from './types';
16
4
  declare const helpers: {
17
5
  capitalize(str: string): string;
18
6
  inflection: Inflection;
@@ -4,3 +4,4 @@ export { default as resolve } from './config-resolver';
4
4
  export { printHelp, availableActions, VERSION } from './help';
5
5
  export { default as Logger } from './logger';
6
6
  export * as errors from './errors';
7
+ export type { ParamDescriptor, ParamType, ParamsSchema } from './types';
@@ -1,4 +1 @@
1
- export interface AnchorLocator {
2
- locate: (lines: string[]) => number;
3
- }
4
1
  export declare const indexByLocation: (attributes: Record<string, unknown>, lines: string[], to: string) => number;
@@ -1,4 +1,3 @@
1
- import type { ActionResult, RenderedAction, RunnerConfig } from '../types';
2
- export type Op = (action: RenderedAction, args: Record<string, unknown>, config: RunnerConfig) => Promise<ActionResult>;
1
+ import type { Op } from '../types';
3
2
  declare const resolve: (attributes: Record<string, unknown>) => Promise<Op[]>;
4
3
  export default resolve;
@@ -0,0 +1,2 @@
1
+ export { coerceParam, checkParam, promptTypeOf, resolveType, validateParams, } from './registry';
2
+ export { promptFromParams } from './prompts';
@@ -0,0 +1,2 @@
1
+ import type { ParamsSchema, Prompter } from '../types';
2
+ export declare const promptFromParams: <Q, T>(schema: ParamsSchema, createPrompter: () => Prompter<Q, T>, args: Record<string, any>) => Promise<Record<string, unknown>>;
@@ -0,0 +1,6 @@
1
+ import type { ParamDescriptor } from '../types';
2
+ export declare const resolveType: (descriptor: ParamDescriptor) => ((raw: unknown) => unknown);
3
+ export declare const promptTypeOf: (descriptor: ParamDescriptor) => string;
4
+ export declare const coerceParam: (descriptor: ParamDescriptor, raw: unknown) => unknown;
5
+ export declare const checkParam: (descriptor: ParamDescriptor, value: unknown) => boolean;
6
+ export declare const validateParams: (schema: ParamDescriptor[], values: Record<string, unknown>) => Record<string, unknown>;
@@ -1,4 +1,3 @@
1
1
  import type { ParamsResult, RunnerConfig } from './types';
2
- export declare const DEFAULT_ACTION = "_default";
3
- declare const params: ({ templates, legacyNameFlag }: RunnerConfig, externalArgv: string[]) => Promise<ParamsResult>;
2
+ declare const params: ({ templates, legacyNameFlag, argCase: argCaseOption }: RunnerConfig, externalArgv: string[]) => Promise<ParamsResult>;
4
3
  export default params;
@@ -0,0 +1,2 @@
1
+ import type { PickResult, RunnerConfig } from './types';
2
+ export declare const pickGeneratorAction: (config: RunnerConfig) => Promise<PickResult | null>;
@@ -1,24 +1,10 @@
1
- import type { ActionHooks, Helpers, Prompter, ProjectHooks, RunnerConfig } from './types';
2
- export declare const ACTION_HOOK_FILES: string[];
3
- export declare const LEGACY_HOOK_FILES: string[];
4
- export declare const HOOK_FILES: string[];
5
- export type HookKind = 'class' | 'legacy' | 'none';
6
- export interface ResolvedActionHooks {
7
- instance: ActionHooks;
8
- kind: HookKind;
9
- file?: string;
10
- source?: unknown;
11
- }
12
- export type HookCache = Map<string, Promise<ResolvedActionHooks>>;
1
+ import type { Helpers, HookCache, Prompter, ProjectHooks, ResolvedActionHooks, RunnerConfig } from './types';
2
+ import type { ParamsSchema } from './types';
3
+ export declare const validateParamsSchema: (schema: ParamsSchema | undefined) => ParamsSchema | undefined;
13
4
  export declare const resolveActionHooks: (actionfolder: string, cache?: HookCache) => Promise<ResolvedActionHooks>;
14
5
  export declare const normalizeProjectHooks: (hooks: unknown, logger: RunnerConfig["logger"]) => ProjectHooks;
15
6
  declare const prompt: <Q, T>(createPrompter: () => Prompter<Q, T>, actionfolder: string, args: Record<string, any>, options?: {
16
- h?: Helpers;
7
+ h?: Helpers | (() => Helpers);
17
8
  cache?: HookCache;
18
9
  }) => Promise<T | object>;
19
- export interface PickResult {
20
- generator: string;
21
- action: string;
22
- }
23
- export declare const pickGeneratorAction: (config: RunnerConfig) => Promise<PickResult | null>;
24
10
  export default prompt;
@@ -0,0 +1,2 @@
1
+ declare const registerTsNode: (file: string, error: new (file: string, cause: unknown) => Error) => Promise<void>;
2
+ export default registerTsNode;
@@ -0,0 +1,18 @@
1
+ export interface ActionAttributes {
2
+ to?: string;
3
+ mirror?: boolean;
4
+ sh?: string;
5
+ glob?: string;
6
+ base?: string;
7
+ stripExtensions?: string | string[];
8
+ destination?: string;
9
+ skipIfExists?: boolean;
10
+ skip?: unknown;
11
+ [key: string]: unknown;
12
+ }
13
+ export interface RenderedAction {
14
+ file?: string;
15
+ attributes: ActionAttributes;
16
+ body: string;
17
+ skip?: true | string;
18
+ }
@@ -0,0 +1,26 @@
1
+ import type { Logger } from './logger';
2
+ import type { Helpers, Transforms } from './helpers-ns';
3
+ import type { Prompter } from './prompter';
4
+ import type { ProjectHooks } from './hooks';
5
+ export interface RunnerConfig {
6
+ exec: (sh: string, body: string) => void;
7
+ templates?: string;
8
+ templatesOverride?: string;
9
+ cwd: string;
10
+ logger: Logger;
11
+ debug?: boolean;
12
+ helpers?: Helpers | ((locals: Record<string, unknown>, config: RunnerContextConfig) => Helpers);
13
+ transforms?: Transforms;
14
+ hooks?: ProjectHooks;
15
+ localsDefaults?: Record<string, unknown>;
16
+ createPrompter: <Q, T>() => Prompter<Q, T>;
17
+ legacyNameFlag?: boolean;
18
+ interactive?: boolean;
19
+ argCase?: 'keep' | 'upper-underscore';
20
+ }
21
+ export type RunnerContextConfig = Partial<RunnerConfig>;
22
+ export interface ResolverIO {
23
+ exists: (arg0: string) => Promise<boolean>;
24
+ load: (arg0: string) => Promise<Record<string, unknown>>;
25
+ none: (arg0: string) => Record<string, unknown>;
26
+ }
@@ -0,0 +1,4 @@
1
+ export type Helper = (...args: unknown[]) => unknown;
2
+ export type Helpers = Record<string, unknown>;
3
+ export type Transform = (content: string, locals: Record<string, unknown>) => string | Promise<string>;
4
+ export type Transforms = Record<string, Transform>;
@@ -0,0 +1,39 @@
1
+ import type { Logger } from './logger';
2
+ import type { Helpers } from './helpers-ns';
3
+ import type { Prompter } from './prompter';
4
+ import type { ActionResult } from './results';
5
+ export interface HookContext {
6
+ cwd: string;
7
+ templates: string;
8
+ generator: string;
9
+ action: string;
10
+ subaction?: string;
11
+ name?: string;
12
+ args: Record<string, unknown>;
13
+ h: Helpers;
14
+ logger: Logger;
15
+ dry: boolean;
16
+ }
17
+ export type HookMethod = (ctx: HookContext) => unknown | Promise<unknown>;
18
+ export interface ProjectHooks {
19
+ beforeAll?: HookMethod;
20
+ beforeEach?: HookMethod;
21
+ afterEach?: (ctx: HookContext, results: ActionResult[]) => unknown | Promise<unknown>;
22
+ afterAll?: (ctx: HookContext, results: ActionResult[]) => unknown | Promise<unknown>;
23
+ }
24
+ export interface ActionHooks extends ProjectHooks {
25
+ prompt?: (input: {
26
+ prompter: Prompter<any, any>;
27
+ args: Record<string, unknown>;
28
+ h: Helpers;
29
+ }) => unknown;
30
+ }
31
+ export type HookKind = 'class' | 'legacy' | 'none';
32
+ export interface ResolvedActionHooks {
33
+ instance: ActionHooks;
34
+ kind: HookKind;
35
+ file?: string;
36
+ source?: unknown;
37
+ params?: import('./params-schema').ParamsSchema;
38
+ }
39
+ export type HookCache = Map<string, Promise<ResolvedActionHooks>>;
@@ -0,0 +1,12 @@
1
+ export * from './logger';
2
+ export * from './prompter';
3
+ export * from './prompter-ns';
4
+ export * from './attributes';
5
+ export * from './helpers-ns';
6
+ export * from './hooks';
7
+ export * from './config';
8
+ export * from './results';
9
+ export * from './params';
10
+ export * from './params-schema';
11
+ export * from './ops';
12
+ export * from './inflection';
@@ -0,0 +1,12 @@
1
+ export interface Inflection {
2
+ pluralize(str: string, plural?: string): string;
3
+ singularize(str: string, singular?: string): string;
4
+ inflect(str: string, count: number, singular?: string, plural?: string): string;
5
+ camelize(str: string, low_first_letter?: boolean): string;
6
+ underscore(str: string, all_upper_case?: boolean): string;
7
+ humanize(str: string, low_first_letter?: boolean): string;
8
+ capitalize(str: string): string;
9
+ dasherize(str: string): string;
10
+ titleize(str: string): string;
11
+ undasherize(str: string): string;
12
+ }
@@ -0,0 +1,8 @@
1
+ export interface Logger {
2
+ ok: (msg: string) => void;
3
+ notice: (msg: string) => void;
4
+ warn: (msg: string) => void;
5
+ err: (msg: string) => void;
6
+ log: (msg: string) => void;
7
+ colorful: (msg: string) => void;
8
+ }
@@ -0,0 +1,7 @@
1
+ import type { ActionResult } from './results';
2
+ import type { RenderedAction } from './attributes';
3
+ import type { RunnerConfig } from './config';
4
+ export type Op = (action: RenderedAction, args: Record<string, unknown>, config: RunnerConfig) => Promise<ActionResult>;
5
+ export interface AnchorLocator {
6
+ locate: (lines: string[]) => number;
7
+ }
@@ -0,0 +1,9 @@
1
+ export type ParamType = 'string' | 'number' | 'boolean' | ((raw: unknown) => unknown);
2
+ export interface ParamDescriptor {
3
+ name: string;
4
+ type: ParamType;
5
+ required?: boolean;
6
+ default?: unknown;
7
+ message?: string;
8
+ }
9
+ export type ParamsSchema = ParamDescriptor[];
@@ -0,0 +1,14 @@
1
+ export type ParamsResult = {
2
+ templates: string | undefined;
3
+ generator: string | undefined;
4
+ action?: string;
5
+ subaction?: string;
6
+ actionfolder?: string;
7
+ name?: string;
8
+ dry?: boolean;
9
+ actions?: string[];
10
+ names?: string[];
11
+ cleanArgv?: Record<string, unknown>;
12
+ _?: (string | number)[];
13
+ ts?: string | number;
14
+ } & object;
@@ -0,0 +1,4 @@
1
+ export interface PickResult {
2
+ generator: string;
3
+ action: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ export interface Prompter<Q, T> {
2
+ prompt: (arg0: Q) => Promise<T>;
3
+ }
@@ -0,0 +1,27 @@
1
+ export type ActionResult = Record<string, unknown> & {
2
+ action?: string;
3
+ name?: string;
4
+ };
5
+ export type ActionStatus = 'ok' | 'skipped' | 'failed';
6
+ export interface ActionStatusEntry {
7
+ action: string;
8
+ name?: string;
9
+ status: ActionStatus;
10
+ reason?: string;
11
+ }
12
+ export interface RunFailure {
13
+ action: string;
14
+ name?: string;
15
+ error: string;
16
+ }
17
+ export interface RunnerResult {
18
+ success: boolean;
19
+ time: number;
20
+ actions: ActionResult[];
21
+ statuses: ActionStatusEntry[];
22
+ failure?: {
23
+ message: string;
24
+ availableActions: string[];
25
+ };
26
+ failures?: RunFailure[];
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biorate/hygen",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "The scalable code generator that saves you time. Fork of jondot/hygen",
5
5
  "keywords": [
6
6
  "template",
@@ -80,5 +80,5 @@
80
80
  "@types/inflection": "1.13.0",
81
81
  "@types/yargs-parser": "21.0.3"
82
82
  },
83
- "gitHead": "d73673a1ec66c0aa22f95373b958ea5c98adbfa4"
83
+ "gitHead": "783186abf7538c13578041ff5e59853cd5354218"
84
84
  }