@travetto/manifest 7.0.4 → 7.1.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 +3 -4
- package/package.json +1 -1
- package/src/context.ts +1 -2
- package/src/dependencies.ts +8 -8
- package/src/package.ts +3 -3
- package/src/types/context.ts +0 -2
- package/src/types/manifest.ts +4 -4
- package/src/types/package.ts +0 -1
- package/src/util.ts +4 -4
package/README.md
CHANGED
|
@@ -55,8 +55,7 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
55
55
|
"name": "@travetto/mono-repo",
|
|
56
56
|
"path": "<generated>",
|
|
57
57
|
"mono": true,
|
|
58
|
-
"manager": "npm"
|
|
59
|
-
"defaultEnv": "local"
|
|
58
|
+
"manager": "npm"
|
|
60
59
|
},
|
|
61
60
|
"build": {
|
|
62
61
|
"compilerUrl": "http://127.0.0.1:26803",
|
|
@@ -73,7 +72,7 @@ By default, all paths within the framework are assumed to be in a POSIX style, a
|
|
|
73
72
|
"modules": {
|
|
74
73
|
"@travetto/manifest": {
|
|
75
74
|
"main": true,
|
|
76
|
-
"
|
|
75
|
+
"production": true,
|
|
77
76
|
"name": "@travetto/manifest",
|
|
78
77
|
"version": "x.x.x",
|
|
79
78
|
"workspace": true,
|
|
@@ -141,7 +140,7 @@ The context contains:
|
|
|
141
140
|
* The framework version (based on @travetto/manifest)
|
|
142
141
|
|
|
143
142
|
### Modules
|
|
144
|
-
The modules represent all of the [Travetto](https://travetto.dev)-aware dependencies (including dev dependencies) used for compiling, testing and executing. A
|
|
143
|
+
The modules represent all of the [Travetto](https://travetto.dev)-aware dependencies (including dev dependencies) used for compiling, testing and executing. A production-only version is produced when packaging the final output. Each module contains:
|
|
145
144
|
* The dependency npm name
|
|
146
145
|
* The dependency version
|
|
147
146
|
* A flag to determine if its a local module
|
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -64,8 +64,7 @@ export function getManifestContext(root: string = process.cwd()): ManifestContex
|
|
|
64
64
|
name: workspace.name ?? 'untitled',
|
|
65
65
|
path: workspace.path,
|
|
66
66
|
mono: !!workspace.workspaces,
|
|
67
|
-
manager: existsSync(path.resolve(workspace.path, 'yarn.lock')) ? 'yarn' : 'npm'
|
|
68
|
-
defaultEnv: workspace.travetto?.defaultEnv ?? 'local'
|
|
67
|
+
manager: existsSync(path.resolve(workspace.path, 'yarn.lock')) ? 'yarn' : 'npm'
|
|
69
68
|
},
|
|
70
69
|
build: {
|
|
71
70
|
compilerUrl: build.compilerUrl ?? `http://localhost:${toPort(wsPrefix)}`,
|
package/src/dependencies.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Package, PackageDependencyType } from './types/package.ts';
|
|
|
5
5
|
import type { ManifestContext } from './types/context.ts';
|
|
6
6
|
import type { PackageModule } from './types/manifest.ts';
|
|
7
7
|
|
|
8
|
-
type CreateOpts = Partial<Pick<PackageModule, 'main' | 'workspace' | '
|
|
8
|
+
type CreateOpts = Partial<Pick<PackageModule, 'main' | 'workspace' | 'production'>> & { roleRoot?: boolean, parent?: PackageModule };
|
|
9
9
|
|
|
10
10
|
type VisitableNode = {
|
|
11
11
|
/** Request package */
|
|
@@ -43,11 +43,11 @@ export class PackageModuleVisitor {
|
|
|
43
43
|
/**
|
|
44
44
|
* Build a package module
|
|
45
45
|
*/
|
|
46
|
-
#create(sourcePath: string, { main, workspace,
|
|
46
|
+
#create(sourcePath: string, { main, workspace, production = false, roleRoot = false, parent }: CreateOpts = {}): VisitableNode {
|
|
47
47
|
const pkg = PackageUtil.readPackage(sourcePath);
|
|
48
48
|
const value = this.#cache[sourcePath] ??= {
|
|
49
49
|
main,
|
|
50
|
-
|
|
50
|
+
production,
|
|
51
51
|
name: pkg.name,
|
|
52
52
|
version: pkg.version,
|
|
53
53
|
workspace: workspace ?? (pkg.name in this.#workspaceModules),
|
|
@@ -56,7 +56,7 @@ export class PackageModuleVisitor {
|
|
|
56
56
|
outputFolder: `node_modules/${pkg.name}`,
|
|
57
57
|
state: {
|
|
58
58
|
childSet: new Set(), parentSet: new Set(), roleSet: new Set(), roleRoot,
|
|
59
|
-
travetto: pkg.travetto,
|
|
59
|
+
travetto: pkg.travetto, dependencies: new Set(Object.keys(pkg.dependencies ?? {}))
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
|
@@ -98,7 +98,7 @@ export class PackageModuleVisitor {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* Propagate
|
|
101
|
+
* Propagate production, role information through graph
|
|
102
102
|
*/
|
|
103
103
|
async #complete(modules: Iterable<PackageModule>): Promise<PackageModule[]> {
|
|
104
104
|
const mapping = new Map([...modules].map(item => [item.name, { parent: new Set(item.state.parentSet), item }]));
|
|
@@ -132,8 +132,8 @@ export class PackageModuleVisitor {
|
|
|
132
132
|
child.item.state.roleSet.add(role);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
// Allow
|
|
136
|
-
child.item.
|
|
135
|
+
// Allow production to trickle down as needed
|
|
136
|
+
child.item.production ||= (item.production && item.state.dependencies.has(childName));
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
// Remove from mapping
|
|
@@ -155,7 +155,7 @@ export class PackageModuleVisitor {
|
|
|
155
155
|
*/
|
|
156
156
|
async visit(): Promise<Iterable<PackageModule>> {
|
|
157
157
|
const seen = new Set<PackageModule>();
|
|
158
|
-
const mainRequire = this.#create(this.#mainSourcePath, { main: true, workspace: true, roleRoot: true,
|
|
158
|
+
const mainRequire = this.#create(this.#mainSourcePath, { main: true, workspace: true, roleRoot: true, production: true });
|
|
159
159
|
|
|
160
160
|
const queue = [
|
|
161
161
|
mainRequire,
|
package/src/package.ts
CHANGED
|
@@ -119,11 +119,11 @@ export class PackageUtil {
|
|
|
119
119
|
/**
|
|
120
120
|
* Get an install command for a given npm module
|
|
121
121
|
*/
|
|
122
|
-
static getInstallCommand(ctx: { workspace: { manager: NodePackageManager } }, pkg: string,
|
|
122
|
+
static getInstallCommand(ctx: { workspace: { manager: NodePackageManager } }, pkg: string, production = false): string {
|
|
123
123
|
let install: string;
|
|
124
124
|
switch (ctx.workspace.manager) {
|
|
125
|
-
case 'npm': install = `npm i ${
|
|
126
|
-
case 'yarn': install = `yarn add ${
|
|
125
|
+
case 'npm': install = `npm i ${production ? '' : '--save-dev '}${pkg}`; break;
|
|
126
|
+
case 'yarn': install = `yarn add ${production ? '' : '--dev '}${pkg}`; break;
|
|
127
127
|
}
|
|
128
128
|
return install;
|
|
129
129
|
}
|
package/src/types/context.ts
CHANGED
package/src/types/manifest.ts
CHANGED
|
@@ -15,8 +15,8 @@ export type ManifestDepCore = {
|
|
|
15
15
|
main?: boolean;
|
|
16
16
|
/** Is this a module that is part of the workspace */
|
|
17
17
|
workspace?: boolean;
|
|
18
|
-
/** Should this module be deployed to
|
|
19
|
-
|
|
18
|
+
/** Should this module be deployed to production? */
|
|
19
|
+
production: boolean;
|
|
20
20
|
/** Is the module intended to be published? */
|
|
21
21
|
internal?: boolean;
|
|
22
22
|
};
|
|
@@ -69,8 +69,8 @@ export type PackageModule = Omit<ManifestModule, 'files' | 'parents' | 'roles'>
|
|
|
69
69
|
roleRoot?: boolean;
|
|
70
70
|
/** Travetto package info */
|
|
71
71
|
travetto?: Package['travetto'];
|
|
72
|
-
/**
|
|
73
|
-
|
|
72
|
+
/** Production dependencies */
|
|
73
|
+
dependencies: Set<string>;
|
|
74
74
|
/** Set of parent package names */
|
|
75
75
|
parentSet: Set<string>;
|
|
76
76
|
/** Set of child package names */
|
package/src/types/package.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -37,8 +37,8 @@ export class ManifestUtil {
|
|
|
37
37
|
* Produce a production manifest from a given manifest
|
|
38
38
|
*/
|
|
39
39
|
static createProductionManifest(manifest: ManifestRoot): ManifestRoot {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
40
|
+
const modules = Object.values(manifest.modules).filter(module => module.production);
|
|
41
|
+
const moduleNames = new Set([...modules.map(module => module.name)]);
|
|
42
42
|
return {
|
|
43
43
|
generated: manifest.generated,
|
|
44
44
|
workspace: manifest.workspace,
|
|
@@ -49,8 +49,8 @@ export class ManifestUtil {
|
|
|
49
49
|
},
|
|
50
50
|
main: manifest.main,
|
|
51
51
|
modules: Object.fromEntries(
|
|
52
|
-
|
|
53
|
-
parents: module.parents.filter(parent =>
|
|
52
|
+
modules.map(module => [module.name, Object.assign(module, {
|
|
53
|
+
parents: module.parents.filter(parent => moduleNames.has(parent))
|
|
54
54
|
})])
|
|
55
55
|
),
|
|
56
56
|
};
|