@ankhorage/infra 7.1.1 → 7.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/CHANGELOG.md +6 -0
- package/dist/cli/runInfraCliAsync.d.ts.map +1 -1
- package/dist/cli/runInfraCliAsync.js +8 -6
- package/dist/cli/runInfraCliAsync.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/cli.test.ts +21 -5
- package/src/cli/runInfraCliAsync.ts +11 -7
- package/src/commands.test.ts +8 -2
- package/src/constants.ts +1 -0
- package/dist/cli/renderInfraRootHelp.d.ts +0 -3
- package/dist/cli/renderInfraRootHelp.d.ts.map +0 -1
- package/dist/cli/renderInfraRootHelp.js +0 -21
- package/dist/cli/renderInfraRootHelp.js.map +0 -1
- package/src/cli/renderInfraRootHelp.ts +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runInfraCliAsync.d.ts","sourceRoot":"","sources":["../../src/cli/runInfraCliAsync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runInfraCliAsync.d.ts","sourceRoot":"","sources":["../../src/cli/runInfraCliAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAO9B,iGAAiG;AACjG,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,CAwBhC;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,cAAc,CAAC,EAAE,mBAAmB,CAAC;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACnD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { isHelpToken, renderProviderHelp } from '@ankhorage/ankh';
|
|
2
|
+
import { INFRA_PACKAGE_DESCRIPTION } from '../constants.js';
|
|
1
3
|
import { createDefaultInfraCommandContext } from './createDefaultInfraCommandContext.js';
|
|
4
|
+
import { createInfraRuntimeProvider } from './createInfraRuntimeProvider.js';
|
|
2
5
|
import { findInfraCommand } from './findInfraCommand.js';
|
|
3
|
-
import { renderInfraRootHelp } from './renderInfraRootHelp.js';
|
|
4
6
|
import { renderUnknownInfraCommand } from './renderUnknownInfraCommand.js';
|
|
5
7
|
import { runInfraCommandAsync } from './runInfraCommandAsync.js';
|
|
6
8
|
/*** Dispatch the standalone executable arguments through the canonical Infra command surface. */
|
|
@@ -9,7 +11,11 @@ export async function runInfraCliAsync(argv, options = {}) {
|
|
|
9
11
|
const runCommand = options.runCommandImpl ?? runInfraCommandAsync;
|
|
10
12
|
const [firstToken, ...restTokens] = argv;
|
|
11
13
|
if (firstToken === undefined || isHelpToken(firstToken)) {
|
|
12
|
-
context.writeStdout(
|
|
14
|
+
context.writeStdout(renderProviderHelp({
|
|
15
|
+
commandPrefix: ['ankhorage-infra'],
|
|
16
|
+
description: INFRA_PACKAGE_DESCRIPTION,
|
|
17
|
+
manifest: createInfraRuntimeProvider(),
|
|
18
|
+
}));
|
|
13
19
|
return { exitCode: 0 };
|
|
14
20
|
}
|
|
15
21
|
if (isVersionToken(firstToken)) {
|
|
@@ -23,10 +29,6 @@ export async function runInfraCliAsync(argv, options = {}) {
|
|
|
23
29
|
}
|
|
24
30
|
return runCommand({ argv: restTokens, command, context }, { services: options.services });
|
|
25
31
|
}
|
|
26
|
-
/*** Recognize standalone help tokens. */
|
|
27
|
-
function isHelpToken(value) {
|
|
28
|
-
return value === '--help' || value === '-h' || value === 'help';
|
|
29
|
-
}
|
|
30
32
|
/*** Recognize standalone version tokens. */
|
|
31
33
|
function isVersionToken(value) {
|
|
32
34
|
return value === '--version' || value === '-v' || value === 'version';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runInfraCliAsync.js","sourceRoot":"","sources":["../../src/cli/runInfraCliAsync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runInfraCliAsync.js","sourceRoot":"","sources":["../../src/cli/runInfraCliAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAO5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAuB,EACvB,UAA2B,EAAE;IAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,gCAAgC,EAAE,CAAC;IACtE,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,IAAI,oBAAoB,CAAC;IAClE,MAAM,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;IACzC,IAAI,UAAU,KAAK,SAAS,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;QACxD,OAAO,CAAC,WAAW,CACjB,kBAAkB,CAAC;YACjB,aAAa,EAAE,CAAC,iBAAiB,CAAC;YAClC,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,0BAA0B,EAAE;SACvC,CAAC,CACH,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACzB,CAAC;IACD,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QAC5C,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACzB,CAAC;IACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,WAAW,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC5F,CAAC;AAQD,4CAA4C;AAC5C,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AACxE,CAAC","sourcesContent":["import { isHelpToken, renderProviderHelp } from '@ankhorage/ankh';\n\nimport { INFRA_PACKAGE_DESCRIPTION } from '../constants.js';\nimport type {\n InfraCommandContext,\n InfraCommandRunResult,\n InfraCommandServices,\n RunInfraCommandImpl,\n} from '../types/infraCli.js';\nimport { createDefaultInfraCommandContext } from './createDefaultInfraCommandContext.js';\nimport { createInfraRuntimeProvider } from './createInfraRuntimeProvider.js';\nimport { findInfraCommand } from './findInfraCommand.js';\nimport { renderUnknownInfraCommand } from './renderUnknownInfraCommand.js';\nimport { runInfraCommandAsync } from './runInfraCommandAsync.js';\n\n/*** Dispatch the standalone executable arguments through the canonical Infra command surface. */\nexport async function runInfraCliAsync(\n argv: readonly string[],\n options: InfraCliOptions = {},\n): Promise<InfraCommandRunResult> {\n const context = options.context ?? createDefaultInfraCommandContext();\n const runCommand = options.runCommandImpl ?? runInfraCommandAsync;\n const [firstToken, ...restTokens] = argv;\n if (firstToken === undefined || isHelpToken(firstToken)) {\n context.writeStdout(\n renderProviderHelp({\n commandPrefix: ['ankhorage-infra'],\n description: INFRA_PACKAGE_DESCRIPTION,\n manifest: createInfraRuntimeProvider(),\n }),\n );\n return { exitCode: 0 };\n }\n if (isVersionToken(firstToken)) {\n context.writeStdout(`${context.version}\\n`);\n return { exitCode: 0 };\n }\n const command = findInfraCommand(firstToken);\n if (command === null) {\n context.writeStderr(renderUnknownInfraCommand(firstToken));\n return { exitCode: 1 };\n }\n return runCommand({ argv: restTokens, command, context }, { services: options.services });\n}\n\ninterface InfraCliOptions {\n readonly context?: InfraCommandContext;\n readonly runCommandImpl?: RunInfraCommandImpl;\n readonly services?: Partial<InfraCommandServices>;\n}\n\n/*** Recognize standalone version tokens. */\nfunction isVersionToken(value: string): boolean {\n return value === '--version' || value === '-v' || value === 'version';\n}\n"]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const INFRA_PACKAGE_NAME: string;
|
|
2
2
|
export declare const INFRA_PACKAGE_VERSION: string;
|
|
3
|
+
export declare const INFRA_PACKAGE_DESCRIPTION: string;
|
|
3
4
|
export declare const INFRA_COMMAND_CATEGORY: "infra";
|
|
4
5
|
export declare const INFRA_CAPABILITIES: readonly ["infra.validate", "infra.plan", "infra.generate", "infra.up", "infra.status", "infra.outputs", "infra.down", "infra.destroy"];
|
|
5
6
|
export declare const INFRA_PACKAGE_METADATA: {
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AACnD,eAAO,MAAM,qBAAqB,QAAsB,CAAC;AACzD,eAAO,MAAM,sBAAsB,SAAiD,CAAC;AACrF,eAAO,MAAM,kBAAkB,yIASiB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;CAIK,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AACnD,eAAO,MAAM,qBAAqB,QAAsB,CAAC;AACzD,eAAO,MAAM,yBAAyB,QAA0B,CAAC;AACjE,eAAO,MAAM,sBAAsB,SAAiD,CAAC;AACrF,eAAO,MAAM,kBAAkB,yIASiB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;CAIK,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import packageJson from '../package.json';
|
|
2
2
|
export const INFRA_PACKAGE_NAME = packageJson.name;
|
|
3
3
|
export const INFRA_PACKAGE_VERSION = packageJson.version;
|
|
4
|
+
export const INFRA_PACKAGE_DESCRIPTION = packageJson.description;
|
|
4
5
|
export const INFRA_COMMAND_CATEGORY = 'infra';
|
|
5
6
|
export const INFRA_CAPABILITIES = [
|
|
6
7
|
'infra.validate',
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAMA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC,OAAO,CAAC;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAA8C,CAAC;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,gBAAgB;IAChB,YAAY;IACZ,gBAAgB;IAChB,UAAU;IACV,cAAc;IACd,eAAe;IACf,YAAY;IACZ,eAAe;CAC+B,CAAC;AAEjD,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,sBAAsB;IAChC,QAAQ,EAAE,qBAAqB;IAC/B,YAAY,EAAE,kBAAkB;CACM,CAAC","sourcesContent":["import type {\n AnkhCapabilityId,\n AnkhCommandCategory,\n AnkhPackageMetadata,\n} from '@ankhorage/contracts/cli';\n\nimport packageJson from '../package.json';\n\nexport const INFRA_PACKAGE_NAME = packageJson.name;\nexport const INFRA_PACKAGE_VERSION = packageJson.version;\nexport const INFRA_COMMAND_CATEGORY = 'infra' as const satisfies AnkhCommandCategory;\nexport const INFRA_CAPABILITIES = [\n 'infra.validate',\n 'infra.plan',\n 'infra.generate',\n 'infra.up',\n 'infra.status',\n 'infra.outputs',\n 'infra.down',\n 'infra.destroy',\n] as const satisfies readonly AnkhCapabilityId[];\n\nexport const INFRA_PACKAGE_METADATA = {\n category: INFRA_COMMAND_CATEGORY,\n provider: './dist/cli/index.js',\n capabilities: INFRA_CAPABILITIES,\n} as const satisfies AnkhPackageMetadata;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAMA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC,OAAO,CAAC;AACzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,WAAW,CAAC,WAAW,CAAC;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAA8C,CAAC;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,gBAAgB;IAChB,YAAY;IACZ,gBAAgB;IAChB,UAAU;IACV,cAAc;IACd,eAAe;IACf,YAAY;IACZ,eAAe;CAC+B,CAAC;AAEjD,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,sBAAsB;IAChC,QAAQ,EAAE,qBAAqB;IAC/B,YAAY,EAAE,kBAAkB;CACM,CAAC","sourcesContent":["import type {\n AnkhCapabilityId,\n AnkhCommandCategory,\n AnkhPackageMetadata,\n} from '@ankhorage/contracts/cli';\n\nimport packageJson from '../package.json';\n\nexport const INFRA_PACKAGE_NAME = packageJson.name;\nexport const INFRA_PACKAGE_VERSION = packageJson.version;\nexport const INFRA_PACKAGE_DESCRIPTION = packageJson.description;\nexport const INFRA_COMMAND_CATEGORY = 'infra' as const satisfies AnkhCommandCategory;\nexport const INFRA_CAPABILITIES = [\n 'infra.validate',\n 'infra.plan',\n 'infra.generate',\n 'infra.up',\n 'infra.status',\n 'infra.outputs',\n 'infra.down',\n 'infra.destroy',\n] as const satisfies readonly AnkhCapabilityId[];\n\nexport const INFRA_PACKAGE_METADATA = {\n category: INFRA_COMMAND_CATEGORY,\n provider: './dist/cli/index.js',\n capabilities: INFRA_CAPABILITIES,\n} as const satisfies AnkhPackageMetadata;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/infra",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.1.
|
|
4
|
+
"version": "7.1.2",
|
|
5
5
|
"description": "Project-aware infrastructure generation library and executable Ankh provider for Ankhorage.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/infra#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"openapi"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@ankhorage/ankh": "^0.9.1",
|
|
38
39
|
"@ankhorage/contracts": "^21.0.0",
|
|
39
40
|
"@ankhorage/utility": "^1.2.0"
|
|
40
41
|
},
|
|
@@ -111,9 +112,8 @@
|
|
|
111
112
|
"knip:test": "bun run knip:check"
|
|
112
113
|
},
|
|
113
114
|
"devDependencies": {
|
|
114
|
-
"@ankhorage/ankh": "^0.8.11",
|
|
115
115
|
"@ankhorage/cerbos": "^0.2.0",
|
|
116
|
-
"@ankhorage/devtools": "^1.
|
|
116
|
+
"@ankhorage/devtools": "^1.15.3",
|
|
117
117
|
"@ankhorage/docker-compose": "^0.5.3",
|
|
118
118
|
"@ankhorage/hetzner": "^0.3.0",
|
|
119
119
|
"@ankhorage/k3s": "^0.4.1",
|
package/src/cli/cli.test.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
|
+
import { renderProviderHelp } from '@ankhorage/ankh';
|
|
1
2
|
import { describe, expect, test } from 'bun:test';
|
|
2
3
|
|
|
4
|
+
import { INFRA_PACKAGE_DESCRIPTION } from '../constants.js';
|
|
3
5
|
import { createCapturedCommandContext } from '../testSupport.js';
|
|
6
|
+
import { createInfraRuntimeProvider } from './createInfraRuntimeProvider.js';
|
|
4
7
|
import { runInfraCliAsync } from './runInfraCliAsync.js';
|
|
5
8
|
|
|
6
9
|
describe('standalone Infra CLI', () => {
|
|
7
|
-
test('
|
|
8
|
-
const
|
|
10
|
+
test('renders every help alias from the canonical provider manifest', async () => {
|
|
11
|
+
const expectedHelp = renderProviderHelp({
|
|
12
|
+
commandPrefix: ['ankhorage-infra'],
|
|
13
|
+
description: INFRA_PACKAGE_DESCRIPTION,
|
|
14
|
+
manifest: createInfraRuntimeProvider(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
for (const argv of [[], ['-h'], ['--help'], ['help']] as const) {
|
|
18
|
+
const captured = createCapturedCommandContext('/workspace', '9.9.9');
|
|
19
|
+
const result = await runInfraCliAsync(argv, { context: captured.context });
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({ exitCode: 0 });
|
|
22
|
+
expect(captured.stdout.value).toBe(expectedHelp);
|
|
23
|
+
expect(captured.stderr.value).toBe('');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('prints version and dispatches all commands through the shared runner', async () => {
|
|
9
28
|
const version = createCapturedCommandContext('/workspace', '9.9.9');
|
|
10
|
-
expect((await runInfraCliAsync([], { context: help.context })).exitCode).toBe(0);
|
|
11
|
-
expect(help.stdout.value).toContain('ankhorage-infra <command>');
|
|
12
|
-
expect(help.stdout.value).toContain('destroy');
|
|
13
29
|
expect((await runInfraCliAsync(['--version'], { context: version.context })).exitCode).toBe(0);
|
|
14
30
|
expect(version.stdout.value).toBe('9.9.9\n');
|
|
15
31
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isHelpToken, renderProviderHelp } from '@ankhorage/ankh';
|
|
2
|
+
|
|
3
|
+
import { INFRA_PACKAGE_DESCRIPTION } from '../constants.js';
|
|
1
4
|
import type {
|
|
2
5
|
InfraCommandContext,
|
|
3
6
|
InfraCommandRunResult,
|
|
@@ -5,8 +8,8 @@ import type {
|
|
|
5
8
|
RunInfraCommandImpl,
|
|
6
9
|
} from '../types/infraCli.js';
|
|
7
10
|
import { createDefaultInfraCommandContext } from './createDefaultInfraCommandContext.js';
|
|
11
|
+
import { createInfraRuntimeProvider } from './createInfraRuntimeProvider.js';
|
|
8
12
|
import { findInfraCommand } from './findInfraCommand.js';
|
|
9
|
-
import { renderInfraRootHelp } from './renderInfraRootHelp.js';
|
|
10
13
|
import { renderUnknownInfraCommand } from './renderUnknownInfraCommand.js';
|
|
11
14
|
import { runInfraCommandAsync } from './runInfraCommandAsync.js';
|
|
12
15
|
|
|
@@ -19,7 +22,13 @@ export async function runInfraCliAsync(
|
|
|
19
22
|
const runCommand = options.runCommandImpl ?? runInfraCommandAsync;
|
|
20
23
|
const [firstToken, ...restTokens] = argv;
|
|
21
24
|
if (firstToken === undefined || isHelpToken(firstToken)) {
|
|
22
|
-
context.writeStdout(
|
|
25
|
+
context.writeStdout(
|
|
26
|
+
renderProviderHelp({
|
|
27
|
+
commandPrefix: ['ankhorage-infra'],
|
|
28
|
+
description: INFRA_PACKAGE_DESCRIPTION,
|
|
29
|
+
manifest: createInfraRuntimeProvider(),
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
23
32
|
return { exitCode: 0 };
|
|
24
33
|
}
|
|
25
34
|
if (isVersionToken(firstToken)) {
|
|
@@ -40,11 +49,6 @@ interface InfraCliOptions {
|
|
|
40
49
|
readonly services?: Partial<InfraCommandServices>;
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
/*** Recognize standalone help tokens. */
|
|
44
|
-
function isHelpToken(value: string): boolean {
|
|
45
|
-
return value === '--help' || value === '-h' || value === 'help';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
52
|
/*** Recognize standalone version tokens. */
|
|
49
53
|
function isVersionToken(value: string): boolean {
|
|
50
54
|
return value === '--version' || value === '-v' || value === 'version';
|
package/src/commands.test.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { renderProviderHelp } from '@ankhorage/ankh';
|
|
1
2
|
import type { AppManifest } from '@ankhorage/contracts';
|
|
2
3
|
import type { InfraEnvironmentSpec, InfraLedger, InfraResult } from '@ankhorage/contracts/infra';
|
|
3
4
|
import { describe, expect, test } from 'bun:test';
|
|
4
5
|
|
|
5
6
|
import { INFRA_COMMANDS } from './cli/constants.js';
|
|
7
|
+
import { createInfraRuntimeProvider } from './cli/createInfraRuntimeProvider.js';
|
|
6
8
|
import { createProviderCommandDescriptors } from './cli/createProviderCommandDescriptors.js';
|
|
7
9
|
import { findInfraCommand } from './cli/findInfraCommand.js';
|
|
8
|
-
import { renderInfraRootHelp } from './cli/renderInfraRootHelp.js';
|
|
9
10
|
import { runInfraCommandAsync } from './cli/runInfraCommandAsync.js';
|
|
11
|
+
import { INFRA_PACKAGE_DESCRIPTION } from './constants.js';
|
|
10
12
|
import { createAppManifest, createCapturedCommandContext } from './testSupport.js';
|
|
11
13
|
import type { InfraCommandServices, InfraLifecycleOperations } from './types/infraCli.js';
|
|
12
14
|
import type { InfraDestroyOperationRequest } from './types/infraOrchestration.js';
|
|
@@ -16,7 +18,11 @@ describe('canonical Infra commands', () => {
|
|
|
16
18
|
const names = ['validate', 'plan', 'generate', 'up', 'status', 'outputs', 'down', 'destroy'];
|
|
17
19
|
expect(INFRA_COMMANDS.map(({ standaloneName }) => standaloneName)).toEqual(names);
|
|
18
20
|
expect(createProviderCommandDescriptors().map(({ path }) => path.join(' '))).toEqual(names);
|
|
19
|
-
const help =
|
|
21
|
+
const help = renderProviderHelp({
|
|
22
|
+
commandPrefix: ['ankhorage-infra'],
|
|
23
|
+
description: INFRA_PACKAGE_DESCRIPTION,
|
|
24
|
+
manifest: createInfraRuntimeProvider(),
|
|
25
|
+
});
|
|
20
26
|
for (const name of names) expect(help).toContain(name);
|
|
21
27
|
expect(help).not.toContain('port-forward');
|
|
22
28
|
expect(help).not.toContain('reset');
|
package/src/constants.ts
CHANGED
|
@@ -8,6 +8,7 @@ import packageJson from '../package.json';
|
|
|
8
8
|
|
|
9
9
|
export const INFRA_PACKAGE_NAME = packageJson.name;
|
|
10
10
|
export const INFRA_PACKAGE_VERSION = packageJson.version;
|
|
11
|
+
export const INFRA_PACKAGE_DESCRIPTION = packageJson.description;
|
|
11
12
|
export const INFRA_COMMAND_CATEGORY = 'infra' as const satisfies AnkhCommandCategory;
|
|
12
13
|
export const INFRA_CAPABILITIES = [
|
|
13
14
|
'infra.validate',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderInfraRootHelp.d.ts","sourceRoot":"","sources":["../../src/cli/renderInfraRootHelp.ts"],"names":[],"mappings":"AAGA,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAkB3D"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { INFRA_COMMAND_CATEGORY } from '../constants.js';
|
|
2
|
-
import { INFRA_COMMANDS } from './constants.js';
|
|
3
|
-
/*** Render the standalone Infra command surface and environment safety rules. */
|
|
4
|
-
export function renderInfraRootHelp(version) {
|
|
5
|
-
const commands = INFRA_COMMANDS.map(({ standaloneName, summary }) => ` ${standaloneName.padEnd(8, ' ')} ${summary}`).join('\n');
|
|
6
|
-
return [
|
|
7
|
-
`@ankhorage/infra v${version}`,
|
|
8
|
-
'',
|
|
9
|
-
'Usage:',
|
|
10
|
-
' ankhorage-infra <command> [project] [--environment <environment>]',
|
|
11
|
-
` ankh ${INFRA_COMMAND_CATEGORY} <command> [project] [--environment <environment>]`,
|
|
12
|
-
'',
|
|
13
|
-
'Commands:',
|
|
14
|
-
commands,
|
|
15
|
-
'',
|
|
16
|
-
'Safety:',
|
|
17
|
-
' local is the only implicit environment; destroy always requires --environment and --confirm.',
|
|
18
|
-
'',
|
|
19
|
-
].join('\n');
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=renderInfraRootHelp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderInfraRootHelp.js","sourceRoot":"","sources":["../../src/cli/renderInfraRootHelp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CACjC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,OAAO,EAAE,CACjF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,OAAO;QACL,qBAAqB,OAAO,EAAE;QAC9B,EAAE;QACF,QAAQ;QACR,qEAAqE;QACrE,UAAU,sBAAsB,oDAAoD;QACpF,EAAE;QACF,WAAW;QACX,QAAQ;QACR,EAAE;QACF,SAAS;QACT,gGAAgG;QAChG,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC","sourcesContent":["import { INFRA_COMMAND_CATEGORY } from '../constants.js';\nimport { INFRA_COMMANDS } from './constants.js';\n\n/*** Render the standalone Infra command surface and environment safety rules. */\nexport function renderInfraRootHelp(version: string): string {\n const commands = INFRA_COMMANDS.map(\n ({ standaloneName, summary }) => ` ${standaloneName.padEnd(8, ' ')} ${summary}`,\n ).join('\\n');\n return [\n `@ankhorage/infra v${version}`,\n '',\n 'Usage:',\n ' ankhorage-infra <command> [project] [--environment <environment>]',\n ` ankh ${INFRA_COMMAND_CATEGORY} <command> [project] [--environment <environment>]`,\n '',\n 'Commands:',\n commands,\n '',\n 'Safety:',\n ' local is the only implicit environment; destroy always requires --environment and --confirm.',\n '',\n ].join('\\n');\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { INFRA_COMMAND_CATEGORY } from '../constants.js';
|
|
2
|
-
import { INFRA_COMMANDS } from './constants.js';
|
|
3
|
-
|
|
4
|
-
/*** Render the standalone Infra command surface and environment safety rules. */
|
|
5
|
-
export function renderInfraRootHelp(version: string): string {
|
|
6
|
-
const commands = INFRA_COMMANDS.map(
|
|
7
|
-
({ standaloneName, summary }) => ` ${standaloneName.padEnd(8, ' ')} ${summary}`,
|
|
8
|
-
).join('\n');
|
|
9
|
-
return [
|
|
10
|
-
`@ankhorage/infra v${version}`,
|
|
11
|
-
'',
|
|
12
|
-
'Usage:',
|
|
13
|
-
' ankhorage-infra <command> [project] [--environment <environment>]',
|
|
14
|
-
` ankh ${INFRA_COMMAND_CATEGORY} <command> [project] [--environment <environment>]`,
|
|
15
|
-
'',
|
|
16
|
-
'Commands:',
|
|
17
|
-
commands,
|
|
18
|
-
'',
|
|
19
|
-
'Safety:',
|
|
20
|
-
' local is the only implicit environment; destroy always requires --environment and --confirm.',
|
|
21
|
-
'',
|
|
22
|
-
].join('\n');
|
|
23
|
-
}
|