@biorate/hygen 0.0.0-stage → 0.2.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/LICENSE +25 -0
- package/README.md +146 -2
- package/dist/cjs/bin.js +26 -0
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/src/cli-help.js +19 -0
- package/dist/cjs/src/config-resolver.js +66 -0
- package/dist/cjs/src/config.js +37 -0
- package/dist/cjs/src/context.js +37 -0
- package/dist/cjs/src/engine.js +149 -0
- package/dist/cjs/src/errors.js +116 -0
- package/dist/cjs/src/execute.js +48 -0
- package/dist/cjs/src/help.js +89 -0
- package/dist/cjs/src/helpers.js +24 -0
- package/dist/cjs/src/index.js +42 -0
- package/dist/cjs/src/logger.js +28 -0
- package/dist/cjs/src/newline.js +13 -0
- package/dist/cjs/src/ops/add.js +74 -0
- package/dist/cjs/src/ops/anchors.js +45 -0
- package/dist/cjs/src/ops/echo.js +17 -0
- package/dist/cjs/src/ops/index.js +51 -0
- package/dist/cjs/src/ops/inject.js +37 -0
- package/dist/cjs/src/ops/injector.js +49 -0
- package/dist/cjs/src/ops/result.js +9 -0
- package/dist/cjs/src/ops/setup.js +52 -0
- package/dist/cjs/src/ops/shell.js +38 -0
- package/dist/cjs/src/params.js +77 -0
- package/dist/cjs/src/path-macros.js +30 -0
- package/dist/cjs/src/prompt.js +111 -0
- package/dist/cjs/src/render.js +189 -0
- package/dist/cjs/src/runner.js +38 -0
- package/dist/cjs/src/types.js +2 -0
- package/dist/cjs/templates/init/repo/new-repo.ejs.t +4 -0
- package/dist/cjs/templates/init/self/new-generator-help.ejs.t +8 -0
- package/dist/cjs/templates/init/self/new-generator-with-prompt.ejs.t +21 -0
- package/dist/cjs/templates/init/self/new-generator-with-prompt.prompt.ejs.t +17 -0
- package/dist/cjs/templates/init/self/new-generator.ejs.t +21 -0
- package/dist/cjs/templates/init/self/new-repo.ejs.t +7 -0
- package/dist/esm/bin.js +21 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/src/cli-help.js +14 -0
- package/dist/esm/src/config-resolver.js +37 -0
- package/dist/esm/src/config.js +29 -0
- package/dist/esm/src/context.js +32 -0
- package/dist/esm/src/engine.js +118 -0
- package/dist/esm/src/errors.js +98 -0
- package/dist/esm/src/execute.js +41 -0
- package/dist/esm/src/help.js +78 -0
- package/dist/esm/src/helpers.js +19 -0
- package/dist/esm/src/index.js +6 -0
- package/dist/esm/src/logger.js +23 -0
- package/dist/esm/src/newline.js +11 -0
- package/dist/esm/src/ops/add.js +69 -0
- package/dist/esm/src/ops/anchors.js +41 -0
- package/dist/esm/src/ops/echo.js +12 -0
- package/dist/esm/src/ops/index.js +26 -0
- package/dist/esm/src/ops/inject.js +32 -0
- package/dist/esm/src/ops/injector.js +44 -0
- package/dist/esm/src/ops/result.js +7 -0
- package/dist/esm/src/ops/setup.js +47 -0
- package/dist/esm/src/ops/shell.js +33 -0
- package/dist/esm/src/params.js +71 -0
- package/dist/esm/src/path-macros.js +24 -0
- package/dist/esm/src/prompt.js +81 -0
- package/dist/esm/src/render.js +182 -0
- package/dist/esm/src/runner.js +32 -0
- package/dist/esm/src/types.js +1 -0
- package/dist/esm/templates/init/repo/new-repo.ejs.t +4 -0
- package/dist/esm/templates/init/self/new-generator-help.ejs.t +8 -0
- package/dist/esm/templates/init/self/new-generator-with-prompt.ejs.t +21 -0
- package/dist/esm/templates/init/self/new-generator-with-prompt.prompt.ejs.t +17 -0
- package/dist/esm/templates/init/self/new-generator.ejs.t +21 -0
- package/dist/esm/templates/init/self/new-repo.ejs.t +7 -0
- package/dist/types/bin.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/src/cli-help.d.ts +3 -0
- package/dist/types/src/config-resolver.d.ts +4 -0
- package/dist/types/src/config.d.ts +14 -0
- package/dist/types/src/context.d.ts +12 -0
- package/dist/types/src/engine.d.ts +6 -0
- package/dist/types/src/errors.d.ts +50 -0
- package/dist/types/src/execute.d.ts +5 -0
- package/dist/types/src/help.d.ts +8 -0
- package/dist/types/src/helpers.d.ts +22 -0
- package/dist/types/src/index.d.ts +6 -0
- package/dist/types/src/logger.d.ts +10 -0
- package/dist/types/src/newline.d.ts +2 -0
- package/dist/types/src/ops/add.d.ts +3 -0
- package/dist/types/src/ops/anchors.d.ts +4 -0
- package/dist/types/src/ops/echo.d.ts +3 -0
- package/dist/types/src/ops/index.d.ts +4 -0
- package/dist/types/src/ops/inject.d.ts +3 -0
- package/dist/types/src/ops/injector.d.ts +3 -0
- package/dist/types/src/ops/result.d.ts +3 -0
- package/dist/types/src/ops/setup.d.ts +3 -0
- package/dist/types/src/ops/shell.d.ts +3 -0
- package/dist/types/src/params.d.ts +4 -0
- package/dist/types/src/path-macros.d.ts +3 -0
- package/dist/types/src/prompt.d.ts +8 -0
- package/dist/types/src/render.d.ts +2 -0
- package/dist/types/src/runner.d.ts +3 -0
- package/dist/types/src/types.d.ts +94 -0
- package/package.json +82 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Logger } from './types';
|
|
2
|
+
declare const VERSION: string;
|
|
3
|
+
declare const isVersionFlag: (args: string[]) => boolean;
|
|
4
|
+
declare const availableActions: (templates: string) => Record<string, string[]>;
|
|
5
|
+
declare const pickableGenerators: (templates: string) => string[];
|
|
6
|
+
declare const generatorActions: (templates: string, generator: string) => string[];
|
|
7
|
+
declare const printHelp: (templates: string | undefined, logger: Logger) => void;
|
|
8
|
+
export { availableActions, pickableGenerators, generatorActions, printHelp, VERSION, isVersionFlag, };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'path';
|
|
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 };
|
|
16
|
+
declare const helpers: {
|
|
17
|
+
capitalize(str: string): string;
|
|
18
|
+
inflection: Inflection;
|
|
19
|
+
changeCase: typeof changeCase;
|
|
20
|
+
path: path.PlatformPath;
|
|
21
|
+
};
|
|
22
|
+
export default helpers;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { runner } from './runner';
|
|
2
|
+
export { engine } from './engine';
|
|
3
|
+
export { default as resolve } from './config-resolver';
|
|
4
|
+
export { printHelp, availableActions, VERSION } from './help';
|
|
5
|
+
export { default as Logger } from './logger';
|
|
6
|
+
export * as errors from './errors';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare class Logger {
|
|
2
|
+
log: (message: string) => void;
|
|
3
|
+
constructor(log: (message: string) => void);
|
|
4
|
+
colorful(msg: string): void;
|
|
5
|
+
notice(msg: string): void;
|
|
6
|
+
warn(msg: string): void;
|
|
7
|
+
err(msg: string): void;
|
|
8
|
+
ok(msg: string): void;
|
|
9
|
+
}
|
|
10
|
+
export default Logger;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ActionResult, RenderedAction, RunnerConfig } from '../types';
|
|
2
|
+
export type Op = (action: RenderedAction, args: Record<string, unknown>, config: RunnerConfig) => Promise<ActionResult>;
|
|
3
|
+
declare const resolve: (attributes: Record<string, unknown>) => Promise<Op[]>;
|
|
4
|
+
export default resolve;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ActionResult, RenderedAction, RunnerConfig } from '../types';
|
|
2
|
+
declare const shell: ({ attributes: { sh, spinner, sh_ignore_exit }, body }: RenderedAction, args: Record<string, any>, { logger, exec }: RunnerConfig) => Promise<ActionResult>;
|
|
3
|
+
export default shell;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Prompter, RunnerConfig } from './types';
|
|
2
|
+
declare const prompt: <Q, T>(createPrompter: () => Prompter<Q, T>, actionfolder: string, args: Record<string, any>) => Promise<T | object>;
|
|
3
|
+
export interface PickResult {
|
|
4
|
+
generator: string;
|
|
5
|
+
action: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const pickGeneratorAction: (config: RunnerConfig) => Promise<PickResult | null>;
|
|
8
|
+
export default prompt;
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
}
|
|
9
|
+
export interface Prompter<Q, T> {
|
|
10
|
+
prompt: (arg0: Q) => Promise<T>;
|
|
11
|
+
}
|
|
12
|
+
export interface ActionAttributes {
|
|
13
|
+
to?: string;
|
|
14
|
+
mirror?: boolean;
|
|
15
|
+
sh?: string;
|
|
16
|
+
glob?: string;
|
|
17
|
+
base?: string;
|
|
18
|
+
stripExtensions?: string | string[];
|
|
19
|
+
destination?: string;
|
|
20
|
+
skipIfExists?: boolean;
|
|
21
|
+
skip?: unknown;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
export interface RenderedAction {
|
|
25
|
+
file?: string;
|
|
26
|
+
attributes: ActionAttributes;
|
|
27
|
+
body: string;
|
|
28
|
+
skip?: true | string;
|
|
29
|
+
}
|
|
30
|
+
export type Helper = (...args: unknown[]) => unknown;
|
|
31
|
+
export type Helpers = Record<string, unknown>;
|
|
32
|
+
export type Transform = (content: string, locals: Record<string, unknown>) => string | Promise<string>;
|
|
33
|
+
export type Transforms = Record<string, Transform>;
|
|
34
|
+
export interface RunnerConfig {
|
|
35
|
+
exec: (sh: string, body: string) => void;
|
|
36
|
+
templates?: string;
|
|
37
|
+
templatesOverride?: string;
|
|
38
|
+
cwd: string;
|
|
39
|
+
logger: Logger;
|
|
40
|
+
debug?: boolean;
|
|
41
|
+
helpers?: Helpers | ((locals: Record<string, unknown>, config: RunnerContextConfig) => Helpers);
|
|
42
|
+
transforms?: Transforms;
|
|
43
|
+
localsDefaults?: Record<string, unknown>;
|
|
44
|
+
createPrompter: <Q, T>() => Prompter<Q, T>;
|
|
45
|
+
legacyNameFlag?: boolean;
|
|
46
|
+
interactive?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export type RunnerContextConfig = Partial<RunnerConfig>;
|
|
49
|
+
export interface ResolverIO {
|
|
50
|
+
exists: (arg0: string) => Promise<boolean>;
|
|
51
|
+
load: (arg0: string) => Promise<Record<string, unknown>>;
|
|
52
|
+
none: (arg0: string) => Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
export type ActionResult = Record<string, unknown> & {
|
|
55
|
+
action?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
};
|
|
58
|
+
export type ActionStatus = 'ok' | 'skipped' | 'failed';
|
|
59
|
+
export interface ActionStatusEntry {
|
|
60
|
+
action: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
status: ActionStatus;
|
|
63
|
+
reason?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface RunFailure {
|
|
66
|
+
action: string;
|
|
67
|
+
name?: string;
|
|
68
|
+
error: string;
|
|
69
|
+
}
|
|
70
|
+
export interface RunnerResult {
|
|
71
|
+
success: boolean;
|
|
72
|
+
time: number;
|
|
73
|
+
actions: ActionResult[];
|
|
74
|
+
statuses: ActionStatusEntry[];
|
|
75
|
+
failure?: {
|
|
76
|
+
message: string;
|
|
77
|
+
availableActions: string[];
|
|
78
|
+
};
|
|
79
|
+
failures?: RunFailure[];
|
|
80
|
+
}
|
|
81
|
+
export type ParamsResult = {
|
|
82
|
+
templates: string | undefined;
|
|
83
|
+
generator: string | undefined;
|
|
84
|
+
action?: string;
|
|
85
|
+
subaction?: string;
|
|
86
|
+
actionfolder?: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
dry?: boolean;
|
|
89
|
+
actions?: string[];
|
|
90
|
+
names?: string[];
|
|
91
|
+
cleanArgv?: Record<string, unknown>;
|
|
92
|
+
_?: (string | number)[];
|
|
93
|
+
ts?: string | number;
|
|
94
|
+
} & object;
|
package/package.json
CHANGED
|
@@ -1,6 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biorate/hygen",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The scalable code generator that saves you time. Fork of jondot/hygen",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"template",
|
|
7
|
+
"generator",
|
|
8
|
+
"hygen",
|
|
9
|
+
"boilerplate"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/biorate/core.git",
|
|
15
|
+
"directory": "packages/@biorate/hygen"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://biorate.github.io/core/hygen",
|
|
21
|
+
"author": "llevkin",
|
|
22
|
+
"main": "./dist/cjs/index.js",
|
|
23
|
+
"module": "./dist/esm/index.js",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"import": "./dist/esm/index.js",
|
|
29
|
+
"require": "./dist/cjs/index.js",
|
|
30
|
+
"default": "./dist/cjs/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"bin": {
|
|
34
|
+
"hygen": "./dist/cjs/bin.js"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/**",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"clean": "cleanup dist",
|
|
43
|
+
"build:cjs": "npx tsc -p ./tsconfig.build.cjs.json",
|
|
44
|
+
"build:esm": "npx tsc -p ./tsconfig.build.esm.json",
|
|
45
|
+
"build:types": "npx tsc -p ./tsconfig.build.types.json",
|
|
46
|
+
"build": "pnpm run clean && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types",
|
|
47
|
+
"docs": "node .scripts/build-hygen-docs.js",
|
|
48
|
+
"demo": "pnpm run docs",
|
|
49
|
+
"postbuild:cjs": "node ../../../.scripts/write-package-type.js dist/cjs commonjs && cp -r src/templates dist/cjs/templates",
|
|
50
|
+
"postbuild:esm": "tsc-esm-fix --tsconfig=./tsconfig.build.esm.json --target=./dist/esm && node ../../../.scripts/write-package-type.js dist/esm module && cp -r src/templates dist/esm/templates",
|
|
51
|
+
"format": "prettier --check src",
|
|
52
|
+
"lint": "eslint src --ext .ts",
|
|
53
|
+
"format:fix": "prettier --write src",
|
|
54
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
55
|
+
"test": "npx vitest run --coverage",
|
|
56
|
+
"prepublishOnly": "pnpm run build"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@biorate/errors": "3.1.2",
|
|
60
|
+
"chalk": "4.1.2",
|
|
61
|
+
"change-case": "3.1.0",
|
|
62
|
+
"debug": "4.3.3",
|
|
63
|
+
"degit": "2.8.4",
|
|
64
|
+
"ejs": "3.1.6",
|
|
65
|
+
"enquirer": "2.3.6",
|
|
66
|
+
"execa": "5.0.0",
|
|
67
|
+
"fast-glob": "^3.3.3",
|
|
68
|
+
"front-matter": "4.0.2",
|
|
69
|
+
"fs-extra": "10.0.0",
|
|
70
|
+
"ignore-walk": "4.0.1",
|
|
71
|
+
"inflection": "1.12.0",
|
|
72
|
+
"ora": "5.4.1",
|
|
73
|
+
"yargs-parser": "21.0.0"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/debug": "4.1.7",
|
|
77
|
+
"@types/ejs": "3.1.0",
|
|
78
|
+
"@types/fs-extra": "9.0.13",
|
|
79
|
+
"@types/ignore-walk": "4.0.3",
|
|
80
|
+
"@types/inflection": "1.13.0",
|
|
81
|
+
"@types/yargs-parser": "21.0.3"
|
|
82
|
+
},
|
|
83
|
+
"gitHead": "0768d737d2355377d0d27e36a716ea27f89b6b1d"
|
|
84
|
+
}
|