Skip to content

Commit ca6f850

Browse files
committed
chore: rename task
1 parent 19af303 commit ca6f850

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

packages/mpx/src/build.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { env } from "node:process";
88
import ms from "pretty-ms";
99
import { BuildOptions, build as buildBundle, watch } from "rolldown";
1010
import { onExit } from "signal-exit";
11-
import { MODELER_FILES } from "./constants.js";
11+
import { PACKAGE_FILES } from "./constants.js";
1212
import { loadConfig } from "./rolldown.js";
1313
import { blue, bold, dim, green, greenBright, inverse } from "./utils/colors.js";
1414
import { isTypeScriptProject, readPackageJson } from "./utils/fs.js";
@@ -77,7 +77,7 @@ const tasks = {
7777
logger.success(formatMsg.built(bundle.output?.file!));
7878
}
7979

80-
await tasks.copyModelerFiles(params);
80+
await tasks.copyPackageFiles(params);
8181
await tasks.buildMpk(params);
8282

8383
const buildInfo = buildMeasure.end();
@@ -117,8 +117,8 @@ const tasks = {
117117
});
118118

119119
await bundleWatchReady;
120-
await tasks.watchModelerFiles(params);
121-
await tasks.watchContent(params);
120+
await tasks.watchPackageFiles(params);
121+
await tasks.watchPackageContent(params);
122122
logger.info("Waiting for changes...");
123123

124124
onExit(() => {
@@ -127,8 +127,8 @@ const tasks = {
127127
logger.log("Build watcher stopped");
128128
});
129129
},
130-
async copyModelerFiles({ project }: TaskParams): Promise<void> {
131-
const stream = fg.stream(MODELER_FILES);
130+
async copyPackageFiles({ project }: TaskParams): Promise<void> {
131+
const stream = fg.stream(PACKAGE_FILES);
132132
for await (const src of stream) {
133133
const f = path.parse(src as string);
134134
const dst = path.join(project.outputDirs.contentRoot, f.base);
@@ -138,12 +138,13 @@ const tasks = {
138138
});
139139
}
140140
},
141-
async watchModelerFiles(params: TaskParams): Promise<void> {
141+
/** Watch & copy static package files */
142+
async watchPackageFiles(params: TaskParams): Promise<void> {
142143
const { project, logger } = params;
143144

144-
await tasks.copyModelerFiles(params);
145+
await tasks.copyPackageFiles(params);
145146

146-
const watcher = chokidar.watch(await fg(MODELER_FILES));
147+
const watcher = chokidar.watch(await fg(PACKAGE_FILES));
147148
watcher.on("change", async file => {
148149
logger.info(formatMsg.copy(file));
149150
const f = path.parse(file);
@@ -155,7 +156,8 @@ const tasks = {
155156
watcher.close();
156157
});
157158
},
158-
async watchContent(params: TaskParams): Promise<void> {
159+
/** Setup package content watcher to build mpk whenever package files change */
160+
async watchPackageContent(params: TaskParams): Promise<void> {
159161
const { project } = params;
160162
await tasks.buildMpk({ ...params, quiet: true });
161163
const watcher = chokidar.watch(project.outputDirs.contentRoot);

packages/mpx/src/constants.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { readFileSync } from "node:fs";
1+
import pkg from "../package.json" with { type: "json" };
22

3-
const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url)).toString());
4-
5-
export const VERSION = version as string;
3+
export const VERSION = pkg.version as string;
64

75
export const STD_EXTERNALS = [
86
// "mendix" and internals under "mendix/"
@@ -13,4 +11,11 @@ export const STD_EXTERNALS = [
1311
/^big.js$/
1412
];
1513

16-
export const MODELER_FILES = ["src/*.xml", "src/*.@(tile|icon)?(.dark).png"];
14+
export const PACKAGE_FILES = [
15+
// XML files
16+
"src/*.xml",
17+
// Modeler icons
18+
"src/*.@(tile|icon)?(.dark).png",
19+
// License file
20+
"{licen[cs]e,LICEN[CS]E}?(.*)"
21+
];

0 commit comments

Comments
 (0)