mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Simplify plugin build scripts
This commit is contained in:
parent
ff08d411fa
commit
9c2fdfc574
4 changed files with 26 additions and 20 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import esbuild from "esbuild";
|
||||
|
||||
const production = process.argv.includes("--production");
|
||||
const watch = process.argv.includes("--watch");
|
||||
import { buildStyles } from "./scripts/build-styles.mjs";
|
||||
|
||||
const context = await esbuild.context({
|
||||
await buildStyles();
|
||||
|
||||
await esbuild.build({
|
||||
entryPoints: ["src/main.ts"],
|
||||
bundle: true,
|
||||
external: ["obsidian"],
|
||||
|
|
@ -12,15 +13,7 @@ const context = await esbuild.context({
|
|||
target: "es2022",
|
||||
jsx: "automatic",
|
||||
outfile: "main.js",
|
||||
sourcemap: production ? false : "inline",
|
||||
minify: production,
|
||||
sourcemap: false,
|
||||
minify: true,
|
||||
logLevel: "info",
|
||||
});
|
||||
|
||||
if (watch) {
|
||||
await context.watch();
|
||||
console.log("Watching Codex Panel plugin...");
|
||||
} else {
|
||||
await context.rebuild();
|
||||
await context.dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
},
|
||||
"homepage": "https://github.com/murashit/codex-panel#readme",
|
||||
"scripts": {
|
||||
"build:styles": "node scripts/build-styles.mjs",
|
||||
"build:styles:check": "node scripts/build-styles.mjs --check",
|
||||
"build": "node esbuild.config.mjs",
|
||||
"build:prod": "node esbuild.config.mjs --production",
|
||||
"dev": "node esbuild.config.mjs --watch",
|
||||
"format": "node scripts/format.mjs",
|
||||
"format:check": "node scripts/format.mjs --check --cache",
|
||||
"format:check:ci": "node scripts/format.mjs --check",
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"api:baseline:check": "node scripts/api-baseline.mjs --check",
|
||||
"generate:app-server-types": "node scripts/generate-app-server-types.mjs",
|
||||
"lint": "node scripts/run-parallel.mjs lint:ts lint:css",
|
||||
"lint:css": "stylelint \"*.css\" \"src/**/*.css\" --max-warnings=0",
|
||||
"lint:css": "stylelint \"src/**/*.css\" --max-warnings=0",
|
||||
"lint:ts": "eslint src tests scripts \"*.config.ts\" \"*.config.mjs\" --max-warnings=0 --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content",
|
||||
"lint:ts:ci": "eslint src tests scripts \"*.config.ts\" \"*.config.mjs\" --max-warnings=0",
|
||||
"release:check": "node scripts/release/check.mjs",
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ for (const arg of args) {
|
|||
}
|
||||
|
||||
if (args.has("--ci")) {
|
||||
for (const script of ["typecheck:ci", "test:ci", "lint:ts:ci", "lint:css", "format:check:ci", "build:prod"]) {
|
||||
for (const script of ["typecheck:ci", "test:ci", "lint:ts:ci", "lint:css", "format:check:ci", "build:styles:check", "build"]) {
|
||||
run(npmCommand, ["run", script]);
|
||||
}
|
||||
} else {
|
||||
run("node", ["scripts/run-parallel.mjs", "typecheck", "test", "lint:ts", "lint:css", "format:check"]);
|
||||
run(npmCommand, ["run", "build:prod"]);
|
||||
run("node", ["scripts/run-parallel.mjs", "typecheck", "test", "lint:ts", "lint:css", "format:check", "build:styles:check"]);
|
||||
run(npmCommand, ["run", "build"]);
|
||||
}
|
||||
|
||||
function run(command, args) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ describe("development scripts", () => {
|
|||
"lint:ts:ci": 'node -e "process.exit(0)"',
|
||||
"lint:css": 'node -e "process.exit(0)"',
|
||||
"format:check:ci": 'node -e "process.exit(0)"',
|
||||
"build:prod": 'node -e "process.exit(0)"',
|
||||
build: 'node -e "process.exit(0)"',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -26,6 +26,19 @@ describe("development scripts", () => {
|
|||
expect(result.status).toBe(7);
|
||||
});
|
||||
|
||||
it("fails style builds when CSS files are missing from the style manifest", async () => {
|
||||
const cwd = await tempWorkspace();
|
||||
await mkdir(path.join(cwd, "src", "styles"), { recursive: true });
|
||||
await writeJson(path.join(cwd, "src", "styles", "manifest.json"), ["00-tokens.css"]);
|
||||
await writeFile(path.join(cwd, "src", "styles", "00-tokens.css"), ".codex-panel { color: var(--text-normal); }\n");
|
||||
await writeFile(path.join(cwd, "src", "styles", "10-unlisted.css"), ".codex-panel__extra { display: block; }\n");
|
||||
|
||||
const result = runNodeScript("scripts/build-styles.mjs", ["--check"], cwd);
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stderr).toContain("CSS files missing from src/styles/manifest.json: 10-unlisted.css");
|
||||
});
|
||||
|
||||
it("passes the expected codex generate-ts arguments", async () => {
|
||||
const cwd = await tempWorkspace();
|
||||
const binDir = path.join(cwd, "bin");
|
||||
|
|
|
|||
Loading…
Reference in a new issue