Skip to content

Commit 70abb87

Browse files
committed
automation setup
1 parent a4087c8 commit 70abb87

File tree

13 files changed

+55
-26
lines changed

13 files changed

+55
-26
lines changed

automation/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"devBranch": "master",
33
"releaseBranch": "release",
4-
"github": "https://github.com/mProjectsCode/obsidian-meta-bind-plugin"
4+
"github": "https://github.com/mProjectsCode/obsidian-meta-bind-plugin",
5+
"corePackages": ["core"],
6+
"packages": ["obsidian", "publish"]
57
}

automation/installScript.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { $, Verboseness } from 'shellUtils';
2+
import config from './config.json';
3+
4+
async function installScript() {
5+
for (const corePackage of config.corePackages) {
6+
await $('bun i', `packages/${corePackage}`, Verboseness.NORMAL);
7+
}
8+
9+
for (const nonCorePackage of config.packages) {
10+
await $('bun i', `packages/${nonCorePackage}`, Verboseness.NORMAL);
11+
}
12+
}
13+
14+
await installScript();

automation/release.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { UserError } from 'utils';
22
import { CanaryVersion, Version, getIncrementOptions, parseVersion, stringifyVersion } from 'versionUtils';
33
import config from './config.json';
4-
import { $choise as $choice, $confirm, $seq, CMD_FMT, Verboseness } from './shellUtils';
4+
import { $choice as $choice, $confirm, $seq, CMD_FMT, Verboseness } from './shellUtils';
55

66
async function runPreconditions(): Promise<void> {
77
// run preconditions
@@ -11,6 +11,7 @@ async function runPreconditions(): Promise<void> {
1111
throw new UserError(`precondition "${cmd}" failed`);
1212
},
1313
() => {},
14+
undefined,
1415
Verboseness.VERBOSE,
1516
);
1617

@@ -21,6 +22,7 @@ async function runPreconditions(): Promise<void> {
2122
throw new UserError('failed to add preconditions changes to git');
2223
},
2324
() => {},
25+
undefined,
2426
Verboseness.NORMAL,
2527
);
2628

@@ -32,6 +34,7 @@ async function runPreconditions(): Promise<void> {
3234
changesToCommit = true;
3335
},
3436
() => {},
37+
undefined,
3538
Verboseness.QUITET,
3639
);
3740

@@ -43,6 +46,7 @@ async function runPreconditions(): Promise<void> {
4346
throw new UserError('failed to add preconditions changes to git');
4447
},
4548
() => {},
49+
undefined,
4650
Verboseness.NORMAL,
4751
);
4852
}
@@ -58,6 +62,7 @@ async function run() {
5862
throw new UserError('there are still untracked changes');
5963
},
6064
() => {},
65+
undefined,
6166
Verboseness.QUITET,
6267
);
6368

@@ -123,6 +128,7 @@ async function run() {
123128
throw new UserError('failed to add preconditions changes to git');
124129
},
125130
() => {},
131+
undefined,
126132
Verboseness.NORMAL,
127133
);
128134

@@ -143,6 +149,7 @@ async function run() {
143149
throw new UserError('failed to merge or create tag');
144150
},
145151
() => {},
152+
undefined,
146153
Verboseness.NORMAL,
147154
);
148155

automation/shellUtils.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ export enum Verboseness {
77
VERBOSE,
88
}
99

