rootless-config 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rootless-config",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Store project config files outside the project root, auto-deploy them where tools expect them.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  /*-------- Auto-discovers and registers CLI commands from src/cli/commands/ --------*/
2
2
 
3
3
  import path from 'node:path'
4
- import { fileURLToPath } from 'node:url'
4
+ import { fileURLToPath, pathToFileURL } from 'node:url'
5
5
  import { readdir } from 'node:fs/promises'
6
6
  import { RcsError } from '../types/errors.js'
7
7
 
@@ -15,7 +15,7 @@ function createCommandRegistry() {
15
15
  const jsFiles = entries.filter(e => e.isFile() && e.name.endsWith('.js'))
16
16
 
17
17
  for (const file of jsFiles) {
18
- const mod = await import(path.join(COMMANDS_DIR, file.name))
18
+ const mod = await import(pathToFileURL(path.join(COMMANDS_DIR, file.name)).href)
19
19
  const descriptor = mod.default ?? mod
20
20
  if (!descriptor?.name || typeof descriptor?.handler !== 'function') continue
21
21
  commands.set(descriptor.name, descriptor)
@@ -1,5 +1,7 @@
1
1
  /*-------- Discovers, validates, and loads plugins into a registry --------*/
2
2
 
3
+ import path from 'node:path'
4
+ import { pathToFileURL } from 'node:url'
3
5
  import { assertValidPlugin } from '../types/pluginInterface.js'
4
6
  import { PluginError } from '../types/errors.js'
5
7
  import { BUILTIN_PLUGINS } from './builtins/index.js'
@@ -11,12 +13,16 @@ async function loadPlugins(config = {}, registry) {
11
13
 
12
14
  const externalDefs = config.plugins ?? []
13
15
  for (const def of externalDefs) {
14
- const moduleName = typeof def === 'string' ? def : def.name
16
+ const moduleName = typeof def === 'string' ? def : (def.path ?? def.name)
15
17
  const pluginOptions = typeof def === 'object' ? def.options ?? {} : {}
16
18
 
19
+ // Local paths (./foo or absolute) must be converted to file:// URLs on Windows
20
+ const isLocalPath = moduleName.startsWith('.') || path.isAbsolute(moduleName)
21
+ const importTarget = isLocalPath ? pathToFileURL(path.resolve(moduleName)).href : moduleName
22
+
17
23
  let mod
18
24
  try {
19
- mod = await import(moduleName)
25
+ mod = await import(importTarget)
20
26
  } catch (err) {
21
27
  throw new PluginError(`Cannot load plugin module "${moduleName}": ${err.message}`, moduleName)
22
28
  }