Skip to content

Commit e8a39f3

Browse files
committed
update deps
1 parent a06165f commit e8a39f3

Some content is hidden

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

44 files changed

+489
-394
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 39 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ exampleVault/.obsidian/*
3232
exampleVault/.obsidian/plugins/*
3333
exampleVault/.obsidian/plugins/obsidian-js-engine-plugin/*
3434
!exampleVault/.obsidian/plugins/obsidian-js-engine-plugin/.hotreload
35+
36+
meta.txt

automation/build/buildBanner.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import manifest from '../../manifest.json' assert { type: 'json' };
2+
3+
export function getBuildBanner(buildType: string, getVersion: (version: string) => string) {
4+
return `/*
5+
-------------------------------------------
6+
${manifest.name} - ${buildType}
7+
-------------------------------------------
8+
By: ${manifest.author} (${manifest.authorUrl})
9+
Time: ${new Date().toUTCString()}
10+
Version: ${getVersion(manifest.version)}
11+
-------------------------------------------
12+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
13+
if you want to view the source, please visit the github repository of this plugin
14+
-------------------------------------------
15+
Copyright (C) ${new Date().getFullYear()} ${manifest.author}
16+
-------------------------------------------
17+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
18+
19+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20+
21+
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
`;
24+
}

automation/build/esbuild.config.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import builtins from 'builtin-modules';
2+
import esbuild from 'esbuild';
3+
import esbuildSvelte from 'esbuild-svelte';
4+
import sveltePreprocess from 'svelte-preprocess';
5+
import { getBuildBanner } from 'build/buildBanner';
6+
7+
const banner = getBuildBanner('Release Build', version => version);
8+
9+
const build = await esbuild.build({
10+
banner: {
11+
js: banner,
12+
},
13+
entryPoints: ['jsEngine/main.ts'],
14+
bundle: true,
15+
external: [
16+
'obsidian',
17+
'electron',
18+
'@codemirror/autocomplete',
19+
'@codemirror/collab',
20+
'@codemirror/commands',
21+
'@codemirror/language',
22+
'@codemirror/lint',
23+
'@codemirror/search',
24+
'@codemirror/state',
25+
'@codemirror/view',
26+
'@lezer/common',
27+
'@lezer/highlight',
28+
'@lezer/lr',
29+
...builtins,
30+
],
31+
format: 'cjs',
32+
target: 'es2022',
33+
logLevel: 'info',
34+
sourcemap: false,
35+
treeShaking: true,
36+
outfile: 'main.js',
37+
minify: true,
38+
metafile: true,
39+
define: {
40+
MB_GLOBAL_CONFIG_DEV_BUILD: 'false',
41+
},
42+
plugins: [
43+
esbuildSvelte({
44+
compilerOptions: { css: 'injected', dev: false, sveltePath: 'svelte' },
45+
preprocess: sveltePreprocess(),
46+
filterWarnings: warning => {
47+
// we don't want warnings from node modules that we can do nothing about
48+
return !warning.filename?.includes('node_modules');
49+
},
50+
}),
51+
],
52+
});
53+
54+
const file = Bun.file('meta.txt');
55+
await Bun.write(file, JSON.stringify(build.metafile, null, '\t'));
56+
57+
process.exit(0);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import esbuild from 'esbuild';
2+
import copy from 'esbuild-plugin-copy-watch';
3+
import esbuildSvelte from 'esbuild-svelte';
4+
import sveltePreprocess from 'svelte-preprocess';
5+
import manifest from '../../manifest.json' assert { type: 'json' };
6+
import { getBuildBanner } from 'build/buildBanner';
7+
8+
const banner = getBuildBanner('Dev Build', _ => 'Dev Build');
9+
10+
const context = await esbuild.context({
11+
banner: {
12+
js: banner,
13+
},
14+
entryPoints: ['jsEngine/main.ts'],
15+
bundle: true,
16+
external: [
17+
'obsidian',
18+
'electron',
19+
'@codemirror/autocomplete',
20+
'@codemirror/collab',
21+
'@codemirror/commands',
22+
'@codemirror/language',
23+
'@codemirror/lint',
24+
'@codemirror/search',
25+
'@codemirror/state',
26+
'@codemirror/view',
27+
'@lezer/common',
28+
'@lezer/highlight',
29+
'@lezer/lr',
30+
],
31+
format: 'cjs',
32+
target: 'es2022',
33+
logLevel: 'info',
34+
sourcemap: 'inline',
35+
treeShaking: true,
36+
outdir: `exampleVault/.obsidian/plugins/${manifest.id}/`,
37+
outbase: 'jsEngine',
38+
plugins: [
39+
copy({
40+
paths: [
41+
{
42+
from: './styles.css',
43+
to: '',
44+
},
45+
{
46+
from: './manifest.json',
47+
to: '',
48+
},
49+
],
50+
}),
51+
esbuildSvelte({
52+
compilerOptions: { css: 'injected', dev: true, sveltePath: 'svelte' },
53+
preprocess: sveltePreprocess(),
54+
filterWarnings: warning => {
55+
// we don't want warnings from node modules that we can do nothing about
56+
return !(warning.filename?.includes('node_modules') || warning.message.includes('has unused export property'));
57+
},
58+
}),
59+
],
60+
});
61+
62+
await context.watch();

automation/release.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { $seq, Verboseness, $input, $choise, $confirm, CMD_FMT } from './shellUtils';
1+
import { UserError } from 'utils/utils';
2+
import { CanaryVersion, Version, getIncrementOptions, parseVersion, stringifyVersion } from 'utils/versionUtils';
23
import config from './config.json';
3-
import { Version, getIncrementOptions, parseVersion, stringifyVersion } from 'versionUtils';
4-
import { UserError } from 'utils';
4+
import { $choice as $choice, $confirm, $seq, CMD_FMT, Verboseness } from 'utils/shellUtils';
55

66
async function runPreconditions(): Promise<void> {
77
// run preconditions
88
await $seq(
9-
[`bun run format`, `bun run lint:fix`, `bun run tsc`, `bun run test`, `bun run types`],
9+
[`bun run format`, `bun run lint:fix`, `bun run test`],
1010
(cmd: string) => {
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

@@ -76,11 +81,11 @@ async function run() {
7681

7782
const versionIncrementOptions = getIncrementOptions(currentVersion);
7883

79-
const selctedIndex = await $choise(
84+
const selectedIndex = await $choice(
8085
`Current version "${currentVersionString}". Select new version`,
8186
versionIncrementOptions.map(x => stringifyVersion(x)),
8287
);
83-
const newVersion = versionIncrementOptions[selctedIndex];
88+
const newVersion = versionIncrementOptions[selectedIndex];
8489
const newVersionString = stringifyVersion(newVersion);
8590

8691
console.log('');
@@ -89,30 +94,41 @@ async function run() {
8994
throw new UserError('user canceled script');
9095
});
9196

92-
manifest.version = newVersionString;
97+
if (!(newVersion instanceof CanaryVersion)) {
98+
manifest.version = newVersionString;
99+
}
93100

94101
await Bun.write(manifestFile, JSON.stringify(manifest, null, '\t'));
95102

96-
const versionsFile = Bun.file('./versions.json');
97-
const versionsJson = await versionsFile.json();
103+
const betaManifest = structuredClone(manifest);
104+
betaManifest.version = newVersionString;
105+
106+
const betaManifestFile = Bun.file('./manifest-beta.json');
107+
await Bun.write(betaManifestFile, JSON.stringify(betaManifest, null, '\t'));
98108

99-
versionsJson[newVersionString] = manifest.minAppVersion;
109+
if (!(newVersion instanceof CanaryVersion)) {
110+
const versionsFile = Bun.file('./versions.json');
111+
const versionsJson = await versionsFile.json();
100112

101-
await Bun.write(versionsFile, JSON.stringify(versionsJson, null, '\t'));
113+
versionsJson[newVersionString] = manifest.minAppVersion;
102114

103-
const packageFile = Bun.file('./package.json');
104-
const packageJson = await packageFile.json();
115+
await Bun.write(versionsFile, JSON.stringify(versionsJson, null, '\t'));
105116

106-
packageJson.version = newVersionString;
117+
const packageFile = Bun.file('./package.json');
118+
const packageJson = await packageFile.json();
107119

108-
await Bun.write(packageFile, JSON.stringify(packageJson, null, '\t'));
120+
packageJson.version = newVersionString;
121+
122+
await Bun.write(packageFile, JSON.stringify(packageJson, null, '\t'));
123+
}
109124

110125
await $seq(
111126
[`bun run format`, `git add .`, `git commit -m "[auto] bump version to \`${newVersionString}\`"`],
112127
() => {
113128
throw new UserError('failed to add preconditions changes to git');
114129
},
115130
() => {},
131+
undefined,
116132
Verboseness.NORMAL,
117133
);
118134

@@ -133,6 +149,7 @@ async function run() {
133149
throw new UserError('failed to merge or create tag');
134150
},
135151
() => {},
152+
undefined,
136153
Verboseness.NORMAL,
137154
);
138155

automation/utils.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

automation/shellUtils.ts renamed to automation/utils/shellUtils.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +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

14-
export async function $(cmd: string, verboseness: Verboseness = Verboseness.NORMAL): Promise<{ stdout: string; stderr: string; exit: number }> {
14+
export async function $(
15+
cmd: string,
16+
cwd?: string | undefined,
17+
verboseness: Verboseness = Verboseness.NORMAL,
18+
): Promise<{ stdout: string; stderr: string; exit: number }> {
1519
if (verboseness === Verboseness.NORMAL || verboseness === Verboseness.VERBOSE) {
16-
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+
}
1725
}
1826

19-
const proc = exec(cmd);
27+
const proc = exec(cmd, cwd);
2028
const stdout = await new Response(proc.stdout).text();
2129
const stderr = await new Response(proc.stderr).text();
2230

@@ -61,12 +69,13 @@ export async function $seq(
6169
cmds: string[],
6270
onError: (cmd: string, index: number) => void,
6371
onSuccess: () => void,
72+
cwd?: string | undefined,
6473
verboseness: Verboseness = Verboseness.NORMAL,
6574
): Promise<void> {
6675
const results = [];
6776
for (let i = 0; i < cmds.length; i += 1) {
6877
const cmd = cmds[i];
69-
const result = await $(cmd, verboseness);
78+
const result = await $(cmd, cwd, verboseness);
7079

7180
if (result.exit !== 0) {
7281
onError(cmd, i);
@@ -88,7 +97,7 @@ export async function $input(message: string): Promise<string> {
8897
return text.trim();
8998
}
9099

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

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

automation/utils/utils.ts

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

0 commit comments

Comments
 (0)