@travetto/manifest 3.2.0-rc.0 → 3.3.0
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 +2 -2
- package/package.json +1 -1
- package/src/manifest-index.ts +1 -0
- package/src/path.ts +7 -7
- package/src/util.ts +1 -1
package/README.md
CHANGED
|
@@ -85,10 +85,10 @@ Once the manifest is created, the application runtime can now read this manifest
|
|
|
85
85
|
* Providing contextual information when provided a filename, import name, etc (e.g. logging, testing output)
|
|
86
86
|
|
|
87
87
|
## Path Normalization
|
|
88
|
-
By default, all paths within the framework are assumed to be in a POSIX style, and all input paths are converted to the POSIX style. This works appropriately within a Unix and a Windows environment. This module offers up [path](https://github.com/travetto/travetto/tree/main/module/manifest/src/path.ts#
|
|
88
|
+
By default, all paths within the framework are assumed to be in a POSIX style, and all input paths are converted to the POSIX style. This works appropriately within a Unix and a Windows environment. This module offers up [path](https://github.com/travetto/travetto/tree/main/module/manifest/src/path.ts#L8) as an equivalent to [Node](https://nodejs.org)'s [http](https://nodejs.org/api/path.html) library. This allows for consistent behavior across all file-interactions, and also allows for easy analysis if [Node](https://nodejs.org)'s [http](https://nodejs.org/api/path.html) library is ever imported.
|
|
89
89
|
|
|
90
90
|
## File Watching
|
|
91
|
-
The module also leverages [
|
|
91
|
+
The module also leverages [@parcel/watcher](https://www.npmjs.com/package/@parcel/watcher), to expose a single function of `watchFolders`. Only the [Compiler](https://github.com/travetto/travetto/tree/main/module/compiler#readme "The compiler infrastructure for the Travetto framework") module packages [@parcel/watcher](https://www.npmjs.com/package/@parcel/watcher) as a direct dependency. This means, that in production, by default all watch operations will fail with a missing dependency.
|
|
92
92
|
|
|
93
93
|
**Code: Watch Configuration**
|
|
94
94
|
```typescript
|
package/package.json
CHANGED
package/src/manifest-index.ts
CHANGED
package/src/path.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { extname, dirname, resolve, basename,
|
|
1
|
+
import { extname, dirname, resolve, basename, join } from 'path/posix';
|
|
2
|
+
import { sep } from 'path';
|
|
2
3
|
|
|
3
4
|
const posix = (file: string): string => file.replaceAll('\\', '/');
|
|
4
5
|
|
|
@@ -7,11 +8,10 @@ const cwd = (): string => posix(process.cwd());
|
|
|
7
8
|
export const path = {
|
|
8
9
|
cwd,
|
|
9
10
|
toPosix: posix,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
join: (root: string, ...args: string[]): string => posix(join(posix(root), ...args.map(f => posix(f)))),
|
|
11
|
+
basename: (file: string, suffix?: string): string => basename(posix(file), suffix),
|
|
12
|
+
extname: (file: string): string => extname(posix(file)),
|
|
13
|
+
dirname: (file: string): string => dirname(posix(file)),
|
|
14
|
+
resolve: (...args: string[]): string => resolve(cwd(), ...args.map(f => posix(f))),
|
|
15
|
+
join: (root: string, ...args: string[]): string => join(posix(root), ...args.map(f => posix(f))),
|
|
16
16
|
toNative: (file: string): string => file.replaceAll('/', sep)
|
|
17
17
|
};
|
package/src/util.ts
CHANGED
|
@@ -17,7 +17,7 @@ export class ManifestUtil {
|
|
|
17
17
|
*/
|
|
18
18
|
static async writeFileWithBuffer(file: string, content: string): Promise<string> {
|
|
19
19
|
const ext = path.extname(file);
|
|
20
|
-
const tempName = `${path.basename(file, ext)}.${process.ppid}.${process.pid}.${Date.now()}.${Math.random()}
|
|
20
|
+
const tempName = `${path.basename(file, ext)}.${process.ppid}.${process.pid}.${Date.now()}.${Math.random()}${ext}`;
|
|
21
21
|
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
22
22
|
const temp = path.resolve(os.tmpdir(), tempName);
|
|
23
23
|
await fs.writeFile(temp, content, 'utf8');
|