@cedarjs/api-server 1.0.1-next.0 → 1.1.0-rc.33

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(): Promise<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":"AAuEA;;;;GAIG;AACH,wBAAsB,UAAU,kBA6E/B"}
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";
@@ -241,52 +251,63 @@ async function validateSdls() {
241
251
  return false;
242
252
  }
243
253
  }
244
- var IGNORED_API_PATHS = [
245
- "api/dist",
246
- // use this, because using rwjsPaths.api.dist seems to not ignore on first build
247
- rwjsPaths2.api.types,
248
- rwjsPaths2.api.db
249
- ].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;
254
+ async function startWatch() {
255
+ const ignoredApiPaths = [
256
+ // use this, because using cedarPaths.api.dist seems to not ignore on first
257
+ // build
258
+ "api/dist",
259
+ cedarPaths.api.types,
260
+ cedarPaths.api.db
261
+ ].map((path3) => (0, import_project_config2.ensurePosixPath)(path3));
262
+ const ignoredExtensions = [
263
+ ".DS_Store",
264
+ ".db",
265
+ ".sqlite",
266
+ "-journal",
267
+ ".test.js",
268
+ ".test.ts",
269
+ ".scenarios.ts",
270
+ ".scenarios.js",
271
+ ".d.ts",
272
+ ".log"
273
+ ];
274
+ const watcher = import_chokidar.default.watch([cedarPaths.api.src], {
275
+ persistent: true,
276
+ ignoreInitial: true,
277
+ ignored: (file) => {
278
+ const shouldIgnore = file.includes("node_modules") || ignoredApiPaths.some((ignoredPath) => file.includes(ignoredPath)) || ignoredExtensions.some((ext) => file.endsWith(ext));
279
+ return shouldIgnore;
280
+ }
281
+ });
282
+ watcher.on("ready", async () => {
283
+ await buildManager.run({ clean: true, rebuild: false });
284
+ await validateSdls();
285
+ });
286
+ watcher.on("all", async (eventName, filePath) => {
287
+ if (eventName === "addDir" && filePath === cedarPaths.api.base) {
288
+ return;
289
+ }
290
+ if (eventName) {
291
+ if (filePath.includes(".sdl")) {
292
+ const isValid = await validateSdls();
293
+ if (!isValid) {
294
+ return;
295
+ }
280
296
  }
281
297
  }
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
- }
298
+ console.log(
299
+ import_ansis2.default.dim(`[${eventName}] ${filePath.replace(cedarPaths.api.base, "")}`)
300
+ );
301
+ buildManager.cancelScheduledBuild();
302
+ if (eventName === "add" || eventName === "unlink") {
303
+ await buildManager.run({ rebuild: false });
304
+ } else {
305
+ await buildManager.run({ rebuild: true });
306
+ }
307
+ });
308
+ }
309
+ startWatch();
310
+ // Annotate the CommonJS export names for ESM import in node:
311
+ 0 && (module.exports = {
312
+ startWatch
292
313
  });
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(): Promise<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":"AAuEA;;;;GAIG;AACH,wBAAsB,UAAU,kBA6E/B"}
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";
@@ -222,52 +222,64 @@ async function validateSdls() {
222
222
  return false;
223
223
  }
224
224
  }
