@travetto/manifest 4.0.1 → 4.0.3
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/package.json +1 -1
- package/src/module.ts +18 -5
- package/src/types/manifest.ts +3 -1
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -26,6 +26,17 @@ const INDEX_FILES = new Set(
|
|
|
26
26
|
const STD_TOP_FOLDERS = new Set(['src', 'bin', 'support']);
|
|
27
27
|
const STD_TOP_FILES = new Set([...INDEX_FILES, 'package.json']);
|
|
28
28
|
|
|
29
|
+
const SUPPORT_FILE_MAP: Record<string, ManifestModuleRole> = {
|
|
30
|
+
transformer: 'compile',
|
|
31
|
+
compile: 'compile',
|
|
32
|
+
test: 'test',
|
|
33
|
+
doc: 'doc',
|
|
34
|
+
pack: 'build',
|
|
35
|
+
FILEld: 'build'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const SUPPORT_FILE_RE = new RegExp(`^support[/](?<name>${Object.keys(SUPPORT_FILE_MAP).join('|')})[./]`);
|
|
39
|
+
|
|
29
40
|
export class ManifestModuleUtil {
|
|
30
41
|
|
|
31
42
|
static #scanCache: Record<string, string[]> = {};
|
|
@@ -121,9 +132,10 @@ export class ManifestModuleUtil {
|
|
|
121
132
|
* Get file type for a file name
|
|
122
133
|
*/
|
|
123
134
|
static getFileRole(moduleFile: string): ManifestModuleRole | undefined {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
135
|
+
const matched = SUPPORT_FILE_MAP[moduleFile.match(SUPPORT_FILE_RE)?.groups?.name ?? ''];
|
|
136
|
+
if (matched) {
|
|
137
|
+
return matched;
|
|
138
|
+
} else if (moduleFile.startsWith('test/')) {
|
|
127
139
|
return 'test';
|
|
128
140
|
} else if (moduleFile.startsWith('doc/') || /^DOC[.]tsx?$/.test(moduleFile)) {
|
|
129
141
|
return 'doc';
|
|
@@ -144,7 +156,7 @@ export class ManifestModuleUtil {
|
|
|
144
156
|
return 'support/fixtures';
|
|
145
157
|
} else if (moduleFile.startsWith('support/resources/')) {
|
|
146
158
|
return 'support/resources';
|
|
147
|
-
} else if (moduleFile
|
|
159
|
+
} else if (/^support\/transformer[./]/.test(moduleFile)) {
|
|
148
160
|
return '$transformer';
|
|
149
161
|
}
|
|
150
162
|
const key = moduleFile.substring(0, folderLocation);
|
|
@@ -172,7 +184,8 @@ export class ManifestModuleUtil {
|
|
|
172
184
|
* Convert file (by ext) to a known file type and also retrieve its latest timestamp
|
|
173
185
|
*/
|
|
174
186
|
static async transformFile(moduleFile: string, full: string): Promise<ManifestModuleFile> {
|
|
175
|
-
const
|
|
187
|
+
const updated = this.#getNewest(await fs.stat(full).catch(() => ({ mtimeMs: 0, ctimeMs: 0 })));
|
|
188
|
+
const res: ManifestModuleFile = [moduleFile, this.getFileType(moduleFile), updated];
|
|
176
189
|
const role = this.getFileRole(moduleFile);
|
|
177
190
|
return role ? [...res, role] : res;
|
|
178
191
|
}
|
package/src/types/manifest.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type { ManifestModuleFileType, ManifestModuleFolderType, ManifestModuleRo
|
|
|
2
2
|
import type { ManifestContext } from './context';
|
|
3
3
|
import { Package } from './package';
|
|
4
4
|
|
|
5
|
-
export type ManifestModuleFile =
|
|
5
|
+
export type ManifestModuleFile =
|
|
6
|
+
[path: string, type: ManifestModuleFileType, updated: number] |
|
|
7
|
+
[path: string, type: ManifestModuleFileType, updated: number, role: ManifestModuleRole];
|
|
6
8
|
|
|
7
9
|
export type ManifestDepCore = {
|
|
8
10
|
/** Package name */
|