rootless-config 1.0.0 → 1.0.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/package.json
CHANGED
|
@@ -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)
|
package/src/cli/commands/init.js
CHANGED
|
@@ -4,7 +4,6 @@ import path from 'node:path'
|
|
|
4
4
|
import { createLogger } from '../../utils/logger.js'
|
|
5
5
|
import { fileExists, ensureDir, atomicWrite, writeJsonFile } from '../../utils/fsUtils.js'
|
|
6
6
|
import { confirm } from '../../utils/prompt.js'
|
|
7
|
-
import { resolveProjectRoot } from '../../core/pathResolver.js'
|
|
8
7
|
import { getLibraryVersion } from '../../core/versionCheck.js'
|
|
9
8
|
|
|
10
9
|
const DIRS = ['configs', 'env', 'assets']
|
|
@@ -25,7 +24,7 @@ export default {
|
|
|
25
24
|
|
|
26
25
|
async handler(args) {
|
|
27
26
|
const logger = createLogger({ verbose: args.verbose ?? false })
|
|
28
|
-
const projectRoot =
|
|
27
|
+
const projectRoot = args.cwd ? path.resolve(args.cwd) : process.cwd()
|
|
29
28
|
const containerPath = path.join(projectRoot, '.root')
|
|
30
29
|
|
|
31
30
|
if (await fileExists(containerPath)) {
|
|
@@ -6,7 +6,6 @@ import { createLogger } from '../../utils/logger.js'
|
|
|
6
6
|
import { fileExists, ensureDir, atomicWrite } from '../../utils/fsUtils.js'
|
|
7
7
|
import { readFile } from 'node:fs/promises'
|
|
8
8
|
import { confirm } from '../../utils/prompt.js'
|
|
9
|
-
import { resolveProjectRoot } from '../../core/pathResolver.js'
|
|
10
9
|
|
|
11
10
|
const CONFIG_PATTERN = /\.(config|rc)\.(js|ts|mjs|cjs|json)$|\.eslintrc$|\.babelrc$/
|
|
12
11
|
const ENV_PATTERN = /^\.env/
|
|
@@ -25,7 +24,7 @@ export default {
|
|
|
25
24
|
|
|
26
25
|
async handler(args) {
|
|
27
26
|
const logger = createLogger({ verbose: args.verbose ?? false })
|
|
28
|
-
const projectRoot =
|
|
27
|
+
const projectRoot = args.cwd ? path.resolve(args.cwd) : process.cwd()
|
|
29
28
|
const containerPath = path.join(projectRoot, '.root')
|
|
30
29
|
|
|
31
30
|
const candidates = await findMigratableFiles(projectRoot)
|
|
@@ -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(
|
|
25
|
+
mod = await import(importTarget)
|
|
20
26
|
} catch (err) {
|
|
21
27
|
throw new PluginError(`Cannot load plugin module "${moduleName}": ${err.message}`, moduleName)
|
|
22
28
|
}
|