@cedarjs/api-server 1.0.0-canary.12776 → 1.0.0-canary.12777

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.
@@ -1,2 +1,7 @@
1
- export {};
1
+ /**
2
+ * Initialize the file watcher for the API server
3
+ * Watches for changes in the API source directory and rebuilds/restarts as
4
+ * needed
5
+ */
6
+ export declare function startWatch(): void;
2
7
  //# sourceMappingURL=watch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/watch.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/watch.ts"],"names":[],"mappings":"AAgFA;;;;GAIG;AACH,wBAAgB,UAAU,SAiEzB"}
package/dist/cjs/watch.js CHANGED
@@ -6,6 +6,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
9
13
  var __copyProps = (to, from, except, desc) => {
10
14
  if (from && typeof from === "object" || typeof from === "function") {
11
15
  for (let key of __getOwnPropNames(from))
@@ -22,8 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
27
  mod
24
28
  ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
30
 
26
31
  // src/watch.ts
32
+ var watch_exports = {};
33
+ __export(watch_exports, {
34
+ startWatch: () => startWatch
35
+ });
36
+ module.exports = __toCommonJS(watch_exports);
27
37
  var import_path2 = __toESM(require("path"), 1);
28
38
  var import_ansis2 = __toESM(require("ansis"), 1);
29
39
  var import_chokidar = __toESM(require("chokidar"), 1);
@@ -202,11 +212,11 @@ var ServerManager = class {
202
212
  var serverManager = new ServerManager();
203
213
 
204
214
  // src/watch.ts
205
- var rwjsPaths2 = (0, import_project_config2.getPaths)();
215
+ var cedarPaths = (0, import_project_config2.getPaths)();
206
216
  if (!process.env.REDWOOD_ENV_FILES_LOADED) {
207
217
  (0, import_dotenv_defaults.config)({
208
- path: import_path2.default.join(rwjsPaths2.base, ".env"),
209
- defaults: import_path2.default.join(rwjsPaths2.base, ".env.defaults"),
218
+ path: import_path2.default.join(cedarPaths.base, ".env"),
219
+ defaults: import_path2.default.join(cedarPaths.base, ".env.defaults"),
210
220
  multiline: true
211
221
  });
212
222
  process.env.REDWOOD_ENV_FILES_LOADED = "true";
@@ -244,49 +254,58 @@ async function validateSdls() {
244
254
  var IGNORED_API_PATHS = [
245
255
  "api/dist",
246
256
  // use this, because using rwjsPaths.api.dist seems to not ignore on first build
247
- rwjsPaths2.api.types,
248
- rwjsPaths2.api.db
257
+ cedarPaths.api.types,
258
+ cedarPaths.api.db
249
259
  ].map((path3) => (0, import_project_config2.ensurePosixPath)(path3));
250
- import_chokidar.default.watch([rwjsPaths2.api.src], {
251
- persistent: true,
252
- ignoreInitial: true,
253
- ignored: (file) => {
254
- const x = file.includes("node_modules") || IGNORED_API_PATHS.some((ignoredPath) => file.includes(ignoredPath)) || [
255
- ".DS_Store",
256
- ".db",
257
- ".sqlite",
258
- "-journal",
259
- ".test.js",
260
- ".test.ts",
261
- ".scenarios.ts",
262
- ".scenarios.js",
263
- ".d.ts",
264
- ".log"
265
- ].some((ext) => file.endsWith(ext));
266
- return x;
267
- }
268
- }).on("ready", async () => {
269
- await buildManager.run({ clean: true, rebuild: false });
270
- await validateSdls();
271
- }).on("all", async (eventName, filePath) => {
272
- if (eventName === "addDir" && filePath === rwjsPaths2.api.base) {
273
- return;
274
- }
275
- if (eventName) {
276
- if (filePath.includes(".sdl")) {
277
- const isValid = await validateSdls();
278
- if (!isValid) {
279
- return;
260
+ function startWatch() {
261
+ const watcher = import_chokidar.default.watch([cedarPaths.api.src], {
262
+ persistent: true,
263
+ ignoreInitial: true,
264
+ ignored: (file) => {
265
+ const x = file.includes("node_modules") || IGNORED_API_PATHS.some((ignoredPath) => file.includes(ignoredPath)) || [
266
+ ".DS_Store",
267
+ ".db",
268
+ ".sqlite",
269
+ "-journal",
270
+ ".test.js",
271
+ ".test.ts",
272
+ ".scenarios.ts",
273
+ ".scenarios.js",
274
+ ".d.ts",
275
+ ".log"
276
+ ].some((ext) => file.endsWith(ext));
277
+ return x;
278
+ }
279
+ });
280
+ watcher.on("ready", async () => {
281
+ await buildManager.run({ clean: true, rebuild: false });
282
+ await validateSdls();
283
+ });
284
+ watcher.on("all", async (eventName, filePath) => {
285
+ if (eventName === "addDir" && filePath === cedarPaths.api.base) {
286
+ return;
287
+ }
288
+ if (eventName) {
289
+ if (filePath.includes(".sdl")) {
290
+ const isValid = await validateSdls();
291
+ if (!isValid) {
292
+ return;
293
+ }
280
294
  }
281
295
  }
282
- }
283
- console.log(
284
- import_ansis2.default.dim(`[${eventName}] ${filePath.replace(rwjsPaths2.api.base, "")}`)
285
- );
286
- buildManager.cancelScheduledBuild();
287
- if (eventName === "add" || eventName === "unlink") {
288
- await buildManager.run({ rebuild: false });
289
- } else {
290
- await buildManager.run({ rebuild: true });
291
- }
296
+ console.log(
297
+ import_ansis2.default.dim(`[${eventName}] ${filePath.replace(cedarPaths.api.base, "")}`)
298
+ );
299
+ buildManager.cancelScheduledBuild();
300
+ if (eventName === "add" || eventName === "unlink") {
301
+ await buildManager.run({ rebuild: false });
302
+ } else {
303
+ await buildManager.run({ rebuild: true });
304
+ }
305
+ });
306
+ }
307
+ startWatch();
308
+ // Annotate the CommonJS export names for ESM import in node:
309
+ 0 && (module.exports = {
310
+ startWatch
292
311
  });
package/dist/watch.d.ts CHANGED
@@ -1,2 +1,7 @@
1
- export {};
1
+ /**
2
+ * Initialize the file watcher for the API server
3
+ * Watches for changes in the API source directory and rebuilds/restarts as
4
+ * needed
5
+ */
6
+ export declare function startWatch(): void;
2
7
  //# sourceMappingURL=watch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAgFA;;;;GAIG;AACH,wBAAgB,UAAU,SAiEzB"}
package/dist/watch.js CHANGED
@@ -183,11 +183,11 @@ var ServerManager = class {
183
183
  var serverManager = new ServerManager();
184
184
 
185
185
  // src/watch.ts
186
- var rwjsPaths2 = getPaths2();
186
+ var cedarPaths = getPaths2();
187
187
  if (!process.env.REDWOOD_ENV_FILES_LOADED) {
188
188
  config({
189
- path: path2.join(rwjsPaths2.base, ".env"),
190
- defaults: path2.join(rwjsPaths2.base, ".env.defaults"),
189
+ path: path2.join(cedarPaths.base, ".env"),
190
+ defaults: path2.join(cedarPaths.base, ".env.defaults"),
191
191
  multiline: true
192
192
  });
193
193
  process.env.REDWOOD_ENV_FILES_LOADED = "true";
@@ -225,49 +225,59 @@ async function validateSdls() {
225
225
  var IGNORED_API_PATHS = [
226
226
  "api/dist",
227
227
  // use this, because using rwjsPaths.api.dist seems to not ignore on first build
228
- rwjsPaths2.api.types,
229
- rwjsPaths2.api.db
228
+ cedarPaths.api.types,
229
+ cedarPaths.api.db
230
230
  ].map((path3) => ensurePosixPath(path3));
231
- chokidar.watch([rwjsPaths2.api.src], {
232
- persistent: true,
233
- ignoreInitial: true,
234
- ignored: (file) => {
235
- const x = file.includes("node_modules") || IGNORED_API_PATHS.some((ignoredPath) => file.includes(ignoredPath)) || [
236
- ".DS_Store",
237
- ".db",
238
- ".sqlite",
239
- "-journal",
240
- ".test.js",
241
- ".test.ts",
242
- ".scenarios.ts",
243
- ".scenarios.js",
244
- ".d.ts",
245
- ".log"
246
- ].some((ext) => file.endsWith(ext));
247
- return x;
248
- }
249
- }).on("ready", async () => {
250
- await buildManager.run({ clean: true, rebuild: false });
251
- await validateSdls();
252
- }).on("all", async (eventName, filePath) => {
253
- if (eventName === "addDir" && filePath === rwjsPaths2.api.base) {
254
- return;
255
- }
256
- if (eventName) {
257
- if (filePath.includes(".sdl")) {
258
- const isValid = await validateSdls();
259
- if (!isValid) {
260
- return;
231
+ function startWatch() {
232
+ const watcher = chokidar.watch([cedarPaths.api.src], {
233
+ persistent: true,
234
+ ignoreInitial: true,
235
+ ignored: (file) => {
236
+ const x = file.includes("node_modules") || IGNORED_API_PATHS.some((ignoredPath) => file.includes(ignoredPath)) || [
237
+ ".DS_Store",
238
+ ".db",
239
+ ".sqlite",
240
+ "-journal",
241
+ ".test.js",
242
+ ".test.ts",
243
+ ".scenarios.ts",
244
+ ".scenarios.js",
245
+ ".d.ts",
246
+ ".log"
247
+ ].some((ext) => file.endsWith(ext));
248
+ return x;
249
+ }
250
+ });
251
+ watcher.on("ready", async () => {
252
+ await buildManager.run({ clean: true, rebuild: false });
253
+ await validateSdls();
254
+ });
255
+ watcher.on("all", async (eventName, filePath) => {
256
+ if (eventName === "addDir" && filePath === cedarPaths.api.base) {
257
+ return;
258
+ }
259
+ if (eventName) {
260
+ if (filePath.includes(".sdl")) {
261
+ const isValid = await validateSdls();
262
+ if (!isValid) {
263
+ return;
264
+ }
261
265
  }
262
266
  }
263
- }
264
- console.log(
265
- ansis2.dim(`[${eventName}] ${filePath.replace(rwjsPaths2.api.base, "")}`)
266
- );
267
- buildManager.cancelScheduledBuild();
268
- if (eventName === "add" || eventName === "unlink") {
269
- await buildManager.run({ rebuild: false });
270
- } else {
271
- await buildManager.run({ rebuild: true });
272
- }
273
- });
267
+ console.log(
268
+ ansis2.dim(`[${eventName}] ${filePath.replace(cedarPaths.api.base, "")}`)
269
+ );
270
+ buildManager.cancelScheduledBuild();
271
+ if (eventName === "add" || eventName === "unlink") {
272
+ await buildManager.run({ rebuild: false });
273
+ } else {
274
+ await buildManager.run({ rebuild: true });
275
+ }
276
+ });
277
+ }
278
+ if (import.meta.url === `file://${process.argv[1]}`) {
279
+ startWatch();
280
+ }
281
+ export {
282
+ startWatch
283
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api-server",
3
- "version": "1.0.0-canary.12776+9a00e73eb",
3
+ "version": "1.0.0-canary.12777+8004fc8b8",
4
4
  "description": "CedarJS's HTTP server for Serverless Functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -68,6 +68,16 @@
68
68
  "./cjs/cliHelpers": {
69
69
  "types": "./dist/cjs/cliHelpers.d.ts",
70
70
  "default": "./dist/cjs/cliHelpers.js"
71
+ },
72
+ "./watch": {
73
+ "import": {
74
+ "types": "./dist/watch.d.ts",
75
+ "default": "./dist/watch.js"
76
+ },
77
+ "require": {
78
+ "types": "./dist/cjs/watch.d.ts",
79
+ "default": "./dist/cjs/watch.js"
80
+ }
71
81
  }
72
82
  },
73
83
  "main": "./dist/createServer.js",
@@ -97,11 +107,11 @@
97
107
  "test:watch": "vitest watch"
98
108
  },
99
109
  "dependencies": {
100
- "@cedarjs/context": "1.0.0-canary.12776",
101
- "@cedarjs/fastify-web": "1.0.0-canary.12776",
102
- "@cedarjs/internal": "1.0.0-canary.12776",
103
- "@cedarjs/project-config": "1.0.0-canary.12776",
104
- "@cedarjs/web-server": "1.0.0-canary.12776",
110
+ "@cedarjs/context": "1.0.0-canary.12777",
111
+ "@cedarjs/fastify-web": "1.0.0-canary.12777",
112
+ "@cedarjs/internal": "1.0.0-canary.12777",
113
+ "@cedarjs/project-config": "1.0.0-canary.12777",
114
+ "@cedarjs/web-server": "1.0.0-canary.12777",
105
115
  "@fastify/multipart": "9.0.3",
106
116
  "@fastify/url-data": "6.0.3",
107
117
  "ansis": "4.1.0",
@@ -118,7 +128,7 @@
118
128
  "yargs": "17.7.2"
119
129
  },
120
130
  "devDependencies": {
121
- "@cedarjs/framework-tools": "1.0.0-canary.12776",
131
+ "@cedarjs/framework-tools": "1.0.0-canary.12777",
122
132
  "@types/aws-lambda": "8.10.152",
123
133
  "@types/dotenv-defaults": "^2.0.4",
124
134
  "@types/qs": "6.9.16",
@@ -131,7 +141,7 @@
131
141
  "vitest": "3.2.4"
132
142
  },
133
143
  "peerDependencies": {
134
- "@cedarjs/graphql-server": "1.0.0-canary.12776"
144
+ "@cedarjs/graphql-server": "1.0.0-canary.12777"
135
145
  },
136
146
  "peerDependenciesMeta": {
137
147
  "@cedarjs/graphql-server": {
@@ -141,5 +151,5 @@
141
151
  "publishConfig": {
142
152
  "access": "public"
143
153
  },
144
- "gitHead": "9a00e73eb84031d9978bec759af11d35dc650e2c"
154
+ "gitHead": "8004fc8b869a8c7f3babe365a0e9db26f4f80518"
145
155
  }