UNPKG

3.69 kBTypeScriptView Raw
1import * as yaml from 'yaml';
2import Command from '../base';
3import { Container, InitParams, InitPaths, Question } from '../types';
4import { OpTypes } from '../constants/opConfig';
5export default class Init extends Command {
6 static description: string;
7 static flags: {
8 help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
9 };
10 questions: object[];
11 srcDir: string;
12 destDir: string;
13 initPrompts: Container<Question>;
14 determineTemplate: (prompts: Container<Question<Record<string, any>>>) => Promise<{
15 prompts: Container<Question<Record<string, any>>>;
16 templates: OpTypes[] | undefined;
17 }>;
18 determineQuestions: ({ prompts, templates, }: {
19 prompts: Container<Question<Record<string, any>>>;
20 templates: OpTypes[];
21 }) => {
22 questions: Question<Record<string, any>>[];
23 templates: OpTypes[];
24 };
25 askQuestions: ({ questions, templates, }: {
26 questions: Question<Record<string, any>>[];
27 templates: OpTypes[];
28 }) => Promise<{
29 answers: Partial<InitParams>;
30 templates: OpTypes[];
31 }>;
32 determineInitPaths: ({ answers, templates, }: {
33 answers: Partial<InitParams>;
34 templates: OpTypes[];
35 }) => {
36 initPaths: {
37 sharedDir: string;
38 destDir: string;
39 };
40 initParams: {
41 templates: OpTypes[];
42 commandName?: string | undefined;
43 commandDescription?: string | undefined;
44 commandVersion?: string | undefined;
45 workflowName?: string | undefined;
46 workflowDescription?: string | undefined;
47 workflowVersion?: string | undefined;
48 help?: void | undefined;
49 };
50 };
51 copyTemplateFiles: ({ initPaths, initParams, }: {
52 initPaths: InitPaths;
53 initParams: InitParams;
54 }) => Promise<{
55 initPaths: InitPaths;
56 initParams: InitParams;
57 }>;
58 customizePackageJson: ({ initPaths, initParams, }: {
59 initPaths: InitPaths;
60 initParams: InitParams;
61 }) => Promise<{
62 initPaths: InitPaths;
63 initParams: InitParams;
64 }>;
65 customizeYaml: ({ initPaths, initParams, }: {
66 initPaths: InitPaths;
67 initParams: InitParams;
68 }) => Promise<{
69 initPaths: InitPaths;
70 initParams: InitParams;
71 }>;
72 addHelpCommentsFor: (key: string, yamlDoc: yaml.ast.Document) => void;
73 customizeOpsYaml: (initParams: InitParams, yamlDoc: yaml.ast.Document) => Promise<void>;
74 customizeWorkflowYaml: (initParams: InitParams, yamlDoc: yaml.ast.Document) => Promise<void>;
75 logMessages: ({ initPaths, initParams, }: {
76 initPaths: InitPaths;
77 initParams: InitParams;
78 }) => Promise<{
79 initPaths: InitPaths;
80 initParams: InitParams;
81 }>;
82 logCommandMessage: (initParams: InitParams) => void;
83 logWorkflowMessage: (initParams: InitParams) => void;
84 logSuccessMessage: (templates: OpTypes[]) => void;
85 sendAnalytics: ({ initPaths, initParams, }: {
86 initPaths: InitPaths;
87 initParams: InitParams;
88 }) => Promise<{
89 initPaths: InitPaths;
90 initParams: InitParams;
91 }>;
92 getNameAndDescription: (initParams: Partial<InitParams>) => {
93 name: string | undefined;
94 description: string | undefined;
95 };
96 _validateName(input: string): true | "You need name your op before you can continue" | "Sorry, please name the Op using only numbers, letters, -, or _";
97 _validateDescription(input: string): true | "You need to provide a description of your op before continuing";
98 private _validateVersion;
99 run(): Promise<void>;
100}