@travetto/manifest 7.0.0-rc.2 → 7.0.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 +1 -3
- package/__index__.ts +1 -1
- package/package.json +2 -1
- package/src/context.ts +5 -1
- package/src/delta.ts +1 -1
- package/src/dependencies.ts +1 -1
- package/src/file.ts +1 -1
- package/src/manifest-index.ts +1 -1
- package/src/module.ts +2 -2
- package/src/package.ts +1 -1
- package/src/path.ts +2 -2
- package/src/types/common.ts +0 -1
- package/src/types/context.ts +1 -3
- package/src/types/package.ts +2 -2
- package/src/util.ts +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Once the manifest is created, the application runtime can now read this manifest
|
|
|
43
43
|
* Providing contextual information when provided a filename, import name, etc (e.g. logging, testing output)
|
|
44
44
|
|
|
45
45
|
## Path Normalization
|
|
46
|
-
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#
|
|
46
|
+
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#L46) as an equivalent to [Node](https://nodejs.org)'s [path](https://nodejs.org/api/path.html) library. This allows for consistent behavior across all file-interactions.
|
|
47
47
|
|
|
48
48
|
## Anatomy of a Manifest
|
|
49
49
|
|
|
@@ -56,7 +56,6 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
56
56
|
"path": "<generated>",
|
|
57
57
|
"mono": true,
|
|
58
58
|
"manager": "npm",
|
|
59
|
-
"type": "commonjs",
|
|
60
59
|
"defaultEnv": "local"
|
|
61
60
|
},
|
|
62
61
|
"build": {
|
|
@@ -132,7 +131,6 @@ The general context describes the project-space and any important information fo
|
|
|
132
131
|
|
|
133
132
|
The context contains:
|
|
134
133
|
* A generated timestamp
|
|
135
|
-
* Module Type: `commonjs`([CommonJS](https://nodejs.org/api/modules.html)) or `module`([Ecmascript Module](https://nodejs.org/api/esm.html))
|
|
136
134
|
* The main module to execute. (*This primarily pertains to mono-repo support when there are multiple modules in the project*)
|
|
137
135
|
* The root path of the project/workspace
|
|
138
136
|
* Whether or not the project is a mono-repo. (*This is determined by using the 'workspaces' field in your [Package JSON](https://docs.npmjs.com/cli/v9/configuring-npm/package-json)*)
|
package/__index__.ts
CHANGED
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -53,13 +53,17 @@ export function getManifestContext(root: string = process.cwd()): ManifestContex
|
|
|
53
53
|
readPackage(resolve(`${process.env.TRV_MODULE}/package.json`)) :
|
|
54
54
|
findPackage(root, pkg => !!pkg) ?? workspace;
|
|
55
55
|
|
|
56
|
+
if (workspace.type !== 'module') {
|
|
57
|
+
console.error('ERROR: Only ESM modules are supported, package.json must be of type module');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
return {
|
|
57
62
|
workspace: {
|
|
58
63
|
name: workspace.name ?? 'untitled',
|
|
59
64
|
path: workspace.path,
|
|
60
65
|
mono: !!workspace.workspaces,
|
|
61
66
|
manager: existsSync(path.resolve(workspace.path, 'yarn.lock')) ? 'yarn' : 'npm',
|
|
62
|
-
type: workspace.type ?? 'commonjs',
|
|
63
67
|
defaultEnv: workspace.travetto?.defaultEnv ?? 'local'
|
|
64
68
|
},
|
|
65
69
|
build: {
|
package/src/delta.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
3
|
import { ManifestModuleUtil } from './module.ts';
|
|
4
|
-
import
|
|
4
|
+
import path from './path.ts';
|
|
5
5
|
|
|
6
6
|
import type { ManifestModule, ManifestModuleCore, ManifestModuleFile, ManifestRoot } from './types/manifest.ts';
|
|
7
7
|
import type { ChangeEventType, ManifestModuleFileType, ManifestModuleFolderType } from './types/common.ts';
|
package/src/dependencies.ts
CHANGED
package/src/file.ts
CHANGED
package/src/manifest-index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
|
|
3
3
|
import { ManifestModuleUtil } from './module.ts';
|
|
4
|
-
import
|
|
4
|
+
import path from './path.ts';
|
|
5
5
|
import { ManifestUtil } from './util.ts';
|
|
6
6
|
|
|
7
7
|
import type { ManifestModule, ManifestRoot, ManifestModuleFile, IndexedModule, IndexedFile, FindConfig } from './types/manifest.ts';
|
package/src/module.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import path from './path.ts';
|
|
4
4
|
import { PackageModuleVisitor } from './dependencies.ts';
|
|
5
5
|
|
|
6
6
|
import type { ManifestModuleFileType, ManifestModuleRole, ManifestModuleFolderType } from './types/common.ts';
|
|
@@ -18,7 +18,7 @@ const EXT_MAPPING: Record<string, ManifestModuleFileType> = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const INDEX_FILES = new Set(
|
|
21
|
-
['__index__', '__index', 'index'
|
|
21
|
+
['__index__', '__index', 'index'].flatMap(file =>
|
|
22
22
|
['ts', 'tsx', 'js'].map(ext => `${file}.${ext}`)
|
|
23
23
|
)
|
|
24
24
|
);
|
package/src/package.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import path from './path.ts';
|
|
6
6
|
import { ManifestFileUtil } from './file.ts';
|
|
7
7
|
|
|
8
8
|
import { PackagePathSymbol, type Package, type PackageWorkspaceEntry } from './types/package.ts';
|
package/src/path.ts
CHANGED
|
@@ -6,8 +6,8 @@ const toPosix = (file: string): string => file.replaceAll('\\', '/');
|
|
|
6
6
|
const toNative = (file: string): string => file.replace(/[\/]/g, native.sep);
|
|
7
7
|
const cwd = (): string => toPosix(process.cwd());
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
native: posix
|
|
9
|
+
const path: typeof posix & {
|
|
10
|
+
native: typeof posix;
|
|
11
11
|
toPosix: typeof toPosix;
|
|
12
12
|
toNative: typeof toNative;
|
|
13
13
|
} = {
|
package/src/types/common.ts
CHANGED
package/src/types/context.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NodePackageManager } from './common.ts';
|
|
2
2
|
|
|
3
3
|
export type ManifestContext = {
|
|
4
4
|
workspace: {
|
|
@@ -8,8 +8,6 @@ export type ManifestContext = {
|
|
|
8
8
|
name: string;
|
|
9
9
|
/** Is the workspace a monorepo? */
|
|
10
10
|
mono?: boolean;
|
|
11
|
-
/** The module type of the workspace */
|
|
12
|
-
type: NodeModuleType;
|
|
13
11
|
/** The package manager of the workspace */
|
|
14
12
|
manager: NodePackageManager;
|
|
15
13
|
/** The default env name */
|
package/src/types/package.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ManifestModuleRole
|
|
1
|
+
import type { ManifestModuleRole } from './common.ts';
|
|
2
2
|
import type { ManifestContext } from './context.ts';
|
|
3
3
|
|
|
4
4
|
export const PackagePathSymbol = Symbol.for('@travetto/manifest:package-path');
|
|
@@ -6,7 +6,7 @@ export const PackagePathSymbol = Symbol.for('@travetto/manifest:package-path');
|
|
|
6
6
|
export type Package = {
|
|
7
7
|
[PackagePathSymbol]?: string;
|
|
8
8
|
name: string;
|
|
9
|
-
type?:
|
|
9
|
+
type?: string;
|
|
10
10
|
version: string;
|
|
11
11
|
description?: string;
|
|
12
12
|
license?: string;
|
package/src/util.ts
CHANGED