225
- var IGNORED_API_PATHS = [
226
- "api/dist",
227
- // use this, because using rwjsPaths.api.dist seems to not ignore on first build
228
- rwjsPaths2.api.types,
229
- rwjsPaths2.api.db
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;
225
+ async function startWatch() {
226
+ const ignoredApiPaths = [
227
+ // use this, because using cedarPaths.api.dist seems to not ignore on first
228
+ // build
229
+ "api/dist",
230
+ cedarPaths.api.types,
231
+ cedarPaths.api.db
232
+ ].map((path3) => ensurePosixPath(path3));
233
+ const ignoredExtensions = [
234
+ ".DS_Store",
235
+ ".db",
236
+ ".sqlite",
237
+ "-journal",
238
+ ".test.js",
239
+ ".test.ts",
240
+ ".scenarios.ts",
241
+ ".scenarios.js",
242
+ ".d.ts",
243
+ ".log"
244
+ ];
245
+ const watcher = chokidar.watch([cedarPaths.api.src], {
246
+ persistent: true,
247
+ ignoreInitial: true,
248
+ ignored: (file) => {
249
+ const shouldIgnore = file.includes("node_modules") || ignoredApiPaths.some((ignoredPath) => file.includes(ignoredPath)) || ignoredExtensions.some((ext) => file.endsWith(ext));
250
+ return shouldIgnore;
251
+ }
252
+ });
253
+ watcher.on("ready", async () => {
254
+ await buildManager.run({ clean: true, rebuild: false });
255
+ await validateSdls();
256
+ });
257
+ watcher.on("all", async (eventName, filePath) => {
258
+ if (eventName === "addDir" && filePath === cedarPaths.api.base) {
259
+ return;
260
+ }
261
+ if (eventName) {
262
+ if (filePath.includes(".sdl")) {
263
+ const isValid = await validateSdls();
264
+ if (!isValid) {
265
+ return;
266
+ }
261
267
  }
262
268
  }
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
- });
269
+ console.log(
270
+ ansis2.dim(`[${eventName}] ${filePath.replace(cedarPaths.api.base, "")}`)
271
+ );
272
+ buildManager.cancelScheduledBuild();
273
+ if (eventName === "add" || eventName === "unlink") {
274
+ await buildManager.run({ rebuild: false });
275
+ } else {
276
+ await buildManager.run({ rebuild: true });
277
+ }
278
+ });
279
+ }
280
+ if (import.meta.url === `file://${process.argv[1]}`) {
281
+ startWatch();
282
+ }
283
+ export {
284
+ startWatch
285
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api-server",
3
- "version": "1.0.1-next.0+5d18bf5dc",
3
+ "version": "1.1.0-rc.33",
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.1-next.0+5d18bf5dc",
101
- "@cedarjs/fastify-web": "1.0.1-next.0+5d18bf5dc",
102
- "@cedarjs/internal": "1.0.1-next.0+5d18bf5dc",
103
- "@cedarjs/project-config": "1.0.1-next.0+5d18bf5dc",
104
- "@cedarjs/web-server": "1.0.1-next.0+5d18bf5dc",
110
+ "@cedarjs/context": "1.1.0-rc.33",
111
+ "@cedarjs/fastify-web": "1.1.0-rc.33",
112
+ "@cedarjs/internal": "1.1.0-rc.33",
113
+ "@cedarjs/project-config": "1.1.0-rc.33",
114
+ "@cedarjs/web-server": "1.1.0-rc.33",
105
115
  "@fastify/multipart": "8.3.1",
106
116
  "@fastify/url-data": "5.4.0",
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",
131
+ "@cedarjs/framework-tools": "1.1.0-rc.33",
122
132
  "@types/aws-lambda": "8.10.152",
123
133
  "@types/dotenv-defaults": "^2.0.4",
124
134
  "@types/qs": "6.9.16",
@@ -130,7 +140,7 @@
130
140
  "vitest": "3.2.4"
131
141
  },
132
142
  "peerDependencies": {
133
- "@cedarjs/graphql-server": "1.0.0"
143
+ "@cedarjs/graphql-server": "1.1.0-rc.33"
134
144
  },
135
145
  "peerDependenciesMeta": {
136
146
  "@cedarjs/graphql-server": {
@@ -140,5 +150,5 @@
140
150
  "publishConfig": {
141
151
  "access": "public"
142
152
  },
143
- "gitHead": "5d18bf5dc354ad0d1446e8cc45fcad3d08cad5e7"
153
+ "gitHead": "86cce410c6f5611663ebcdb11df912f35d0b17fb"
144
154
  }