@emeryld/manager 0.1.2 → 0.1.4

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,23 +1,23 @@
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)
8
8
  const __dirname = path.dirname(__filename)
9
9
  const packageRoot = path.resolve(__dirname, '..')
10
10
  const tsconfigPath = path.join(packageRoot, 'tsconfig.base.json')
11
- const entryPoint = path.join(packageRoot, 'src', 'publish.js')
11
+ 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
15
  const registerCode = [
16
16
  'import { register } from "node:module";',
17
17
  'import { pathToFileURL } from "node:url";',
18
- `register(${JSON.stringify(tsNodeLoader)}, pathToFileURL(${JSON.stringify(
19
- path.dirname(entryPoint),
20
- )}));`,
18
+ `register(${JSON.stringify(
19
+ tsNodeLoader,
20
+ )}, pathToFileURL(${JSON.stringify(entryPoint)}));`,
21
21
  ].join(' ')
22
22
  const registerImport = `data:text/javascript,${encodeURIComponent(registerCode)}`
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/manager",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Interactive manager for pnpm monorepos (update/test/build/publish).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,8 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^20.17.0",
32
- "@types/semver": "^7.7.1"
32
+ "@types/semver": "^7.7.1",
33
+ "cross-env": "^7.0.3"
33
34
  },
34
35
  "ts-node": {
35
36
  "esm": true,
@@ -39,6 +40,7 @@
39
40
  },
40
41
  "scripts": {
41
42
  "build": "tsc -p tsconfig.base.json",
42
- "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"
43
45
  }
44
46
  }
package/src/helper-cli.ts CHANGED
@@ -16,14 +16,14 @@ function getTsNodeLoaderPath() {
16
16
  return tsNodeLoaderPath
17
17
  }
18
18
 
19
- function buildTsNodeRegisterImport(baseDir: string) {
19
+ export function buildTsNodeRegisterImport(scriptPath: string) {
20
20
  const loader = getTsNodeLoaderPath()
21
21
  const code = [
22
22
  'import { register } from "node:module";',
23
23
  'import { pathToFileURL } from "node:url";',
24
24
  `register(${JSON.stringify(
25
25
  loader,
26
- )}, pathToFileURL(${JSON.stringify(baseDir)}));`,
26
+ )}, pathToFileURL(${JSON.stringify(scriptPath)}));`,
27
27
  ].join(' ')
28
28
  return `data:text/javascript,${encodeURIComponent(code)}`
29
29
  }
@@ -329,7 +329,7 @@ function runEntry(entry: ResolvedScriptEntry, forwardedArgs: string[]) {
329
329
  const execArgs = isTypeScript
330
330
  ? [
331
331
  '--import',
332
- buildTsNodeRegisterImport(path.dirname(scriptPath)),
332
+ buildTsNodeRegisterImport(scriptPath),
333
333
  scriptPath,
334
334
  ...forwardedArgs,
335
335
  ]
@@ -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"],