@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.
- package/README.md +14 -14
- package/dist/cjs/src/config-resolver.js +4 -11
- package/dist/cjs/src/constants/config.js +5 -0
- package/dist/cjs/src/constants/engine.js +4 -0
- package/dist/cjs/src/constants/hooks.js +18 -0
- package/dist/cjs/src/constants/index.js +19 -0
- package/dist/cjs/src/engine.js +14 -14
- package/dist/cjs/src/errors.js +19 -1
- package/dist/cjs/src/help.js +3 -3
- package/dist/cjs/src/params-schema/index.js +11 -0
- package/dist/cjs/src/params-schema/prompts.js +34 -0
- package/dist/cjs/src/params-schema/registry.js +92 -0
- package/dist/cjs/src/params.js +21 -5
- package/dist/cjs/src/picker.js +55 -0
- package/dist/cjs/src/prompt.js +39 -69
- package/dist/cjs/src/ts-node-register.js +36 -0
- package/dist/cjs/src/types/config.js +2 -0
- package/dist/cjs/src/types/helpers-ns.js +2 -0
- package/dist/cjs/src/types/hooks.js +2 -0
- package/dist/cjs/src/types/index.js +28 -0
- package/dist/cjs/src/types/inflection.js +2 -0
- package/dist/cjs/src/types/logger.js +2 -0
- package/dist/cjs/src/types/ops.js +2 -0
- package/dist/cjs/src/types/params-schema.js +2 -0
- package/dist/cjs/src/types/params.js +2 -0
- package/dist/cjs/src/types/prompter-ns.js +2 -0
- package/dist/cjs/src/types/prompter.js +2 -0
- package/dist/cjs/src/types/results.js +2 -0
- package/dist/esm/src/config-resolver.js +3 -9
- package/dist/esm/src/constants/config.js +2 -0
- package/dist/esm/src/constants/engine.js +1 -0
- package/dist/esm/src/constants/hooks.js +15 -0
- package/dist/esm/src/constants/index.js +3 -0
- package/dist/esm/src/engine.js +10 -10
- package/dist/esm/src/errors.js +15 -0
- package/dist/esm/src/help.js +1 -1
- package/dist/esm/src/params-schema/index.js +2 -0
- package/dist/esm/src/params-schema/prompts.js +30 -0
- package/dist/esm/src/params-schema/registry.js +84 -0
- package/dist/esm/src/params.js +19 -2
- package/dist/esm/src/picker.js +48 -0
- package/dist/esm/src/prompt.js +34 -64
- package/dist/esm/src/ts-node-register.js +11 -0
- package/dist/esm/src/types/config.js +1 -0
- package/dist/esm/src/types/helpers-ns.js +1 -0
- package/dist/esm/src/types/hooks.js +1 -0
- package/dist/esm/src/types/index.js +12 -0
- package/dist/esm/src/types/inflection.js +1 -0
- package/dist/esm/src/types/logger.js +1 -0
- package/dist/esm/src/types/ops.js +1 -0
- package/dist/esm/src/types/params-schema.js +1 -0
- package/dist/esm/src/types/params.js +1 -0
- package/dist/esm/src/types/prompter-ns.js +1 -0
- package/dist/esm/src/types/prompter.js +1 -0
- package/dist/esm/src/types/results.js +1 -0
- package/dist/types/src/config-resolver.d.ts +0 -1
- package/dist/types/src/constants/config.d.ts +2 -0
- package/dist/types/src/constants/engine.d.ts +1 -0
- package/dist/types/src/constants/hooks.d.ts +4 -0
- package/dist/types/src/constants/index.d.ts +3 -0
- package/dist/types/src/context.d.ts +1 -1
- package/dist/types/src/errors.d.ts +9 -0
- package/dist/types/src/helpers.d.ts +1 -13
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/ops/anchors.d.ts +0 -3
- package/dist/types/src/ops/index.d.ts +1 -2
- package/dist/types/src/params-schema/index.d.ts +2 -0
- package/dist/types/src/params-schema/prompts.d.ts +2 -0
- package/dist/types/src/params-schema/registry.d.ts +6 -0
- package/dist/types/src/params.d.ts +1 -2
- package/dist/types/src/picker.d.ts +2 -0
- package/dist/types/src/prompt.d.ts +4 -18
- package/dist/types/src/ts-node-register.d.ts +2 -0
- package/dist/types/src/types/attributes.d.ts +18 -0
- package/dist/types/src/types/config.d.ts +26 -0
- package/dist/types/src/types/helpers-ns.d.ts +4 -0
- package/dist/types/src/types/hooks.d.ts +39 -0
- package/dist/types/src/types/index.d.ts +12 -0
- package/dist/types/src/types/inflection.d.ts +12 -0
- package/dist/types/src/types/logger.d.ts +8 -0
- package/dist/types/src/types/ops.d.ts +7 -0
- package/dist/types/src/types/params-schema.d.ts +9 -0
- package/dist/types/src/types/params.d.ts +14 -0
- package/dist/types/src/types/prompter-ns.d.ts +4 -0
- package/dist/types/src/types/prompter.d.ts +3 -0
- package/dist/types/src/types/results.d.ts +27 -0
- package/package.json +2 -2
- package/dist/types/src/types.d.ts +0 -121
- /package/dist/cjs/src/{types.js → types/attributes.js} +0 -0
- /package/dist/esm/src/{types.js → types/attributes.js} +0 -0
package/dist/esm/src/prompt.js
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RUN_SCOPE = "*";
|
|
@@ -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("./
|
|
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
|
-
|
|
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,3 @@
|
|
|
1
|
-
import type {
|
|
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,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
|
-
|
|
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;
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
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,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,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,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,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
|
+
"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": "
|
|
83
|
+
"gitHead": "783186abf7538c13578041ff5e59853cd5354218"
|
|
84
84
|
}
|