@travetto/manifest 3.4.0 → 4.0.0-rc.1
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/LICENSE +1 -1
- package/README.md +35 -24
- package/__index__.ts +6 -3
- package/bin/context.d.ts +1 -1
- package/bin/context.js +68 -58
- package/package.json +4 -2
- package/src/delta.ts +15 -14
- package/src/dependencies.ts +88 -106
- package/src/file.ts +4 -24
- package/src/manifest-index.ts +49 -57
- package/src/module.ts +29 -40
- package/src/package.ts +59 -93
- package/src/path.ts +3 -3
- package/src/{root-index.ts → runtime.ts} +53 -39
- package/src/types/common.ts +20 -0
- package/src/types/context.ts +40 -0
- package/src/types/manifest.ts +79 -0
- package/src/types/package.ts +75 -0
- package/src/util.ts +107 -35
- package/support/transformer.function-metadata.ts +8 -8
- package/src/types.ts +0 -118
- /package/src/{typings.d.ts → global.d.ts} +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -30,12 +30,12 @@ During the compilation process, the compiler needs to know every file that is el
|
|
|
30
30
|
Additionally, once the code has been compiled (or even bundled after that), the executing process needs to know what files are available for loading, and any patterns necessary for knowing which files to load versus which ones to ignore. This allows for dynamic loading of modules/files without knowledge/access to the file system, and in a more performant manner.
|
|
31
31
|
|
|
32
32
|
## Manifest Delta
|
|
33
|
-
During the compilation process, it is helpful to know how the output content differs from the manifest, which is produced from the source input. The [ManifestDeltaUtil](https://github.com/travetto/travetto/tree/main/module/manifest/src/delta.ts#
|
|
33
|
+
During the compilation process, it is helpful to know how the output content differs from the manifest, which is produced from the source input. The [ManifestDeltaUtil](https://github.com/travetto/travetto/tree/main/module/manifest/src/delta.ts#L21) provides the functionality for a given manifest, and will produce a stream of changes grouped by module. This is the primary input into the [Compiler](https://github.com/travetto/travetto/tree/main/module/compiler#readme "The compiler infrastructure for the Travetto framework")'s incremental behavior to know when a file has changed and needs to be recompiled.
|
|
34
34
|
|
|
35
35
|
## Class and Function Metadata
|
|
36
36
|
For the framework to work properly, metadata needs to be collected about files, classes and functions to uniquely identify them, with support for detecting changes during live reloads. To achieve this, every `class` is decorated with an additional field of `Ⲑid`. `Ⲑid` represents a computed id that is tied to the file/class combination.
|
|
37
37
|
|
|
38
|
-
`Ⲑid` is used heavily throughout the framework for determining which classes are owned by the framework, and being able to lookup the needed data from the [
|
|
38
|
+
`Ⲑid` is used heavily throughout the framework for determining which classes are owned by the framework, and being able to lookup the needed data from the [RuntimeIndex](https://github.com/travetto/travetto/tree/main/module/manifest/src/runtime.ts#L14) using the `getFunctionMetadata` method.
|
|
39
39
|
|
|
40
40
|
**Code: Test Class**
|
|
41
41
|
```typescript
|
|
@@ -50,10 +50,10 @@ export class TestClass {
|
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
exports.TestClass = void 0;
|
|
52
52
|
const tslib_1 = require("tslib");
|
|
53
|
-
const Ⲑ
|
|
53
|
+
const Ⲑ_runtime_1 = tslib_1.__importStar(require("@travetto/manifest/src/runtime.js"));
|
|
54
54
|
var ᚕf = "@travetto/manifest/doc/test-class.js";
|
|
55
55
|
class TestClass {
|
|
56
|
-
static Ⲑinit = Ⲑ
|
|
56
|
+
static Ⲑinit = Ⲑ_runtime_1.RuntimeIndex.registerFunction(TestClass, ᚕf, 197152026, { doStuff: { hash: 51337554 } }, false, false);
|
|
57
57
|
async doStuff() { }
|
|
58
58
|
}
|
|
59
59
|
exports.TestClass = TestClass;
|
|
@@ -92,31 +92,39 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
92
92
|
```typescript
|
|
93
93
|
{
|
|
94
94
|
"generated": 1868155200000,
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
"workspace": {
|
|
96
|
+
"name": "@travetto/mono-repo",
|
|
97
|
+
"path": "<generated>",
|
|
98
|
+
"mono": true,
|
|
99
|
+
"manager": "npm",
|
|
100
|
+
"type": "commonjs",
|
|
101
|
+
"defaultEnv": "local"
|
|
102
|
+
},
|
|
103
|
+
"build": {
|
|
104
|
+
"compilerFolder": ".trv/compiler",
|
|
105
|
+
"compilerUrl": "http://127.0.0.1:26803",
|
|
106
|
+
"compilerModuleFolder": "module/compiler",
|
|
107
|
+
"outputFolder": ".trv/output",
|
|
108
|
+
"toolFolder": ".trv/tool"
|
|
109
|
+
},
|
|
110
|
+
"main": {
|
|
111
|
+
"name": "@travetto/manifest",
|
|
112
|
+
"folder": "module/manifest",
|
|
113
|
+
"version": "x.x.x",
|
|
114
|
+
"description": "Support for project indexing, manifesting, along with file watching"
|
|
115
|
+
},
|
|
108
116
|
"modules": {
|
|
109
117
|
"@travetto/manifest": {
|
|
110
118
|
"main": true,
|
|
119
|
+
"prod": true,
|
|
111
120
|
"name": "@travetto/manifest",
|
|
112
121
|
"version": "x.x.x",
|
|
113
|
-
"
|
|
122
|
+
"workspace": true,
|
|
114
123
|
"internal": false,
|
|
115
124
|
"sourceFolder": "module/manifest",
|
|
116
125
|
"outputFolder": "node_modules/@travetto/manifest",
|
|
117
126
|
"roles": [ "std" ],
|
|
118
127
|
"parents": [],
|
|
119
|
-
"prod": true,
|
|
120
128
|
"files": {
|
|
121
129
|
"$root": [
|
|
122
130
|
[ "DOC.html", "unknown", 1868155200000 ],
|
|
@@ -136,7 +144,7 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
136
144
|
],
|
|
137
145
|
"test": [
|
|
138
146
|
[ "test/path.ts", "ts", 1868155200000, "test" ],
|
|
139
|
-
[ "test/
|
|
147
|
+
[ "test/runtime.ts", "ts", 1868155200000, "test" ]
|
|
140
148
|
],
|
|
141
149
|
"test/fixtures": [
|
|
142
150
|
[ "test/fixtures/simple.ts", "fixture", 1868155200000, "test" ]
|
|
@@ -148,14 +156,17 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
148
156
|
[ "src/delta.ts", "ts", 1868155200000 ],
|
|
149
157
|
[ "src/dependencies.ts", "ts", 1868155200000 ],
|
|
150
158
|
[ "src/file.ts", "ts", 1868155200000 ],
|
|
159
|
+
[ "src/global.d.ts", "typings", 1868155200000 ],
|
|
151
160
|
[ "src/manifest-index.ts", "ts", 1868155200000 ],
|
|
152
161
|
[ "src/module.ts", "ts", 1868155200000 ],
|
|
153
162
|
[ "src/package.ts", "ts", 1868155200000 ],
|
|
154
163
|
[ "src/path.ts", "ts", 1868155200000 ],
|
|
155
|
-
[ "src/
|
|
156
|
-
[ "src/
|
|
157
|
-
[ "src/
|
|
158
|
-
[ "src/
|
|
164
|
+
[ "src/runtime.ts", "ts", 1868155200000 ],
|
|
165
|
+
[ "src/util.ts", "ts", 1868155200000 ],
|
|
166
|
+
[ "src/types/common.ts", "ts", 1868155200000 ],
|
|
167
|
+
[ "src/types/context.ts", "ts", 1868155200000 ],
|
|
168
|
+
[ "src/types/manifest.ts", "ts", 1868155200000 ],
|
|
169
|
+
[ "src/types/package.ts", "ts", 1868155200000 ]
|
|
159
170
|
],
|
|
160
171
|
"bin": [
|
|
161
172
|
[ "bin/context.d.ts", "typings", 1868155200000 ],
|
package/__index__.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
/// <reference path="./src/
|
|
1
|
+
/// <reference path="./src/global.d.ts" />
|
|
2
2
|
|
|
3
3
|
export * from './src/path';
|
|
4
4
|
export * from './src/module';
|
|
5
5
|
export * from './src/delta';
|
|
6
6
|
export * from './src/manifest-index';
|
|
7
|
-
export * from './src/
|
|
7
|
+
export * from './src/runtime';
|
|
8
8
|
export * from './src/package';
|
|
9
9
|
export * from './src/util';
|
|
10
10
|
export * from './src/file';
|
|
11
|
-
export * from './src/types';
|
|
11
|
+
export * from './src/types/context';
|
|
12
|
+
export * from './src/types/package';
|
|
13
|
+
export * from './src/types/manifest';
|
|
14
|
+
export * from './src/types/common';
|
package/bin/context.d.ts
CHANGED
package/bin/context.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {import('../src/types').Package & { path:string }} Pkg
|
|
4
|
+
* @typedef {import('../src/types/package').Package & { path:string }} Pkg
|
|
5
5
|
* @typedef {Pkg & { mono: boolean, manager: 'yarn'|'npm', resolve: (file:string) => string}} Workspace
|
|
6
|
-
* @typedef {import('../src/types').ManifestContext} ManifestContext
|
|
6
|
+
* @typedef {import('../src/types/context').ManifestContext} ManifestContext
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import path from 'path';
|
|
10
|
-
import { createRequire } from 'module';
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { createRequire } from 'node:module';
|
|
11
11
|
|
|
12
12
|
/** @type {Record<string, Workspace>} */ const WS_ROOT = {};
|
|
13
13
|
const TOOL_FOLDER = '.trv/tool';
|
|
@@ -17,24 +17,26 @@ const OUTPUT_FOLDER = '.trv/output';
|
|
|
17
17
|
/**
|
|
18
18
|
* Read package.json or return undefined if missing
|
|
19
19
|
* @param {string} dir
|
|
20
|
-
* @returns {
|
|
20
|
+
* @returns {Pkg|undefined}
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
function $readPackage(dir) {
|
|
23
23
|
dir = dir.endsWith('.json') ? path.dirname(dir) : dir;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
try {
|
|
25
|
+
const v = readFileSync(path.resolve(dir, 'package.json'), 'utf8');
|
|
26
|
+
return ({ ...JSON.parse(v), path: path.resolve(dir) });
|
|
27
|
+
} catch { }
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* Find package.json for a given folder
|
|
30
32
|
* @param {string} dir
|
|
31
|
-
* @return {
|
|
33
|
+
* @return {Pkg}
|
|
32
34
|
*/
|
|
33
|
-
|
|
35
|
+
function $findPackage(dir) {
|
|
34
36
|
let prev;
|
|
35
37
|
let pkg, curr = path.resolve(dir);
|
|
36
38
|
while (!pkg && curr !== prev) {
|
|
37
|
-
pkg =
|
|
39
|
+
pkg = $readPackage(curr);
|
|
38
40
|
[prev, curr] = [curr, path.dirname(curr)];
|
|
39
41
|
}
|
|
40
42
|
if (!pkg) {
|
|
@@ -46,9 +48,9 @@ async function $findPackage(dir) {
|
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* Get workspace root
|
|
49
|
-
* @return {
|
|
51
|
+
* @return {Workspace}
|
|
50
52
|
*/
|
|
51
|
-
|
|
53
|
+
function $resolveWorkspace(base = process.cwd()) {
|
|
52
54
|
if (base in WS_ROOT) { return WS_ROOT[base]; }
|
|
53
55
|
let folder = base;
|
|
54
56
|
let prev;
|
|
@@ -57,10 +59,10 @@ async function $resolveWorkspace(base = process.cwd()) {
|
|
|
57
59
|
|
|
58
60
|
while (prev !== folder) {
|
|
59
61
|
[prev, prevPkg] = [folder, pkg];
|
|
60
|
-
pkg =
|
|
62
|
+
pkg = $readPackage(folder) ?? pkg;
|
|
61
63
|
if (
|
|
62
|
-
(pkg && (!!pkg.workspaces || !!pkg.travetto?.isolated)) || // if we have a monorepo root, or we are isolated
|
|
63
|
-
|
|
64
|
+
(pkg && (!!pkg.workspaces || !!pkg.travetto?.build?.isolated)) || // if we have a monorepo root, or we are isolated
|
|
65
|
+
existsSync(path.resolve(folder, '.git')) // we made it to the source repo root
|
|
64
66
|
) {
|
|
65
67
|
break;
|
|
66
68
|
}
|
|
@@ -73,29 +75,29 @@ async function $resolveWorkspace(base = process.cwd()) {
|
|
|
73
75
|
|
|
74
76
|
return WS_ROOT[base] = {
|
|
75
77
|
...pkg,
|
|
76
|
-
|
|
78
|
+
name: pkg.name ?? 'untitled',
|
|
79
|
+
type: pkg.type,
|
|
80
|
+
manager: existsSync(path.resolve(pkg.path, 'yarn.lock')) ? 'yarn' : 'npm',
|
|
77
81
|
resolve: createRequire(`${pkg.path}/node_modules`).resolve.bind(null),
|
|
78
|
-
mono: !!pkg.workspaces || (!pkg.travetto?.isolated && !!prevPkg) // Workspaces or nested projects
|
|
82
|
+
mono: !!pkg.workspaces || (!pkg.travetto?.build?.isolated && !!prevPkg) // Workspaces or nested projects
|
|
79
83
|
};
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/**
|
|
83
87
|
* Get Compiler url
|
|
84
88
|
* @param {Workspace} ws
|
|
89
|
+
* @param {string} toolFolder
|
|
85
90
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
95
|
-
await fs.writeFile(file, out, 'utf8');
|
|
96
|
-
}
|
|
91
|
+
function $getCompilerUrl(ws, toolFolder) {
|
|
92
|
+
const file = path.resolve(ws.path, toolFolder, 'build.compilerUrl');
|
|
93
|
+
// eslint-disable-next-line no-bitwise
|
|
94
|
+
const port = (Math.abs([...file].reduce((a, b) => (a * 33) ^ b.charCodeAt(0), 5381)) % 29000) + 20000;
|
|
95
|
+
const out = `http://localhost:${port}`;
|
|
96
|
+
if (!existsSync(file)) {
|
|
97
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
98
|
+
writeFileSync(file, out, 'utf8');
|
|
97
99
|
}
|
|
98
|
-
return out
|
|
100
|
+
return out;
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
/**
|
|
@@ -103,13 +105,16 @@ async function $getCompilerUrl(ws) {
|
|
|
103
105
|
* @param {Workspace} workspace
|
|
104
106
|
* @param {string|undefined} folder
|
|
105
107
|
*/
|
|
106
|
-
|
|
108
|
+
function $resolveModule(workspace, folder) {
|
|
107
109
|
let mod;
|
|
108
110
|
if (!folder && process.env.TRV_MODULE) {
|
|
109
111
|
mod = process.env.TRV_MODULE;
|
|
110
|
-
if (/[.](t|j)
|
|
111
|
-
|
|
112
|
-
.
|
|
112
|
+
if (/[.](t|j)sx?$/.test(mod)) { // Rewrite from file to module
|
|
113
|
+
try {
|
|
114
|
+
process.env.TRV_MODULE = mod = $findPackage(path.dirname(mod)).name;
|
|
115
|
+
} catch {
|
|
116
|
+
process.env.TRV_MODULE = mod = '';
|
|
117
|
+
}
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
|
|
@@ -117,7 +122,7 @@ async function $resolveModule(workspace, folder) {
|
|
|
117
122
|
try {
|
|
118
123
|
folder = path.dirname(workspace.resolve(`${mod}/package.json`));
|
|
119
124
|
} catch {
|
|
120
|
-
const workspacePkg =
|
|
125
|
+
const workspacePkg = $readPackage(workspace.path);
|
|
121
126
|
if (workspacePkg?.name === mod) {
|
|
122
127
|
folder = workspace.path;
|
|
123
128
|
} else {
|
|
@@ -132,30 +137,35 @@ async function $resolveModule(workspace, folder) {
|
|
|
132
137
|
/**
|
|
133
138
|
* Gets build context
|
|
134
139
|
* @param {string} [folder]
|
|
135
|
-
* @return {
|
|
140
|
+
* @return {ManifestContext}
|
|
136
141
|
*/
|
|
137
|
-
export
|
|
138
|
-
const workspace =
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
$readPackage(workspace.resolve('@travetto/manifest/package.json')),
|
|
143
|
-
$getCompilerUrl(workspace),
|
|
144
|
-
]);
|
|
142
|
+
export function getManifestContext(folder) {
|
|
143
|
+
const workspace = $resolveWorkspace(folder);
|
|
144
|
+
const mod = $resolveModule(workspace, folder);
|
|
145
|
+
const build = workspace.travetto?.build ?? {};
|
|
146
|
+
const toolFolder = build.toolFolder ?? TOOL_FOLDER;
|
|
145
147
|
|
|
146
148
|
return {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
workspace: {
|
|
150
|
+
name: workspace.name,
|
|
151
|
+
path: workspace.path,
|
|
152
|
+
mono: workspace.mono,
|
|
153
|
+
manager: workspace.manager,
|
|
154
|
+
type: workspace.type ?? 'commonjs',
|
|
155
|
+
defaultEnv: workspace.travetto?.defaultEnv ?? 'local'
|
|
156
|
+
},
|
|
157
|
+
build: {
|
|
158
|
+
compilerFolder: build.compilerFolder ?? COMPILER_FOLDER,
|
|
159
|
+
compilerUrl: build.compilerUrl ?? $getCompilerUrl(workspace, toolFolder),
|
|
160
|
+
compilerModuleFolder: path.dirname(workspace.resolve('@travetto/compiler/package.json')).replace(`${workspace.path}/`, ''),
|
|
161
|
+
outputFolder: build.outputFolder ?? OUTPUT_FOLDER,
|
|
162
|
+
toolFolder
|
|
163
|
+
},
|
|
164
|
+
main: {
|
|
165
|
+
name: mod.name ?? 'untitled',
|
|
166
|
+
folder: mod.path === workspace.path ? '' : mod.path.replace(`${workspace.path}/`, ''),
|
|
167
|
+
version: mod.version,
|
|
168
|
+
description: mod.description
|
|
169
|
+
}
|
|
160
170
|
};
|
|
161
171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/manifest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"description": "Support for project indexing, manifesting, along with file watching",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"path",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
|
34
34
|
"displayName": "Manifest",
|
|
35
|
-
"
|
|
35
|
+
"doc": {
|
|
36
|
+
"baseUrl": "https://github.com/travetto/travetto/tree/main"
|
|
37
|
+
}
|
|
36
38
|
},
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public"
|
package/src/delta.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
ManifestContext, ManifestModule, ManifestModuleCore, ManifestModuleFile,
|
|
3
|
-
ManifestModuleFileType, ManifestModuleFolderType, ManifestRoot
|
|
4
|
-
} from './types';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
5
2
|
|
|
6
3
|
import { ManifestModuleUtil } from './module';
|
|
7
|
-
import { ManifestFileUtil } from './file';
|
|
8
4
|
import { path } from './path';
|
|
9
5
|
|
|
6
|
+
import type { ManifestModule, ManifestModuleCore, ManifestModuleFile, ManifestRoot } from './types/manifest';
|
|
7
|
+
import type { ManifestModuleFileType, ManifestModuleFolderType } from './types/common';
|
|
8
|
+
import type { ManifestContext } from './types/context';
|
|
9
|
+
|
|
10
10
|
type DeltaEventType = 'added' | 'changed' | 'removed' | 'missing' | 'dirty';
|
|
11
11
|
type DeltaModule = ManifestModuleCore & { files: Record<string, ManifestModuleFile> };
|
|
12
|
-
export type DeltaEvent = { file: string, type: DeltaEventType, module: string };
|
|
12
|
+
export type DeltaEvent = { file: string, type: DeltaEventType, module: string, sourceFile: string };
|
|
13
13
|
|
|
14
14
|
const VALID_SOURCE_FOLDERS = new Set<ManifestModuleFolderType>(['bin', 'src', 'test', 'support', '$index', '$package', 'doc']);
|
|
15
|
-
const
|
|
15
|
+
const VALID_OUTPUT_TYPE = new Set<ManifestModuleFileType>(['js', 'ts', 'package-json']);
|
|
16
|
+
const VALID_SOURCE_TYPE = new Set<ManifestModuleFileType>([...VALID_OUTPUT_TYPE, 'typings']);
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Produce delta for the manifest
|
|
@@ -30,14 +31,14 @@ export class ManifestDeltaUtil {
|
|
|
30
31
|
const out: DeltaEvent[] = [];
|
|
31
32
|
|
|
32
33
|
const add = (file: string, type: DeltaEvent['type']): unknown =>
|
|
33
|
-
out.push({ file, module: left.name, type });
|
|
34
|
+
out.push({ file, module: left.name, type, sourceFile: path.resolve(ctx.workspace.path, left.sourceFolder, file) });
|
|
34
35
|
|
|
35
|
-
const root =
|
|
36
|
+
const root = path.resolve(ctx.workspace.path, ctx.build.outputFolder, left.outputFolder);
|
|
36
37
|
const right = new Set(
|
|
37
38
|
(await ManifestModuleUtil.scanFolder(root, left.main))
|
|
38
39
|
.filter(x => {
|
|
39
40
|
const type = ManifestModuleUtil.getFileType(x);
|
|
40
|
-
return type
|
|
41
|
+
return VALID_SOURCE_TYPE.has(type);
|
|
41
42
|
})
|
|
42
43
|
.map(x => ManifestModuleUtil.sourceToBlankExt(x.replace(`${root}/`, '')))
|
|
43
44
|
);
|
|
@@ -45,7 +46,7 @@ export class ManifestDeltaUtil {
|
|
|
45
46
|
for (const el of Object.keys(left.files)) {
|
|
46
47
|
const output = ManifestModuleUtil.sourceToOutputExt(`${outputFolder}/${left.outputFolder}/${el}`);
|
|
47
48
|
const [, , leftTs] = left.files[el];
|
|
48
|
-
const stat = await
|
|
49
|
+
const stat = await fs.stat(output).catch(() => undefined);
|
|
49
50
|
right.delete(ManifestModuleUtil.sourceToBlankExt(el));
|
|
50
51
|
|
|
51
52
|
if (!stat) {
|
|
@@ -77,7 +78,7 @@ export class ManifestDeltaUtil {
|
|
|
77
78
|
continue;
|
|
78
79
|
}
|
|
79
80
|
for (const [name, type, date] of m.files?.[key] ?? []) {
|
|
80
|
-
if (
|
|
81
|
+
if (VALID_OUTPUT_TYPE.has(type)) {
|
|
81
82
|
out[name] = [name, type, date];
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -88,14 +89,14 @@ export class ManifestDeltaUtil {
|
|
|
88
89
|
/**
|
|
89
90
|
* Produce delta between manifest root and the output folder
|
|
90
91
|
*/
|
|
91
|
-
static async produceDelta(
|
|
92
|
+
static async produceDelta(manifest: ManifestRoot): Promise<DeltaEvent[]> {
|
|
92
93
|
const deltaLeft = Object.fromEntries(
|
|
93
94
|
Object.values(manifest.modules)
|
|
94
95
|
.map(m => [m.name, { ...m, files: this.#flattenModuleFiles(m) }])
|
|
95
96
|
);
|
|
96
97
|
|
|
97
98
|
const out: DeltaEvent[] = [];
|
|
98
|
-
const outputFolder = path.resolve(
|
|
99
|
+
const outputFolder = path.resolve(manifest.workspace.path, manifest.build.outputFolder);
|
|
99
100
|
|
|
100
101
|
for (const lMod of Object.values(deltaLeft)) {
|
|
101
102
|
out.push(...await this.#deltaModules(manifest, outputFolder, lMod));
|