infra-kit 0.1.72 → 0.1.75
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/dist/cli.js +33 -16
- package/dist/cli.js.map +4 -4
- package/dist/mcp.js +29 -19
- package/dist/mcp.js.map +4 -4
- package/package.json +5 -5
- package/src/commands/doctor/doctor.ts +105 -0
- package/src/commands/doctor/index.ts +1 -0
- package/src/commands/env-clear/env-clear.ts +91 -0
- package/src/commands/env-clear/index.ts +1 -0
- package/src/commands/env-init/env-init.ts +83 -0
- package/src/commands/env-init/index.ts +1 -0
- package/src/commands/env-list/env-list.ts +50 -0
- package/src/commands/env-list/index.ts +1 -0
- package/src/commands/env-load/env-load.ts +120 -0
- package/src/commands/env-load/index.ts +1 -0
- package/src/commands/env-status/env-status.ts +103 -0
- package/src/commands/env-status/index.ts +1 -0
- package/src/entry/cli.ts +49 -7
- package/src/entry/mcp.ts +0 -5
- package/src/integrations/doppler/doppler-cli-auth.ts +25 -0
- package/src/integrations/doppler/doppler-project.ts +23 -0
- package/src/integrations/doppler/index.ts +2 -0
- package/src/lib/constants.ts +39 -0
- package/src/lib/logger/index.ts +1 -0
- package/src/mcp/tools/index.ts +8 -0
- package/src/integrations/acli/acli-auth/acli-auth.ts +0 -25
- package/src/integrations/acli/acli-auth/index.ts +0 -1
- package/src/integrations/acli/index.ts +0 -1
- package/src/lib/load-env/index.ts +0 -1
- package/src/lib/load-env/load-env.ts +0 -27
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { $ } from 'zx'
|
|
3
|
+
|
|
4
|
+
import { logger } from 'src/lib/logger'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validate Doppler CLI installation and authentication status and throw an error if not valid
|
|
8
|
+
*/
|
|
9
|
+
export const validateDopplerCliAndAuth = async () => {
|
|
10
|
+
try {
|
|
11
|
+
await $`doppler --version`
|
|
12
|
+
} catch (error: unknown) {
|
|
13
|
+
logger.error({ error }, 'Error: Doppler CLI is not installed.')
|
|
14
|
+
logger.error('Please install it from: https://docs.doppler.com/docs/install-cli')
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await $`doppler me`
|
|
20
|
+
} catch (error: unknown) {
|
|
21
|
+
logger.error({ error }, 'Error: Doppler CLI is not authenticated.')
|
|
22
|
+
logger.error('Please authenticate by running: doppler login')
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import { DOPPLER_PROJECT_MAP } from 'src/lib/constants'
|
|
4
|
+
import { getProjectRoot } from 'src/lib/git-utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolve Doppler project name from the current working directory
|
|
8
|
+
*/
|
|
9
|
+
export const getDopplerProject = async (): Promise<string> => {
|
|
10
|
+
const projectRoot = await getProjectRoot()
|
|
11
|
+
|
|
12
|
+
const dirName = path.basename(projectRoot)
|
|
13
|
+
const dopplerProject = DOPPLER_PROJECT_MAP[dirName]
|
|
14
|
+
|
|
15
|
+
if (!dopplerProject) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Could not determine Doppler project for directory "${dirName}". ` +
|
|
18
|
+
`Expected one of: ${Object.keys(DOPPLER_PROJECT_MAP).join(', ')}`,
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return dopplerProject
|
|
23
|
+
}
|
package/src/lib/constants.ts
CHANGED
|
@@ -1,8 +1,47 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import process from 'node:process'
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* List of environments for the project deployment
|
|
3
7
|
*/
|
|
4
8
|
export const ENVs = ['dev', 'arthur', 'renana', 'roman', 'eliran', 'oriana']
|
|
5
9
|
|
|
10
|
+
export const DOPPLER_PROJECT_MAP: Record<string, string> = {
|
|
11
|
+
'hulyo-monorepo': 'hulyo',
|
|
12
|
+
'travelist-monorepo': 'travelist',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const ENV_CACHE_DIR = './node_modules/.cache/infra-kit'
|
|
16
|
+
export const ENV_LOAD_FILE = 'env-load.env'
|
|
17
|
+
export const ENV_CLEAR_FILE = 'env-clear.sh'
|
|
18
|
+
|
|
19
|
+
export const INFRA_KIT_SESSION_VAR = 'INFRA_KIT_SESSION'
|
|
20
|
+
export const INFRA_KIT_ENV_CONFIG_VAR = 'INFRA_KIT_ENV_CONFIG'
|
|
21
|
+
export const INFRA_KIT_ENV_PROJECT_VAR = 'INFRA_KIT_ENV_PROJECT'
|
|
22
|
+
export const INFRA_KIT_ENV_LOADED_AT_VAR = 'INFRA_KIT_ENV_LOADED_AT'
|
|
23
|
+
|
|
24
|
+
export const parseVarNamesFromEnvFile = (filePath: string): string[] => {
|
|
25
|
+
if (!fs.existsSync(filePath)) return []
|
|
26
|
+
|
|
27
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
28
|
+
|
|
29
|
+
return content
|
|
30
|
+
.split('\n')
|
|
31
|
+
.filter((line) => line.includes('=') && !line.startsWith('set '))
|
|
32
|
+
.map((line) => line.split('=')[0]!)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const getSessionCacheDir = (): string => {
|
|
36
|
+
const session = process.env[INFRA_KIT_SESSION_VAR]
|
|
37
|
+
|
|
38
|
+
if (!session) {
|
|
39
|
+
throw new Error('INFRA_KIT_SESSION is not set. Run `source ~/.zshrc` or `infra-kit env-init` first.')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return path.join(ENV_CACHE_DIR, session)
|
|
43
|
+
}
|
|
44
|
+
|
|
6
45
|
export const WORKTREES_DIR_SUFFIX = '-worktrees'
|
|
7
46
|
// eslint-disable-next-line sonarjs/publicly-writable-directories
|
|
8
47
|
export const LOG_FILE_PATH = '/tmp/mcp-infra-kit.log'
|
package/src/lib/logger/index.ts
CHANGED
package/src/mcp/tools/index.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
2
|
|
|
3
|
+
import { envClearMcpTool } from 'src/commands/env-clear'
|
|
4
|
+
import { envListMcpTool } from 'src/commands/env-list'
|
|
5
|
+
import { envLoadMcpTool } from 'src/commands/env-load'
|
|
6
|
+
import { envStatusMcpTool } from 'src/commands/env-status'
|
|
3
7
|
import { ghMergeDevMcpTool } from 'src/commands/gh-merge-dev'
|
|
4
8
|
import { ghReleaseDeliverMcpTool } from 'src/commands/gh-release-deliver'
|
|
5
9
|
import { ghReleaseDeployAllMcpTool } from 'src/commands/gh-release-deploy-all'
|
|
@@ -15,6 +19,10 @@ import { worktreesSyncMcpTool } from 'src/commands/worktrees-sync'
|
|
|
15
19
|
import { createToolHandler } from 'src/lib/tool-handler'
|
|
16
20
|
|
|
17
21
|
const tools = [
|
|
22
|
+
envStatusMcpTool,
|
|
23
|
+
envListMcpTool,
|
|
24
|
+
envLoadMcpTool,
|
|
25
|
+
envClearMcpTool,
|
|
18
26
|
ghMergeDevMcpTool,
|
|
19
27
|
releaseCreateMcpTool,
|
|
20
28
|
releaseCreateBatchMcpTool,
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import process from 'node:process'
|
|
2
|
-
import { $ } from 'zx'
|
|
3
|
-
|
|
4
|
-
import { logger } from 'src/lib/logger'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Validate Atlassian CLI installation and authentication status and throw an error if not valid
|
|
8
|
-
*/
|
|
9
|
-
export const validateAtlassianCliAndAuth = async () => {
|
|
10
|
-
try {
|
|
11
|
-
await $`acli --version`
|
|
12
|
-
} catch (error: unknown) {
|
|
13
|
-
logger.error({ error }, 'Error: Atlassian CLI (atlassian) is not installed.')
|
|
14
|
-
logger.error('Please install it from: https://developer.atlassian.com/cloud/acli/guides/install-macos/')
|
|
15
|
-
process.exit(1)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
await $`gh auth status`
|
|
20
|
-
} catch (error: unknown) {
|
|
21
|
-
logger.error({ error }, 'Error: GitHub CLI (gh) is not authenticated.')
|
|
22
|
-
logger.error('Please authenticate it from: https://cli.github.com/manual/gh_auth_login or type "gh auth login"')
|
|
23
|
-
process.exit(1)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { validateAtlassianCliAndAuth } from './acli-auth'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { validateAtlassianCliAndAuth } from './acli-auth'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { loadEnvFromGitRoot } from './load-env'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { config } from 'dotenv'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { $ } from 'zx'
|
|
4
|
-
|
|
5
|
-
import { getProjectRoot } from 'src/lib/git-utils'
|
|
6
|
-
import { logger } from 'src/lib/logger'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Load .env file from git repository root
|
|
10
|
-
* Uses getProjectRoot to find the repository root, works regardless of where package is installed
|
|
11
|
-
*/
|
|
12
|
-
export const loadEnvFromGitRoot = async (): Promise<void> => {
|
|
13
|
-
try {
|
|
14
|
-
$.quiet = true
|
|
15
|
-
|
|
16
|
-
const gitRoot = await getProjectRoot()
|
|
17
|
-
|
|
18
|
-
config({ path: resolve(gitRoot, '.env'), quiet: true })
|
|
19
|
-
|
|
20
|
-
logger.info('Loaded .env file from git repository root')
|
|
21
|
-
} catch {
|
|
22
|
-
// Git command failed - not in a git repository or git not available
|
|
23
|
-
// This is acceptable, env vars might be provided another way
|
|
24
|
-
} finally {
|
|
25
|
-
$.quiet = false
|
|
26
|
-
}
|
|
27
|
-
}
|