@keymanapp/kmc-copy 18.0.138-alpha
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/build/src/KeymanProjectCopier.d.ts +145 -0
- package/build/src/KeymanProjectCopier.d.ts.map +1 -0
- package/build/src/KeymanProjectCopier.js +551 -0
- package/build/src/KeymanProjectCopier.js.map +1 -0
- package/build/src/cloud.d.ts +26 -0
- package/build/src/cloud.d.ts.map +1 -0
- package/build/src/cloud.js +126 -0
- package/build/src/cloud.js.map +1 -0
- package/build/src/copier-async-callbacks.d.ts +21 -0
- package/build/src/copier-async-callbacks.d.ts.map +1 -0
- package/build/src/copier-async-callbacks.js +113 -0
- package/build/src/copier-async-callbacks.js.map +1 -0
- package/build/src/copier-messages.d.ts +130 -0
- package/build/src/copier-messages.d.ts.map +1 -0
- package/build/src/copier-messages.js +91 -0
- package/build/src/copier-messages.js.map +1 -0
- package/build/src/main.d.ts +3 -0
- package/build/src/main.d.ts.map +1 -0
- package/build/src/main.js +6 -0
- package/build/src/main.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { CompilerCallbacks, CompilerLogLevel, KeymanCompiler, KeymanCompilerArtifact, KeymanCompilerArtifacts, KeymanCompilerResult } from "@keymanapp/developer-utils";
|
|
2
|
+
import { CopierAsyncCallbacks } from "./copier-async-callbacks.js";
|
|
3
|
+
import { GitHubRef, KeymanCloudSource } from "./cloud.js";
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* Options for the Keyman Developer project copier
|
|
7
|
+
*/
|
|
8
|
+
export interface CopierOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Reporting level to console, used by NodeCompilerCallbacks (not used in
|
|
11
|
+
* compiler modules; all messages are still reported to the internal log)
|
|
12
|
+
*/
|
|
13
|
+
logLevel?: CompilerLogLevel;
|
|
14
|
+
/**
|
|
15
|
+
* output path where project folder will be created
|
|
16
|
+
*/
|
|
17
|
+
outPath: string;
|
|
18
|
+
/**
|
|
19
|
+
* dryRun: show what would happen
|
|
20
|
+
*/
|
|
21
|
+
dryRun: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
* Internal in-memory build artifacts from a successful copy
|
|
26
|
+
*/
|
|
27
|
+
export interface CopierArtifacts extends KeymanCompilerArtifacts {
|
|
28
|
+
/**
|
|
29
|
+
* The target path for the copy, equal to the normalized output path.
|
|
30
|
+
* This folder must not exist before `write()`. This pattern is
|
|
31
|
+
* used to avoid name collisions with other artifacts
|
|
32
|
+
*/
|
|
33
|
+
['kmc-copy:outputPath']: KeymanCompilerArtifact;
|
|
34
|
+
/**
|
|
35
|
+
* Copied project files to be written to disk
|
|
36
|
+
*/
|
|
37
|
+
[name: string]: KeymanCompilerArtifact;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
* Result of a successful copy
|
|
42
|
+
*/
|
|
43
|
+
export interface CopierResult extends KeymanCompilerResult {
|
|
44
|
+
/**
|
|
45
|
+
* Internal in-memory build artifacts from a successful compilation. Caller
|
|
46
|
+
* can write these to disk with {@link KeymanProjectCopier.write}
|
|
47
|
+
*/
|
|
48
|
+
artifacts: CopierArtifacts;
|
|
49
|
+
}
|
|
50
|
+
export declare class KeymanProjectCopier implements KeymanCompiler {
|
|
51
|
+
options: CopierOptions;
|
|
52
|
+
callbacks: CompilerCallbacks;
|
|
53
|
+
asyncCallbacks: CopierAsyncCallbacks;
|
|
54
|
+
sourceId: string;
|
|
55
|
+
outputId: string;
|
|
56
|
+
outPath: string;
|
|
57
|
+
githubRef: GitHubRef;
|
|
58
|
+
cloudSource: KeymanCloudSource;
|
|
59
|
+
isLocalOrigin(): boolean;
|
|
60
|
+
relocateExternalFiles: boolean;
|
|
61
|
+
init(callbacks: CompilerCallbacks, options: CopierOptions): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Copy a Keyman project. Returns an object containing binary
|
|
64
|
+
* artifacts on success. The files are passed in by name, and the compiler
|
|
65
|
+
* will use callbacks as passed to the {@link KeymanProjectCopier.init}
|
|
66
|
+
* function to read any input files by disk.
|
|
67
|
+
* @param source Source file or folder to copy. Can be a local file or folder, github:repo[:path], or cloud:id
|
|
68
|
+
* @returns Binary artifacts on success, null on failure.
|
|
69
|
+
*/
|
|
70
|
+
run(source: string): Promise<CopierResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the source project file to either a local filesystem file,
|
|
73
|
+
* or a reference on GitHub
|
|
74
|
+
* @param source
|
|
75
|
+
* @returns path to .kpj (either local or remote)
|
|
76
|
+
*/
|
|
77
|
+
private getSourceProject;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve source path to the contained project file; the project
|
|
80
|
+
* file must have the same basename as the folder in this case
|
|
81
|
+
* @param source
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
private getLocalFolderProject;
|
|
85
|
+
/**
|
|
86
|
+
* Resolve source path to the input .kpj filename, folder name
|
|
87
|
+
* is not relevant when .kpj filename is passed in
|
|
88
|
+
* @param source
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
private getLocalFileProject;
|
|
92
|
+
/**
|
|
93
|
+
* Resolve path to GitHub source, which must be in the following format:
|
|
94
|
+
* `github:owner/repo[:branch]:path/to/kpj`
|
|
95
|
+
* The path must be fully qualified, referencing the .kpj file; it
|
|
96
|
+
* cannot just be the folder where the .kpj is found
|
|
97
|
+
* @param source
|
|
98
|
+
* @returns a promise: GitHub reference to the source for the keyboard, or null on failure
|
|
99
|
+
*/
|
|
100
|
+
private getGitHubSourceProject;
|
|
101
|
+
/**
|
|
102
|
+
* Resolve path to Keyman Cloud source (which is on GitHub), which must be in
|
|
103
|
+
* the following format:
|
|
104
|
+
* `cloud:keyboard_id|model_id`
|
|
105
|
+
* The `keyboard_id` parameter should be a valid id (a-z0-9_), as found at
|
|
106
|
+
* https://keyman.com/keyboards; alternativel if it is a model_id, it should
|
|
107
|
+
* have the format author.bcp47.uniq
|
|
108
|
+
* @param source
|
|
109
|
+
* @returns a promise: GitHub reference to the source for the keyboard, or null on failure
|
|
110
|
+
*/
|
|
111
|
+
private getCloudSourceProject;
|
|
112
|
+
private normalizePath;
|
|
113
|
+
private verifyOutputPath;
|
|
114
|
+
private copiers;
|
|
115
|
+
private copyFolder;
|
|
116
|
+
private resolveFilename;
|
|
117
|
+
private copyProjectFile;
|
|
118
|
+
private copyGenericFile;
|
|
119
|
+
private copySourceFile;
|
|
120
|
+
private copyModelTsSourceFile;
|
|
121
|
+
private copyKmnSourceFile;
|
|
122
|
+
private copyKpsSourceFile;
|
|
123
|
+
private copySubFileAndGetRelativePath;
|
|
124
|
+
private splitFilename;
|
|
125
|
+
/**
|
|
126
|
+
* renames matching filename to the output filename pattern, and prepends the
|
|
127
|
+
* outputPath
|
|
128
|
+
* @param filename
|
|
129
|
+
* @param outputPath
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
private generateNewFilename;
|
|
133
|
+
private calculateNewFilePath;
|
|
134
|
+
private loadProjectFromFile;
|
|
135
|
+
/**
|
|
136
|
+
* Write artifacts from a successful compile to disk, via callbacks methods.
|
|
137
|
+
* The artifacts written will include all files from the project, across
|
|
138
|
+
* multiple folders. Folders will be created as needed
|
|
139
|
+
*
|
|
140
|
+
* @param artifacts - object containing artifact binary data to write out
|
|
141
|
+
* @returns true on success
|
|
142
|
+
*/
|
|
143
|
+
write(artifacts: CopierArtifacts): Promise<boolean>;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=KeymanProjectCopier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeymanProjectCopier.d.ts","sourceRoot":"","sources":["../../src/KeymanProjectCopier.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,oBAAoB,EAAqH,MAA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