@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 +33 -0
- package/bin/manager-cli.js +10 -2
- package/package.json +8 -2
- package/src/git.ts +4 -4
- package/src/helper-cli.ts +19 -2
- package/src/menu.ts +9 -9
- package/src/packages.ts +5 -5
- package/src/preflight.ts +6 -6
- package/src/prompts.ts +2 -2
- package/src/publish.ts +7 -7
- package/src/release.ts +9 -9
- package/src/semver.ts +2 -2
- package/src/utils/colors.ts +1 -1
- package/src/utils/log.ts +2 -2
- package/src/utils/run.ts +1 -1
- package/src/workspace.ts +7 -6
- package/tsconfig.base.json +1 -0
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.
|
package/bin/manager-cli.js
CHANGED
|
@@ -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 = ['--
|
|
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.
|
|
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.
|
|
1
|
+
// src/git.js
|
|
2
2
|
import { spawn } from 'node:child_process'
|
|
3
|
-
import { run } from './utils/run.
|
|
4
|
-
import { logGlobal, colors } from './utils/log.
|
|
5
|
-
import { rootDir } from './utils/run.
|
|
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 === '.
|
|
327
|
+
const isTypeScript = extension === '.js' || extension === '.mts' || extension === '.cts'
|
|
316
328
|
const command = process.execPath
|
|
317
329
|
const execArgs = isTypeScript
|
|
318
|
-
? [
|
|
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.
|
|
2
|
-
import type { HelperScriptEntry } from './helper-cli.
|
|
3
|
-
import type { LoadedPackage } from './utils/log.
|
|
4
|
-
import { colors, globalEmoji } from './utils/log.
|
|
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.
|
|
11
|
+
} from './workspace.js'
|
|
12
12
|
|
|
13
|
-
import { releaseMultiple, releaseSingle } from './release.
|
|
14
|
-
import { getOrderedPackages } from './packages.
|
|
15
|
-
import { runHelperCli } from './helper-cli.
|
|
16
|
-
import { ensureWorkingTreeCommitted } from './preflight.
|
|
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.
|
|
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.
|
|
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)
|
|
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)
|
|
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)
|
|
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.
|
|
2
|
-
import { collectGitStatus } from './git.
|
|
1
|
+
// src/preflight.js
|
|
2
|
+
import { collectGitStatus } from './git.js'
|
|
3
3
|
|
|
4
|
-
import { colors, logGlobal } from './utils/log.
|
|
5
|
-
import { run } from './utils/run.
|
|
6
|
-
import { gitAdd, gitCommit } from './git.
|
|
7
|
-
import { askLine } from './prompts.
|
|
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.
|
|
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.
|
|
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.
|
|
2
|
-
import { runHelperCli } from './helper-cli.
|
|
3
|
-
import { buildPackageSelectionMenu, runStepLoop, type StepKey } from './menu.
|
|
4
|
-
import { getOrderedPackages, loadPackages, resolvePackage } from './packages.
|
|
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.
|
|
10
|
-
import { ensureWorkingTreeCommitted } from './preflight.
|
|
11
|
-
import { publishCliState } from './prompts.
|
|
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.
|
|
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.
|
|
5
|
-
import { askLine, promptSingleKey, promptYesNoAll } from './prompts.
|
|
6
|
-
import { bumpVersion, isSemver, type BumpType } from './semver.
|
|
7
|
-
import type { LoadedPackage } from './utils/log.
|
|
8
|
-
import { colors, formatPkgName, logGlobal, logPkg } from './utils/log.
|
|
9
|
-
import { run } from './utils/run.
|
|
10
|
-
|
|
11
|
-
// in release.
|
|
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
package/src/utils/colors.ts
CHANGED
package/src/utils/log.ts
CHANGED
package/src/utils/run.ts
CHANGED
package/src/workspace.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// src/workspace.
|
|
1
|
+
// src/workspace.js
|
|
2
2
|
import { spawnSync } from 'node:child_process'
|
|
3
|
-
import { run, rootDir } from './utils/run.
|
|
4
|
-
import type { LoadedPackage } from './utils/log.
|
|
5
|
-
import { logGlobal, logPkg, colors } from './utils/log.
|
|
6
|
-
import { collectGitStatus, gitAdd, gitCommit } from './git.
|
|
7
|
-
import { askLine, promptSingleKey } from './prompts.
|
|
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',
|