@cedarjs/internal 0.6.1-next.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/ast.d.ts.map +1 -1
  2. package/dist/ast.js +28 -64
  3. package/dist/build/api.js +22 -56
  4. package/dist/cjs/ast.d.ts +26 -0
  5. package/dist/cjs/ast.d.ts.map +1 -0
  6. package/dist/cjs/ast.js +201 -0
  7. package/dist/cjs/build/api.d.ts +6 -0
  8. package/dist/cjs/build/api.d.ts.map +1 -0
  9. package/dist/cjs/build/api.js +109 -0
  10. package/dist/cjs/cliLogger.d.ts +11 -0
  11. package/dist/cjs/cliLogger.d.ts.map +1 -0
  12. package/dist/cjs/cliLogger.js +36 -0
  13. package/dist/cjs/dev.d.ts +2 -0
  14. package/dist/cjs/dev.d.ts.map +1 -0
  15. package/dist/cjs/dev.js +41 -0
  16. package/dist/cjs/files.d.ts +56 -0
  17. package/dist/cjs/files.d.ts.map +1 -0
  18. package/dist/cjs/files.js +230 -0
  19. package/dist/cjs/generate/clientPreset.d.ts +17 -0
  20. package/dist/cjs/generate/clientPreset.d.ts.map +1 -0
  21. package/dist/cjs/generate/clientPreset.js +85 -0
  22. package/dist/cjs/generate/generate.d.ts +10 -0
  23. package/dist/cjs/generate/generate.d.ts.map +1 -0
  24. package/dist/cjs/generate/generate.js +91 -0
  25. package/dist/cjs/generate/graphqlCodeGen.d.ts +16 -0
  26. package/dist/cjs/generate/graphqlCodeGen.d.ts.map +1 -0
  27. package/dist/cjs/generate/graphqlCodeGen.js +346 -0
  28. package/dist/cjs/generate/graphqlSchema.d.ts +8 -0
  29. package/dist/cjs/generate/graphqlSchema.d.ts.map +1 -0
  30. package/dist/cjs/generate/graphqlSchema.js +154 -0
  31. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts +7 -0
  32. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -0
  33. package/dist/cjs/generate/plugins/rw-typescript-resolvers/index.js +65 -0
  34. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts +9 -0
  35. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -0
  36. package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.js +84 -0
  37. package/dist/cjs/generate/possibleTypes.d.ts +36 -0
  38. package/dist/cjs/generate/possibleTypes.d.ts.map +1 -0
  39. package/dist/cjs/generate/possibleTypes.js +106 -0
  40. package/dist/cjs/generate/templates/all-currentUser.d.ts.template +30 -0
  41. package/dist/cjs/generate/templates/api-globImports.d.ts.template +9 -0
  42. package/dist/cjs/generate/templates/api-globalContext.d.ts.template +7 -0
  43. package/dist/cjs/generate/templates/api-scenarios.d.ts.template +10 -0
  44. package/dist/cjs/generate/templates/api-test-globals.d.ts.template +5 -0
  45. package/dist/cjs/generate/templates/mirror-cell.d.ts.template +13 -0
  46. package/dist/cjs/generate/templates/mirror-directoryNamedModule.d.ts.template +5 -0
  47. package/dist/cjs/generate/templates/web-routerRoutes.d.ts.template +20 -0
  48. package/dist/cjs/generate/templates/web-routesPages.d.ts.template +13 -0
  49. package/dist/cjs/generate/templates/web-test-globals.d.ts.template +7 -0
  50. package/dist/cjs/generate/templates.d.ts +6 -0
  51. package/dist/cjs/generate/templates.d.ts.map +1 -0
  52. package/dist/cjs/generate/templates.js +68 -0
  53. package/dist/cjs/generate/trustedDocuments.d.ts +3 -0
  54. package/dist/cjs/generate/trustedDocuments.d.ts.map +1 -0
  55. package/dist/cjs/generate/trustedDocuments.js +95 -0
  56. package/dist/cjs/generate/typeDefinitions.d.ts +30 -0
  57. package/dist/cjs/generate/typeDefinitions.d.ts.map +1 -0
  58. package/dist/cjs/generate/typeDefinitions.js +369 -0
  59. package/dist/cjs/generate/types.d.ts +6 -0
  60. package/dist/cjs/generate/types.d.ts.map +1 -0
  61. package/dist/cjs/generate/types.js +16 -0
  62. package/dist/cjs/generate/watch.d.ts +3 -0
  63. package/dist/cjs/generate/watch.d.ts.map +1 -0
  64. package/dist/cjs/generate/watch.js +124 -0
  65. package/dist/cjs/gql.d.ts +14 -0
  66. package/dist/cjs/gql.d.ts.map +1 -0
  67. package/dist/cjs/gql.js +108 -0
  68. package/dist/cjs/index.d.ts +11 -0
  69. package/dist/cjs/index.d.ts.map +1 -0
  70. package/dist/cjs/index.js +49 -0
  71. package/dist/cjs/jsx.d.ts +16 -0
  72. package/dist/cjs/jsx.d.ts.map +1 -0
  73. package/dist/cjs/jsx.js +101 -0
  74. package/dist/cjs/jsxAttributeValue.d.ts +2 -0
  75. package/dist/cjs/jsxAttributeValue.d.ts.map +1 -0
  76. package/dist/cjs/jsxAttributeValue.js +129 -0
  77. package/dist/cjs/package.json +1 -0
  78. package/dist/cjs/project.d.ts +8 -0
  79. package/dist/cjs/project.d.ts.map +1 -0
  80. package/dist/cjs/project.js +82 -0
  81. package/dist/cjs/routes.d.ts +42 -0
  82. package/dist/cjs/routes.d.ts.map +1 -0
  83. package/dist/cjs/routes.js +111 -0
  84. package/dist/cjs/ts2js.d.ts +40 -0
  85. package/dist/cjs/ts2js.d.ts.map +1 -0
  86. package/dist/cjs/ts2js.js +159 -0
  87. package/dist/cjs/validateSchema.d.ts +14 -0
  88. package/dist/cjs/validateSchema.d.ts.map +1 -0
  89. package/dist/cjs/validateSchema.js +194 -0
  90. package/dist/cliLogger.js +4 -28
  91. package/dist/dev.js +4 -38
  92. package/dist/files.d.ts.map +1 -1
  93. package/dist/files.js +46 -95
  94. package/dist/generate/clientPreset.js +17 -39
  95. package/dist/generate/generate.js +14 -39
  96. package/dist/generate/graphqlCodeGen.d.ts.map +1 -1
  97. package/dist/generate/graphqlCodeGen.js +49 -79
  98. package/dist/generate/graphqlSchema.d.ts.map +1 -1
  99. package/dist/generate/graphqlSchema.js +26 -59
  100. package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts +4 -3
  101. package/dist/generate/plugins/rw-typescript-resolvers/index.d.ts.map +1 -1
  102. package/dist/generate/plugins/rw-typescript-resolvers/index.js +11 -35
  103. package/dist/generate/plugins/rw-typescript-resolvers/visitor.js +10 -31
  104. package/dist/generate/possibleTypes.js +19 -53
  105. package/dist/generate/templates.d.ts.map +1 -1
  106. package/dist/generate/templates.js +14 -42
  107. package/dist/generate/trustedDocuments.js +13 -48
  108. package/dist/generate/typeDefinitions.d.ts +2 -2
  109. package/dist/generate/typeDefinitions.d.ts.map +1 -1
  110. package/dist/generate/typeDefinitions.js +83 -123
  111. package/dist/generate/types.js +0 -16
  112. package/dist/generate/watch.js +55 -63
  113. package/dist/gql.js +16 -42
  114. package/dist/index.d.ts +8 -8
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +13 -47
  117. package/dist/jsx.d.ts.map +1 -1
  118. package/dist/jsx.js +7 -40
  119. package/dist/jsxAttributeValue.js +2 -26
  120. package/dist/project.js +21 -58
  121. package/dist/routes.d.ts +1 -1
  122. package/dist/routes.d.ts.map +1 -1
  123. package/dist/routes.js +12 -48
  124. package/dist/ts2js.d.ts +1 -1
  125. package/dist/ts2js.js +33 -73
  126. package/dist/validateSchema.js +19 -47
  127. package/package.json +91 -31
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export * from '@cedarjs/project-config';
2
- export * from './ts2js';
3
- export * from './dev';
4
- export * from './routes';
5
- export * from './files';
6
- export { generate } from './generate/generate';
7
- export { buildApi } from './build/api';
8
- export * from './validateSchema';
2
+ export * from './ts2js.js';
3
+ export * from './dev.js';
4
+ export * from './routes.js';
5
+ export * from './files.js';
6
+ export { generate } from './generate/generate.js';
7
+ export { buildApi } from './build/api.js';
8
+ export * from './validateSchema.js';
9
9
  export * from '@cedarjs/babel-config';
