Skip to content

Commit 073682c

Browse files
committed
Make names consistent
1 parent 626282e commit 073682c

13 files changed

Lines changed: 117 additions & 73 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
-
99
-->
1010

11+
# 5.0.0
12+
## Breaking changes
13+
- Made service `group` actions consistent with others (eg. `mm delete` => `mm group XXX delete`, `mm group` => `mm group new`)
14+
- Made folder names more intuitive (eg. `event-catalogue` => `event-configuration`, `public` => `front-end`, `service-group-1` => `back-end`)
15+
- `mm org new` no longer asks for names for the service group and repo, since they can simply be renamed later
16+
## Fixes and improvements
17+
- More responsive. Generalized code for skipping server response if argument is given (ie. `mm rapids post`)
18+
- `dryrun` should work more reliably
19+
- Added short-hand for `version` (`-v`)
20+
- Made `start`, `init` (as npm), and `--init` (as tsc) into aliases for `register`
21+
- Prepared some of the features we are working on
22+
- On immediate post to a new service, don't ask for event type
23+
1124
# 4.10.2
1225
## Fixes and improvements
1326
- `keys` table fixed

Execute.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { GRAY, INVISIBLE, NORMAL_COLOR, RED, WHITE, YELLOW } from "./prompt.js";
1717
import { PathTo, PathToOrganization, PathToRepository } from "./types.js";
1818
import { all, generateString } from "./utils.js";
1919
import { readdir, readFile } from "fs/promises";
20+
import { DEFAULT_EVENT_CATALOGUE_NAME } from "./config.js";
2021

