@emeryld/manager 0.1.1 → 0.1.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/bin/manager-cli.js +10 -2
- package/package.json +5 -1
- 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/bin/manager-cli.js
CHANGED
|
@@ -8,12 +8,20 @@ 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.
|
|
11
|
+
const entryPoint = path.join(packageRoot, 'src', 'publish.js')
|
|
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(tsNodeLoader)}, pathToFileURL(${JSON.stringify(
|
|
19
|
+
path.dirname(entryPoint),
|
|
20
|
+
)}));`,
|
|
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.2",
|
|
4
4
|
"description": "Interactive manager for pnpm monorepos (update/test/build/publish).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,10 @@
|
|
|
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
|
+
},
|
|
30
34
|
"ts-node": {
|
|
31
35
|
"esm": true,
|
|
32
36
|
"project": "tsconfig.base.json",
|
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
|
+
function buildTsNodeRegisterImport(baseDir: 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(baseDir)}));`,
|
|
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(path.dirname(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',
|