@emeryld/manager 0.1.1 → 0.1.3

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 ADDED
@@ -0,0 +1,33 @@
1
+ # @emeryld/manager
2
+
3
+ Interactive release helper for pnpm monorepos. Install it as a local dev dependency, then run `pnpm manager-cli` (or call a `scripts.manager-cli` alias) from your workspace root to walk through selecting packages, running updates/tests/builds, and publishing.
4
+
5
+ ## Installation
6
+
7
+ 1. Ensure your workspace has a `packages/` directory (or configure one via `packages.mjs`).
8
+ 2. Add the manager to your dev dependencies so its CLI and helpers are hoisted into the consuming repo:
9
+ ```sh
10
+ pnpm add -D @emeryld/manager
11
+ ```
12
+ 3. Include a script in your `package.json` so you can invoke it consistently:
13
+ ```json
14
+ {
15
+ "scripts": {
16
+ "manager-cli": "manager-cli"
17
+ }
18
+ }
19
+ ```
20
+ 4. Run `pnpm install` to fetch `ts-node`, `semver`, and other runtime deps.
21
+
22
+ ## Running the CLI
23
+
24
+ - Always run `pnpm manager-cli` (or `pnpm run manager-cli`) from the **workspace root** where your `packages/` folder lives. The manager operates against the workspace you are in, not the package that ships the tool.
25
+ - Each TypeScript helper script registers the bundled `ts-node/esm` loader with the exact script path, so the CLI works even from pnpm workspaces that hoist dependencies.
26
+ - To avoid the warning/error you saw earlier, make sure:
27
+ - the workspace has `packages/` (or a configured manifest) so `loadPackages()` can find targets,
28
+ - `pnpm install` has already written `ts-node` into `node_modules`,
29
+ - you execute the CLI from the workspace that owns those packages.
30
+
31
+ ## Testing the loader registration
32
+
33
+ Run `pnpm test` to ensure the helper CLI always generates a `--import data:text...` snippet that registers `ts-node/esm.mjs` with **the actual script file path**. This guards against regressions that would make Node reject the loader and crash before the interactive menu appears.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from 'node:child_process'
3
3
  import path from 'node:path'
4
- import { fileURLToPath } from 'node:url'
4
+ import { fileURLToPath, pathToFileURL } from 'node:url'
5
5
  import { createRequire } from 'node:module'
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url)
@@ -12,8 +12,16 @@ const entryPoint = path.join(packageRoot, 'src', 'publish.ts')
12
12
 
13
13
  const require = createRequire(import.meta.url)
14
14
  const tsNodeLoader = require.resolve('ts-node/esm.mjs')
15
+ const registerCode = [
16
+ 'import { register } from "node:module";',
17
+ 'import { pathToFileURL } from "node:url";',
18
+ `register(${JSON.stringify(
19
+ tsNodeLoader,
20
+ )}, pathToFileURL(${JSON.stringify(entryPoint)}));`,
21
+ ].join(' ')
22
+ const registerImport = `data:text/javascript,${encodeURIComponent(registerCode)}`
15
23
 
16
- const nodeArgs = ['--loader', tsNodeLoader, entryPoint, ...process.argv.slice(2)]
24
+ const nodeArgs = ['--import', registerImport, entryPoint, ...process.argv.slice(2)]
17
25
  const execOptions = {
18
26
  env: { ...process.env, TS_NODE_PROJECT: tsconfigPath },
19
27
  stdio: 'inherit',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/manager",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Interactive manager for pnpm monorepos (update/test/build/publish).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,6 +27,11 @@
27
27
  "ts-node": "^10.9.1",
28
28
  "typescript": "^5.3.0"
29
29
  },
30
+ "devDependencies": {
31
+ "@types/node": "^20.17.0",
32
+ "@types/semver": "^7.7.1",
33
+ "cross-env": "^7.0.3"
34
+ },
30
35
  "ts-node": {
31
36
  "esm": true,
32
37
  "project": "tsconfig.base.json",
@@ -35,6 +40,7 @@
35
40
  },
36
41
  "scripts": {
37
42
  "build": "tsc -p tsconfig.base.json",
38
- "typecheck": "tsc -p tsconfig.base.json --noEmit"
43
+ "typecheck": "tsc -p tsconfig.base.json --noEmit",
44
+ "test": "cross-env TS_NODE_PROJECT=tsconfig.base.json node --loader ts-node/esm test/helper-cli.test.ts"
39
45
  }
