Skip to content

Commit 51633ed

Browse files
authored
chore/fix-prettier (#1079)
* chore: auto build on dev * chore: fix eslint script * chore: run prettier * chore: update git-blame * chore: compiler issue
1 parent a822a07 commit 51633ed

File tree

178 files changed

+3049
-2480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+3049
-2480
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ b03ee5f5213b291d2e8d676597e064bb6977529e
1919
64be06c815fb9ed24e8699f9d687c5009098c7b8
2020
9046a02e14b02a95a8bfb89518a6640e499e5173
2121
8ab97017ec377d11c0f448ab1e8aaa43c26d1159
22+
# prettier
23+
1312c0909ec6dbd059b9e6a7e83125f28c9b458d

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@
8989
}
9090
},
9191
"lint-staged": {
92-
"*.{ts,tsx}": "prettier --config prettier.config.js --loglevel debug --write",
93-
"*.{ts,tsx}": "eslint"
92+
"*.{ts,tsx}": ["prettier --config prettier.config.js --loglevel debug --write", "eslint"]
9493
},
9594
"dependencies": {
9695
"@dendronhq/conventional-changelog-dendron": "^5.0.11",

packages/api-server/src/Server.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function appModule({
2020
nextStaticRoot?: string;
2121
}) {
2222
const ctx = "appModule:start";
23-
const logger = getLogger()
23+
const logger = getLogger();
2424
const app = express();
2525
app.use(cors());
2626
app.use(express.json({ limit: "500mb" }));
@@ -44,8 +44,14 @@ export function appModule({
4444
// for dev environment, get preview from next-server in monorepo
4545
if (getStage() !== "prod") {
4646
// packages/api-server/lib/Server.ts
47-
const devStaticRoot = path.join(__dirname, "..", "..", "dendron-next-server", "out");
48-
logger.info({ ctx, msg: "devStaticRoot:add", devStaticRoot});
47+
const devStaticRoot = path.join(
48+
__dirname,
49+
"..",
50+
"..",
51+
"dendron-next-server",
52+
"out"
53+
);
54+
logger.info({ ctx, msg: "devStaticRoot:add", devStaticRoot });
4955
app.use(express.static(devStaticRoot));
5056
}
5157
if (nextStaticRoot) {

packages/api-server/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LogLvl } from "@dendronhq/common-server";
22
import express from "express";
33
import _ from "lodash";
44
import { configureLogger, getLogger } from "./core";
5-
export {ServerUtils, SubProcessExitType} from "./utils"
5+
export { ServerUtils, SubProcessExitType } from "./utils";
66

77
type LaunchOpts = {
88
port?: number;

packages/api-server/src/modules/assets.ts

+36-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
ERROR_STATUS,
66
getStage,
77
RespV2,
8-
ThemeTarget, ThemeType
8+
ThemeTarget,
9+
ThemeType,
910
} from "@dendronhq/common-all";
1011
import { WorkspaceUtils } from "@dendronhq/engine-server";
1112
import { getWS } from "../utils";
@@ -50,20 +51,27 @@ export class AssetsController {
5051
};
5152
}
5253

53-
async getTheme({ themeTarget, themeType }: AssetGetThemeRequest): Promise<RespV2<string>> {
54-
const ctx = "Assets:getTheme"
54+
async getTheme({
55+
themeTarget,
56+
themeType,
57+
}: AssetGetThemeRequest): Promise<RespV2<string>> {
58+
const ctx = "Assets:getTheme";
5559
const stage = getStage();
5660
const logger = getLogger();
57-
logger.info({ctx, themeTarget, themeType, stage});
61+
logger.info({ ctx, themeTarget, themeType, stage });
5862
let root: string;
5963
if (stage !== "prod") {
6064
// lib/modules/
6165
root = path.join(__dirname, "..", "..", "assets");
6266
} else {
63-
root = __dirname
67+
root = __dirname;
6468
}
6569

66-
const getPathForTarget = ({themeTarget}:{themeTarget: ThemeTarget}) => {
70+
const getPathForTarget = ({
71+
themeTarget,
72+
}: {
73+
themeTarget: ThemeTarget;
74+
}) => {
6775
const themeDir = path.join(root, "static", "themes");
6876
if (themeTarget === ThemeTarget.PRISM) {
6977
return path.join(themeDir, "prism");
@@ -72,26 +80,34 @@ export class AssetsController {
7280
status: ERROR_STATUS.INVALID_CONFIG,
7381
message: `target ${themeTarget} not valid`,
7482
});
75-
}
76-
const getFileForType = ({themeType, targetRoot}:{themeType: ThemeType, targetRoot: string}) => {
77-
return path.join(targetRoot, `${themeType.toLowerCase()}.css`)
78-
}
79-
const targetRoot = getPathForTarget({themeTarget})
83+
};
84+
const getFileForType = ({
85+
themeType,
86+
targetRoot,
87+
}: {
88+
themeType: ThemeType;
89+
targetRoot: string;
90+
}) => {
91+
return path.join(targetRoot, `${themeType.toLowerCase()}.css`);
92+
};
93+
const targetRoot = getPathForTarget({ themeTarget });
8094
if (targetRoot instanceof DendronError) {
81-
return {error: targetRoot};
95+
return { error: targetRoot };
8296
}
83-
const pathForTarget = getFileForType({themeType, targetRoot});
84-
logger.info({ctx, pathForTarget});
97+
const pathForTarget = getFileForType({ themeType, targetRoot });
98+
logger.info({ ctx, pathForTarget });
8599
if (!fs.existsSync(pathForTarget)) {
86-
return {error: DendronError.createFromStatus({
87-
status: ERROR_STATUS.DOES_NOT_EXIST,
88-
message: `no file at ${pathForTarget}`,
89-
})};
100+
return {
101+
error: DendronError.createFromStatus({
102+
status: ERROR_STATUS.DOES_NOT_EXIST,
103+
message: `no file at ${pathForTarget}`,
104+
}),
105+
};
90106
}
91107

92108
return {
93109
data: pathForTarget,
94-
error: null
95-
}
110+
error: null,
111+
};
96112
}
97113
}

packages/api-server/src/utils.ts

+23-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
DEngine,
44
ERROR_SEVERITY,
55
ERROR_STATUS,
6-
stringifyError
6+
stringifyError,
77
} from "@dendronhq/common-all";
88
import { createLogger } from "@dendronhq/common-server";
99
import { DendronEngineV2 } from "@dendronhq/engine-server";
@@ -57,7 +57,7 @@ export enum SubProcessExitType {
5757
SIGINT = "SIGINT",
5858
SIGURS1 = "SIGUSR1",
5959
SIGURS2 = "SIGUSR2",
60-
UNCAUGHT_EXCEPTION = "uncaughtException"
60+
UNCAUGHT_EXCEPTION = "uncaughtException",
6161
}
6262
export class ServerUtils {
6363
static onProcessExit({
@@ -74,7 +74,9 @@ export class ServerUtils {
7474
subprocess.on("SIGUSR2", () => cb(SubProcessExitType.SIGURS2));
7575

7676
//catches uncaught exceptions
77-
subprocess.on("uncaughtException", () => cb(SubProcessExitType.UNCAUGHT_EXCEPTION));
77+
subprocess.on("uncaughtException", () =>
78+
cb(SubProcessExitType.UNCAUGHT_EXCEPTION)
79+
);
7880
}
7981

8082
/**
@@ -160,9 +162,12 @@ export class ServerUtils {
160162
nextStaticRoot,
161163
port,
162164
}: ServerArgs): Promise<{ port: number; subprocess: ExecaChildProcess }> {
163-
const logger = createLogger("execServer", path.join(logPath, "dendron.log"));
165+
const logger = createLogger(
166+
"execServer",
167+
path.join(logPath, "dendron.log")
168+
);
164169
return new Promise((resolve, reject) => {
165-
logger.info({state: "enter"})
170+
logger.info({ state: "enter" });
166171
const subprocess = execa.node(scriptPath, {
167172
env: {
168173
LOG_PATH: logPath,
@@ -171,32 +176,34 @@ export class ServerUtils {
171176
NEXT_STATIC_ROOT: nextStaticRoot,
172177
} as SERVER_ENV,
173178
});
174-
logger.info({state: "post:exec.node"})
179+
logger.info({ state: "post:exec.node" });
175180
subprocess.on("close", (code) => {
176-
logger.error({state: "close"})
177-
reject(new DendronError({message: "close", payload: {code}}));
181+
logger.error({ state: "close" });
182+
reject(new DendronError({ message: "close", payload: { code } }));
178183
});
179184
subprocess.on("disconnect", () => {
180-
logger.error({state: "disconnect"})
181-
reject(new DendronError({message: "disconnect"}));
185+
logger.error({ state: "disconnect" });
186+
reject(new DendronError({ message: "disconnect" }));
182187
});
183188
subprocess.on("exit", (code) => {
184-
logger.error({state: "exit"})
185-
reject(new DendronError({message: "exit", payload: {code}}));
189+
logger.error({ state: "exit" });
190+
reject(new DendronError({ message: "exit", payload: { code } }));
186191
});
187192
subprocess.on("error", (err) => {
188-
logger.error({state: "error", payload: err})
189-
reject(new DendronError({message: "error", payload: stringifyError(err)}));
193+
logger.error({ state: "error", payload: err });
194+
reject(
195+
new DendronError({ message: "error", payload: stringifyError(err) })
196+
);
190197
});
191198
subprocess.on("message", (message) => {
192-
logger.info({state: "message", message})
199+
logger.info({ state: "message", message });
193200
const port = parseInt(message as string, 10);
194201
if (port <= 0) {
195202
reject({
196203
error: new DendronError({
197204
message: "port is smaller than 0",
198205
severity: ERROR_SEVERITY.FATAL,
199-
})
206+
}),
200207
});
201208
}
202209
resolve({ port, subprocess });

packages/common-all/src/analytics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export enum VSCodeEvents {
1212
Uninstall = "Uninstall",
1313
ShowLapsedUserMessage = "Show_Lapsed_User_Msg",
1414
LapsedUserMessageAccepted = "Lapsed_User_Msg_Accepted",
15-
LapsedUserMessageRejected = "Show_Lapsed_User_Rejected"
15+
LapsedUserMessageRejected = "Show_Lapsed_User_Rejected",
1616
}
1717

1818
export enum TutorialEvents {
@@ -27,5 +27,5 @@ export enum TutorialEvents {
2727

2828
export const DendronEvents = {
2929
VSCodeEvents,
30-
TutorialEvents
30+
TutorialEvents,
3131
};

packages/common-all/src/api.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ export type SchemaUpdateRequest = SchemaWriteRequest;
168168

169169
export type AssetGetRequest = { fpath: string } & WorkspaceRequest;
170170

171-
export type AssetGetThemeRequest = { themeTarget: ThemeTarget, themeType: ThemeType} & WorkspaceRequest;
171+
export type AssetGetThemeRequest = {
172+
themeTarget: ThemeTarget;
173+
themeType: ThemeType;
174+
} & WorkspaceRequest;
172175

173176
// --- Payload
174177
export type InitializePayload = APIPayload<DEngineInitPayload>;
@@ -312,7 +315,9 @@ export class DendronAPI extends API {
312315
return resp;
313316
}
314317

315-
async assetGetTheme(req: AssetGetThemeRequest): Promise<DendronError | Buffer> {
318+
async assetGetTheme(
319+
req: AssetGetThemeRequest
320+
): Promise<DendronError | Buffer> {
316321
const resp = await this._makeRequestRaw({
317322
path: "assets/theme",
318323
method: "get",

packages/common-all/src/colors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,4 +953,4 @@ export const COLORS: { [index: string]: string } = {
953953
green: "#15b01a",
954954
purple: "#7e1e9c",
955955
};
956-
export const COLORS_LIST = Object.values(COLORS);
956+
export const COLORS_LIST = Object.values(COLORS);

packages/common-all/src/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export enum ThemeType {
66
}
77

88
export enum ThemeTarget {
9-
PRISM = "PRISM"
9+
PRISM = "PRISM",
1010
}
1111

1212
export const CONSTANTS = {
@@ -68,4 +68,4 @@ export enum RESERVED_KEYS {
6868
}
6969

7070
/** Notes under this hierarchy are considered tags, for example `${TAGS_HIERARCHY}foo` is a tag note. */
71-
export const TAGS_HIERARCHY = "tags.";
71+
export const TAGS_HIERARCHY = "tags.";

packages/common-all/src/dnode.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -861,17 +861,12 @@ export class NoteUtils {
861861
return true;
862862
}
863863

864-
static createFnameNoteMap(
865-
notes: NoteProps[],
866-
removeStubs?: boolean,
867-
) {
864+
static createFnameNoteMap(notes: NoteProps[], removeStubs?: boolean) {
868865
const notesMap = new Map<string, NoteProps>();
869-
const candidates = removeStubs ?
870-
notes.filter((n) => !n.stub) :
871-
notes;
866+
const candidates = removeStubs ? notes.filter((n) => !n.stub) : notes;
872867
candidates.map((n) => {
873868
notesMap.set(n.fname, n);
874-
})
869+
});
875870
return notesMap;
876871
}
877872
}

packages/common-all/src/themes.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
2-
31
type Theme = {
4-
bodyBackground: string;
5-
}
2+
bodyBackground: string;
3+
};
64

75
const LIGHT: Theme = {
8-
bodyBackground: "#ffffff"
9-
}
6+
bodyBackground: "#ffffff",
7+
};
108

119
const DARK: Theme = {
12-
bodyBackground: "#303030"
13-
}
10+
bodyBackground: "#303030",
11+
};
1412

1513
export const THEMES = {
16-
DARK,
17-
LIGHT,
18-
}
14+
DARK,
15+
LIGHT,
16+
};

packages/common-all/src/types/typesv2.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export type EngineInfoResp = {
329329

330330
export type WorkspaceSettings = {
331331
folders: WorkspaceFolderRaw[];
332-
settings: any|undefined;
332+
settings: any | undefined;
333333
extensions: WorkspaceExtensionSetting;
334334
};
335335

@@ -531,7 +531,7 @@ export enum GraphViewMessageType {
531531
"onSelect" = "onSelect",
532532
"onGetActiveEditor" = "onGetActiveEditor",
533533
"onReady" = "onReady",
534-
"onRequestGraphStyle" = "onRequestGraphStyle"
534+
"onRequestGraphStyle" = "onRequestGraphStyle",
535535
}
536536

537537
export enum CalendarViewMessageType {

0 commit comments

Comments
 (0)