10-
function exec(c: string): Subprocess<'ignore', 'pipe', 'inherit'> {
11-
return Bun.spawn(stringArgv(c));
10+
function exec(c: string, cwd?: string): Subprocess<'ignore', 'pipe', 'inherit'> {
11+
return Bun.spawn(stringArgv(c), { cwd: cwd });
1212
}
1313

1414
export async function $(
1515
cmd: string,
16+
cwd?: string | undefined,
1617
verboseness: Verboseness = Verboseness.NORMAL,
1718
): Promise<{ stdout: string; stderr: string; exit: number }> {
1819
if (verboseness === Verboseness.NORMAL || verboseness === Verboseness.VERBOSE) {
19-
console.log(`\n${CMD_FMT.Bright}running${CMD_FMT.Reset} - ${cmd}\n`);
20+
if (cwd !== undefined) {
21+
console.log(`\n${CMD_FMT.Bright}running${CMD_FMT.Reset} in ${cwd} - ${cmd}\n`);
22+
} else {
23+
console.log(`\n${CMD_FMT.Bright}running${CMD_FMT.Reset} - ${cmd}\n`);
24+
}
2025
}
2126

22-
const proc = exec(cmd);
27+
const proc = exec(cmd, cwd);
2328
const stdout = await new Response(proc.stdout).text();
2429
const stderr = await new Response(proc.stderr).text();
2530

@@ -64,12 +69,13 @@ export async function $seq(
6469
cmds: string[],
6570
onError: (cmd: string, index: number) => void,
6671
onSuccess: () => void,
72+
cwd?: string | undefined,
6773
verboseness: Verboseness = Verboseness.NORMAL,
6874
): Promise<void> {
6975
const results = [];
7076
for (let i = 0; i < cmds.length; i += 1) {
7177
const cmd = cmds[i];
72-
const result = await $(cmd, verboseness);
78+
const result = await $(cmd, cwd, verboseness);
7379

7480
if (result.exit !== 0) {
7581
onError(cmd, i);
@@ -91,7 +97,7 @@ export async function $input(message: string): Promise<string> {
9197
return text.trim();
9298
}
9399

94-
export async function $choise(message: string, options: string[]): Promise<number> {
100+
export async function $choice(message: string, options: string[]): Promise<number> {
95101
console.log(`${message} `);
96102

97103
let optionNumbers = new Map<string, number>();

automation/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
export class UserError extends Error {}
2+
3+
export interface ProjectConfig {
4+
corePackages: string[];
5+
packages: string[];
6+
}

bun.lockb

8.67 KB
Binary file not shown.

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"types": "tsc -p \"./tsconfig.types.json\"",
1919
"check": "bun run format:check && bun run lint && bun run tsc && bun run test",
2020
"check:fix": "bun run format && bun run lint:fix && bun run tsc && bun run test",
21+
"pack:i": "bun run automation/installScript.ts",
2122
"release": "bun run automation/release.ts",
2223
"serve-publish": "bun --watch automation/publishServer.ts",
2324
"stats": "bun run automation/stats.ts"
@@ -41,7 +42,6 @@
4142
"eslint-plugin-isaacscript": "^3.12.2",
4243
"eslint-plugin-no-relative-import-paths": "^1.5.3",
4344
"eslint-plugin-only-warn": "^1.1.0",
44-
"itertools-ts": "^1.27.0",
4545
"prettier": "^3.2.5",
4646
"prettier-plugin-svelte": "^3.2.1",
4747
"string-argv": "^0.3.2",
@@ -50,5 +50,14 @@
5050
"tslib": "2.6.2",
5151
"typescript": "^5.3.3"
5252
},
53+
"dependencies": {
54+
"@codemirror/legacy-modes": "^6.3.3",
55+
"@lemons_dev/parsinom": "^0.0.12",
56+
"itertools-ts": "^1.27.0",
57+
"mathjs": "^12.0.0",
58+
"zod": "^3.22.4",
59+
"zod-validation-error": "^2.1.0",
60+
"moment": "^2.30.1"
61+
},
5362
"private": true
5463
}

packages/core/bun.lockb

-6.15 KB
Binary file not shown.

packages/core/package.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
"name": "meta-bind-core",
33
"main": "src/index.ts",
44
"devDependencies": {
5-
"svelte": "^4.2.11",
6-
"typescript": "^5.0.0"
7-
},
8-
"dependencies": {
9-
"@lemons_dev/parsinom": "^0.0.12",
10-
"itertools-ts": "^1.27.0",
11-
"mathjs": "^12.0.0",
12-
"zod": "^3.22.4",
13-
"zod-validation-error": "^2.1.0",
14-
"moment": "^2.30.1"
5+
"svelte": "^4.2.11"
156
}
167
}

packages/obsidian/bun.lockb

-862 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)