Skip to content

Commit 130402a

Browse files
committed
feat: Fixed build issues and improved help
1 parent 780ad3e commit 130402a

File tree

16 files changed

+100
-69
lines changed

16 files changed

+100
-69
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"uuid": "^10.0.0",
4848
"ws": "^8.18.3"
4949
},
50-
"description": "Codify allows users to configure settings, install new packages, and automate their systems using code instead of the GUI. Get set up on a new laptop in one click, maintain a Codify file within your project so anyone can get started and never lose your cool apps or favourite settings again.",
50+
"description": "Codify allows users to configure settings, install new packages, and automate their systems using code instead of the GUI. Check out https://dashboard.codifycli.com for an online editor.",
5151
"devDependencies": {
5252
"@memlab/core": "^1.1.39",
5353
"@oclif/prettier-config": "^0.2.1",
@@ -58,7 +58,6 @@
5858
"@types/jju": "^1.4.5",
5959
"@types/js-yaml": "^4.0.9",
6060
"@types/json5": "^2.2.0",
61-
"@types/kill-port": "^2.0.3",
6261
"@types/mocha": "^10.0.10",
6362
"@types/node": "^20",
6463
"@types/react": "^18.3.1",
@@ -108,6 +107,7 @@
108107
"bin": "codify",
109108
"dirname": "codify",
110109
"commands": "./dist/commands",
110+
"helpClass": "./dist/help",
111111
"additionalVersionFlags": [
112112
"-v"
113113
],

src/api/backend/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const ApiClient = {
5656
return data.hash;
5757
},
5858

59-
async updateRemoteFile(filePath: string, content: Blob, credentials: string): Promise<string> {
59+
async updateRemoteFile(filePath: string, content: Blob, credentials: string): Promise<void> {
6060
const { documentId, fileId } = this.extractCodifyFileInfo(filePath);
6161

6262
const formData = new FormData();

src/commands/connect.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { ConnectOrchestrator } from '../orchestrators/connect.js';
33

44
export default class Connect extends BaseCommand {
55
static description =
6-
`Validate a codify.jsonc/codify.json/codify.yaml file.
6+
`Open a connection to the Codify dashboard. This command will host a local server to receive commands (e.g. apply, destroy, etc.)
7+
from the Codify dashboard.
78
8-
For more information, visit: https://docs.codifycli.com/commands/validate
9+
For more information, visit: https://docs.codifycli.com/commands/connect
910
`
1011

1112
static flags = {}

src/commands/edit.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { BaseCommand } from '../common/base-command.js';
2-
import { ConnectOrchestrator } from '../orchestrators/connect.js';
32
import { EditOrchestrator } from '../orchestrators/edit.js';
4-
import { LoginHelper } from '../connect/login-helper.js';
53

64
export default class Edit extends BaseCommand {
75
static description =
8-
`Edit a codify.jsonc/codify.json/codify.yaml file.
6+
`Short cut for opening your default Codify file in the Codify dashboard.
97
10-
For more information, visit: https://docs.codifycli.com/commands/validate
8+
For more information, visit: https://docs.codifycli.com/commands/edit
119
`
1210

1311
static flags = {}

src/commands/import.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,19 @@ import { ShellUtils } from '../utils/shell.js';
99
export default class Import extends BaseCommand {
1010
static strict = false;
1111
static override description =
12-
`Generate Codify configurations from already installed packages.
13-
14-
Use a space-separated list of arguments to specify the resource types to import.
15-
If a codify.jsonc file already exists, omit arguments to update the file to match the system.
16-
17-
${chalk.bold('Modes:')}
18-
1. ${chalk.bold('No args:')} If no args are specified and an *.codify.jsonc already exists, Codify
19-
will update the existing file with new changes on the system.
20-
21-
${chalk.underline('Command:')}
22-
codify import
12+
`Generate Codify configurations from already installed programs / applications.
2313
14+
Two modes are available:
15+
1. ${chalk.bold('No args:')} If no args are specified will attempt to import all supported resources.
2416
2. ${chalk.bold('With args:')} Specify specific resources to import using arguments. Wild card matching is supported
2517
using '*' and '?' (${chalk.italic('Note: in zsh * expands to the current dir and needs to be escaped using \\* or \'*\'')}).
2618
A prompt will be shown if more information is required to complete the import.
2719
20+
Use a space-separated list of arguments to specify the resource types to import.
21+
2822
${chalk.underline('Examples:')}
2923
codify import nvm asdf*
30-
codify import \\* (for importing all supported resources)
24+
codify import
3125
3226
The results can be saved in one of three ways:
3327
a. To an existing *.codify.jsonc file

src/commands/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LoginOrchestrator } from '../orchestrators/login.js';
55

66
export default class Login extends BaseCommand {
77
static description =
8-
`Logins to codify cloud account
8+
`Logins to Codify cloud account
99
1010
For more information, visit: https://docs.codifycli.com/commands/login
1111
`

src/commands/logout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { LoginHelper } from '../connect/login-helper.js';
66

77
export default class Login extends BaseCommand {
88
static description =
9-
`Logout of codify cloud account
9+
`Logout of Codify cloud account
1010
1111
For more information, visit: https://docs.codifycli.com/commands/logout
1212
`

src/commands/refresh.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,14 @@ import { RefreshOrchestrator } from '../orchestrators/refresh.js';
1010
export default class Refresh extends BaseCommand {
1111
static strict = false;
1212
static override description =
13-
`Generate Codify configurations from already installed packages.
13+
`Refreshes existing Codify configurations to have the latest changes on the system.
1414
15-
Use a space-separated list of arguments to specify the resource types to import.
16-
If a codify.jsonc file already exists, omit arguments to update the file to match the system.
15+
Use a space-separated list of arguments to specify specific resource types to refresh.
16+
Leave empty to refresh all resources.
1717
18-
${chalk.bold('Modes:')}
19-
1. ${chalk.bold('No args:')} If no args are specified and an *.codify.jsonc already exists, Codify
20-
will update the existing file with new changes on the system.
21-
22-
${chalk.underline('Command:')}
23-
codify import
24-
25-
2. ${chalk.bold('With args:')} Specify specific resources to import using arguments. Wild card matching is supported
26-
using '*' and '?' (${chalk.italic('Note: in zsh * expands to the current dir and needs to be escaped using \\* or \'*\'')}).
27-
A prompt will be shown if more information is required to complete the import.
28-
29-
${chalk.underline('Examples:')}
30-
codify import nvm asdf*
31-
codify import \\* (for importing all supported resources)
32-
33-
The results can be saved in one of three ways:
34-
a. To an existing *.codify.jsonc file
35-
b. To a new file
36-
c. Printed to the console only
37-
3818
Codify will attempt to smartly insert new configurations while preserving existing spacing and formatting.
3919
40-
For more information, visit: https://docs.codifycli.com/commands/import`
20+
For more information, visit: https://docs.codifycli.com/commands/refresh`
4121

4222
static override examples = [
4323
'<%= config.bin %> <%= command.id %> homebrew nvm asdf',

src/help.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { Command, Help, HelpBase } from '@oclif/core';
2+
import { colorize } from '@oclif/core/ux';
3+
import chalk from 'chalk';
4+
import stripAnsi from 'strip-ansi';
5+
6+
enum HelpSection {
7+
GET_STARTED = 'GETTING STARTED',
8+
CORE = 'CORE',
9+
IMPORT = 'IMPORT',
10+
CLOUD = 'CLOUD',
11+
}
12+
13+
const HelpOrganization = {
14+
[HelpSection.GET_STARTED]: [
15+
'init',
16+
],
17+
[HelpSection.CORE]: [
18+
'plan',
19+
'apply',
20+
'destroy',
21+
'validate'
22+
],
23+
[HelpSection.IMPORT]: [
24+
'import',
25+
'refresh',
26+
],
27+
[HelpSection.CLOUD]: [
28+
'login',
29+
'logout',
30+
'edit',
31+
'connect',
32+
]
33+
}
34+
35+
export default class CustomHelp extends Help {
36+
formatCommands(commands: Command.Loadable[]): string {
37+
if (commands.length === 0) return ''
38+
39+
const gettingStarted = this.formatSection(HelpSection.GET_STARTED, commands)
40+
const core = this.formatSection(HelpSection.CORE, commands)
41+
const importSection = this.formatSection(HelpSection.IMPORT, commands)
42+
const cloud = this.formatSection(HelpSection.CLOUD, commands)
43+
44+
return this.section('COMMANDS', `${gettingStarted}\n\n${core}\n\n${importSection}\n\n${cloud}`)
45+
}
46+
47+
formatSection(section: HelpSection, commands: Command.Loadable[]): string {
48+
const body = this.renderList(
49+
commands
50+
.filter((c) => HelpOrganization[section].includes(c.id))
51+
.filter((c) => (this.opts.hideAliasesFromRoot ? !c.aliases?.includes(c.id) : true))
52+
.map((c) => {
53+
if (this.config.topicSeparator !== ':') c.id = c.id.replaceAll(':', this.config.topicSeparator)
54+
const summary = this.summary(c)
55+
return [
56+
colorize(this.config?.theme?.command, c.id),
57+
summary && colorize(this.config?.theme?.sectionDescription, stripAnsi(summary)),
58+
]
59+
}),
60+
{
61+
indentation: 2,
62+
spacer: '\n',
63+
stripAnsi: this.opts.stripAnsi,
64+
},
65+
)
66+
67+
return `${chalk.underline(section)}\n${body}`
68+
}
69+
}

0 commit comments

Comments
 (0)