UNPKG

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