appstage 0.2.4 → 0.2.5

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/bin.js CHANGED
@@ -332,7 +332,8 @@ function toImportPath(relativePath, referencePath = ".") {
332
332
  }
333
333
 
334
334
  // src/scripts/utils/populateEntries.ts
335
- async function populateEntries() {
335
+ async function populateEntries({ entriesPath }) {
336
+ if (entriesPath === null) return;
336
337
  let serverEntries = await getEntryPoints(["server", "server/index"]);
337
338
  let content = "";
338
339
  if (serverEntries.length === 0) content = "export const entries = [];";
@@ -346,7 +347,7 @@ async function populateEntries() {
346
347
  content += "\n ])\n).map(({ server }) => server);";
347
348
  }
348
349
  await writeFile(
349
- "src/server/autoentries.ts",
350
+ entriesPath ?? "src/server/entries.ts",
350
351
  `// Populated automatically during the build phase by picking
351
352
  // all server exports from "src/entries/<entry_name>/server(/index)?.(js|ts)"
352
353
  ${content}
@@ -355,8 +356,9 @@ ${content}
355
356
  }
356
357
 
357
358
  // src/scripts/utils/buildServer.ts
358
- async function buildServer({ targetDir, watch, watchServer }, plugins) {
359
- await populateEntries();
359
+ async function buildServer(params, plugins) {
360
+ let { targetDir, watch, watchServer } = params;
361
+ await populateEntries(params);
360
362
  let buildOptions = {
361
363
  ...commonBuildOptions,
362
364
  entryPoints: ["src/server/index.ts"],
@@ -520,6 +522,7 @@ async function cli(args = []) {
520
522
  watchClient: args.includes("--watch-client"),
521
523
  start: args.includes("--start")
522
524
  };
525
+ if (args.includes("--no-auto-entries")) params.entriesPath = null;
523
526
  if (args.includes("--clean-only")) {
524
527
  await clean(params);
525
528
  return;
@@ -542,7 +545,7 @@ async function run() {
542
545
  }
543
546
  if (scriptName === "build") return await cli(args);
544
547
  let nodeEnv = nodeEnvMap[scriptName];
545
- let host = args[0];
548
+ let host = args.shift();
546
549
  if (nodeEnv !== void 0) process.env.NODE_ENV = nodeEnv;
547
550
  if (host) {
548
551
  let [hostname, port] = host.split(":");
@@ -550,7 +553,7 @@ async function run() {
550
553
  if (port) process.env.APP_PORT = port;
551
554
  }
552
555
  await cli(
553
- nodeEnv === "development" ? ["src/public", "--clean", "--start", "--watch"] : ["src/public", "--clean", "--start", "--silent"]
556
+ nodeEnv === "development" ? ["src/public", "--clean", "--start", "--watch", ...args] : ["src/public", "--clean", "--start", "--silent", ...args]
554
557
  );
555
558
  }
556
559
  await run();
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
 
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) {
14
- __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- }
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
20
16
  }
21
17
  return to;
22
18
  };
@@ -402,7 +398,8 @@ function toImportPath(relativePath, referencePath = ".") {
402
398
  return importPath;
403
399
  }
404
400
 
405
- async function populateEntries() {
401
+ async function populateEntries({ entriesPath }) {
402
+ if (entriesPath === null) return;
406
403
  let serverEntries = await getEntryPoints(["server", "server/index"]);
407
404
  let content = "";
408
405
  if (serverEntries.length === 0) content = "export const entries = [];";
@@ -412,14 +409,15 @@ async function populateEntries() {
412
409
  import("${toImportPath(serverEntries[i].path, "src/server")}"),`;
413
410
  content += "\n ])\n).map(({ server }) => server);";
414
411
  }
415
- await (0, node_fs_promises.writeFile)("src/server/autoentries.ts", `// Populated automatically during the build phase by picking
412
+ await (0, node_fs_promises.writeFile)(entriesPath ?? "src/server/entries.ts", `// Populated automatically during the build phase by picking
416
413
  // all server exports from "src/entries/<entry_name>/server(/index)?.(js|ts)"
417
414
  ${content}
418
415
  `);
419
416
  }
420
417
 
421
- async function buildServer({ targetDir, watch, watchServer }, plugins) {
422
- await populateEntries();
418
+ async function buildServer(params, plugins) {
419
+ let { targetDir, watch, watchServer } = params;
420
+ await populateEntries(params);
423
421
  let buildOptions = {
424
422
  ...commonBuildOptions,
425
423
  entryPoints: ["src/server/index.ts"],
@@ -559,6 +557,7 @@ async function cli(args = []) {
559
557
  watchClient: args.includes("--watch-client"),
560
558
  start: args.includes("--start")
561
559
  };
560
+ if (args.includes("--no-auto-entries")) params.entriesPath = null;
562
561
  if (args.includes("--clean-only")) {
563
562
  await clean(params);
564
563
  return;
@@ -578,7 +577,7 @@ function createApp(callback) {
578
577
  let app = (0, express.default)();
579
578
  if (!app.events) app.events = new node_events.default();
580
579
  let host = process.env.APP_HOST || "localhost";
581
- let port = Number(process.env.APP_PORT) || 80;
580
+ let port = Number(process.env.APP_PORT) || 3e3;
582
581
  let listen = () => {
583
582
  app.listen(port, host, () => {
584
583
  emitLog(app, `Server running at ${`http://${host}:${port}/`} (${`NODE_ENV=${process.env.NODE_ENV}`})`);
package/dist/index.d.ts CHANGED
@@ -138,6 +138,15 @@ type BuildParams = {
138
138
  watchClient?: boolean;
139
139
  watchServer?: boolean;
140
140
  start?: boolean;
141
+ /**
142
+ * A file path that the automatically picked entry exports will be
143
+ * written to.
144
+ *
145
+ * Set it to `null` to skip the automatic picking of entry exports.
146
+ *
147
+ * @default "src/server/entries.ts"
148
+ */
149
+ entriesPath?: string | null;
141
150
  };
142
151
 
143
152
  declare function build(params: BuildParams): Promise<void>;
package/dist/index.mjs CHANGED
@@ -372,7 +372,8 @@ function toImportPath(relativePath, referencePath = ".") {
372
372
  return importPath;
373
373
  }
374
374
 
375
- async function populateEntries() {
375
+ async function populateEntries({ entriesPath }) {
376
+ if (entriesPath === null) return;
376
377
  let serverEntries = await getEntryPoints(["server", "server/index"]);
377
378
  let content = "";
378
379
  if (serverEntries.length === 0) content = "export const entries = [];";
@@ -382,14 +383,15 @@ async function populateEntries() {
382
383
  import("${toImportPath(serverEntries[i].path, "src/server")}"),`;
383
384
  content += "\n ])\n).map(({ server }) => server);";
384
385
  }
385
- await writeFile("src/server/autoentries.ts", `// Populated automatically during the build phase by picking
386
+ await writeFile(entriesPath ?? "src/server/entries.ts", `// Populated automatically during the build phase by picking
386
387
  // all server exports from "src/entries/<entry_name>/server(/index)?.(js|ts)"
387
388
  ${content}
388
389
  `);
389
390
  }
390
391
 
391
- async function buildServer({ targetDir, watch, watchServer }, plugins) {
392
- await populateEntries();
392
+ async function buildServer(params, plugins) {
393
+ let { targetDir, watch, watchServer } = params;
394
+ await populateEntries(params);
393
395
  let buildOptions = {
394
396
  ...commonBuildOptions,
395
397
  entryPoints: ["src/server/index.ts"],
@@ -529,6 +531,7 @@ async function cli(args = []) {
529
531
  watchClient: args.includes("--watch-client"),
530
532
  start: args.includes("--start")
531
533
  };
534
+ if (args.includes("--no-auto-entries")) params.entriesPath = null;
532
535
  if (args.includes("--clean-only")) {
533
536
  await clean(params);
534
537
  return;
@@ -548,7 +551,7 @@ function createApp(callback) {
548
551
  let app = express();
549
552
  if (!app.events) app.events = new EventEmitter();
550
553
  let host = process.env.APP_HOST || "localhost";
551
- let port = Number(process.env.APP_PORT) || 80;
554
+ let port = Number(process.env.APP_PORT) || 3e3;
552
555
  let listen = () => {
553
556
  app.listen(port, host, () => {
554
557
  emitLog(app, `Server running at ${`http://${host}:${port}/`} (${`NODE_ENV=${process.env.NODE_ENV}`})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appstage",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -19,7 +19,7 @@ async function run() {
19
19
  if (scriptName === "build") return await cli(args);
20
20
 
21
21
  let nodeEnv = nodeEnvMap[scriptName];
22
- let host = args[0];
22
+ let host = args.shift();
23
23
 
24
24
  if (nodeEnv !== undefined) process.env.NODE_ENV = nodeEnv;
25
25
 
@@ -32,8 +32,8 @@ async function run() {
32
32
 
33
33
  await cli(
34
34
  nodeEnv === "development"
35
- ? ["src/public", "--clean", "--start", "--watch"]
36
- : ["src/public", "--clean", "--start", "--silent"],
35
+ ? ["src/public", "--clean", "--start", "--watch", ...args]
36
+ : ["src/public", "--clean", "--start", "--silent", ...args],
37
37
  );
38
38
  }
39
39
 
@@ -35,6 +35,8 @@ export async function cli(args: string[] = []) {
35
35
  start: args.includes("--start"),
36
36
  };
37
37
 
38
+ if (args.includes("--no-auto-entries")) params.entriesPath = null;
39
+
38
40
  if (args.includes("--clean-only")) {
39
41
  await clean(params);
40
42
  return;
@@ -6,4 +6,13 @@ export type BuildParams = {
6
6
  watchClient?: boolean;
7
7
  watchServer?: boolean;
8
8
  start?: boolean;
9
+ /**
10
+ * A file path that the automatically picked entry exports will be
11
+ * written to.
12
+ *
13
+ * Set it to `null` to skip the automatic picking of entry exports.
14
+ *
15
+ * @default "src/server/entries.ts"
16
+ */
17
+ entriesPath?: string | null;
9
18
  };
@@ -3,11 +3,10 @@ import { commonBuildOptions } from "../const/commonBuildOptions.ts";
3
3
  import type { BuildParams } from "../types/BuildParams.ts";
4
4
  import { populateEntries } from "./populateEntries.ts";
5
5
 
6
- export async function buildServer(
7
- { targetDir, watch, watchServer }: BuildParams,
8
- plugins?: Plugin[],
9
- ) {
10
- await populateEntries();
6
+ export async function buildServer(params: BuildParams, plugins?: Plugin[]) {
7
+ let { targetDir, watch, watchServer } = params;
8
+
9
+ await populateEntries(params);
11
10
 
12
11
  let buildOptions: BuildOptions = {
13
12
  ...commonBuildOptions,
@@ -1,8 +1,11 @@
1
1
  import { writeFile } from "node:fs/promises";
2
+ import type { BuildParams } from "../types/BuildParams.ts";
2
3
  import { getEntryPoints } from "./getEntryPoints.ts";
3
4
  import { toImportPath } from "./toImportPath.ts";
4
5
 
5
- export async function populateEntries() {
6
+ export async function populateEntries({ entriesPath }: BuildParams) {
7
+ if (entriesPath === null) return;
8
+
6
9
  let serverEntries = await getEntryPoints(["server", "server/index"]);
7
10
  let content = "";
8
11
 
@@ -19,7 +22,7 @@ export async function populateEntries() {
19
22
  }
20
23
 
21
24
  await writeFile(
22
- "src/server/autoentries.ts",
25
+ entriesPath ?? "src/server/entries.ts",
23
26
  `// Populated automatically during the build phase by picking
24
27
  // all server exports from "src/entries/<entry_name>/server(/index)?.(js|ts)"
25
28
  ${content}
@@ -13,7 +13,7 @@ export function createApp(callback?: () => void | Promise<void>) {
13
13
  if (!app.events) app.events = new EventEmitter();
14
14
 
15
15
  let host = process.env.APP_HOST || "localhost";
16
- let port = Number(process.env.APP_PORT) || 80;
16
+ let port = Number(process.env.APP_PORT) || 3000;
17
17
 
18
18
  let listen = () => {
19
19
  app.listen(port, host, () => {