@travetto/manifest 5.0.0-rc.2 → 5.0.0-rc.4
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/README.md +4 -8
- package/package.json +1 -1
- package/src/delta.ts +3 -3
- package/src/file.ts +3 -2
- package/src/manifest-index.ts +7 -6
- package/src/module.ts +5 -5
package/README.md
CHANGED
|
@@ -50,17 +50,13 @@ 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 Ⲑ_decorator_1 = tslib_1.__importStar(require("@travetto/registry/src/decorator.js"));
|
|
54
53
|
const Ⲑ_function_1 = tslib_1.__importStar(require("@travetto/runtime/src/function.js"));
|
|
55
|
-
var ᚕm = ["@travetto/manifest", "doc/test-class"];
|
|
56
|
-
|
|
57
|
-
static Ⲑinit = Ⲑ_function_1.
|
|
54
|
+
var ᚕm = ["@travetto/manifest", "doc/test-class.ts"];
|
|
55
|
+
class TestClass {
|
|
56
|
+
static Ⲑinit = Ⲑ_function_1.registerFunction(TestClass, ᚕm, { hash: 197152026, lines: [1, 3] }, { doStuff: { hash: 51337554, lines: [2, 2] } }, false, false);
|
|
58
57
|
async doStuff() { }
|
|
59
|
-
}
|
|
58
|
+
}
|
|
60
59
|
exports.TestClass = TestClass;
|
|
61
|
-
exports.TestClass = TestClass = tslib_1.__decorate([
|
|
62
|
-
Ⲑ_decorator_1.Register()
|
|
63
|
-
], TestClass);
|
|
64
60
|
```
|
|
65
61
|
|
|
66
62
|
## Module Indexing
|
package/package.json
CHANGED
package/src/delta.ts
CHANGED
|
@@ -40,14 +40,14 @@ export class ManifestDeltaUtil {
|
|
|
40
40
|
const type = ManifestModuleUtil.getFileType(x);
|
|
41
41
|
return VALID_SOURCE_TYPE.has(type);
|
|
42
42
|
})
|
|
43
|
-
.map(x => ManifestModuleUtil.
|
|
43
|
+
.map(x => ManifestModuleUtil.withoutSourceExtension(x.replace(`${root}/`, '')))
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
for (const el of Object.keys(left.files)) {
|
|
47
|
-
const output = ManifestModuleUtil.
|
|
47
|
+
const output = ManifestModuleUtil.withOutputExtension(`${outputFolder}/${left.outputFolder}/${el}`);
|
|
48
48
|
const [, , leftTs] = left.files[el];
|
|
49
49
|
const stat = await fs.stat(output).catch(() => undefined);
|
|
50
|
-
right.delete(ManifestModuleUtil.
|
|
50
|
+
right.delete(ManifestModuleUtil.withoutSourceExtension(el));
|
|
51
51
|
|
|
52
52
|
if (!stat) {
|
|
53
53
|
add(el, 'added');
|
package/src/file.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
3
4
|
|
|
4
5
|
import { path } from './path';
|
|
5
6
|
|
|
@@ -8,9 +9,9 @@ export class ManifestFileUtil {
|
|
|
8
9
|
* Write file and copy over when ready
|
|
9
10
|
*/
|
|
10
11
|
static async bufferedFileWrite(file: string, content: string): Promise<void> {
|
|
11
|
-
const temp = path.resolve(
|
|
12
|
-
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
12
|
+
const temp = path.resolve(os.tmpdir(), `${process.hrtime()[1]}.${path.basename(file)}`);
|
|
13
13
|
await fs.writeFile(temp, content, 'utf8');
|
|
14
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
14
15
|
await fs.rename(temp, file);
|
|
15
16
|
}
|
|
16
17
|
|
package/src/manifest-index.ts
CHANGED
|
@@ -61,12 +61,12 @@ export class ManifestIndex {
|
|
|
61
61
|
return files.map(([f, type, ts, role = 'std']) => {
|
|
62
62
|
const isSource = type === 'ts' || type === 'js';
|
|
63
63
|
const sourceFile = path.resolve(this.#manifest.workspace.path, m.sourceFolder, f);
|
|
64
|
-
const js = isSource ? ManifestModuleUtil.
|
|
64
|
+
const js = isSource ? ManifestModuleUtil.withOutputExtension(f) : f;
|
|
65
65
|
const outputFile = this.#resolveOutput(m.outputFolder, js);
|
|
66
|
-
const modImport = `${m.name}/${
|
|
67
|
-
let id =
|
|
66
|
+
const modImport = `${m.name}/${f}`;
|
|
67
|
+
let id = `${m.name}:${f}`;
|
|
68
68
|
if (isSource) {
|
|
69
|
-
id = ManifestModuleUtil.
|
|
69
|
+
id = ManifestModuleUtil.withoutSourceExtension(id);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
return { id, type, sourceFile, outputFile, import: modImport, role, relativeFile: f, module: m.name };
|
|
@@ -100,7 +100,8 @@ export class ManifestIndex {
|
|
|
100
100
|
this.#outputToEntry.set(entry.outputFile, entry);
|
|
101
101
|
this.#sourceToEntry.set(entry.sourceFile, entry);
|
|
102
102
|
this.#importToEntry.set(entry.import, entry);
|
|
103
|
-
this.#importToEntry.set(entry.import
|
|
103
|
+
this.#importToEntry.set(ManifestModuleUtil.withoutSourceExtension(entry.import), entry);
|
|
104
|
+
this.#importToEntry.set(ManifestModuleUtil.withOutputExtension(entry.import), entry);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -189,7 +190,7 @@ export class ManifestIndex {
|
|
|
189
190
|
*/
|
|
190
191
|
getFromImport(imp: string): IndexedFile | undefined {
|
|
191
192
|
// Strip ext
|
|
192
|
-
imp = ManifestModuleUtil.
|
|
193
|
+
imp = ManifestModuleUtil.withoutSourceExtension(imp);
|
|
193
194
|
return this.#importToEntry.get(imp);
|
|
194
195
|
}
|
|
195
196
|
|
package/src/module.ts
CHANGED
|
@@ -48,7 +48,7 @@ export class ManifestModuleUtil {
|
|
|
48
48
|
/**
|
|
49
49
|
* Replace a source file's extension with a given value
|
|
50
50
|
*/
|
|
51
|
-
static #
|
|
51
|
+
static #pathToExtension(inputFile: string, ext: string): string {
|
|
52
52
|
return inputFile.replace(/[.][tj]sx?$/, ext);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -227,14 +227,14 @@ export class ManifestModuleUtil {
|
|
|
227
227
|
/**
|
|
228
228
|
* Get the output file name for a given input
|
|
229
229
|
*/
|
|
230
|
-
static
|
|
231
|
-
return this.#
|
|
230
|
+
static withOutputExtension(inputFile: string): string {
|
|
231
|
+
return this.#pathToExtension(inputFile, '.js');
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* Get the file without an extension
|
|
236
236
|
*/
|
|
237
|
-
static
|
|
238
|
-
return this.#
|
|
237
|
+
static withoutSourceExtension(inputFile: string): string {
|
|
238
|
+
return this.#pathToExtension(inputFile, '');
|
|
239
239
|
}
|
|
240
240
|
}
|