@decohere/workspace 0.0.1-dev.20261108.265 → 0.0.1-dev.20261110.278
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
CHANGED
|
@@ -33,7 +33,12 @@ Packages do **not** have to live under `projects/` — that is only the default
|
|
|
33
33
|
|
|
34
34
|
### Optional `.decohere.js`
|
|
35
35
|
|
|
36
|
-
If the file is missing, the workspace package uses the defaults above. Arrays in
|
|
36
|
+
If the file is missing, the workspace package uses the defaults above. The file overrides the defaults, including a tool's own (forge's `configurations` and `copyFiles`). Arrays in it **replace** the defaults, except `ignoreProjects` and `ignore`, which **add** to them: list only what you leave out.
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// Keep a Pulumi program under projects/ out of forge and flux. node_modules, __fixtures__ and dist stay ignored.
|
|
40
|
+
export default { ignoreProjects: ["projects/infra/**"] };
|
|
41
|
+
```
|
|
37
42
|
|
|
38
43
|
```js
|
|
39
44
|
/** @type {import("@decohere/workspace").WorkspaceOptions} */
|
|
@@ -82,4 +87,6 @@ const projects = workspace.getProjects("debug");
|
|
|
82
87
|
const aliases = workspace.getPackageAliases("debug");
|
|
83
88
|
```
|
|
84
89
|
|
|
90
|
+
A tool with defaults of its own passes them as the second argument, `WorkspaceFactory.create(options, defaults)`, so `.decohere.js` can override them. Anything in `options` overrides the user's file.
|
|
91
|
+
|
|
85
92
|
Pass a pre-built `workspace` into Forge/Flux in tests to skip filesystem discovery.
|
|
@@ -6,9 +6,17 @@ import { PackageJson } from "../models/package-json.model.js";
|
|
|
6
6
|
import { Workspace } from "../models/workspace.model.js";
|
|
7
7
|
import { UserConfigFactory } from "./config.factory.js";
|
|
8
8
|
import { ProjectFactory } from "./project.factory.js";
|
|
9
|
+
/** Patterns that leave things out: a user's list adds to the defaults', so they needn't restate them. */ const ADDITIVE = [
|
|
10
|
+
"ignoreProjects",
|
|
11
|
+
"ignore"
|
|
12
|
+
];
|
|
9
13
|
class Factory {
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The workspace from `defaults`, then the user's `.decohere.js`, then `options`, each over the
|
|
16
|
+
* one before. A tool passes its own defaults here, not in `options`, so the user's file can
|
|
17
|
+
* change them. Arrays replace the ones before them, except the ignore lists, which add up.
|
|
18
|
+
*/ async create(options = {}, defaults = WorkspaceDefaults) {
|
|
19
|
+
const config = await this.getMergedConfig(options, defaults);
|
|
12
20
|
const projectSeeds = await ProjectFactory.getProjectSeeds(config);
|
|
13
21
|
const packageJson = await this.getPackageJson(config.rootDir ?? "./");
|
|
14
22
|
const workspace = new Workspace({
|
|
@@ -18,12 +26,23 @@ class Factory {
|
|
|
18
26
|
});
|
|
19
27
|
return workspace;
|
|
20
28
|
}
|
|
21
|
-
async getMergedConfig(options) {
|
|
29
|
+
async getMergedConfig(options, defaults) {
|
|
22
30
|
const { configFile, ...rest } = options;
|
|
23
31
|
const userConfig = await UserConfigFactory.getUserConfig(configFile);
|
|
24
|
-
|
|
32
|
+
const config = merge.withOptions({
|
|
25
33
|
mergeArrays: false
|
|
26
|
-
},
|
|
34
|
+
}, defaults, userConfig, rest);
|
|
35
|
+
for (const key of ADDITIVE){
|
|
36
|
+
const layers = [
|
|
37
|
+
defaults[key],
|
|
38
|
+
userConfig[key],
|
|
39
|
+
rest[key]
|
|
40
|
+
];
|
|
41
|
+
config[key] = [
|
|
42
|
+
...new Set(layers.flatMap((patterns)=>patterns ?? []))
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return config;
|
|
27
46
|
}
|
|
28
47
|
async getPackageJson(rootDir) {
|
|
29
48
|
const packageJsonPath = path.join(rootDir, PACKAGE_JSON);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decohere/workspace",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.20261110.278",
|
|
4
4
|
"description": "Workspace and project model primitives for monorepo tooling",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@decohere/core": "0.0.1-dev.
|
|
36
|
-
"@decohere/crucible": "0.0.1-dev.
|
|
37
|
-
"@decohere/devkit": "0.0.1-dev.
|
|
35
|
+
"@decohere/core": "0.0.1-dev.20261110.278",
|
|
36
|
+
"@decohere/crucible": "0.0.1-dev.20261110.278",
|
|
37
|
+
"@decohere/devkit": "0.0.1-dev.20261110.278",
|
|
38
38
|
"get-tsconfig": "^4.14.3",
|
|
39
39
|
"picomatch": "^4.0.4"
|
|
40
40
|
},
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Workspace } from "../models/workspace.model.js";
|
|
2
2
|
import type { WorkspaceFactoryOptions, WorkspaceOptions } from "../models/workspace-config.type.js";
|
|
3
3
|
declare class Factory {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The workspace from `defaults`, then the user's `.decohere.js`, then `options`, each over the
|
|
6
|
+
* one before. A tool passes its own defaults here, not in `options`, so the user's file can
|
|
7
|
+
* change them. Arrays replace the ones before them, except the ignore lists, which add up.
|
|
8
|
+
*/
|
|
9
|
+
create(options?: WorkspaceFactoryOptions & Partial<WorkspaceOptions>, defaults?: WorkspaceOptions): Promise<Workspace>;
|
|
5
10
|
private getMergedConfig;
|
|
6
11
|
private getPackageJson;
|
|
7
12
|
}
|