@kapeta/local-cluster-service 0.21.0 → 0.21.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [0.21.2](https://github.com/kapetacom/local-cluster-service/compare/v0.21.1...v0.21.2) (2023-09-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Handle windows paths in watcher ([#81](https://github.com/kapetacom/local-cluster-service/issues/81)) ([a2b7c3d](https://github.com/kapetacom/local-cluster-service/commit/a2b7c3dc9efba4d1b6d0a1a64703f7cf40ea3278))
7
+
8
+ ## [0.21.1](https://github.com/kapetacom/local-cluster-service/compare/v0.21.0...v0.21.1) (2023-09-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Use mounts and real paths - otherwise it fails on windows ([#80](https://github.com/kapetacom/local-cluster-service/issues/80)) ([8e73fdd](https://github.com/kapetacom/local-cluster-service/commit/8e73fddbaafcbcef547a72fd78f2b063ceed10b8))
14
+
1
15
  # [0.21.0](https://github.com/kapetacom/local-cluster-service/compare/v0.20.4...v0.21.0) (2023-09-17)
2
16
 
3
17
 
@@ -96,7 +96,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
96
96
  if (path.startsWith(this.baseDir)) {
97
97
  const relativePath = node_path_1.default.relative(this.baseDir, path);
98
98
  // Inside the repo we can use the path to determine the handle, name and version
99
- [handle, name, version] = relativePath.split(/\//g);
99
+ [handle, name, version] = relativePath.split(node_path_1.default.sep);
100
100
  if (!handle || !name || !version) {
101
101
  // Do nothing with this
102
102
  return;
@@ -134,7 +134,6 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
134
134
  if (!path) {
135
135
  return;
136
136
  }
137
- //console.log('File changed', eventName, path);
138
137
  const assetIdentity = await this.getAssetIdentity(path);
139
138
  if (!assetIdentity) {
140
139
  return;
@@ -144,7 +143,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
144
143
  }
145
144
  // If this is false it's because we're watching a symlink target
146
145
  const withinRepo = path.startsWith(this.baseDir);
147
- if (withinRepo && assetIdentity.version === 'local' && path.endsWith('/local')) {
146
+ if (withinRepo && assetIdentity.version === 'local' && path.endsWith(node_path_1.default.sep + 'local')) {
148
147
  // This is likely a symlink target
149
148
  if (eventName === 'add') {
150
149
  //console.log('Checking if we should add symlink target', handle, name, version, path);
@@ -244,7 +243,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
244
243
  }
245
244
  catch (e) { }
246
245
  if (symbolicLink) {
247
- const realPath = `${await fs_extra_1.default.realpath(path)}/kapeta.yml`;
246
+ const realPath = node_path_1.default.join(await fs_extra_1.default.realpath(path), 'kapeta.yml');
248
247
  if (await this.exists(realPath)) {
249
248
  //console.log('Watching symlink target %s => %s', path, realPath);
250
249
  this.watcher?.add(realPath);
@@ -261,7 +260,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
261
260
  if (!path.startsWith(this.baseDir)) {
262
261
  return false;
263
262
  }
264
- if (path.includes('/node_modules/')) {
263
+ if (path.includes(node_path_1.default.sep + 'node_modules' + node_path_1.default.sep)) {
265
264
  return true;
266
265
  }
267
266
  const filename = node_path_1.default.basename(path);
@@ -158,6 +158,10 @@ class BlockInstanceRunner {
158
158
  if (localContainer.healthcheck) {
159
159
  HealthCheck = containerManager_1.containerManager.toDockerHealth({ cmd: localContainer.healthcheck });
160
160
  }
161
+ const realLocalPath = node_fs_1.default.realpathSync(baseDir);
162
+ const Mounts = containerManager_1.containerManager.toDockerMounts({
163
+ [workingDir]: (0, containerManager_1.toLocalBindVolume)(realLocalPath)
164
+ });
161
165
  const systemUri = (0, nodejs_utils_1.parseKapetaUri)(this._systemId);
162
166
  return this.ensureContainer({
163
167
  ...dockerOpts,
@@ -185,10 +189,10 @@ class BlockInstanceRunner {
185
189
  HostConfig: {
186
190
  ...customHostConfigs,
187
191
  Binds: [
188
- `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
189
- `${(0, containerManager_1.toLocalBindVolume)(baseDir)}:${workingDir}`,
192
+ `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`
190
193
  ],
191
194
  PortBindings,
195
+ Mounts
192
196
  },
193
197
  });
194
198
  }
@@ -96,7 +96,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
96
96
  if (path.startsWith(this.baseDir)) {
97
97
  const relativePath = node_path_1.default.relative(this.baseDir, path);
98
98
  // Inside the repo we can use the path to determine the handle, name and version
99
- [handle, name, version] = relativePath.split(/\//g);
99
+ [handle, name, version] = relativePath.split(node_path_1.default.sep);
100
100
  if (!handle || !name || !version) {
101
101
  // Do nothing with this
102
102
  return;
@@ -134,7 +134,6 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
134
134
  if (!path) {
135
135
  return;
136
136
  }
137
- //console.log('File changed', eventName, path);
138
137
  const assetIdentity = await this.getAssetIdentity(path);
139
138
  if (!assetIdentity) {
140
139
  return;
@@ -144,7 +143,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
144
143
  }
145
144
  // If this is false it's because we're watching a symlink target
146
145
  const withinRepo = path.startsWith(this.baseDir);
147
- if (withinRepo && assetIdentity.version === 'local' && path.endsWith('/local')) {
146
+ if (withinRepo && assetIdentity.version === 'local' && path.endsWith(node_path_1.default.sep + 'local')) {
148
147
  // This is likely a symlink target
149
148
  if (eventName === 'add') {
150
149
  //console.log('Checking if we should add symlink target', handle, name, version, path);
@@ -244,7 +243,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
244
243
  }
245
244
  catch (e) { }
246
245
  if (symbolicLink) {
247
- const realPath = `${await fs_extra_1.default.realpath(path)}/kapeta.yml`;
246
+ const realPath = node_path_1.default.join(await fs_extra_1.default.realpath(path), 'kapeta.yml');
248
247
  if (await this.exists(realPath)) {
249
248
  //console.log('Watching symlink target %s => %s', path, realPath);
250
249
  this.watcher?.add(realPath);
@@ -261,7 +260,7 @@ class RepositoryWatcher extends node_events_1.EventEmitter {
261
260
  if (!path.startsWith(this.baseDir)) {
262
261
  return false;
263
262
  }
264
- if (path.includes('/node_modules/')) {
263
+ if (path.includes(node_path_1.default.sep + 'node_modules' + node_path_1.default.sep)) {
265
264
  return true;
266
265
  }
267
266
  const filename = node_path_1.default.basename(path);
@@ -158,6 +158,10 @@ class BlockInstanceRunner {
158
158
  if (localContainer.healthcheck) {
159
159
  HealthCheck = containerManager_1.containerManager.toDockerHealth({ cmd: localContainer.healthcheck });
160
160
  }
161
+ const realLocalPath = node_fs_1.default.realpathSync(baseDir);
162
+ const Mounts = containerManager_1.containerManager.toDockerMounts({
163
+ [workingDir]: (0, containerManager_1.toLocalBindVolume)(realLocalPath)
164
+ });
161
165
  const systemUri = (0, nodejs_utils_1.parseKapetaUri)(this._systemId);
162
166
  return this.ensureContainer({
163
167
  ...dockerOpts,
@@ -185,10 +189,10 @@ class BlockInstanceRunner {
185
189
  HostConfig: {
186
190
  ...customHostConfigs,
187
191
  Binds: [
188
- `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`,
189
- `${(0, containerManager_1.toLocalBindVolume)(baseDir)}:${workingDir}`,
192
+ `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${homeDir}/.kapeta`
190
193
  ],
191
194
  PortBindings,
195
+ Mounts
192
196
  },
193
197
  });
194
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -101,7 +101,7 @@ export class RepositoryWatcher extends EventEmitter {
101
101
  if (path.startsWith(this.baseDir)) {
102
102
  const relativePath = Path.relative(this.baseDir, path);
103
103
  // Inside the repo we can use the path to determine the handle, name and version
104
- [handle, name, version] = relativePath.split(/\//g);
104
+ [handle, name, version] = relativePath.split(Path.sep);
105
105
  if (!handle || !name || !version) {
106
106
  // Do nothing with this
107
107
  return;
@@ -143,8 +143,6 @@ export class RepositoryWatcher extends EventEmitter {
143
143
  return;
144
144
  }
145
145
 
146
- //console.log('File changed', eventName, path);
147
-
148
146
  const assetIdentity = await this.getAssetIdentity(path);
149
147
  if (!assetIdentity) {
150
148
  return;
@@ -156,7 +154,7 @@ export class RepositoryWatcher extends EventEmitter {
156
154
 
157
155
  // If this is false it's because we're watching a symlink target
158
156
  const withinRepo = path.startsWith(this.baseDir);
159
- if (withinRepo && assetIdentity.version === 'local' && path.endsWith('/local')) {
157
+ if (withinRepo && assetIdentity.version === 'local' && path.endsWith(Path.sep + 'local')) {
160
158
  // This is likely a symlink target
161
159
  if (eventName === 'add') {
162
160
  //console.log('Checking if we should add symlink target', handle, name, version, path);
@@ -271,7 +269,7 @@ export class RepositoryWatcher extends EventEmitter {
271
269
  } catch (e) {}
272
270
 
273
271
  if (symbolicLink) {
274
- const realPath = `${await FS.realpath(path)}/kapeta.yml`;
272
+ const realPath = Path.join(await FS.realpath(path), 'kapeta.yml');
275
273
  if (await this.exists(realPath)) {
276
274
  //console.log('Watching symlink target %s => %s', path, realPath);
277
275
  this.watcher?.add(realPath);
@@ -288,7 +286,7 @@ export class RepositoryWatcher extends EventEmitter {
288
286
  if (!path.startsWith(this.baseDir)) {
289
287
  return false;
290
288
  }
291
- if (path.includes('/node_modules/')) {
289
+ if (path.includes(Path.sep + 'node_modules' + Path.sep)) {
292
290
  return true;
293
291
  }
294
292
 
@@ -211,6 +211,12 @@ export class BlockInstanceRunner {
211
211
  HealthCheck = containerManager.toDockerHealth({ cmd: localContainer.healthcheck });
212
212
  }
213
213
 
214
+ const realLocalPath = FS.realpathSync(baseDir);
215
+
216
+ const Mounts = containerManager.toDockerMounts({
217
+ [workingDir]: toLocalBindVolume(realLocalPath)
218
+ });
219
+
214
220
  const systemUri = parseKapetaUri(this._systemId);
215
221
 
216
222
  return this.ensureContainer({
@@ -239,10 +245,10 @@ export class BlockInstanceRunner {
239
245
  HostConfig: {
240
246
  ...customHostConfigs,
241
247
  Binds: [
242
- `${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`,
243
- `${toLocalBindVolume(baseDir)}:${workingDir}`,
248
+ `${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${homeDir}/.kapeta`
244
249
  ],
245
250
  PortBindings,
251
+ Mounts
246
252
  },
247
253
  });
248
254
  }