2122
interface Envelope {
2223
messageId: string;
@@ -550,9 +551,15 @@ ${NORMAL_COLOR}`);
550551
sessionId = "s" + Math.random();
551552
resp.cookie("sessionId", sessionId);
552553
}
554+
const api_json_path = this.pathToRoot
555+
.with(DEFAULT_EVENT_CATALOGUE_NAME)
556+
.with("api.json")
557+
.toString();
553558
const api_json: ApiJson = JSON.parse(
554559
await readFile(
555-
this.pathToRoot.with("event-catalogue").with("api.json").toString(),
560+
existsSync(api_json_path)
561+
? api_json_path
562+
: this.pathToRoot.with("event-catalogue").with("api.json").toString(),
556563
"utf-8"
557564
)
558565
);

config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ export const SSH_HOST = `${API_URL}`;
88
export const SSH_USER = `mist`;
99
export const GIT_HOST = `ssh://${SSH_USER}@${API_URL}`;
1010

11-
export const SPECIAL_FOLDERS = ["event-catalogue", "public"];
12-
1311
export const DEFAULT_SERVICE_GROUP_NAME = "back-end";
1412
export const DEFAULT_REPOSITORY_NAME = "service-1";
1513
export const DEFAULT_PUBLIC_NAME = "front-end";
1614
export const DEFAULT_EVENT_CATALOGUE_NAME = "event-configuration";
15+
16+
export const SPECIAL_FOLDERS = [
17+
DEFAULT_EVENT_CATALOGUE_NAME,
18+
DEFAULT_PUBLIC_NAME,
19+
];
20+
21+
export const SERVICE_GROUP = "service group";
22+
export const REPOSITORY = "code repository";
23+
export const CLONE = "checkout";

contexts.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import fs, { existsSync } from "fs";
1+
import { existsSync } from "fs";
2+
import { lstat, readdir } from "fs/promises";
23
import path from "path";
4+
import { REPOSITORY, SERVICE_GROUP, SPECIAL_FOLDERS } from "./config.js";
35
import { GREEN, NORMAL_COLOR } from "./prompt.js";
46
import { Path, directoryNames, fetchOrgRaw } from "./utils.js";
5-
import { lstat, readdir } from "fs/promises";
67

78
async function downOrg(cmd: string) {
89
try {
@@ -45,7 +46,7 @@ async function upOrg(cmd: string) {
4546

4647
const SERVICE_CONTEXT = async (cmd: string) => {
4748
try {
48-
let hint = `You can only run '${cmd}' from inside a service folder.`;
49+
let hint = `You can only run '${cmd}' from inside a ${REPOSITORY}.`;
4950
const bfs = ["."];
5051
while (bfs.length !== 0) {
5152
const cur = bfs.shift()!;
@@ -68,18 +69,18 @@ const SERVICE_CONTEXT = async (cmd: string) => {
6869
}
6970
};
7071
const NOT_SERVICE_CONTEXT = (cmd: string) => {
71-
let hint = `You cannot run '${cmd}' from inside a service folder.`;
72+
let hint = `You cannot run '${cmd}' from inside a ${REPOSITORY}.`;
7273
hint += `\nUse '${GREEN}cd ..${NORMAL_COLOR}' or one of these:`;
7374
return Promise.resolve(hint);
7475
};
7576
const SERVICE_GROUP_CONTEXT = async (cmd: string) => {
7677
try {
7778
const struct = await fetchOrgRaw();
78-
const serviceGroups = await directoryNames(new Path(struct.pathToRoot!), [
79-
"event-catalogue",
80-
"public",
81-
]);
82-
let hint = `You can only run '${cmd}' from inside a service group.`;
79+
const serviceGroups = await directoryNames(
80+
new Path(struct.pathToRoot!),
81+
SPECIAL_FOLDERS
82+
);
83+
let hint = `You can only run '${cmd}' from inside a ${SERVICE_GROUP}.`;
8384
hint += `\nUse '${GREEN}cd ${path
8485
.join(struct.pathToRoot!, serviceGroups[0].name)
8586
.replace(/\\/g, "\\\\")}${NORMAL_COLOR}' or one of these:`;

newCommands/envvar.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ async function envvar_key_random(
208208
try {
209209
const value = +(await shortText("Length", "How many bytes", "32").then());
210210
const bytes = randomBytes(value);
211-
console.log(bytes.toString("base64"));
212-
console.log(bytes.toString("hex"));
213211
return envvar_key_visible_value(
214212
pathToOrganization,
215213
organizationId,

newCommands/event.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { key_create } from "./apikey.js";
66
import { outputGit } from "../printUtils.js";
77
import { Str } from "@merrymake/utils";
88
import { isDryrun } from "../dryrun.js";
9+
import { DEFAULT_EVENT_CATALOGUE_NAME } from "../config.js";
910

1011
export async function do_event(
1112
apikeyId: string,
@@ -46,7 +47,7 @@ async function event_key(apikeyId: string) {
4647
"Which events would you like to allow and disallow?",
4748
events,
4849
(s) => event_key_events(apikeyId, s),
49-
"No events in event-catalogue. Make sure you have added events to the event-catalogue and deployed it."
50+
`No events in ${DEFAULT_EVENT_CATALOGUE_NAME}. Make sure you have added events to the ${DEFAULT_EVENT_CATALOGUE_NAME} and deployed it.`
5051
);
5152
} catch (e) {
5253
throw e;

newCommands/fetch.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Promise_all, Str } from "@merrymake/utils";
22
import { existsSync } from "fs";
33
import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
4-
import { GIT_HOST } from "../config.js";
4+
import { GIT_HOST, SPECIAL_FOLDERS } from "../config.js";
55
import { addToExecuteQueue, finish } from "../exitMessages.js";
66
import { outputGit } from "../printUtils.js";
77
import {
@@ -33,10 +33,7 @@ export type ToBeStructure = {
3333
};
3434

3535
async function getCurrentStructure(pathToOrganization: PathToOrganization) {
36-
const folders = await directoryNames(pathToOrganization, [
37-
"event-catalogue",
38-
"public",
39-
]);
36+
const folders = await directoryNames(pathToOrganization, SPECIAL_FOLDERS);
4037
const groups: AsIsStructure = {};
4138
await Promise_all(
4239
...folders.map(async (f) => {

newCommands/group.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ import {
1414
import { sshReq } from "../utils.js";
1515
import { repo_create } from "./repo.js";
1616
import { isDryrun } from "../dryrun.js";
17+
import { outputGit } from "../printUtils.js";
18+
import { SERVICE_GROUP } from "../config.js";
1719

1820
export async function do_deleteServiceGroup(
1921
serviceGroup: ServiceGroup,
2022
displayName: string
2123
) {
2224
if (isDryrun()) {
23-
output("DRYRUN: Would delete service group");
25+
output(`DRYRUN: Would delete ${SERVICE_GROUP}`);
2426
return;
2527
}
2628
try {
27-
console.log(`Deleting service group '${displayName}'...`);
29+
outputGit(`Deleting ${SERVICE_GROUP} '${displayName}'...`);
2830
const reply = await sshReq(`group-delete`, serviceGroup.id.toString());
29-
console.log(reply);
31+
outputGit(reply);
3032
if (existsSync(serviceGroup.pathTo.toString()))
3133
await rename(
3234
serviceGroup.pathTo.toString(),
@@ -54,7 +56,7 @@ export async function deleteServiceGroup(organization: Organization) {
5456
const folderName = Str.toFolderName(group.name);
5557
return {
5658
long: folderName,
57-
text: `Delete ${group.name} (${folderName})`,
59+
text: `Delete ${SERVICE_GROUP} ${group.name} permanently`,
5860
action: () =>
5961
deleteServiceGroupId(
6062
{
@@ -67,7 +69,7 @@ export async function deleteServiceGroup(organization: Organization) {
6769
});
6870
return {
6971
options,
70-
header: "Which service group would you like to delete?",
72+
header: `Which ${SERVICE_GROUP} would you like to delete?`,
7173
};
7274
}).then();
7375
} catch (e) {
@@ -81,11 +83,11 @@ export async function do_createServiceGroup(
8183
displayName: string
8284
) {
8385
if (isDryrun()) {
84-
output("DRYRUN: Would create service group");
86+
output(`DRYRUN: Would create ${SERVICE_GROUP}`);
8587
return new ServiceGroupId("dryrun_id");
8688
}
8789
try {
88-
console.log(`Creating service group '${displayName}'...`);
90+
outputGit(`Creating ${SERVICE_GROUP} '${displayName}'...`);
8991
const reply = await sshReq(
9092
`group-create`,
9193
displayName,
@@ -114,7 +116,7 @@ export async function group_new(organization: Organization) {
114116
)
115117
num++;
116118
const displayName = await shortText(
117-
"Service group name",
119+
`${SERVICE_GROUP[0].toUpperCase() + SERVICE_GROUP.substring(1)} name`,
118120
"Used to share envvars.",
119121
"service-group-" + num
120122
).then();
@@ -140,11 +142,11 @@ export async function do_renameServiceGroup(
140142
newDisplayName: string
141143
) {
142144
if (isDryrun()) {
143-
output("DRYRUN: Would rename service group");
145+
output(`DRYRUN: Would rename ${SERVICE_GROUP}`);
144146
return;
145147
}
146148
try {
147-
console.log(`Renaming service group to '${newDisplayName}'...`);
149+
outputGit(`Renaming ${SERVICE_GROUP} to '${newDisplayName}'...`);
148150
const reply = await sshReq(
149151
`group-modify`,
150152
`--displayName`,
@@ -168,7 +170,7 @@ async function group_edit_rename(
168170
) {
169171
try {
170172
const newDisplayName = await shortText(
171-
"Service group name",
173+
`${SERVICE_GROUP[0].toUpperCase() + SERVICE_GROUP.substring(1)} name`,
172174
"Used to share envvars.",
173175
oldDisplayName
174176
).then();
@@ -195,7 +197,7 @@ async function group_edit(serviceGroup: ServiceGroup, displayName: string) {
195197
[
196198
{
197199
long: "rename",
198-
text: `rename it`,
200+
text: `rename ${SERVICE_GROUP}`,
199201
action: () =>
200202
group_edit_rename(
201203
serviceGroup.pathTo,
@@ -205,14 +207,14 @@ async function group_edit(serviceGroup: ServiceGroup, displayName: string) {
205207
},
206208
{
207209
long: "delete",
208-
text: `delete it permanently`,
210+
text: `delete ${SERVICE_GROUP} '${displayName}' permanently`,
209211
action: () => deleteServiceGroupId(serviceGroup, displayName),
210212
},
211213
],
212214
async () => {
213215
return {
214216
options: [],
215-
header: `How would you like to edit '${displayName}'?`,
217+
header: `How would you like to edit the ${SERVICE_GROUP}?`,
216218
};
217219
}
218220
).then((x) => x);
@@ -227,7 +229,7 @@ export async function group(organization: Organization) {
227229
{
228230
long: "new",
229231
short: "n",
230-
text: `create new service group`,
232+
text: `create a new ${SERVICE_GROUP}`,
231233
action: () => group_new(organization),
232234
},
233235
],
@@ -255,7 +257,7 @@ export async function group(organization: Organization) {
255257
});
256258
return {
257259
options,
258-
header: "Which service group would you like to manage?",
260+
header: `Which ${SERVICE_GROUP} would you like to manage?`,
259261
};
260262
}
261263
).then();

newCommands/help.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { sshReq, urlReq } from "../utils.js";
1212
import { Str } from "@merrymake/utils";
1313
import { getCommand } from "../mmCommand.js";
14+
import { REPOSITORY, SERVICE_GROUP } from "../config.js";
1415

1516
async function do_help(ctx: {
1617
repositoryId: RepositoryId | undefined;
@@ -46,17 +47,17 @@ async function do_help(ctx: {
4647
);
4748
}
4849
if (ctx.serviceGroup === undefined) {
49-
outputGit(`Warning: Not inside service group.`);
50+
outputGit(`Warning: Not inside ${SERVICE_GROUP}.`);
5051
} else {
5152
outputGit(
52-
`${GRAY}Inside service group (${ctx.serviceGroup.id}).${NORMAL_COLOR}`
53+
`${GRAY}Inside ${SERVICE_GROUP} (${ctx.serviceGroup.id}).${NORMAL_COLOR}`
5354
);
5455
}
5556
if (!existsSync("merrymake.json")) {
56-
outputGit(`Warning: Not inside service repo.`);
57+
outputGit(`Warning: Not inside ${REPOSITORY}.`);
5758
} else {
5859
outputGit(
59-
`${GRAY}Inside service repo (${ctx.repositoryId}).${NORMAL_COLOR}`
60+
`${GRAY}Inside ${REPOSITORY} (${ctx.repositoryId}).${NORMAL_COLOR}`
6061
);
6162
}
6263
}

newCommands/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { role } from "./role.js";
3131
import { rollback } from "./rollback.js";
3232
import { update } from "./update.js";
3333
import { upgrade } from "./upgrade.js";
34+
import { REPOSITORY, SERVICE_GROUP } from "../config.js";
35+
import { Str } from "@merrymake/utils";
3436

3537
function partitionLast(str: string, radix: string) {
3638
const index = str.lastIndexOf(radix);
@@ -135,7 +137,7 @@ export async function index() {
135137
options.push({
136138
long: "deploy",
137139
short: "d",
138-
text: "deploy this repository with git",
140+
text: `deploy this ${REPOSITORY} with git`,
139141
weight: 900,
140142
action: () => deploy(monorepo),
141143
});
@@ -144,7 +146,7 @@ export async function index() {
144146
options.push({
145147
long: "rollback",
146148
short: "r",
147-
text: "rollback individual hooks or the entire service to a stable version",
149+
text: `rollback individual hooks or the entire ${REPOSITORY} to a stable version`,
148150
weight: 800,
149151
action: () => rollback(repositoryId),
150152
});
@@ -153,7 +155,7 @@ export async function index() {
153155
options.push({
154156
long: "build",
155157
short: "b",
156-
text: "build this service locally",
158+
text: `build this ${REPOSITORY} locally`,
157159
weight: 800,
158160
action: () => build(),
159161
});
@@ -177,15 +179,15 @@ export async function index() {
177179
{
178180
long: "envvar",
179181
short: "e",
180-
text: "add or edit an envvar in this service group",
182+
text: `add or edit an envvar in this ${SERVICE_GROUP}`,
181183
weight: 800,
182184
action: () =>
183185
envvar(organization!.pathTo, organization!.id, serviceGroup.id),
184186
},
185187
{
186188
long: "repo",
187189
short: "r",
188-
text: "add or edit a repository",
190+
text: `add or edit a ${REPOSITORY}`,
189191
weight: 700,
190192
action: () => repo(organization!, serviceGroup),
191193
}
@@ -198,7 +200,10 @@ export async function index() {
198200
options.push({
199201
long: "fetch",
200202
short: "f",
201-
text: "fetch updates to service groups and repos",
203+
text: `fetch updates to ${Str.plural(
204+
2,
205+
SERVICE_GROUP
206+
)}s and ${Str.plural(2, REPOSITORY)}`,
202207
weight: 600,
203208
action: () => fetch(organization),
204209
});
@@ -219,7 +224,7 @@ export async function index() {
219224
{
220225
long: "group",
221226
short: "g",
222-
text: "add or edit a service group",
227+
text: `add or edit a ${SERVICE_GROUP}`,
223228
weight: 500,
224229
action: () => group(organization),
225230
},

0 commit comments

Comments
 (0)