UNPKG

6.09 kBTypeScriptView Raw
1import * as spec from '@jsii/spec';
2import * as reflect from 'jsii-reflect';
3import { RosettaTabletReader } from 'jsii-rosetta';
4import { IGenerator } from './generator';
5export declare abstract class Target {
6 protected readonly packageDir: string;
7 protected readonly fingerprint: boolean;
8 protected readonly force: boolean;
9 protected readonly arguments: {
10 [name: string]: any;
11 };
12 protected readonly targetName: string;
13 protected readonly assembly: reflect.Assembly;
14 protected readonly rosetta: RosettaTabletReader;
15 protected readonly runtimeTypeChecking: boolean;
16 protected abstract readonly generator: IGenerator;
17 constructor(options: TargetOptions);
18 /**
19 * Emits code artifacts.
20 *
21 * @param outDir the directory where the generated source will be placed.
22 */
23 generateCode(outDir: string, tarball: string): Promise<void>;
24 /**
25 * Builds the generated code.
26 *
27 * @param sourceDir the directory where the generated source was put.
28 * @param outDir the directory where the build artifacts will be placed.
29 */
30 abstract build(sourceDir: string, outDir: string): Promise<void>;
31 /**
32 * A utility to copy files from one directory to another.
33 *
34 * @param sourceDir the directory to copy from.
35 * @param targetDir the directory to copy into.
36 */
37 protected copyFiles(sourceDir: string, targetDir: string): Promise<void>;
38 /**
39 * Traverses the dep graph and returns a list of pacmak output directories
40 * available locally for this specific target. This allows target builds to
41 * take local dependencies in case a dependency is checked-out.
42 *
43 * @param packageDir The directory of the package to resolve from.
44 */
45 protected findLocalDepsOutput(rootPackageDir: string): Promise<string[]>;
46}
47/**
48 * Traverses the dep graph and returns a list of pacmak output directories
49 * available locally for this specific target. This allows target builds to
50 * take local dependencies in case a dependency is checked-out.
51 *
52 * @param packageDir The directory of the package to resolve from.
53 */
54export declare function findLocalBuildDirs(rootPackageDir: string, targetName: string): Promise<string[]>;
55export interface TargetConstructor {
56 /**
57 * Provides information about an assembly in the usual package repositories for the target. This includes information
58 * necessary to locate the package in the repositories (a URL to the repository's public endpoint), as well as usage
59 * instructions for the various configruation files (e.g: Maven POM, Gemfile, ...) and/or installation instructions
60 * using the standard command line tools (npm, yarn, ...).
61 *
62 * @param assm the assembly for which coodinates are requested.
63 *
64 * @return Information about the assembly in the various package managers supported for a given language. The return
65 * value is a hash, as some packages can be used across different languages (typescript & javascript, java &
66 * scala & clojure & kotlin...).
67 */
68 toPackageInfos?: (assm: spec.Assembly) => {
69 [language: string]: PackageInfo;
70 };
71 /**
72 * Provides the native way to reference a Type, for example a Java import statement, or a Javscript require directive.
73 * Particularly useful when generating documentation.
74 *
75 * @param type the JSII type for which a native reference is requested.
76 * @param options the target-specific options provided.
77 *
78 * @return the native reference for the target for each supported language (there can be multiple languages
79 * supported by a given target: typescript & javascript, java & scala & clojure & kotlin, ...)
80 */
81 toNativeReference?: (type: spec.Type, options: any) => {
82 [language: string]: string | undefined;
83 };
84 new (options: TargetOptions): Target;
85}
86/**
87 * Information about a package
88 */
89export interface PackageInfo {
90 /** The name by which the package repository is known */
91 repository: string;
92 /** The URL to the package within it's repository */
93 url: string;
94 /**
95 * Configuration fragments or installation instructions, by client scenario (e.g: maven + gradle). Values can be a
96 * plain string (documentation should render as a pre-formatted block of text using monospace font), or an object
97 * describing a language-tagged block of code.
98 *
99 * @example {
100 * maven: {
101 * language: 'xml',
102 * code: '<dependency><groupId>grp</groupId><artifactId>art</artifactId><version>version</version></dependency>'
103 * },
104 * gradle: "compile 'grp:art:version'",
105 * }
106 *
107 * @example {
108 * npm: { language: 'console', code: '$ npm install pkg' },
109 * yarn: { language: 'console', code: '$ yarn add pkg' },
110 * 'package.json': { language: json, code: '{"pkg": "^version" }' }
111 * }
112 */
113 usage: {
114 [label: string]: string | {
115 language: string;
116 code: string;
117 };
118 };
119}
120export interface TargetOptions {
121 /** The name of the target language we are generating */
122 targetName: string;
123 /** The directory where the JSII package is located */
124 packageDir: string;
125 /** The JSII-reflect assembly for this JSII assembly */
126 assembly: reflect.Assembly;
127 /** The Rosetta instance */
128 rosetta: RosettaTabletReader;
129 /** Whether to generate runtime type-checking code */
130 runtimeTypeChecking: boolean;
131 /**
132 * Whether to fingerprint the produced artifacts.
133 * @default true
134 */
135 fingerprint?: boolean;
136 /**
137 * Whether artifacts should be re-build even if their fingerprints look up-to-date.
138 * @default false
139 */
140 force?: boolean;
141 /**
142 * Arguments provided by the user (how they are used is target-dependent)
143 */
144 arguments: {
145 [name: string]: any;
146 };
147}
148//# sourceMappingURL=target.d.ts.map
\No newline at end of file