UNPKG

22.6 kBTypeScriptView Raw
1/// <reference types="node" />
2import { BaseConfig, CommandInstanceInfo as FrameworkCommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMetadata as FrameworkCommandMetadata, CommandMetadataInput, CommandMetadataOption as FrameworkCommandMetadataOption, HydratedCommandMetadata as FrameworkHydratedCommandMetadata, ICommand as FrameworkCommand, INamespace as FrameworkNamespace, Logger, NamespaceLocateResult as FrameworkNamespaceLocateResult, PackageJson } from '@ionic/cli-framework';
3import { PromptModule } from '@ionic/cli-framework-prompts';
4import { NetworkInterface } from '@ionic/utils-network';
5import { Subprocess, SubprocessOptions, WhichOptions } from '@ionic/utils-subprocess';
6import { ChildProcess, SpawnOptions } from 'child_process';
7import * as fs from 'fs';
8export { CommandLineInputs, CommandLineOptions, CommandMetadataInput, NamespaceMetadata, } from '@ionic/cli-framework';
9export declare type SuperAgentRequest = import('superagent').SuperAgentRequest;
10export interface SuperAgentError extends Error {
11 response: import('superagent').Response;
12}
13export declare type LogFn = (msg: string) => void;
14export interface ILogger extends Logger {
15 ok: LogFn;
16 rawmsg: LogFn;
17}
18export interface StarterManifest {
19 name: string;
20 baseref: string;
21 welcome?: string;
22}
23export interface CordovaPackageJson extends PackageJson {
24 cordova: {
25 platforms: string[];
26 plugins: {
27 [key: string]: unknown;
28 };
29 };
30}
31export interface Runner<T extends object, U> {
32 run(options: T): Promise<U>;
33}
34export declare type ProjectType = 'angular' | 'ionic-angular' | 'ionic1' | 'custom' | 'bare' | 'react' | 'vue';
35export declare type HookName = 'build:before' | 'build:after' | 'serve:before' | 'serve:after';
36export interface BaseHookContext {
37 project: {
38 type: ProjectType;
39 dir: string;
40 srcDir: string;
41 };
42 argv: string[];
43 env: NodeJS.ProcessEnv;
44}
45export interface BuildHookInput {
46 readonly name: 'build:before' | 'build:after';
47 readonly build: AngularBuildOptions | IonicAngularBuildOptions | Ionic1BuildOptions;
48}
49export interface ServeBeforeHookInput {
50 readonly name: 'serve:before';
51 readonly serve: AngularServeOptions | IonicAngularServeOptions | Ionic1ServeOptions;
52}
53export interface ServeAfterHookInput {
54 readonly name: 'serve:after';
55 readonly serve: (AngularServeOptions | IonicAngularServeOptions | Ionic1ServeOptions) & ServeDetails;
56}
57export declare type HookInput = BuildHookInput | ServeBeforeHookInput | ServeAfterHookInput;
58export declare type HookContext = BaseHookContext & HookInput;
59export declare type HookFn = (ctx: HookContext) => Promise<void>;
60export declare type IntegrationName = 'capacitor' | 'cordova' | 'enterprise';
61export interface ProjectIntegration {
62 enabled?: boolean;
63 root?: string;
64}
65export interface EnterpriseProjectIntegration extends ProjectIntegration {
66 productKey?: string;
67 registries?: string[];
68 appId?: string;
69 orgId?: string;
70 keyId?: number;
71}
72export interface ProjectIntegrations {
73 cordova?: ProjectIntegration;
74 capacitor?: ProjectIntegration;
75 enterprise?: EnterpriseProjectIntegration;
76}
77export interface Response<T extends object> extends APIResponseSuccess {
78 data: T;
79}
80export interface ResourceClientLoad<T extends object> {
81 load(id: string | number, modifiers: ResourceClientRequestModifiers): Promise<T>;
82}
83export interface ResourceClientDelete {
84 delete(id: string | number): Promise<void>;
85}
86export interface ResourceClientCreate<T extends object, U extends object> {
87 create(details: U): Promise<T>;
88}
89export interface ResourceClientPaginate<T extends object> {
90 paginate(args?: Partial<PaginateArgs<Response<T[]>>>): IPaginator<Response<T[]>, PaginatorState>;
91}
92export interface ResourceClientRequestModifiers {
93 fields?: string[];
94}
95export interface Org {
96 name: string;
97}
98export interface GithubRepo {
99 full_name: string;
100 id: number;
101}
102export interface GithubBranch {
103 name: string;
104}
105export interface AppAssociation {
106 repository: RepoAssociation;
107}
108export interface RepoAssociationBase {
109 html_url: string;
110 clone_url: string;
111 full_name: string;
112}
113export interface GithubRepoAssociation extends RepoAssociationBase {
114 type: 'github';
115 id: number;
116}
117export interface BitbucketCloudRepoAssociation extends RepoAssociationBase {
118 type: 'bitbucket_cloud';
119 id: string;
120}
121export interface BitbucketServerRepoAssociation extends RepoAssociationBase {
122 type: 'bitbucket_server';
123 id: number;
124}
125export declare type RepoAssociation = GithubRepoAssociation | BitbucketCloudRepoAssociation | BitbucketServerRepoAssociation;
126export declare type AssociationType = 'github' | 'bitbucket_cloud' | 'bitbucket_server';
127export interface App {
128 id: string;
129 name: string;
130 slug: string;
131 org: null | Org;
132 repo_url?: string;
133 association?: null | AppAssociation;
134}
135export interface Login {
136 user: User;
137 token: string;
138}
139export interface User {
140 id: number;
141 email: string;
142 oauth_identities?: OAuthIdentity;
143}
144export declare type OAuthIdentity = {
145 [A in AssociationType]?: OAuthIdentityDetails;
146};
147export interface OAuthIdentityDetails {
148 username: string;
149 name: string;
150 html_url: string;
151}
152export interface Snapshot {
153 id: string;
154 sha: string;
155 ref: string;
156 state: string;
157 created: string;
158 note: string;
159}
160export interface SSHKey {
161 id: string;
162 pubkey: string;
163 fingerprint: string;
164 annotation: string;
165 name: string;
166 created: string;
167 updated: string;
168}
169export interface SecurityProfile {
170 name: string;
171 tag: string;
172 type: 'development' | 'production';
173 created: string;
174 credentials: {
175 android?: object;
176 ios?: object;
177 };
178}
179export interface IConfig extends BaseConfig<ConfigFile> {
180 getAPIUrl(): string;
181 getDashUrl(): string;
182 getGitHost(): string;
183 getGitPort(): number;
184 getHTTPConfig(): CreateRequestOptions;
185}
186export interface ProjectPersonalizationDetails {
187 name: string;
188 projectId: string;
189 packageId?: string;
190 version?: string;
191 description?: string;
192}
193export interface IProjectConfig {
194 name: string;
195 type?: ProjectType;
196 id?: string;
197 root?: string;
198 readonly integrations: ProjectIntegrations;
199 readonly hooks?: Record<HookName, string | string[] | undefined>;
200}
201export interface IMultiProjectConfig {
202 defaultProject?: string;
203 projects: {
204 [key: string]: IProjectConfig | undefined;
205 };
206}
207export declare type ProjectFile = IProjectConfig | IMultiProjectConfig;
208export interface IProject {
209 readonly rootDirectory: string;
210 readonly directory: string;
211 readonly filePath: string;
212 readonly pathPrefix: readonly string[];
213 readonly type: ProjectType;
214 readonly config: BaseConfig<IProjectConfig>;
215 readonly details: import('./lib/project').ProjectDetailsResult;
216 getDocsUrl(): Promise<string>;
217 getSourceDir(sourceRoot?: string): Promise<string>;
218 getDistDir(): Promise<string>;
219 getInfo(): Promise<InfoItem[]>;
220 detected(): Promise<boolean>;
221 createIntegration(name: IntegrationName): Promise<IIntegration<ProjectIntegration>>;
222 getIntegration(name: IntegrationName): Required<ProjectIntegration> | undefined;
223 requireIntegration(name: IntegrationName): Required<ProjectIntegration>;
224 requireAppflowId(): Promise<string>;
225 getPackageJson(pkgName?: string): Promise<[PackageJson | undefined, string | undefined]>;
226 requirePackageJson(pkgName?: string): Promise<PackageJson>;
227 personalize(details: ProjectPersonalizationDetails): Promise<void>;
228 registerAilments(registry: IAilmentRegistry): Promise<void>;
229 getBuildRunner(): Promise<import('./lib/build').BuildRunner<any> | undefined>;
230 getServeRunner(): Promise<import('./lib/serve').ServeRunner<any> | undefined>;
231 getGenerateRunner(): Promise<import('./lib/generate').GenerateRunner<any> | undefined>;
232 requireBuildRunner(): Promise<import('./lib/build').BuildRunner<any>>;
233 requireServeRunner(): Promise<import('./lib/serve').ServeRunner<any>>;
234 requireGenerateRunner(): Promise<import('./lib/generate').GenerateRunner<any>>;
235}
236export interface IntegrationAddDetails {
237 env: IonicEnvironment;
238 quiet?: boolean;
239 root: string;
240 enableArgs?: string[];
241}
242export interface IntegrationAddHandlers {
243 conflictHandler?: (f: string, stats: fs.Stats) => Promise<boolean>;
244 onFileCreate?: (f: string) => void;
245}
246export interface IIntegration<T extends ProjectIntegration> {
247 readonly name: IntegrationName;
248 readonly summary: string;
249 readonly archiveUrl?: string;
250 readonly config: BaseConfig<T>;
251 add(details: IntegrationAddDetails): Promise<void>;
252 isAdded(): boolean;
253 enable(config?: T): Promise<void>;
254 isEnabled(): boolean;
255 disable(): Promise<void>;
256 getInfo(): Promise<InfoItem[]>;
257 personalize(details: ProjectPersonalizationDetails): Promise<void>;
258}
259export interface PackageVersions {
260 [key: string]: string;
261}
262export interface CommandMetadataOption extends FrameworkCommandMetadataOption {
263 private?: boolean;
264 hint?: string;
265}
266export interface ExitCodeException extends Error {
267 exitCode: number;
268}
269export interface CommandMetadata extends FrameworkCommandMetadata<CommandMetadataInput, CommandMetadataOption> {
270 type: 'global' | 'project';
271}
272export declare type HydratedCommandMetadata = CommandMetadata & FrameworkHydratedCommandMetadata<ICommand, INamespace, CommandMetadata, CommandMetadataInput, CommandMetadataOption>;
273export declare type CommandInstanceInfo = FrameworkCommandInstanceInfo<ICommand, INamespace, CommandMetadata, CommandMetadataInput, CommandMetadataOption>;
274export declare type NamespaceLocateResult = FrameworkNamespaceLocateResult<ICommand, INamespace, CommandMetadata, CommandMetadataInput, CommandMetadataOption>;
275export interface ISession {
276 login(email: string, password: string): Promise<void>;
277 ssoLogin(email: string): Promise<void>;
278 tokenLogin(token: string): Promise<void>;
279 logout(): Promise<void>;
280 isLoggedIn(): boolean;
281 getUser(): {
282 id: number;
283 };
284 getUserToken(): string;
285}
286export interface IShellSpawnOptions extends SpawnOptions {
287 showCommand?: boolean;
288}
289export interface IShellOutputOptions extends IShellSpawnOptions {
290 fatalOnError?: boolean;
291 fatalOnNotFound?: boolean;
292 showError?: boolean;
293}
294export interface IShellRunOptions extends IShellOutputOptions {
295 stream?: NodeJS.WritableStream;
296 killOnExit?: boolean;
297 truncateErrorOutput?: number;
298}
299export interface IShell {
300 alterPath: (path: string) => string;
301 run(command: string, args: readonly string[], options: IShellRunOptions): Promise<void>;
302 output(command: string, args: readonly string[], options: IShellOutputOptions): Promise<string>;
303 spawn(command: string, args: readonly string[], options: IShellSpawnOptions): Promise<ChildProcess>;
304 cmdinfo(cmd: string, args?: readonly string[], options?: SubprocessOptions): Promise<string | undefined>;
305 which(command: string, options?: WhichOptions): Promise<string>;
306 createSubprocess(command: string, args: readonly string[], options?: SubprocessOptions): Promise<Subprocess>;
307}
308export interface ITelemetry {
309 sendCommand(command: string, args: string[]): Promise<void>;
310}
311export declare type NpmClient = 'yarn' | 'npm';
312export declare type FeatureId = 'ssl-commands';
313export interface ConfigFile {
314 'version': string;
315 'telemetry': boolean;
316 'npmClient': NpmClient;
317 'interactive'?: boolean;
318 'proxy'?: string;
319 'ssl.cafile'?: string | string[];
320 'ssl.certfile'?: string | string[];
321 'ssl.keyfile'?: string | string[];
322 'urls.api'?: string;
323 'urls.dash'?: string;
324 'git.host'?: string;
325 'git.port'?: number;
326 'git.setup'?: boolean;
327 'org.id'?: string;
328 'user.id'?: number;
329 'user.email'?: string;
330 'tokens.user'?: string;
331 'tokens.telemetry'?: string;
332 'features.ssl-commands'?: boolean;
333}
334export interface SSLConfig {
335 cafile?: string | string[];
336 certfile?: string | string[];
337 keyfile?: string | string[];
338}
339export interface CreateRequestOptions {
340 ssl?: SSLConfig;
341 proxy?: string;
342}
343export declare type APIResponse = APIResponseSuccess | APIResponseError;
344export interface APIResponseMeta {
345 status: number;
346 version: string;
347 request_id: string;
348}
349export declare type APIResponseData = object | object[] | string;
350export interface APIResponseErrorDetails {
351 error_type: string;
352 parameter: string;
353 errors: string[];
354}
355export interface APIResponseError {
356 error: APIResponseErrorError;
357 meta: APIResponseMeta;
358}
359export interface APIResponseErrorError {
360 message: string;
361 link: string | null;
362 type: string;
363 details?: APIResponseErrorDetails[];
364}
365export interface APIResponseSuccess {
366 data: APIResponseData;
367 meta: APIResponseMeta;
368}
369export interface APIResponsePageTokenMeta extends APIResponseMeta {
370 prev_page_token?: string;
371 next_page_token?: string;
372}
373export declare type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'PURGE' | 'HEAD' | 'OPTIONS';
374export interface IClient {
375 config: IConfig;
376 make(method: HttpMethod, path: string): Promise<{
377 req: SuperAgentRequest;
378 }>;
379 do(req: SuperAgentRequest): Promise<APIResponseSuccess>;
380 paginate<T extends Response<object[]>>(args: PaginateArgs<T>): IPaginator<T>;
381}
382export declare type PaginateArgs<T extends Response<object[]>> = Pick<PaginatorDeps<T>, 'reqgen' | 'guard' | 'state' | 'max'>;
383export interface IPaginator<T extends Response<object[]>, S = PaginatorState> extends IterableIterator<Promise<T>> {
384 readonly state: S;
385}
386export declare type PaginatorRequestGenerator = () => Promise<{
387 req: SuperAgentRequest;
388}>;
389export declare type PaginatorGuard<T extends Response<object[]>> = (res: APIResponseSuccess) => res is T;
390export interface PaginatorState {
391 done: boolean;
392 loaded: number;
393}
394export interface PagePaginatorState extends PaginatorState {
395 page: number;
396 page_size?: number;
397}
398export interface TokenPaginatorState extends PaginatorState {
399 page_token?: string;
400}
401export interface PaginatorDeps<T extends Response<object[]>, S = PaginatorState> {
402 readonly client: IClient;
403 readonly reqgen: PaginatorRequestGenerator;
404 readonly guard: PaginatorGuard<T>;
405 readonly state?: Partial<S>;
406 readonly max?: number;
407}
408export declare type InfoItemGroup = 'ionic' | 'capacitor' | 'cordova' | 'utility' | 'system' | 'environment';
409export interface InfoItem {
410 group: InfoItemGroup;
411 name: string;
412 value: string;
413 key?: string;
414 flair?: string;
415 path?: string;
416 hidden?: boolean;
417}
418export interface BaseBuildOptions {
419 engine: string;
420 platform?: string;
421 project?: string;
422 verbose?: boolean;
423 '--': string[];
424}
425export interface BuildOptions<T extends ProjectType> extends BaseBuildOptions {
426 type: T;
427}
428export interface AngularBuildOptions extends BuildOptions<'angular'> {
429 /**
430 * The Angular architect configuration to use for builds.
431 *
432 * The `--prod` command line flag is a shortcut which translates to the
433 * 'production' configuration.
434 */
435 configuration?: string;
436 sourcemaps?: boolean;
437 cordovaAssets?: boolean;
438 watch?: boolean;
439}
440export interface ReactBuildOptions extends BuildOptions<'react'> {
441 publicUrl?: string;
442 ci?: boolean;
443 sourceMap?: boolean;
444 inlineRuntimeChunk?: boolean;
445}
446export interface VueBuildOptions extends BuildOptions<'vue'> {
447 configuration?: string;
448 sourcemaps?: boolean;
449 cordovaAssets?: boolean;
450}
451export interface IonicAngularBuildOptions extends BuildOptions<'ionic-angular'> {
452 prod: boolean;
453 sourcemaps?: boolean;
454 aot: boolean;
455 minifyjs: boolean;
456 minifycss: boolean;
457 optimizejs: boolean;
458 env?: string;
459}
460export interface Ionic1BuildOptions extends BuildOptions<'ionic1'> {
461}
462export interface CustomBuildOptions extends BuildOptions<'custom'> {
463}
464export interface GenerateOptions {
465 type: string;
466 name: string;
467}
468export interface AngularGenerateOptions extends GenerateOptions {
469 [key: string]: any;
470}
471export interface IonicAngularGenerateOptions extends GenerateOptions {
472 module: boolean;
473 constants: boolean;
474}
475export interface ServeOptions {
476 address: string;
477 port: number;
478 livereload: boolean;
479 proxy: boolean;
480 lab: boolean;
481 labHost: string;
482 labPort: number;
483 open: boolean;
484 browser?: string;
485 browserOption?: string;
486 devapp: boolean;
487 platform?: string;
488 project?: string;
489 verbose?: boolean;
490 '--': string[];
491 externalAddressRequired?: boolean;
492 engine: string;
493}
494export interface AngularServeOptions extends ServeOptions {
495 consolelogs?: boolean;
496 consolelogsPort?: number;
497 ssl?: boolean;
498 configuration?: string;
499 sourcemaps?: boolean;
500}
501export interface ReactServeOptions extends ServeOptions {
502 https?: boolean;
503 ci?: boolean;
504 reactEditor?: string;
505}
506export interface VueServeOptions extends ServeOptions {
507 ssl?: boolean;
508 configuration?: string;
509 sourcemaps?: boolean;
510}
511export interface IonicAngularServeOptions extends ServeOptions {
512 sourcemaps?: boolean;
513 consolelogs: boolean;
514 serverlogs: boolean;
515 env?: string;
516 livereloadPort: number;
517 notificationPort: number;
518}
519export interface Ionic1ServeOptions extends ServeOptions {
520 consolelogs: boolean;
521 serverlogs: boolean;
522 livereloadPort: number;
523 notificationPort: number;
524}
525export interface CustomServeOptions extends ServeOptions {
526}
527export interface LabServeDetails {
528 projectType: ProjectType;
529 address: string;
530 port: number;
531}
532export interface DevAppDetails {
533 channel?: string;
534 port: number;
535 commPort: number;
536 interfaces: {
537 address: string;
538 broadcast: string;
539 }[];
540}
541export interface ServeDetails {
542 custom: boolean;
543 protocol: string;
544 localAddress: string;
545 externalAddress: string;
546 port: number;
547 externalNetworkInterfaces: NetworkInterface[];
548 externallyAccessible: boolean;
549}
550export interface IAilment {
551 readonly id: string;
552 implicit: boolean;
553 projects?: ProjectType[];
554 getMessage(): Promise<string>;
555 detected(): Promise<boolean>;
556 getTreatmentSteps(): Promise<PatientTreatmentStep[]>;
557}
558export interface TreatableAilment extends IAilment {
559 readonly treatable: boolean;
560 getTreatmentSteps(): Promise<DoctorTreatmentStep[]>;
561}
562export interface PatientTreatmentStep {
563 message: string;
564}
565export interface DoctorTreatmentStep extends PatientTreatmentStep {
566 treat(): Promise<void>;
567}
568export interface IAilmentRegistry {
569 ailments: IAilment[];
570 register(ailment: IAilment): void;
571 get(id: string): IAilment | undefined;
572}
573export interface IonicContext {
574 readonly binPath: string;
575 readonly libPath: string;
576 readonly execPath: string;
577 readonly version: string;
578}
579export interface IonicEnvironment {
580 readonly flags: IonicEnvironmentFlags;
581 readonly client: IClient;
582 readonly config: IConfig;
583 readonly log: ILogger;
584 readonly prompt: PromptModule;
585 readonly ctx: IonicContext;
586 readonly session: ISession;
587 readonly shell: IShell;
588 getInfo(): Promise<InfoItem[]>;
589}
590export interface IonicEnvironmentFlags {
591 readonly interactive: boolean;
592 readonly confirm: boolean;
593}
594export declare type DistTag = 'testing' | 'canary' | 'latest';
595export interface ICommand extends FrameworkCommand<ICommand, INamespace, CommandMetadata, CommandMetadataInput, CommandMetadataOption> {
596 readonly env: IonicEnvironment;
597 readonly project?: IProject;
598 execute(inputs: CommandLineInputs, options: CommandLineOptions, metadata: CommandInstanceInfo): Promise<void>;
599}
600export interface CommandPreRun extends ICommand {
601 preRun(inputs: CommandLineInputs, options: CommandLineOptions, metadata: CommandInstanceInfo): Promise<void>;
602}
603export interface INamespace extends FrameworkNamespace<ICommand, INamespace, CommandMetadata, CommandMetadataInput, CommandMetadataOption> {
604 env: IonicEnvironment;
605 project?: IProject;
606}
607export interface ImageResource {
608 platform: string;
609 imageId?: string;
610 dest: string;
611 resType: string;
612 nodeName: string;
613 nodeAttributes: string[];
614 name: string;
615 width: number;
616 height: number;
617 density?: string;
618 orientation?: 'landscape' | 'portrait';
619}
620export interface ImageResourceTransformResult {
621 resource: ImageResource;
622 error?: Error;
623 tmpDest: string;
624}
625export interface ResourcesImageConfig {
626 name: string;
627 width: number;
628 height: number;
629 density?: string;
630 orientation?: 'landscape' | 'portrait';
631}
632export interface SourceImage {
633 ext: string;
634 imageId?: string;
635 cachedId?: string;
636 platform: string;
637 resType: string;
638 path: string;
639 vector: boolean;
640 width: number;
641 height: number;
642}
643export interface ImageUploadResponse {
644 Error: string;
645 Width: number;
646 Height: number;
647 Type: string;
648 Vector: boolean;
649}
650export interface ResourcesPlatform {
651 [imgType: string]: {
652 images: ResourcesImageConfig[];
653 nodeName: string;
654 nodeAttributes: string[];
655 };
656}
657export interface ResourcesConfig {
658 [propName: string]: ResourcesPlatform;
659}
660export declare type KnownPlatform = 'ios' | 'android' | 'wp8' | 'windows' | 'browser';
661export declare type KnownResourceType = 'icon' | 'splash';
662export interface StarterList {
663 starters: {
664 name: string;
665 id: string;
666 type: ProjectType;
667 }[];
668 integrations: {
669 name: IntegrationName;
670 id: string;
671 }[];
672}
673export interface BaseStarterTemplate {
674 name: string;
675 projectType: ProjectType;
676 description?: string;
677}
678export interface RepoStarterTemplate extends BaseStarterTemplate {
679 type: 'repo';
680 repo: string;
681}
682export interface ManagedStarterTemplate extends BaseStarterTemplate {
683 type: 'managed';
684 id: string;
685}
686export declare type StarterTemplate = RepoStarterTemplate | ManagedStarterTemplate;
687export interface ResolvedStarterTemplate extends BaseStarterTemplate {
688 archive: string;
689}
690export interface TelemetryIPCMessage {
691 type: 'telemetry';
692 data: {
693 command: string;
694 args: string[];
695 };
696}
697export interface UpdateCheckIPCMessage {
698 type: 'update-check';
699}
700export declare type IPCMessage = TelemetryIPCMessage | UpdateCheckIPCMessage;