10
- export { listQueryTypeFieldsInProject } from './gql';
10
+ export { listQueryTypeFieldsInProject } from './gql.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AAExB,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,uBAAuB,CAAA;AAErC,OAAO,EAAE,4BAA4B,EAAE,MAAM,OAAO,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,cAAc,qBAAqB,CAAA;AAGnC,cAAc,uBAAuB,CAAA;AAErC,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA"}
package/dist/index.js CHANGED
@@ -1,49 +1,15 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var index_exports = {};
21
- __export(index_exports, {
22
- buildApi: () => import_api.buildApi,
23
- generate: () => import_generate.generate,
24
- listQueryTypeFieldsInProject: () => import_gql.listQueryTypeFieldsInProject
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
- __reExport(index_exports, require("@cedarjs/project-config"), module.exports);
28
- __reExport(index_exports, require("./ts2js"), module.exports);
29
- __reExport(index_exports, require("./dev"), module.exports);
30
- __reExport(index_exports, require("./routes"), module.exports);
31
- __reExport(index_exports, require("./files"), module.exports);
32
- var import_generate = require("./generate/generate");
33
- var import_api = require("./build/api");
34
- __reExport(index_exports, require("./validateSchema"), module.exports);
35
- __reExport(index_exports, require("@cedarjs/babel-config"), module.exports);
36
- var import_gql = require("./gql");
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
1
+ export * from "@cedarjs/project-config";
2
+ export * from "./ts2js.js";
3
+ export * from "./dev.js";
4
+ export * from "./routes.js";
5
+ export * from "./files.js";
6
+ import { generate } from "./generate/generate.js";
7
+ import { buildApi } from "./build/api.js";
8
+ export * from "./validateSchema.js";
9
+ export * from "@cedarjs/babel-config";
10
+ import { listQueryTypeFieldsInProject } from "./gql.js";
11
+ export {
39
12
  buildApi,
40
13
  generate,
41
- listQueryTypeFieldsInProject,
42
- ...require("@cedarjs/project-config"),
43
- ...require("./ts2js"),
44
- ...require("./dev"),
45
- ...require("./routes"),
46
- ...require("./files"),
47
- ...require("./validateSchema"),
48
- ...require("@cedarjs/babel-config")
49
- });
14
+ listQueryTypeFieldsInProject
15
+ };
package/dist/jsx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAKxC,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAA;IACvB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AACD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAS,KAAK,CAAC,IAAI,QAAQ,MAAM,iBAgB3D,CAAA"}
1
+ {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAUxC,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAA;IACvB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,QAAS,KAAK,CAAC,IAAI,QAAQ,MAAM,iBAgB3D,CAAA"}
package/dist/jsx.js CHANGED
@@ -1,41 +1,9 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var jsx_exports = {};
30
- __export(jsx_exports, {
31
- getJsxElements: () => getJsxElements
32
- });
33
- module.exports = __toCommonJS(jsx_exports);
34
- var import_traverse = __toESM(require("@babel/traverse"));
35
- var import_jsxAttributeValue = require("./jsxAttributeValue");
1
+ import babelTraverse from "@babel/traverse";
2
+ import { getJsxAttributeValue } from "./jsxAttributeValue.js";
3
+ const traverse = babelTraverse.default || babelTraverse;
36
4
  const getJsxElements = (ast, name) => {
37
5
  let elements = [];
38
- (0, import_traverse.default)(ast, {
6
+ traverse(ast, {
39
7
  JSXIdentifier(path) {
40
8
  if (path.node.name === name && path.parentPath.type === "JSXOpeningElement") {
41
9
  if (path?.parentPath?.parentPath?.type === "JSXElement") {
@@ -57,7 +25,7 @@ const getJsxProps = (jsxElement) => {
57
25
  const props = {};
58
26
  for (const a of attributes) {
59
27
  if (typeof a.name.name === "string") {
60
- props[a.name.name] = (0, import_jsxAttributeValue.getJsxAttributeValue)(a.value);
28
+ props[a.name.name] = getJsxAttributeValue(a.value);
61
29
  }
62
30
  }
63
31
  return props;
@@ -94,7 +62,6 @@ const reduceJsxElement = (oldNode, currentNode) => {
94
62
  }
95
63
  return oldNode;
96
64
  };
97
- // Annotate the CommonJS export names for ESM import in node:
98
- 0 && (module.exports = {
65
+ export {
99
66
  getJsxElements
100
- });
67
+ };
@@ -1,26 +1,3 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var jsxAttributeValue_exports = {};
20
- __export(jsxAttributeValue_exports, {
21
- getJsxAttributeValue: () => getJsxAttributeValue
22
- });
23
- module.exports = __toCommonJS(jsxAttributeValue_exports);
24
1
  const getJsxAttributeValue = (expression) => {
25
2
  if (expression === null) {
26
3
  return true;
@@ -123,7 +100,6 @@ const getJsxAttributeValue = (expression) => {
123
100
  }
124
101
  return `${expression.type} is not supported`;
125
102
  };
126
- // Annotate the CommonJS export names for ESM import in node:
127
- 0 && (module.exports = {
103
+ export {
128
104
  getJsxAttributeValue
129
- });
105
+ };
package/dist/project.js CHANGED
@@ -1,54 +1,18 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var project_exports = {};
30
- __export(project_exports, {
31
- getTsConfigs: () => getTsConfigs,
32
- isRealtimeSetup: () => isRealtimeSetup,
33
- isServerFileSetup: () => isServerFileSetup,
34
- isTypeScriptProject: () => isTypeScriptProject
35
- });
36
- module.exports = __toCommonJS(project_exports);
37
- var import_fs = __toESM(require("fs"));
38
- var import_path = __toESM(require("path"));
39
- var import_typescript = require("typescript");
40
- var import_project_config = require("@cedarjs/project-config");
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { parseConfigFileTextToJson } from "typescript";
4
+ import { getPaths } from "@cedarjs/project-config";
41
5
  const getTsConfigs = () => {
42
- const rwPaths = (0, import_project_config.getPaths)();
43
- const apiTsConfigPath = import_path.default.join(rwPaths.api.base, "tsconfig.json");
44
- const webTsConfigPath = import_path.default.join(rwPaths.web.base, "tsconfig.json");
45
- const apiTsConfig = import_fs.default.existsSync(apiTsConfigPath) ? (0, import_typescript.parseConfigFileTextToJson)(
6
+ const rwPaths = getPaths();
7
+ const apiTsConfigPath = path.join(rwPaths.api.base, "tsconfig.json");
8
+ const webTsConfigPath = path.join(rwPaths.web.base, "tsconfig.json");
9
+ const apiTsConfig = fs.existsSync(apiTsConfigPath) ? parseConfigFileTextToJson(
46
10
  apiTsConfigPath,
47
- import_fs.default.readFileSync(apiTsConfigPath, "utf-8")
11
+ fs.readFileSync(apiTsConfigPath, "utf-8")
48
12
  ) : null;
49
- const webTsConfig = import_fs.default.existsSync(webTsConfigPath) ? (0, import_typescript.parseConfigFileTextToJson)(
13
+ const webTsConfig = fs.existsSync(webTsConfigPath) ? parseConfigFileTextToJson(
50
14
  webTsConfigPath,
51
- import_fs.default.readFileSync(webTsConfigPath, "utf-8")
15
+ fs.readFileSync(webTsConfigPath, "utf-8")
52
16
  ) : null;
53
17
  return {
54
18
  api: apiTsConfig?.config ?? null,
@@ -56,27 +20,26 @@ const getTsConfigs = () => {
56
20
  };
57
21
  };
58
22
  const isTypeScriptProject = () => {
59
- const paths = (0, import_project_config.getPaths)();
60
- return import_fs.default.existsSync(import_path.default.join(paths.web.base, "tsconfig.json")) || import_fs.default.existsSync(import_path.default.join(paths.api.base, "tsconfig.json"));
23
+ const paths = getPaths();
24
+ return fs.existsSync(path.join(paths.web.base, "tsconfig.json")) || fs.existsSync(path.join(paths.api.base, "tsconfig.json"));
61
25
  };
62
26
  const isServerFileSetup = () => {
63
- const serverFilePath = import_path.default.join(
64
- (0, import_project_config.getPaths)().api.src,
27
+ const serverFilePath = path.join(
28
+ getPaths().api.src,
65
29
  `server.${isTypeScriptProject() ? "ts" : "js"}`
66
30
  );
67
- return import_fs.default.existsSync(serverFilePath);
31
+ return fs.existsSync(serverFilePath);
68
32
  };
69
33
  const isRealtimeSetup = () => {
70
- const realtimePath = import_path.default.join(
71
- (0, import_project_config.getPaths)().api.lib,
34
+ const realtimePath = path.join(
35
+ getPaths().api.lib,
72
36
  `realtime.${isTypeScriptProject() ? "ts" : "js"}`
73
37
  );
74
- return import_fs.default.existsSync(realtimePath);
38
+ return fs.existsSync(realtimePath);
75
39
  };
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
40
+ export {
78
41
  getTsConfigs,
79
42
  isRealtimeSetup,
80
43
  isServerFileSetup,
81
44
  isTypeScriptProject
82
- });
45
+ };
package/dist/routes.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare function getDuplicateRoutes(): RouteInformation[];
10
10
  /**
11
11
  * Detects any potential duplicate routes and returns a formatted warning message
12
12
  * @see {@link getDuplicateRoutes} for how duplicate routes are detected
13
- * @return {string} Warning message when duplicate routes found, empty string if not
13
+ * @return Warning message when duplicate routes found, empty string if not
14
14
  */
15
15
  export declare function warningForDuplicateRoutes(): string;
16
16
  export interface RWRouteManifestItem {
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,uBAyBjC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,WAcxC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;IACnD,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAE9B;AAED,MAAM,WAAW,SAAU,SAAQ,mBAAmB;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,eAAO,MAAM,gBAAgB,QAAO,SAAS,EAkC5C,CAAA"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,EAAE,CAyBvD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,WAgBxC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;IACnD,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAE9B;AAED,MAAM,WAAW,SAAU,SAAQ,mBAAmB;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,eAAO,MAAM,gBAAgB,QAAO,SAAS,EAkC5C,CAAA"}
package/dist/routes.js CHANGED
@@ -1,46 +1,11 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var routes_exports = {};
30
- __export(routes_exports, {
31
- getDuplicateRoutes: () => getDuplicateRoutes,
32
- getProjectRoutes: () => getProjectRoutes,
33
- warningForDuplicateRoutes: () => warningForDuplicateRoutes
34
- });
35
- module.exports = __toCommonJS(routes_exports);
36
- var import_path = __toESM(require("path"));
37
- var import_project_config = require("@cedarjs/project-config");
38
- var import_util = require("@cedarjs/router/dist/util");
39
- var import_dist = require("@cedarjs/structure/dist/index.js");
40
- const ansis = require("ansis");
1
+ import path from "node:path";
2
+ import ansis from "ansis";
3
+ import { getPaths, getRouteHookForPage } from "@cedarjs/project-config";
4
+ import { getRouteRegexAndParams } from "@cedarjs/router/dist/util";
5
+ import { getProject } from "@cedarjs/structure/dist/index.js";
41
6
  function getDuplicateRoutes() {
42
7
  const duplicateRoutes = [];
43
- const allRoutes = (0, import_dist.getProject)((0, import_project_config.getPaths)().base).router.routes;
8
+ const allRoutes = getProject(getPaths().base).router.routes;
44
9
  const uniqueNames = new Set(
45
10
  allRoutes.filter((route) => route.name !== void 0).map((route) => route.name)
46
11
  );
@@ -78,10 +43,10 @@ function warningForDuplicateRoutes() {
78
43
  return message.trimEnd();
79
44
  }
80
45
  const getProjectRoutes = () => {
81
- const rwProject = (0, import_dist.getProject)((0, import_project_config.getPaths)().base);
46
+ const rwProject = getProject(getPaths().base);
82
47
  const routes = rwProject.getRouter().routes;
83
48
  return routes.map((route) => {
84
- const { matchRegexString, routeParams } = route.isNotFound ? { matchRegexString: null, routeParams: null } : (0, import_util.getRouteRegexAndParams)(route.path);
49
+ const { matchRegexString, routeParams } = route.isNotFound ? { matchRegexString: null, routeParams: null } : getRouteRegexAndParams(route.path);
85
50
  return {
86
51
  name: route.isNotFound ? "NotFoundPage" : route.name,
87
52
  pathDefinition: route.isNotFound ? "notfound" : route.path,
@@ -89,8 +54,8 @@ const getProjectRoutes = () => {
89
54
  id: route.id,
90
55
  isNotFound: route.isNotFound,
91
56
  filePath: route.page?.filePath,
92
- relativeFilePath: route.page?.filePath ? import_path.default.relative((0, import_project_config.getPaths)().web.src, route.page?.filePath) : void 0,
93
- routeHooks: (0, import_project_config.getRouteHookForPage)(route.page?.filePath),
57
+ relativeFilePath: route.page?.filePath ? path.relative(getPaths().web.src, route.page?.filePath) : void 0,
58
+ routeHooks: getRouteHookForPage(route.page?.filePath),
94
59
  renderMode: route.renderMode,
95
60
  matchRegexString,
96
61
  paramNames: routeParams,
@@ -103,9 +68,8 @@ const getProjectRoutes = () => {
103
68
  };
104
69
  });
105
70
  };
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
71
+ export {
108
72
  getDuplicateRoutes,
109
73
  getProjectRoutes,
110
74
  warningForDuplicateRoutes
111
- });
75
+ };
package/dist/ts2js.d.ts CHANGED
@@ -31,7 +31,7 @@ export declare const transformTSToJS: (file: string) => Promise<string> | undefi
31
31
  export declare const getPrettierConfig: () => Promise<any>;
32
32
  /**
33
33
  * Prettify `code` according to the extension in `filename`.
34
- * This will also read a user's `prettier.config.js` file if it exists.
34
+ * This will also read a user's `prettier.config.cjs` file if it exists.
35
35
  *
36
36
  * @param {string} code
37
37
  * @param {string} filename
package/dist/ts2js.js CHANGED
@@ -1,53 +1,14 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var ts2js_exports = {};
30
- __export(ts2js_exports, {
31
- convertTsFilesToJs: () => convertTsFilesToJs,
32
- convertTsProjectToJs: () => convertTsProjectToJs,
33
- convertTsScriptsToJs: () => convertTsScriptsToJs,
34
- getPrettierConfig: () => getPrettierConfig,
35
- prettify: () => prettify,
36
- transformTSToJS: () => transformTSToJS,
37
- typeScriptSourceFiles: () => typeScriptSourceFiles
38
- });
39
- module.exports = __toCommonJS(ts2js_exports);
40
- var import_fs = __toESM(require("fs"));
41
- var import_path = __toESM(require("path"));
42
- var import_core = require("@babel/core");
43
- var import_fast_glob = __toESM(require("fast-glob"));
44
- var import_prettier = require("prettier");
45
- var import_project_config = require("@cedarjs/project-config");
46
- const convertTsProjectToJs = (cwd = (0, import_project_config.getPaths)().base) => {
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { transform } from "@babel/core";
4
+ import fg from "fast-glob";
5
+ import { format } from "prettier";
6
+ import { getPaths } from "@cedarjs/project-config";
7
+ const convertTsProjectToJs = (cwd = getPaths().base) => {
47
8
  const files = typeScriptSourceFiles(cwd);
48
9
  convertTsFilesToJs(cwd, files);
49
10
  };
50
- const convertTsScriptsToJs = (cwd = (0, import_project_config.getPaths)().base) => {
11
+ const convertTsScriptsToJs = (cwd = getPaths().base) => {
51
12
  const files = typeScriptSourceFiles(cwd, "scripts/*.{ts,tsx}");
52
13
  convertTsFilesToJs(cwd, files);
53
14
  };
@@ -58,46 +19,46 @@ const convertTsFilesToJs = async (cwd, files) => {
58
19
  for (const f of files) {
59
20
  const code = await transformTSToJS(f);
60
21
  if (code) {
61
- import_fs.default.writeFileSync(
62
- import_path.default.join(cwd, f.replace(".tsx", ".jsx").replace(".ts", ".js")),
22
+ fs.writeFileSync(
23
+ path.join(cwd, f.replace(".tsx", ".jsx").replace(".ts", ".js")),
63
24
  code,
64
25
  "utf8"
65
26
  );
66
- import_fs.default.unlinkSync(import_path.default.join(cwd, f));
27
+ fs.unlinkSync(path.join(cwd, f));
67
28
  }
68
29
  }
69
- if (import_fs.default.existsSync(import_path.default.join(cwd, "api/tsconfig.json"))) {
70
- import_fs.default.renameSync(
71
- import_path.default.join(cwd, "api/tsconfig.json"),
72
- import_path.default.join(cwd, "api/jsconfig.json")
30
+ if (fs.existsSync(path.join(cwd, "api/tsconfig.json"))) {
31
+ fs.renameSync(
32
+ path.join(cwd, "api/tsconfig.json"),
33
+ path.join(cwd, "api/jsconfig.json")
73
34
  );
74
35
  }
75
- if (import_fs.default.existsSync(import_path.default.join(cwd, "web/tsconfig.json"))) {
76
- import_fs.default.renameSync(
77
- import_path.default.join(cwd, "web/tsconfig.json"),
78
- import_path.default.join(cwd, "web/jsconfig.json")
36
+ if (fs.existsSync(path.join(cwd, "web/tsconfig.json"))) {
37
+ fs.renameSync(
38
+ path.join(cwd, "web/tsconfig.json"),
39
+ path.join(cwd, "web/jsconfig.json")
79
40
  );
80
41
  }
81
- if (import_fs.default.existsSync(import_path.default.join(cwd, "scripts/tsconfig.json"))) {
82
- import_fs.default.renameSync(
83
- import_path.default.join(cwd, "scripts/tsconfig.json"),
84
- import_path.default.join(cwd, "scripts/jsconfig.json")
42
+ if (fs.existsSync(path.join(cwd, "scripts/tsconfig.json"))) {
43
+ fs.renameSync(
44
+ path.join(cwd, "scripts/tsconfig.json"),
45
+ path.join(cwd, "scripts/jsconfig.json")
85
46
  );
86
47
  }
87
48
  };
88
49
  const typeScriptSourceFiles = (cwd, globPattern = "{api,web}/src/**/*.{ts,tsx}") => {
89
50
  console.log(globPattern);
90
- return import_fast_glob.default.sync(globPattern, {
51
+ return fg.sync(globPattern, {
91
52
  cwd,
92
53
  ignore: ["node_modules"]
93
54
  });
94
55
  };
95
56
  const transformTSToJS = (file) => {
96
- const tsCode = import_fs.default.readFileSync(file, "utf8");
97
- const filename = import_path.default.basename(file);
98
- const result = (0, import_core.transform)(tsCode, {
57
+ const tsCode = fs.readFileSync(file, "utf8");
58
+ const filename = path.basename(file);
59
+ const result = transform(tsCode, {
99
60
  filename,
100
- cwd: (0, import_project_config.getPaths)().base,
61
+ cwd: getPaths().base,
101
62
  configFile: false,
102
63
  plugins: [
103
64
  [
@@ -117,14 +78,14 @@ const transformTSToJS = (file) => {
117
78
  };
118
79
  const getPrettierConfig = async () => {
119
80
  try {
120
- const { default: prettierConfig } = await import(`file://${import_path.default.join((0, import_project_config.getPaths)().base, "prettier.config.js")}`);
81
+ const { default: prettierConfig } = await import(`file://${path.join(getPaths().base, "prettier.config.cjs")}`);
121
82
  return prettierConfig;
122
83
  } catch {
123
84
  return void 0;
124
85
  }
125
86
  };
126
87
  const prettierParser = (filename) => {
127
- switch (import_path.default.extname(filename.replace(".template", ""))) {
88
+ switch (path.extname(filename.replace(".template", ""))) {
128
89
  case ".css":
129
90
  return "css";
130
91
  case ".js":
@@ -142,13 +103,12 @@ const prettify = async (code, filename) => {
142
103
  return code;
143
104
  }
144
105
  const prettierConfig = await getPrettierConfig();
145
- return (0, import_prettier.format)(code, {
106
+ return format(code, {
146
107
  ...prettierConfig,
147
108
  parser
148
109
  });
149
110
  };
150
- // Annotate the CommonJS export names for ESM import in node:
151
- 0 && (module.exports = {
111
+ export {
152
112
  convertTsFilesToJs,
153
113
  convertTsProjectToJs,
154
114
  convertTsScriptsToJs,
@@ -156,4 +116,4 @@ const prettify = async (code, filename) => {
156
116
  prettify,
157
117
  transformTSToJS,
158
118
  typeScriptSourceFiles
159
- });
119
+ };