40
46
  }
package/src/git.ts CHANGED
@@ -1,8 +1,8 @@
1
- // src/git.ts
1
+ // src/git.js
2
2
  import { spawn } from 'node:child_process'
3
- import { run } from './utils/run.ts'
4
- import { logGlobal, colors } from './utils/log.ts'
5
- import { rootDir } from './utils/run.ts'
3
+ import { run } from './utils/run.js'
4
+ import { logGlobal, colors } from './utils/log.js'
5
+ import { rootDir } from './utils/run.js'
6
6
 
7
7
  export async function collectGitStatus(): Promise<string[]> {
8
8
  return new Promise<string[]>((resolve, reject) => {
package/src/helper-cli.ts CHANGED
@@ -16,6 +16,18 @@ function getTsNodeLoaderPath() {
16
16
  return tsNodeLoaderPath
17
17
  }
18
18
 
19
+ export function buildTsNodeRegisterImport(scriptPath: string) {
20
+ const loader = getTsNodeLoaderPath()
21
+ const code = [
22
+ 'import { register } from "node:module";',
23
+ 'import { pathToFileURL } from "node:url";',
24
+ `register(${JSON.stringify(
25
+ loader,
26
+ )}, pathToFileURL(${JSON.stringify(scriptPath)}));`,
27
+ ].join(' ')
28
+ return `data:text/javascript,${encodeURIComponent(code)}`
29
+ }
30
+
19
31
  const ansi = (code: number) => (text: string) => `\x1b[${code}m${text}\x1b[0m`
20
32
  const colors = {
21
33
  cyan: ansi(36),
@@ -312,10 +324,15 @@ function runEntry(entry: ResolvedScriptEntry, forwardedArgs: string[]) {
312
324
  const scriptPath = entry.absoluteScript
313
325
  const tsConfigPath = path.join(rootDir, 'tsconfig.base.json')
314
326
  const extension = path.extname(scriptPath).toLowerCase()
315
- const isTypeScript = extension === '.ts' || extension === '.mts' || extension === '.cts'
327
+ const isTypeScript = extension === '.js' || extension === '.mts' || extension === '.cts'
316
328
  const command = process.execPath
317
329
  const execArgs = isTypeScript
318
- ? ['--loader', getTsNodeLoaderPath(), scriptPath, ...forwardedArgs]
330
+ ? [
331
+ '--import',
332
+ buildTsNodeRegisterImport(scriptPath),
333
+ scriptPath,
334
+ ...forwardedArgs,
335
+ ]
319
336
  : [scriptPath, ...forwardedArgs]
320
337
  return new Promise<void>((resolve, reject) => {
321
338
  const child = spawn(command, execArgs, {
package/src/menu.ts CHANGED
@@ -1,19 +1,19 @@
1
- // src/menu.ts
2
- import type { HelperScriptEntry } from './helper-cli.ts'
3
- import type { LoadedPackage } from './utils/log.ts'
4
- import { colors, globalEmoji } from './utils/log.ts'
1
+ // src/menu.js
2
+ import type { HelperScriptEntry } from './helper-cli.js'
3
+ import type { LoadedPackage } from './utils/log.js'
4
+ import { colors, globalEmoji } from './utils/log.js'
5
5
  import {
6
6
  updateDependencies,
7
7
  testAll,
8
8
  testSingle,
9
9
  buildAll,
10
10
  buildSingle,
11
- } from './workspace.ts'
11
+ } from './workspace.js'
12
12
 
13
- import { releaseMultiple, releaseSingle } from './release.ts'
14
- import { getOrderedPackages } from './packages.ts'
15
- import { runHelperCli } from './helper-cli.ts'
16
- import { ensureWorkingTreeCommitted } from './preflight.ts'
13
+ import { releaseMultiple, releaseSingle } from './release.js'
14
+ import { getOrderedPackages } from './packages.js'
15
+ import { runHelperCli } from './helper-cli.js'
16
+ import { ensureWorkingTreeCommitted } from './preflight.js'
17
17
 
18
18
  export type StepKey = 'update' | 'test' | 'build' | 'publish' | 'full' | 'back'
19
19
 
package/src/packages.ts CHANGED
@@ -1,8 +1,8 @@
1
- // src/packages.ts
1
+ // src/packages.js
2
2
  import path from 'node:path'
3
3
  import { pathToFileURL } from 'node:url'
4
4
  import { readdir, readFile } from 'node:fs/promises'
5
- import type { PackageColor, LoadedPackage } from './utils/log.ts'
5
+ import type { PackageColor, LoadedPackage } from './utils/log.js'
6
6
 
7
7
  const rootDir = process.cwd()
8
8
  export const packagesDir = path.join(rootDir, 'packages')
@@ -123,7 +123,7 @@ function mergeManifestEntries(
123
123
  const name = override.name || baseEntry.name
124
124
  const color = override.color ?? baseEntry.color ?? colorFromSeed(name)
125
125
  const substitute =
126
- override.substitute ?? baseEntry.substitute ?? deriveSubstitute(name) || name
126
+ override.substitute ?? baseEntry.substitute ?? deriveSubstitute(name) ?? name
127
127
  merged.push({ name, path: normalized, color, substitute })
128
128
  } else {
129
129
  merged.push({ ...baseEntry, path: normalized })
@@ -133,7 +133,7 @@ function mergeManifestEntries(
133
133
  normalizedOverrides.forEach((entry) => {
134
134
  const name = entry.name || path.basename(entry.path) || 'package'
135
135
  const color = entry.color ?? colorFromSeed(name)
136
- const substitute = entry.substitute ?? deriveSubstitute(name) || name
136
+ const substitute = entry.substitute ?? deriveSubstitute(name) ?? name
137
137
  merged.push({ name, path: entry.path, color, substitute })
138
138
  })
139
139
 
@@ -176,7 +176,7 @@ export async function loadPackages(): Promise<LoadedPackage[]> {
176
176
  byPath.get(relativePath.toLowerCase()) ??
177
177
  byName.get(pkgName.toLowerCase())
178
178
  const substitute =
179
- meta?.substitute ?? deriveSubstitute(pkgName) || entry.name
179
+ meta?.substitute ?? deriveSubstitute(pkgName) ?? entry.name
180
180
  const color = meta?.color ?? colorFromSeed(pkgName)
181
181
  packages.push({
182
182
  dirName: entry.name,
package/src/preflight.ts CHANGED
@@ -1,10 +1,10 @@
1
- // src/preflight.ts
2
- import { collectGitStatus } from './git.ts'
1
+ // src/preflight.js
2
+ import { collectGitStatus } from './git.js'
3
3
 
4
- import { colors, logGlobal } from './utils/log.ts'
5
- import { run } from './utils/run.ts'
6
- import { gitAdd, gitCommit } from './git.ts'
7
- import { askLine } from './prompts.ts'
4
+ import { colors, logGlobal } from './utils/log.js'
5
+ import { run } from './utils/run.js'
6
+ import { gitAdd, gitCommit } from './git.js'
7
+ import { askLine } from './prompts.js'
8
8
 
9
9
  export async function ensureWorkingTreeCommitted() {
10
10
  const changes = await collectGitStatus()
package/src/prompts.ts CHANGED
@@ -1,7 +1,7 @@
1
- // src/prompts.ts
1
+ // src/prompts.js
2
2
  import readline from 'node:readline/promises'
3
3
  import { stdin as input, stdout as output } from 'node:process'
4
- import { colors } from './utils/log.ts'
4
+ import { colors } from './utils/log.js'
5
5
 
6
6
  export type YesNoAll = 'yes' | 'no' | 'all'
7
7
 
package/src/publish.ts CHANGED
@@ -1,14 +1,14 @@
1
- // src/publish.ts
2
- import { runHelperCli } from './helper-cli.ts'
3
- import { buildPackageSelectionMenu, runStepLoop, type StepKey } from './menu.ts'
4
- import { getOrderedPackages, loadPackages, resolvePackage } from './packages.ts'
1
+ // src/publish.js
2
+ import { runHelperCli } from './helper-cli.js'
3
+ import { buildPackageSelectionMenu, runStepLoop, type StepKey } from './menu.js'
4
+ import { getOrderedPackages, loadPackages, resolvePackage } from './packages.js'
5
5
  import {
6
6
  releaseMultiple,
7
7
  releaseSingle,
8
8
  type PublishOptions,
9
- } from './release.ts'
10
- import { ensureWorkingTreeCommitted } from './preflight.ts'
11
- import { publishCliState } from './prompts.ts'
9
+ } from './release.js'
10
+ import { ensureWorkingTreeCommitted } from './preflight.js'
11
+ import { publishCliState } from './prompts.js'
12
12
 
13
13
  type Parsed = {
14
14
  selectionArg?: string
package/src/release.ts CHANGED
@@ -1,14 +1,14 @@
1
- // src/release.ts
1
+ // src/release.js
2
2
  import { readFile, writeFile } from 'node:fs/promises'
3
3
  import path from 'node:path'
4
- import { stageCommitPush } from './git.ts'
5
- import { askLine, promptSingleKey, promptYesNoAll } from './prompts.ts'
6
- import { bumpVersion, isSemver, type BumpType } from './semver.ts'
7
- import type { LoadedPackage } from './utils/log.ts'
8
- import { colors, formatPkgName, logGlobal, logPkg } from './utils/log.ts'
9
- import { run } from './utils/run.ts'
10
-
11
- // in release.ts
4
+ import { stageCommitPush } from './git.js'
5
+ import { askLine, promptSingleKey, promptYesNoAll } from './prompts.js'
6
+ import { bumpVersion, isSemver, type BumpType } from './semver.js'
7
+ import type { LoadedPackage } from './utils/log.js'
8
+ import { colors, formatPkgName, logGlobal, logPkg } from './utils/log.js'
9
+ import { run } from './utils/run.js'
10
+
11
+ // in release.js
12
12
 
13
13
  type VersionStrategy =
14
14
  | { mode: 'bump'; bumpType: BumpType; preid?: string }
package/src/semver.ts CHANGED
@@ -1,5 +1,5 @@
1
- // src/semver.ts
2
- import { inc, valid } from 'semver'
1
+ // src/semver.js
2
+ import { inc, valid, } from 'semver'
3
3
 
4
4
  export type BumpType =
5
5
  | 'patch'
@@ -1,4 +1,4 @@
1
- // src/utils/colors.ts
1
+ // src/utils/colors.js
2
2
  const ansi = (code: number) => (text: string) => `\x1b[${code}m${text}\x1b[0m`
3
3
  export const colors = {
4
4
  cyan: ansi(36),
package/src/utils/log.ts CHANGED
@@ -1,5 +1,5 @@
1
- // src/utils/log.ts
2
- import { colors } from './colors.ts'
1
+ // src/utils/log.js
2
+ import { colors } from './colors.js'
3
3
 
4
4
  export type PackageColor = 'cyan' | 'green' | 'yellow' | 'magenta' | 'red'
5
5
  export const defaultPackageColor: PackageColor = 'cyan'
package/src/utils/run.ts CHANGED
@@ -1,4 +1,4 @@
1
- // src/utils/run.ts
1
+ // src/utils/run.js
2
2
  import { spawn, type SpawnOptions } from 'node:child_process'
3
3
  import path from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
package/src/workspace.ts CHANGED
@@ -1,10 +1,11 @@
1
- // src/workspace.ts
1
+ // src/workspace.js
2
2
  import { spawnSync } from 'node:child_process'
3
- import { run, rootDir } from './utils/run.ts'
4
- import type { LoadedPackage } from './utils/log.ts'
5
- import { logGlobal, logPkg, colors } from './utils/log.ts'
6
- import { collectGitStatus, gitAdd, gitCommit } from './git.ts'
7
- import { askLine, promptSingleKey } from './prompts.ts'
3
+ import { run, rootDir } from './utils/run.js'
4
+ import type { LoadedPackage } from './utils/log.js'
5
+ import { logGlobal, logPkg, colors } from './utils/log.js'
6
+ import { collectGitStatus, gitAdd, gitCommit } from './git.js'
7
+ import { askLine, promptSingleKey } from './prompts.js'
8
+
8
9
 
9
10
  const dependencyFiles = new Set([
10
11
  'package.json',
@@ -3,6 +3,7 @@
3
3
  "target": "ES2022",
4
4
  "module": "NodeNext",
5
5
  "moduleResolution": "NodeNext",
6
+ "allowImportingTsExtensions": true,
6
7
  "rootDir": "src",
7
8
  "outDir": "dist",
8
9
  "lib": ["ES2022"],