Skip to content

Commit c43692c

Browse files
committed
fixes npm publish checklist
1 parent 73015ae commit c43692c

13 files changed

Lines changed: 353 additions & 334 deletions

File tree

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545
],
4646
"homepage": "https://github.com/Promact/moa-cli-core",
4747
"keywords": [
48-
"oclif"
48+
"oclif",
49+
"moa",
50+
"automation",
51+
"ai",
52+
"cli"
4953
],
5054
"license": "MIT",
5155
"main": "dist/index.js",
@@ -81,6 +85,7 @@
8185
"postpack": "shx rm -f oclif.manifest.json",
8286
"posttest": "pnpm run lint",
8387
"prepack": "oclif manifest && oclif readme",
88+
"prepublishOnly": "npm run build && mocha --forbid-only \"test/**/*.test.ts\"",
8489
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
8590
"version": "oclif readme && git add README.md"
8691
},

src/commands/config/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
*/
66

77
import { Command, Flags } from '@oclif/core';
8-
import { getConfigManager } from '../../lib/config/config-manager.js';
8+
99
import { getAuthManager } from '../../lib/auth/auth-manager.js';
10+
import { getConfigManager } from '../../lib/config/config-manager.js';
1011

1112
export default class Config extends Command {
1213
static override description = 'Display current configuration and profiles';
13-
14-
static override examples = [
14+
static override examples = [
1515
'<%= config.bin %> <%= command.id %>',
1616
'<%= config.bin %> <%= command.id %> --profile=client-a',
1717
];
18-
19-
static override flags = {
18+
static override flags = {
2019
profile: Flags.string({
2120
char: 'p',
2221
description: 'Show configuration for specific profile',
@@ -51,6 +50,7 @@ export default class Config extends Command {
5150
this.log(` ${status} ${provider}`);
5251
}
5352
}
53+
5454
this.log('');
5555
}
5656
}

src/commands/config/use.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { Args, Command } from '@oclif/core';
8+
89
import { getConfigManager } from '../../lib/config/config-manager.js';
910

1011
export default class ConfigUse extends Command {
@@ -14,10 +15,8 @@ export default class ConfigUse extends Command {
1415
required: true,
1516
}),
1617
};
17-
18-
static override description = 'Switch to a different profile';
19-
20-
static override examples = [
18+
static override description = 'Switch to a different profile';
19+
static override examples = [
2120
'<%= config.bin %> <%= command.id %> client-a',
2221
'<%= config.bin %> <%= command.id %> default',
2322
];

src/commands/login/index.ts

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* Usage: moa login <service> [--profile=<name>]
55
*/
66

7-
import { Args, Command, Flags } from '@oclif/core';
87
import { confirm, password } from '@inquirer/prompts';
9-
import { getAuthManager, Credentials } from '../../lib/auth/auth-manager.js';
8+
import { Args, Command, Flags } from '@oclif/core';
9+
10+
import { Credentials, getAuthManager } from '../../lib/auth/auth-manager.js';
1011
import { getConfigManager } from '../../lib/config/config-manager.js';
1112

1213
const SUPPORTED_PROVIDERS = ['hubspot', 'semrush', 'meta'] as const;
@@ -20,27 +21,24 @@ export default class Login extends Command {
2021
required: true,
2122
}),
2223
};
23-
24-
static override description = 'Authenticate with a SaaS provider';
25-
26-
static override examples = [
24+
static override description = 'Authenticate with a SaaS provider';
25+
static override examples = [
2726
'<%= config.bin %> <%= command.id %> hubspot',
2827
'<%= config.bin %> <%= command.id %> hubspot --profile=client-a',
2928
'<%= config.bin %> <%= command.id %> semrush --profile=agency',
3029
];
31-
32-
static override flags = {
30+
static override flags = {
3331
profile: Flags.string({
3432
char: 'p',
35-
description: 'Profile name to store credentials under',
3633
default: 'default',
34+
description: 'Profile name to store credentials under',
3735
}),
3836
};
3937

4038
async run(): Promise<void> {
4139
const { args, flags } = await this.parse(Login);
4240
const service = args.service as SupportedProvider;
43-
const profile = flags.profile;
41+
const {profile} = flags;
4442

4543
// Set active profile
4644
const configManager = getConfigManager();
@@ -55,8 +53,8 @@ export default class Login extends Command {
5553

5654
if (existing) {
5755
const overwrite = await confirm({
58-
message: 'Credentials already exist for this service/profile. Overwrite?',
5956
default: false,
57+
message: 'Credentials already exist for this service/profile. Overwrite?',
6058
});
6159
if (!overwrite) {
6260
this.log('Login cancelled.');
@@ -79,14 +77,21 @@ export default class Login extends Command {
7977
service: SupportedProvider
8078
): Promise<Credentials> {
8179
switch (service) {
82-
case 'hubspot':
80+
case 'hubspot': {
8381
return this.promptHubSpotCredentials();
84-
case 'semrush':
85-
return this.promptSemrushCredentials();
86-
case 'meta':
82+
}
83+
84+
case 'meta': {
8785
return this.promptMetaCredentials();
88-
default:
86+
}
87+
88+
case 'semrush': {
89+
return this.promptSemrushCredentials();
90+
}
91+
92+
default: {
8993
throw new Error(`Unsupported provider: ${service}`);
94+
}
9095
}
9196
}
9297

@@ -95,8 +100,8 @@ export default class Login extends Command {
95100
this.log('Create one at: https://developers.hubspot.com/docs/api/private-apps\n');
96101

97102
const token = await password({
98-
message: 'Enter your HubSpot Private App token:',
99103
mask: '*',
104+
message: 'Enter your HubSpot Private App token:',
100105
});
101106

102107
return {
@@ -105,33 +110,33 @@ export default class Login extends Command {
105110
};
106111
}
107112

108-
private async promptSemrushCredentials(): Promise<Credentials> {
109-
this.log('Semrush uses API keys for authentication.');
110-
this.log('Find your API key at: https://www.semrush.com/accounts/profile/\n');
113+
private async promptMetaCredentials(): Promise<Credentials> {
114+
this.log('Meta Ads uses OAuth2 access tokens.');
115+
this.log('Generate a token at: https://developers.facebook.com/tools/explorer/\n');
111116

112117
const token = await password({
113-
message: 'Enter your Semrush API key:',
114118
mask: '*',
119+
message: 'Enter your Meta access token:',
115120
});
116121

117122
return {
118123
token,
119-
tokenType: 'api_key',
124+
tokenType: 'oauth',
120125
};
121126
}
122127

123-
private async promptMetaCredentials(): Promise<Credentials> {
124-
this.log('Meta Ads uses OAuth2 access tokens.');
125-
this.log('Generate a token at: https://developers.facebook.com/tools/explorer/\n');
128+
private async promptSemrushCredentials(): Promise<Credentials> {
129+
this.log('Semrush uses API keys for authentication.');
130+
this.log('Find your API key at: https://www.semrush.com/accounts/profile/\n');
126131

127132
const token = await password({
128-
message: 'Enter your Meta access token:',
129133
mask: '*',
134+
message: 'Enter your Semrush API key:',
130135
});
131136

132137
return {
133138
token,
134-
tokenType: 'oauth',
139+
tokenType: 'api_key',
135140
};
136141
}
137142
}

src/commands/logout/index.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* Usage: moa logout <service> [--profile=<name>]
55
*/
66

7-
import { Args, Command, Flags } from '@oclif/core';
87
import { confirm } from '@inquirer/prompts';
8+
import { Args, Command, Flags } from '@oclif/core';
9+
910
import { getAuthManager } from '../../lib/auth/auth-manager.js';
1011

1112
const SUPPORTED_PROVIDERS = ['hubspot', 'semrush', 'meta'] as const;
@@ -19,31 +20,28 @@ export default class Logout extends Command {
1920
required: true,
2021
}),
2122
};
22-
23-
static override description = 'Remove stored credentials for a SaaS provider';
24-
25-
static override examples = [
23+
static override description = 'Remove stored credentials for a SaaS provider';
24+
static override examples = [
2625
'<%= config.bin %> <%= command.id %> hubspot',
2726
'<%= config.bin %> <%= command.id %> hubspot --profile=client-a',
2827
];
29-
30-
static override flags = {
28+
static override flags = {
3129
force: Flags.boolean({
3230
char: 'f',
33-
description: 'Skip confirmation prompt',
3431
default: false,
32+
description: 'Skip confirmation prompt',
3533
}),
3634
profile: Flags.string({
3735
char: 'p',
38-
description: 'Profile name to remove credentials from',
3936
default: 'default',
37+
description: 'Profile name to remove credentials from',
4038
}),
4139
};
4240

4341
async run(): Promise<void> {
4442
const { args, flags } = await this.parse(Logout);
4543
const service = args.service as SupportedProvider;
46-
const profile = flags.profile;
44+
const {profile} = flags;
4745

4846
const authManager = getAuthManager();
4947
const hasCredentials = await authManager.hasCredentials(service, profile);
@@ -55,8 +53,8 @@ export default class Logout extends Command {
5553

5654
if (!flags.force) {
5755
const shouldDelete = await confirm({
58-
message: `Remove credentials for ${service} (profile: ${profile})?`,
5956
default: false,
57+
message: `Remove credentials for ${service} (profile: ${profile})?`,
6058
});
6159
if (!shouldDelete) {
6260
this.log('Logout cancelled.');

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export { run } from '@oclif/core'
2-
export * from './lib/interfaces/SaasProvider.js';
31
export * from './lib/auth/auth-manager.js';
42
export * from './lib/config/config-manager.js';
53
export * from './lib/http/http-client.js';
64
export * from './lib/http/rate-limiter.js';
5+
export * from './lib/interfaces/SaasProvider.js';
6+
export { run } from '@oclif/core'

0 commit comments

Comments
 (0)