@decohere/workspace 0.0.1-dev.118 → 0.0.1-dev.119
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/commonjs/src/factories/project.factory.js +2 -1
- package/commonjs/src/models/project.model.js +15 -15
- package/es6/src/factories/project.factory.js +2 -1
- package/es6/src/models/project.model.js +15 -15
- package/package.json +4 -3
- package/types/src/models/project-file-event.d.ts +3 -2
- package/types/src/models/project.model.d.ts +1 -1
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "ProjectFactory", {
|
|
|
10
10
|
});
|
|
11
11
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
12
12
|
const _io = require("@decohere/core/io");
|
|
13
|
+
const _io1 = require("@decohere/devkit/io");
|
|
13
14
|
const _objects = require("@decohere/core/objects");
|
|
14
15
|
const _errors = require("../errors.js");
|
|
15
16
|
const _packagejsonmodel = require("../models/package-json.model.js");
|
|
@@ -23,7 +24,7 @@ class ProjectFactory {
|
|
|
23
24
|
static async getProjectSeeds(config) {
|
|
24
25
|
const { includeProjects, ignoreProjects, rootDir } = config;
|
|
25
26
|
const cwd = rootDir ?? "./";
|
|
26
|
-
const discoveredPackageJsonFiles = await
|
|
27
|
+
const discoveredPackageJsonFiles = await (0, _io1.findFiles)(includeProjects, {
|
|
27
28
|
cwd,
|
|
28
29
|
ignore: ignoreProjects
|
|
29
30
|
});
|
|
@@ -12,7 +12,7 @@ const _nodefs = require("node:fs");
|
|
|
12
12
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
13
13
|
const _caching = require("@decohere/core/caching");
|
|
14
14
|
const _extensibility = require("@decohere/core/extensibility");
|
|
15
|
-
const _io = require("@decohere/
|
|
15
|
+
const _io = require("@decohere/devkit/io");
|
|
16
16
|
const _picomatch = /*#__PURE__*/ _interop_require_default(require("picomatch"));
|
|
17
17
|
const _rxjs = require("rxjs");
|
|
18
18
|
const _errors = require("../errors.js");
|
|
@@ -117,7 +117,7 @@ class Project extends (0, _extensibility.mixwith)(_haspackagejsonmixin.HasPackag
|
|
|
117
117
|
return this.#projectFileChangedSubject.asObservable();
|
|
118
118
|
}
|
|
119
119
|
async getAllFiles() {
|
|
120
|
-
const files = await _io.
|
|
120
|
+
const files = await (0, _io.findFiles)(this.include, {
|
|
121
121
|
cwd: this.#absoluteProjectDir,
|
|
122
122
|
ignore: this.ignore
|
|
123
123
|
});
|
|
@@ -138,37 +138,37 @@ class Project extends (0, _extensibility.mixwith)(_haspackagejsonmixin.HasPackag
|
|
|
138
138
|
if (!this.#hasLoadedSourceFiles) {
|
|
139
139
|
await this.getAllFiles();
|
|
140
140
|
}
|
|
141
|
-
const watcher = _io.
|
|
141
|
+
const watcher = (0, _io.watch)(this.#absoluteProjectDir, {
|
|
142
142
|
ignoreInitial: true
|
|
143
143
|
});
|
|
144
144
|
this.#watcher = watcher;
|
|
145
|
-
watcher.on(_io.
|
|
145
|
+
watcher.on(_io.WatchEvents.add, (file)=>{
|
|
146
146
|
const fileEx = file;
|
|
147
|
-
this.updateSourceFileCache(_io.
|
|
147
|
+
this.updateSourceFileCache(_io.WatchEvents.add, fileEx);
|
|
148
148
|
this.#projectFileChangedSubject.next({
|
|
149
149
|
project: this,
|
|
150
150
|
configuration,
|
|
151
|
-
eventName: _io.
|
|
151
|
+
eventName: _io.WatchEvents.add,
|
|
152
152
|
file: fileEx
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
|
-
watcher.on(_io.
|
|
155
|
+
watcher.on(_io.WatchEvents.change, (file)=>{
|
|
156
156
|
const fileEx = file;
|
|
157
|
-
this.updateSourceFileCache(_io.
|
|
157
|
+
this.updateSourceFileCache(_io.WatchEvents.change, fileEx);
|
|
158
158
|
this.#projectFileChangedSubject.next({
|
|
159
159
|
project: this,
|
|
160
160
|
configuration,
|
|
161
|
-
eventName: _io.
|
|
161
|
+
eventName: _io.WatchEvents.change,
|
|
162
162
|
file: fileEx
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
|
-
watcher.on(_io.
|
|
165
|
+
watcher.on(_io.WatchEvents.unlink, (file)=>{
|
|
166
166
|
const fileEx = file;
|
|
167
|
-
this.updateSourceFileCache(_io.
|
|
167
|
+
this.updateSourceFileCache(_io.WatchEvents.unlink, fileEx);
|
|
168
168
|
this.#projectFileChangedSubject.next({
|
|
169
169
|
project: this,
|
|
170
170
|
configuration,
|
|
171
|
-
eventName: _io.
|
|
171
|
+
eventName: _io.WatchEvents.unlink,
|
|
172
172
|
file: fileEx
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -246,11 +246,11 @@ class Project extends (0, _extensibility.mixwith)(_haspackagejsonmixin.HasPackag
|
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
switch(eventName){
|
|
249
|
-
case _io.
|
|
249
|
+
case _io.WatchEvents.unlink:
|
|
250
250
|
this.#sourceFiles.delete(file.relativePath);
|
|
251
251
|
return;
|
|
252
|
-
case _io.
|
|
253
|
-
case _io.
|
|
252
|
+
case _io.WatchEvents.add:
|
|
253
|
+
case _io.WatchEvents.change:
|
|
254
254
|
if (this.matchesSourcePattern(file.relativePath)) {
|
|
255
255
|
this.#sourceFiles.set(file.relativePath, file);
|
|
256
256
|
return;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { io } from "@decohere/core/io";
|
|
3
|
+
import { findFiles } from "@decohere/devkit/io";
|
|
3
4
|
import { merge } from "@decohere/core/objects";
|
|
4
5
|
import { WorkspaceConfigurationError } from "../errors.js";
|
|
5
6
|
import { PackageJson } from "../models/package-json.model.js";
|
|
@@ -8,7 +9,7 @@ export class ProjectFactory {
|
|
|
8
9
|
static async getProjectSeeds(config) {
|
|
9
10
|
const { includeProjects, ignoreProjects, rootDir } = config;
|
|
10
11
|
const cwd = rootDir ?? "./";
|
|
11
|
-
const discoveredPackageJsonFiles = await
|
|
12
|
+
const discoveredPackageJsonFiles = await findFiles(includeProjects, {
|
|
12
13
|
cwd,
|
|
13
14
|
ignore: ignoreProjects
|
|
14
15
|
});
|
|
@@ -11,7 +11,7 @@ import { existsSync } from "node:fs";
|
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { cache, memoize } from "@decohere/core/caching";
|
|
13
13
|
import { mixwith } from "@decohere/core/extensibility";
|
|
14
|
-
import {
|
|
14
|
+
import { findFiles, WatchEvents, watch as watchDirectory } from "@decohere/devkit/io";
|
|
15
15
|
import picomatch from "picomatch";
|
|
16
16
|
import { Subject } from "rxjs";
|
|
17
17
|
import { WorkspaceConfigurationError } from "../errors.js";
|
|
@@ -102,7 +102,7 @@ export class Project extends mixwith(HasPackageJson, HasTsConfig) {
|
|
|
102
102
|
return this.#projectFileChangedSubject.asObservable();
|
|
103
103
|
}
|
|
104
104
|
async getAllFiles() {
|
|
105
|
-
const files = await
|
|
105
|
+
const files = await findFiles(this.include, {
|
|
106
106
|
cwd: this.#absoluteProjectDir,
|
|
107
107
|
ignore: this.ignore
|
|
108
108
|
});
|
|
@@ -123,37 +123,37 @@ export class Project extends mixwith(HasPackageJson, HasTsConfig) {
|
|
|
123
123
|
if (!this.#hasLoadedSourceFiles) {
|
|
124
124
|
await this.getAllFiles();
|
|
125
125
|
}
|
|
126
|
-
const watcher =
|
|
126
|
+
const watcher = watchDirectory(this.#absoluteProjectDir, {
|
|
127
127
|
ignoreInitial: true
|
|
128
128
|
});
|
|
129
129
|
this.#watcher = watcher;
|
|
130
|
-
watcher.on(
|
|
130
|
+
watcher.on(WatchEvents.add, (file)=>{
|
|
131
131
|
const fileEx = file;
|
|
132
|
-
this.updateSourceFileCache(
|
|
132
|
+
this.updateSourceFileCache(WatchEvents.add, fileEx);
|
|
133
133
|
this.#projectFileChangedSubject.next({
|
|
134
134
|
project: this,
|
|
135
135
|
configuration,
|
|
136
|
-
eventName:
|
|
136
|
+
eventName: WatchEvents.add,
|
|
137
137
|
file: fileEx
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
|
-
watcher.on(
|
|
140
|
+
watcher.on(WatchEvents.change, (file)=>{
|
|
141
141
|
const fileEx = file;
|
|
142
|
-
this.updateSourceFileCache(
|
|
142
|
+
this.updateSourceFileCache(WatchEvents.change, fileEx);
|
|
143
143
|
this.#projectFileChangedSubject.next({
|
|
144
144
|
project: this,
|
|
145
145
|
configuration,
|
|
146
|
-
eventName:
|
|
146
|
+
eventName: WatchEvents.change,
|
|
147
147
|
file: fileEx
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
|
-
watcher.on(
|
|
150
|
+
watcher.on(WatchEvents.unlink, (file)=>{
|
|
151
151
|
const fileEx = file;
|
|
152
|
-
this.updateSourceFileCache(
|
|
152
|
+
this.updateSourceFileCache(WatchEvents.unlink, fileEx);
|
|
153
153
|
this.#projectFileChangedSubject.next({
|
|
154
154
|
project: this,
|
|
155
155
|
configuration,
|
|
156
|
-
eventName:
|
|
156
|
+
eventName: WatchEvents.unlink,
|
|
157
157
|
file: fileEx
|
|
158
158
|
});
|
|
159
159
|
});
|
|
@@ -231,11 +231,11 @@ export class Project extends mixwith(HasPackageJson, HasTsConfig) {
|
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
233
|
switch(eventName){
|
|
234
|
-
case
|
|
234
|
+
case WatchEvents.unlink:
|
|
235
235
|
this.#sourceFiles.delete(file.relativePath);
|
|
236
236
|
return;
|
|
237
|
-
case
|
|
238
|
-
case
|
|
237
|
+
case WatchEvents.add:
|
|
238
|
+
case WatchEvents.change:
|
|
239
239
|
if (this.matchesSourcePattern(file.relativePath)) {
|
|
240
240
|
this.#sourceFiles.set(file.relativePath, file);
|
|
241
241
|
return;
|
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.119",
|
|
4
4
|
"description": "Workspace and project model primitives for monorepo tooling",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@decohere/core": "0.0.1-dev.
|
|
28
|
-
"@decohere/crucible": "0.0.1-dev.
|
|
27
|
+
"@decohere/core": "0.0.1-dev.119",
|
|
28
|
+
"@decohere/crucible": "0.0.1-dev.119",
|
|
29
|
+
"@decohere/devkit": "0.0.1-dev.119",
|
|
29
30
|
"picomatch": "^4.0.4",
|
|
30
31
|
"rxjs": "^7.8.2",
|
|
31
32
|
"typescript": "^6.0.3"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { FileEx
|
|
1
|
+
import type { FileEx } from "@decohere/core/io";
|
|
2
|
+
import type { WatchEventName } from "@decohere/devkit/io";
|
|
2
3
|
import type { Project } from "./project.model.js";
|
|
3
4
|
export type ProjectFileEvent = {
|
|
4
|
-
eventName:
|
|
5
|
+
eventName: WatchEventName;
|
|
5
6
|
project: Project;
|
|
6
7
|
configuration: string;
|
|
7
8
|
file: FileEx;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FileEx, Watcher } from "@decohere/core/io";
|
|
2
2
|
import { HasPackageJson } from "./has-package-json.mixin.js";
|
|
3
3
|
import { HasTsConfig } from "./has-tsconfig.mixin.js";
|
|
4
4
|
import { PackageJson } from "./package-json.model.js";
|