Skip to content

Commit 6dcf6fa

Browse files
committed
feat: Switched to using the custom codify-ink-form library to render the import prompt
1 parent 6df1759 commit 6dcf6fa

File tree

6 files changed

+93
-104
lines changed

6 files changed

+93
-104
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@codifycli:registry=https://npm.pkg.github.com

package-lock.json

Lines changed: 63 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"codify": "./bin/run.js"
55
},
66
"dependencies": {
7+
"@codifycli/ink-form": "0.0.1",
78
"@homebridge/node-pty-prebuilt-multiarch": "^0.12.0-beta.5",
89
"@inkjs/ui": "^2",
910
"@oclif/core": "^4.0.8",
@@ -15,7 +16,6 @@
1516
"codify-schemas": "^1.0.63",
1617
"debug": "^4.3.4",
1718
"ink": "^5",
18-
"ink-form": "^2.0.1",
1919
"jotai": "^2.11.1",
2020
"js-yaml": "^4.1.0",
2121
"js-yaml-source-map": "^0.2.2",

src/orchestrators/import.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export interface RequiredParameter {
2828
* The type (string, number, boolean) of the parameter. Un-related to type ids
2929
*/
3030
type: string;
31+
32+
/**
33+
* Description for a field
34+
*/
35+
description?: string;
3136
}
3237

3338
export class ImportOrchestrator {

src/ui/components/import/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Form, FormProps } from 'ink-form';
1+
import { Form, FormProps } from '@codifycli/ink-form';
22
import React from 'react';
33

44
import { RequiredParameters } from '../../../orchestrators/import.js';
@@ -10,14 +10,14 @@ export function ImportParametersForm(
1010

1111
const form: FormProps = {
1212
form: {
13-
title: 'Import: Additional information is required for the following resources',
13+
title: 'codify import',
14+
description: 'some parameters are required to continue import',
1415
sections: [...requiredParameters.entries()].map(([resourceName, v]) => ({
15-
title: `${resourceName}`,
16-
description: `Specify the following parameters for '${resourceName}'`,
16+
title: resourceName,
1717
fields: v.map((resourceParameters) => ({
1818
type: resourceParameters.type,
19-
name: `${resourceName}.${resourceParameters.name}`,
20-
label: `'${resourceParameters.name}' parameter value`,
19+
name: resourceParameters.name,
20+
label: resourceParameters.name,
2121
required: true,
2222
})),
2323
})),

src/ui/reporters/default-reporter.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,29 @@ export class DefaultReporter implements Reporter {
4949
return new Map();
5050
}
5151

52+
fullscreen()
53+
process.on('beforeExit', exitFullScreen);
54+
5255
const userInput = await this.updateStateAndAwaitEvent<object>(() => {
5356
this.updateRenderState(RenderStatus.IMPORT_PROMPT, requiredParameters);
5457
}, RenderEvent.PROMPT_IMPORT_PARAMETERS_RESULT);
5558

59+
60+
exitFullScreen()
61+
process.off('beforeExit', exitFullScreen);
5662
this.updateRenderState(RenderStatus.PROGRESS);
63+
5764
return this.extractUserSuppliedParametersFromResult(userInput);
65+
66+
function fullscreen() {
67+
process.stdout.write('\x1b[?1049h');
68+
process.stdout.write('\x1b[?1000h');
69+
}
70+
71+
function exitFullScreen() {
72+
process.stdout.write('\x1b[?1049l');
73+
process.stdout.write('\x1b[?1000l');
74+
}
5875
}
5976

6077
displayImportResult(importResult: ImportResult): void {

0 commit comments

Comments
 (0)