@mndw/cli 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/meta.json +80 -24
- package/dist/mndw.js +382 -69
- package/host-dev/assets/index-BqQCCILo.css +1 -0
- package/host-dev/assets/index-DFVRx7na.js +94 -0
- package/host-dev/assets/sandbox-url-D8HO7UBF.js +1 -0
- package/host-dev/index.html +3 -3
- package/host-dev/shared/{mndw-ui@0.1.6.js → mndw-ui@0.2.0.js} +171 -156
- package/package.json +18 -14
- package/templates/angular/i18n/en.json +4 -9
- package/templates/angular/i18n/ru.json +4 -9
- package/templates/angular/src/app.component.ts +39 -39
- package/templates/angular/src/index.ts +14 -1
- package/templates/angular/src/l10n.test.ts +50 -17
- package/templates/go/i18n/en.json +1 -1
- package/templates/go/i18n/ru.json +1 -1
- package/templates/go/src/index.css +4 -20
- package/templates/go/src/index.test.ts +12 -24
- package/templates/go/src/index.ts +18 -15
- package/templates/go/src/l10n.test.ts +37 -23
- package/templates/svelte/i18n/en.json +4 -9
- package/templates/svelte/i18n/ru.json +4 -9
- package/templates/svelte/src/App.svelte +46 -72
- package/templates/svelte/src/index.ts +7 -0
- package/templates/svelte/src/l10n.test.ts +64 -17
- package/templates/svelte/svelte.config.js +7 -0
- package/templates/svelte/vitest.config.ts +2 -1
- package/templates/vanilla/i18n/en.json +4 -3
- package/templates/vanilla/i18n/ru.json +4 -3
- package/templates/vanilla/src/index.css +4 -20
- package/templates/vanilla/src/index.ts +47 -17
- package/templates/vanilla/src/l10n.test.ts +50 -17
- package/templates/vue/i18n/en.json +4 -9
- package/templates/vue/i18n/ru.json +4 -9
- package/templates/vue/src/App.vue +36 -54
- package/templates/vue/src/index.ts +7 -0
- package/templates/vue/src/l10n.test.ts +50 -17
- package/host-dev/assets/index-B_LYyF1e.css +0 -1
- package/host-dev/assets/index-MuieOssk.js +0 -94
- package/host-dev/assets/sandbox-url-CsfwrS11.js +0 -1
- package/templates/angular/src/table.test.ts +0 -59
- package/templates/svelte/src/TableNameCell.svelte +0 -10
- package/templates/svelte/src/table.test.ts +0 -53
- package/templates/vue/src/TableNameCell.vue +0 -12
- package/templates/vue/src/table.test.ts +0 -53
package/dist/mndw.js
CHANGED
|
@@ -211,7 +211,8 @@ var eventSchema = z.union([
|
|
|
211
211
|
available_bytes: nonNegativeInteger,
|
|
212
212
|
threshold_bytes: nonNegativeInteger
|
|
213
213
|
}).strict()
|
|
214
|
-
)
|
|
214
|
+
),
|
|
215
|
+
eventBranch("telemetry.gathering_changed", "internal", z.object({ enabled: z.boolean() }).strict())
|
|
215
216
|
]).superRefine((event, context) => {
|
|
216
217
|
const encoded = new TextEncoder().encode(JSON.stringify(event.payload));
|
|
217
218
|
if (encoded.length > MaxEventPayloadBytes) {
|
|
@@ -285,6 +286,150 @@ var backendStatusSchema = z3.preprocess(
|
|
|
285
286
|
rejectVariantOnlyFields,
|
|
286
287
|
z3.discriminatedUnion("state", [blockedStatusSchema, incompatibleStatusSchema, plainStatusSchema])
|
|
287
288
|
);
|
|
289
|
+
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
290
|
+
"BACKEND_BUSY",
|
|
291
|
+
"BACKEND_STARTING",
|
|
292
|
+
"BACKEND_UNAVAILABLE",
|
|
293
|
+
"BACKEND_MAINTENANCE",
|
|
294
|
+
"BAD_GATEWAY",
|
|
295
|
+
"SERVER_BUSY",
|
|
296
|
+
"REQUEST_TIMEOUT",
|
|
297
|
+
"SCRIPT_TIMEOUT",
|
|
298
|
+
"STATUS_QUERY_FAILED"
|
|
299
|
+
]);
|
|
300
|
+
var isRetryable = (code, status) => {
|
|
301
|
+
if (code === "HTTP_ERROR") {
|
|
302
|
+
return status === 408 || status === 425 || status === 429 || status !== void 0 && status >= 500;
|
|
303
|
+
}
|
|
304
|
+
return RETRYABLE_CODES.has(code);
|
|
305
|
+
};
|
|
306
|
+
var BackendError = class extends Error {
|
|
307
|
+
id;
|
|
308
|
+
code;
|
|
309
|
+
status;
|
|
310
|
+
retryable;
|
|
311
|
+
details;
|
|
312
|
+
constructor(message, code, id, options = {}) {
|
|
313
|
+
super(message);
|
|
314
|
+
this.name = "BackendError";
|
|
315
|
+
this.code = code;
|
|
316
|
+
this.id = id;
|
|
317
|
+
this.status = options.status;
|
|
318
|
+
this.retryable = options.retryable ?? isRetryable(code, options.status);
|
|
319
|
+
this.details = options.details;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
var BackendUnknownId = class extends BackendError {
|
|
323
|
+
code;
|
|
324
|
+
constructor(id, options = {}) {
|
|
325
|
+
const code = options.code ?? "UNKNOWN_ID";
|
|
326
|
+
super(`Unknown backend binding id: "${id}"`, code, id, options);
|
|
327
|
+
this.code = code;
|
|
328
|
+
this.name = "BackendUnknownId";
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
var BackendNotApproved = class extends BackendError {
|
|
332
|
+
code = "NOT_APPROVED";
|
|
333
|
+
constructor(id, options = {}) {
|
|
334
|
+
super(`Backend "${id}" is not approved`, "NOT_APPROVED", id, options);
|
|
335
|
+
this.name = "BackendNotApproved";
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
var BackendDisabled = class extends BackendError {
|
|
339
|
+
code = "DISABLED";
|
|
340
|
+
constructor(id, options = {}) {
|
|
341
|
+
super(`Backend "${id}" is disabled`, "DISABLED", id, options);
|
|
342
|
+
this.name = "BackendDisabled";
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var BackendStarting = class extends BackendError {
|
|
346
|
+
constructor(id, retryAfterSeconds, options = {}) {
|
|
347
|
+
super(`Backend "${id}" is starting`, "BACKEND_STARTING", id, options);
|
|
348
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
349
|
+
this.name = "BackendStarting";
|
|
350
|
+
}
|
|
351
|
+
code = "BACKEND_STARTING";
|
|
352
|
+
};
|
|
353
|
+
var BackendUnavailable = class extends BackendError {
|
|
354
|
+
code = "BACKEND_UNAVAILABLE";
|
|
355
|
+
constructor(id, options = {}) {
|
|
356
|
+
super(`Backend "${id}" is unavailable`, "BACKEND_UNAVAILABLE", id, options);
|
|
357
|
+
this.name = "BackendUnavailable";
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
var BackendIncompatible = class extends BackendError {
|
|
361
|
+
code = "BACKEND_INCOMPATIBLE";
|
|
362
|
+
constructor(id, options = {}) {
|
|
363
|
+
super(`Backend "${id}" is incompatible`, "BACKEND_INCOMPATIBLE", id, options);
|
|
364
|
+
this.name = "BackendIncompatible";
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var BackendMaintenance = class extends BackendError {
|
|
368
|
+
constructor(id, retryAfterSeconds, options = {}) {
|
|
369
|
+
super(`Backend "${id}" is under maintenance`, "BACKEND_MAINTENANCE", id, options);
|
|
370
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
371
|
+
this.name = "BackendMaintenance";
|
|
372
|
+
}
|
|
373
|
+
code = "BACKEND_MAINTENANCE";
|
|
374
|
+
};
|
|
375
|
+
var BackendBlocked = class extends BackendError {
|
|
376
|
+
constructor(id, blockers, retryAfterSeconds, options = {}) {
|
|
377
|
+
super(`Backend "${id}" is blocked on an unmet activation prerequisite`, "BACKEND_BLOCKED", id, options);
|
|
378
|
+
this.blockers = blockers;
|
|
379
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
380
|
+
this.name = "BackendBlocked";
|
|
381
|
+
}
|
|
382
|
+
code = "BACKEND_BLOCKED";
|
|
383
|
+
};
|
|
384
|
+
var BackendBadGateway = class extends BackendError {
|
|
385
|
+
code = "BAD_GATEWAY";
|
|
386
|
+
constructor(id, options = {}) {
|
|
387
|
+
super(`Backend "${id}" returned a bad gateway response`, "BAD_GATEWAY", id, options);
|
|
388
|
+
this.name = "BackendBadGateway";
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var parseRetryAfterSeconds = (response) => {
|
|
392
|
+
const raw = response.headers.get("Retry-After");
|
|
393
|
+
if (raw === null || !/^\d+$/.test(raw)) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
const value = Number(raw);
|
|
397
|
+
return Number.isSafeInteger(value) ? value : null;
|
|
398
|
+
};
|
|
399
|
+
var parseBlockers = (detail) => {
|
|
400
|
+
const parsed = z3.array(backendBlockerSchema).safeParse(detail);
|
|
401
|
+
return parsed.success ? parsed.data : [];
|
|
402
|
+
};
|
|
403
|
+
var genericErrorFactory = (code, fallback) => {
|
|
404
|
+
return (id, response, error, options) => new BackendError(
|
|
405
|
+
error.message ?? fallback,
|
|
406
|
+
code,
|
|
407
|
+
id,
|
|
408
|
+
{ ...options, status: response.status }
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
var ERROR_BY_CODE = {
|
|
412
|
+
DISABLED: (id, _res, _error, options) => new BackendDisabled(id, options),
|
|
413
|
+
NOT_APPROVED: (id, _res, _error, options) => new BackendNotApproved(id, options),
|
|
414
|
+
ROUTE_NOT_FOUND: (id, _res, _error, options) => new BackendUnknownId(id, { ...options, code: "ROUTE_NOT_FOUND" }),
|
|
415
|
+
BACKEND_STARTING: (id, res, _error, options) => new BackendStarting(id, parseRetryAfterSeconds(res), options),
|
|
416
|
+
BACKEND_UNAVAILABLE: (id, _res, _error, options) => new BackendUnavailable(id, options),
|
|
417
|
+
BACKEND_INCOMPATIBLE: (id, _res, _error, options) => new BackendIncompatible(id, options),
|
|
418
|
+
BACKEND_MAINTENANCE: (id, res, _error, options) => new BackendMaintenance(id, parseRetryAfterSeconds(res), options),
|
|
419
|
+
BACKEND_BLOCKED: (id, res, error, options) => new BackendBlocked(id, parseBlockers(error.detail), parseRetryAfterSeconds(res), options),
|
|
420
|
+
BAD_GATEWAY: (id, _res, _error, options) => new BackendBadGateway(id, options),
|
|
421
|
+
BAD_REQUEST: genericErrorFactory("BAD_REQUEST", "Backend request was rejected"),
|
|
422
|
+
INTERNAL: genericErrorFactory("INTERNAL", "Backend request failed"),
|
|
423
|
+
SERVER_BUSY: genericErrorFactory("SERVER_BUSY", "Backend request intake is busy"),
|
|
424
|
+
REQUEST_TIMEOUT: genericErrorFactory("REQUEST_TIMEOUT", "Backend request timed out"),
|
|
425
|
+
SCRIPT_FAILED: genericErrorFactory("SCRIPT_FAILED", "Backend script failed"),
|
|
426
|
+
SCRIPT_TIMEOUT: genericErrorFactory("SCRIPT_TIMEOUT", "Backend script timed out"),
|
|
427
|
+
BACKEND_BUSY: genericErrorFactory("BACKEND_BUSY", "Backend is busy"),
|
|
428
|
+
BACKEND_BODY_TOO_LARGE: genericErrorFactory("BACKEND_BODY_TOO_LARGE", "Backend request body is too large"),
|
|
429
|
+
BACKEND_OUTPUT_TOO_LARGE: genericErrorFactory("BACKEND_OUTPUT_TOO_LARGE", "Backend output is too large"),
|
|
430
|
+
CSRF_REQUIRED: genericErrorFactory("CSRF_REQUIRED", "Backend request requires CSRF protection"),
|
|
431
|
+
UNAUTHORIZED: genericErrorFactory("UNAUTHORIZED", "Backend request is unauthorized")
|
|
432
|
+
};
|
|
288
433
|
|
|
289
434
|
// ../../frontend/sdk-internal/src/manifest-schema.ts
|
|
290
435
|
var pluginNameSchema = z4.string().regex(/^[a-z0-9][a-z0-9-]*$/, {
|
|
@@ -377,7 +522,7 @@ var safeBackendRoutePath = (value) => {
|
|
|
377
522
|
const segments = decoded.split("/");
|
|
378
523
|
return segments.every((segment) => segment.length > 0 && segment !== "." && segment !== "..") && segments[0] !== "_mndw";
|
|
379
524
|
};
|
|
380
|
-
var commandSchema = safeRelativePathSchema.refine(hasFileName, { message: "command must include a file name" }).refine((command) => {
|
|
525
|
+
var commandSchema = safeRelativePathSchema.regex(/^backend\//, { message: "command must start with backend/" }).refine(hasFileName, { message: "command must include a file name" }).refine((command) => {
|
|
381
526
|
return !command.split("/").some((segment) => segment === "." || segment === "..");
|
|
382
527
|
}, { message: "command must not contain dot segments" });
|
|
383
528
|
var literalArgumentSchema = z4.string().min(1).refine((value) => {
|
|
@@ -421,7 +566,7 @@ var validateRoutes = (routes, ctx) => {
|
|
|
421
566
|
var execBackendSchema = z4.object({
|
|
422
567
|
kind: z4.literal("exec"),
|
|
423
568
|
packages: z4.array(packageSchema).optional(),
|
|
424
|
-
routes: z4.array(execRouteSchema).min(1)
|
|
569
|
+
routes: z4.array(execRouteSchema).min(1, { message: "backend.routes must contain at least one route" })
|
|
425
570
|
}).strict().superRefine((backend, ctx) => {
|
|
426
571
|
validateRoutes(backend.routes, ctx);
|
|
427
572
|
});
|
|
@@ -431,16 +576,23 @@ var serviceBackendSchema = z4.object({
|
|
|
431
576
|
command: commandSchema,
|
|
432
577
|
args: z4.array(literalArgumentSchema).optional(),
|
|
433
578
|
packages: z4.array(packageSchema).optional(),
|
|
434
|
-
routes: z4.array(z4.union([httpRouteSchema, websocketRouteSchema])).min(1
|
|
579
|
+
routes: z4.array(z4.union([httpRouteSchema, websocketRouteSchema])).min(1, {
|
|
580
|
+
message: "backend.routes must contain at least one route"
|
|
581
|
+
})
|
|
435
582
|
}).strict().superRefine((backend, ctx) => {
|
|
436
583
|
validateRoutes(backend.routes, ctx);
|
|
437
584
|
});
|
|
438
585
|
var backendSchema = z4.union([execBackendSchema, serviceBackendSchema]);
|
|
439
|
-
var gridColumns = z4.number().int().
|
|
586
|
+
var gridColumns = z4.number().int({ message: "gridColumns must be an integer" }).min(1, { message: "gridColumns must be at least 1" }).max(12, { message: "gridColumns must be at most 12" });
|
|
440
587
|
var gridRows = z4.number().int().positive();
|
|
441
588
|
var versionSchema = z4.literal(1).describe("Manifest format version. Must be 1.");
|
|
442
589
|
var nameSchema = pluginNameSchema.describe("Unique plugin id used as the on-disk folder and URL segment.");
|
|
443
|
-
var versionField = z4.string().
|
|
590
|
+
var versionField = z4.string().regex(
|
|
591
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,
|
|
592
|
+
{
|
|
593
|
+
message: "version must be valid SemVer (for example, 1.2.3)"
|
|
594
|
+
}
|
|
595
|
+
).describe("Semantic version of this plugin.");
|
|
444
596
|
var labelField = z4.string().min(1).describe("Human-readable name shown in the dashboard or navigation.");
|
|
445
597
|
var entryField = pluginEntrySchema.describe("Relative path to the bundled entry module.");
|
|
446
598
|
var iconField = z4.string().optional().describe("Optional icon name.");
|
|
@@ -561,7 +713,7 @@ var SHARED_DEPENDENCIES = [
|
|
|
561
713
|
{
|
|
562
714
|
specifiers: ["@mndw/ui"],
|
|
563
715
|
bundle: "mndw-ui",
|
|
564
|
-
version: "0.
|
|
716
|
+
version: "0.2.0",
|
|
565
717
|
entryPoint: "@mndw/ui",
|
|
566
718
|
external: ["d3"],
|
|
567
719
|
framework: "base"
|
|
@@ -2337,7 +2489,7 @@ function angularSandboxPlugin(pluginDir, deps = {}) {
|
|
|
2337
2489
|
const relativePath = path.relative(sourceDir, sourcePath);
|
|
2338
2490
|
return !relativePath.startsWith("..") && path.extname(sourcePath) === ".ts" && !sourcePath.endsWith(".d.ts");
|
|
2339
2491
|
};
|
|
2340
|
-
const
|
|
2492
|
+
const transform2 = (_code, id) => {
|
|
2341
2493
|
const sourcePath = path.resolve(stripQuery(id));
|
|
2342
2494
|
if (!isSourceFile(sourcePath)) {
|
|
2343
2495
|
return null;
|
|
@@ -2404,7 +2556,7 @@ if (typeof document !== 'undefined') {
|
|
|
2404
2556
|
export default css;
|
|
2405
2557
|
`;
|
|
2406
2558
|
},
|
|
2407
|
-
transform,
|
|
2559
|
+
transform: transform2,
|
|
2408
2560
|
handleHotUpdate,
|
|
2409
2561
|
configureServer(server) {
|
|
2410
2562
|
server.httpServer?.once("close", () => compiler.dispose());
|
|
@@ -2427,6 +2579,7 @@ function errorMessage(error) {
|
|
|
2427
2579
|
|
|
2428
2580
|
// src/dev-server/start.ts
|
|
2429
2581
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
2582
|
+
import { mndwSvelteWarningFilter } from "@mndw/sdk/svelte";
|
|
2430
2583
|
import vue from "@vitejs/plugin-vue";
|
|
2431
2584
|
import { createServer } from "vite";
|
|
2432
2585
|
|
|
@@ -2711,7 +2864,7 @@ function sharedExternals(framework) {
|
|
|
2711
2864
|
|
|
2712
2865
|
// src/dev-server/start.ts
|
|
2713
2866
|
async function startPluginDevServer(options) {
|
|
2714
|
-
const frameworkPlugins = options.framework === "svelte" ? [svelte()] : options.framework === "vue" ? [vue({ isProduction: true })] : options.framework === "angular" ? [angularSandboxPlugin(options.pluginDir)] : [];
|
|
2867
|
+
const frameworkPlugins = options.framework === "svelte" ? [svelte({ compilerOptions: { warningFilter: mndwSvelteWarningFilter } })] : options.framework === "vue" ? [vue({ isProduction: true })] : options.framework === "angular" ? [angularSandboxPlugin(options.pluginDir)] : [];
|
|
2715
2868
|
const server = await createServer({
|
|
2716
2869
|
root: options.pluginDir,
|
|
2717
2870
|
cacheDir: resolve13(options.pluginDir, "node_modules", `.vite-${options.framework}-dev`),
|
|
@@ -3298,34 +3451,155 @@ function validatePluginCatalogs(pluginDir, manifest, options) {
|
|
|
3298
3451
|
return warnings;
|
|
3299
3452
|
}
|
|
3300
3453
|
|
|
3454
|
+
// src/css-scope-validator.ts
|
|
3455
|
+
import { existsSync as existsSync6, readFileSync as readFileSync10 } from "node:fs";
|
|
3456
|
+
import { join as join11 } from "node:path";
|
|
3457
|
+
import postcss from "postcss";
|
|
3458
|
+
var isKeyframesRule = (name) => {
|
|
3459
|
+
return /^(?:-\w+-)?keyframes$/i.test(name);
|
|
3460
|
+
};
|
|
3461
|
+
var isAtRule = (node) => {
|
|
3462
|
+
return node.type === "atrule";
|
|
3463
|
+
};
|
|
3464
|
+
var hasKeyframesAncestor = (rule) => {
|
|
3465
|
+
let node = rule.parent;
|
|
3466
|
+
while (node !== void 0) {
|
|
3467
|
+
if (isAtRule(node) && isKeyframesRule(node.name)) {
|
|
3468
|
+
return true;
|
|
3469
|
+
}
|
|
3470
|
+
node = node.parent;
|
|
3471
|
+
}
|
|
3472
|
+
return false;
|
|
3473
|
+
};
|
|
3474
|
+
var isRootTokenSelector = (selector) => {
|
|
3475
|
+
return /^:root(?:\[data-theme(?:=(?:"[^"]*"|'[^']*'|[^\]]+))?\])*$/.test(selector);
|
|
3476
|
+
};
|
|
3477
|
+
var skipCssEscape = (selector, index) => {
|
|
3478
|
+
let next = index + 1;
|
|
3479
|
+
if (!/[\da-f]/i.test(selector[next] ?? "")) {
|
|
3480
|
+
return Math.min(next + 1, selector.length);
|
|
3481
|
+
}
|
|
3482
|
+
for (let digits = 0; digits < 6 && /[\da-f]/i.test(selector[next] ?? ""); digits++) {
|
|
3483
|
+
next++;
|
|
3484
|
+
}
|
|
3485
|
+
return next + (/[\s]/.test(selector[next] ?? "") ? 1 : 0);
|
|
3486
|
+
};
|
|
3487
|
+
var firstRootCombinator = (selector, start) => {
|
|
3488
|
+
let brackets = 0;
|
|
3489
|
+
let parentheses = 0;
|
|
3490
|
+
let quote;
|
|
3491
|
+
for (let index = start; index < selector.length; index++) {
|
|
3492
|
+
const character = selector[index];
|
|
3493
|
+
if (character === "\\") {
|
|
3494
|
+
index = skipCssEscape(selector, index) - 1;
|
|
3495
|
+
continue;
|
|
3496
|
+
}
|
|
3497
|
+
if (quote !== void 0) {
|
|
3498
|
+
if (character === quote) {
|
|
3499
|
+
quote = void 0;
|
|
3500
|
+
}
|
|
3501
|
+
continue;
|
|
3502
|
+
}
|
|
3503
|
+
if (selector.startsWith("/*", index)) {
|
|
3504
|
+
const commentEnd = selector.indexOf("*/", index + 2);
|
|
3505
|
+
if (commentEnd === -1) {
|
|
3506
|
+
return void 0;
|
|
3507
|
+
}
|
|
3508
|
+
index = commentEnd + 1;
|
|
3509
|
+
continue;
|
|
3510
|
+
}
|
|
3511
|
+
if (character === '"' || character === "'") {
|
|
3512
|
+
quote = character;
|
|
3513
|
+
continue;
|
|
3514
|
+
}
|
|
3515
|
+
if (character === "[") {
|
|
3516
|
+
brackets++;
|
|
3517
|
+
continue;
|
|
3518
|
+
}
|
|
3519
|
+
if (character === "]" && brackets > 0) {
|
|
3520
|
+
brackets--;
|
|
3521
|
+
continue;
|
|
3522
|
+
}
|
|
3523
|
+
if (character === "(") {
|
|
3524
|
+
parentheses++;
|
|
3525
|
+
continue;
|
|
3526
|
+
}
|
|
3527
|
+
if (character === ")" && parentheses > 0) {
|
|
3528
|
+
parentheses--;
|
|
3529
|
+
continue;
|
|
3530
|
+
}
|
|
3531
|
+
if (brackets > 0 || parentheses > 0) {
|
|
3532
|
+
continue;
|
|
3533
|
+
}
|
|
3534
|
+
if (character !== void 0 && "+~>".includes(character)) {
|
|
3535
|
+
return character;
|
|
3536
|
+
}
|
|
3537
|
+
if (character !== void 0 && /\s/.test(character)) {
|
|
3538
|
+
const next = selector.slice(index).replace(/^(?:\s+|\/\*[\s\S]*?\*\/)+/, "")[0];
|
|
3539
|
+
return next !== void 0 && "+~>".includes(next) ? next : " ";
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
return void 0;
|
|
3543
|
+
};
|
|
3544
|
+
var isPluginScoped = (selector, pluginName) => {
|
|
3545
|
+
const prefix = `.${pluginName}`;
|
|
3546
|
+
if (!selector.startsWith(prefix)) {
|
|
3547
|
+
return false;
|
|
3548
|
+
}
|
|
3549
|
+
const boundary = selector[prefix.length];
|
|
3550
|
+
if (boundary !== void 0 && !".#:[".includes(boundary) && !/\s/.test(boundary) && !"><+~".includes(boundary)) {
|
|
3551
|
+
return false;
|
|
3552
|
+
}
|
|
3553
|
+
const combinator = firstRootCombinator(selector, prefix.length);
|
|
3554
|
+
return combinator !== "+" && combinator !== "~";
|
|
3555
|
+
};
|
|
3556
|
+
function findUnscopedCssSelectors(css, pluginName, allowlist = []) {
|
|
3557
|
+
const ignored = new Set(allowlist);
|
|
3558
|
+
const violations = [];
|
|
3559
|
+
postcss.parse(css).walkRules((rule) => {
|
|
3560
|
+
if (hasKeyframesAncestor(rule)) {
|
|
3561
|
+
return;
|
|
3562
|
+
}
|
|
3563
|
+
for (const selector of rule.selectors) {
|
|
3564
|
+
if (!ignored.has(selector) && !isRootTokenSelector(selector) && !isPluginScoped(selector, pluginName)) {
|
|
3565
|
+
violations.push(selector);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
});
|
|
3569
|
+
return violations;
|
|
3570
|
+
}
|
|
3571
|
+
function validatePluginCss(pluginDir, pluginName) {
|
|
3572
|
+
const cssPath = join11(pluginDir, "dist", "index.css");
|
|
3573
|
+
if (!existsSync6(cssPath)) {
|
|
3574
|
+
return [];
|
|
3575
|
+
}
|
|
3576
|
+
const css = readFileSync10(cssPath, "utf8");
|
|
3577
|
+
const packageMetadata = readPluginPackage(pluginDir);
|
|
3578
|
+
const configuredAllowlist = packageMetadata?.mndw?.cssSelectorAllowlist;
|
|
3579
|
+
const allowlist = Array.isArray(configuredAllowlist) ? configuredAllowlist.filter((selector) => typeof selector === "string") : [];
|
|
3580
|
+
return findUnscopedCssSelectors(css, pluginName, allowlist).map((selector) => `CSS selector "${selector}" is not scoped under .${pluginName}`);
|
|
3581
|
+
}
|
|
3582
|
+
|
|
3301
3583
|
// src/pack.ts
|
|
3302
3584
|
import { createHash } from "node:crypto";
|
|
3303
3585
|
import {
|
|
3304
3586
|
chmodSync as chmodSync2,
|
|
3305
|
-
existsSync as
|
|
3587
|
+
existsSync as existsSync9,
|
|
3306
3588
|
mkdirSync as mkdirSync5,
|
|
3307
3589
|
mkdtempSync as mkdtempSync4,
|
|
3308
|
-
readFileSync as
|
|
3590
|
+
readFileSync as readFileSync11,
|
|
3309
3591
|
readdirSync as readdirSync5,
|
|
3310
3592
|
realpathSync,
|
|
3311
3593
|
rmSync as rmSync6,
|
|
3312
3594
|
statSync as statSync5,
|
|
3313
3595
|
writeFileSync as writeFileSync5
|
|
3314
3596
|
} from "node:fs";
|
|
3315
|
-
import { basename as basename2, dirname as dirname8, extname as extname3, isAbsolute as isAbsolute5, join as
|
|
3597
|
+
import { basename as basename2, dirname as dirname8, extname as extname3, isAbsolute as isAbsolute5, join as join13, relative as relative6, resolve as resolve17, sep as sep4 } from "node:path";
|
|
3316
3598
|
import crossSpawn4 from "cross-spawn";
|
|
3317
|
-
import { build } from "esbuild";
|
|
3599
|
+
import { build, transform } from "esbuild";
|
|
3318
3600
|
import esbuildSvelte from "esbuild-svelte";
|
|
3319
3601
|
import vuePlugin from "unplugin-vue/esbuild";
|
|
3320
|
-
|
|
3321
|
-
// src/svelte-warning-filter.ts
|
|
3322
|
-
var MNDW_BUTTON_A11Y_WARNING_CODES = /* @__PURE__ */ new Set([
|
|
3323
|
-
"a11y_click_events_have_key_events",
|
|
3324
|
-
"a11y_no_static_element_interactions"
|
|
3325
|
-
]);
|
|
3326
|
-
var isMndwButtonA11yWarning = (warning) => {
|
|
3327
|
-
return MNDW_BUTTON_A11Y_WARNING_CODES.has(warning.code ?? "") && (warning.message ?? "").includes("<mndw-button>");
|
|
3328
|
-
};
|
|
3602
|
+
import { mndwSvelteWarningFilter as mndwSvelteWarningFilter2 } from "@mndw/sdk/svelte";
|
|
3329
3603
|
|
|
3330
3604
|
// src/angular-compiler.ts
|
|
3331
3605
|
function compileAngular2(pluginDir, sourceEntry = "src/index.ts") {
|
|
@@ -3340,14 +3614,14 @@ function compileAngular2(pluginDir, sourceEntry = "src/index.ts") {
|
|
|
3340
3614
|
}
|
|
3341
3615
|
|
|
3342
3616
|
// src/cli-node-paths.ts
|
|
3343
|
-
import { existsSync as
|
|
3344
|
-
import { dirname as dirname7, join as
|
|
3617
|
+
import { existsSync as existsSync7, statSync as statSync4 } from "node:fs";
|
|
3618
|
+
import { dirname as dirname7, join as join12, resolve as resolve16 } from "node:path";
|
|
3345
3619
|
function cliNodePaths(root = cliPackageRoot()) {
|
|
3346
3620
|
const paths = [];
|
|
3347
3621
|
let directory = resolve16(root);
|
|
3348
3622
|
for (; ; ) {
|
|
3349
|
-
const modules =
|
|
3350
|
-
if (
|
|
3623
|
+
const modules = join12(directory, "node_modules");
|
|
3624
|
+
if (existsSync7(modules) && statSync4(modules).isDirectory()) {
|
|
3351
3625
|
paths.push(modules);
|
|
3352
3626
|
}
|
|
3353
3627
|
const parent = dirname7(directory);
|
|
@@ -3362,11 +3636,11 @@ function packNodePaths(pluginDir, cliRoot = cliPackageRoot()) {
|
|
|
3362
3636
|
}
|
|
3363
3637
|
|
|
3364
3638
|
// src/promote-directory.ts
|
|
3365
|
-
import { existsSync as
|
|
3639
|
+
import { existsSync as existsSync8, renameSync, rmSync as rmSync5 } from "node:fs";
|
|
3366
3640
|
function promoteDirectory(source, destination) {
|
|
3367
3641
|
const backup = `${destination}.previous`;
|
|
3368
|
-
const hadExisting =
|
|
3369
|
-
const hadBackup =
|
|
3642
|
+
const hadExisting = existsSync8(destination);
|
|
3643
|
+
const hadBackup = existsSync8(backup);
|
|
3370
3644
|
if (hadExisting && hadBackup) {
|
|
3371
3645
|
rmSync5(backup, { recursive: true, force: true });
|
|
3372
3646
|
}
|
|
@@ -3387,26 +3661,41 @@ function promoteDirectory(source, destination) {
|
|
|
3387
3661
|
}
|
|
3388
3662
|
|
|
3389
3663
|
// src/pack.ts
|
|
3664
|
+
async function sanitizeBundleOutput(contents, loader, production) {
|
|
3665
|
+
if (!production) {
|
|
3666
|
+
return Buffer.from(contents);
|
|
3667
|
+
}
|
|
3668
|
+
const source = Buffer.from(contents).toString("utf8");
|
|
3669
|
+
const result = loader === "js" ? await transform(source, {
|
|
3670
|
+
loader: "js",
|
|
3671
|
+
minify: true,
|
|
3672
|
+
legalComments: "inline",
|
|
3673
|
+
format: "esm",
|
|
3674
|
+
target: "es2022"
|
|
3675
|
+
}) : await transform(source, { loader: "css", minify: true, legalComments: "inline" });
|
|
3676
|
+
return Buffer.from(result.code);
|
|
3677
|
+
}
|
|
3390
3678
|
async function packPlugin(pluginDir, options = {}) {
|
|
3391
3679
|
const resolvedDir = resolvePluginDir(pluginDir);
|
|
3392
3680
|
const { manifest } = readManifest(pluginDir);
|
|
3393
3681
|
const warnings = validatePluginCatalogs(resolvedDir, manifest, { strict: false });
|
|
3394
3682
|
const sourceEntry = options.development ? resolveDevelopmentSourceEntry(resolvedDir) : resolveProductionSourceEntry(resolvedDir);
|
|
3395
3683
|
const framework = detectFramework(resolvedDir);
|
|
3396
|
-
const outDir = options.outDir === void 0 ?
|
|
3397
|
-
const defaultOutDir =
|
|
3684
|
+
const outDir = options.outDir === void 0 ? join13(resolvedDir, "dist") : resolve17(process.cwd(), options.outDir);
|
|
3685
|
+
const defaultOutDir = join13(resolvedDir, "dist");
|
|
3398
3686
|
if (outDir !== defaultOutDir && pathsOverlap(resolvedDir, outDir)) {
|
|
3399
3687
|
throw new CliError(`Output directory overlaps plugin source: ${outDir}`);
|
|
3400
3688
|
}
|
|
3401
3689
|
let angularCompile;
|
|
3402
|
-
const entryPoint = framework === "angular" ? (angularCompile = compileAngular2(resolvedDir, sourceEntry)).entryPath :
|
|
3690
|
+
const entryPoint = framework === "angular" ? (angularCompile = compileAngular2(resolvedDir, sourceEntry)).entryPath : join13(resolvedDir, sourceEntry);
|
|
3403
3691
|
try {
|
|
3404
|
-
const styleEntry = angularCompile === void 0 ? void 0 :
|
|
3405
|
-
const entryPoints = styleEntry !== void 0 &&
|
|
3692
|
+
const styleEntry = angularCompile === void 0 ? void 0 : join13(angularCompile.cacheDir, "styles.css");
|
|
3693
|
+
const entryPoints = styleEntry !== void 0 && existsSync9(styleEntry) ? [entryPoint, styleEntry] : [entryPoint];
|
|
3406
3694
|
const result = await build({
|
|
3407
3695
|
entryPoints,
|
|
3408
3696
|
outdir: outDir,
|
|
3409
3697
|
bundle: true,
|
|
3698
|
+
legalComments: "inline",
|
|
3410
3699
|
format: "esm",
|
|
3411
3700
|
platform: "browser",
|
|
3412
3701
|
target: "es2022",
|
|
@@ -3419,16 +3708,17 @@ async function packPlugin(pluginDir, options = {}) {
|
|
|
3419
3708
|
esbuildSvelte({
|
|
3420
3709
|
compilerOptions: {
|
|
3421
3710
|
css: "external",
|
|
3422
|
-
warningFilter:
|
|
3711
|
+
warningFilter: mndwSvelteWarningFilter2
|
|
3423
3712
|
}
|
|
3424
3713
|
})
|
|
3425
3714
|
] : framework === "vue" ? [vuePlugin({
|
|
3715
|
+
isProduction: !options.development,
|
|
3426
3716
|
sourceMap: false,
|
|
3427
3717
|
template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith("mndw-") } }
|
|
3428
3718
|
})] : []
|
|
3429
3719
|
});
|
|
3430
3720
|
const jsOutputs = result.outputFiles.filter((file) => file.path.endsWith(".js"));
|
|
3431
|
-
const jsOutput = jsOutputs.find((file) => file.path ===
|
|
3721
|
+
const jsOutput = jsOutputs.find((file) => file.path === join13(outDir, "index.js")) ?? jsOutputs[0];
|
|
3432
3722
|
if (jsOutput === void 0) {
|
|
3433
3723
|
throw new CliError("esbuild produced no JavaScript bundle");
|
|
3434
3724
|
}
|
|
@@ -3471,15 +3761,29 @@ async function packPlugin(pluginDir, options = {}) {
|
|
|
3471
3761
|
};
|
|
3472
3762
|
const catalogAssets = collectCatalogAssets(manifest, resolvedDir);
|
|
3473
3763
|
const workerReferences = collectWorkerReferences(manifest.entry, result.metafile);
|
|
3474
|
-
const workerAssets = await buildWorkerAssets(
|
|
3475
|
-
|
|
3764
|
+
const workerAssets = await buildWorkerAssets(
|
|
3765
|
+
workerReferences,
|
|
3766
|
+
outDir,
|
|
3767
|
+
resolvedDir,
|
|
3768
|
+
framework,
|
|
3769
|
+
!options.development
|
|
3770
|
+
);
|
|
3771
|
+
const mainBundle = await sanitizeBundleOutput(
|
|
3772
|
+
rewriteWorkerSpecifiers(jsOutput.contents, workerReferences),
|
|
3773
|
+
"js",
|
|
3774
|
+
!options.development
|
|
3775
|
+
);
|
|
3476
3776
|
const parent = dirname8(outDir);
|
|
3477
3777
|
mkdirSync5(parent, { recursive: true });
|
|
3478
|
-
const staging = mkdtempSync4(
|
|
3778
|
+
const staging = mkdtempSync4(join13(parent, ".mndw-pack-"));
|
|
3479
3779
|
try {
|
|
3480
3780
|
writeStaged(staging, manifest.entry, mainBundle);
|
|
3481
3781
|
if (cssOutput !== void 0) {
|
|
3482
|
-
writeStaged(
|
|
3782
|
+
writeStaged(
|
|
3783
|
+
staging,
|
|
3784
|
+
"index.css",
|
|
3785
|
+
await sanitizeBundleOutput(cssOutput.contents, "css", !options.development)
|
|
3786
|
+
);
|
|
3483
3787
|
}
|
|
3484
3788
|
writeStaged(staging, "manifest.json", Buffer.from(`${JSON.stringify(manifest, null, 2)}
|
|
3485
3789
|
`));
|
|
@@ -3496,7 +3800,7 @@ async function packPlugin(pluginDir, options = {}) {
|
|
|
3496
3800
|
if (isAbsolute5(rel) || rel === ".." || rel.startsWith(`..${sep4}`)) {
|
|
3497
3801
|
throw new CliError(`esbuild output escapes plugin directory: ${output.path}`);
|
|
3498
3802
|
}
|
|
3499
|
-
writeStaged(staging, rel,
|
|
3803
|
+
writeStaged(staging, rel, await sanitizeBundleOutput(output.contents, "js", !options.development));
|
|
3500
3804
|
}
|
|
3501
3805
|
}
|
|
3502
3806
|
for (const asset of workerAssets) {
|
|
@@ -3517,8 +3821,8 @@ async function packPlugin(pluginDir, options = {}) {
|
|
|
3517
3821
|
outDir,
|
|
3518
3822
|
framework,
|
|
3519
3823
|
manifest,
|
|
3520
|
-
manifestPath:
|
|
3521
|
-
entryPath:
|
|
3824
|
+
manifestPath: join13(outDir, "manifest.json"),
|
|
3825
|
+
entryPath: join13(outDir, manifest.entry),
|
|
3522
3826
|
warnings
|
|
3523
3827
|
};
|
|
3524
3828
|
} finally {
|
|
@@ -3549,21 +3853,21 @@ function collectWorkerReferences(manifestEntry, metafile) {
|
|
|
3549
3853
|
const outputOwners = /* @__PURE__ */ new Map();
|
|
3550
3854
|
for (const input of Object.keys(metafile.inputs)) {
|
|
3551
3855
|
const inputPath = resolve17(process.cwd(), input);
|
|
3552
|
-
if (!
|
|
3856
|
+
if (!existsSync9(inputPath)) {
|
|
3553
3857
|
continue;
|
|
3554
3858
|
}
|
|
3555
3859
|
const realInputPath = realpathSync(inputPath);
|
|
3556
|
-
const source =
|
|
3860
|
+
const source = readFileSync11(realInputPath, "utf8");
|
|
3557
3861
|
for (const match of source.matchAll(WORKER_URL_PATTERN)) {
|
|
3558
3862
|
const sourceSpecifier = match[2];
|
|
3559
3863
|
if (!sourceSpecifier?.endsWith(".worker.ts")) {
|
|
3560
3864
|
continue;
|
|
3561
3865
|
}
|
|
3562
3866
|
const sourcePath = resolve17(dirname8(realInputPath), sourceSpecifier);
|
|
3563
|
-
if (!
|
|
3867
|
+
if (!existsSync9(sourcePath)) {
|
|
3564
3868
|
throw new CliError(`Missing worker source: ${sourcePath}`);
|
|
3565
3869
|
}
|
|
3566
|
-
const outputRel =
|
|
3870
|
+
const outputRel = join13(dirname8(manifestEntry), `${basename2(sourcePath, extname3(sourcePath))}.js`);
|
|
3567
3871
|
const previousOwner = outputOwners.get(outputRel);
|
|
3568
3872
|
if (previousOwner !== void 0 && previousOwner !== sourcePath) {
|
|
3569
3873
|
throw new CliError(`Worker output path collision: ${outputRel}`);
|
|
@@ -3583,7 +3887,7 @@ function collectWorkerReferences(manifestEntry, metafile) {
|
|
|
3583
3887
|
}
|
|
3584
3888
|
return references;
|
|
3585
3889
|
}
|
|
3586
|
-
async function buildWorkerAssets(references, outDir, pluginDir, framework) {
|
|
3890
|
+
async function buildWorkerAssets(references, outDir, pluginDir, framework, production) {
|
|
3587
3891
|
const assets = [];
|
|
3588
3892
|
const built = /* @__PURE__ */ new Set();
|
|
3589
3893
|
for (const reference of references) {
|
|
@@ -3606,7 +3910,10 @@ async function buildWorkerAssets(references, outDir, pluginDir, framework) {
|
|
|
3606
3910
|
if (output === void 0) {
|
|
3607
3911
|
throw new CliError(`esbuild produced no JavaScript bundle for worker: ${reference.sourcePath}`);
|
|
3608
3912
|
}
|
|
3609
|
-
assets.push({
|
|
3913
|
+
assets.push({
|
|
3914
|
+
rel: reference.outputRel,
|
|
3915
|
+
contents: await sanitizeBundleOutput(output.contents, "js", production)
|
|
3916
|
+
});
|
|
3610
3917
|
built.add(reference.outputRel);
|
|
3611
3918
|
}
|
|
3612
3919
|
return assets;
|
|
@@ -3641,13 +3948,13 @@ function collectBackendOverrideAssets(manifest, pluginDir, override, auxiliaryAs
|
|
|
3641
3948
|
}
|
|
3642
3949
|
const source = resolve17(file.source);
|
|
3643
3950
|
const sourceRelative = relative6(sourceRoot, source);
|
|
3644
|
-
if (sourceRelative.startsWith("..") || isAbsolute5(sourceRelative) || !
|
|
3951
|
+
if (sourceRelative.startsWith("..") || isAbsolute5(sourceRelative) || !existsSync9(source) || !statSync5(source).isFile()) {
|
|
3645
3952
|
throw new CliError(`Target backend source is outside its build output: ${source}`);
|
|
3646
3953
|
}
|
|
3647
3954
|
destinations.add(file.destination);
|
|
3648
3955
|
return {
|
|
3649
3956
|
rel: file.destination,
|
|
3650
|
-
contents:
|
|
3957
|
+
contents: readFileSync11(source),
|
|
3651
3958
|
mode: file.mode ?? 493
|
|
3652
3959
|
};
|
|
3653
3960
|
});
|
|
@@ -3672,7 +3979,7 @@ function collectSourceBackendAsset(rel, pluginDir, declaredBy) {
|
|
|
3672
3979
|
if (!stat.isFile()) {
|
|
3673
3980
|
throw new CliError(`Backend asset is not a regular file: ${source}`);
|
|
3674
3981
|
}
|
|
3675
|
-
return { rel, contents:
|
|
3982
|
+
return { rel, contents: readFileSync11(source), mode: 493 };
|
|
3676
3983
|
} catch (error) {
|
|
3677
3984
|
if (error instanceof CliError) {
|
|
3678
3985
|
throw error;
|
|
@@ -3691,7 +3998,7 @@ function collectCatalogAssets(manifest, pluginDir) {
|
|
|
3691
3998
|
if (!stat.isFile()) {
|
|
3692
3999
|
throw new CliError(`Catalog is not a regular file: ${source}`);
|
|
3693
4000
|
}
|
|
3694
|
-
return { rel, contents:
|
|
4001
|
+
return { rel, contents: readFileSync11(source) };
|
|
3695
4002
|
} catch (error) {
|
|
3696
4003
|
if (error instanceof CliError) {
|
|
3697
4004
|
throw error;
|
|
@@ -3721,14 +4028,14 @@ function pathsOverlap(first, second) {
|
|
|
3721
4028
|
}
|
|
3722
4029
|
|
|
3723
4030
|
// src/backend-build-run.ts
|
|
3724
|
-
import { readFileSync as
|
|
3725
|
-
import { isAbsolute as isAbsolute6, join as
|
|
4031
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
4032
|
+
import { isAbsolute as isAbsolute6, join as join14, resolve as resolve18 } from "node:path";
|
|
3726
4033
|
function nonEmptyString2(value) {
|
|
3727
4034
|
return typeof value === "string" && value.length > 0;
|
|
3728
4035
|
}
|
|
3729
4036
|
function readJson(path3, label) {
|
|
3730
4037
|
try {
|
|
3731
|
-
return JSON.parse(
|
|
4038
|
+
return JSON.parse(readFileSync12(path3, "utf8"));
|
|
3732
4039
|
} catch (error) {
|
|
3733
4040
|
throw new CliError(`failed to read ${label} at ${path3}: ${error.message}`);
|
|
3734
4041
|
}
|
|
@@ -3778,8 +4085,8 @@ function isSafeEntryPackage(value) {
|
|
|
3778
4085
|
}
|
|
3779
4086
|
function readBackendBuildConfig(pluginDir) {
|
|
3780
4087
|
const dir = resolve18(pluginDir);
|
|
3781
|
-
const manifestValue = readJson(
|
|
3782
|
-
const packageValue = readJson(
|
|
4088
|
+
const manifestValue = readJson(join14(dir, "manifest.json"), "manifest.json");
|
|
4089
|
+
const packageValue = readJson(join14(dir, "package.json"), "package.json");
|
|
3783
4090
|
if (!isRecord4(manifestValue)) {
|
|
3784
4091
|
throw new CliError(`manifest.json in ${dir} must contain a JSON object`);
|
|
3785
4092
|
}
|
|
@@ -3814,7 +4121,7 @@ function runBuildBackendCommand(options) {
|
|
|
3814
4121
|
const config = readBackendBuildConfig(options.pluginDir);
|
|
3815
4122
|
buildGoBackend({
|
|
3816
4123
|
plugin: config.plugin,
|
|
3817
|
-
backendDir:
|
|
4124
|
+
backendDir: join14(resolve18(options.pluginDir), "backend"),
|
|
3818
4125
|
binaryName: config.binaryName,
|
|
3819
4126
|
entryPackage: config.entryPackage,
|
|
3820
4127
|
target: productTarget,
|
|
@@ -3824,8 +4131,8 @@ function runBuildBackendCommand(options) {
|
|
|
3824
4131
|
}
|
|
3825
4132
|
|
|
3826
4133
|
// src/zip.ts
|
|
3827
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
3828
|
-
import { dirname as dirname9, join as
|
|
4134
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync13, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
4135
|
+
import { dirname as dirname9, join as join15, resolve as resolve19 } from "node:path";
|
|
3829
4136
|
import { zipSync } from "fflate";
|
|
3830
4137
|
function backendCommandPaths(manifest) {
|
|
3831
4138
|
const backend = manifest.backend;
|
|
@@ -3844,12 +4151,12 @@ function collectFiles(dir) {
|
|
|
3844
4151
|
if (entry.name.startsWith(".")) {
|
|
3845
4152
|
continue;
|
|
3846
4153
|
}
|
|
3847
|
-
const absolute =
|
|
4154
|
+
const absolute = join15(current, entry.name);
|
|
3848
4155
|
const relative7 = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
3849
4156
|
if (entry.isDirectory()) {
|
|
3850
4157
|
walk2(absolute, relative7);
|
|
3851
4158
|
} else if (entry.isFile()) {
|
|
3852
|
-
files[relative7] =
|
|
4159
|
+
files[relative7] = readFileSync13(absolute);
|
|
3853
4160
|
}
|
|
3854
4161
|
}
|
|
3855
4162
|
};
|
|
@@ -3868,7 +4175,7 @@ async function zipPlugin(pluginDir, options = {}) {
|
|
|
3868
4175
|
const { output, ...packOptions } = options;
|
|
3869
4176
|
const pack = await packPlugin(pluginDir, packOptions);
|
|
3870
4177
|
const archive = zipDirectory(pack.outDir, backendCommandPaths(pack.manifest));
|
|
3871
|
-
const outputPath = output === void 0 ?
|
|
4178
|
+
const outputPath = output === void 0 ? join15(resolvePluginDir(pluginDir), `${pack.manifest.name}.zip`) : resolve19(process.cwd(), output);
|
|
3872
4179
|
mkdirSync6(dirname9(outputPath), { recursive: true });
|
|
3873
4180
|
writeFileSync6(outputPath, archive);
|
|
3874
4181
|
return { outputPath, pack };
|
|
@@ -3924,6 +4231,7 @@ function createProgram() {
|
|
|
3924
4231
|
}
|
|
3925
4232
|
const warnings = [
|
|
3926
4233
|
...result.warnings,
|
|
4234
|
+
...validatePluginCss(resolvePluginDir(pluginDir), result.manifest.name),
|
|
3927
4235
|
...validatePluginCatalogs(resolvePluginDir(pluginDir), result.manifest, {
|
|
3928
4236
|
strict: options.strict === true
|
|
3929
4237
|
})
|
|
@@ -3963,10 +4271,15 @@ function createProgram() {
|
|
|
3963
4271
|
process.stdout.write(`Zipped ${result.pack.manifest.name} \u2192 ${result.outputPath}
|
|
3964
4272
|
`);
|
|
3965
4273
|
});
|
|
3966
|
-
program.command("build-backend").description(
|
|
3967
|
-
"build
|
|
3968
|
-
).allowUnknownOption().allowExcessArguments().action((_options, command) => {
|
|
3969
|
-
|
|
4274
|
+
program.command("build-backend [plugin-dir]").description(
|
|
4275
|
+
"build a plugin's Go backend (defaults to current directory; name from manifest.json, binary/entry from package.json mndw.backend)"
|
|
4276
|
+
).allowUnknownOption().allowExcessArguments().action((_pluginDir, _options, command) => {
|
|
4277
|
+
const firstArg = command.args[0];
|
|
4278
|
+
const hasPluginDir = firstArg !== void 0 && !firstArg.startsWith("-");
|
|
4279
|
+
runBuildBackendCommand({
|
|
4280
|
+
pluginDir: resolve20(process.cwd(), hasPluginDir ? firstArg : "."),
|
|
4281
|
+
args: hasPluginDir ? command.args.slice(1) : command.args
|
|
4282
|
+
});
|
|
3970
4283
|
});
|
|
3971
4284
|
return program;
|
|
3972
4285
|
}
|