@swarm.ing/pieui 2.0.22 → 2.0.23
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/cli.js +893 -400
- package/dist/code/args.d.ts +3 -1
- package/dist/code/args.d.ts.map +1 -1
- package/dist/code/commands/add.d.ts.map +1 -1
- package/dist/code/commands/addEvent.d.ts.map +1 -1
- package/dist/code/commands/cardPull.d.ts +2 -0
- package/dist/code/commands/cardPull.d.ts.map +1 -0
- package/dist/code/commands/cardView.d.ts +2 -0
- package/dist/code/commands/cardView.d.ts.map +1 -0
- package/dist/code/commands/create.d.ts +1 -1
- package/dist/code/commands/create.d.ts.map +1 -1
- package/dist/code/commands/init.d.ts +1 -1
- package/dist/code/commands/init.d.ts.map +1 -1
- package/dist/code/commands/list.d.ts.map +1 -1
- package/dist/code/commands/pageAdd.d.ts.map +1 -1
- package/dist/code/commands/pageAjax.d.ts +3 -0
- package/dist/code/commands/pageAjax.d.ts.map +1 -0
- package/dist/code/commands/pageView.d.ts +2 -0
- package/dist/code/commands/pageView.d.ts.map +1 -0
- package/dist/code/scan.d.ts.map +1 -1
- package/dist/code/types.d.ts +7 -3
- package/dist/code/types.d.ts.map +1 -1
- package/dist/components/PieCard/index.d.ts +1 -1
- package/dist/components/PieCard/index.d.ts.map +1 -1
- package/dist/components/PieCard/types/index.d.ts +6 -0
- package/dist/components/PieCard/types/index.d.ts.map +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -883,9 +883,9 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s))
|
|
|
883
883
|
Wt2.LRUCache = undefined;
|
|
884
884
|
var er = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, as2 = new Set, ge2 = typeof process == "object" && process ? process : {}, ls2 = (n7, t, e, s) => {
|
|
885
885
|
typeof ge2.emitWarning == "function" ? ge2.emitWarning(n7, t, e, s) : console.error(`[${e}] ${t}: ${n7}`);
|
|
886
|
-
}, Lt2 = globalThis.AbortController,
|
|
886
|
+
}, Lt2 = globalThis.AbortController, os3 = globalThis.AbortSignal;
|
|
887
887
|
if (typeof Lt2 > "u") {
|
|
888
|
-
|
|
888
|
+
os3 = class {
|
|
889
889
|
onabort;
|
|
890
890
|
_onabort = [];
|
|
891
891
|
reason;
|
|
@@ -897,7 +897,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s))
|
|
|
897
897
|
constructor() {
|
|
898
898
|
t();
|
|
899
899
|
}
|
|
900
|
-
signal = new
|
|
900
|
+
signal = new os3;
|
|
901
901
|
abort(e) {
|
|
902
902
|
if (!this.signal.aborted) {
|
|
903
903
|
this.signal.reason = e, this.signal.aborted = true;
|
|
@@ -172964,7 +172964,7 @@ var require_v8_compile_cache = __commonJS((exports2, module2) => {
|
|
|
172964
172964
|
var fs6 = require("fs");
|
|
172965
172965
|
var path5 = require("path");
|
|
172966
172966
|
var vm = require("vm");
|
|
172967
|
-
var
|
|
172967
|
+
var os3 = require("os");
|
|
172968
172968
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
172969
172969
|
|
|
172970
172970
|
class FileSystemBlobStore {
|
|
@@ -173208,7 +173208,7 @@ var require_v8_compile_cache = __commonJS((exports2, module2) => {
|
|
|
173208
173208
|
}
|
|
173209
173209
|
const dirname = typeof process.getuid === "function" ? "v8-compile-cache-" + process.getuid() : "v8-compile-cache";
|
|
173210
173210
|
const version = typeof process.versions.v8 === "string" ? process.versions.v8 : typeof process.versions.chakracore === "string" ? "chakracore-" + process.versions.chakracore : "node-" + process.version;
|
|
173211
|
-
const cacheDir = path5.join(
|
|
173211
|
+
const cacheDir = path5.join(os3.tmpdir(), dirname, version);
|
|
173212
173212
|
return cacheDir;
|
|
173213
173213
|
}
|
|
173214
173214
|
function getMainName() {
|
|
@@ -188195,10 +188195,125 @@ var require_typescript_json_schema = __commonJS((exports2) => {
|
|
|
188195
188195
|
}
|
|
188196
188196
|
});
|
|
188197
188197
|
|
|
188198
|
+
// src/cli.ts
|
|
188199
|
+
var import_node_path9 = __toESM(require("node:path"));
|
|
188200
|
+
|
|
188198
188201
|
// src/code/args.ts
|
|
188202
|
+
var VALID_CARD_ACTIONS = [
|
|
188203
|
+
"add",
|
|
188204
|
+
"list",
|
|
188205
|
+
"pull",
|
|
188206
|
+
"view",
|
|
188207
|
+
"remove",
|
|
188208
|
+
"list-events",
|
|
188209
|
+
"add-event",
|
|
188210
|
+
"remote"
|
|
188211
|
+
];
|
|
188212
|
+
var VALID_CARD_REMOTE_ACTIONS = [
|
|
188213
|
+
"push",
|
|
188214
|
+
"pull",
|
|
188215
|
+
"list",
|
|
188216
|
+
"remove",
|
|
188217
|
+
"history",
|
|
188218
|
+
"public",
|
|
188219
|
+
"private"
|
|
188220
|
+
];
|
|
188221
|
+
var VALID_PAGE_ACTIONS = ["add", "view", "ajax"];
|
|
188222
|
+
var VALID_PAGE_AJAX_ACTIONS = ["add", "remove"];
|
|
188223
|
+
var VALID_COMPONENT_TYPES = [
|
|
188224
|
+
"simple",
|
|
188225
|
+
"complex",
|
|
188226
|
+
"simple-container",
|
|
188227
|
+
"complex-container"
|
|
188228
|
+
];
|
|
188229
|
+
var VALID_LIST_FILTERS = [
|
|
188230
|
+
"all",
|
|
188231
|
+
"simple",
|
|
188232
|
+
"complex",
|
|
188233
|
+
"simple-container",
|
|
188234
|
+
"complex-container"
|
|
188235
|
+
];
|
|
188236
|
+
var parseIntFlag = (name, raw) => {
|
|
188237
|
+
if (!/^-?\d+$/.test(raw)) {
|
|
188238
|
+
throw new Error(`${name} must be an integer, got ${JSON.stringify(raw)}`);
|
|
188239
|
+
}
|
|
188240
|
+
return Number(raw);
|
|
188241
|
+
};
|
|
188242
|
+
var consumeFlags = (tokens) => {
|
|
188243
|
+
const flags = {};
|
|
188244
|
+
const positionals = [];
|
|
188245
|
+
let ajax = false;
|
|
188246
|
+
let io = false;
|
|
188247
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
188248
|
+
const tok = tokens[i];
|
|
188249
|
+
if (tok === "--ajax") {
|
|
188250
|
+
ajax = true;
|
|
188251
|
+
continue;
|
|
188252
|
+
}
|
|
188253
|
+
if (tok === "--io") {
|
|
188254
|
+
io = true;
|
|
188255
|
+
continue;
|
|
188256
|
+
}
|
|
188257
|
+
if (tok === "--user" && tokens[i + 1]) {
|
|
188258
|
+
flags.remoteUserId = tokens[i + 1];
|
|
188259
|
+
i++;
|
|
188260
|
+
continue;
|
|
188261
|
+
}
|
|
188262
|
+
if (tok === "--project" && tokens[i + 1]) {
|
|
188263
|
+
flags.remoteProject = tokens[i + 1];
|
|
188264
|
+
i++;
|
|
188265
|
+
continue;
|
|
188266
|
+
}
|
|
188267
|
+
if (tok === "--page" && tokens[i + 1]) {
|
|
188268
|
+
flags.historyPage = parseIntFlag("--page", tokens[i + 1]);
|
|
188269
|
+
i++;
|
|
188270
|
+
continue;
|
|
188271
|
+
}
|
|
188272
|
+
if (tok === "--per-page" && tokens[i + 1]) {
|
|
188273
|
+
flags.historyPerPage = parseIntFlag("--per-page", tokens[i + 1]);
|
|
188274
|
+
i++;
|
|
188275
|
+
continue;
|
|
188276
|
+
}
|
|
188277
|
+
if (tok === "--from" && tokens[i + 1]) {
|
|
188278
|
+
flags.historyFrom = parseIntFlag("--from", tokens[i + 1]);
|
|
188279
|
+
i++;
|
|
188280
|
+
continue;
|
|
188281
|
+
}
|
|
188282
|
+
if (tok === "--to" && tokens[i + 1]) {
|
|
188283
|
+
flags.historyTo = parseIntFlag("--to", tokens[i + 1]);
|
|
188284
|
+
i++;
|
|
188285
|
+
continue;
|
|
188286
|
+
}
|
|
188287
|
+
if (tok.startsWith("--user=")) {
|
|
188288
|
+
flags.remoteUserId = tok.slice("--user=".length);
|
|
188289
|
+
continue;
|
|
188290
|
+
}
|
|
188291
|
+
if (tok.startsWith("--project=")) {
|
|
188292
|
+
flags.remoteProject = tok.slice("--project=".length);
|
|
188293
|
+
continue;
|
|
188294
|
+
}
|
|
188295
|
+
if (tok.startsWith("--page=")) {
|
|
188296
|
+
flags.historyPage = parseIntFlag("--page", tok.slice("--page=".length));
|
|
188297
|
+
continue;
|
|
188298
|
+
}
|
|
188299
|
+
if (tok.startsWith("--per-page=")) {
|
|
188300
|
+
flags.historyPerPage = parseIntFlag("--per-page", tok.slice("--per-page=".length));
|
|
188301
|
+
continue;
|
|
188302
|
+
}
|
|
188303
|
+
if (tok.startsWith("--from=")) {
|
|
188304
|
+
flags.historyFrom = parseIntFlag("--from", tok.slice("--from=".length));
|
|
188305
|
+
continue;
|
|
188306
|
+
}
|
|
188307
|
+
if (tok.startsWith("--to=")) {
|
|
188308
|
+
flags.historyTo = parseIntFlag("--to", tok.slice("--to=".length));
|
|
188309
|
+
continue;
|
|
188310
|
+
}
|
|
188311
|
+
positionals.push(tok);
|
|
188312
|
+
}
|
|
188313
|
+
return { positionals, flags, boolFlags: { ajax, io } };
|
|
188314
|
+
};
|
|
188199
188315
|
var parseArgs = (argv) => {
|
|
188200
188316
|
const [command = ""] = argv;
|
|
188201
|
-
const cardFlagSet = new Set(["--io", "--ajax"]);
|
|
188202
188317
|
const outDirFlag = argv.find((arg) => arg.startsWith("--out-dir="));
|
|
188203
188318
|
const srcDirFlag = argv.find((arg) => arg.startsWith("--src-dir="));
|
|
188204
188319
|
const outDirIndex = argv.findIndex((arg) => arg === "--out-dir" || arg === "-o");
|
|
@@ -188206,159 +188321,6 @@ var parseArgs = (argv) => {
|
|
|
188206
188321
|
const appendFlag = argv.includes("--append");
|
|
188207
188322
|
let outDir = command === "postbuild" ? "public" : ".";
|
|
188208
188323
|
let srcDir = ".";
|
|
188209
|
-
let componentType;
|
|
188210
|
-
let componentName;
|
|
188211
|
-
let createAppName;
|
|
188212
|
-
let eventName;
|
|
188213
|
-
let cardAction;
|
|
188214
|
-
let cardAjax = false;
|
|
188215
|
-
let cardIo = false;
|
|
188216
|
-
let cardRemoteAction;
|
|
188217
|
-
let remoteUserId;
|
|
188218
|
-
let remoteProject;
|
|
188219
|
-
let pageAction;
|
|
188220
|
-
let pagePath;
|
|
188221
|
-
let removeComponentName;
|
|
188222
|
-
let listFilter;
|
|
188223
|
-
if (command === "remove" && argv[1]) {
|
|
188224
|
-
removeComponentName = argv[1];
|
|
188225
|
-
}
|
|
188226
|
-
if ((command === "create-pie-app" || command === "create-pieui" || command === "create") && argv[1]) {
|
|
188227
|
-
createAppName = argv[1];
|
|
188228
|
-
}
|
|
188229
|
-
if (command === "list") {
|
|
188230
|
-
const validFilters = [
|
|
188231
|
-
"all",
|
|
188232
|
-
"simple",
|
|
188233
|
-
"complex",
|
|
188234
|
-
"simple-container",
|
|
188235
|
-
"complex-container"
|
|
188236
|
-
];
|
|
188237
|
-
const filterArg = argv[1];
|
|
188238
|
-
listFilter = filterArg && validFilters.includes(filterArg) ? filterArg : "all";
|
|
188239
|
-
}
|
|
188240
|
-
if (command === "card" && argv[1]) {
|
|
188241
|
-
const validActions = ["add", "remote"];
|
|
188242
|
-
if (validActions.includes(argv[1])) {
|
|
188243
|
-
cardAction = argv[1];
|
|
188244
|
-
}
|
|
188245
|
-
}
|
|
188246
|
-
if ((command === "card" && cardAction === "add" || command === "add") && argv[1]) {
|
|
188247
|
-
const offset = command === "card" ? 2 : 1;
|
|
188248
|
-
const cardArgv = argv.slice(offset);
|
|
188249
|
-
const positionalArgs = cardArgv.filter((arg) => !cardFlagSet.has(arg));
|
|
188250
|
-
cardIo = cardArgv.includes("--io");
|
|
188251
|
-
cardAjax = cardArgv.includes("--ajax");
|
|
188252
|
-
const validTypes = [
|
|
188253
|
-
"simple",
|
|
188254
|
-
"complex",
|
|
188255
|
-
"simple-container",
|
|
188256
|
-
"complex-container"
|
|
188257
|
-
];
|
|
188258
|
-
if (validTypes.includes(positionalArgs[0])) {
|
|
188259
|
-
componentType = positionalArgs[0];
|
|
188260
|
-
componentName = positionalArgs[1];
|
|
188261
|
-
} else {
|
|
188262
|
-
componentType = "complex-container";
|
|
188263
|
-
componentName = positionalArgs[0];
|
|
188264
|
-
}
|
|
188265
|
-
}
|
|
188266
|
-
let historyPage;
|
|
188267
|
-
let historyPerPage;
|
|
188268
|
-
let historyFrom;
|
|
188269
|
-
let historyTo;
|
|
188270
|
-
if (command === "card" && cardAction === "remote" && argv[2]) {
|
|
188271
|
-
const validRemoteActions = [
|
|
188272
|
-
"push",
|
|
188273
|
-
"pull",
|
|
188274
|
-
"list",
|
|
188275
|
-
"remove",
|
|
188276
|
-
"history",
|
|
188277
|
-
"public",
|
|
188278
|
-
"private"
|
|
188279
|
-
];
|
|
188280
|
-
const action = argv[2];
|
|
188281
|
-
if (validRemoteActions.includes(action)) {
|
|
188282
|
-
cardRemoteAction = action;
|
|
188283
|
-
const rest = argv.slice(3);
|
|
188284
|
-
const flagIndexes = new Set;
|
|
188285
|
-
const parseIntFlag = (name, raw) => {
|
|
188286
|
-
if (!/^-?\d+$/.test(raw)) {
|
|
188287
|
-
throw new Error(`${name} must be an integer, got ${JSON.stringify(raw)}`);
|
|
188288
|
-
}
|
|
188289
|
-
return Number(raw);
|
|
188290
|
-
};
|
|
188291
|
-
for (let i = 0;i < rest.length; i++) {
|
|
188292
|
-
const tok = rest[i];
|
|
188293
|
-
if (tok === "--user" && rest[i + 1]) {
|
|
188294
|
-
remoteUserId = rest[i + 1];
|
|
188295
|
-
flagIndexes.add(i);
|
|
188296
|
-
flagIndexes.add(i + 1);
|
|
188297
|
-
i++;
|
|
188298
|
-
} else if (tok === "--project" && rest[i + 1]) {
|
|
188299
|
-
remoteProject = rest[i + 1];
|
|
188300
|
-
flagIndexes.add(i);
|
|
188301
|
-
flagIndexes.add(i + 1);
|
|
188302
|
-
i++;
|
|
188303
|
-
} else if (tok === "--page" && rest[i + 1]) {
|
|
188304
|
-
historyPage = parseIntFlag("--page", rest[i + 1]);
|
|
188305
|
-
flagIndexes.add(i);
|
|
188306
|
-
flagIndexes.add(i + 1);
|
|
188307
|
-
i++;
|
|
188308
|
-
} else if (tok === "--per-page" && rest[i + 1]) {
|
|
188309
|
-
historyPerPage = parseIntFlag("--per-page", rest[i + 1]);
|
|
188310
|
-
flagIndexes.add(i);
|
|
188311
|
-
flagIndexes.add(i + 1);
|
|
188312
|
-
i++;
|
|
188313
|
-
} else if (tok === "--from" && rest[i + 1]) {
|
|
188314
|
-
historyFrom = parseIntFlag("--from", rest[i + 1]);
|
|
188315
|
-
flagIndexes.add(i);
|
|
188316
|
-
flagIndexes.add(i + 1);
|
|
188317
|
-
i++;
|
|
188318
|
-
} else if (tok === "--to" && rest[i + 1]) {
|
|
188319
|
-
historyTo = parseIntFlag("--to", rest[i + 1]);
|
|
188320
|
-
flagIndexes.add(i);
|
|
188321
|
-
flagIndexes.add(i + 1);
|
|
188322
|
-
i++;
|
|
188323
|
-
} else if (tok?.startsWith("--user=")) {
|
|
188324
|
-
remoteUserId = tok.slice("--user=".length);
|
|
188325
|
-
flagIndexes.add(i);
|
|
188326
|
-
} else if (tok?.startsWith("--project=")) {
|
|
188327
|
-
remoteProject = tok.slice("--project=".length);
|
|
188328
|
-
flagIndexes.add(i);
|
|
188329
|
-
} else if (tok?.startsWith("--page=")) {
|
|
188330
|
-
historyPage = parseIntFlag("--page", tok.slice("--page=".length));
|
|
188331
|
-
flagIndexes.add(i);
|
|
188332
|
-
} else if (tok?.startsWith("--per-page=")) {
|
|
188333
|
-
historyPerPage = parseIntFlag("--per-page", tok.slice("--per-page=".length));
|
|
188334
|
-
flagIndexes.add(i);
|
|
188335
|
-
} else if (tok?.startsWith("--from=")) {
|
|
188336
|
-
historyFrom = parseIntFlag("--from", tok.slice("--from=".length));
|
|
188337
|
-
flagIndexes.add(i);
|
|
188338
|
-
} else if (tok?.startsWith("--to=")) {
|
|
188339
|
-
historyTo = parseIntFlag("--to", tok.slice("--to=".length));
|
|
188340
|
-
flagIndexes.add(i);
|
|
188341
|
-
}
|
|
188342
|
-
}
|
|
188343
|
-
const positionals = rest.filter((_, i) => !flagIndexes.has(i));
|
|
188344
|
-
if (positionals[0])
|
|
188345
|
-
componentName = positionals[0];
|
|
188346
|
-
}
|
|
188347
|
-
}
|
|
188348
|
-
if (command === "page" && argv[1]) {
|
|
188349
|
-
const validActions = ["add"];
|
|
188350
|
-
if (validActions.includes(argv[1])) {
|
|
188351
|
-
pageAction = argv[1];
|
|
188352
|
-
pagePath = argv[2];
|
|
188353
|
-
}
|
|
188354
|
-
}
|
|
188355
|
-
if (command === "list-events" && argv[1]) {
|
|
188356
|
-
componentName = argv[1];
|
|
188357
|
-
}
|
|
188358
|
-
if (command === "add-event" && argv[1] && argv[2]) {
|
|
188359
|
-
componentName = argv[1];
|
|
188360
|
-
eventName = argv[2];
|
|
188361
|
-
}
|
|
188362
188324
|
if (outDirFlag) {
|
|
188363
188325
|
outDir = outDirFlag.split("=")[1] || outDir;
|
|
188364
188326
|
} else if (outDirIndex !== -1 && argv[outDirIndex + 1]) {
|
|
@@ -188369,127 +188331,300 @@ var parseArgs = (argv) => {
|
|
|
188369
188331
|
} else if (srcDirIndex !== -1 && argv[srcDirIndex + 1]) {
|
|
188370
188332
|
srcDir = argv[srcDirIndex + 1];
|
|
188371
188333
|
}
|
|
188372
|
-
|
|
188334
|
+
const result = {
|
|
188373
188335
|
command,
|
|
188374
188336
|
outDir,
|
|
188375
188337
|
srcDir,
|
|
188376
|
-
append: appendFlag
|
|
188377
|
-
componentName,
|
|
188378
|
-
createAppName,
|
|
188379
|
-
componentType,
|
|
188380
|
-
eventName,
|
|
188381
|
-
removeComponentName,
|
|
188382
|
-
listFilter,
|
|
188383
|
-
cardAction,
|
|
188384
|
-
cardAjax,
|
|
188385
|
-
cardIo,
|
|
188386
|
-
cardRemoteAction,
|
|
188387
|
-
remoteUserId,
|
|
188388
|
-
remoteProject,
|
|
188389
|
-
pageAction,
|
|
188390
|
-
pagePath,
|
|
188391
|
-
historyPage,
|
|
188392
|
-
historyPerPage,
|
|
188393
|
-
historyFrom,
|
|
188394
|
-
historyTo
|
|
188338
|
+
append: appendFlag
|
|
188395
188339
|
};
|
|
188340
|
+
if ((command === "create-pie-app" || command === "create-pieui" || command === "create") && argv[1]) {
|
|
188341
|
+
result.createAppName = argv[1];
|
|
188342
|
+
}
|
|
188343
|
+
if (command === "card" && argv[1]) {
|
|
188344
|
+
const action = argv[1];
|
|
188345
|
+
if (!VALID_CARD_ACTIONS.includes(action)) {
|
|
188346
|
+
return result;
|
|
188347
|
+
}
|
|
188348
|
+
result.cardAction = action;
|
|
188349
|
+
const tail = argv.slice(2);
|
|
188350
|
+
const { positionals, flags, boolFlags } = consumeFlags(tail);
|
|
188351
|
+
if (action === "add") {
|
|
188352
|
+
result.cardAjax = boolFlags.ajax;
|
|
188353
|
+
result.cardIo = boolFlags.io;
|
|
188354
|
+
if (positionals[0] && VALID_COMPONENT_TYPES.includes(positionals[0])) {
|
|
188355
|
+
result.componentType = positionals[0];
|
|
188356
|
+
result.componentName = positionals[1];
|
|
188357
|
+
} else {
|
|
188358
|
+
result.componentType = "complex-container";
|
|
188359
|
+
result.componentName = positionals[0];
|
|
188360
|
+
}
|
|
188361
|
+
} else if (action === "list") {
|
|
188362
|
+
const filter = positionals[0];
|
|
188363
|
+
result.listFilter = filter && VALID_LIST_FILTERS.includes(filter) ? filter : "all";
|
|
188364
|
+
} else if (action === "pull") {
|
|
188365
|
+
result.cardPullRef = positionals[0];
|
|
188366
|
+
} else if (action === "view") {
|
|
188367
|
+
result.componentName = positionals[0];
|
|
188368
|
+
} else if (action === "remove") {
|
|
188369
|
+
result.componentName = positionals[0];
|
|
188370
|
+
} else if (action === "list-events") {
|
|
188371
|
+
result.componentName = positionals[0];
|
|
188372
|
+
} else if (action === "add-event") {
|
|
188373
|
+
result.componentName = positionals[0];
|
|
188374
|
+
result.eventName = positionals[1];
|
|
188375
|
+
} else if (action === "remote") {
|
|
188376
|
+
const sub = positionals[0];
|
|
188377
|
+
if (sub && VALID_CARD_REMOTE_ACTIONS.includes(sub)) {
|
|
188378
|
+
result.cardRemoteAction = sub;
|
|
188379
|
+
if (positionals[1])
|
|
188380
|
+
result.componentName = positionals[1];
|
|
188381
|
+
result.remoteUserId = flags.remoteUserId;
|
|
188382
|
+
result.remoteProject = flags.remoteProject;
|
|
188383
|
+
result.historyPage = flags.historyPage;
|
|
188384
|
+
result.historyPerPage = flags.historyPerPage;
|
|
188385
|
+
result.historyFrom = flags.historyFrom;
|
|
188386
|
+
result.historyTo = flags.historyTo;
|
|
188387
|
+
}
|
|
188388
|
+
}
|
|
188389
|
+
}
|
|
188390
|
+
if (command === "page" && argv[1]) {
|
|
188391
|
+
const action = argv[1];
|
|
188392
|
+
if (!VALID_PAGE_ACTIONS.includes(action)) {
|
|
188393
|
+
return result;
|
|
188394
|
+
}
|
|
188395
|
+
result.pageAction = action;
|
|
188396
|
+
if (action === "add") {
|
|
188397
|
+
result.pagePath = argv[2];
|
|
188398
|
+
} else if (action === "view") {
|
|
188399
|
+
result.pageName = argv[2];
|
|
188400
|
+
} else if (action === "ajax") {
|
|
188401
|
+
result.pageName = argv[2];
|
|
188402
|
+
const sub = argv[3];
|
|
188403
|
+
if (sub && VALID_PAGE_AJAX_ACTIONS.includes(sub)) {
|
|
188404
|
+
result.pageAjaxAction = sub;
|
|
188405
|
+
}
|
|
188406
|
+
result.pageAjaxHandler = argv[4];
|
|
188407
|
+
}
|
|
188408
|
+
}
|
|
188409
|
+
return result;
|
|
188396
188410
|
};
|
|
188397
|
-
var
|
|
188398
|
-
|
|
188399
|
-
|
|
188400
|
-
|
|
188401
|
-
|
|
188402
|
-
|
|
188403
|
-
|
|
188404
|
-
|
|
188405
|
-
|
|
188406
|
-
|
|
188407
|
-
|
|
188408
|
-
|
|
188409
|
-
|
|
188410
|
-
|
|
188411
|
-
|
|
188412
|
-
|
|
188413
|
-
|
|
188414
|
-
|
|
188415
|
-
|
|
188416
|
-
|
|
188417
|
-
|
|
188418
|
-
|
|
188419
|
-
|
|
188420
|
-
|
|
188421
|
-
|
|
188422
|
-
|
|
188423
|
-
|
|
188424
|
-
|
|
188425
|
-
|
|
188426
|
-
|
|
188427
|
-
|
|
188428
|
-
|
|
188429
|
-
|
|
188430
|
-
|
|
188431
|
-
|
|
188432
|
-
|
|
188433
|
-
|
|
188434
|
-
|
|
188435
|
-
|
|
188436
|
-
|
|
188437
|
-
|
|
188438
|
-
|
|
188439
|
-
|
|
188440
|
-
|
|
188441
|
-
|
|
188442
|
-
|
|
188443
|
-
|
|
188444
|
-
|
|
188445
|
-
|
|
188446
|
-
|
|
188447
|
-
|
|
188448
|
-
|
|
188449
|
-
|
|
188450
|
-
|
|
188451
|
-
|
|
188452
|
-
|
|
188453
|
-
|
|
188454
|
-
|
|
188455
|
-
|
|
188456
|
-
|
|
188457
|
-
|
|
188458
|
-
|
|
188459
|
-
|
|
188460
|
-
|
|
188461
|
-
|
|
188462
|
-
|
|
188463
|
-
|
|
188464
|
-
|
|
188465
|
-
|
|
188466
|
-
|
|
188467
|
-
|
|
188468
|
-
|
|
188469
|
-
|
|
188470
|
-
|
|
188471
|
-
|
|
188472
|
-
|
|
188473
|
-
|
|
188474
|
-
|
|
188475
|
-
|
|
188476
|
-
|
|
188477
|
-
|
|
188478
|
-
|
|
188479
|
-
|
|
188480
|
-
|
|
188481
|
-
|
|
188482
|
-
|
|
188483
|
-
|
|
188484
|
-
|
|
188485
|
-
|
|
188486
|
-
|
|
188487
|
-
|
|
188411
|
+
var detectHelpScope = (argv) => {
|
|
188412
|
+
if (!argv.includes("--help") && !argv.includes("-h"))
|
|
188413
|
+
return null;
|
|
188414
|
+
const [c0, c1] = argv;
|
|
188415
|
+
if (!c0 || c0 === "--help" || c0 === "-h")
|
|
188416
|
+
return "all";
|
|
188417
|
+
if (c0 === "card" && c1 === "remote")
|
|
188418
|
+
return "card-remote";
|
|
188419
|
+
if (c0 === "card")
|
|
188420
|
+
return "card";
|
|
188421
|
+
if (c0 === "page")
|
|
188422
|
+
return "page";
|
|
188423
|
+
if (c0 === "init")
|
|
188424
|
+
return "init";
|
|
188425
|
+
if (c0 === "postbuild")
|
|
188426
|
+
return "postbuild";
|
|
188427
|
+
if (c0 === "login")
|
|
188428
|
+
return "login";
|
|
188429
|
+
if (c0 === "create" || c0 === "create-pie-app" || c0 === "create-pieui") {
|
|
188430
|
+
return "create";
|
|
188431
|
+
}
|
|
188432
|
+
return "all";
|
|
188433
|
+
};
|
|
188434
|
+
var ALL_LINES = [
|
|
188435
|
+
"Usage: pieui <command> [options]",
|
|
188436
|
+
"",
|
|
188437
|
+
"Commands:",
|
|
188438
|
+
" login Sign in to PieUI and save credentials to .pie/config.json",
|
|
188439
|
+
" create <AppName> Create a Next.js app and run pieui init inside it",
|
|
188440
|
+
" create-pie-app <AppName> Create a blank Next.js web template for PieUI",
|
|
188441
|
+
" create-pieui <AppName> Alias for create-pie-app",
|
|
188442
|
+
" init Initialize piecomponents dir, registry.ts, tailwind & next.config; prompt for backend dirs",
|
|
188443
|
+
" postbuild Scan for components and generate manifest",
|
|
188444
|
+
"",
|
|
188445
|
+
"Card management (mirrors `pie card ...`):",
|
|
188446
|
+
" card add [type] <Name> [--io] [--ajax] Create a new component in piecomponents/",
|
|
188447
|
+
" card list [filter] List registered components",
|
|
188448
|
+
" card pull <ref> Pull a card by Name, project/Name, or r/user/Name (public alias)",
|
|
188449
|
+
" card view <Name> Print card name, props, ajax, IO, and events",
|
|
188450
|
+
" card remove <Name> Remove a component from piecomponents/",
|
|
188451
|
+
" card list-events <Name> List methods keys on the registered PieCard",
|
|
188452
|
+
" card add-event <Name> <event> Add a new methods key with a default handler",
|
|
188453
|
+
" card remote list [--user U] [--project S] List remote components",
|
|
188454
|
+
" card remote push <Name> Upload piecomponents/<Name>/ to PieUI storage",
|
|
188455
|
+
" card remote pull <Name>[@rev] Download component from PieUI storage",
|
|
188456
|
+
" card remote remove <Name> Delete component from PieUI storage",
|
|
188457
|
+
" card remote history <Name> [--page N] [--per-page N] [--from R] [--to R]",
|
|
188458
|
+
" Show revision history with per-file diff stats",
|
|
188459
|
+
" card remote public <Name> Mark component public (readable as r/<user>/<Name>)",
|
|
188460
|
+
" card remote private <Name> Make a public component private again",
|
|
188461
|
+
"",
|
|
188462
|
+
"Page management (mirrors `pie page ...`):",
|
|
188463
|
+
" page add <path> Create app/<path>/page.tsx from the standard Pie page template",
|
|
188464
|
+
" page view <path> Print app/<path>/page.tsx source",
|
|
188465
|
+
" page ajax <path> <add|remove> <handler> Add or remove an AJAX handler in app/<path>/page.tsx",
|
|
188466
|
+
"",
|
|
188467
|
+
"Component types for `card add`:",
|
|
188468
|
+
" simple Simple component (only data prop)",
|
|
188469
|
+
" complex Complex component (data + children props)",
|
|
188470
|
+
" simple-container Container with single content (data + content)",
|
|
188471
|
+
" complex-container Container with array content (data + content[]) [default]",
|
|
188472
|
+
"",
|
|
188473
|
+
"Options for `card add`:",
|
|
188474
|
+
" --io Add realtime support fields to the generated data interface",
|
|
188475
|
+
" --ajax Add AJAX request fields to the generated data interface",
|
|
188476
|
+
"",
|
|
188477
|
+
"Options for init:",
|
|
188478
|
+
" --out-dir <dir>, -o <dir> Base directory for piecomponents (default: .)",
|
|
188479
|
+
"",
|
|
188480
|
+
"Options for postbuild:",
|
|
188481
|
+
" --out-dir <dir>, -o <dir> Output directory (default: public)",
|
|
188482
|
+
" --src-dir <dir>, -s <dir> Source directory (default: src)",
|
|
188483
|
+
" --append Include built-in pieui components in the manifest",
|
|
188484
|
+
"",
|
|
188485
|
+
"Options for `card list` / `card list-events` / `card add-event`:",
|
|
188486
|
+
" --src-dir <dir>, -s <dir> Source directory (default: .)",
|
|
188487
|
+
"",
|
|
188488
|
+
"Examples:",
|
|
188489
|
+
" pieui login",
|
|
188490
|
+
" pieui init",
|
|
188491
|
+
" pieui create my-pie-app",
|
|
188492
|
+
" pieui card add MyCustomCard",
|
|
188493
|
+
" pieui card add simple MySimpleCard",
|
|
188494
|
+
" pieui card list complex-container",
|
|
188495
|
+
" pieui card view MyCustomCard",
|
|
188496
|
+
" pieui card pull r/alice/HeroCard",
|
|
188497
|
+
" pieui card remote push MyCustomCard",
|
|
188498
|
+
" pieui page add dashboard",
|
|
188499
|
+
" pieui page view dashboard",
|
|
188500
|
+
" pieui page ajax dashboard add refresh"
|
|
188501
|
+
];
|
|
188502
|
+
var CARD_LINES = [
|
|
188503
|
+
"Usage: pieui card <subcommand> [options]",
|
|
188504
|
+
"",
|
|
188505
|
+
"Subcommands:",
|
|
188506
|
+
" add [type] <Name> [--io] [--ajax] Create a new component in piecomponents/",
|
|
188507
|
+
" list [filter] List registered components",
|
|
188508
|
+
" pull <ref> Pull a card by Name, project/Name, or r/user/Name (public alias)",
|
|
188509
|
+
" view <Name> Print card name, props, ajax, IO, and events",
|
|
188510
|
+
" remove <Name> Remove a component from piecomponents/",
|
|
188511
|
+
" list-events <Name> List methods keys on the registered PieCard",
|
|
188512
|
+
" add-event <Name> <event> Add a new methods key with a default handler",
|
|
188513
|
+
" remote ... Remote storage operations (see `pieui card remote --help`)",
|
|
188514
|
+
"",
|
|
188515
|
+
"Component types for `card add`:",
|
|
188516
|
+
" simple Simple component (only data prop)",
|
|
188517
|
+
" complex Complex component (data + children props)",
|
|
188518
|
+
" simple-container Container with single content (data + content)",
|
|
188519
|
+
" complex-container Container with array content (data + content[]) [default]",
|
|
188520
|
+
"",
|
|
188521
|
+
"Options for `card add`:",
|
|
188522
|
+
" --io Add realtime support fields to the generated data interface",
|
|
188523
|
+
" --ajax Add AJAX request fields to the generated data interface",
|
|
188524
|
+
"",
|
|
188525
|
+
"Options for `card list` / `card list-events` / `card add-event`:",
|
|
188526
|
+
" --src-dir <dir>, -s <dir> Source directory (default: .)",
|
|
188527
|
+
"",
|
|
188528
|
+
"Examples:",
|
|
188529
|
+
" pieui card add MyCustomCard",
|
|
188530
|
+
" pieui card add simple MySimpleCard",
|
|
188531
|
+
" pieui card list complex-container",
|
|
188532
|
+
" pieui card view MyCustomCard",
|
|
188533
|
+
" pieui card pull r/alice/HeroCard"
|
|
188534
|
+
];
|
|
188535
|
+
var CARD_REMOTE_LINES = [
|
|
188536
|
+
"Usage: pieui card remote <subcommand> [options]",
|
|
188537
|
+
"",
|
|
188538
|
+
"Subcommands:",
|
|
188539
|
+
" list [--user U] [--project S] List remote components",
|
|
188540
|
+
" push <Name> Upload piecomponents/<Name>/ to PieUI storage",
|
|
188541
|
+
" pull <Name>[@rev] Download component from PieUI storage",
|
|
188542
|
+
" remove <Name> Delete component from PieUI storage",
|
|
188543
|
+
" history <Name> [--page N] [--per-page N] [--from R] [--to R]",
|
|
188544
|
+
" Show revision history with per-file diff stats",
|
|
188545
|
+
" public <Name> Mark component public (readable as r/<user>/<Name>)",
|
|
188546
|
+
" private <Name> Make a public component private again",
|
|
188547
|
+
"",
|
|
188548
|
+
"Examples:",
|
|
188549
|
+
" pieui card remote push MyCustomCard",
|
|
188550
|
+
" pieui card remote pull MyCustomCard",
|
|
188551
|
+
" pieui card remote list --user alice --project demo",
|
|
188552
|
+
" pieui card remote history MyCustomCard --page 2"
|
|
188553
|
+
];
|
|
188554
|
+
var PAGE_LINES = [
|
|
188555
|
+
"Usage: pieui page <subcommand> [options]",
|
|
188556
|
+
"",
|
|
188557
|
+
"Subcommands:",
|
|
188558
|
+
" add <path> Create app/<path>/page.tsx from the standard Pie page template",
|
|
188559
|
+
" view <path> Print app/<path>/page.tsx source",
|
|
188560
|
+
" ajax <path> <add|remove> <handler> Add or remove an AJAX handler in app/<path>/page.tsx",
|
|
188561
|
+
"",
|
|
188562
|
+
"Examples:",
|
|
188563
|
+
" pieui page add dashboard",
|
|
188564
|
+
" pieui page view dashboard",
|
|
188565
|
+
" pieui page ajax dashboard add refresh"
|
|
188566
|
+
];
|
|
188567
|
+
var INIT_LINES = [
|
|
188568
|
+
"Usage: pieui init [options]",
|
|
188569
|
+
"",
|
|
188570
|
+
"Initialize piecomponents dir, registry.ts, tailwind & next.config; prompt for backend dirs.",
|
|
188571
|
+
"",
|
|
188572
|
+
"Options:",
|
|
188573
|
+
" --out-dir <dir>, -o <dir> Base directory for piecomponents (default: .)"
|
|
188574
|
+
];
|
|
188575
|
+
var POSTBUILD_LINES = [
|
|
188576
|
+
"Usage: pieui postbuild [options]",
|
|
188577
|
+
"",
|
|
188578
|
+
"Scan for components and generate manifest.",
|
|
188579
|
+
"",
|
|
188580
|
+
"Options:",
|
|
188581
|
+
" --out-dir <dir>, -o <dir> Output directory (default: public)",
|
|
188582
|
+
" --src-dir <dir>, -s <dir> Source directory (default: src)",
|
|
188583
|
+
" --append Include built-in pieui components in the manifest"
|
|
188584
|
+
];
|
|
188585
|
+
var LOGIN_LINES = [
|
|
188586
|
+
"Usage: pieui login",
|
|
188587
|
+
"",
|
|
188588
|
+
"Sign in to PieUI and save credentials to .pie/config.json."
|
|
188589
|
+
];
|
|
188590
|
+
var CREATE_LINES = [
|
|
188591
|
+
"Usage: pieui create <AppName>",
|
|
188592
|
+
" pieui create-pie-app <AppName>",
|
|
188593
|
+
" pieui create-pieui <AppName>",
|
|
188594
|
+
"",
|
|
188595
|
+
"`create` creates a Next.js app and runs `pieui init` inside it.",
|
|
188596
|
+
"`create-pie-app` (alias `create-pieui`) creates a blank Next.js web template for PieUI."
|
|
188597
|
+
];
|
|
188598
|
+
var printUsage = (scope = "all") => {
|
|
188599
|
+
const lines = (() => {
|
|
188600
|
+
switch (scope) {
|
|
188601
|
+
case "card":
|
|
188602
|
+
return CARD_LINES;
|
|
188603
|
+
case "card-remote":
|
|
188604
|
+
return CARD_REMOTE_LINES;
|
|
188605
|
+
case "page":
|
|
188606
|
+
return PAGE_LINES;
|
|
188607
|
+
case "init":
|
|
188608
|
+
return INIT_LINES;
|
|
188609
|
+
case "postbuild":
|
|
188610
|
+
return POSTBUILD_LINES;
|
|
188611
|
+
case "login":
|
|
188612
|
+
return LOGIN_LINES;
|
|
188613
|
+
case "create":
|
|
188614
|
+
return CREATE_LINES;
|
|
188615
|
+
default:
|
|
188616
|
+
return ALL_LINES;
|
|
188617
|
+
}
|
|
188618
|
+
})();
|
|
188619
|
+
for (const line of lines)
|
|
188620
|
+
console.log(line);
|
|
188488
188621
|
};
|
|
188489
188622
|
|
|
188490
188623
|
// src/code/commands/init.ts
|
|
188491
188624
|
var import_fs = __toESM(require("fs"));
|
|
188625
|
+
var import_os = __toESM(require("os"));
|
|
188492
188626
|
var import_path = __toESM(require("path"));
|
|
188627
|
+
var readline = __toESM(require("readline/promises"));
|
|
188493
188628
|
|
|
188494
188629
|
// src/code/templates/componentIndex.ts
|
|
188495
188630
|
var componentIndexTemplate = (componentName) => `import { registerPieComponent } from "@swarm.ing/pieui";
|
|
@@ -188837,15 +188972,15 @@ var componentTemplateFor = (componentType, componentName, options = {}) => {
|
|
|
188837
188972
|
};
|
|
188838
188973
|
|
|
188839
188974
|
// src/code/commands/init.ts
|
|
188840
|
-
var initCommand = (outDir) => {
|
|
188975
|
+
var initCommand = async (outDir) => {
|
|
188841
188976
|
const resolvedOutDir = import_path.default.resolve(process.cwd(), outDir);
|
|
188842
188977
|
console.log(`[pieui] Initializing piecomponents directory in ${resolvedOutDir}...`);
|
|
188843
188978
|
const pieComponentsDir = import_path.default.join(resolvedOutDir, "piecomponents");
|
|
188844
188979
|
if (!import_fs.default.existsSync(pieComponentsDir)) {
|
|
188845
188980
|
import_fs.default.mkdirSync(pieComponentsDir, { recursive: true });
|
|
188846
|
-
console.log(
|
|
188981
|
+
console.log(`[pieui] Created piecomponents directory: ${pieComponentsDir}`);
|
|
188847
188982
|
} else {
|
|
188848
|
-
console.log(
|
|
188983
|
+
console.log(`[pieui] piecomponents directory already exists: ${pieComponentsDir}`);
|
|
188849
188984
|
}
|
|
188850
188985
|
const registryPath = import_path.default.join(pieComponentsDir, "registry.ts");
|
|
188851
188986
|
const registryContent = `"use client";
|
|
@@ -188856,9 +188991,9 @@ var initCommand = (outDir) => {
|
|
|
188856
188991
|
`;
|
|
188857
188992
|
if (!import_fs.default.existsSync(registryPath)) {
|
|
188858
188993
|
import_fs.default.writeFileSync(registryPath, registryContent, "utf8");
|
|
188859
|
-
console.log(
|
|
188994
|
+
console.log(`[pieui] Created registry.ts: ${registryPath}`);
|
|
188860
188995
|
} else {
|
|
188861
|
-
console.log(
|
|
188996
|
+
console.log(`[pieui] registry.ts already exists: ${registryPath}`);
|
|
188862
188997
|
}
|
|
188863
188998
|
const tailwindConfigPath = import_path.default.join(resolvedOutDir, "tailwind.config.js");
|
|
188864
188999
|
const tailwindConfigTsPath = import_path.default.join(resolvedOutDir, "tailwind.config.ts");
|
|
@@ -188902,11 +189037,156 @@ var initCommand = (outDir) => {
|
|
|
188902
189037
|
console.log(`[pieui] "${pieuiContentPath}"`);
|
|
188903
189038
|
}
|
|
188904
189039
|
ensureNextConfig(resolvedOutDir);
|
|
189040
|
+
await ensureBackendPaths(resolvedOutDir);
|
|
188905
189041
|
console.log("[pieui] Initialization complete!");
|
|
188906
189042
|
console.log("[pieui] Next steps:");
|
|
188907
189043
|
console.log(' 1. Import "./piecomponents/registry" in your app entry point');
|
|
188908
189044
|
console.log(' 2. Use "pieui card add <ComponentName>" to create new components');
|
|
188909
189045
|
};
|
|
189046
|
+
var PIE_CONFIG_DIR = ".pie";
|
|
189047
|
+
var PIE_CONFIG_FILE = "config.json";
|
|
189048
|
+
var MAX_HOMEDIR_SCAN_DEPTH = 2;
|
|
189049
|
+
var ensureBackendPaths = async (resolvedOutDir) => {
|
|
189050
|
+
const existing = readPieConfig(resolvedOutDir);
|
|
189051
|
+
if (existing.backendPagesDir && existing.backendComponentsDir) {
|
|
189052
|
+
console.log(`[pieui] Backend dirs already configured in .pie/${PIE_CONFIG_FILE}:`);
|
|
189053
|
+
console.log(`[pieui] pages: ${existing.backendPagesDir}`);
|
|
189054
|
+
console.log(`[pieui] components: ${existing.backendComponentsDir}`);
|
|
189055
|
+
return;
|
|
189056
|
+
}
|
|
189057
|
+
if (!process.stdin.isTTY) {
|
|
189058
|
+
console.log("[pieui] Non-interactive shell — skipping backend pages/components prompt.");
|
|
189059
|
+
console.log(`[pieui] To configure, add "backendPagesDir" and "backendComponentsDir" to ${import_path.default.join(resolvedOutDir, PIE_CONFIG_DIR, PIE_CONFIG_FILE)}`);
|
|
189060
|
+
return;
|
|
189061
|
+
}
|
|
189062
|
+
const home = import_os.default.homedir();
|
|
189063
|
+
console.log(`[pieui] Searching ${home} for backend projects with pages/ and components/ directories...`);
|
|
189064
|
+
const candidates = findBackendCandidates(home, MAX_HOMEDIR_SCAN_DEPTH);
|
|
189065
|
+
const rl = readline.createInterface({
|
|
189066
|
+
input: process.stdin,
|
|
189067
|
+
output: process.stdout
|
|
189068
|
+
});
|
|
189069
|
+
try {
|
|
189070
|
+
let pagesDir = existing.backendPagesDir;
|
|
189071
|
+
let componentsDir = existing.backendComponentsDir;
|
|
189072
|
+
if (!pagesDir || !componentsDir) {
|
|
189073
|
+
const picked = await pickBackendPair(rl, candidates, home);
|
|
189074
|
+
if (picked) {
|
|
189075
|
+
pagesDir = pagesDir || picked.pages;
|
|
189076
|
+
componentsDir = componentsDir || picked.components;
|
|
189077
|
+
}
|
|
189078
|
+
}
|
|
189079
|
+
if (!pagesDir) {
|
|
189080
|
+
pagesDir = await promptAbsoluteDir(rl, "Path to backend pages directory", home);
|
|
189081
|
+
}
|
|
189082
|
+
if (!componentsDir) {
|
|
189083
|
+
componentsDir = await promptAbsoluteDir(rl, "Path to backend components directory", home);
|
|
189084
|
+
}
|
|
189085
|
+
if (!pagesDir || !componentsDir) {
|
|
189086
|
+
console.log("[pieui] Skipped backend paths — neither directory was provided.");
|
|
189087
|
+
return;
|
|
189088
|
+
}
|
|
189089
|
+
writePieConfig(resolvedOutDir, {
|
|
189090
|
+
...existing,
|
|
189091
|
+
backendPagesDir: pagesDir,
|
|
189092
|
+
backendComponentsDir: componentsDir
|
|
189093
|
+
});
|
|
189094
|
+
const configPath = import_path.default.join(resolvedOutDir, PIE_CONFIG_DIR, PIE_CONFIG_FILE);
|
|
189095
|
+
console.log(`[pieui] Saved backend paths to ${configPath}`);
|
|
189096
|
+
console.log(`[pieui] pages: ${pagesDir}`);
|
|
189097
|
+
console.log(`[pieui] components: ${componentsDir}`);
|
|
189098
|
+
} finally {
|
|
189099
|
+
rl.close();
|
|
189100
|
+
}
|
|
189101
|
+
};
|
|
189102
|
+
var findBackendCandidates = (home, maxDepth) => {
|
|
189103
|
+
const found = [];
|
|
189104
|
+
const visit = (dir, depth) => {
|
|
189105
|
+
if (depth > maxDepth)
|
|
189106
|
+
return;
|
|
189107
|
+
let entries;
|
|
189108
|
+
try {
|
|
189109
|
+
entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
|
|
189110
|
+
} catch {
|
|
189111
|
+
return;
|
|
189112
|
+
}
|
|
189113
|
+
const subdirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith("."));
|
|
189114
|
+
const subdirNames = new Set(subdirs.map((e) => e.name));
|
|
189115
|
+
if (subdirNames.has("pages") && subdirNames.has("components")) {
|
|
189116
|
+
found.push({
|
|
189117
|
+
project: dir,
|
|
189118
|
+
pages: import_path.default.join(dir, "pages"),
|
|
189119
|
+
components: import_path.default.join(dir, "components")
|
|
189120
|
+
});
|
|
189121
|
+
}
|
|
189122
|
+
for (const sub of subdirs) {
|
|
189123
|
+
if (sub.name === "node_modules" || sub.name === ".git")
|
|
189124
|
+
continue;
|
|
189125
|
+
visit(import_path.default.join(dir, sub.name), depth + 1);
|
|
189126
|
+
}
|
|
189127
|
+
};
|
|
189128
|
+
visit(home, 0);
|
|
189129
|
+
return found;
|
|
189130
|
+
};
|
|
189131
|
+
var pickBackendPair = async (rl, candidates, home) => {
|
|
189132
|
+
if (candidates.length === 0) {
|
|
189133
|
+
console.log("[pieui] No matching backend projects found under home directory.");
|
|
189134
|
+
return null;
|
|
189135
|
+
}
|
|
189136
|
+
console.log("[pieui] Found backend candidates:");
|
|
189137
|
+
candidates.forEach((c, i) => {
|
|
189138
|
+
const rel = import_path.default.relative(home, c.project) || ".";
|
|
189139
|
+
console.log(` ${i + 1}. ~/${rel}`);
|
|
189140
|
+
});
|
|
189141
|
+
const answer = (await rl.question(`[pieui] Pick a candidate [1-${candidates.length}] or press Enter to type paths manually: `)).trim();
|
|
189142
|
+
if (!answer)
|
|
189143
|
+
return null;
|
|
189144
|
+
const idx = Number.parseInt(answer, 10);
|
|
189145
|
+
if (Number.isNaN(idx) || idx < 1 || idx > candidates.length) {
|
|
189146
|
+
console.log("[pieui] Invalid selection — falling back to manual input.");
|
|
189147
|
+
return null;
|
|
189148
|
+
}
|
|
189149
|
+
return candidates[idx - 1];
|
|
189150
|
+
};
|
|
189151
|
+
var promptAbsoluteDir = async (rl, label, home) => {
|
|
189152
|
+
while (true) {
|
|
189153
|
+
const raw = (await rl.question(`[pieui] ${label} (absolute or ~/...): `)).trim();
|
|
189154
|
+
if (!raw)
|
|
189155
|
+
return;
|
|
189156
|
+
const expanded = raw.startsWith("~") ? import_path.default.join(home, raw.slice(1).replace(/^[\\/]/, "")) : raw;
|
|
189157
|
+
const absolute = import_path.default.resolve(expanded);
|
|
189158
|
+
if (!absolute.startsWith(home + import_path.default.sep) && absolute !== home) {
|
|
189159
|
+
console.log(`[pieui] Warning: ${absolute} is outside ${home}. Continuing anyway.`);
|
|
189160
|
+
}
|
|
189161
|
+
if (!import_fs.default.existsSync(absolute) || !import_fs.default.statSync(absolute).isDirectory()) {
|
|
189162
|
+
console.log(`[pieui] Not a directory: ${absolute}. Try again.`);
|
|
189163
|
+
continue;
|
|
189164
|
+
}
|
|
189165
|
+
return absolute;
|
|
189166
|
+
}
|
|
189167
|
+
};
|
|
189168
|
+
var readPieConfig = (resolvedOutDir) => {
|
|
189169
|
+
const configPath = import_path.default.join(resolvedOutDir, PIE_CONFIG_DIR, PIE_CONFIG_FILE);
|
|
189170
|
+
if (!import_fs.default.existsSync(configPath))
|
|
189171
|
+
return {};
|
|
189172
|
+
try {
|
|
189173
|
+
const parsed = JSON.parse(import_fs.default.readFileSync(configPath, "utf8"));
|
|
189174
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
189175
|
+
return {};
|
|
189176
|
+
return parsed;
|
|
189177
|
+
} catch {
|
|
189178
|
+
return {};
|
|
189179
|
+
}
|
|
189180
|
+
};
|
|
189181
|
+
var writePieConfig = (resolvedOutDir, config) => {
|
|
189182
|
+
const pieDir = import_path.default.join(resolvedOutDir, PIE_CONFIG_DIR);
|
|
189183
|
+
if (!import_fs.default.existsSync(pieDir)) {
|
|
189184
|
+
import_fs.default.mkdirSync(pieDir, { recursive: true });
|
|
189185
|
+
}
|
|
189186
|
+
const configPath = import_path.default.join(pieDir, PIE_CONFIG_FILE);
|
|
189187
|
+
import_fs.default.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}
|
|
189188
|
+
`, "utf8");
|
|
189189
|
+
};
|
|
188910
189190
|
var ensureNextConfig = (resolvedOutDir) => {
|
|
188911
189191
|
const candidates = [
|
|
188912
189192
|
"next.config.ts",
|
|
@@ -189075,10 +189355,10 @@ var addCommand = (componentName, componentType = "complex-container", options =
|
|
|
189075
189355
|
}
|
|
189076
189356
|
console.log(`[pieui] Component ${componentName} (${componentType}) created successfully!`);
|
|
189077
189357
|
console.log(`[pieui] Files created:`);
|
|
189078
|
-
console.log(` -
|
|
189079
|
-
console.log(` -
|
|
189080
|
-
console.log(` -
|
|
189081
|
-
console.log(`[pieui] Updated registry
|
|
189358
|
+
console.log(` - ${import_path3.default.join(componentDir, "index.ts")}`);
|
|
189359
|
+
console.log(` - ${import_path3.default.join(componentDir, "types", "index.ts")}`);
|
|
189360
|
+
console.log(` - ${import_path3.default.join(componentDir, "ui", `${componentName}.tsx`)}`);
|
|
189361
|
+
console.log(`[pieui] Updated registry: ${resolveRegistryPath(pieComponentsDir)}`);
|
|
189082
189362
|
console.log("");
|
|
189083
189363
|
console.log(`[pieui] Component type: ${componentType}`);
|
|
189084
189364
|
console.log(`[pieui] IO fields: ${options.io ? "enabled" : "disabled"}`);
|
|
@@ -189113,12 +189393,12 @@ var removeCommand = (componentName) => {
|
|
|
189113
189393
|
console.error("[pieui] Error: piecomponents directory not found. Nothing to remove.");
|
|
189114
189394
|
process.exit(1);
|
|
189115
189395
|
}
|
|
189116
|
-
const componentDir = import_path4.default.
|
|
189396
|
+
const componentDir = import_path4.default.resolve(pieComponentsDir, componentName);
|
|
189117
189397
|
if (import_fs4.default.existsSync(componentDir)) {
|
|
189118
189398
|
import_fs4.default.rmSync(componentDir, { recursive: true, force: true });
|
|
189119
|
-
console.log(`[pieui] Removed directory:
|
|
189399
|
+
console.log(`[pieui] Removed directory: ${componentDir}`);
|
|
189120
189400
|
} else {
|
|
189121
|
-
console.log(`[pieui] Warning: Component directory
|
|
189401
|
+
console.log(`[pieui] Warning: Component directory not found: ${componentDir}`);
|
|
189122
189402
|
}
|
|
189123
189403
|
const registryPath = resolveRegistryPath(pieComponentsDir);
|
|
189124
189404
|
if (import_fs4.default.existsSync(registryPath)) {
|
|
@@ -189131,9 +189411,9 @@ var removeCommand = (componentName) => {
|
|
|
189131
189411
|
`);
|
|
189132
189412
|
if (registryContent !== originalContent) {
|
|
189133
189413
|
import_fs4.default.writeFileSync(registryPath, registryContent, "utf8");
|
|
189134
|
-
console.log(`[pieui] Cleaned up registry
|
|
189414
|
+
console.log(`[pieui] Cleaned up registry: ${registryPath}`);
|
|
189135
189415
|
} else {
|
|
189136
|
-
console.log(`[pieui] Warning: ${componentName} not found in
|
|
189416
|
+
console.log(`[pieui] Warning: ${componentName} not found in ${registryPath}`);
|
|
189137
189417
|
}
|
|
189138
189418
|
}
|
|
189139
189419
|
console.log(`[pieui] Component ${componentName} removed successfully!`);
|
|
@@ -189187,7 +189467,7 @@ var pe = "\x00PERIOD" + Math.random() + "\x00";
|
|
|
189187
189467
|
var is = new RegExp(fe, "g");
|
|
189188
189468
|
var rs = new RegExp(ue, "g");
|
|
189189
189469
|
var ns = new RegExp(qt, "g");
|
|
189190
|
-
var
|
|
189470
|
+
var os2 = new RegExp(de, "g");
|
|
189191
189471
|
var hs = new RegExp(pe, "g");
|
|
189192
189472
|
var as = /\\\\/g;
|
|
189193
189473
|
var ls = /\\{/g;
|
|
@@ -189202,7 +189482,7 @@ function ps(n) {
|
|
|
189202
189482
|
return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs5, de).replace(us, pe);
|
|
189203
189483
|
}
|
|
189204
189484
|
function ms(n) {
|
|
189205
|
-
return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(
|
|
189485
|
+
return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os2, ",").replace(hs, ".");
|
|
189206
189486
|
}
|
|
189207
189487
|
function me(n) {
|
|
189208
189488
|
if (!n)
|
|
@@ -192462,7 +192742,7 @@ var defaultCompilerOptions = () => ({
|
|
|
192462
192742
|
skipLibCheck: true
|
|
192463
192743
|
});
|
|
192464
192744
|
var findComponentRegistrations = (srcDir) => {
|
|
192465
|
-
console.log(`[pieui] Searching for components in: ${srcDir}`);
|
|
192745
|
+
console.log(`[pieui] Searching for components in: ${import_path5.default.resolve(process.cwd(), srcDir)}`);
|
|
192466
192746
|
const files = Ze.sync(`${srcDir}/**/*.{ts,tsx}`, {
|
|
192467
192747
|
ignore: ["**/*.d.ts", "**/dist/**", "**/node_modules/**"]
|
|
192468
192748
|
});
|
|
@@ -192602,7 +192882,8 @@ var detectComponentType = (propsType, checker) => {
|
|
|
192602
192882
|
|
|
192603
192883
|
// src/code/commands/list.ts
|
|
192604
192884
|
var listCommand = (srcDir, filter) => {
|
|
192605
|
-
|
|
192885
|
+
const resolvedSrcDir = import_path6.default.resolve(process.cwd(), srcDir);
|
|
192886
|
+
console.log(`[pieui] Scanning components in: ${resolvedSrcDir}`);
|
|
192606
192887
|
const files = Ze.sync(`${srcDir}/**/*.{ts,tsx}`, {
|
|
192607
192888
|
ignore: [
|
|
192608
192889
|
"**/*.d.ts",
|
|
@@ -192698,7 +192979,7 @@ var listCommand = (srcDir, filter) => {
|
|
|
192698
192979
|
components.push({
|
|
192699
192980
|
name: componentName,
|
|
192700
192981
|
type: compType,
|
|
192701
|
-
file: import_path6.default.
|
|
192982
|
+
file: import_path6.default.resolve(componentFile),
|
|
192702
192983
|
dataType: dataTypeName,
|
|
192703
192984
|
lazy: hasLoader && !componentRef
|
|
192704
192985
|
});
|
|
@@ -192919,7 +193200,7 @@ var listEventsCommand = (srcDir, componentName) => {
|
|
|
192919
193200
|
entries.push({
|
|
192920
193201
|
event: f.event,
|
|
192921
193202
|
handler: f.handler,
|
|
192922
|
-
file: import_path7.default.
|
|
193203
|
+
file: import_path7.default.resolve(sourceFile.fileName),
|
|
192923
193204
|
line: f.line
|
|
192924
193205
|
});
|
|
192925
193206
|
}
|
|
@@ -192951,7 +193232,7 @@ var listEventsCommand = (srcDir, componentName) => {
|
|
|
192951
193232
|
entries.push({
|
|
192952
193233
|
event: f.event,
|
|
192953
193234
|
handler: f.handler,
|
|
192954
|
-
file: import_path7.default.
|
|
193235
|
+
file: import_path7.default.resolve(sourceFile.fileName),
|
|
192955
193236
|
line: f.line
|
|
192956
193237
|
});
|
|
192957
193238
|
}
|
|
@@ -193134,7 +193415,7 @@ var addEventCommand = (srcDir, componentName, eventName) => {
|
|
|
193134
193415
|
const methodsObj = target.methodsObj;
|
|
193135
193416
|
const existingKeys = getPropertyKeys(methodsObj);
|
|
193136
193417
|
if (existingKeys.has(eventName)) {
|
|
193137
|
-
console.log(`[pieui] methods.${eventName} already exists in ${import_path8.default.
|
|
193418
|
+
console.log(`[pieui] methods.${eventName} already exists in ${import_path8.default.resolve(filePath)}`);
|
|
193138
193419
|
return;
|
|
193139
193420
|
}
|
|
193140
193421
|
const { propIndent, closingIndent } = computeIndentFromExistingProp(sourceText, target.sourceFile, methodsObj);
|
|
@@ -193150,7 +193431,7 @@ ${propIndent}${eventName}: ${handler}
|
|
|
193150
193431
|
${closingIndent}`;
|
|
193151
193432
|
const updated = sourceText.slice(0, insertAt) + insertion + sourceText.slice(insertAt);
|
|
193152
193433
|
import_fs6.default.writeFileSync(filePath, updated, "utf8");
|
|
193153
|
-
console.log(`[pieui] Updated: ${import_path8.default.
|
|
193434
|
+
console.log(`[pieui] Updated: ${import_path8.default.resolve(filePath)} (added "${eventName}")`);
|
|
193154
193435
|
};
|
|
193155
193436
|
|
|
193156
193437
|
// src/code/commands/postbuild.ts
|
|
@@ -194286,6 +194567,115 @@ var cardRemotePrivateCommand = async (componentName) => {
|
|
|
194286
194567
|
console.log(`[pieui] is_public: ${state.isPublic}`);
|
|
194287
194568
|
};
|
|
194288
194569
|
|
|
194570
|
+
// src/code/commands/cardPull.ts
|
|
194571
|
+
var cardPullCommand = async (cardRef) => {
|
|
194572
|
+
await cardRemotePullCommand(cardRef);
|
|
194573
|
+
};
|
|
194574
|
+
|
|
194575
|
+
// src/code/commands/cardView.ts
|
|
194576
|
+
var import_node_fs4 = __toESM(require("node:fs"));
|
|
194577
|
+
var import_node_path5 = __toESM(require("node:path"));
|
|
194578
|
+
var AJAX_FIELD_NAMES2 = new Set(["pathname", "deps_names", "kwargs"]);
|
|
194579
|
+
var IO_FIELD_RE = /\buse_[A-Za-z0-9_]+_support\b/g;
|
|
194580
|
+
var extractInterfaceBody = (source, interfaceName) => {
|
|
194581
|
+
const idx = source.indexOf(`interface ${interfaceName}`);
|
|
194582
|
+
if (idx === -1)
|
|
194583
|
+
return null;
|
|
194584
|
+
const braceStart = source.indexOf("{", idx);
|
|
194585
|
+
if (braceStart === -1)
|
|
194586
|
+
return null;
|
|
194587
|
+
let depth = 0;
|
|
194588
|
+
for (let i = braceStart;i < source.length; i++) {
|
|
194589
|
+
const ch = source[i];
|
|
194590
|
+
if (ch === "{")
|
|
194591
|
+
depth++;
|
|
194592
|
+
else if (ch === "}") {
|
|
194593
|
+
depth--;
|
|
194594
|
+
if (depth === 0)
|
|
194595
|
+
return source.slice(braceStart + 1, i);
|
|
194596
|
+
}
|
|
194597
|
+
}
|
|
194598
|
+
return null;
|
|
194599
|
+
};
|
|
194600
|
+
var parseProps = (body) => {
|
|
194601
|
+
const props = [];
|
|
194602
|
+
const lineRe = /^[ \t]*([A-Za-z_][A-Za-z0-9_]*)(\?)?\s*:\s*([^;\n]+?)\s*;?\s*$/gm;
|
|
194603
|
+
let match;
|
|
194604
|
+
while ((match = lineRe.exec(body)) !== null) {
|
|
194605
|
+
const [, name, optional, typeRaw] = match;
|
|
194606
|
+
props.push({
|
|
194607
|
+
name,
|
|
194608
|
+
type: typeRaw.trim(),
|
|
194609
|
+
default: optional ? "(optional)" : "(required)"
|
|
194610
|
+
});
|
|
194611
|
+
}
|
|
194612
|
+
return props;
|
|
194613
|
+
};
|
|
194614
|
+
var formatTable = (headers, rows) => {
|
|
194615
|
+
const data = [headers, ...rows];
|
|
194616
|
+
const widths = headers.map((_2, c) => Math.max(...data.map((row) => (row[c] ?? "").length)));
|
|
194617
|
+
const hline = `+${widths.map((w) => "-".repeat(w + 2)).join("+")}+`;
|
|
194618
|
+
const fmtRow = (cells) => `|${cells.map((cell, i) => ` ${(cell ?? "").padEnd(widths[i])} `).join("|")}|`;
|
|
194619
|
+
return [hline, fmtRow(headers), hline, ...rows.map(fmtRow), hline].join(`
|
|
194620
|
+
`);
|
|
194621
|
+
};
|
|
194622
|
+
var cardViewCommand = (componentName) => {
|
|
194623
|
+
const settings = loadSettings();
|
|
194624
|
+
const componentDir = import_node_path5.default.join(settings.componentsDir, componentName);
|
|
194625
|
+
if (!import_node_fs4.default.existsSync(componentDir)) {
|
|
194626
|
+
throw new Error(`Component directory not found: ${componentDir}`);
|
|
194627
|
+
}
|
|
194628
|
+
const typesPath = import_node_path5.default.join(componentDir, "types.ts");
|
|
194629
|
+
const indexPath = import_node_path5.default.join(componentDir, "index.tsx");
|
|
194630
|
+
const indexPathTs = import_node_path5.default.join(componentDir, "index.ts");
|
|
194631
|
+
const typesSource = import_node_fs4.default.existsSync(typesPath) ? import_node_fs4.default.readFileSync(typesPath, "utf8") : "";
|
|
194632
|
+
const indexSource = import_node_fs4.default.existsSync(indexPath) ? import_node_fs4.default.readFileSync(indexPath, "utf8") : import_node_fs4.default.existsSync(indexPathTs) ? import_node_fs4.default.readFileSync(indexPathTs, "utf8") : "";
|
|
194633
|
+
const dataInterface = extractInterfaceBody(typesSource, `${componentName}Data`) ?? "";
|
|
194634
|
+
const props = parseProps(dataInterface);
|
|
194635
|
+
const hasAjax = props.some((p) => AJAX_FIELD_NAMES2.has(p.name));
|
|
194636
|
+
const ioFields2 = props.map((p) => p.name).filter((name) => IO_FIELD_RE.test(name));
|
|
194637
|
+
IO_FIELD_RE.lastIndex = 0;
|
|
194638
|
+
const events = [];
|
|
194639
|
+
const eventRe = /\b(?:on|create)([A-Z][A-Za-z0-9]*)Event\b|methods\s*=\s*\{([\s\S]*?)\}/g;
|
|
194640
|
+
const methodsMatch = indexSource.match(/methods\s*=\s*\{([\s\S]*?)\}/);
|
|
194641
|
+
if (methodsMatch) {
|
|
194642
|
+
const inner = methodsMatch[1];
|
|
194643
|
+
const keyRe = /([A-Za-z_][A-Za-z0-9_]*)\s*:/g;
|
|
194644
|
+
let m;
|
|
194645
|
+
while ((m = keyRe.exec(inner)) !== null)
|
|
194646
|
+
events.push(m[1]);
|
|
194647
|
+
}
|
|
194648
|
+
console.log("Name:");
|
|
194649
|
+
console.log(componentName);
|
|
194650
|
+
console.log("");
|
|
194651
|
+
console.log("File:");
|
|
194652
|
+
console.log(import_node_path5.default.resolve(componentDir));
|
|
194653
|
+
console.log("");
|
|
194654
|
+
console.log("Props:");
|
|
194655
|
+
if (props.length === 0) {
|
|
194656
|
+
console.log("(none)");
|
|
194657
|
+
} else {
|
|
194658
|
+
console.log(formatTable(["Name", "Type", "Default"], props.map((p) => [p.name, p.type, p.default])));
|
|
194659
|
+
}
|
|
194660
|
+
console.log("");
|
|
194661
|
+
console.log("Ajax:");
|
|
194662
|
+
console.log(hasAjax ? "yes" : "no");
|
|
194663
|
+
console.log("");
|
|
194664
|
+
console.log("IO:");
|
|
194665
|
+
if (ioFields2.length === 0) {
|
|
194666
|
+
console.log("no");
|
|
194667
|
+
} else {
|
|
194668
|
+
console.log(formatTable(["name"], ioFields2.map((n7) => [n7])));
|
|
194669
|
+
}
|
|
194670
|
+
console.log("");
|
|
194671
|
+
console.log("Events:");
|
|
194672
|
+
if (events.length === 0) {
|
|
194673
|
+
console.log("no (run `pieui card list-events " + componentName + "`)");
|
|
194674
|
+
} else {
|
|
194675
|
+
console.log(formatTable(["event"], events.map((e) => [e])));
|
|
194676
|
+
}
|
|
194677
|
+
};
|
|
194678
|
+
|
|
194289
194679
|
// src/code/commands/pageAdd.ts
|
|
194290
194680
|
var import_fs8 = __toESM(require("fs"));
|
|
194291
194681
|
var import_path10 = __toESM(require("path"));
|
|
@@ -194325,12 +194715,93 @@ var pageAddCommand = (pagePath) => {
|
|
|
194325
194715
|
throw new Error("Page path must stay inside the app directory");
|
|
194326
194716
|
}
|
|
194327
194717
|
if (import_fs8.default.existsSync(targetFile)) {
|
|
194328
|
-
console.error(`[pieui] Error: Page already exists at
|
|
194718
|
+
console.error(`[pieui] Error: Page already exists at ${targetFile}`);
|
|
194329
194719
|
process.exit(1);
|
|
194330
194720
|
}
|
|
194331
194721
|
import_fs8.default.mkdirSync(import_path10.default.dirname(targetFile), { recursive: true });
|
|
194332
194722
|
import_fs8.default.writeFileSync(targetFile, pageTemplate(pageComponentName), "utf8");
|
|
194333
|
-
console.log(`[pieui] Page created successfully at
|
|
194723
|
+
console.log(`[pieui] Page created successfully at ${targetFile}`);
|
|
194724
|
+
};
|
|
194725
|
+
|
|
194726
|
+
// src/code/commands/pageView.ts
|
|
194727
|
+
var import_node_fs5 = __toESM(require("node:fs"));
|
|
194728
|
+
var import_node_path6 = __toESM(require("node:path"));
|
|
194729
|
+
var normalizePagePath2 = (pagePath) => {
|
|
194730
|
+
const trimmed = pagePath.trim();
|
|
194731
|
+
if (!trimmed)
|
|
194732
|
+
throw new Error("Path is required for page view command");
|
|
194733
|
+
const slashed = trimmed.replace(/\\/g, "/");
|
|
194734
|
+
const noRel = slashed.replace(/^\.\/+/, "");
|
|
194735
|
+
const noApp = noRel.replace(/^app\//, "");
|
|
194736
|
+
const noEdge = noApp.replace(/^\/+|\/+$/g, "");
|
|
194737
|
+
const normalized = import_node_path6.default.posix.normalize(noEdge);
|
|
194738
|
+
if (!normalized || normalized === ".") {
|
|
194739
|
+
throw new Error("Path is required for page view command");
|
|
194740
|
+
}
|
|
194741
|
+
if (normalized === ".." || normalized.startsWith("../") || normalized.includes("/../")) {
|
|
194742
|
+
throw new Error("Page path must stay inside the app directory");
|
|
194743
|
+
}
|
|
194744
|
+
return normalized;
|
|
194745
|
+
};
|
|
194746
|
+
var pageViewCommand = (pagePath) => {
|
|
194747
|
+
const normalized = normalizePagePath2(pagePath);
|
|
194748
|
+
const target = import_node_path6.default.join(process.cwd(), "app", normalized, "page.tsx");
|
|
194749
|
+
if (!import_node_fs5.default.existsSync(target)) {
|
|
194750
|
+
throw new Error(`Page file not found: ${target}`);
|
|
194751
|
+
}
|
|
194752
|
+
const source = import_node_fs5.default.readFileSync(target, "utf8");
|
|
194753
|
+
console.log(`[pieui] Path: ${target}`);
|
|
194754
|
+
console.log("");
|
|
194755
|
+
process.stdout.write(source);
|
|
194756
|
+
if (!source.endsWith(`
|
|
194757
|
+
`))
|
|
194758
|
+
console.log("");
|
|
194759
|
+
};
|
|
194760
|
+
|
|
194761
|
+
// src/code/commands/pageAjax.ts
|
|
194762
|
+
var import_node_fs6 = __toESM(require("node:fs"));
|
|
194763
|
+
var import_node_path7 = __toESM(require("node:path"));
|
|
194764
|
+
var import_node_child_process = require("node:child_process");
|
|
194765
|
+
var PIE_CONFIG_PATH = ".pie/config.json";
|
|
194766
|
+
var readBackendRoot = () => {
|
|
194767
|
+
const configPath = import_node_path7.default.join(process.cwd(), PIE_CONFIG_PATH);
|
|
194768
|
+
if (!import_node_fs6.default.existsSync(configPath))
|
|
194769
|
+
return;
|
|
194770
|
+
try {
|
|
194771
|
+
const parsed = JSON.parse(import_node_fs6.default.readFileSync(configPath, "utf8"));
|
|
194772
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
194773
|
+
return;
|
|
194774
|
+
const config = parsed;
|
|
194775
|
+
if (!config.backendPagesDir)
|
|
194776
|
+
return;
|
|
194777
|
+
const pages = import_node_path7.default.resolve(config.backendPagesDir);
|
|
194778
|
+
if (!import_node_fs6.default.existsSync(pages) || !import_node_fs6.default.statSync(pages).isDirectory()) {
|
|
194779
|
+
return;
|
|
194780
|
+
}
|
|
194781
|
+
return import_node_path7.default.dirname(pages);
|
|
194782
|
+
} catch {
|
|
194783
|
+
return;
|
|
194784
|
+
}
|
|
194785
|
+
};
|
|
194786
|
+
var pageAjaxCommand = (pageName, action, handlerName) => {
|
|
194787
|
+
if (!pageName)
|
|
194788
|
+
throw new Error("Page name is required for page ajax command");
|
|
194789
|
+
if (!handlerName) {
|
|
194790
|
+
throw new Error("Handler name is required for page ajax command");
|
|
194791
|
+
}
|
|
194792
|
+
const backendRoot = readBackendRoot();
|
|
194793
|
+
if (!backendRoot) {
|
|
194794
|
+
throw new Error("Backend project not configured. Run `pieui init` to link a backend project (saves backendPagesDir/.backendComponentsDir to .pie/config.json).");
|
|
194795
|
+
}
|
|
194796
|
+
console.log(`[pieui] Delegating to backend: ${backendRoot}`);
|
|
194797
|
+
console.log(`[pieui] pie page ajax ${pageName} ${action} ${handlerName}`);
|
|
194798
|
+
const result = import_node_child_process.spawnSync("pie", ["page", "ajax", pageName, action, handlerName], { cwd: backendRoot, stdio: "inherit", env: process.env });
|
|
194799
|
+
if (result.error) {
|
|
194800
|
+
throw new Error(`Failed to invoke \`pie\` in ${backendRoot}: ${result.error.message}`);
|
|
194801
|
+
}
|
|
194802
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
194803
|
+
process.exit(result.status);
|
|
194804
|
+
}
|
|
194334
194805
|
};
|
|
194335
194806
|
|
|
194336
194807
|
// src/code/commands/create.ts
|
|
@@ -194338,6 +194809,7 @@ var import_fs9 = __toESM(require("fs"));
|
|
|
194338
194809
|
var import_path11 = __toESM(require("path"));
|
|
194339
194810
|
var import_child_process = require("child_process");
|
|
194340
194811
|
var DEFAULT_TEMPLATE_SPEC = "next-app@latest";
|
|
194812
|
+
var DEFAULT_PIEUI_PACKAGE_SPEC = "@swarm.ing/pieui";
|
|
194341
194813
|
var clearDirectory = (targetDir) => {
|
|
194342
194814
|
if (!import_fs9.default.existsSync(targetDir))
|
|
194343
194815
|
return;
|
|
@@ -194395,7 +194867,7 @@ var runBunCommand = (bunBin, args, cwd) => {
|
|
|
194395
194867
|
throw new Error(`${args.join(" ")} failed (exit code ${result.status ?? "unknown"})`);
|
|
194396
194868
|
}
|
|
194397
194869
|
};
|
|
194398
|
-
var createCommand = (appName) => {
|
|
194870
|
+
var createCommand = async (appName) => {
|
|
194399
194871
|
const trimmedAppName = appName.trim();
|
|
194400
194872
|
if (!trimmedAppName) {
|
|
194401
194873
|
console.error("[pieui] Error: App name is required for create command");
|
|
@@ -194408,6 +194880,7 @@ var createCommand = (appName) => {
|
|
|
194408
194880
|
}
|
|
194409
194881
|
const bunBin = process.env.PIEUI_CREATE_BUN_BIN || "bun";
|
|
194410
194882
|
const templateSpec = process.env.PIEUI_CREATE_NEXT_APP_SPEC || DEFAULT_TEMPLATE_SPEC;
|
|
194883
|
+
const pieuiPackageSpec = process.env.PIEUI_CREATE_PACKAGE_SPEC || DEFAULT_PIEUI_PACKAGE_SPEC;
|
|
194411
194884
|
console.log(`[pieui] Creating Next.js app in "${trimmedAppName}"...`);
|
|
194412
194885
|
const result = import_child_process.spawnSync(bunBin, ["create", templateSpec, trimmedAppName, "--yes"], {
|
|
194413
194886
|
cwd: process.cwd(),
|
|
@@ -194421,9 +194894,9 @@ var createCommand = (appName) => {
|
|
|
194421
194894
|
throw new Error(`create failed (exit code ${result.status ?? "unknown"})`);
|
|
194422
194895
|
}
|
|
194423
194896
|
scaffoldCreateAppFiles(appDir);
|
|
194424
|
-
initCommand(trimmedAppName);
|
|
194425
194897
|
writeFile(import_path11.default.join(appDir, ".env"), envTemplate());
|
|
194426
|
-
runBunCommand(bunBin, ["
|
|
194898
|
+
runBunCommand(bunBin, ["add", pieuiPackageSpec], appDir);
|
|
194899
|
+
await initCommand(trimmedAppName);
|
|
194427
194900
|
runBunCommand(bunBin, ["run", "dev"], appDir);
|
|
194428
194901
|
};
|
|
194429
194902
|
|
|
@@ -194676,10 +195149,10 @@ var createPieAppCommand = (appName) => {
|
|
|
194676
195149
|
};
|
|
194677
195150
|
|
|
194678
195151
|
// src/code/commands/login.ts
|
|
194679
|
-
var
|
|
195152
|
+
var import_node_child_process2 = require("node:child_process");
|
|
194680
195153
|
var import_node_crypto = require("node:crypto");
|
|
194681
|
-
var
|
|
194682
|
-
var
|
|
195154
|
+
var import_node_fs7 = __toESM(require("node:fs"));
|
|
195155
|
+
var import_node_path8 = __toESM(require("node:path"));
|
|
194683
195156
|
var CONNECT_BASE = "https://pieui.swarm.ing/connect";
|
|
194684
195157
|
var CREDENTIALS_API = "https://api-pieui.swarm.ing/api/external/credentials";
|
|
194685
195158
|
var CONNECT_BASE_ENV = "PIEUI_LOGIN_CONNECT_BASE";
|
|
@@ -194696,13 +195169,13 @@ var generateCode = (length = CODE_LENGTH) => {
|
|
|
194696
195169
|
var tryOpenBrowser = (url) => {
|
|
194697
195170
|
try {
|
|
194698
195171
|
if (process.platform === "win32") {
|
|
194699
|
-
|
|
195172
|
+
import_node_child_process2.execFile("cmd", ["/c", "start", "", url], () => {
|
|
194700
195173
|
});
|
|
194701
195174
|
} else if (process.platform === "darwin") {
|
|
194702
|
-
|
|
195175
|
+
import_node_child_process2.execFile("open", [url], () => {
|
|
194703
195176
|
});
|
|
194704
195177
|
} else {
|
|
194705
|
-
|
|
195178
|
+
import_node_child_process2.execFile("xdg-open", [url], () => {
|
|
194706
195179
|
});
|
|
194707
195180
|
}
|
|
194708
195181
|
} catch {
|
|
@@ -194735,8 +195208,8 @@ var appendPieCredentialsToEnv = (cwd, config) => {
|
|
|
194735
195208
|
if (Object.keys(entries).length === 0) {
|
|
194736
195209
|
return;
|
|
194737
195210
|
}
|
|
194738
|
-
const envPath =
|
|
194739
|
-
let content =
|
|
195211
|
+
const envPath = import_node_path8.default.join(cwd, ".env");
|
|
195212
|
+
let content = import_node_fs7.default.existsSync(envPath) ? import_node_fs7.default.readFileSync(envPath, "utf8") : "";
|
|
194740
195213
|
if (content.length > 0 && !content.endsWith(`
|
|
194741
195214
|
`)) {
|
|
194742
195215
|
content += `
|
|
@@ -194746,7 +195219,7 @@ var appendPieCredentialsToEnv = (cwd, config) => {
|
|
|
194746
195219
|
content += `${additions.join(`
|
|
194747
195220
|
`)}
|
|
194748
195221
|
`;
|
|
194749
|
-
|
|
195222
|
+
import_node_fs7.default.writeFileSync(envPath, content, "utf8");
|
|
194750
195223
|
console.log(`[pie] Appended credentials to ${envPath}`);
|
|
194751
195224
|
};
|
|
194752
195225
|
async function loginCommand(options = {}) {
|
|
@@ -194768,8 +195241,8 @@ async function loginCommand(options = {}) {
|
|
|
194768
195241
|
openBrowser(connectUrl);
|
|
194769
195242
|
} catch {
|
|
194770
195243
|
}
|
|
194771
|
-
const pieDir =
|
|
194772
|
-
const configPath =
|
|
195244
|
+
const pieDir = import_node_path8.default.join(cwd, ".pie");
|
|
195245
|
+
const configPath = import_node_path8.default.join(pieDir, "config.json");
|
|
194773
195246
|
const url = `${credentialsApi}?${new URLSearchParams({ code }).toString()}`;
|
|
194774
195247
|
let first = true;
|
|
194775
195248
|
while (true) {
|
|
@@ -194802,8 +195275,8 @@ async function loginCommand(options = {}) {
|
|
|
194802
195275
|
if (!("config" in record)) {
|
|
194803
195276
|
throw new Error("Login succeeded but response had no 'config' field");
|
|
194804
195277
|
}
|
|
194805
|
-
|
|
194806
|
-
|
|
195278
|
+
import_node_fs7.default.mkdirSync(pieDir, { recursive: true });
|
|
195279
|
+
import_node_fs7.default.writeFileSync(configPath, `${JSON.stringify(record.config, null, 2)}
|
|
194807
195280
|
`, "utf8");
|
|
194808
195281
|
console.log(`[pie] Saved credentials to ${configPath}`);
|
|
194809
195282
|
appendPieCredentialsToEnv(cwd, record.config);
|
|
@@ -194813,7 +195286,22 @@ async function loginCommand(options = {}) {
|
|
|
194813
195286
|
}
|
|
194814
195287
|
|
|
194815
195288
|
// src/cli.ts
|
|
195289
|
+
var requireName = (value2, label) => {
|
|
195290
|
+
if (!value2) {
|
|
195291
|
+
console.error(`[pieui] Error: ${label} is required`);
|
|
195292
|
+
printUsage();
|
|
195293
|
+
process.exit(1);
|
|
195294
|
+
}
|
|
195295
|
+
return value2;
|
|
195296
|
+
};
|
|
194816
195297
|
var main = async () => {
|
|
195298
|
+
const rawArgs = process.argv.slice(2);
|
|
195299
|
+
const helpScope = detectHelpScope(rawArgs);
|
|
195300
|
+
if (helpScope) {
|
|
195301
|
+
printUsage(helpScope);
|
|
195302
|
+
return;
|
|
195303
|
+
}
|
|
195304
|
+
const args = parseArgs(rawArgs);
|
|
194817
195305
|
const {
|
|
194818
195306
|
command,
|
|
194819
195307
|
outDir,
|
|
@@ -194822,57 +195310,98 @@ var main = async () => {
|
|
|
194822
195310
|
componentName,
|
|
194823
195311
|
createAppName,
|
|
194824
195312
|
componentType,
|
|
194825
|
-
removeComponentName,
|
|
194826
195313
|
listFilter,
|
|
194827
195314
|
eventName,
|
|
194828
195315
|
cardAction,
|
|
194829
195316
|
cardAjax,
|
|
194830
195317
|
cardIo,
|
|
194831
195318
|
cardRemoteAction,
|
|
195319
|
+
cardPullRef,
|
|
194832
195320
|
remoteUserId,
|
|
194833
195321
|
remoteProject,
|
|
194834
195322
|
pageAction,
|
|
194835
195323
|
pagePath,
|
|
195324
|
+
pageName,
|
|
195325
|
+
pageAjaxAction,
|
|
195326
|
+
pageAjaxHandler,
|
|
194836
195327
|
historyPage,
|
|
194837
195328
|
historyPerPage,
|
|
194838
195329
|
historyFrom,
|
|
194839
195330
|
historyTo
|
|
194840
|
-
} =
|
|
195331
|
+
} = args;
|
|
194841
195332
|
console.log(`[pieui] CLI started with command: "${command}"`);
|
|
194842
195333
|
switch (command) {
|
|
194843
195334
|
case "init":
|
|
194844
|
-
initCommand(outDir);
|
|
195335
|
+
await initCommand(outDir);
|
|
194845
195336
|
return;
|
|
194846
|
-
case "create":
|
|
194847
|
-
|
|
194848
|
-
|
|
194849
|
-
printUsage();
|
|
194850
|
-
process.exit(1);
|
|
194851
|
-
}
|
|
194852
|
-
createCommand(createAppName);
|
|
195337
|
+
case "create": {
|
|
195338
|
+
const name = requireName(createAppName, "App name");
|
|
195339
|
+
await createCommand(name);
|
|
194853
195340
|
return;
|
|
195341
|
+
}
|
|
194854
195342
|
case "create-pie-app":
|
|
194855
|
-
case "create-pieui":
|
|
194856
|
-
|
|
194857
|
-
|
|
195343
|
+
case "create-pieui": {
|
|
195344
|
+
const name = requireName(createAppName, "App name");
|
|
195345
|
+
createPieAppCommand(name);
|
|
195346
|
+
return;
|
|
195347
|
+
}
|
|
195348
|
+
case "login":
|
|
195349
|
+
await loginCommand();
|
|
195350
|
+
return;
|
|
195351
|
+
case "postbuild":
|
|
195352
|
+
console.log(`[pieui] Source directory: ${import_node_path9.default.resolve(process.cwd(), srcDir)}`);
|
|
195353
|
+
console.log(`[pieui] Output directory: ${import_node_path9.default.resolve(process.cwd(), outDir)}`);
|
|
195354
|
+
console.log(`[pieui] Append mode: ${append}`);
|
|
195355
|
+
await postbuildCommand(srcDir, outDir, append);
|
|
195356
|
+
return;
|
|
195357
|
+
case "card": {
|
|
195358
|
+
if (!cardAction) {
|
|
195359
|
+
console.error("[pieui] Error: Supported card subcommands: add, list, pull, view, remove, list-events, add-event, remote");
|
|
194858
195360
|
printUsage();
|
|
194859
195361
|
process.exit(1);
|
|
194860
195362
|
}
|
|
194861
|
-
createPieAppCommand(createAppName);
|
|
194862
|
-
return;
|
|
194863
|
-
case "card":
|
|
194864
195363
|
if (cardAction === "add") {
|
|
194865
|
-
|
|
194866
|
-
|
|
194867
|
-
printUsage();
|
|
194868
|
-
process.exit(1);
|
|
194869
|
-
}
|
|
194870
|
-
addCommand(componentName, componentType, {
|
|
195364
|
+
const name = requireName(componentName, "Component name");
|
|
195365
|
+
addCommand(name, componentType, {
|
|
194871
195366
|
ajax: cardAjax,
|
|
194872
195367
|
io: cardIo
|
|
194873
195368
|
});
|
|
194874
195369
|
return;
|
|
194875
195370
|
}
|
|
195371
|
+
if (cardAction === "list") {
|
|
195372
|
+
listCommand(srcDir, listFilter || "all");
|
|
195373
|
+
return;
|
|
195374
|
+
}
|
|
195375
|
+
if (cardAction === "pull") {
|
|
195376
|
+
const ref = requireName(cardPullRef, "Card reference");
|
|
195377
|
+
await cardPullCommand(ref);
|
|
195378
|
+
return;
|
|
195379
|
+
}
|
|
195380
|
+
if (cardAction === "view") {
|
|
195381
|
+
const name = requireName(componentName, "Component name");
|
|
195382
|
+
cardViewCommand(name);
|
|
195383
|
+
return;
|
|
195384
|
+
}
|
|
195385
|
+
if (cardAction === "remove") {
|
|
195386
|
+
const name = requireName(componentName, "Component name");
|
|
195387
|
+
removeCommand(name);
|
|
195388
|
+
return;
|
|
195389
|
+
}
|
|
195390
|
+
if (cardAction === "list-events") {
|
|
195391
|
+
const name = requireName(componentName, "Component name");
|
|
195392
|
+
listEventsCommand(srcDir, name);
|
|
195393
|
+
return;
|
|
195394
|
+
}
|
|
195395
|
+
if (cardAction === "add-event") {
|
|
195396
|
+
const name = requireName(componentName, "Component name");
|
|
195397
|
+
if (!eventName) {
|
|
195398
|
+
console.error("[pieui] Error: Event name is required");
|
|
195399
|
+
printUsage();
|
|
195400
|
+
process.exit(1);
|
|
195401
|
+
}
|
|
195402
|
+
addEventCommand(srcDir, name, eventName);
|
|
195403
|
+
return;
|
|
195404
|
+
}
|
|
194876
195405
|
if (cardAction === "remote") {
|
|
194877
195406
|
if (cardRemoteAction === "list") {
|
|
194878
195407
|
await cardRemoteListCommand({
|
|
@@ -194881,26 +195410,22 @@ var main = async () => {
|
|
|
194881
195410
|
});
|
|
194882
195411
|
return;
|
|
194883
195412
|
}
|
|
194884
|
-
|
|
194885
|
-
console.error(`[pieui] Error: Component name is required for card remote ${cardRemoteAction ?? ""} command`);
|
|
194886
|
-
printUsage();
|
|
194887
|
-
process.exit(1);
|
|
194888
|
-
}
|
|
195413
|
+
const name = requireName(componentName, `Component name (for card remote ${cardRemoteAction ?? ""})`);
|
|
194889
195414
|
if (cardRemoteAction === "push") {
|
|
194890
|
-
await cardRemotePushCommand(
|
|
195415
|
+
await cardRemotePushCommand(name);
|
|
194891
195416
|
return;
|
|
194892
195417
|
}
|
|
194893
195418
|
if (cardRemoteAction === "pull") {
|
|
194894
|
-
await cardRemotePullCommand(
|
|
195419
|
+
await cardRemotePullCommand(name);
|
|
194895
195420
|
return;
|
|
194896
195421
|
}
|
|
194897
195422
|
if (cardRemoteAction === "remove") {
|
|
194898
|
-
await cardRemoteRemoveCommand(
|
|
195423
|
+
await cardRemoteRemoveCommand(name);
|
|
194899
195424
|
return;
|
|
194900
195425
|
}
|
|
194901
195426
|
if (cardRemoteAction === "history") {
|
|
194902
195427
|
await cardRemoteHistoryCommand({
|
|
194903
|
-
componentName,
|
|
195428
|
+
componentName: name,
|
|
194904
195429
|
page: historyPage,
|
|
194905
195430
|
perPage: historyPerPage,
|
|
194906
195431
|
from: historyFrom,
|
|
@@ -194909,80 +195434,48 @@ var main = async () => {
|
|
|
194909
195434
|
return;
|
|
194910
195435
|
}
|
|
194911
195436
|
if (cardRemoteAction === "public") {
|
|
194912
|
-
await cardRemotePublicCommand(
|
|
195437
|
+
await cardRemotePublicCommand(name);
|
|
194913
195438
|
return;
|
|
194914
195439
|
}
|
|
194915
195440
|
if (cardRemoteAction === "private") {
|
|
194916
|
-
await cardRemotePrivateCommand(
|
|
195441
|
+
await cardRemotePrivateCommand(name);
|
|
194917
195442
|
return;
|
|
194918
195443
|
}
|
|
194919
|
-
console.error("[pieui] Error: Supported card remote subcommands: push, pull,
|
|
194920
|
-
printUsage();
|
|
194921
|
-
process.exit(1);
|
|
194922
|
-
}
|
|
194923
|
-
console.error("[pieui] Error: Supported card subcommands: add, remote");
|
|
194924
|
-
printUsage();
|
|
194925
|
-
process.exit(1);
|
|
194926
|
-
case "add":
|
|
194927
|
-
if (!componentName) {
|
|
194928
|
-
console.error("[pieui] Error: Component name is required for card add command");
|
|
195444
|
+
console.error("[pieui] Error: Supported card remote subcommands: list, push, pull, remove, history, public, private");
|
|
194929
195445
|
printUsage();
|
|
194930
195446
|
process.exit(1);
|
|
194931
195447
|
}
|
|
194932
|
-
addCommand(componentName, componentType, {
|
|
194933
|
-
ajax: cardAjax,
|
|
194934
|
-
io: cardIo
|
|
194935
|
-
});
|
|
194936
195448
|
return;
|
|
194937
|
-
|
|
194938
|
-
|
|
194939
|
-
|
|
194940
|
-
|
|
194941
|
-
process.exit(1);
|
|
194942
|
-
}
|
|
194943
|
-
if (!pagePath) {
|
|
194944
|
-
console.error("[pieui] Error: Path is required for page add command");
|
|
195449
|
+
}
|
|
195450
|
+
case "page": {
|
|
195451
|
+
if (!pageAction) {
|
|
195452
|
+
console.error("[pieui] Error: Supported page subcommands: add, view, ajax");
|
|
194945
195453
|
printUsage();
|
|
194946
195454
|
process.exit(1);
|
|
194947
195455
|
}
|
|
194948
|
-
|
|
194949
|
-
|
|
194950
|
-
|
|
194951
|
-
|
|
194952
|
-
console.error("[pieui] Error: Component name is required for remove command");
|
|
194953
|
-
printUsage();
|
|
194954
|
-
process.exit(1);
|
|
195456
|
+
if (pageAction === "add") {
|
|
195457
|
+
const p = requireName(pagePath, "Path");
|
|
195458
|
+
pageAddCommand(p);
|
|
195459
|
+
return;
|
|
194955
195460
|
}
|
|
194956
|
-
|
|
194957
|
-
|
|
194958
|
-
|
|
194959
|
-
|
|
194960
|
-
return;
|
|
194961
|
-
case "list-events":
|
|
194962
|
-
if (!componentName) {
|
|
194963
|
-
console.error("[pieui] Error: Component name is required for list-events command");
|
|
194964
|
-
printUsage();
|
|
194965
|
-
process.exit(1);
|
|
195461
|
+
if (pageAction === "view") {
|
|
195462
|
+
const name = requireName(pageName, "Path");
|
|
195463
|
+
pageViewCommand(name);
|
|
195464
|
+
return;
|
|
194966
195465
|
}
|
|
194967
|
-
|
|
194968
|
-
|
|
194969
|
-
|
|
194970
|
-
|
|
194971
|
-
|
|
194972
|
-
|
|
194973
|
-
|
|
195466
|
+
if (pageAction === "ajax") {
|
|
195467
|
+
const name = requireName(pageName, "Page name");
|
|
195468
|
+
if (!pageAjaxAction) {
|
|
195469
|
+
console.error("[pieui] Error: page ajax action must be `add` or `remove`");
|
|
195470
|
+
printUsage();
|
|
195471
|
+
process.exit(1);
|
|
195472
|
+
}
|
|
195473
|
+
const handler = requireName(pageAjaxHandler, "Handler name");
|
|
195474
|
+
pageAjaxCommand(name, pageAjaxAction, handler);
|
|
195475
|
+
return;
|
|
194974
195476
|
}
|
|
194975
|
-
addEventCommand(srcDir, componentName, eventName);
|
|
194976
|
-
return;
|
|
194977
|
-
case "postbuild":
|
|
194978
|
-
console.log(`[pieui] Source directory: ${srcDir}`);
|
|
194979
|
-
console.log(`[pieui] Output directory: ${outDir}`);
|
|
194980
|
-
console.log(`[pieui] Append mode: ${append}`);
|
|
194981
|
-
await postbuildCommand(srcDir, outDir, append);
|
|
194982
|
-
return;
|
|
194983
|
-
case "login":
|
|
194984
|
-
await loginCommand();
|
|
194985
195477
|
return;
|
|
195478
|
+
}
|
|
194986
195479
|
default:
|
|
194987
195480
|
printUsage();
|
|
194988
195481
|
process.exit(1);
|